source: trunk/kernel/devices/dev_iob.c @ 375

Last change on this file since 375 was 346, checked in by max@…, 7 years ago

Hide soclib_iob.

File size: 4.6 KB
RevLine 
[1]1/*
[3]2 * dev_iob.c - IOB (bridge to external I/O) generic device API implementation.
[1]3 *
4 * Authors   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
[3]16 * MERCHANTABILITY or FITNESS FOR A PARTIOBLAR PURPOSE.  See the GNU
[1]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_special.h>
27#include <remote_spinlock.h>
[3]28#include <chdev.h>
[1]29#include <printk.h>
[346]30#include <hal_drivers.h>
[3]31#include <dev_iob.h>
[1]32
[3]33////////////////////////////////////
34void dev_iob_init( chdev_t * chdev )
[1]35{
[346]36    // get implementation
[3]37    uint32_t  impl = chdev->impl;
[1]38
[23]39    // set chdev name
40    strcpy( chdev->name , "iob" );
41
[1]42    // call driver init function
[346]43    hal_drivers_iob_init( chdev , impl );
[1]44}
45
46//////////////////////////////////////////
[3]47void dev_iob_iommu_enable( xptr_t dev_xp )
[1]48{
[3]49    // get IOB chdev descriptor cluster and local pointer
50    cxy_t     dev_cxy = GET_CXY( dev_xp );
51    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
[1]52
[346]53    // get pointer on set_active function
54    iob_set_active_t * f = hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->ext.iob.set_active ) );
[1]55
[346]56    // call relevant driver function
57    remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
58    f( dev_xp , 1 );
59    remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
[1]60}
61
62///////////////////////////////////////////
[3]63void dev_iob_iommu_disable( xptr_t dev_xp )
[1]64{
[3]65    // get IOB chdev descriptor cluster and local pointer
66    cxy_t     dev_cxy = GET_CXY( dev_xp );
67    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
[1]68
[346]69    // get pointer on set_active function
70    iob_set_active_t * f = hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->ext.iob.set_active ) );
[1]71
72    // call driver function
[346]73    remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
74    f( dev_xp , 0 );
75    remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
[1]76}
77
78////////////////////////////////////////
[3]79void dev_iob_set_ptpr( xptr_t    dev_xp,
[1]80                       uint32_t  wdata )
81{
[3]82    // get IOB chdev descriptor cluster and local pointer
83    cxy_t     dev_cxy = GET_CXY( dev_xp );
84    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
[1]85
[346]86    // get pointer on set_ptpr function
87    iob_set_ptpr_t * f = hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->ext.iob.set_ptpr ) );
[1]88
89    // call driver function
[346]90    remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
91    f( dev_xp , wdata );
92    remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
93
[1]94}
[346]95
[1]96////////////////////////////////////////
[3]97void dev_iob_inval_page( xptr_t  dev_xp,
[1]98                         vpn_t   vpn )
99{
[3]100    // get IOB chdev descriptor cluster and local pointer
101    cxy_t     dev_cxy = GET_CXY( dev_xp );
102    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
[1]103
[346]104    // get pointer on inval_page function
105    iob_inval_page_t * f = hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->ext.iob.inval_page ) );
[1]106
107    // call driver function
[346]108    remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
109    f( dev_xp , vpn );
110    remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
[1]111}
112
113///////////////////////////////////////////
[3]114void dev_iob_get_status( xptr_t     dev_xp,
[1]115                         uint32_t * error,
116                         uint32_t * bvar,
117                         uint32_t * srcid )
118{
[3]119    // get IOB chdev descriptor cluster and local pointer
120    cxy_t     dev_cxy = GET_CXY( dev_xp );
121    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
[1]122
[346]123    // get pointer on the functions
124    iob_get_error_t * f_get_error = hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->ext.iob.get_error ) );
125    iob_get_srcid_t * f_get_srcid = hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->ext.iob.get_srcid ) );
126    iob_get_bvar_t  * f_get_bvar  = hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->ext.iob.get_bvar  ) );
[1]127
128    // call driver function
[346]129    remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
130    *error = f_get_error( dev_xp );
131    *srcid = f_get_srcid( dev_xp );
132    *bvar  = f_get_bvar( dev_xp );
133    remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
[1]134}
135
Note: See TracBrowser for help on using the repository browser.