source: trunk/kernel/drivers/soclib/soclib_iob.c @ 2

Last change on this file since 2 was 1, checked in by alain, 8 years ago

First import

File size: 4.5 KB
Line 
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/////////////////////////////////////
30void soclib_iob_init( xptr_t iox_xp )
31{
32    // get IOX device cluster and local pointer
33    cxy_t      iox_cxy = GET_CXY( iox_xp );
34    device_t * iox_ptr = (device_t *)GET_PTR( iox_xp );
35
36    // get extended pointer on SOCLIB_IOB base_xp segment
37    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iox_cxy , &iox_ptr->base ) );
38
39    // desactivate IOMMU
40    hal_remote_sw( base_xp + (IOB_IOMMU_ACTIVE<<2) , 0 );
41}
42
43////////////////////////////////////////////
44void soclib_iob_set_active( xptr_t   iox_xp,
45                            uint32_t value )
46{
47    // get IOX device cluster and local pointer
48    cxy_t      iox_cxy = GET_CXY( iox_xp );
49    device_t * iox_ptr = (device_t *)GET_PTR( iox_xp );
50
51    // get extended pointer on SOCLIB_IOB base_xp segment
52    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iox_cxy , &iox_ptr->base ) );
53
54    // set ACTIVE register
55    hal_remote_sw( base_xp + (IOB_IOMMU_ACTIVE<<2) , value );
56}
57
58//////////////////////////////////////////
59void soclib_iob_set_ptpr( xptr_t   iox_xp,
60                          uint32_t value )
61{
62    // get IOX device cluster and local pointer
63    cxy_t      iox_cxy = GET_CXY( iox_xp );
64    device_t * iox_ptr = (device_t *)GET_PTR( iox_xp );
65
66    // get extended pointer on SOCLIB_IOB base_xp segment
67    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iox_cxy , &iox_ptr->base ) );
68
69    // set PTPR register
70    hal_remote_sw( base_xp + (IOB_IOMMU_PTPR<<2) , value );
71}
72
73///////////////////////////////////////////
74void soclib_iob_inval_page( xptr_t  iox_xp,
75                            vpn_t   vpn )
76{
77    // get IOX device cluster and local pointer
78    cxy_t      iox_cxy = GET_CXY( iox_xp );
79    device_t * iox_ptr = (device_t *)GET_PTR( iox_xp );
80
81    // get extended pointer on SOCLIB_IOB base_xp segment
82    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iox_cxy , &iox_ptr->base ) );
83
84    // invalidate TLB entry
85    hal_remote_sw( base_xp + (IOB_INVAL_PTE<<2) , vpn );
86}
87
88//////////////////////////////////////////////
89uint32_t soclib_iob_get_bvar( xptr_t  iox_xp )
90{
91    // get IOX device cluster and local pointer
92    cxy_t      iox_cxy = GET_CXY( iox_xp );
93    device_t * iox_ptr = (device_t *)GET_PTR( iox_xp );
94
95    // get extended pointer on SOCLIB_IOB base_xp segment
96    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iox_cxy , &iox_ptr->base ) );
97
98    // get BVAR register
99    return hal_remote_lw( base_xp + (IOB_IOMMU_BVAR<<2) );
100}
101
102///////////////////////////////////////////////
103uint32_t soclib_iob_get_srcid( xptr_t  iox_xp )
104{
105    // get IOX device cluster and local pointer
106    cxy_t      iox_cxy = GET_CXY( iox_xp );
107    device_t * iox_ptr = (device_t *)GET_PTR( iox_xp );
108
109    // get extended pointer on SOCLIB_IOB base_xp segment
110    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iox_cxy , &iox_ptr->base ) );
111
112    // get BVAR register
113    return hal_remote_lw( base_xp + (IOB_IOMMU_SRCID<<2) );
114}
115
116///////////////////////////////////////////////
117uint32_t soclib_iob_get_error( xptr_t  iox_xp )
118{
119    // get IOX device cluster and local pointer
120    cxy_t      iox_cxy = GET_CXY( iox_xp );
121    device_t * iox_ptr = (device_t *)GET_PTR( iox_xp );
122
123    // get extended pointer on SOCLIB_IOB base_xp segment
124    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iox_cxy , &iox_ptr->base ) );
125
126    // get BVAR register
127    return hal_remote_lw( base_xp + (IOB_IOMMU_ERROR<<2) );
128}
129
130
131// Local Variables:
132// tab-width: 4
133// c-basic-offset: 4
134// c-file-offsets:((innamespace . 0)(inline-open . 0))
135// indent-tabs-mode: nil
136// End:
137// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
138
Note: See TracBrowser for help on using the repository browser.