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

Last change on this file since 23 was 14, checked in by alain, 8 years ago

Bugs fix.

File size: 4.2 KB
RevLine 
[1]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
[14]24#include <kernel_config.h>
[1]25#include <hal_types.h>
26#include <hal_remote.h>
27#include <soclib_iob.h>
28
[4]29///////////////////////////////////////
30void soclib_iob_init( chdev_t * chdev )
[1]31{
32    // desactivate IOMMU
[4]33    hal_remote_sw( chdev->base + (IOB_IOMMU_ACTIVE<<2) , 0 );
[1]34}
35
36////////////////////////////////////////////
[4]37void soclib_iob_set_active( xptr_t   iob_xp,
[1]38                            uint32_t value )
39{
40    // get IOX device cluster and local pointer
[4]41    cxy_t     iob_cxy = GET_CXY( iob_xp );
42    chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp );
[1]43
44    // get extended pointer on SOCLIB_IOB base_xp segment
[4]45    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
[1]46
47    // set ACTIVE register
48    hal_remote_sw( base_xp + (IOB_IOMMU_ACTIVE<<2) , value );
49}
50
51//////////////////////////////////////////
[4]52void soclib_iob_set_ptpr( xptr_t   iob_xp,
[1]53                          uint32_t value )
54{
55    // get IOX device cluster and local pointer
[4]56    cxy_t     iob_cxy = GET_CXY( iob_xp );
57    chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp );
[1]58
59    // get extended pointer on SOCLIB_IOB base_xp segment
[4]60    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
[1]61
62    // set PTPR register
63    hal_remote_sw( base_xp + (IOB_IOMMU_PTPR<<2) , value );
64}
65
66///////////////////////////////////////////
[4]67void soclib_iob_inval_page( xptr_t  iob_xp,
[1]68                            vpn_t   vpn )
69{
70    // get IOX device cluster and local pointer
[4]71    cxy_t     iob_cxy = GET_CXY( iob_xp );
72    chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp );
[1]73
74    // get extended pointer on SOCLIB_IOB base_xp segment
[4]75    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
[1]76
77    // invalidate TLB entry
78    hal_remote_sw( base_xp + (IOB_INVAL_PTE<<2) , vpn );
79}
80
81//////////////////////////////////////////////
[4]82uint32_t soclib_iob_get_bvar( xptr_t  iob_xp )
[1]83{
84    // get IOX device cluster and local pointer
[4]85    cxy_t     iob_cxy = GET_CXY( iob_xp );
86    chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp );
[1]87
88    // get extended pointer on SOCLIB_IOB base_xp segment
[4]89    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
[1]90
91    // get BVAR register
92    return hal_remote_lw( base_xp + (IOB_IOMMU_BVAR<<2) );
93}
94
95///////////////////////////////////////////////
[4]96uint32_t soclib_iob_get_srcid( xptr_t  iob_xp )
[1]97{
98    // get IOX device cluster and local pointer
[4]99    cxy_t     iob_cxy = GET_CXY( iob_xp );
100    chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp );
[1]101
102    // get extended pointer on SOCLIB_IOB base_xp segment
[4]103    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
[1]104
105    // get BVAR register
106    return hal_remote_lw( base_xp + (IOB_IOMMU_SRCID<<2) );
107}
108
109///////////////////////////////////////////////
[4]110uint32_t soclib_iob_get_error( xptr_t  iob_xp )
[1]111{
112    // get IOX device cluster and local pointer
[4]113    cxy_t     iob_cxy = GET_CXY( iob_xp );
114    chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp );
[1]115
116    // get extended pointer on SOCLIB_IOB base_xp segment
[4]117    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
[1]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
Note: See TracBrowser for help on using the repository browser.