source: trunk/softs/tsar_boot/io_drivers/ioc.h @ 276

Last change on this file since 276 was 276, checked in by bouyer, 12 years ago

A boot loader to be stored in ROM of a TSAR platform.
Based on Cesar FUGUET's work.
Platform-specific files are in a subdirectory, e.g. platform_fpga_de2-115,
so the same code can be targetted to different platforms.
The platform is selected with the PLATFORM_DIR environnement variable.
The supported variant are soclib and fpga, the later being the default
and the former selected by defining the SOCLIB environnement variable.
The boot loader embeds a binary device tree describing the platform,
to be used by the loaded software.

File size: 3.0 KB
RevLine 
[276]1#ifndef IOC_H
2#define IOC_H
3
4#include <io.h>
5#include <sdcard.h>
6#include <spi.h>
7#include <block_device.h>
8#include <boot_tty.h>
9
10//////////////////////////////////////////////////////////////////////////////////////////
11//  I/O BLOCK_DEVICE
12// The three functions below use the three variables _ioc_lock _ioc_done,
13// and _ioc_status for synchronsation.
14// - As the IOC component can be used by several programs running in parallel,
15// the _ioc_lock variable guaranties exclusive access to the device.
16// The _ioc_read() and _ioc_write() functions use atomic LL/SC to get the lock.
17// and set _ioc_lock to a non zero value.
18// The _ioc_write() and _ioc_read() functions are blocking, polling the _ioc_lock
19// variable until the device is available.
20// - When the tranfer is completed, the ISR routine activated by the IOC IRQ
21// set the _ioc_done variable to a non-zero value. Possible address errors detected
22// by the IOC peripheral are reported by the ISR in the _ioc_status variable.
23// The _ioc_completed() function is polling the _ioc_done variable, waiting for
24// tranfer conpletion. When the completion is signaled, the _ioc_completed() function
25// reset the _ioc_done variable to zero, and releases the _ioc_lock variable.
26//
27// In a multi-tasks environment, this polling policy must be replaced by a
28// descheduling policy for the requesting process.
29///////////////////////////////////////////////////////////////////////////////////////
30//  _ioc_get_lock()
31// This blocking function is used by the _ioc_read() and _ioc_write() functions
32// to get _ioc_lock using LL/SC.
33///////////////////////////////////////////////////////////////////////////////////////
34void _ioc_get_lock();
35
36int _ioc_init();
37
38///////////////////////////////////////////////////////////////////////////////////////
39//  _ioc_completed()
40// This blocking function cheks completion of an I/O transfer and reports errors.
41// It returns 0 if the transfer is successfully completed.
42// It returns -1 if an error has been reported.
43///////////////////////////////////////////////////////////////////////////////////////
44int _ioc_completed();
45
46//////////////////////////////////////////////////////////////////////////////////////
47//  _ioc_write()
48// Transfer data from a memory buffer to a file on the block_device.
49// - lba    : first block index on the disk
50// - buffer : base address of the memory buffer
51// - count  : number of blocks to be transfered
52// The source buffer must be in user address space.
53///////////////////////////////////////////////////////////////////////////////////////
54int _ioc_write(size_t lba, void* buffer, size_t count);
55
56/**
57 *  _ioc_read()
58 *
59 * Transfer data from a file on the block device to a memory buffer.
60 *
61 * \param lba    : first block index on the disk
62 * \param buffer : base address of the memory buffer
63 * \param count  : number of blocks to be transfered
64 *
65 * \note This is a blocking function. The function returns once the transfer
66 *       has finished
67 */
68int _ioc_read(size_t lba, void* buffer, size_t count);
69
70#endif
71
72/*
73 * vim: tabstop=4 : shiftwidth=4 : expandtab
74 */
Note: See TracBrowser for help on using the repository browser.