Ignore:
Timestamp:
Jun 18, 2017, 10:06:41 PM (7 years ago)
Author:
alain
Message:

Introduce syscalls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/devices/dev_ioc.h

    r14 r23  
    3838 * magnetic hard disk or a SD card, that can store blocks of data in a linear array
    3939 * 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.
    4648 * A) the client thread start the I/O operation, by calling the dev_ioc_read()
    4749 *    or the dev_ioc_write() kernel functions that perform the following actions:
     
    5052 *    3) it access the PIC to link the WTI mailbox to the IOC IRQ.
    5153 *    4) it builds the command descriptor.
    52  *    5) it registers in the IOCdevice waiting queue.
     54 *    5) it registers in the IOC device waiting queue.
    5355 *    6) itblock on the THREAD_BLOCKED_IO condition and deschedule.
    5456 * B) The server thread attached to the IOC device descriptor handles the commands
     
    6163 *    2) disable the WTI IRQ in the client cluster ICU and update interrupt vector.
    6264 *    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.
    6369 *****************************************************************************************/
    6470
     
    9399 *****************************************************************************************/
    94100
     101enum
     102{
     103    IOC_READ       = 0,
     104    IOC_WRITE      = 1,
     105    IOC_SYNC_READ  = 2,
     106};
     107
    95108typedef struct ioc_command_s
    96109{
    97     xptr_t      dev_xp;      /*! extended pointer on device descriptor                    */
    98     uint32_t    to_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                     */
    99112    uint32_t    lba;        /*! first block index                                        */
    100113    uint32_t    count;      /*! number of blocks                                         */
     
    119132/******************************************************************************************
    120133 * 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 actually
     134 * from the block device to a local memory buffer. The corresponding request is actually
    122135 * registered in the device pending request queue, and the calling thread is descheduled,
    123136 * waiting on transfer completion. It will be resumed by the IRQ signaling completion.
    124137 * It must be called in the client cluster.
    125138 ******************************************************************************************
    126  * @ buffer    : local pointer on target buffer in memory.
     139 * @ buffer    : local pointer on target buffer in memory (must be block aligned).
    127140 * @ lba       : first block index on device.
    128141 * @ count     : number of blocks to transfer.
    129142 * @ returns 0 if success / returns EINVAL if error.
    130143 *****************************************************************************************/
    131 error_t dev_ioc_read( char         * buffer,
     144error_t dev_ioc_read( uint8_t      * buffer,
    132145                      uint32_t       lba,
    133146                      uint32_t       count );
     
    135148/******************************************************************************************
    136149 * 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 actually
     150 * from a local memory buffer to the block device. The corresponding request is actually
    138151 * registered in the device pending request queue, and the calling thread is descheduled,
    139152 * waiting on transfer completion. It will be resumed by the IRQ signaling completion.
    140153 * It must be called in the client cluster.
    141154 ******************************************************************************************
    142  * @ buffer    : local pointer on source buffer in memory.
     155 * @ buffer    : local pointer on source buffer in memory (must be block aligned).
    143156 * @ lba       : first block index on device.
    144157 * @ count     : number of blocks to transfer.
    145158 * @ returns 0 if success / returns EINVAL if error.
    146159 *****************************************************************************************/
    147 error_t dev_ioc_write( char         * buffer,
     160error_t dev_ioc_write( uint8_t      * buffer,
    148161                       uint32_t       lba,
    149162                       uint32_t       count );
    150163
     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 *****************************************************************************************/
     177error_t dev_ioc_sync_read( uint8_t      * buffer,
     178                           uint32_t       lba,
     179                           uint32_t       count );
     180
    151181#endif  /* _DEV_IOC_H */
Note: See TracChangeset for help on using the changeset viewer.