source: trunk/kernel/devices/dev_iob.c

Last change on this file was 647, checked in by alain, 4 years ago

...miscelaneous...

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