|
Data Structures | |
| struct | block_request |
| A block device request. More... | |
| struct | block_device |
| A block device. More... | |
Modules | |
| DataFlash® Block Device | |
Typedefs | |
| typedef uint32_t | block_addr_t |
| Type for holding a logical block address (LBA). | |
| typedef uint32_t | block_len_t |
| Type for holding a block length (i.e. number of blocks). | |
Enumerations | |
| enum | block_device_flag { BDEV_UNIT_ATTENTION, BDEV_PRESENT, BDEV_WRITEABLE } |
Flags representing the state of a block device. More... | |
| enum | block_operation { BLK_OP_READ, BLK_OP_WRITE } |
Block device operation codes. More... | |
Functions | |
| static uint16_t | blkdev_get_block_size (struct block_device *bdev) |
| Return the block size of bdev. | |
| static void | blkdev_set_block_size (struct block_device *bdev, uint16_t block_size) |
| Set the block size of bdev. | |
| struct block_request * | block_alloc_request (struct block_device *bdev) |
| Allocate a block request. | |
| void | block_free_request (struct block_device *bdev, struct block_request *req) |
| Free a block request previously allocated using block_alloc_request(). | |
| static void | block_prepare_req (struct block_device *bdev, struct block_request *req, block_addr_t lba, block_len_t nr_blocks, enum block_operation operation) |
| Prepare a block request. | |
| static void | block_submit_req (struct block_device *bdev, struct block_request *req) |
| Submit a request for I/O. | |
| static int | block_submit_buf_list (struct block_device *bdev, struct block_request *breq, struct slist *buf_list) |
| Submit a list of buffers for an already-queued request. | |
| static block_len_t | blk_req_get_blocks_xfered (struct block_device *bdev, struct block_request *breq) |
| Get the number of blocks actually transfered for a request. | |
| static block_len_t | blk_req_get_bytes_xfered (struct block_device *bdev, struct block_request *breq) |
| Get the number of bytes actually transfered for a request. | |
| static void | blk_req_add_buffer (struct block_request *req, struct buffer *buf) |
| Associate the buffer buf with the block request req. | |
| static void | blk_req_add_buffer_list (struct block_request *req, struct slist *list) |
| Associated the list of buffers list with the block request req. | |
| typedef uint32_t block_addr_t |
| typedef uint32_t block_len_t |
| enum block_device_flag |
| enum block_operation |
| static void blk_req_add_buffer | ( | struct block_request * | req, | |
| struct buffer * | buf | |||
| ) | [inline, static] |
Associate the buffer buf with the block request req.
Definition at line 339 of file device.h.
References block_request::buf_list, buffer::node, and slist_insert_tail().
| static void blk_req_add_buffer_list | ( | struct block_request * | req, | |
| struct slist * | list | |||
| ) | [inline, static] |
Associated the list of buffers list with the block request req.
list will be empty when this function returns
Definition at line 351 of file device.h.
References block_request::buf_list, and slist_move_to_tail().
| static block_len_t blk_req_get_blocks_xfered | ( | struct block_device * | bdev, | |
| struct block_request * | breq | |||
| ) | [inline, static] |
Get the number of blocks actually transfered for a request.
This function returns the number of blocks actually transfered. May be less than requested if an error occurred.
This number is updated before each time buf_list_done() and req_done() is called. Note that when buf_list_done() is called for write requests, this indicates the number of blocks transfered to the controller, which may be more than the number of blocks written to the underlying storage.
Definition at line 308 of file device.h.
References assert, block_request::bdev, and blkdev_get_block_size().
| static block_len_t blk_req_get_bytes_xfered | ( | struct block_device * | bdev, | |
| struct block_request * | breq | |||
| ) | [inline, static] |
Get the number of bytes actually transfered for a request.
This function returns the number of bytes actually transfered. May be less than requested if an error occurred.
This number is updated before each time buf_list_done() and req_done() is called. Note that when buf_list_done() is called for write requests, this indicates the number of bytes transfered to the controller, which may be more than the number of bytes written to the underlying storage.
Definition at line 328 of file device.h.
References assert, and block_request::bdev.
| static uint16_t blkdev_get_block_size | ( | struct block_device * | bdev | ) | [inline, static] |
Return the block size of bdev.
This returns the size in bytes of the smallest addressable unit that make up bdev. It is highly recommended to use this function rather than accessing block_device::block_size directly, as the latter may be replaced by a compile-time constant in some applications. A constant block size may eliminate some expensive calculations at run time, thus making the code smaller and faster.
| bdev | The block device to query |
Definition at line 173 of file device.h.
References block_device::block_size.
Referenced by blk_req_get_blocks_xfered(), msc_do_read(), msc_read_worker(), msc_submit_read_buffers(), and msc_submit_write_data_req().
| static void blkdev_set_block_size | ( | struct block_device * | bdev, | |
| uint16_t | block_size | |||
| ) | [inline, static] |
Set the block size of bdev.
This changes the block size of bdev to be block_size bytes. If CONFIG_BLOCK_FIXED_BLOCK_SIZE is set, this is the only legal value for block_size.
| bdev | The block device to query | |
| block_size | The new block size of bdev in bytes |
Definition at line 192 of file device.h.
References assert, and block_device::block_size.
Referenced by dataflash_detect().
| struct block_request* block_alloc_request | ( | struct block_device * | bdev | ) | [read] |
Allocate a block request.
| bdev | Block device which will handle the request |
Definition at line 53 of file block_core.c.
References block_device::alloc_req, assert, block_request::bdev, dbg_warning, and likely.
| void block_free_request | ( | struct block_device * | bdev, | |
| struct block_request * | req | |||
| ) |
Free a block request previously allocated using block_alloc_request().
| bdev | The block device for which req was allocated | |
| req | The block request object to be freed. |
Definition at line 77 of file block_core.c.
References assert, block_request::bdev, and block_device::free_req.
| static void block_prepare_req | ( | struct block_device * | bdev, | |
| struct block_request * | req, | |||
| block_addr_t | lba, | |||
| block_len_t | nr_blocks, | |||
| enum block_operation | operation | |||
| ) | [inline, static] |
Prepare a block request.
This function will initialize a block_request structure with default values (no buffers, no bytes transferred, etc.) The req_submit() field will point to the function that will start the operation indicated by operation.
| bdev | The block device which should handle the request | |
| req | The block request to be initialized | |
| lba | The Logical Block Address of the first block | |
| nr_blocks | The number of blocks to operate on | |
| operation | One of the operations defined by block_operation. |
Definition at line 222 of file device.h.
References assert, block_request::bdev, and block_device::prepare_req.
| static int block_submit_buf_list | ( | struct block_device * | bdev, | |
| struct block_request * | breq, | |||
| struct slist * | buf_list | |||
| ) | [inline, static] |
Submit a list of buffers for an already-queued request.
This function will atomically submit a list of buffers for transfering data associated with a block request. If the request has already failed before the buffers are queued, this function will leave the buffers alone and return -STATUS_FLUSHED. The caller is responsible for cleaning up the buffer list when this happens.
| bdev | The block device handling the request | |
| breq | The block request associated with the buffers | |
| buf_list | List of buffers to be submitted |
| 0 | The buffers were successfully submitted | |
| -STATUS_FLUSHED | breq is not queued (i.e. it might have encountered an error.) |
Definition at line 287 of file device.h.
References assert, and block_request::bdev.
Referenced by msc_submit_read_buffers().
| static void block_submit_req | ( | struct block_device * | bdev, | |
| struct block_request * | req | |||
| ) | [inline, static] |
Submit a request for I/O.
| bdev | The Block Device to handle the request. | |
| req | This request |
Definition at line 240 of file device.h.
References assert, and block_request::bdev.
1.6.3