31UINT8 mMasterBase = 0xff;
32UINT8 mSlaveBase = 0xff;
33EFI_8259_MODE mMode = Efi8259ProtectedMode;
34UINT16 mProtectedModeMask = 0xffff;
35UINT16 mLegacyModeMask;
36UINT16 mProtectedModeEdgeLevel = 0x0000;
37UINT16 mLegacyModeEdgeLevel;
58 IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, (UINT8)Mask);
59 IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, (UINT8)(Mask >> 8));
60 IoWrite8 (LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER, (UINT8)EdgeLevel);
61 IoWrite8 (LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE, (UINT8)(EdgeLevel >> 8));
83 MasterValue =
IoRead8 (LEGACY_8259_MASK_REGISTER_MASTER);
84 SlaveValue =
IoRead8 (LEGACY_8259_MASK_REGISTER_SLAVE);
86 *Mask = (UINT16)(MasterValue | (SlaveValue << 8));
89 if (EdgeLevel !=
NULL) {
90 MasterValue =
IoRead8 (LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER);
91 SlaveValue =
IoRead8 (LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE);
93 *EdgeLevel = (UINT16)(MasterValue | (SlaveValue << 8));
123 OriginalTpl =
gBS->RaiseTPL (TPL_HIGH_LEVEL);
127 if (SlaveBase != mSlaveBase) {
128 mSlaveBase = SlaveBase;
138 Mask =
IoRead8 (LEGACY_8259_MASK_REGISTER_SLAVE);
143 IoWrite8 (LEGACY_8259_CONTROL_REGISTER_SLAVE, 0x11);
148 IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, mSlaveBase);
153 IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0x02);
158 IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0x01);
163 IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, Mask);
169 if (MasterBase != mMasterBase) {
170 mMasterBase = MasterBase;
180 Mask =
IoRead8 (LEGACY_8259_MASK_REGISTER_MASTER);
185 IoWrite8 (LEGACY_8259_CONTROL_REGISTER_MASTER, 0x11);
190 IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, mMasterBase);
195 IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0x04);
200 IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0x01);
205 IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, Mask);
208 IoWrite8 (LEGACY_8259_CONTROL_REGISTER_SLAVE, LEGACY_8259_EOI);
209 IoWrite8 (LEGACY_8259_CONTROL_REGISTER_MASTER, LEGACY_8259_EOI);
211 gBS->RestoreTPL (OriginalTpl);
233 OUT UINT16 *LegacyMask OPTIONAL,
234 OUT UINT16 *LegacyEdgeLevel OPTIONAL,
235 OUT UINT16 *ProtectedMask OPTIONAL,
236 OUT UINT16 *ProtectedEdgeLevel OPTIONAL
239 if (LegacyMask !=
NULL) {
240 *LegacyMask = mLegacyModeMask;
243 if (LegacyEdgeLevel !=
NULL) {
244 *LegacyEdgeLevel = mLegacyModeEdgeLevel;
247 if (ProtectedMask !=
NULL) {
248 *ProtectedMask = mProtectedModeMask;
251 if (ProtectedEdgeLevel !=
NULL) {
252 *ProtectedEdgeLevel = mProtectedModeEdgeLevel;
275 IN UINT16 *LegacyMask OPTIONAL,
276 IN UINT16 *LegacyEdgeLevel OPTIONAL,
277 IN UINT16 *ProtectedMask OPTIONAL,
278 IN UINT16 *ProtectedEdgeLevel OPTIONAL
281 if (LegacyMask !=
NULL) {
282 mLegacyModeMask = *LegacyMask;
285 if (LegacyEdgeLevel !=
NULL) {
286 mLegacyModeEdgeLevel = *LegacyEdgeLevel;
289 if (ProtectedMask !=
NULL) {
290 mProtectedModeMask = *ProtectedMask;
293 if (ProtectedEdgeLevel !=
NULL) {
294 mProtectedModeEdgeLevel = *ProtectedEdgeLevel;
316 IN EFI_8259_MODE Mode,
317 IN UINT16 *Mask OPTIONAL,
318 IN UINT16 *EdgeLevel OPTIONAL
325 if (Mode == Efi8259LegacyMode) {
337 mLegacyModeMask = *Mask;
340 if (EdgeLevel !=
NULL) {
344 mLegacyModeEdgeLevel = *EdgeLevel;
357 if (Mode == Efi8259ProtectedMode) {
366 mLegacyModeMask &= 0xFFFE;
372 mProtectedModeMask = *Mask;
375 if (EdgeLevel !=
NULL) {
379 mProtectedModeEdgeLevel = *EdgeLevel;
392 return EFI_INVALID_PARAMETER;
414 if ((UINT32)Irq > Efi8259Irq15) {
415 return EFI_INVALID_PARAMETER;
418 if (Irq <= Efi8259Irq7) {
419 *Vector = (UINT8)(mMasterBase + Irq);
421 *Vector = (UINT8)(mSlaveBase + (Irq - Efi8259Irq8));
443 IN BOOLEAN LevelTriggered
446 if ((UINT32)Irq > Efi8259Irq15) {
447 return EFI_INVALID_PARAMETER;
450 mProtectedModeMask = (UINT16)(mProtectedModeMask & ~(1 << Irq));
451 if (LevelTriggered) {
452 mProtectedModeEdgeLevel = (UINT16)(mProtectedModeEdgeLevel | (1 << Irq));
454 mProtectedModeEdgeLevel = (UINT16)(mProtectedModeEdgeLevel & ~(1 << Irq));
479 if ((UINT32)Irq > Efi8259Irq15) {
480 return EFI_INVALID_PARAMETER;
483 mProtectedModeMask = (UINT16)(mProtectedModeMask | (1 << Irq));
485 mProtectedModeEdgeLevel = (UINT16)(mProtectedModeEdgeLevel & ~(1 << Irq));
514 Status =
gBS->HandleProtocol (
516 &gEfiPciIoProtocolGuid,
519 if (EFI_ERROR (Status)) {
520 return EFI_INVALID_PARAMETER;
534 *Vector = InterruptLine;
556 if ((UINT32)Irq > Efi8259Irq15) {
557 return EFI_INVALID_PARAMETER;
560 if (Irq >= Efi8259Irq8) {
561 IoWrite8 (LEGACY_8259_CONTROL_REGISTER_SLAVE, LEGACY_8259_EOI);
564 IoWrite8 (LEGACY_8259_CONTROL_REGISTER_MASTER, LEGACY_8259_EOI);
592 mLegacyModeMask =
PcdGet16 (Pcd8259LegacyModeMask);
593 mLegacyModeEdgeLevel =
PcdGet16 (Pcd8259LegacyModeEdgeLevel);
598 for (Irq = Efi8259Irq0; Irq <= Efi8259Irq15; Irq++) {
615 Status =
gBS->InstallProtocolInterface (
617 &gEfiLegacy8259ProtocolGuid,
EFI_STATUS EFIAPI Interrupt8259GetVector(IN EFI_LEGACY_8259_PROTOCOL *This, IN EFI_8259_IRQ Irq, OUT UINT8 *Vector)
EFI_STATUS EFIAPI Interrupt8259EndOfInterrupt(IN EFI_LEGACY_8259_PROTOCOL *This, IN EFI_8259_IRQ Irq)
VOID Interrupt8259ReadMask(OUT UINT16 *Mask, OUT UINT16 *EdgeLevel)
EFI_STATUS EFIAPI Install8259(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID Interrupt8259WriteMask(IN UINT16 Mask, IN UINT16 EdgeLevel)
EFI_STATUS EFIAPI Interrupt8259SetMask(IN EFI_LEGACY_8259_PROTOCOL *This, IN UINT16 *LegacyMask OPTIONAL, IN UINT16 *LegacyEdgeLevel OPTIONAL, IN UINT16 *ProtectedMask OPTIONAL, IN UINT16 *ProtectedEdgeLevel OPTIONAL)
EFI_STATUS EFIAPI Interrupt8259GetMask(IN EFI_LEGACY_8259_PROTOCOL *This, OUT UINT16 *LegacyMask OPTIONAL, OUT UINT16 *LegacyEdgeLevel OPTIONAL, OUT UINT16 *ProtectedMask OPTIONAL, OUT UINT16 *ProtectedEdgeLevel OPTIONAL)
EFI_STATUS EFIAPI Interrupt8259GetInterruptLine(IN EFI_LEGACY_8259_PROTOCOL *This, IN EFI_HANDLE PciHandle, OUT UINT8 *Vector)
EFI_STATUS EFIAPI Interrupt8259EnableIrq(IN EFI_LEGACY_8259_PROTOCOL *This, IN EFI_8259_IRQ Irq, IN BOOLEAN LevelTriggered)
EFI_STATUS EFIAPI Interrupt8259DisableIrq(IN EFI_LEGACY_8259_PROTOCOL *This, IN EFI_8259_IRQ Irq)
EFI_STATUS EFIAPI Interrupt8259SetVectorBase(IN EFI_LEGACY_8259_PROTOCOL *This, IN UINT8 MasterBase, IN UINT8 SlaveBase)
EFI_STATUS EFIAPI Interrupt8259SetMode(IN EFI_LEGACY_8259_PROTOCOL *This, IN EFI_8259_MODE Mode, IN UINT16 *Mask OPTIONAL, IN UINT16 *EdgeLevel OPTIONAL)
UINT8 EFIAPI IoWrite8(IN UINTN Port, IN UINT8 Value)
UINT8 EFIAPI IoRead8(IN UINTN Port)
#define PcdGet16(TokenName)
#define PCI_INT_LINE_OFFSET
Interrupt Line Register.
EFI_PCI_IO_PROTOCOL_CONFIG Read