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

Last change on this file since 710 was 709, checked in by alain, 9 years ago

Major release: Change the task model to implement the POSIX threads API.

  • The shell "exec" and "kill" commands can be used to activate/de-activate the applications.
  • The "pause", "resume", and "context" commands can be used to stop, restart, a single thtead or to display the thread context.

This version has been tested on the following multi-threaded applications,
that have been modified to use the POSIX threads:

  • classif
  • convol
  • transpose
  • gameoflife
  • raycast
File size: 4.9 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//            Low level access function
81///////////////////////////////////////////////////////////////////////////////////
82
83unsigned int _bdv_get_register( unsigned int index );
84
85void _bdv_set_register( unsigned int index,
86                        unsigned int value );
87
88///////////////////////////////////////////////////////////////////////////////////
89// This function cheks block size == 512, and desactivates the interrupts.
90// Return 0 for success, > 0 if error
91///////////////////////////////////////////////////////////////////////////////////
92extern unsigned int _bdv_init();
93
94///////////////////////////////////////////////////////////////////////////////////
95// Transfer data to/from the block device from/to a memory buffer.
96// - use_irq  : descheduling + IRQ if non zero / polling if zero
97// - to_mem   : from external storage to memory when non 0.
98// - lba      : first block index on the block device
99// - buffer   : pbase address of the memory buffer (must be word aligned)
100// - count    : number of blocks to be transfered.
101// Returns 0 if success, > 0 if error.
102///////////////////////////////////////////////////////////////////////////////////
103extern unsigned int _bdv_access( unsigned int       use_irq,
104                                 unsigned int       to_mem,
105                                 unsigned int       lba, 
106                                 unsigned long long buffer,
107                                 unsigned int       count );
108
109///////////////////////////////////////////////////////////////////////////////////
110// This ISR save the status, acknowledge the IRQ, and activates the task
111// waiting on IO transfer. It can be an HWI or a SWI.
112//
113// TODO the _set_task_slot access should be replaced by an atomic LL/SC
114//      when the CTX_RUN bool will be replaced by a bit_vector.
115///////////////////////////////////////////////////////////////////////////////////
116extern void _bdv_isr( unsigned irq_type,
117                      unsigned irq_id,
118                      unsigned channel );
119
120
121#endif
122
123// Local Variables:
124// tab-width: 4
125// c-basic-offset: 4
126// c-file-offsets:((innamespace . 0)(inline-open . 0))
127// indent-tabs-mode: nil
128// End:
129// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
130
Note: See TracBrowser for help on using the repository browser.