![]() |
RTEMS 6.2-rc3
|
Generic Flash API to wrap specific device drivers. More...
Data Structures | |
| struct | rtems_flashdev_region |
| General definition for on flash device. More... | |
| struct | rtems_flashdev_region_table |
| Struct holding region definitions. More... | |
| struct | rtems_flashdev_ioctl_page_info |
| Page information returned from IOCTL calls. More... | |
| struct | rtems_flashdev_ioctl_sector_info |
| Sector information returned from IOCTL calls. More... | |
| struct | rtems_flashdev_ioctl_sector_health |
| Sector information returned from IOCTL calls. More... | |
| struct | rtems_flashdev_ioctl_oob_rw_info |
| Read/write information used with OOB IOCTL calls. More... | |
| struct | rtems_flashdev |
| Flash device. More... | |
Macros | |
| #define | RTEMS_FLASHDEV_IOCTL_OBTAIN 0 |
| Obtains the flash device. | |
| #define | RTEMS_FLASHDEV_IOCTL_RELEASE 1 |
| Releases the flash device. | |
| #define | RTEMS_FLASHDEV_IOCTL_JEDEC_ID 2 |
| Returns the JEDEC ID of the flash device. This IOCTL call is informational only. | |
| #define | RTEMS_FLASHDEV_IOCTL_ERASE 3 |
| Erases flash device. | |
| #define | RTEMS_FLASHDEV_IOCTL_REGION_SET 4 |
| Set a region that limits read, write and erase calls to within it. Regions are file descriptor specific and limited to a single region per file descriptor and 32 regions total per flash device. Regions can be changed or updated by calling this IOCTL again. | |
| #define | RTEMS_FLASHDEV_IOCTL_REGION_UNSET 5 |
| Removes the set region on the file descriptor. | |
| #define | RTEMS_FLASHDEV_IOCTL_TYPE 6 |
| Returns the type of flash device (e.g. NOR or NAND). | |
| #define | RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_OFFSET 7 |
| Get the size and address of flash page at given offset. | |
| #define | RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_INDEX 8 |
| Get the size and address of nth flash page where n is index passed in. | |
| #define | RTEMS_FLASHDEV_IOCTL_PAGE_COUNT 9 |
| Get the number of pages in flash device. | |
| #define | RTEMS_FLASHDEV_IOCTL_WRITE_BLOCK_SIZE 10 |
| Get the minimum write size supported by the driver. | |
| #define | RTEMS_FLASHDEV_IOCTL_SECTORINFO_BY_OFFSET 11 |
| Get the size and address of flash erase sector at given offset. | |
| #define | RTEMS_FLASHDEV_IOCTL_SECTOR_COUNT 12 |
| Get the number of erase sectors in flash device. | |
| #define | RTEMS_FLASHDEV_IOCTL_REGION_SECTORINFO_BY_OFFSET 13 |
| Get the size and address of flash erase sector at given offset. | |
| #define | RTEMS_FLASHDEV_IOCTL_OOB_BYTES_PER_PAGE 14 |
| Get the number of bytes per page of out of band space. | |
| #define | RTEMS_FLASHDEV_IOCTL_REGION_OOB_READ 15 |
| Read bytes from the out of band space. | |
| #define | RTEMS_FLASHDEV_IOCTL_REGION_OOB_WRITE 16 |
| Read bytes from the out of band space. | |
| #define | RTEMS_FLASHDEV_IOCTL_REGION_SECTOR_MARK_BAD 17 |
| Mark a sector as bad. | |
| #define | RTEMS_FLASHDEV_IOCTL_REGION_SECTOR_HEALTH 18 |
| Check whether a sector is bad. | |
| #define | RTEMS_FLASHDEV_MAX_REGIONS 32 |
| The maximum number of region limited file descriptors allowed to be open at once. | |
Typedefs | |
| typedef enum rtems_flashdev_flash_type | rtems_flashdev_flash_type |
| Enum for flash type returned from IOCTL call. | |
| typedef struct rtems_flashdev_region | rtems_flashdev_region |
| General definition for on flash device. | |
| typedef struct rtems_flashdev_region_table | rtems_flashdev_region_table |
| Struct holding region definitions. | |
| typedef struct rtems_flashdev_ioctl_page_info | rtems_flashdev_ioctl_page_info |
| Page information returned from IOCTL calls. | |
| typedef struct rtems_flashdev_ioctl_sector_info | rtems_flashdev_ioctl_sector_info |
| Sector information returned from IOCTL calls. | |
| typedef struct rtems_flashdev_ioctl_sector_health | rtems_flashdev_ioctl_sector_health |
| Sector information returned from IOCTL calls. | |
| typedef struct rtems_flashdev_ioctl_oob_rw_info | rtems_flashdev_ioctl_oob_rw_info |
| Read/write information used with OOB IOCTL calls. | |
Enumerations | |
| enum | rtems_flashdev_flash_type { RTEMS_FLASHDEV_NOR , RTEMS_FLASHDEV_NAND } |
| Enum for flash type returned from IOCTL call. More... | |
Functions | |
| rtems_flashdev * | rtems_flashdev_alloc_and_init (size_t size) |
| Allocate and initialize the flash device. | |
| int | rtems_flashdev_init (rtems_flashdev *flash) |
| Initialize the flash device. | |
| int | rtems_flashdev_register (rtems_flashdev *flash, const char *flash_path) |
| Register the flash device. | |
| int | rtems_flashdev_unregister (const char *flash_path) |
| Unregister the flash device. | |
| void | rtems_flashdev_destroy (rtems_flashdev *flash) |
| Destroys the flash device. | |
| void | rtems_flashdev_destroy_and_free (rtems_flashdev *flash) |
| Destroys the flash device and frees its memory. | |
Generic Flash API to wrap specific device drivers.
| #define RTEMS_FLASHDEV_IOCTL_ERASE 3 |
Erases flash device.
| [in] | erase_args | Pointer to rtems_flashdev_region struct containing offset and size of erase to be performed. |
| #define RTEMS_FLASHDEV_IOCTL_JEDEC_ID 2 |
Returns the JEDEC ID of the flash device. This IOCTL call is informational only.
| [out] | jedec_id | Pointer to uint32_t in which the JEDEC ID is returned in. |
| #define RTEMS_FLASHDEV_IOCTL_OBTAIN 0 |
Obtains the flash device.
This command has no argument.
| #define RTEMS_FLASHDEV_IOCTL_OOB_BYTES_PER_PAGE 14 |
Get the number of bytes per page of out of band space.
This IOCTL is only applicable to devices which have out of band space, typically NAND.
| [out] | count | size_t containing the number of bytes. |
| #define RTEMS_FLASHDEV_IOCTL_PAGE_COUNT 9 |
Get the number of pages in flash device.
| [out] | count | Integer containing the number of pages. |
| #define RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_INDEX 8 |
Get the size and address of nth flash page where n is index passed in.
The index ignores the region limiting.
| [in,out] | rtems_flashdev_ioctl_page_info | arg Pointer to struct with index and space for return values. |
| #define RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_OFFSET 7 |
Get the size and address of flash page at given offset.
The offset ignores the region limiting. To find page of region limited offset add the base of the region to the desired offset.
| [in,out] | rtems_flashdev_ioctl_page_info | arg Pointer to struct with offset and space for return values. |
| #define RTEMS_FLASHDEV_IOCTL_REGION_OOB_READ 15 |
Read bytes from the out of band space.
This IOCTL is only applicable to devices which have out of band space, typically NAND.
| [in,out] | rtems_flashdev_ioctl_oob_rw_info | arg Pointer to struct with offset and space for return values. |
| #define RTEMS_FLASHDEV_IOCTL_REGION_OOB_WRITE 16 |
Read bytes from the out of band space.
This IOCTL is only applicable to devices which have out of band space, typically NAND.
| [in,out] | rtems_flashdev_ioctl_oob_rw_info | arg Pointer to struct with offset and space for return values. |
| #define RTEMS_FLASHDEV_IOCTL_REGION_SECTOR_HEALTH 18 |
Check whether a sector is bad.
Sectors are referred to as blocks in NAND devices. Not all devices have bad sector management.
| [in,out] | rtems_flashdev_ioctl_sector_health | arg Pointer to struct with offset and return value. |
| #define RTEMS_FLASHDEV_IOCTL_REGION_SECTOR_MARK_BAD 17 |
Mark a sector as bad.
Sectors are referred to as blocks in NAND devices. Not all devices have bad sector management.
| [in,out] | off_t | arg Pointer to a off_t holding the offset of the sector to be marked bad |
| #define RTEMS_FLASHDEV_IOCTL_REGION_SECTORINFO_BY_OFFSET 13 |
Get the size and address of flash erase sector at given offset.
The offset ignores the region limiting. To find sector of region limited offset add the base of the region to the desired offset.
| [in,out] | rtems_flashdev_ioctl_sector_info | arg Pointer to struct with offset and space for return values. |
| #define RTEMS_FLASHDEV_IOCTL_REGION_SET 4 |
Set a region that limits read, write and erase calls to within it. Regions are file descriptor specific and limited to a single region per file descriptor and 32 regions total per flash device. Regions can be changed or updated by calling this IOCTL again.
| [in] | region | Pointer to rtems_flashdev_region struct containing base and length of defined region. |
| #define RTEMS_FLASHDEV_IOCTL_REGION_UNSET 5 |
Removes the set region on the file descriptor.
This command has no argument.
| #define RTEMS_FLASHDEV_IOCTL_RELEASE 1 |
Releases the flash device.
This command has no argument.
| #define RTEMS_FLASHDEV_IOCTL_SECTOR_COUNT 12 |
Get the number of erase sectors in flash device.
| [out] | count | Integer containing the number of sectors. |
| #define RTEMS_FLASHDEV_IOCTL_SECTORINFO_BY_OFFSET 11 |
Get the size and address of flash erase sector at given offset.
The offset ignores the region limiting. To find sector of region limited offset add the base of the region to the desired offset.
| [in,out] | rtems_flashdev_ioctl_sector_info | arg Pointer to struct with offset and space for return values. |
| #define RTEMS_FLASHDEV_IOCTL_TYPE 6 |
Returns the type of flash device (e.g. NOR or NAND).
| [out] | flash_type | Pointer to integer which is set to the flash type macro value. |
| #define RTEMS_FLASHDEV_IOCTL_WRITE_BLOCK_SIZE 10 |
Get the minimum write size supported by the driver.
| [out] | count | Integer containing the minimum write size. |
| rtems_flashdev * rtems_flashdev_alloc_and_init | ( | size_t | size | ) |
Allocate and initialize the flash device.
After a successful allocation and initialization of the flash device it must be destroyed via rtems_flashdev_destroy_and_free().
| [in] | size | The number of bytes to allocate. |
| NULL | Failed to set up flash device. |
| non-NULL | The new flash device. |
| void rtems_flashdev_destroy | ( | rtems_flashdev * | flash | ) |
Destroys the flash device.
This function must only be used on rtems_flashdev instances that have not been registered.
| [in] | flash | The flash device. |
| void rtems_flashdev_destroy_and_free | ( | rtems_flashdev * | flash | ) |
Destroys the flash device and frees its memory.
This function must only be used on rtems_flashdev instances that have not been registered.
| [in] | flash | The flash device. |
| int rtems_flashdev_init | ( | rtems_flashdev * | flash | ) |
Initialize the flash device.
After a successful initialization of the flash device it must be destroyed via rtems_flashdev_destory().
After initialization and before registration read, write, erase, jedec_id and flash_type functions need to be set in the flashdev.
| [in] | flash | The flash device to initialize. |
| 1 | Failed to set up flash device. |
| 0 | Successful set up of flash device. |
| int rtems_flashdev_register | ( | rtems_flashdev * | flash, |
| const char * | flash_path | ||
| ) |
Register the flash device.
This function always claims ownership of the flash device passed to it. Once registered, the flash device can only be destroyed by unregistering it.
After initialization and before registration read, write, erase, jedec_id and flash_type functions need to be set in the flashdev.
| [in] | flash | The flash device. |
| [in] | flash_path | The path to the flash device file. |
| 0 | Successful operation. |
| non-zero | Failed operation. |
| int rtems_flashdev_unregister | ( | const char * | flash_path | ) |
Unregister the flash device.
| [in] | flash | The flash device. |
| 0 | Successful operation. |
| non-zero | Failed operation. |