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

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

Hide IMPL_PIC_.

File size: 4.2 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 implementation-specific PIC driver
48    hal_drivers_pic_init(pic, impl);
49}
50
51/////////////////////////////////////////////////
52void dev_pic_extend_init( uint32_t * lapic_base )
53{
54    // get pointer on PIC chdev
55    chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic );
56    cxy_t     pic_cxy = GET_CXY( chdev_dir.pic );
57
58    // get pointer on extend_init function
59    extend_init_t * f = hal_remote_lpt( XPTR( pic_cxy , &pic_ptr->ext.pic.extend_init ) ); 
60
61    // call relevant driver function
62    f( lapic_base );
63}
64
65/////////////////////////////////////
66void dev_pic_bind_irq( lid_t     lid,
67                       chdev_t * src_chdev )
68{
69    // get pointer on PIC chdev
70    chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic );
71    cxy_t     pic_cxy = GET_CXY( chdev_dir.pic );
72
73    // get pointer on bind_irq function
74    bind_irq_t * f = hal_remote_lpt( XPTR( pic_cxy , &pic_ptr->ext.pic.bind_irq ) );
75
76    // call relevant driver function
77    f( lid , src_chdev );
78}
79
80/////////////////////////////////////
81void dev_pic_enable_irq( lid_t   lid,
82                         xptr_t  src_chdev_xp )
83{
84    // get pointer on PIC chdev
85    chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic );
86    cxy_t     pic_cxy = GET_CXY( chdev_dir.pic );
87
88    // get pointer on enable_irq function
89    enable_irq_t * f = hal_remote_lpt( XPTR( pic_cxy , &pic_ptr->ext.pic.enable_irq ) );
90
91    // call relevant driver function
92    f( lid , src_chdev_xp );
93}
94
95//////////////////////////////////////
96void dev_pic_disable_irq( lid_t   lid,
97                          xptr_t  src_chdev_xp )
98{
99    // get pointer on PIC chdev
100    chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic );
101    cxy_t     pic_cxy = GET_CXY( chdev_dir.pic );
102
103    // get pointer on disable_irq function
104    disable_irq_t * f = hal_remote_lpt( XPTR( pic_cxy , &pic_ptr->ext.pic.disable_irq ) );
105
106    // call relevant driver function
107    f( lid , src_chdev_xp );
108}
109
110////////////////////////////////////////////
111void dev_pic_enable_timer( uint32_t period )
112{
113    // get pointer on PIC chdev
114    chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic );
115    cxy_t     pic_cxy = GET_CXY( chdev_dir.pic );
116
117    // get pointer on enable_timer function
118    enable_timer_t * f = hal_remote_lpt( XPTR( pic_cxy , &pic_ptr->ext.pic.enable_timer ) );
119
120    // call relevant driver function
121    f( period );
122}
123
124//////////////////////////////////
125void dev_pic_send_ipi( cxy_t  cxy,
126                       lid_t  lid )
127{
128    // get pointer on PIC chdev
129    chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic );
130    cxy_t     pic_cxy = GET_CXY( chdev_dir.pic );
131
132    // get pointer on send_ipi function
133    send_ipi_t * f = hal_remote_lpt( XPTR( pic_cxy , &pic_ptr->ext.pic.send_ipi ) );
134
135    // call relevant driver function
136    f( cxy , lid );
137}
138
Note: See TracBrowser for help on using the repository browser.