source: soft/giet_vm/giet_kernel/irq_handler.h @ 695

Last change on this file since 695 was 629, checked in by alain, 9 years ago

Modify the task activation/desactivation mechanism
to support the _kill_application() and _exec_application() system functions.
The RUN Boolean in task context has been replaced by the NORUN bit-vector.

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