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

Last change on this file since 8 was 3, checked in by alain, 8 years ago

Introduce dev_fbf, dev dma, dev_iob

File size: 3.3 KB
RevLine 
[1]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 <dev_icu.h>
[3]27#include <chdev.h>
[1]28#include <memcpy.h>
29#include <printk.h>
30#include <soclib_pic.h>
31#include <dev_pic.h>
32
33/////////////////////////////////////////////////////////////////////////////////////////
34// Extern global variables
35/////////////////////////////////////////////////////////////////////////////////////////
36
[3]37extern chdev_directory_t  chdev_dir;         // allocated in kernel_init.c
[1]38
[3]39extern chdev_pic_input_t  chdev_pic_input;   // allocated in kernel_init.c
[1]40
41///////////////////////////////////
[3]42void dev_pic_init( chdev_t * chdev,
43                   uint32_t  irq_nr )
[1]44{
[3]45    // set PIC chdev extension field
46    chdev->ext.pic.irq_nr = irq_nr;
[1]47
[3]48    // get implementation
49    uint32_t impl = chdev->impl;
[1]50
[3]51    // call the relevant driver init function
[1]52    if( impl == IMPL_PIC_SOC )
53    {
[3]54        soclib_pic_init( chdev );
[1]55    }
56    else
57    {
[3]58        assert( false , __FUNCTION__ , "illegal PIC device implementation" );
[1]59    }
60} // end dev_pic_init()
61
62/////////////////////////////////////////
63void dev_pic_bind_irq( uint32_t   irq_id,
64                       cxy_t      cxy,
65                       uint32_t   wti_id )
66{
67    // get extended pointer on WTI mailbox
[3]68    xptr_t wti_xp = XPTR( cxy , dev_icu_wti_ptr( wti_id ) );
[1]69
[3]70    // get extended pointer on PIC chdev from directory
71    xptr_t dev_xp = chdev_dir.pic;
[1]72
[3]73    // get PIC chdev cluster and local pointer
74    cxy_t     dev_cxy = GET_CXY( dev_xp );
75    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
[1]76
77    // get implementation index and segment base
78    uint32_t impl   = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->impl ) );
79
80    // call the implementation specific driver function
81    if( impl == IMPL_PIC_SOC )
82    {
83        soclib_pic_bind_irq( dev_xp , irq_id , wti_xp );
84    }
85}  // end dev_pic_link_wti()
86
87//////////////////////////////////////////
88void dev_pic_unbind_irq( uint32_t irq_id )
89{
[3]90    // get extended pointer on PIC chdev from directory
91    xptr_t dev_xp = chdev_dir.pic;
[1]92
[3]93    // get PIC chdev cluster and local pointer
94    cxy_t     dev_cxy = GET_CXY( dev_xp );
95    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
[1]96
97    // get implementation index
98    uint32_t impl = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->impl ) );
99
100    // call the implementation specific driver function
101    if( impl == IMPL_PIC_SOC )
102    {
103        soclib_pic_unbind_irq( dev_xp , irq_id );
104    }
105} // end dev_pic_disable_irq()
106
107
Note: See TracBrowser for help on using the repository browser.