source: trunk/kernel/devices/dev_pic.h @ 98

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

Bugs fix.

File size: 4.8 KB
Line 
1/*
2 * dev_pic.h - PIC (External Interrupt Controler) generic device API definition.
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 PARTICULAR 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#ifndef _DEV_PIC_H_
25#define _DEV_PIC_H_
26
27#include <kernel_config.h>
28#include <hal_types.h>
29
30/*****************************************************************************************
31 *     Generic External Interrupt Controler definition
32 *
33 * The PIC generic device describes an external interrupt Controler, that translates
34 * N input IRQs generated by external peripherals to N WTI IRQs, that will be routed
35 * to a dynamically allocated WTI mailbox in a given cluster.
36 *
37 * The max number of input IRQs is defined by the CONFIG_MAX_IRQS_PER_PIC parameter.
38 * The actual number of connected IRQs is defined in the ''arch_info'' file, and stored
39 * in the PIC device extension. 
40 * The "source" device for each input IRQ is also defined in the ''arch_info'' file,
41 * and are stored in the ''chdev_input_irq'' global variable in kernel initialization.
42 *
43 * This external peripheral does not execute I/O operations, but is just acting as a
44 * dynamically configurable interrupt router for another I/O operation. Therefore,
45 * ALMOS-MKH does not use the PIC device waiting queue, but call directly the relevant
46 * driver blocking functions to dynamically "bind" or "unbind" an external IRQ to a
47 * WTI mailbox.
48 ****************************************************************************************/
49 
50/****  Forward declarations  ****/
51
52struct chdev_s;
53
54/*****************************************************************************************
55 * This defines the (implementation independant) extension for the PIC device.
56 ****************************************************************************************/
57
58typedef struct pic_extend_s
59{
60    uint32_t    irq_nr;     /*! actual number of input IRQs to the PIC device           */
61}
62pic_extend_t;
63
64/*****************************************************************************************
65 * This enum defines the various implementations of the PIC external interrupt controller.
66 * This array must be kept consistent with the define in arch_info.h file
67 ****************************************************************************************/
68
69enum pic_impl_e
70{
71    IMPL_PIC_SOC =   0,     
72    IMPL_PIC_I86 =   1,
73}
74pic_impl_t;
75
76/*****************************************************************************************
77 * This function makes two initialisations:
78 * - It initializes the PIC specific fields of the chdev descriptor.
79 * - it initializes the implementation specific PIC hardware device.
80 * It must be executed once in the kernel initialisation phase.
81 *****************************************************************************************
82 * @ xp_dev     : extended pointer on PIC device descriptor.
83 * @ uint32_t   : actual number of input IRQs.
84 ****************************************************************************************/
85void dev_pic_init( struct chdev_s * chdev,
86                   uint32_t         irq_nr );
87
88/*****************************************************************************************
89 * This function link a WTI mailbox to the PIC input IRQ identified by its index,
90 * and unmask the selected input IRQ, calling the relevant driver.
91 *****************************************************************************************
92 * @ irq_id    : input IRQ index.
93 * @ cxy       : WTI mailbox cluster.
94 * @ wti_id    : WTI mailbox index in cluster.
95 ****************************************************************************************/
96void dev_pic_bind_irq( uint32_t   irq_id,
97                       cxy_t      cxy,
98                       uint32_t   wti_id );
99
100/*****************************************************************************************
101 * This function mask a PIC input IRQ identified by its index, calling te relevant driver.
102 *****************************************************************************************
103 * @ irq_id    : input IRQ index.
104 ****************************************************************************************/
105void dev_pic_unbind_irq( uint32_t   irq_id );
106                       
107
108#endif  /* _DEV_PIC_H_ */
Note: See TracBrowser for help on using the repository browser.