[bio][flash] Added bio ioctl to return memory mapped address without putting the device into linear mode

This commit is contained in:
Gurjant Kalsi
2015-11-11 15:27:58 -08:00
parent 6a9df9aaed
commit d9a97e7c0d
4 changed files with 14 additions and 6 deletions

View File

@@ -139,6 +139,7 @@ static inline bool bio_contains_range(uint64_t container_start, uint64_t contain
/* generic bio ioctls */
enum bio_ioctl_num {
BIO_IOCTL_NULL = 0,
BIO_IOCTL_GET_MEM_MAP, /* if supported, request a pointer to the memory map of the device */
BIO_IOCTL_PUT_MEM_MAP, /* if needed, return the pointer (to 'close' the map) */
BIO_IOCTL_GET_MEM_MAP, /* if supported, request a pointer to the memory map of the device */
BIO_IOCTL_PUT_MEM_MAP, /* if needed, return the pointer (to 'close' the map) */
BIO_IOCTL_GET_MAP_ADDR, /* if supported, request a pointer to the memory map without putting the device into linear mode */
};

View File

@@ -238,6 +238,7 @@ static int stm32_flash_ioctl(struct bdev *bdev, int request, void *argp)
int ret = ERR_NOT_SUPPORTED;
switch (request) {
case BIO_IOCTL_GET_MAP_ADDR:
case BIO_IOCTL_GET_MEM_MAP:
/* we're already mapped */
if (argp)

View File

@@ -392,17 +392,19 @@ finish:
static int spiflash_ioctl(struct bdev* device, int request, void* argp)
{
int ret = ERR_NOT_SUPPORTED;
int ret = NO_ERROR;
switch (request) {
case BIO_IOCTL_GET_MEM_MAP:
/* put the device into linear mode */
ret = qspi_enable_linear();
if (ret != NO_ERROR)
break;
// Fallthrough.
case BIO_IOCTL_GET_MAP_ADDR:
if (argp)
*(void **)argp = (void*)QSPI_BASE;
break;
default:
ret = ERR_NOT_SUPPORTED;
}
return ret;

View File

@@ -419,11 +419,13 @@ static int spiflash_ioctl(struct bdev *bdev, int request, void *argp)
{
LTRACEF("dev %p, request %d, argp %p\n", bdev, request, argp);
int ret = ERR_NOT_SUPPORTED;
int ret = NO_ERROR;
switch (request) {
case BIO_IOCTL_GET_MEM_MAP:
/* put the device into linear mode */
ret = qspi_enable_linear(&flash.qspi);
// Fallthrough.
case BIO_IOCTL_GET_MAP_ADDR:
if (argp)
*(void **)argp = (void *)QSPI_LINEAR_BASE;
break;
@@ -431,6 +433,8 @@ static int spiflash_ioctl(struct bdev *bdev, int request, void *argp)
/* put the device back into regular mode */
ret = qspi_disable_linear(&flash.qspi);
break;
default:
ret = ERR_NOT_SUPPORTED;
}
return ret;