Skip to content

Commit 1569d20

Browse files
committed
drivers/flash/flash_simulator: Add support for flash_mmap API call
The commit adds implementation of flash_mmap API call. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 0e32c11 commit 1569d20

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/flash/flash_simulator.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,22 @@ static int flash_sim_get_size(const struct device *dev, uint64_t *size)
372372

373373
return 0;
374374
}
375+
376+
static int flash_sim_mmap(const struct device *dev, void **base, uint64_t *size,
377+
uint32_t flags)
378+
{
379+
ARG_UNUSED(dev);
380+
381+
if (flags & ~(FLASH_MMAP_F_READ | FLASH_MMAP_F_WRITE)) {
382+
return -EINVAL;
383+
}
384+
385+
*base = (void *)&mock_flash[0];
386+
*size = (uint64_t)FLASH_SIMULATOR_FLASH_SIZE;
387+
388+
return 0;
389+
}
390+
375391
static const struct flash_parameters *
376392
flash_sim_get_parameters(const struct device *dev)
377393
{
@@ -384,6 +400,7 @@ static DEVICE_API(flash, flash_sim_api) = {
384400
.read = flash_sim_read,
385401
.write = flash_sim_write,
386402
.erase = flash_sim_erase,
403+
.mmap = flash_sim_mmap,
387404
.get_parameters = flash_sim_get_parameters,
388405
.get_size = flash_sim_get_size,
389406
#ifdef CONFIG_FLASH_PAGE_LAYOUT

0 commit comments

Comments
 (0)