RTEMS 6.1-rc6
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
 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_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.
 

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

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.

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.

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.