Changeset 23 for trunk/kernel/devices/dev_ioc.h
- Timestamp:
- Jun 18, 2017, 10:06:41 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_ioc.h
r14 r23 38 38 * magnetic hard disk or a SD card, that can store blocks of data in a linear array 39 39 * of sectors indexed by a simple lba (logic block address). 40 * It supports two command types: 41 * - READ : move a given number of contiguous blocks from device to a memory buffer. 42 * - WRITE : move a given number of contiguous blocks from a memory buffer to device. 43 * 44 * An I/O operation requires dynamic ressource allocation, and is always blocking for 45 * the client thread. The general scenario is detailed below. 40 * It supports three command types: 41 * - READ : move blocks from device to memory, with a descheduling policy. 42 * - WRITE : move blocks from memory to device, with a descheduling policy. 43 * - SYNC_READ : move blocks from device to memory, with a busy waiting policy. 44 45 * A READ or WRITE operation requires dynamic ressource allocation. The calling thread 46 * is descheduled, and the work is done by the server thread associated to IOC device. 47 * The general scenario is detailed below. 46 48 * A) the client thread start the I/O operation, by calling the dev_ioc_read() 47 49 * or the dev_ioc_write() kernel functions that perform the following actions: … … 50 52 * 3) it access the PIC to link the WTI mailbox to the IOC IRQ. 51 53 * 4) it builds the command descriptor. 52 * 5) it registers in the IOC device waiting queue.54 * 5) it registers in the IOC device waiting queue. 53 55 * 6) itblock on the THREAD_BLOCKED_IO condition and deschedule. 54 56 * B) The server thread attached to the IOC device descriptor handles the commands … … 61 63 * 2) disable the WTI IRQ in the client cluster ICU and update interrupt vector. 62 64 * 3) release the WTI mailbox to the client cluster WTI allocator. 65 * 66 * The SYNC_READ operation is used by the kernel in the initialisation phase. It does 67 * not uses the IOC device waiting queue and server thread, and does not use the IOC IRQ, 68 * but implement a busy-waiting policy for the calling thread. 63 69 *****************************************************************************************/ 64 70 … … 93 99 *****************************************************************************************/ 94 100 101 enum 102 { 103 IOC_READ = 0, 104 IOC_WRITE = 1, 105 IOC_SYNC_READ = 2, 106 }; 107 95 108 typedef struct ioc_command_s 96 109 { 97 xptr_t dev_xp; 98 uint32_t t o_mem; /*! requested operation (WRITE if zero / READ if non-zero)*/110 xptr_t dev_xp; /*! extended pointer on device descriptor */ 111 uint32_t type; /*! IOC_READ / IOC_WRITE / IOC_SYNC_READ */ 99 112 uint32_t lba; /*! first block index */ 100 113 uint32_t count; /*! number of blocks */ … … 119 132 /****************************************************************************************** 120 133 * This blocking function try to tranfer one or several contiguous blocks of data 121 * from the block device to a memory buffer. The corresponding request is actually134 * from the block device to a local memory buffer. The corresponding request is actually 122 135 * registered in the device pending request queue, and the calling thread is descheduled, 123 136 * waiting on transfer completion. It will be resumed by the IRQ signaling completion. 124 137 * It must be called in the client cluster. 125 138 ****************************************************************************************** 126 * @ buffer : local pointer on target buffer in memory .139 * @ buffer : local pointer on target buffer in memory (must be block aligned). 127 140 * @ lba : first block index on device. 128 141 * @ count : number of blocks to transfer. 129 142 * @ returns 0 if success / returns EINVAL if error. 130 143 *****************************************************************************************/ 131 error_t dev_ioc_read( char* buffer,144 error_t dev_ioc_read( uint8_t * buffer, 132 145 uint32_t lba, 133 146 uint32_t count ); … … 135 148 /****************************************************************************************** 136 149 * This blocking function try to tranfer one or several contiguous blocks of data 137 * from a memory buffer to the block device. The corresponding request is actually150 * from a local memory buffer to the block device. The corresponding request is actually 138 151 * registered in the device pending request queue, and the calling thread is descheduled, 139 152 * waiting on transfer completion. It will be resumed by the IRQ signaling completion. 140 153 * It must be called in the client cluster. 141 154 ****************************************************************************************** 142 * @ buffer : local pointer on source buffer in memory .155 * @ buffer : local pointer on source buffer in memory (must be block aligned). 143 156 * @ lba : first block index on device. 144 157 * @ count : number of blocks to transfer. 145 158 * @ returns 0 if success / returns EINVAL if error. 146 159 *****************************************************************************************/ 147 error_t dev_ioc_write( char* buffer,160 error_t dev_ioc_write( uint8_t * buffer, 148 161 uint32_t lba, 149 162 uint32_t count ); 150 163 164 /****************************************************************************************** 165 * This blocking function try to tranfer one or several contiguous blocks of data 166 * from the block device to a memory buffer. 167 * It does not uses the IOC device waiting queue and server thread, and does not use 168 * the IOC IRQ, but call directly the relevant OIC driver, implementing a busy-waiting 169 * policy for the calling thread. 170 * It must be called in the client cluster. 171 ****************************************************************************************** 172 * @ buffer : local pointer on target buffer in memory (must be block aligned). 173 * @ lba : first block index on device. 174 * @ count : number of blocks to transfer. 175 * @ returns 0 if success / returns EINVAL if error. 176 *****************************************************************************************/ 177 error_t dev_ioc_sync_read( uint8_t * buffer, 178 uint32_t lba, 179 uint32_t count ); 180 151 181 #endif /* _DEV_IOC_H */
Note: See TracChangeset
for help on using the changeset viewer.