1 /** @file
2   Abstraction for hardware based interrupt routine
3 
4   On non IA-32 systems it is common to have a single hardware interrupt vector
5   and a 2nd layer of software that routes the interrupt handlers based on the
6   interrupt source. This protocol enables this routing. The driver implementing
7   this protocol is responsible for clearing the pending interrupt in the
8   interrupt routing hardware. The HARDWARE_INTERRUPT_HANDLER is responsible
9   for clearing interrupt sources from individual devices.
10 
11 
12   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
13 
14   This program and the accompanying materials
15   are licensed and made available under the terms and conditions of the BSD License
16   which accompanies this distribution.  The full text of the license may be found at
17   http://opensource.org/licenses/bsd-license.php
18 
19   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
20   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 
22 **/
23 
24 #ifndef __HARDWARE_INTERRUPT_H__
25 #define __HARDWARE_INTERRUPT_H__
26 
27 #include <Protocol/DebugSupport.h>
28 
29 
30 //
31 // Protocol GUID
32 //
33 // EAB39028-3D05-4316-AD0C-D64808DA3FF1
34 
35 #define EFI_HARDWARE_INTERRUPT_PROTOCOL_GGUID \
36   { 0x2890B3EA, 0x053D, 0x1643, { 0xAD, 0x0C, 0xD6, 0x48, 0x08, 0xDA, 0x3F, 0xF1 } }
37 
38 
39 typedef struct _EFI_HARDWARE_INTERRUPT_PROTOCOL EFI_HARDWARE_INTERRUPT_PROTOCOL;
40 
41 
42 typedef UINTN HARDWARE_INTERRUPT_SOURCE;
43 
44 
45 /**
46   C Interrupt Handler calledin the interrupt context when Source interrupt is active.
47 
48   @param Source         Source of the interrupt. Hardware routing off a specific platform defines
49                         what source means.
50   @param SystemContext  Pointer to system register context. Mostly used by debuggers and will
51                         update the system context after the return from the interrupt if
52                         modified. Don't change these values unless you know what you are doing
53 
54 **/
55 typedef
56 VOID
57 (EFIAPI *HARDWARE_INTERRUPT_HANDLER) (
58   IN  HARDWARE_INTERRUPT_SOURCE   Source,
59   IN  EFI_SYSTEM_CONTEXT          SystemContext
60   );
61 
62 
63 /**
64   Register Handler for the specified interrupt source.
65 
66   @param This     Instance pointer for this protocol
67   @param Source   Hardware source of the interrupt
68   @param Handler  Callback for interrupt. NULL to unregister
69 
70   @retval EFI_SUCCESS Source was updated to support Handler.
71   @retval EFI_DEVICE_ERROR  Hardware could not be programmed.
72 
73 **/
74 typedef
75 EFI_STATUS
76 (EFIAPI *HARDWARE_INTERRUPT_REGISTER) (
77   IN EFI_HARDWARE_INTERRUPT_PROTOCOL    *This,
78   IN HARDWARE_INTERRUPT_SOURCE          Source,
79   IN HARDWARE_INTERRUPT_HANDLER         Handler
80   );
81 
82 
83 /**
84   Enable interrupt source Source.
85 
86   @param This     Instance pointer for this protocol
87   @param Source   Hardware source of the interrupt
88 
89   @retval EFI_SUCCESS       Source interrupt enabled.
90   @retval EFI_DEVICE_ERROR  Hardware could not be programmed.
91 
92 **/
93 typedef
94 EFI_STATUS
95 (EFIAPI *HARDWARE_INTERRUPT_ENABLE) (
96   IN EFI_HARDWARE_INTERRUPT_PROTOCOL    *This,
97   IN HARDWARE_INTERRUPT_SOURCE          Source
98   );
99 
100 
101 
102 /**
103   Disable interrupt source Source.
104 
105   @param This     Instance pointer for this protocol
106   @param Source   Hardware source of the interrupt
107 
108   @retval EFI_SUCCESS       Source interrupt disabled.
109   @retval EFI_DEVICE_ERROR  Hardware could not be programmed.
110 
111 **/
112 typedef
113 EFI_STATUS
114 (EFIAPI *HARDWARE_INTERRUPT_DISABLE) (
115   IN EFI_HARDWARE_INTERRUPT_PROTOCOL    *This,
116   IN HARDWARE_INTERRUPT_SOURCE          Source
117   );
118 
119 
120 /**
121   Return current state of interrupt source Source.
122 
123   @param This     Instance pointer for this protocol
124   @param Source   Hardware source of the interrupt
125   @param InterruptState  TRUE: source enabled, FALSE: source disabled.
126 
127   @retval EFI_SUCCESS       InterruptState is valid
128   @retval EFI_DEVICE_ERROR  InterruptState is not valid
129 
130 **/
131 typedef
132 EFI_STATUS
133 (EFIAPI *HARDWARE_INTERRUPT_INTERRUPT_STATE) (
134   IN EFI_HARDWARE_INTERRUPT_PROTOCOL    *This,
135   IN HARDWARE_INTERRUPT_SOURCE          Source,
136   IN BOOLEAN                            *InterruptState
137   );
138 
139 /**
140   Signal to the hardware that the End Of Intrrupt state
141   has been reached.
142 
143   @param This     Instance pointer for this protocol
144   @param Source   Hardware source of the interrupt
145 
146   @retval EFI_SUCCESS       Source interrupt EOI'ed.
147   @retval EFI_DEVICE_ERROR  Hardware could not be programmed.
148 
149 **/
150 typedef
151 EFI_STATUS
152 (EFIAPI *HARDWARE_INTERRUPT_END_OF_INTERRUPT) (
153   IN EFI_HARDWARE_INTERRUPT_PROTOCOL    *This,
154   IN HARDWARE_INTERRUPT_SOURCE          Source
155   );
156 
157 
158 struct _EFI_HARDWARE_INTERRUPT_PROTOCOL {
159   HARDWARE_INTERRUPT_REGISTER         RegisterInterruptSource;
160   HARDWARE_INTERRUPT_ENABLE           EnableInterruptSource;
161   HARDWARE_INTERRUPT_DISABLE          DisableInterruptSource;
162   HARDWARE_INTERRUPT_INTERRUPT_STATE  GetInterruptSourceState;
163   HARDWARE_INTERRUPT_END_OF_INTERRUPT EndOfInterrupt;
164 };
165 
166 extern EFI_GUID gHardwareInterruptProtocolGuid;
167 
168 #endif
169 
170 
171