source: trunk/kernel/devices/dev_pic.c @ 191

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

hide soclib

File size: 3.6 KB
Line 
1/*
2 * dev_pic.c - PIC (External Interrupt Controler) generic device API implementation.
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
16 * MERCHANTABILITY or FITNESS FOR A PARTPICLAR 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 <hal_types.h>
25#include <hal_special.h>
26#include <chdev.h>
27#include <printk.h>
28#include <hal_drivers.h>
29#include <dev_pic.h>
30#include <cluster.h>
31
32/////////////////////////////////////////////////////////////////////////////////////////
33// Extern global variables
34/////////////////////////////////////////////////////////////////////////////////////////
35
36extern chdev_directory_t  chdev_dir;         // allocated in kernel_init.c
37
38///////////////////////////////////
39void dev_pic_init( chdev_t  * pic )
40{
41    // get implementation
42    uint32_t impl = pic->impl;
43
44    // set chdev name
45    strcpy( pic->name , "pic" );
46
47    // call the relevant driver init function,
48    // and register commands in PIC device extension
49    if( impl == IMPL_PIC_SCL )
50    {
51        // call the PIC SOCLIB driver
52        hal_drivers_pic_init( pic );
53    }
54    else if( impl == IMPL_PIC_I86 )
55    {
56        assert( false , __FUNCTION__ , "missing implementation for X86\n" );
57    }
58    else
59    {
60        assert( false , __FUNCTION__ , "undefined PIC device implementation" );
61    }
62} // end dev_pic_init()
63
64/////////////////////////////////////////////////
65void dev_pic_extend_init( uint32_t * lapic_base )
66{
67    // get pointer on PIC chdev
68    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
69
70    // call relevant driver function
71    pic->ext.pic.extend_init( lapic_base );
72}
73
74/////////////////////////////////////
75void dev_pic_bind_irq( lid_t     lid,
76                       chdev_t * src_chdev )
77{
78    // get pointer on PIC chdev
79    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
80
81    // call relevant driver function
82    pic->ext.pic.bind_irq( lid , src_chdev );
83} 
84
85///////////////////////////////////////
86void dev_pic_enable_irq( lid_t     lid,
87                         chdev_t * src_chdev )
88{
89    // get pointer on PIC chdev
90    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
91
92    // call relevant driver function
93    pic->ext.pic.enable_irq( src_chdev );
94}
95
96////////////////////////////////////////
97void dev_pic_disable_irq( lid_t     lid,
98                          chdev_t * src_chdev )
99{
100    // get pointer on PIC chdev
101    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
102
103    // call relevant driver function
104    pic->ext.pic.disable_irq( src_chdev );
105}
106
107////////////////////////////////////////////
108void dev_pic_enable_timer( uint32_t period )
109{
110    // get pointer on PIC chdev
111    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
112
113    // call relevant driver function
114    pic->ext.pic.enable_timer( period );
115}
116
117//////////////////////////////////
118void dev_pic_send_ipi( cxy_t  cxy,
119                       lid_t  lid )
120{
121    // get pointer on PIC chdev
122    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
123
124    // call relevant driver function
125    pic->ext.pic.send_ipi( cxy , lid );
126}
127
128
Note: See TracBrowser for help on using the repository browser.