summaryrefslogtreecommitdiffstats
path: root/cpukit/libblock/include/rtems
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2008-07-29 02:21:15 +0000
committerChris Johns <chrisj@rtems.org>2008-07-29 02:21:15 +0000
commit3899a5379f4bfa067e73b4612a547a308a6634ec (patch)
treef837533ace01e934da6089cdca360822d85cc662 /cpukit/libblock/include/rtems
parent2008-07-27 Ralf Corsépius <ralf.corsepius@rtems.org> (diff)
downloadrtems-3899a5379f4bfa067e73b4612a547a308a6634ec.tar.bz2
2008-07-29 Chris Johns <chrisj@rtems.org>
* libblock/Makefile.am: Removed src/show_bdbuf.c. * libblock/src/show_bdbuf.c: Removed. * libblock/include/rtems/bdbuf.h, cpukit/libblock/src/bdbuf.c: Rewritten the bdbuf code. Remove pre-emption disable, score access, fixed many bugs and increased performance. * libblock/include/rtems/blkdev.h: Added RTEMS_BLKDEV_CAPABILITIES block device request. Cleaned up comments. Added block and user fields to the sg buffer request. Move to rtems_* namespace. * libblock/include/rtems/diskdevs.h, cpukit/libblock/src/diskdevs.c: Move to rtems_* namespace. Add a capabilities field for drivers. Change rtems_disk_lookup to rtems_disk_obtain to match the release call. You do not lookup and release a disk, you obtain and release a disk. * libblock/include/rtems/ide_part_table.h, libblock/include/rtems/ramdisk.h, libblock/src/ide_part_table.c: Move to rtems_* namespace. * libblock/include/rtems/nvdisk.h: Formatting change. * libblock/src/blkdev.c: Move to rtems_* namespace. Change rtems_disk_lookup to rtems_disk_obtain * libblock/src/flashdisk.c: Move to rtems_* namespace. Use the new support for the block number in the scatter/grather request struct. This allows non-continuous buffer requests for those drivers that can support increasing performance. * libblock/src/nvdisk.c: Move to rtems_* namespace. Removed warnings. Added better error checking. Fixed some comments. * libblock/src/ramdisk.c: Move to rtems_* namespace. Added some trace functions to help debugging upper layers. Use the new support for the block number in the scatter/grather request struct. This allows non-continuous buffer requests for those drivers that can support increasing performance. * libfs/src/dosfs/fat.c, libfs/src/dosfs/fat.h: Use new chains API. Removed temporary hack and changed set_errno_and_return_minus_one to rtems_set_errno_and_return_minus_one. Move fat_buf_access from header and stopped it being inlined. Updated to libblock changes. * libfs/src/dosfs/fat_fat_operations.c, libfs/src/dosfs/fat_file.c, libfs/src/dosfs/msdos_create.c, libfs/src/dosfs/msdos_dir.c, libfs/src/dosfs/msdos_eval.c, libfs/src/dosfs/msdos_file.c, libfs/src/dosfs/msdos_format.c, libfs/src/dosfs/msdos_free.c, libfs/src/dosfs/msdos_initsupp.c, libfs/src/dosfs/msdos_misc.c, libfs/src/dosfs/msdos_mknod.c: Use new chains API. Removed temporary hack and changed set_errno_and_return_minus_one to rtems_set_errno_and_return_minus_one. Updated to libblock changes. * libmisc/Makefile.am: Add new ls and rm command files. * libmisc/shell/cmp-ls.c, libmisc/shell/extern-ls.h, libmisc/shell/filemode.c, libmisc/shell/print-ls.c, libmisc/shell/pwcache.c, libmisc/shell/utils-ls.c, libmisc/shell/vis.c, shell/vis.h: New. * libmisc/shell/extern-cp.h, libmisc/shell/main_cp.c, libmisc/shell/utils-cp.c: Fixed the usage call bug. * libmisc/shell/main_blksync.c: Updated to the new block IO ioctl command. * libmisc/shell/main_ls.c, libmisc/shell/main_rm.c: Updated to BSD commands with more features. * score/src/coremutex.c: Fix the strick order mutex code. * libmisc/shell/shell.c: Change shell tasks mode to be timeslice and no ASR. * sapi/include/confdefs.h: Change ata_driver_task_priority to rtems_ata_driver_task_priority. Add the new BD buf cache parameters with defaults. * score/src/interr.c: Do not return if the CPU halt call returns.
Diffstat (limited to 'cpukit/libblock/include/rtems')
-rw-r--r--cpukit/libblock/include/rtems/bdbuf.h250
-rw-r--r--cpukit/libblock/include/rtems/blkdev.h113
-rw-r--r--cpukit/libblock/include/rtems/diskdevs.h71
-rw-r--r--cpukit/libblock/include/rtems/ide_part_table.h33
-rw-r--r--cpukit/libblock/include/rtems/nvdisk.h2
-rw-r--r--cpukit/libblock/include/rtems/ramdisk.h112
6 files changed, 318 insertions, 263 deletions
diff --git a/cpukit/libblock/include/rtems/bdbuf.h b/cpukit/libblock/include/rtems/bdbuf.h
index f4308963dd..991da1fdaa 100644
--- a/cpukit/libblock/include/rtems/bdbuf.h
+++ b/cpukit/libblock/include/rtems/bdbuf.h
@@ -25,116 +25,143 @@ extern "C" {
#include "rtems/blkdev.h"
#include "rtems/diskdevs.h"
-
-/*
- * To manage buffers we using Buffer Descriptors.
- * To speed-up buffer lookup descriptors are organized in AVL-Tree.
- * The fields 'dev' and 'block' are search key.
+/**
+ * State of a buffer in the cache.
*/
+typedef enum
+{
+ RTEMS_BDBUF_STATE_EMPTY = 0, /* Not in use. */
+ RTEMS_BDBUF_STATE_READ_AHEAD = 1, /* Holds read ahead data only */
+ RTEMS_BDBUF_STATE_CACHED = 2, /* In the cache and available */
+ RTEMS_BDBUF_STATE_ACCESS = 3, /* The user has the buffer */
+ RTEMS_BDBUF_STATE_MODIFIED = 4, /* In the cache but modified */
+ RTEMS_BDBUF_STATE_ACCESS_MODIFIED = 5, /* With the user but modified */
+ RTEMS_BDBUF_STATE_SYNC = 6, /* Requested to be sync'ed */
+ RTEMS_BDBUF_STATE_TRANSFER = 7 /* Being transferred to or from disk */
+} rtems_bdbuf_buf_state;
-/* Buffer descriptors
- * Descriptors organized in AVL-tree to speedup buffer lookup.
- * dev and block fields are search key in AVL-tree.
- * Modified buffers, free buffers and used buffers linked in 'mod', 'free' and
- * 'lru' chains appropriately.
+/**
+ * To manage buffers we using buffer descriptors (BD). A BD holds a buffer plus
+ * a range of other information related to managing the buffer in the cache. To
+ * speed-up buffer lookup descriptors are organized in AVL-Tree. The fields
+ * 'dev' and 'block' are search keys.
*/
+typedef struct rtems_bdbuf_buffer
+{
+ rtems_chain_node link; /* Link in the BD onto a number of lists. */
-typedef struct bdbuf_buffer {
- Chain_Node link; /* Link in the lru, mod or free chains */
-
- struct bdbuf_avl_node {
- signed char cache; /* Cache */
+ struct rtems_bdbuf_avl_node
+ {
+ signed char cache; /* Cache */
+ struct rtems_bdbuf_buffer* left; /* Left Child */
+ struct rtems_bdbuf_buffer* right; /* Right Child */
+ signed char bal; /* The balance of the sub-tree */
+ } avl;
- struct bdbuf_buffer* left; /* Left Child */
- struct bdbuf_buffer* right; /* Right Child */
+ dev_t dev; /* device number */
+ rtems_blkdev_bnum block; /* block number on the device */
- signed char bal; /* The balance of the sub-tree */
- } avl;
+ unsigned char* buffer; /* Pointer to the buffer memory area */
+ int error; /* If not 0 indicate an error value (errno)
+ * which can be used by user later */
- dev_t dev; /* device number */
- blkdev_bnum block; /* block number on the device */
+ volatile rtems_bdbuf_buf_state state; /* State of the buffer. */
- unsigned char *buffer; /* Pointer to the buffer memory area */
- rtems_status_code status; /* Last I/O operation completion status */
- int error; /* If status != RTEMS_SUCCESSFUL, this field contains
- errno value which can be used by user later */
- boolean modified:1; /* =1 if buffer was modified */
- boolean in_progress:1; /* =1 if exchange with disk is in progress;
- need to wait on semaphore */
- boolean actual:1; /* Buffer contains actual data */
- int use_count; /* Usage counter; incremented when somebody use
- this buffer; decremented when buffer released
- without modification or when buffer is flushed
- by swapout task */
+ volatile uint32_t waiters; /* The number of threads waiting on this
+ * buffer. */
+ rtems_bdpool_id pool; /* Identifier of buffer pool to which this buffer
+ belongs */
- rtems_bdpool_id pool; /* Identifier of buffer pool to which this buffer
- belongs */
- CORE_mutex_Control transfer_sema;
- /* Transfer operation semaphore */
-} bdbuf_buffer;
+ volatile uint32_t hold_timer; /* Timer to indicate how long a buffer
+ * has been held in the cache modified. */
+} rtems_bdbuf_buffer;
+/**
+ * The groups of the blocks with the same size are collected in a pool. Note
+ * that a several of the buffer's groups with the same size can exists.
+ */
+typedef struct rtems_bdbuf_pool
+{
+ int blksize; /* The size of the blocks (in bytes) */
+ int nblks; /* Number of blocks in this pool */
+
+ uint32_t flags; /* Configuration flags */
+
+ rtems_id lock; /* The pool lock. Lock this data and
+ * all BDs. */
+ rtems_id sync_lock; /* Sync calls lock writes. */
+ boolean sync_active; /* True if a sync is active. */
+ rtems_id sync_requester; /* The sync requester. */
+ dev_t sync_device; /* The device to sync */
+
+ rtems_bdbuf_buffer* tree; /* Buffer descriptor lookup AVL tree
+ * root */
+ rtems_chain_control ready; /* Free buffers list (or read-ahead) */
+ rtems_chain_control lru; /* Last recently used list */
+ rtems_chain_control modified; /* Modified buffers list */
+ rtems_chain_control sync; /* Buffers to sync list */
+
+ rtems_id access; /* Obtain if waiting for a buffer in the
+ * ACCESS state. */
+ volatile uint32_t access_waiters; /* Count of access blockers. */
+ rtems_id transfer; /* Obtain if waiting for a buffer in the
+ * TRANSFER state. */
+ volatile uint32_t transfer_waiters; /* Count of transfer blockers. */
+ rtems_id waiting; /* Obtain if waiting for a buffer and the
+ * none are available. */
+ volatile uint32_t wait_waiters; /* Count of waiting blockers. */
+
+ rtems_bdbuf_buffer* bds; /* Pointer to table of buffer descriptors
+ * allocated for this buffer pool. */
+ void* buffers; /* The buffer's memory. */
+} rtems_bdbuf_pool;
-/*
- * the following data structures are internal to the bdbuf layer,
- * but it is convenient to have them visible from the outside for inspection
+/**
+ * Configuration structure describes block configuration (size, amount, memory
+ * location) for buffering layer pool.
*/
-/*
- * The groups of the blocks with the same size are collected in the
- * bd_pool. Note that a several of the buffer's groups with the
- * same size can exists.
+typedef struct rtems_bdbuf_pool_config {
+ int size; /* Size of block */
+ int num; /* Number of blocks of appropriate size */
+ unsigned char* mem_area; /* Pointer to the blocks location or NULL, in this
+ * case memory for blocks will be allocated by
+ * Buffering Layer with the help of RTEMS partition
+ * manager */
+} rtems_bdbuf_pool_config;
+
+/**
+ * External references provided by the user for each pool in the system.
*/
-typedef struct bdbuf_pool
-{
- bdbuf_buffer *tree; /* Buffer descriptor lookup AVL tree root */
-
- Chain_Control free; /* Free buffers list */
- Chain_Control lru; /* Last recently used list */
-
- int blksize; /* The size of the blocks (in bytes) */
- int nblks; /* Number of blocks in this pool */
- rtems_id bufget_sema; /* Buffer obtain counting semaphore */
- void *mallocd_bufs; /* Pointer to the malloc'd buffer memory,
- or NULL, if buffer memory provided in
- buffer configuration */
- bdbuf_buffer *bdbufs; /* Pointer to table of buffer descriptors
- allocated for this buffer pool. */
-} bdbuf_pool;
-
-/* Buffering layer context definition */
-struct bdbuf_context {
- bdbuf_pool *pool; /* Table of buffer pools */
- int npools; /* Number of entries in pool table */
-
- Chain_Control mod; /* Modified buffers list */
- rtems_id flush_sema; /* Buffer flush semaphore; counting
- semaphore; incremented when buffer
- flushed to the disk; decremented when
- buffer modified */
- rtems_id swapout_task; /* Swapout task ID */
-};
- /*
- * the context of the buffering layer, visible for inspection
- */
-extern struct bdbuf_context rtems_bdbuf_ctx;
-
-/* bdbuf_config structure describes block configuration (size,
- * amount, memory location) for buffering layer
+extern rtems_bdbuf_pool_config rtems_bdbuf_pool_configuration[];
+extern int rtems_bdbuf_pool_configuration_size;
+
+/**
+ * Buffering configuration definition. See confdefs.h for support on using this
+ * structure.
*/
typedef struct rtems_bdbuf_config {
- int size; /* Size of block */
- int num; /* Number of blocks of appropriate size */
- unsigned char *mem_area;
- /* Pointer to the blocks location or NULL, in this
- case memory for blocks will be allocated by
- Buffering Layer with the help of RTEMS partition
- manager */
+ int max_read_ahead_blocks; /*<< Number of blocks to read ahead. */
+ int max_write_blocks; /*<< Number of blocks to write at once. */
+ rtems_task_priority swapout_priority; /*<< Priority of the swap out task. */
+ uint32_t swapout_period; /*<< Period swapout checks buf timers. */
+ uint32_t swap_block_hold; /*<< Period a buffer is held. */
} rtems_bdbuf_config;
-extern rtems_bdbuf_config rtems_bdbuf_configuration[];
-extern int rtems_bdbuf_configuration_size;
+/**
+ * External referernce to the configuration. The configuration is provided by
+ * the user.
+ */
+extern rtems_bdbuf_config rtems_bdbuf_configuration;
-#define SWAPOUT_TASK_DEFAULT_PRIORITY 15
-extern rtems_task_priority swapout_task_priority;
+/**
+ * The max_read_ahead_blocks value is altered if there are fewer buffers
+ * than this defined max. This stops thrashing in the cache.
+ */
+#define RTEMS_BDBUF_MAX_READ_AHEAD_BLOCKS_DEFAULT 32
+#define RTEMS_BDBUF_MAX_WRITE_BLOCKS_DEFAULT 16
+#define RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT 15
+#define RTEMS_BDBUF_SWAPOUT_TASK_SWAP_PERIOD_DEFAULT 250 /* milli-seconds */
+#define RTEMS_BDBUF_SWAPOUT_TASK_BLOCK_HOLD_DEFAULT 1000 /* milli-seconds */
/* rtems_bdbuf_init --
* Prepare buffering layer to work - initialize buffer descritors
@@ -143,17 +170,12 @@ extern rtems_task_priority swapout_task_priority;
* amount requested. After initialization all blocks is placed into
* free elements lists.
*
- * PARAMETERS:
- * conf_table - pointer to the buffers configuration table
- * size - number of entries in configuration table
- *
* RETURNS:
* RTEMS status code (RTEMS_SUCCESSFUL if operation completed successfully
* or error code if error is occured)
*/
rtems_status_code
-rtems_bdbuf_init(rtems_bdbuf_config *conf_table, int size);
-
+rtems_bdbuf_init ();
/* rtems_bdbuf_get --
* Obtain block buffer. If specified block already cached (i.e. there's
@@ -177,8 +199,8 @@ rtems_bdbuf_init(rtems_bdbuf_config *conf_table, int size);
* SIDE EFFECTS:
* bufget_sema semaphore obtained by this primitive.
*/
-rtems_status_code
-rtems_bdbuf_get(dev_t device, blkdev_bnum block, bdbuf_buffer **bdb_ptr);
+ rtems_status_code
+ rtems_bdbuf_get(dev_t device, rtems_blkdev_bnum block, rtems_bdbuf_buffer** bd);
/* rtems_bdbuf_read --
* (Similar to the rtems_bdbuf_get, except reading data from media)
@@ -201,8 +223,8 @@ rtems_bdbuf_get(dev_t device, blkdev_bnum block, bdbuf_buffer **bdb_ptr);
* SIDE EFFECTS:
* bufget_sema and transfer_sema semaphores obtained by this primitive.
*/
-rtems_status_code
-rtems_bdbuf_read(dev_t device, blkdev_bnum block, bdbuf_buffer **bdb_ptr);
+ rtems_status_code
+ rtems_bdbuf_read(dev_t device, rtems_blkdev_bnum block, rtems_bdbuf_buffer** bd);
/* rtems_bdbuf_release --
* Release buffer allocated before. This primitive decrease the
@@ -223,8 +245,8 @@ rtems_bdbuf_read(dev_t device, blkdev_bnum block, bdbuf_buffer **bdb_ptr);
* SIDE EFFECTS:
* flush_sema and bufget_sema semaphores may be released by this primitive.
*/
-rtems_status_code
-rtems_bdbuf_release(bdbuf_buffer *bd_buf);
+ rtems_status_code
+ rtems_bdbuf_release(rtems_bdbuf_buffer* bd);
/* rtems_bdbuf_release_modified --
* Release buffer allocated before, assuming that it is _modified_ by
@@ -244,8 +266,8 @@ rtems_bdbuf_release(bdbuf_buffer *bd_buf);
* SIDE EFFECTS:
* flush_sema semaphore may be released by this primitive.
*/
-rtems_status_code
-rtems_bdbuf_release_modified(bdbuf_buffer *bd_buf);
+ rtems_status_code
+ rtems_bdbuf_release_modified(rtems_bdbuf_buffer* bd);
/* rtems_bdbuf_sync --
* Wait until specified buffer synchronized with disk. Invoked on exchanges
@@ -265,8 +287,8 @@ rtems_bdbuf_release_modified(bdbuf_buffer *bd_buf);
* SIDE EFFECTS:
* Primitive may be blocked on transfer_sema semaphore.
*/
-rtems_status_code
-rtems_bdbuf_sync(bdbuf_buffer *bd_buf);
+ rtems_status_code
+ rtems_bdbuf_sync(rtems_bdbuf_buffer* bd);
/* rtems_bdbuf_syncdev --
* Synchronize with disk all buffers containing the blocks belonging to
@@ -279,8 +301,8 @@ rtems_bdbuf_sync(bdbuf_buffer *bd_buf);
* RTEMS status code (RTEMS_SUCCESSFUL if operation completed successfully
* or error code if error is occured)
*/
-rtems_status_code
-rtems_bdbuf_syncdev(dev_t dev);
+ rtems_status_code
+ rtems_bdbuf_syncdev(dev_t dev);
/* rtems_bdbuf_find_pool --
* Find first appropriate buffer pool. This primitive returns the index
@@ -297,8 +319,8 @@ rtems_bdbuf_syncdev(dev_t dev);
* of 2), RTEMS_NOT_DEFINED if buffer pool for this or greater block size
* is not configured.
*/
-rtems_status_code
-rtems_bdbuf_find_pool(int block_size, rtems_bdpool_id *pool);
+ rtems_status_code
+ rtems_bdbuf_find_pool(int block_size, rtems_bdpool_id *pool);
/* rtems_bdbuf_get_pool_info --
* Obtain characteristics of buffer pool with specified number.
@@ -316,8 +338,8 @@ rtems_bdbuf_find_pool(int block_size, rtems_bdpool_id *pool);
* NOTE:
* Buffer pools enumerated contiguously starting from 0.
*/
-rtems_status_code
-rtems_bdbuf_get_pool_info(rtems_bdpool_id pool, int *block_size, int *blocks);
+ rtems_status_code
+ rtems_bdbuf_get_pool_info(rtems_bdpool_id pool, int *block_size, int *blocks);
#ifdef __cplusplus
}
diff --git a/cpukit/libblock/include/rtems/blkdev.h b/cpukit/libblock/include/rtems/blkdev.h
index fadbdce9c7..03b639c73c 100644
--- a/cpukit/libblock/include/rtems/blkdev.h
+++ b/cpukit/libblock/include/rtems/blkdev.h
@@ -20,67 +20,92 @@
extern "C" {
#endif
-/* Interface with device drivers
- * Block device looks, initialized and behaves like traditional RTEMS device
- * driver. Heart of the block device driver is in BIOREQUEST ioctl. This call
- * puts I/O request to the block device queue, in priority order, for
- * asynchronous processing. When driver executes request, req_done
- * function invoked, so callee knows about it. Look for details below.
+/*
+ * Interface with device drivers Block device looks, initialized and behaves
+ * like traditional RTEMS device driver. Heart of the block device driver is in
+ * BIOREQUEST ioctl. This call puts I/O request to the block device queue, in
+ * priority order, for asynchronous processing. When driver executes request,
+ * req_done function invoked, so callee knows about it. Look for details below.
*/
-
-/* Block device block number datatype */
-typedef uint32_t blkdev_bnum;
+/*
+ * Block device block number datatype
+ */
+typedef uint32_t rtems_blkdev_bnum;
/* Block device request type */
-typedef enum blkdev_request_op {
- BLKDEV_REQ_READ, /* Read operation */
- BLKDEV_REQ_WRITE /* Write operation */
-} blkdev_request_op;
+typedef enum rtems_blkdev_request_op {
+ RTEMS_BLKDEV_REQ_READ, /* Read operation */
+ RTEMS_BLKDEV_REQ_WRITE, /* Write operation */
+ RTEMS_BLKDEV_CAPABILITIES /* Capabilities request */
+} rtems_blkdev_request_op;
+
+/**
+ * ATA multi-sector buffer requests only supported. This option
+ * means the cache will only supply multiple buffers that are
+ * inorder so the ATA multi-sector command can be used. This is a
+ * hack to work around the current ATA driver.
+ */
+#define RTEMS_BLKDEV_CAP_MULTISECTOR_CONT (1 << 0)
-/* Type for block device request done callback function.
+/*
+ * @typedef rtems_blkdev_request_cb
*
- * PARAMETERS:
- * arg - argument supplied in blkdev_request
- * status - rtems status code for this operation
- * errno - errno value to be passed to the user when
+ * Type for block device request done callback function.
+ *
+ * @param arg Argument supplied in blkdev_request
+ * @param status RTEMS status code for this operation
+ * @param errno errno value to be passed to the user when
* status != RTEMS_SUCCESSFUL
*/
-typedef void (* blkdev_request_cb)(void *arg,
- rtems_status_code status,
- int error);
+typedef void (* rtems_blkdev_request_cb)(void *arg,
+ rtems_status_code status,
+ int error);
-/* blkdev_sg_buffer
+/**
+ * @struct rtems_blkdev_sg_buffer
* Block device scatter/gather buffer structure
*/
-typedef struct blkdev_sg_buffer {
+typedef struct rtems_blkdev_sg_buffer {
+ uint32_t block; /* The block number */
uint32_t length; /* Buffer length */
- void *buffer; /* Buffer pointer */
-} blkdev_sg_buffer;
+ void *buffer; /* Buffer pointer */
+ void *user; /* User pointer */
+} rtems_blkdev_sg_buffer;
/* blkdev_request (Block Device Request) structure is
* used to read/write a number of blocks from/to device.
*/
-typedef struct blkdev_request {
- blkdev_request_op req; /* Block device operation (read or write) */
- blkdev_request_cb req_done; /* Callback function */
- void *done_arg; /* Argument to be passed to callback function*/
- rtems_status_code status; /* Last I/O operation completion status */
- int error; /* If status != RTEMS_SUCCESSFUL, this field
- * contains error code
- */
- blkdev_bnum start; /* Start block number */
- uint32_t count; /* Number of blocks to be exchanged */
- uint32_t bufnum; /* Number of buffers provided */
-
- blkdev_sg_buffer bufs[0];/* List of scatter/gather buffers */
-} blkdev_request;
+typedef struct rtems_blkdev_request {
+ /* Block device operation (read or write) */
+ rtems_blkdev_request_op req;
+ /* Callback function */
+ rtems_blkdev_request_cb req_done;
+ /* Argument to be passed to callback function*/
+ void *done_arg;
+ /* Last I/O operation completion status */
+ rtems_status_code status;
+ /* If status != RTEMS_SUCCESSFUL, this field contains error code */
+ int error;
+ /* Start block number */
+ rtems_blkdev_bnum start;
+ /* Number of blocks to be exchanged */
+ uint32_t count;
+ /* Number of buffers provided */
+ uint32_t bufnum;
+
+ /* The task requesting the IO operation. */
+ rtems_id io_task;
+
+ /* List of scatter/gather buffers */
+ rtems_blkdev_sg_buffer bufs[0];
+} rtems_blkdev_request;
/* Block device IOCTL request codes */
-#define BLKIO_REQUEST _IOWR('B', 1, blkdev_request)
-#define BLKIO_GETBLKSIZE _IO('B', 2)
-#define BLKIO_GETSIZE _IO('B', 3)
-#define BLKIO_SYNCDEV _IO('B', 4)
+#define RTEMS_BLKIO_REQUEST _IOWR('B', 1, rtems_blkdev_request)
+#define RTEMS_BLKIO_GETBLKSIZE _IO('B', 2)
+#define RTEMS_BLKIO_GETSIZE _IO('B', 3)
+#define RTEMS_BLKIO_SYNCDEV _IO('B', 4)
/* Device driver interface conventions suppose that driver may
* contain initialize/open/close/read/write/ioctl entry points. These
@@ -90,7 +115,7 @@ typedef struct blkdev_request {
* all block devices and appropriate ioctl handlers.
*/
-#define GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \
+#define RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \
rtems_blkdev_generic_open, rtems_blkdev_generic_close, \
rtems_blkdev_generic_read, rtems_blkdev_generic_write, \
rtems_blkdev_generic_ioctl
diff --git a/cpukit/libblock/include/rtems/diskdevs.h b/cpukit/libblock/include/rtems/diskdevs.h
index 6542d74775..3517ddede2 100644
--- a/cpukit/libblock/include/rtems/diskdevs.h
+++ b/cpukit/libblock/include/rtems/diskdevs.h
@@ -21,44 +21,47 @@ extern "C" {
#include <rtems/libio.h>
#include <stdlib.h>
-#include "rtems/blkdev.h"
-
/* Buffer pool identifier */
typedef int rtems_bdpool_id;
+#include "rtems/blkdev.h"
+
+/* Driver capabilities. */
+
/* Block device ioctl handler */
-typedef int (* block_device_ioctl) (dev_t dev, uint32_t req, void *argp);
+typedef int (* rtems_block_device_ioctl) (dev_t dev, uint32_t req, void *argp);
-/* disk_device: Entry of this type created for every disk device (both for
- * logical and physical disks).
+/* rtems_disk_device: Entry of this type created for every disk device
+ * (both for logical and physical disks).
* Array of arrays of pointers to disk_device structures maintained. First
* table indexed by major number and second table indexed by minor number.
* Such data organization allow quick lookup using data structure of
* moderated size.
*/
-typedef struct disk_device {
- dev_t dev; /* Device ID (major + minor) */
- struct disk_device *phys_dev; /* Physical device ID (the same
- as dev if this entry specifies
- the physical device) */
- char *name; /* Disk device name */
- int uses; /* Use counter. Device couldn't be
- removed if it is in use. */
- int start; /* Starting block number (0 for
- physical devices, block offset
- on the related physical device
- for logical device) */
- int size; /* Size of physical or logical disk
- in disk blocks */
- int block_size; /* Size of device block (minimum
- transfer unit) in bytes
- (must be power of 2) */
- int block_size_log2; /* log2 of block_size */
- rtems_bdpool_id pool; /* Buffer pool assigned to this
- device */
- block_device_ioctl ioctl; /* ioctl handler for this block
- device */
-} disk_device;
+typedef struct rtems_disk_device {
+ dev_t dev; /* Device ID (major + minor) */
+ struct rtems_disk_device *phys_dev; /* Physical device ID (the same
+ as dev if this entry specifies
+ the physical device) */
+ uint32_t capabilities; /* Driver capabilities. */
+ char *name; /* Disk device name */
+ int uses; /* Use counter. Device couldn't be
+ removed if it is in use. */
+ int start; /* Starting block number (0 for
+ physical devices, block offset
+ on the related physical device
+ for logical device) */
+ int size; /* Size of physical or logical disk
+ in disk blocks */
+ int block_size; /* Size of device block (minimum
+ transfer unit) in bytes
+ (must be power of 2) */
+ int block_size_log2; /* log2 of block_size */
+ rtems_bdpool_id pool; /* Buffer pool assigned to this
+ device */
+ rtems_block_device_ioctl ioctl; /* ioctl handler for this block
+ device */
+} rtems_disk_device;
/* rtems_disk_create_phys --
* Create physical disk entry. This function usually invoked from
@@ -84,7 +87,7 @@ typedef struct disk_device {
*/
rtems_status_code
rtems_disk_create_phys(dev_t dev, int block_size, int disk_size,
- block_device_ioctl handler,
+ rtems_block_device_ioctl handler,
const char *name);
/* rtems_disk_create_log --
@@ -131,7 +134,7 @@ rtems_disk_create_log(dev_t dev, dev_t phys, int start, int size, char *name);
rtems_status_code
rtems_disk_delete(dev_t dev);
-/* rtems_disk_lookup --
+/* rtems_disk_obtain --
* Find block device descriptor by its device identifier. This function
* increment usage counter to 1. User should release disk_device structure
* by invoking rtems_disk_release primitive.
@@ -143,8 +146,8 @@ rtems_disk_delete(dev_t dev);
* pointer to the block device descriptor, or NULL if no such device
* exists.
*/
-disk_device *
-rtems_disk_lookup(dev_t dev);
+rtems_disk_device *
+rtems_disk_obtain(dev_t dev);
/* rtems_disk_release --
* Release disk_device structure (decrement usage counter to 1).
@@ -159,7 +162,7 @@ rtems_disk_lookup(dev_t dev);
* It should be implemented as inline function.
*/
rtems_status_code
-rtems_disk_release(disk_device *dd);
+rtems_disk_release(rtems_disk_device *dd);
/* rtems_disk_next --
* Disk device enumerator. Looking for device having device number larger
@@ -172,7 +175,7 @@ rtems_disk_release(disk_device *dd);
* RETURNS:
* Pointer to the disk descriptor for next disk device, or NULL if all
* devices enumerated. */
-disk_device *
+rtems_disk_device *
rtems_disk_next(dev_t dev);
/* rtems_diskio_initialize --
diff --git a/cpukit/libblock/include/rtems/ide_part_table.h b/cpukit/libblock/include/rtems/ide_part_table.h
index abbbb121c4..052f445f2f 100644
--- a/cpukit/libblock/include/rtems/ide_part_table.h
+++ b/cpukit/libblock/include/rtems/ide_part_table.h
@@ -77,16 +77,18 @@
* sector_data_t --
* corresponds to the sector on the device
*/
-typedef struct sector_data_s
+typedef struct rtems_sector_data_s
{
uint32_t sector_num; /* sector number on the device */
uint8_t data[0]; /* raw sector data */
-} sector_data_t;
+} rtems_sector_data_t;
/*
* Enum partition types
* see list at http://ata-atapi.com/hiwtab.htm
+ *
+ * @todo Should these have RTEMS before them.
*/
enum {
EMPTY_PARTITION = 0x00,
@@ -108,29 +110,32 @@ enum {
/* Forward declaration */
-struct disk_desc_s;
+struct rtems_disk_desc_s;
/*
* part_desc_t --
* contains all neccessary information about partition
*/
-typedef struct part_desc_s {
+typedef struct rtems_part_desc_s {
uint8_t bootable; /* is the partition active */
uint8_t sys_type; /* type of partition */
uint8_t log_id; /* logical number of partition */
- uint32_t start; /* first partition sector, in absolute numeration */
+ uint32_t start; /* first partition sector, in absolute
+ * numeration */
uint32_t size; /* size in sectors */
uint32_t end; /* last partition sector, end = start + size - 1 */
- struct disk_desc_s *disk_desc; /* descriptor of disk, partition contains in */
- struct part_desc_s *ext_part; /* extended partition containing this one */
+ struct rtems_disk_desc_s *disk_desc; /* descriptor of disk, partition
+ * contains in */
+ struct rtems_part_desc_s *ext_part; /* extended partition containing this
+ * one */
/* partitions, containing in this one */
- struct part_desc_s *sub_part[RTEMS_IDE_PARTITION_MAX_SUB_PARTITION_NUMBER];
-} part_desc_t;
+ struct rtems_part_desc_s *sub_part[RTEMS_IDE_PARTITION_MAX_SUB_PARTITION_NUMBER];
+} rtems_part_desc_t;
-typedef struct disk_desc_s {
+typedef struct rtems_disk_desc_s {
dev_t dev; /* device number */
/* device name in /dev filesystem */
@@ -142,8 +147,8 @@ typedef struct disk_desc_s {
int last_log_id; /* used for logical disks enumerating */
/* primary partition descriptors */
- part_desc_t *partitions[RTEMS_IDE_PARTITION_MAX_PARTITION_NUMBER];
-} disk_desc_t;
+ rtems_part_desc_t *partitions[RTEMS_IDE_PARTITION_MAX_PARTITION_NUMBER];
+} rtems_disk_desc_t;
#ifdef __cplusplus
extern "C" {
@@ -160,7 +165,7 @@ extern "C" {
* N/A
*/
void
-rtems_ide_part_table_free(disk_desc_t *disk_desc);
+rtems_ide_part_table_free(rtems_disk_desc_t *disk_desc);
/*
@@ -176,7 +181,7 @@ rtems_ide_part_table_free(disk_desc_t *disk_desc);
* RTEMS_SUCCESSFUL if success, or -1 and corresponding errno else
*/
rtems_status_code
-rtems_ide_part_table_get(const char *dev_name, disk_desc_t *disk_desc);
+rtems_ide_part_table_get(const char *dev_name, rtems_disk_desc_t *disk_desc);
/*
diff --git a/cpukit/libblock/include/rtems/nvdisk.h b/cpukit/libblock/include/rtems/nvdisk.h
index 5e2a0dd6af..24b62f665e 100644
--- a/cpukit/libblock/include/rtems/nvdisk.h
+++ b/cpukit/libblock/include/rtems/nvdisk.h
@@ -164,7 +164,7 @@ typedef struct rtems_nvdisk_config
const rtems_nvdisk_device_desc* devices; /**< The device descriptions. */
uint32_t flags; /**< Set of flags to control
driver. */
- uint32_t info_level; /**< Default info level. */
+ uint32_t info_level; /**< Default info level. */
} rtems_nvdisk_config;
/*
diff --git a/cpukit/libblock/include/rtems/ramdisk.h b/cpukit/libblock/include/rtems/ramdisk.h
index 64d9bad5e7..8fcc442d32 100644
--- a/cpukit/libblock/include/rtems/ramdisk.h
+++ b/cpukit/libblock/include/rtems/ramdisk.h
@@ -1,56 +1,56 @@
-/**
- * @file rtems/ramdisk.h
- * RAM disk block device implementation
- */
-
-/*
- * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
- * Author: Victor V. Vengerov <vvv@oktet.ru>
- *
- * @(#) $Id$
- */
-
-#ifndef _RTEMS_RAMDISK_H
-#define _RTEMS_RAMDISK_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <rtems.h>
-
-#include "rtems/blkdev.h"
-
-/* RAM disk configuration table entry */
-typedef struct rtems_ramdisk_config {
- int block_size; /* RAM disk block size */
- int block_num; /* Number of blocks on this RAM disk */
- void *location; /* RAM disk permanent location (out of RTEMS controlled
- memory), or NULL if RAM disk memory should be
- allocated dynamically */
-} rtems_ramdisk_config;
-
-/* If application want to use RAM disk, it should specify configuration of
- * available RAM disks.
- * The following is definitions for RAM disk configuration table
- */
-extern rtems_ramdisk_config rtems_ramdisk_configuration[];
-extern size_t rtems_ramdisk_configuration_size;
-
-/* ramdisk_initialize --
- * RAM disk driver initialization entry point.
- */
-rtems_device_driver
-ramdisk_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *arg);
-
-#define RAMDISK_DRIVER_TABLE_ENTRY \
- { ramdisk_initialize, GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES }
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+/**
+ * @file rtems/ramdisk.h
+ * RAM disk block device implementation
+ */
+
+/*
+ * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
+ * Author: Victor V. Vengerov <vvv@oktet.ru>
+ *
+ * @(#) $Id$
+ */
+
+#ifndef _RTEMS_RAMDISK_H
+#define _RTEMS_RAMDISK_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems.h>
+
+#include "rtems/blkdev.h"
+
+/* RAM disk configuration table entry */
+typedef struct rtems_ramdisk_config {
+ int block_size; /* RAM disk block size */
+ int block_num; /* Number of blocks on this RAM disk */
+ void *location; /* RAM disk permanent location (out of RTEMS controlled
+ memory), or NULL if RAM disk memory should be
+ allocated dynamically */
+} rtems_ramdisk_config;
+
+/* If application want to use RAM disk, it should specify configuration of
+ * available RAM disks.
+ * The following is definitions for RAM disk configuration table
+ */
+extern rtems_ramdisk_config rtems_ramdisk_configuration[];
+extern size_t rtems_ramdisk_configuration_size;
+
+/* ramdisk_initialize --
+ * RAM disk driver initialization entry point.
+ */
+rtems_device_driver
+ramdisk_initialize(
+ rtems_device_major_number major,
+ rtems_device_minor_number minor,
+ void *arg);
+
+#define RAMDISK_DRIVER_TABLE_ENTRY \
+ { ramdisk_initialize, RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES }
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif