1 | /* |
---|
2 | * soclib_iob.c - soclib IOB driver API implementation. |
---|
3 | * |
---|
4 | * Alain Greiner (2017) |
---|
5 | * |
---|
6 | * Copyright (c) UPMC Sorbonne Universites |
---|
7 | * |
---|
8 | * This file is part of ALMOS-MKH. |
---|
9 | * |
---|
10 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
11 | * under the terms of the GNU General Public License as published by |
---|
12 | * the Free Software Foundation; version 2.0 of the License. |
---|
13 | * |
---|
14 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
17 | * General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
22 | */ |
---|
23 | |
---|
24 | #include <almos_config.h> |
---|
25 | #include <hal_types.h> |
---|
26 | #include <hal_remote.h> |
---|
27 | #include <soclib_iob.h> |
---|
28 | |
---|
29 | /////////////////////////////////////// |
---|
30 | void soclib_iob_init( chdev_t * chdev ) |
---|
31 | { |
---|
32 | // desactivate IOMMU |
---|
33 | hal_remote_sw( chdev->base + (IOB_IOMMU_ACTIVE<<2) , 0 ); |
---|
34 | } |
---|
35 | |
---|
36 | //////////////////////////////////////////// |
---|
37 | void soclib_iob_set_active( xptr_t iob_xp, |
---|
38 | uint32_t value ) |
---|
39 | { |
---|
40 | // get IOX device cluster and local pointer |
---|
41 | cxy_t iob_cxy = GET_CXY( iob_xp ); |
---|
42 | chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp ); |
---|
43 | |
---|
44 | // get extended pointer on SOCLIB_IOB base_xp segment |
---|
45 | xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) ); |
---|
46 | |
---|
47 | // set ACTIVE register |
---|
48 | hal_remote_sw( base_xp + (IOB_IOMMU_ACTIVE<<2) , value ); |
---|
49 | } |
---|
50 | |
---|
51 | ////////////////////////////////////////// |
---|
52 | void soclib_iob_set_ptpr( xptr_t iob_xp, |
---|
53 | uint32_t value ) |
---|
54 | { |
---|
55 | // get IOX device cluster and local pointer |
---|
56 | cxy_t iob_cxy = GET_CXY( iob_xp ); |
---|
57 | chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp ); |
---|
58 | |
---|
59 | // get extended pointer on SOCLIB_IOB base_xp segment |
---|
60 | xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) ); |
---|
61 | |
---|
62 | // set PTPR register |
---|
63 | hal_remote_sw( base_xp + (IOB_IOMMU_PTPR<<2) , value ); |
---|
64 | } |
---|
65 | |
---|
66 | /////////////////////////////////////////// |
---|
67 | void soclib_iob_inval_page( xptr_t iob_xp, |
---|
68 | vpn_t vpn ) |
---|
69 | { |
---|
70 | // get IOX device cluster and local pointer |
---|
71 | cxy_t iob_cxy = GET_CXY( iob_xp ); |
---|
72 | chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp ); |
---|
73 | |
---|
74 | // get extended pointer on SOCLIB_IOB base_xp segment |
---|
75 | xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) ); |
---|
76 | |
---|
77 | // invalidate TLB entry |
---|
78 | hal_remote_sw( base_xp + (IOB_INVAL_PTE<<2) , vpn ); |
---|
79 | } |
---|
80 | |
---|
81 | ////////////////////////////////////////////// |
---|
82 | uint32_t soclib_iob_get_bvar( xptr_t iob_xp ) |
---|
83 | { |
---|
84 | // get IOX device cluster and local pointer |
---|
85 | cxy_t iob_cxy = GET_CXY( iob_xp ); |
---|
86 | chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp ); |
---|
87 | |
---|
88 | // get extended pointer on SOCLIB_IOB base_xp segment |
---|
89 | xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) ); |
---|
90 | |
---|
91 | // get BVAR register |
---|
92 | return hal_remote_lw( base_xp + (IOB_IOMMU_BVAR<<2) ); |
---|
93 | } |
---|
94 | |
---|
95 | /////////////////////////////////////////////// |
---|
96 | uint32_t soclib_iob_get_srcid( xptr_t iob_xp ) |
---|
97 | { |
---|
98 | // get IOX device cluster and local pointer |
---|
99 | cxy_t iob_cxy = GET_CXY( iob_xp ); |
---|
100 | chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp ); |
---|
101 | |
---|
102 | // get extended pointer on SOCLIB_IOB base_xp segment |
---|
103 | xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) ); |
---|
104 | |
---|
105 | // get BVAR register |
---|
106 | return hal_remote_lw( base_xp + (IOB_IOMMU_SRCID<<2) ); |
---|
107 | } |
---|
108 | |
---|
109 | /////////////////////////////////////////////// |
---|
110 | uint32_t soclib_iob_get_error( xptr_t iob_xp ) |
---|
111 | { |
---|
112 | // get IOX device cluster and local pointer |
---|
113 | cxy_t iob_cxy = GET_CXY( iob_xp ); |
---|
114 | chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp ); |
---|
115 | |
---|
116 | // get extended pointer on SOCLIB_IOB base_xp segment |
---|
117 | xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) ); |
---|
118 | |
---|
119 | // get BVAR register |
---|
120 | return hal_remote_lw( base_xp + (IOB_IOMMU_ERROR<<2) ); |
---|
121 | } |
---|
122 | |
---|
123 | |
---|
124 | // Local Variables: |
---|
125 | // tab-width: 4 |
---|
126 | // c-basic-offset: 4 |
---|
127 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
128 | // indent-tabs-mode: nil |
---|
129 | // End: |
---|
130 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
131 | |
---|