2 Legacy Interrupt Support
4 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are
7 licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "LegacyInterrupt.h"
19 // Handle for the Legacy Interrupt Protocol instance produced by this driver
21 STATIC EFI_HANDLE mLegacyInterruptHandle
= NULL
;
24 // The Legacy Interrupt Protocol instance produced by this driver
26 STATIC EFI_LEGACY_INTERRUPT_PROTOCOL mLegacyInterrupt
= {
33 STATIC UINT8 PirqReg
[MAX_PIRQ_NUMBER
] = { PIRQA
, PIRQB
, PIRQC
, PIRQD
, PIRQE
, PIRQF
, PIRQG
, PIRQH
};
37 Return the number of PIRQs supported by this chipset.
39 @param[in] This Pointer to LegacyInterrupt Protocol
40 @param[out] NumberPirqs The pointer to return the max IRQ number supported
42 @retval EFI_SUCCESS Max PIRQs successfully returned
48 IN EFI_LEGACY_INTERRUPT_PROTOCOL
*This
,
49 OUT UINT8
*NumberPirqs
52 *NumberPirqs
= MAX_PIRQ_NUMBER
;
59 Return PCI location of this device.
60 $PIR table requires this info.
62 @param[in] This - Protocol instance pointer.
63 @param[out] Bus - PCI Bus
64 @param[out] Device - PCI Device
65 @param[out] Function - PCI Function
67 @retval EFI_SUCCESS Bus/Device/Function returned
73 IN EFI_LEGACY_INTERRUPT_PROTOCOL
*This
,
79 *Bus
= LEGACY_INT_BUS
;
80 *Device
= LEGACY_INT_DEV
;
81 *Function
= LEGACY_INT_FUNC
;
88 Builds the PCI configuration address for the register specified by PirqNumber
90 @param[in] PirqNumber - The PIRQ number to build the PCI configuration address for
92 @return The PCI Configuration address for the PIRQ
99 return PCI_LIB_ADDRESS(
108 Read the given PIRQ register
110 @param[in] This Protocol instance pointer
111 @param[in] PirqNumber The Pirq register 0 = A, 1 = B etc
112 @param[out] PirqData Value read
114 @retval EFI_SUCCESS Decoding change affected.
115 @retval EFI_INVALID_PARAMETER Invalid PIRQ number
121 IN EFI_LEGACY_INTERRUPT_PROTOCOL
*This
,
126 if (PirqNumber
>= MAX_PIRQ_NUMBER
) {
127 return EFI_INVALID_PARAMETER
;
130 *PirqData
= PciRead8 (GetAddress (PirqNumber
));
131 *PirqData
= (UINT8
) (*PirqData
& 0x7f);
138 Write the given PIRQ register
140 @param[in] This Protocol instance pointer
141 @param[in] PirqNumber The Pirq register 0 = A, 1 = B etc
142 @param[out] PirqData Value to write
144 @retval EFI_SUCCESS Decoding change affected.
145 @retval EFI_INVALID_PARAMETER Invalid PIRQ number
151 IN EFI_LEGACY_INTERRUPT_PROTOCOL
*This
,
156 if (PirqNumber
>= MAX_PIRQ_NUMBER
) {
157 return EFI_INVALID_PARAMETER
;
160 PciWrite8 (GetAddress (PirqNumber
), PirqData
);
166 Initialize Legacy Interrupt support
168 @retval EFI_SUCCESS Successfully initialized
172 LegacyInterruptInstall (
179 // Make sure the Legacy Interrupt Protocol is not already installed in the system
181 ASSERT_PROTOCOL_ALREADY_INSTALLED(NULL
, &gEfiLegacyInterruptProtocolGuid
);
184 // Make a new handle and install the protocol
186 Status
= gBS
->InstallMultipleProtocolInterfaces (
187 &mLegacyInterruptHandle
,
188 &gEfiLegacyInterruptProtocolGuid
,
192 ASSERT_EFI_ERROR(Status
);