RTEMS 6.2-rc3
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions

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_flashdevrtems_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.
 

Detailed Description

Generic Flash API to wrap specific device drivers.

Macro Definition Documentation

◆ RTEMS_FLASHDEV_IOCTL_ERASE

#define RTEMS_FLASHDEV_IOCTL_ERASE   3

Erases flash device.

Parameters
[in]erase_argsPointer to rtems_flashdev_region struct containing offset and size of erase to be performed.

◆ RTEMS_FLASHDEV_IOCTL_JEDEC_ID

#define RTEMS_FLASHDEV_IOCTL_JEDEC_ID   2

Returns the JEDEC ID of the flash device. This IOCTL call is informational only.

Parameters
[out]jedec_idPointer to uint32_t in which the JEDEC ID is returned in.

◆ RTEMS_FLASHDEV_IOCTL_OBTAIN

#define RTEMS_FLASHDEV_IOCTL_OBTAIN   0

Obtains the flash device.

This command has no argument.

◆ RTEMS_FLASHDEV_IOCTL_OOB_BYTES_PER_PAGE

#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.

Parameters
[out]countsize_t containing the number of bytes.

◆ RTEMS_FLASHDEV_IOCTL_PAGE_COUNT

#define RTEMS_FLASHDEV_IOCTL_PAGE_COUNT   9

Get the number of pages in flash device.

Parameters
[out]countInteger containing the number of pages.

◆ RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_INDEX

#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.

Parameters
[in,out]rtems_flashdev_ioctl_page_infoarg Pointer to struct with index and space for return values.

◆ RTEMS_FLASHDEV_IOCTL_PAGEINFO_BY_OFFSET

#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.

Parameters
[in,out]rtems_flashdev_ioctl_page_infoarg Pointer to struct with offset and space for return values.

◆ RTEMS_FLASHDEV_IOCTL_REGION_OOB_READ

#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.

Parameters
[in,out]rtems_flashdev_ioctl_oob_rw_infoarg Pointer to struct with offset and space for return values.

◆ RTEMS_FLASHDEV_IOCTL_REGION_OOB_WRITE

#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.

Parameters
[in,out]rtems_flashdev_ioctl_oob_rw_infoarg Pointer to struct with offset and space for return values.

◆ RTEMS_FLASHDEV_IOCTL_REGION_SECTOR_HEALTH

#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.

Parameters
[in,out]rtems_flashdev_ioctl_sector_healtharg Pointer to struct with offset and return value.

◆ RTEMS_FLASHDEV_IOCTL_REGION_SECTOR_MARK_BAD

#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.

Parameters
[in,out]off_targ Pointer to a off_t holding the offset of the sector to be marked bad

◆ RTEMS_FLASHDEV_IOCTL_REGION_SECTORINFO_BY_OFFSET

#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.

Parameters
[in,out]rtems_flashdev_ioctl_sector_infoarg Pointer to struct with offset and space for return values.

◆ RTEMS_FLASHDEV_IOCTL_REGION_SET

#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.

Parameters
[in]regionPointer to rtems_flashdev_region struct containing base and length of defined region.

◆ RTEMS_FLASHDEV_IOCTL_REGION_UNSET

#define RTEMS_FLASHDEV_IOCTL_REGION_UNSET   5

Removes the set region on the file descriptor.

This command has no argument.

◆ RTEMS_FLASHDEV_IOCTL_RELEASE

#define RTEMS_FLASHDEV_IOCTL_RELEASE   1

Releases the flash device.

This command has no argument.

◆ RTEMS_FLASHDEV_IOCTL_SECTOR_COUNT

#define RTEMS_FLASHDEV_IOCTL_SECTOR_COUNT   12

Get the number of erase sectors in flash device.

Parameters
[out]countInteger containing the number of sectors.

◆ RTEMS_FLASHDEV_IOCTL_SECTORINFO_BY_OFFSET

#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.

Parameters
[in,out]rtems_flashdev_ioctl_sector_infoarg Pointer to struct with offset and space for return values.

◆ RTEMS_FLASHDEV_IOCTL_TYPE

#define RTEMS_FLASHDEV_IOCTL_TYPE   6

Returns the type of flash device (e.g. NOR or NAND).

Parameters
[out]flash_typePointer to integer which is set to the flash type macro value.

◆ RTEMS_FLASHDEV_IOCTL_WRITE_BLOCK_SIZE

#define RTEMS_FLASHDEV_IOCTL_WRITE_BLOCK_SIZE   10

Get the minimum write size supported by the driver.

Parameters
[out]countInteger containing the minimum write size.

Enumeration Type Documentation

◆ rtems_flashdev_flash_type

Enum for flash type returned from IOCTL call.

Enumerator
RTEMS_FLASHDEV_NOR 

The flash device is NOR flash.

RTEMS_FLASHDEV_NAND 

The flash device is NAND flash.

Function Documentation

◆ rtems_flashdev_alloc_and_init()

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().

Parameters
[in]sizeThe number of bytes to allocate.
Return values
NULLFailed to set up flash device.
non-NULLThe new flash device.

◆ rtems_flashdev_destroy()

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.

Parameters
[in]flashThe flash device.

◆ rtems_flashdev_destroy_and_free()

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.

Parameters
[in]flashThe flash device.

◆ rtems_flashdev_init()

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.

Parameters
[in]flashThe flash device to initialize.
Return values
1Failed to set up flash device.
0Successful set up of flash device.

◆ rtems_flashdev_register()

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.

Parameters
[in]flashThe flash device.
[in]flash_pathThe path to the flash device file.
Return values
0Successful operation.
non-zeroFailed operation.

◆ rtems_flashdev_unregister()

int rtems_flashdev_unregister ( const char *  flash_path)

Unregister the flash device.

Parameters
[in]flashThe flash device.
Return values
0Successful operation.
non-zeroFailed operation.