[528] | 1 | /////////////////////////////////////////////////////////////////////////// |
---|
[294] | 2 | // File : irq_handler.h |
---|
| 3 | // Date : 01/04/2012 |
---|
| 4 | // Author : alain greiner |
---|
| 5 | // Copyright (c) UPMC-LIP6 |
---|
[528] | 6 | /////////////////////////////////////////////////////////////////////////// |
---|
| 7 | // The irq_handler.c and irq_handler.h files are part of the GIET-VM. |
---|
| 8 | // They contain the code of used to handlle HWI, WTI, PTI interrupts. |
---|
| 9 | /////////////////////////////////////////////////////////////////////////// |
---|
[294] | 10 | |
---|
[258] | 11 | #ifndef _IRQ_HANDLER_H |
---|
| 12 | #define _IRQ_HANDLER_H |
---|
| 13 | |
---|
[528] | 14 | /////////////////////////////////////////////////////////////////////////// |
---|
[519] | 15 | // This enum must consistent with the values defined in |
---|
[528] | 16 | // xml_driver.c / xml_parser.c / irq_handler.c / mapping.py |
---|
| 17 | /////////////////////////////////////////////////////////////////////////// |
---|
[294] | 18 | |
---|
[258] | 19 | enum isr_type_t |
---|
| 20 | { |
---|
| 21 | ISR_DEFAULT = 0, |
---|
[294] | 22 | ISR_TICK = 1, |
---|
| 23 | ISR_TTY_RX = 2, |
---|
| 24 | ISR_TTY_TX = 3, |
---|
| 25 | ISR_BDV = 4, |
---|
[258] | 26 | ISR_TIMER = 5, |
---|
| 27 | ISR_WAKUP = 6, |
---|
[294] | 28 | ISR_NIC_RX = 7, |
---|
| 29 | ISR_NIC_TX = 8, |
---|
| 30 | ISR_CMA = 9, |
---|
[297] | 31 | ISR_MMC = 10, |
---|
[322] | 32 | ISR_DMA = 11, |
---|
| 33 | ISR_SPI = 12, |
---|
[519] | 34 | ISR_MWR = 13, |
---|
[528] | 35 | ISR_HBA = 14, |
---|
[258] | 36 | }; |
---|
| 37 | |
---|
[528] | 38 | /////////////////////////////////////////////////////////////////////////// |
---|
| 39 | // Global variables allocated in irq_handler.c |
---|
| 40 | /////////////////////////////////////////////////////////////////////////// |
---|
| 41 | |
---|
| 42 | // array of external IRQ indexes for each (isr/channel) couple |
---|
| 43 | extern unsigned char _ext_irq_index[GIET_ISR_TYPE_MAX][GIET_ISR_CHANNEL_MAX]; |
---|
| 44 | |
---|
| 45 | // WTI mailbox allocators for external IRQ routing (3 allocators per proc) |
---|
| 46 | extern unsigned char _wti_alloc_one[X_SIZE][Y_SIZE][NB_PROCS_MAX]; |
---|
| 47 | extern unsigned char _wti_alloc_two[X_SIZE][Y_SIZE][NB_PROCS_MAX]; |
---|
| 48 | extern unsigned char _wti_alloc_ter[X_SIZE][Y_SIZE][NB_PROCS_MAX]; |
---|
| 49 | |
---|
| 50 | /////////////////////////////////////////////////////////////////////////// |
---|
[440] | 51 | // irq_handler functions |
---|
[528] | 52 | /////////////////////////////////////////////////////////////////////////// |
---|
[258] | 53 | |
---|
[528] | 54 | /////////////////////////////////////////////////////////////////////////// |
---|
| 55 | // This function is only used when the architecture contains an external |
---|
| 56 | // IOPIC component. It initializes the _ext_irq_index[isr][channel] array, |
---|
| 57 | // defining the IRQ index associated to (isr_type/isr_channel) couple. |
---|
| 58 | // This array is used by the kernel for dynamic routing of an external IRQ |
---|
| 59 | // signaling completion to the processor that launched the I/O operation. |
---|
| 60 | /////////////////////////////////////////////////////////////////////////// |
---|
| 61 | |
---|
| 62 | extern void _ext_irq_init(); |
---|
| 63 | |
---|
| 64 | /////////////////////////////////////////////////////////////////////////// |
---|
| 65 | // This function is only used when the architecture contains an external |
---|
| 66 | // IOPIC component. It dynamically routes an external IRQ signaling |
---|
| 67 | // completion of an I/O operation to the processor P[x,y,p] running |
---|
| 68 | // the calling task. |
---|
| 69 | // 1) it allocates a WTI mailbox in the XCU of cluster[x,y] : Each processor |
---|
| 70 | // has 3 mailboxes, with index in [4*p+1, 4*p+2, 4*p+3]. |
---|
| 71 | // 2) it initialises the IOPIC_ADDRESS and IOPIC_MASK registers associated |
---|
| 72 | // to the (isr_type/isr_channel) couple. |
---|
| 73 | // 3) it initializes the proper entry in the WTI interrupt vector associated |
---|
| 74 | // to processor P[x,y,p]. |
---|
| 75 | /////////////////////////////////////////////////////////////////////////// |
---|
| 76 | |
---|
| 77 | extern void _ext_irq_alloc( unsigned int isr_type, |
---|
| 78 | unsigned int isr_channel, |
---|
| 79 | unsigned int* wti_index ); |
---|
| 80 | |
---|
| 81 | /////////////////////////////////////////////////////////////////////////// |
---|
| 82 | // This function is only used when the architecture contains an external |
---|
| 83 | // IOPIC component. It desallocates all ressources allocated by the |
---|
| 84 | // previous _ext_irq_alloc() function to the calling processor. |
---|
| 85 | // 1) it desactivates the PIC entry associated to (isr_type/isr_channel). |
---|
| 86 | // 2) it releases the WTI mailbox in the XCU of cluster[x,y]. |
---|
| 87 | /////////////////////////////////////////////////////////////////////////// |
---|
| 88 | |
---|
| 89 | extern void _ext_irq_release( unsigned int isr_type, |
---|
| 90 | unsigned int isr_channel, |
---|
| 91 | unsigned int wti_index ); |
---|
| 92 | |
---|
| 93 | /////////////////////////////////////////////////////////////////////////// |
---|
| 94 | // This function access the XICU component (Interrupt Controler Unit) |
---|
| 95 | // to get the interrupt vector entry. There is one XICU component per |
---|
[440] | 96 | // cluster, and this component can support up to NB_PROCS_MAX output IRQs. |
---|
| 97 | // It returns the highest priority active interrupt index (smaller |
---|
| 98 | // indexes have the highest priority). |
---|
[528] | 99 | // Any value larger than 31 means "no active interrupt". |
---|
[440] | 100 | // |
---|
| 101 | // There is three interrupt vectors per processor (stored in the processor's |
---|
| 102 | // scheduler) for the three HWI, PTI, and WTI interrupts types. |
---|
[528] | 103 | // Each interrupt vector entry contains two fields: |
---|
| 104 | // - isr_type bits[15:0] : defines the type of ISR to be executed. |
---|
| 105 | // - isr_channel bits[31:16] : defines the channel index |
---|
[440] | 106 | // If the peripheral is replicated in clusters, the channel_id is |
---|
| 107 | // a global index : channel_id = cluster_id * NB_CHANNELS_MAX + loc_id |
---|
[528] | 108 | /////////////////////////////////////////////////////////////////////////// |
---|
| 109 | |
---|
[258] | 110 | extern void _irq_demux(); |
---|
| 111 | |
---|
[528] | 112 | /////////////////////////////////////////////////////////////////////////// |
---|
[440] | 113 | // This default ISR is called when the interrupt handler is called, |
---|
[528] | 114 | // and there is no active IRQ. It displays a warning message on TTY[0]. |
---|
| 115 | /////////////////////////////////////////////////////////////////////////// |
---|
| 116 | |
---|
[258] | 117 | extern void _isr_default(); |
---|
| 118 | |
---|
[528] | 119 | /////////////////////////////////////////////////////////////////////////// |
---|
| 120 | // This ISR can only be executed after a WTI to force a context switch |
---|
| 121 | // on a remote processor. The context switch is only executed if the |
---|
| 122 | // current task is the IDLE_TASK, or if the value written in the mailbox |
---|
| 123 | // is non zero. |
---|
| 124 | /////////////////////////////////////////////////////////////////////////// |
---|
| 125 | |
---|
[440] | 126 | extern void _isr_wakup( unsigned int irq_type, |
---|
| 127 | unsigned int irq_id, |
---|
| 128 | unsigned int channel ); |
---|
| 129 | |
---|
| 130 | ///////////////////////////////////////////////////////////////////////////////////// |
---|
| 131 | // This ISR is in charge of context switch, and handles the IRQs generated by |
---|
| 132 | // the "system" timers. It can be PTI in case of XCU, or it can be HWI generated |
---|
| 133 | // by an external timer in case of ICU. |
---|
| 134 | // The ISR acknowledges the IRQ, and calls the _ctx_switch() function. |
---|
| 135 | ///////////////////////////////////////////////////////////////////////////////////// |
---|
[294] | 136 | extern void _isr_tick( unsigned int irq_type, |
---|
| 137 | unsigned int irq_id, |
---|
| 138 | unsigned int channel ); |
---|
| 139 | |
---|
[258] | 140 | #endif |
---|
| 141 | |
---|
| 142 | // Local Variables: |
---|
| 143 | // tab-width: 4 |
---|
| 144 | // c-basic-offset: 4 |
---|
| 145 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 146 | // indent-tabs-mode: nil |
---|
| 147 | // End: |
---|
| 148 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 149 | |
---|