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

Last change on this file since 819 was 697, checked in by guerin, 9 years ago

kernel: release WTI mailbox associated with TTY

We don't block on giet_tty_alloc() anymore when launching the same app
again and again.

  • Property svn:executable set to *
File size: 6.7 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
100///////////////////////////////////////////////////////////////////////////
101// This function access the XICU component (Interrupt Controler Unit)
102// to get the interrupt vector entry. There is one XICU component per
103// cluster, and this component can support up to NB_PROCS_MAX output IRQs.
104// It returns the highest priority active interrupt index (smaller
105// indexes have the highest priority).
106// Any value larger than 31 means "no active interrupt".
107//
108// There is three interrupt vectors per processor (stored in the processor's
109// scheduler) for the three HWI, PTI, and WTI interrupts types.
110// Each interrupt vector entry contains two fields:
111// - isr_type     bits[15:0]  : defines the type of ISR to be executed.
112// - isr_channel  bits[31:16] : defines the channel index
113// If the peripheral is replicated in clusters, the channel_id is
114// a global index : channel_id = cluster_id * NB_CHANNELS_MAX + loc_id   
115///////////////////////////////////////////////////////////////////////////
116
117extern void _irq_demux();
118
119///////////////////////////////////////////////////////////////////////////
120// This default ISR is called  when the interrupt handler is called,
121// and there is no active IRQ. It displays a warning message on TTY[0].
122///////////////////////////////////////////////////////////////////////////
123
124extern void _isr_default();
125
126///////////////////////////////////////////////////////////////////////////
127// This ISR can only be executed after a WTI to force a context switch
128// on a remote processor. The context switch is only executed if the
129// current task is the IDLE_TASK, or if the value written in the mailbox
130// is non zero.
131///////////////////////////////////////////////////////////////////////////
132
133extern void _isr_wakup( unsigned int irq_type,
134                        unsigned int irq_id,
135                        unsigned int channel );
136
137/////////////////////////////////////////////////////////////////////////////////////
138// This ISR is in charge of context switch, and handles the IRQs generated by
139// the "system" timers. It can be PTI in case of XCU, or it can be HWI generated
140// by an external timer in case of ICU.
141// The ISR acknowledges the IRQ, and calls the _ctx_switch() function.
142/////////////////////////////////////////////////////////////////////////////////////
143extern void _isr_tick( unsigned int irq_type,
144                       unsigned int irq_id,
145                       unsigned int channel );
146
147#endif
148
149// Local Variables:
150// tab-width: 4
151// c-basic-offset: 4
152// c-file-offsets:((innamespace . 0)(inline-open . 0))
153// indent-tabs-mode: nil
154// End:
155// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
156
Note: See TracBrowser for help on using the repository browser.