[1] | 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 <almos_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 ''devices_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 | /***************************************************************************************** |
---|
| 51 | * This defines the (implementation independant) extension for the generic ICU device. |
---|
| 52 | ****************************************************************************************/ |
---|
| 53 | |
---|
| 54 | typedef struct pic_extend_s |
---|
| 55 | { |
---|
| 56 | uint32_t irq_nr; /*! actual number of input IRQs to the PIC device */ |
---|
| 57 | } |
---|
| 58 | pic_extend_t; |
---|
| 59 | |
---|
| 60 | /***************************************************************************************** |
---|
| 61 | * This enum defines the various implementations of the PIC external interrupt controller. |
---|
| 62 | * This array must be kept consistent with the define in arch_info.h file |
---|
| 63 | ****************************************************************************************/ |
---|
| 64 | |
---|
| 65 | enum pic_impl_e |
---|
| 66 | { |
---|
| 67 | IMPL_PIC_SOC = 0, |
---|
| 68 | IMPL_PIC_I86 = 1, |
---|
| 69 | } |
---|
| 70 | pic_impl_t; |
---|
| 71 | |
---|
| 72 | /***************************************************************************************** |
---|
| 73 | * This function makes two initialisations: |
---|
| 74 | * - It initializes the PIC specific fields of the device descriptor. |
---|
| 75 | * - it initializes the implementation specific PIC hardware device. |
---|
| 76 | * It must be executed once in the kernel initialisation phase. |
---|
| 77 | ***************************************************************************************** |
---|
| 78 | * @ xp_dev : extended pointer on PIC device descriptor. |
---|
| 79 | * @ uint32_t : actual number of input IRQs. |
---|
| 80 | ****************************************************************************************/ |
---|
| 81 | void dev_pic_init( xptr_t xp_dev, |
---|
| 82 | uint32_t irq_nr ); |
---|
| 83 | |
---|
| 84 | /***************************************************************************************** |
---|
| 85 | * This function link a WTI mailbox to the PIC input IRQ identified by its index, |
---|
| 86 | * and unmask the selected input IRQ, calling the relevant driver. |
---|
| 87 | ***************************************************************************************** |
---|
| 88 | * @ irq_id : input IRQ index. |
---|
| 89 | * @ cxy : WTI mailbox cluster. |
---|
| 90 | * @ wti_id : WTI mailbox index in cluster. |
---|
| 91 | ****************************************************************************************/ |
---|
| 92 | void dev_pic_bind_irq( uint32_t irq_id, |
---|
| 93 | cxy_t cxy, |
---|
| 94 | uint32_t wti_id ); |
---|
| 95 | |
---|
| 96 | /***************************************************************************************** |
---|
| 97 | * This function mask a PIC input IRQ identified by its index, calling te relevant driver. |
---|
| 98 | ***************************************************************************************** |
---|
| 99 | * @ irq_id : input IRQ index. |
---|
| 100 | ****************************************************************************************/ |
---|
| 101 | void dev_pic_unbind_irq( uint32_t irq_id ); |
---|
| 102 | |
---|
| 103 | |
---|
| 104 | #endif /* _DEV_PIC_H_ */ |
---|