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

Last change on this file since 529 was 528, checked in by alain, 10 years ago

1) Introducing support for external IRQs dynamic routing.
2) Simplifying the _v2p_translate() function.
3) Removing the generic IOC driver (integrated in the FAT library).

  • Property svn:executable set to *
File size: 6.6 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#ifndef _IRQ_HANDLER_H
12#define _IRQ_HANDLER_H
13
14///////////////////////////////////////////////////////////////////////////
15// This enum must consistent with the values defined in
16// xml_driver.c / xml_parser.c / irq_handler.c / mapping.py
17///////////////////////////////////////////////////////////////////////////
18
19enum isr_type_t
20{
21    ISR_DEFAULT = 0,
22    ISR_TICK    = 1,
23    ISR_TTY_RX  = 2,
24    ISR_TTY_TX  = 3,
25    ISR_BDV     = 4,
26    ISR_TIMER   = 5,
27    ISR_WAKUP   = 6,
28    ISR_NIC_RX  = 7,
29    ISR_NIC_TX  = 8,
30    ISR_CMA     = 9,
31    ISR_MMC     = 10,
32    ISR_DMA     = 11,
33    ISR_SPI     = 12,
34    ISR_MWR     = 13,
35    ISR_HBA     = 14,
36};
37
38///////////////////////////////////////////////////////////////////////////
39//    Global variables allocated in irq_handler.c     
40///////////////////////////////////////////////////////////////////////////
41
42// array of external IRQ indexes for each (isr/channel) couple
43extern 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)
46extern unsigned char _wti_alloc_one[X_SIZE][Y_SIZE][NB_PROCS_MAX];
47extern unsigned char _wti_alloc_two[X_SIZE][Y_SIZE][NB_PROCS_MAX];
48extern unsigned char _wti_alloc_ter[X_SIZE][Y_SIZE][NB_PROCS_MAX];
49
50///////////////////////////////////////////////////////////////////////////
51//    irq_handler functions
52///////////////////////////////////////////////////////////////////////////
53
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
62extern 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
77extern 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
89extern 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
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).
99// Any value larger than 31 means "no active interrupt".
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.
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
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   
108///////////////////////////////////////////////////////////////////////////
109
110extern void _irq_demux();
111
112///////////////////////////////////////////////////////////////////////////
113// This default ISR is called  when the interrupt handler is called,
114// and there is no active IRQ. It displays a warning message on TTY[0].
115///////////////////////////////////////////////////////////////////////////
116
117extern void _isr_default();
118
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
126extern 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/////////////////////////////////////////////////////////////////////////////////////
136extern void _isr_tick( unsigned int irq_type,
137                       unsigned int irq_id,
138                       unsigned int channel );
139
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
Note: See TracBrowser for help on using the repository browser.