| 1 | [wiki:Component SocLib Components General Index] |
| 2 | |
| 3 | = !VciMultiAhci = |
| 4 | |
| 5 | == 1) Functional Description == |
| 6 | |
| 7 | This component emulates a multi-channels disk controller with VCI interface. Each channel[k] can |
| 8 | access a different physical disk, modeled as a different file[k] belonging to the host system, |
| 9 | and containing a complete disk image. |
| 10 | Each channel[k] can perform data transfers between file[k] and a buffer in the physical memory |
| 11 | of the virtual system. he number of supported channels, the file name(s), the VCI burst size, and the block size are hardware parameters,defined as constructors parameters. |
| 12 | The number of channels cannot be larger than 8. The burst size must be a power of 2 between 8 and 64 bytes. |
| 13 | The block size must be a power of 2 between 128 and 4096 bytes. |
| 14 | |
| 15 | According to the AHCI specification, each channel[k] controller uses a private ''Command List'' |
| 16 | that is handled as a software FIFO. For each channel[k], the ''Command List'' can register up to 32 |
| 17 | ''read'' or ''write'' commands, that are handled in pseudo-parallelism by the channel controller. |
| 18 | This VCI component has a DMA capability, and use it to access the ''Command List'' and to transfer |
| 19 | the data to or from memory. |
| 20 | |
| 21 | On the VCI side, it supports both 32 bits and 64 bits data words, and up to 64 bits address width. |
| 22 | |
| 23 | For each channel, a single IRQ[k] can be (optionally) asserted as soon as at list one command |
| 24 | in the Command List is completed. WARNING: the IRQ[k] is associated to a specific channel, |
| 25 | but not to a specific command. |
| 26 | |
| 27 | This hardware component checks for segmentation violation, and can be used as a default target. |
| 28 | |
| 29 | == 2) Addressable registers == |
| 30 | |
| 31 | Each channel[k] contains seven 32 bits registers: |
| 32 | |
| 33 | * '''HBA''' (read/write) |
| 34 | Physical address of the source (or destination) buffer in SoC memory. |
| 35 | |
| 36 | * '''BLOCK_DEVICE_COUNT''' (read/write) |
| 37 | Number of blocks to be transfered. |
| 38 | |
| 39 | * '''BLOCK_DEVICE_LBA''' (read/write) |
| 40 | Logical Base Address (index of the first block in the block device) |
| 41 | |
| 42 | * '''BLOCK_DEVICE_OP''' (write only) |
| 43 | Type of operation, writing here initiates the operation.This register goes back to BLOCK_DEVICE_NOOP when operation is finished. The following operations codes are defined: |
| 44 | || `BLOCK_DEVICE_NOOP` || No operation || |
| 45 | || `BLOCK_DEVICE_READ` || Transfer from block device to memory || |
| 46 | || `BLOCK_DEVICE_WRITE` || Transfer from memory to block device || |
| 47 | |
| 48 | * '''BLOCK_DEVICE_STATUS''' (read only) |
| 49 | State of the transfer. Reading this register while not busy resets its value to IDLE, and acknowledge the IRQ. Value may be one of : |
| 50 | || `BLOCK_DEVICE_IDLE` || |
| 51 | || `BLOCK_DEVICE_BUSY` || |
| 52 | || `BLOCK_DEVICE_READ_SUCCESS` || |
| 53 | || `BLOCK_DEVICE_WRITE_SUCCESS` || |
| 54 | || `BLOCK_DEVICE_READ_ERROR` || |
| 55 | || `BLOCK_DEVICE_WRITE_ERROR` || |
| 56 | |
| 57 | * '''BLOCK_DEVICE_IRQ_ENABLE''' (read/write) |
| 58 | Boolean enabling the IRQ line |
| 59 | |
| 60 | * '''BLOCK_DEVICE_SIZE''' (read only) |
| 61 | Number of blocks addressable in the block device |
| 62 | |
| 63 | * '''BLOCK_DEVICE_BLOCK_SIZE''' (read only) |
| 64 | Block size (in bytes) |
| 65 | |
| 66 | For extensibility issues, you should access this component using globally-defined offsets. |
| 67 | You should include file `soclib/block_device.h` from your software, it |
| 68 | defines `BLOCK_DEVICE_COUNT`, `BLOCK_DEVICE_READ`, ... |
| 69 | |
| 70 | Sample code: |
| 71 | Please see reference implementation in source:trunk/soclib/soclib/platform/topcells/caba-vgmn-block_device-mips32el |
| 72 | |
| 73 | (add -I/path/to/soclib/include to your compilation command-line) |
| 74 | |
| 75 | == 2) Component definition & usage == |
| 76 | |
| 77 | source:trunk/soclib/soclib/module/connectivity_component/vci_block_device/caba/metadata/vci_block_device.sd |
| 78 | |
| 79 | See [wiki:SoclibCc/VciParameters SoclibCc/VciParameters] |
| 80 | {{{ |
| 81 | Uses( 'vci_block_device', **vci_parameters ) |
| 82 | }}} |
| 83 | |
| 84 | == 3) CABA Implementation == |
| 85 | |
| 86 | === CABA sources === |
| 87 | |
| 88 | * interface : source:trunk/soclib/soclib/module/connectivity_component/vci_block_device/caba/source/include/vci_block_device.h |
| 89 | * implementation : source:trunk/soclib/soclib/module/connectivity_component/vci_block_device/caba/source/src/vci_block_device.cpp |
| 90 | |
| 91 | === CABA Constructor parameters === |
| 92 | |
| 93 | {{{ |
| 94 | VciBlockDevice( |
| 95 | sc_module_name name, // Component Name |
| 96 | const soclib::common::MappingTable &mt, // MappingTable |
| 97 | const soclib::common::IntTab &srcid, // Initiator index |
| 98 | const soclib::common::IntTab &tgtid, // Target index |
| 99 | const std::string &filename, // mapped file, may be a host block device |
| 100 | const uint32_t block_size = 512, // block size in bytes |
| 101 | const uint32_t latency = 0); // initial access time (number of cycles) |
| 102 | }}} |
| 103 | |
| 104 | === CABA Ports === |
| 105 | |
| 106 | * '''p_resetn''' : Global system reset |
| 107 | * '''p_clk''' : Global system clock |
| 108 | * '''p_vci_target''' : The VCI target port |
| 109 | * '''p_vci_initiator''' : The VCI initiator port |
| 110 | * '''p_irq''' : Interrupt port |
| 111 | |
| 112 | == 4) TLM-DT Implementation == |
| 113 | |
| 114 | === TLM-DT sources === |
| 115 | |
| 116 | * interface : source:trunk/soclib/soclib/module/connectivity_component/vci_block_device/tlmdt/source/include/vci_block_device.h |
| 117 | * implementation : source:trunk/soclib/soclib/module/connectivity_component/vci_block_device/tlmdt/source/src/vci_block_device.cpp |
| 118 | |
| 119 | === TLM-DT Constructor parameters === |
| 120 | |
| 121 | {{{ |
| 122 | VciBlockDevice( |
| 123 | sc_module_name name, // Component Name |
| 124 | const soclib::common::MappingTable &mt, // MappingTable |
| 125 | const soclib::common::IntTab &srcid, // Initiator index |
| 126 | const soclib::common::IntTab &tgtid, // Target index |
| 127 | const std::string &filename, // mapped file, may be a host block device |
| 128 | const uint32_t block_size = 512, // block size in bytes |
| 129 | const uint32_t latency = 0); // initial access time (number of cycles) |
| 130 | }}} |
| 131 | |
| 132 | === TLM-DT Ports === |
| 133 | |
| 134 | * '''p_vci_target''' : The VCI target port |
| 135 | * '''p_vci_initiator''' : The VCI initiator port |
| 136 | * '''p_irq''' : Interrupt port |