Changes between Initial Version and Version 1 of Component/Vci Block Device


Ignore:
Timestamp:
Dec 2, 2008, 7:21:42 PM (15 years ago)
Author:
Nicolas Pouillon
Comment:

Block device added

Legend:

Unmodified
Added
Removed
Modified
  • Component/Vci Block Device

    v1 v1  
     1[wiki:Component SocLib Components General Index]
     2
     3= !VciBlockDevice =
     4
     5== 1) Functional Description ==
     6
     7This VCI component is both a target and an initiator.
     8 * It is addressed as a target to be configured for a transfer.
     9 * It is acting as an initiator to do the transfer
     10
     11There is only one block device handled by this component, limited to 2^41 bytes.
     12An IRQ is optionally asserted when transfer is finished.
     13
     14This hardware component checks for segmentation violation, and can be used
     15as a default target.
     16
     17It contains the following memory-mapped registers:
     18
     19 * `BLOCK_DEVICE_BUFFER` Physical address of the buffer in SoC memory
     20
     21 * `BLOCK_DEVICE_COUNT` Count of blocks to transfer
     22
     23 * `BLOCK_DEVICE_LBA` Base sector for transfer
     24
     25 * `BLOCK_DEVICE_OP` Type of operation, writing here initiates the operation.[[BR]]
     26   This register goes back to BLOCK_DEVICE_NOOP when operation is finished.
     27
     28 * `BLOCK_DEVICE_STATUS` State of the transfer, -1 on failure
     29
     30 * `BLOCK_DEVICE_IRQ_ENABLE` Boolean enabling the IRQ line
     31
     32 * `BLOCK_DEVICE_SIZE` Number of blocks addressable in the controller (read-only)
     33
     34The following operations codes are defined:
     35
     36 * `BLOCK_DEVICE_NOOP` Nothing
     37
     38 * `BLOCK_DEVICE_READ` read()
     39
     40 * `BLOCK_DEVICE_WRITE` write()
     41
     42For extensibility issues, you should access this component using globally-defined offsets.
     43You should include file `soclib/block_device.h` from your software, it
     44defines `BLOCK_DEVICE_COUNT`, `BLOCK_DEVICE_READ`, ...
     45
     46Sample code:
     47{{{
     48#include "soclib/block_device.h"
     49
     50static const void* bd_base = 0xc0000000;
     51
     52
     53int 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
     64int 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
     75uint32_t block_size()
     76{
     77        return soclib_io_get(bd_base, BLOCK_DEVICE_SIZE);
     78}
     79
     80}}}
     81
     82(add -I/path/to/soclib/include to your compilation command-line)
     83
     84== 2) Component definition & usage ==
     85
     86source:trunk/soclib/module/connectivity_component/vci_block_device/caba/metadata/vci_block_device.sd
     87
     88See [wiki:SoclibCc/VciParameters SoclibCc/VciParameters]
     89{{{
     90Uses( 'vci_block_device', **vci_parameters )
     91}}}
     92
     93== 3) CABA  Implementation ==
     94
     95=== CABA sources ===
     96
     97 * interface : source:trunk/soclib/soclib/module/connectivity_component/vci_block_device/caba/source/include/vci_block_device.h
     98 * implementation : source:trunk/soclib/soclib/module/connectivity_component/vci_block_device/caba/source/src/vci_block_device.cpp
     99
     100=== CABA Constructor parameters ===
     101
     102{{{
     103VciBlockDevice(
     104     sc_module_name name,   //  Component Name
     105     const soclib::common::IntTab & index,  // Target index
     106     const soclib::common::MappingTable &mt,  // MappingTable
     107     const std::string &filename ) // mapped file, may be a host block device
     108}}}
     109
     110=== CABA Ports ===
     111
     112 * sc_in<bool> '''p_resetn''' : Global system reset
     113 * sc_in<bool> '''p_clk''' : Global system clock
     114 * soclib::caba::!VciTarget<vci_param> '''p_vci_target''' : The VCI target port
     115 * soclib::caba::!VciInitiator<vci_param> '''p_vci_initiator''' : The VCI initiator port
     116 * sc_out<bool> '''p_irq''' : Interrupt port
     117
     118== 4) TLM-T Implementation ==
     119
     120The TLM-T implementation is not yet available.