Contiki-Inga 3.x
|
Files | |
file | diskio.c |
DiskIO Abstraction Layer Implementation | |
file | diskio.h |
DiskIO Layer definitions | |
Data Structures | |
struct | diskio_device_info |
Stores the necessary information to identify a device using the diskio-Library. More... | |
Macros | |
#define | DISKIO_DEVICE_TYPE_NOT_RECOGNIZED 0 |
Allows raw access to disks, used by the MBR-Subsystem. | |
#define | DISKIO_MAX_SECTOR_SIZE 512 |
Bigger sectors then this are not supported. More... | |
#define | DISKIO_DEVICE_TYPE_MASK 0x7f |
Mask used to ignore modifiers like the PARTITION flag. | |
Functions | |
void | diskio_print_device_info (struct diskio_device_info *dev) |
Prints information about the specified device. More... | |
int | diskio_read_block (struct diskio_device_info *dev, uint32_t block_address, uint8_t *buffer) |
Reads one block from the specified device and stores it in buffer. More... | |
int | diskio_read_blocks (struct diskio_device_info *dev, uint32_t block_start_address, uint32_t num_blocks, uint8_t *buffer) |
Reads multiple blocks from the specified device. More... | |
int | diskio_write_block (struct diskio_device_info *dev, uint32_t block_address, uint8_t *buffer) |
Writes a single block to the specified device. More... | |
int | diskio_write_blocks_start (struct diskio_device_info *dev, uint32_t block_start_address, uint32_t num_blocks) |
Start writing multiple blocks to the specified device. More... | |
int | diskio_write_blocks_next (struct diskio_device_info *dev, uint8_t *buffer) |
Write next of multiple blocks to the specified device. More... | |
int | diskio_write_blocks_done (struct diskio_device_info *dev) |
Start writing multiple blocks to the specified device. More... | |
void | diskio_set_default_device (struct diskio_device_info *dev) |
Sets the default operation device. More... | |
struct diskio_device_info * | diskio_devices () |
Returns the device-Database. More... | |
int | diskio_detect_devices () |
Creates the internal database of available devices. More... | |
It's normally not important for Filesystem-Drivers to know, what type the underlying storage device is. It's only important that the Driver can write and read on this device. This abstraction layer enabled the filesystem drivers to do exactly that.
#define DISKIO_MAX_SECTOR_SIZE 512 |
Bigger sectors then this are not supported.
May be reduced down to 512 to use less memory.
Definition at line 65 of file diskio.h.
Referenced by diskio_detect_devices().
int diskio_detect_devices | ( | ) |
Creates the internal database of available devices.
Adds virtual devices for multiple Partitions on devices using the MBR-Library. Number of devices in the database is limited by the DISKIO_MAX_DEVICES define. Warning the device numbers may change when calling this function. It should be called once on start but may also be called, if the microSD-Card was ejected to update the device database.
Definition at line 329 of file diskio.c.
References DISKIO_MAX_SECTOR_SIZE, diskio_device_info::first_sector, mbr_primary_partition::lba_first_sector, mbr_primary_partition::lba_num_sectors, mbr_hasPartition(), mbr_init(), mbr_read(), diskio_device_info::num_sectors, diskio_device_info::number, mbr::partition, diskio_device_info::partition, diskio_device_info::sector_size, and diskio_device_info::type.
|
read |
void diskio_print_device_info | ( | struct diskio_device_info * | dev | ) |
Prints information about the specified device.
Output Format:
DiskIO Device Info
type = text
number = X
partition = X
num_sectors = X
sector_size = X
first_sector = X
*dev | the pointer to the device info struct |
Definition at line 73 of file diskio.c.
References diskio_device_info::first_sector, diskio_device_info::num_sectors, diskio_device_info::number, diskio_device_info::partition, diskio_device_info::sector_size, and diskio_device_info::type.
int diskio_read_block | ( | struct diskio_device_info * | dev, |
uint32_t | block_address, | ||
uint8_t * | buffer | ||
) |
Reads one block from the specified device and stores it in buffer.
*dev | the pointer to the device info struct |
block_address | Which block should be read |
*buffer | buffer in which the data is written |
Definition at line 103 of file diskio.c.
Referenced by cfs_fat_mount_device(), cfs_fat_sync_fats(), and mbr_read().
int diskio_read_blocks | ( | struct diskio_device_info * | dev, |
uint32_t | block_start_address, | ||
uint32_t | num_blocks, | ||
uint8_t * | buffer | ||
) |
Reads multiple blocks from the specified device.
This may or may not be supported for every device. DISKIO_ERROR_OPERATION_NOT_SUPPORTED will be returned in that case.
*dev | the pointer to the device info |
block_start_address | the address of the first block to be read |
num_blocks | the number of blocks to be read |
*buffer | buffer in which the data is written |
void diskio_set_default_device | ( | struct diskio_device_info * | dev | ) |
int diskio_write_block | ( | struct diskio_device_info * | dev, |
uint32_t | block_address, | ||
uint8_t * | buffer | ||
) |
Writes a single block to the specified device.
*dev | the pointer to the device info |
block_address | address where the block should be written |
*buffer | buffer in which the data is stored |
Definition at line 115 of file diskio.c.
Referenced by cfs_fat_flush(), cfs_fat_sync_fats(), and mbr_write().
int diskio_write_blocks_done | ( | struct diskio_device_info * | dev | ) |
int diskio_write_blocks_next | ( | struct diskio_device_info * | dev, |
uint8_t * | buffer | ||
) |
int diskio_write_blocks_start | ( | struct diskio_device_info * | dev, |
uint32_t | block_start_address, | ||
uint32_t | num_blocks | ||
) |
Start writing multiple blocks to the specified device.
*dev | the pointer to the device info |
block_start_address | the address of the first block to be written |
num_blocks | number of blocks to be written |
Definition at line 121 of file diskio.c.
References NULL.