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 base addresses must be defined in giet_vsegs.ld 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(GIET_USE_IOMMU) |
---|
21 | # error: You must define GIET_USE_IOMMU in the giet_config.h file |
---|
22 | #endif |
---|
23 | |
---|
24 | #if !defined( USE_IOB ) |
---|
25 | # error: You must define USE_IOB in the hard_config.h file |
---|
26 | #endif |
---|
27 | |
---|
28 | |
---|
29 | /////////////////////////////////////////////////////////////////////////////// |
---|
30 | // This low level function returns the value contained in register "index" |
---|
31 | // in the IOB component contained in cluster "cluster_xy" |
---|
32 | /////////////////////////////////////////////////////////////////////////////// |
---|
33 | unsigned int _iob_get_register( unsigned int cluster_xy, // cluster index |
---|
34 | unsigned int index ) // register index |
---|
35 | { |
---|
36 | unsigned long long paddr = (unsigned long long)(unsigned int)&seg_iob_base + |
---|
37 | ((unsigned long long)cluster_xy << 32) + |
---|
38 | ((unsigned long long)index << 2); |
---|
39 | |
---|
40 | return _physical_read( paddr ); |
---|
41 | } |
---|
42 | /////////////////////////////////////////////////////////////////////////////// |
---|
43 | // This low level function sets a new value in register "index" |
---|
44 | // in the IOB component contained in cluster "cluster_xy" |
---|
45 | /////////////////////////////////////////////////////////////////////////////// |
---|
46 | void _iob_set_register( unsigned int cluster_xy, // cluster index |
---|
47 | unsigned int index, // register index |
---|
48 | unsigned int value ) // value to be written |
---|
49 | { |
---|
50 | unsigned long long paddr = (unsigned long long)(unsigned int)&seg_iob_base + |
---|
51 | ((unsigned long long)cluster_xy << 32) + |
---|
52 | ((unsigned long long)index << 2); |
---|
53 | |
---|
54 | _physical_write( paddr, value ); |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | /////////////////////////////////////////////////////////////////////////////// |
---|
61 | // This function invalidates a TLB entry identified by a virtual address. |
---|
62 | /////////////////////////////////////////////////////////////////////////////// |
---|
63 | void _iob_inval_tlb_entry( unsigned int cluster_xy, |
---|
64 | unsigned int vaddr ) |
---|
65 | { |
---|
66 | _iob_set_register( cluster_xy, |
---|
67 | IOB_INVAL_PTE, |
---|
68 | vaddr ); |
---|
69 | } |
---|
70 | |
---|
71 | /////////////////////////////////////////////////////////////////////////////// |
---|
72 | // This function sets a new value in IOB_IOMMU_PTPR register. |
---|
73 | /////////////////////////////////////////////////////////////////////////////// |
---|
74 | void _iob_set_iommu_ptpr( unsigned int cluster_xy, |
---|
75 | unsigned int value ) |
---|
76 | { |
---|
77 | _iob_set_register( cluster_xy, |
---|
78 | IOB_IOMMU_PTPR, |
---|
79 | value ); |
---|
80 | } |
---|
81 | |
---|
82 | /////////////////////////////////////////////////////////////////////////////// |
---|
83 | // This function sets a new value in IOB_XICU_BASE register. |
---|
84 | /////////////////////////////////////////////////////////////////////////////// |
---|
85 | void _iob_set_xicu_base( unsigned int cluster_xy, |
---|
86 | unsigned int value ) |
---|
87 | { |
---|
88 | _iob_set_register( cluster_xy, |
---|
89 | IOB_XICU_BASE, |
---|
90 | value ); |
---|
91 | } |
---|
92 | |
---|
93 | /////////////////////////////////////////////////////////////////////////////// |
---|
94 | // This function sets a new value in IOB_XICU_SIZE register. |
---|
95 | /////////////////////////////////////////////////////////////////////////////// |
---|
96 | void _iob_set_xicu_size( unsigned int cluster_xy, |
---|
97 | unsigned int value ) |
---|
98 | { |
---|
99 | _iob_set_register( cluster_xy, |
---|
100 | IOB_XICU_SIZE, |
---|
101 | value ); |
---|
102 | } |
---|
103 | |
---|
104 | |
---|
105 | |
---|
106 | // Local Variables: |
---|
107 | // tab-width: 4 |
---|
108 | // c-basic-offset: 4 |
---|
109 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
110 | // indent-tabs-mode: nil |
---|
111 | // End: |
---|
112 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
113 | |
---|