source: soft/giet_vm/giet_drivers/iob_driver.c @ 320

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

All drivers have been modified to use only the information
contained in the hard_config.h file

File size: 4.5 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File     : iob_driver.c
3// Date     : 23/05/2013
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7// The iob_driver.c and iob_driver.h files are part ot the GIET-VM kernel.
8// This driver supports the TSAR vci_io_bridge, that is a bridge to access
9// The external peripherals, implementing an IO_MMU.
10// This component can be instanciated in more than one cluster.
11///////////////////////////////////////////////////////////////////////////////////
12// The SEG_IOB_BASE virtual addresses must be defined in hard_config.h file.
13// The physical base address is supposed to be (cluster_xy << 32) | SEG_IOB_BASE.
14///////////////////////////////////////////////////////////////////////////////////
15
16#include <giet_config.h>
17#include <iob_driver.h>
18#include <utils.h>
19
20#if !defined(SEG_IOB_BASE)
21# error: You must define SEG_IOB_BASE in the hard_config.h file
22#endif
23
24#if !defined(GIET_USE_IOMMU)
25# error: You must define GIET_USE_IOMMU in the giet_config.h file
26#endif
27
28#if !defined( USE_IOB )
29# error: You must define USE_IOB in the hard_config.h file
30#endif
31
32
33///////////////////////////////////////////////////////////////////////////////
34// This low level function returns the value contained in register "index"
35// in the IOB component contained in cluster "cluster_xy"
36///////////////////////////////////////////////////////////////////////////////
37unsigned int _iob_get_register( unsigned int cluster_xy,   // cluster index
38                                unsigned int index )       // register index
39{
40    unsigned long long paddr = (unsigned long long)SEG_IOB_BASE + 
41                               ((unsigned long long)cluster_xy << 32) +
42                               ((unsigned long long)index << 2);
43
44    return _physical_read( paddr );
45}
46///////////////////////////////////////////////////////////////////////////////
47// This low level function sets a new value in register "index"
48// in the IOB component contained in cluster "cluster_xy"
49///////////////////////////////////////////////////////////////////////////////
50void _iob_set_register( unsigned int cluster_xy,       // cluster index
51                        unsigned int index,            // register index
52                        unsigned int value )           // value to be written
53{
54    unsigned long long paddr = (unsigned long long)SEG_IOB_BASE + 
55                               ((unsigned long long)cluster_xy << 32) +
56                               ((unsigned long long)index << 2);
57
58    _physical_write( paddr, value );
59}
60
61
62
63///////////////////////////////////////////////////////////////////////////////
64// This function invalidates a TLB entry identified by a virtual address.
65///////////////////////////////////////////////////////////////////////////////
66void _iob_inval_tlb_entry( unsigned int cluster_xy,
67                           unsigned int vaddr )
68{
69    _iob_set_register( cluster_xy,
70                       IOB_INVAL_PTE,
71                       vaddr );
72}
73
74///////////////////////////////////////////////////////////////////////////////
75// This function sets a new value in IOB_IOMMU_PTPR register.
76///////////////////////////////////////////////////////////////////////////////
77void _iob_set_iommu_ptpr( unsigned int cluster_xy,
78                          unsigned int value )
79{
80    _iob_set_register( cluster_xy,
81                       IOB_IOMMU_PTPR,
82                       value );
83}
84
85///////////////////////////////////////////////////////////////////////////////
86// This function sets a new value in IOB_XICU_BASE register.
87///////////////////////////////////////////////////////////////////////////////
88void _iob_set_xicu_base( unsigned int cluster_xy,
89                         unsigned int value )
90{
91    _iob_set_register( cluster_xy,
92                       IOB_XICU_BASE,
93                       value );
94}
95
96///////////////////////////////////////////////////////////////////////////////
97// This function sets a new value in IOB_XICU_SIZE register.
98///////////////////////////////////////////////////////////////////////////////
99void _iob_set_xicu_size( unsigned int cluster_xy,
100                         unsigned int value )
101{
102    _iob_set_register( cluster_xy,
103                       IOB_XICU_SIZE,
104                       value );
105}
106
107
108
109// Local Variables:
110// tab-width: 4
111// c-basic-offset: 4
112// c-file-offsets:((innamespace . 0)(inline-open . 0))
113// indent-tabs-mode: nil
114// End:
115// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
116
Note: See TracBrowser for help on using the repository browser.