source: trunk/tools/bootloader_tsar/boot_bdv_driver.h @ 59

Last change on this file since 59 was 1, checked in by alain, 8 years ago

First import

File size: 4.1 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File     : boot_bdv_driver.h
3// Date     : 01/11/2013
4// Authors  : Alain Greiner / Vu Son
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7// This file defines a simplified driver for the SocLib vci_block_device, 
8// a single channel, block-oriented, external mass storage peripheral.
9// The driver is used by the ALMOS-MKH boot-loader when the USE_IOC_BDV flag
10// is set in the hard_config.h file.
11// All accesses to the device registers are performed via 2 low-level
12// functions boot_bdv_get_register() and boot_bdv_set_register(). 
13// Since the driver is used by the boot-loader, it implements synchronous
14// accesses to block device by polling the BDV_STATUS register to detect
15// transfer completion, as interrupts are not activated.                   
16///////////////////////////////////////////////////////////////////////////////////
17
18#ifndef BOOT_BDV_DRIVER_H
19#define BOOT_BDV_DRIVER_H
20
21#include <hal_types.h>
22
23/****************************************************************************
24 *                            Driver register map.                          *
25 ****************************************************************************/
26
27enum BDV_registers
28{
29    BDV_BUFFER      = 0,    /* 32 LSB of the source or destination buffer   */
30    BDV_LBA         = 1,    /* LBA of the first block to be transfered.     */
31    BDV_COUNT       = 2,    /* Number of blocks to be transfered.           */
32    BDV_OPERATION   = 3,    /* Operation to perform.                        */
33    BDV_STATUS      = 4,    /* Transfer status.                             */
34    BDV_IRQ_ENABLE  = 5,    /* Boolean enabling the IRQ line.               */
35    BDV_SIZE        = 6,    /* Count of addessable blocks in the device.    */
36    BDV_BLOCK_SIZE  = 7,    /* Block size (in bytes).                       */
37    BDV_BUFFER_EXT  = 8,    /* 32 MSB of the source or destination buffer   */
38
39    BDV_SPAN        = 9,    /* BDV segment size (32 bits words)             */
40};
41
42/****************************************************************************
43 *                             Driver operations.                           *
44 ****************************************************************************/
45
46enum BDV_operations
47{
48    BDV_NOOP    = 0,
49    BDV_READ    = 1,
50    BDV_WRITE   = 2,
51};
52
53/****************************************************************************
54 *                           Driver status values.                          *
55 ****************************************************************************/
56
57enum BDV_status
58{
59    BDV_IDLE        = 0,
60    BDV_BUSY        = 1,
61    BDV_READ_SUCC   = 2,
62    BDV_WRITE_SUCC  = 3,
63    BDV_READ_ERR    = 4,
64    BDV_WRITE_ERR   = 5,
65};
66
67/****************************************************************************
68 *                           Driver API functions.                          *
69 ****************************************************************************/
70
71/****************************************************************************
72 * This function checks if a block size is indeed 512 bytes, and            *
73 * desactivates the interrupts.                                             *
74 * @ returns 0 on success, -1 on error.                                     *
75 ****************************************************************************/
76int boot_bdv_init();
77
78/****************************************************************************
79 * This function transfers 'count' blocks from the block device to memory.
80 * @ lba        : LBA of the first block on the block device.               *
81 * @ buf_paddr  : memory buffer physical address.                           *
82 * @ count      : number of blocks to be transfered.                        *
83 * @ returns 0 on success, -1 on error.                                     *
84 ****************************************************************************/
85int boot_bdv_access( uint32_t  lba,
86                     xptr_t    buf_paddr,
87                     uint32_t  count );
88
89#endif // BOOT_BDV_DRIVER_H
Note: See TracBrowser for help on using the repository browser.