Changes between Version 2 and Version 3 of Component/Vci Block Device


Ignore:
Timestamp:
Dec 3, 2008, 3:42:39 PM (15 years ago)
Author:
Nicolas Pouillon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Component/Vci Block Device

    v2 v3  
    2626   This register goes back to BLOCK_DEVICE_NOOP when operation is finished.
    2727
    28  * `BLOCK_DEVICE_STATUS` State of the transfer, -1 on failure
     28 * `BLOCK_DEVICE_STATUS` State of the transfer. Reading this register while not busy resets its value to IDLE. Value may be one of
     29  * `BLOCK_DEVICE_IDLE`
     30  * `BLOCK_DEVICE_BUSY`
     31  * `BLOCK_DEVICE_SUCCESS`
     32  * `BLOCK_DEVICE_ERROR`
    2933
    3034 * `BLOCK_DEVICE_IRQ_ENABLE` Boolean enabling the IRQ line
    3135
    3236 * `BLOCK_DEVICE_SIZE` Number of blocks addressable in the controller (read-only)
     37
     38 * `BLOCK_DEVICE_BLOCK_SIZE` Block size (in bytes) (read-only)
    3339
    3440The following operations codes are defined:
     
    4551
    4652Sample code:
    47 {{{
    48 #include "soclib/block_device.h"
    49 
    50 static const void* bd_base = 0xc0000000;
    51 
    52 
    53 int block_read( const size_t lba, void *buffer, const size_t len )
    54 {
    55         soclib_io_set(bd_base, BLOCK_DEVICE_LBA, lba);
    56         soclib_io_set(bd_base, BLOCK_DEVICE_BUFFER, (uint32_t)buffer);
    57         soclib_io_set(bd_base, BLOCK_DEVICE_COUNT, len);
    58         soclib_io_set(bd_base, BLOCK_DEVICE_OP, BLOCK_DEVICE_READ);
    59         while (soclib_io_get(bd_base, BLOCK_DEVICE_OP))
    60                 ;
    61         return soclib_io_get(bd_base, BLOCK_DEVICE_STATUS);
    62 }
    63 
    64 int block_write( const size_t lba, const void *buffer, const size_t len )
    65 {
    66         soclib_io_set(bd_base, BLOCK_DEVICE_LBA, lba);
    67         soclib_io_set(bd_base, BLOCK_DEVICE_BUFFER, (uint32_t)buffer);
    68         soclib_io_set(bd_base, BLOCK_DEVICE_COUNT, len);
    69         soclib_io_set(bd_base, BLOCK_DEVICE_OP, BLOCK_DEVICE_WRITE);
    70         while (soclib_io_get(bd_base, BLOCK_DEVICE_OP))
    71                 ;
    72         return soclib_io_get(bd_base, BLOCK_DEVICE_STATUS);
    73 }
    74 
    75 uint32_t block_size()
    76 {
    77         return soclib_io_get(bd_base, BLOCK_DEVICE_SIZE);
    78 }
    79 
    80 }}}
     53Please see reference implementation in source:trunk/soclib/soclib/platform/topcells/caba-vgmn-block_device-mips32el
    8154
    8255(add -I/path/to/soclib/include to your compilation command-line)