3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
28 IN PCI_IO_DEVICE
*PciIoDevice
,
32 OUT UINT16
*PtrCommand
45 // TODO: PciIoDevice - add argument and description to function comment
46 // TODO: Command - add argument and description to function comment
47 // TODO: Offset - add argument and description to function comment
48 // TODO: Operation - add argument and description to function comment
49 // TODO: PtrCommand - add argument and description to function comment
53 EFI_PCI_IO_PROTOCOL
*PciIo
;
56 PciIo
= &PciIoDevice
->PciIo
;
58 if (Operation
!= EFI_SET_REGISTER
) {
67 if (Operation
== EFI_GET_REGISTER
) {
68 *PtrCommand
= OldCommand
;
73 if (Operation
== EFI_ENABLE_REGISTER
) {
74 OldCommand
= (UINT16
) (OldCommand
| Command
);
75 } else if (Operation
== EFI_DISABLE_REGISTER
) {
76 OldCommand
= (UINT16
) (OldCommand
& ~(Command
));
91 PciCapabilitySupport (
92 IN PCI_IO_DEVICE
*PciIoDevice
105 // TODO: PciIoDevice - add argument and description to function comment
108 if (PciIoDevice
->Pci
.Hdr
.Status
& EFI_PCI_STATUS_CAPABILITY
) {
116 LocateCapabilityRegBlock (
117 IN PCI_IO_DEVICE
*PciIoDevice
,
119 IN OUT UINT8
*Offset
,
120 OUT UINT8
*NextRegBlock OPTIONAL
128 PciIoDevice - A pointer to the PCI_IO_DEVICE.
130 Offset - A pointer to the offset.
131 NextRegBlock - A pointer to the next block.
138 // TODO: EFI_UNSUPPORTED - add return value to function comment
139 // TODO: EFI_SUCCESS - add return value to function comment
140 // TODO: EFI_NOT_FOUND - add return value to function comment
143 UINT16 CapabilityEntry
;
147 // To check the cpability of this device supports
149 if (!PciCapabilitySupport (PciIoDevice
)) {
150 return EFI_UNSUPPORTED
;
154 CapabilityPtr
= *Offset
;
158 if (IS_CARDBUS_BRIDGE (&PciIoDevice
->Pci
)) {
163 EFI_PCI_CARDBUS_BRIDGE_CAPABILITY_PTR
,
172 EFI_PCI_CAPABILITY_PTR
,
179 while (CapabilityPtr
> 0x3F) {
181 // Mask it to DWORD alignment per PCI spec
183 CapabilityPtr
&= 0xFC;
192 CapabilityID
= (UINT8
) CapabilityEntry
;
194 if (CapabilityID
== CapId
) {
195 *Offset
= CapabilityPtr
;
196 if (NextRegBlock
!= NULL
) {
197 *NextRegBlock
= (UINT8
) (CapabilityEntry
>> 8);
203 CapabilityPtr
= (UINT8
) (CapabilityEntry
>> 8);
206 return EFI_NOT_FOUND
;