source: soft/giet_vm/giet_drivers/bdv_driver.h @ 573

Last change on this file since 573 was 529, checked in by alain, 10 years ago

1) Removing the IOC driver (integrated in the FAT library).
2) Simplifying the BDV, HBA, SDC, RDK drivers: they support
only two modes (synchronous => polling / descheduling => IRQ),
and only one access function (for both read/write).

File size: 4.7 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File      : bdv_driver.h
3// Date      : 01/11/2013
4// Author    : alain greiner
5// Maintainer: cesar fuguet
6// Copyright (c) UPMC-LIP6
7///////////////////////////////////////////////////////////////////////////////////
8// The bdv_driver.c and bdv_driver.h files are part ot the GIET-VM kernel.
9// This driver supports the SocLib vci_block_device component, that is
10// a single channel, block oriented, external storage contrÃŽler.
11//
12// The _bdv_access() function supports both read and write access to block device,
13// and implement two operating modes:
14//
15// - in "synchronous" mode, it uses a polling policy on the BDV STATUS
16//   register to detect transfer completion, as interrupts are not activated.
17//   This mode is used by the boot code to load the map.bin file into memory
18//   (before MMU activation), or to load the .elf files (after MMU activation).
19// - In "descheduling" mode, ir uses a descheduling + IRQ policy.
20//   The ISR executed when transfer completes should restart the calling task,
21//   as the calling task global index has been saved in the _bdv_gtid variable.
22//   
23// As the BDV component can be used by several programs running in parallel,
24// the _bdv_lock variable guaranties exclusive access to the device.
25//
26// The SEG_IOC_BASE address must be defined in the hard_config.h file.
27///////////////////////////////////////////////////////////////////////////////////
28
29#ifndef _GIET_BDV_DRIVER_H_
30#define _GIET_BDV_DRIVER_H_
31
32#include "kernel_locks.h"
33
34///////////////////////////////////////////////////////////////////////////////////
35// BDV registers, operations and status values
36///////////////////////////////////////////////////////////////////////////////////
37
38enum BDV_registers
39{
40    BLOCK_DEVICE_BUFFER,
41    BLOCK_DEVICE_LBA,
42    BLOCK_DEVICE_COUNT,
43    BLOCK_DEVICE_OP,
44    BLOCK_DEVICE_STATUS,
45    BLOCK_DEVICE_IRQ_ENABLE,
46    BLOCK_DEVICE_SIZE,
47    BLOCK_DEVICE_BLOCK_SIZE,
48    BLOCK_DEVICE_BUFFER_EXT,
49};
50
51enum BDV_operations
52{
53    BLOCK_DEVICE_NOOP,
54    BLOCK_DEVICE_READ,
55    BLOCK_DEVICE_WRITE,
56};
57
58enum BDV_status
59{
60    BLOCK_DEVICE_IDLE,
61    BLOCK_DEVICE_BUSY,
62    BLOCK_DEVICE_READ_SUCCESS,
63    BLOCK_DEVICE_WRITE_SUCCESS,
64    BLOCK_DEVICE_READ_ERROR,
65    BLOCK_DEVICE_WRITE_ERROR,
66    BLOCK_DEVICE_ERROR,
67};
68
69///////////////////////////////////////////////////////////////////////////////
70//           Global variables
71///////////////////////////////////////////////////////////////////////////////
72
73extern spin_lock_t  _bdv_lock;
74
75extern unsigned int _bdv_gtid;
76
77extern unsigned int _bdv_status;
78
79///////////////////////////////////////////////////////////////////////////////////
80//            Access functions
81///////////////////////////////////////////////////////////////////////////////////
82
83///////////////////////////////////////////////////////////////////////////////////
84// This function cheks block size == 512, and desactivates the interrupts.
85// Return 0 for success, > 0 if error
86///////////////////////////////////////////////////////////////////////////////////
87extern unsigned int _bdv_init();
88
89///////////////////////////////////////////////////////////////////////////////////
90// Transfer data to/from the block device from/to a memory buffer.
91// - use_irq  : descheduling + IRQ if non zero / polling if zero
92// - to_mem   : from external storage to memory when non 0.
93// - lba      : first block index on the block device
94// - buffer   : pbase address of the memory buffer (must be word aligned)
95// - count    : number of blocks to be transfered.
96// Returns 0 if success, > 0 if error.
97///////////////////////////////////////////////////////////////////////////////////
98extern unsigned int _bdv_access( unsigned int       use_irq,
99                                 unsigned int       to_mem,
100                                 unsigned int       lba, 
101                                 unsigned long long buffer,
102                                 unsigned int       count );
103
104///////////////////////////////////////////////////////////////////////////////////
105// This ISR save the status, acknowledge the IRQ, and activates the task
106// waiting on IO transfer. It can be an HWI or a SWI.
107//
108// TODO the _set_task_slot access should be replaced by an atomic LL/SC
109//      when the CTX_RUN bool will be replaced by a bit_vector.
110///////////////////////////////////////////////////////////////////////////////////
111extern void _bdv_isr( unsigned irq_type,
112                      unsigned irq_id,
113                      unsigned channel );
114
115
116#endif
117
118// Local Variables:
119// tab-width: 4
120// c-basic-offset: 4
121// c-file-offsets:((innamespace . 0)(inline-open . 0))
122// indent-tabs-mode: nil
123// End:
124// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
125
Note: See TracBrowser for help on using the repository browser.