source: trunk/softs/tsar_boot/src/reset_ioc.c @ 770

Last change on this file since 770 was 758, checked in by cfuguet, 10 years ago

tsar_boot: improving configuration infrastructure

  • Using hard_config.h which respects the same sintax that the hard_config.h file of all TSAR platforms. This file can be then generated by the GIET-VM genmap tool or written manually.
  • All peripheral drivers have been moved to a drivers directory and they are compiled as a static library. This allows GCC to only include in the final .ELF the object files of used peripherals and not all of them.
  • Example hard_config.h and ldscripts have been introduced in the conf directory.
  • Improving comments in all files
File size: 1.7 KB
Line 
1/**
2 * \file   reset_ioc.c
3 * \date   December 2013
4 * \author Cesar Fuguet
5 *
6 * \brief  API for accessing the disk controller
7 *
8 * \note   These functions call the specific disk controller driver depending
9 *         on the USE_IOC_BDV, USE_IOC_SPI or USE_RAMDISK constants
10 */
11
12#include <reset_ioc.h>
13#include <defs.h>
14
15#if !defined(USE_IOC_BDV) && !defined(USE_IOC_SPI) && !defined(USE_RAMDISK)
16#   error "One of the USE_IOC_* constants must be defined in the hard_config.h"
17#endif
18
19#if (USE_IOC_BDV + USE_IOC_SPI + USE_RAMDISK) != 1
20#   error "Only one disk controller must be used"
21#endif
22
23#if USE_IOC_SPI
24#include <reset_sdc.h>
25#endif
26
27#if USE_IOC_BDV
28#include <reset_bdv.h>
29#endif
30
31#if USE_RAMDISK
32#include <reset_rdk.h>
33#endif
34
35/**
36 * \brief Initialize the disk controller
37 */
38int reset_ioc_init()
39{
40#if USE_IOC_BDV
41    return reset_bdv_init();
42#elif USE_IOC_SPI
43    return reset_sdc_init();
44#elif USE_RAMDISK
45    return reset_rdk_init();
46#else
47#   error "reset_ioc_init() : Not supported disk controller chosen"
48#endif
49}
50
51/**
52 * \param lba   : first block index on the disk
53 * \param buffer: base address of the memory buffer
54 * \param count : number of blocks to be transfered
55 *
56 * \brief Transfer data from disk to a memory buffer
57 *
58 * \note  This is a blocking function. The function returns once the transfer
59 *        is completed.
60 */
61int reset_ioc_read( unsigned int lba, void* buffer, unsigned int count )
62{
63#if USE_IOC_BDV
64    return reset_bdv_read(lba, buffer, count);
65#elif USE_IOC_SPI
66    return reset_sdc_read(lba, buffer, count);
67#elif USE_RAMDISK
68    return reset_rdk_read(lba, buffer, count);
69#else
70#   error "reset_ioc_read() : Not supported disk controller chosen"
71#endif
72}
73
74/*
75 * vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab
76 */
Note: See TracBrowser for help on using the repository browser.