source: trunk/kernel/devices/dev_iob.h @ 595

Last change on this file since 595 was 565, checked in by alain, 6 years ago

Complete restructuration of kernel locks.

File size: 6.3 KB
RevLine 
[1]1/*
[3]2 * dev_iob.h - IOB (bridge to external I/O) generic device API.
[1]3 *
4 * Authors   Alain Greiner  (2016)
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
[3]24#ifndef _DEV_IOB_H_
25#define _DEV_IOB_H_
[1]26
[14]27#include <kernel_config.h>
[457]28#include <hal_kernel_types.h>
[1]29
30/*****************************************************************************************
[3]31 *     Generic IOB (bridge to external IO peripherals) definition.
[1]32 *
[3]33 * The IOB device is used to access external peripherals. It implements an IO-MMU service
[1]34 * for DMA transactions launched by DMA capable external peripherals.
[279]35 *
[3]36 * This IOB peripheral is acting as a dynamically configurable bridge, used for others
37 * I/O operations. Therefore, ALMOS-MKH does not use the IOB device waiting queue,
38 * and calls directly the IOB driver blocking functions, using the device lock to
39 * get exclusive access to the IOB bridge internal state.
[1]40 ****************************************************************************************/
41 
[3]42/****  Forward declarations  ****/
[1]43
[3]44struct chdev_s;
45
[1]46/*****************************************************************************************
[346]47 * This defines the specific extension for the IOB chdev descriptor.
48 ****************************************************************************************/
49
50typedef void     (iob_set_active_t) ( xptr_t iob_xp, uint32_t value );
51typedef void     (iob_set_ptpr_t)   ( xptr_t iob_xp, uint32_t value );
52typedef void     (iob_inval_page_t) ( xptr_t iob_xp, vpn_t vpn );
53typedef uint32_t (iob_get_bvar_t)   ( xptr_t iob_xp );
54typedef uint32_t (iob_get_srcid_t)  ( xptr_t iob_xp );
55typedef uint32_t (iob_get_error_t)  ( xptr_t iob_xp );
56
57typedef struct iob_extend_s
58{
59    iob_set_active_t  * set_active;
60    iob_set_ptpr_t    * set_ptpr;
61    iob_inval_page_t  * inval_page;
62    iob_get_bvar_t    * get_bvar;
63    iob_get_srcid_t   * get_srcid;
64    iob_get_error_t   * get_error;
65}
66iob_extend_t;
67
68/*****************************************************************************************
[3]69 * This enum defines the various implementations of the IOB generic device.
[1]70 * This array must be kept consistent with the define in arch_info.h file
71 ****************************************************************************************/
72
[3]73enum iob_impl_e
[1]74{
[3]75    IMPL_IOB_TSR =   0,         /* vci_iob component used in TSAR                       */
76    IMPL_IOB_I86 =   1,         /* TBD                                                  */
[1]77}
[3]78iob_impl_t;
[1]79
80/*****************************************************************************************
[3]81 * This function initializes the IOB device descriptor with IOMMU disabled.
[1]82 *****************************************************************************************
[3]83 * @ chdev      :  pointer on IOB chdev descriptor.
[1]84 ****************************************************************************************/
[3]85void dev_iob_init( struct chdev_s * chdev );
[1]86
87/*****************************************************************************************
[3]88 * This function activates the IOMMU for the IOB device identified by its
[1]89 * extended pointer.
90 *****************************************************************************************
[3]91 * @ dev_xp   : extended pointer on IOB device descriptor.
[1]92 ****************************************************************************************/
[3]93void dev_iob_iommu_enable( xptr_t dev_xp );
[1]94
95/*****************************************************************************************
[3]96 * This function desactivates the IO-MMU for the IOB device identified by its
[1]97 * extended pointer.
98 *****************************************************************************************
[3]99 * @ dev_xp   : extended pointer on IOB device descriptor.
[1]100 ****************************************************************************************/
[3]101void dev_iob_iommu_disable( xptr_t dev_xp );
[1]102
103/*****************************************************************************************
104 * This function set a new value in the IO-MMU PTPR register.
105 *****************************************************************************************
[3]106 * @ dev_xp   : extended pointer on IOB device descriptor.
[1]107 * @ wdata    : value to be written in PTPR register.
108 ****************************************************************************************/
[3]109void dev_iob_set_ptpr( xptr_t    dev_xp,
[1]110                       uint32_t  wdata );
111                       
112/*****************************************************************************************
113 * This function invalidates an IOMMU TLB entry identified by its vpn.
114 *****************************************************************************************
[3]115 * @ dev_xp   : extended pointer on IOB device descriptor.
[1]116 * @ vpn      : virtual page number in IO virtual space.
117 ****************************************************************************************/
[3]118void dev_iob_inval_page( xptr_t  dev_xp,
[1]119                         vpn_t   vpn );
120
121/*****************************************************************************************
122 * This function return informations relative to an error reported by the IOMMU.
123 *****************************************************************************************
[3]124 * @ dev_xp   : extended pointer on IOB device descriptor.
[1]125 * @ error    : [out] pointer on buffer for erro type.
126 * @ bvar     : [out] pointer on buffer for bad virtual address.
127 * @ srcid    : [out] pointer on buffer for faulty peripheral index.
128 ****************************************************************************************/
[3]129void dev_iob_get_status( xptr_t     dev_xp,
[1]130                         uint32_t * error,
131                         uint32_t * bvar,
132                         uint32_t * srcid );
133
[3]134#endif  /* _DEV_IOB_H_ */
Note: See TracBrowser for help on using the repository browser.