3 Copyright (c) 2006, 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.
19 IN PCI_IO_DEVICE
*PciIoDevice
,
23 OUT UINT16
*PtrCommand
36 // TODO: PciIoDevice - add argument and description to function comment
37 // TODO: Command - add argument and description to function comment
38 // TODO: Offset - add argument and description to function comment
39 // TODO: Operation - add argument and description to function comment
40 // TODO: PtrCommand - add argument and description to function comment
44 EFI_PCI_IO_PROTOCOL
*PciIo
;
47 PciIo
= &PciIoDevice
->PciIo
;
49 if (Operation
!= EFI_SET_REGISTER
) {
58 if (Operation
== EFI_GET_REGISTER
) {
59 *PtrCommand
= OldCommand
;
64 if (Operation
== EFI_ENABLE_REGISTER
) {
65 OldCommand
= (UINT16
) (OldCommand
| Command
);
66 } else if (Operation
== EFI_DISABLE_REGISTER
) {
67 OldCommand
= (UINT16
) (OldCommand
& ~(Command
));
82 PciCapabilitySupport (
83 IN PCI_IO_DEVICE
*PciIoDevice
96 // TODO: PciIoDevice - add argument and description to function comment
99 if (PciIoDevice
->Pci
.Hdr
.Status
& EFI_PCI_STATUS_CAPABILITY
) {
107 LocateCapabilityRegBlock (
108 IN PCI_IO_DEVICE
*PciIoDevice
,
110 IN OUT UINT8
*Offset
,
111 OUT UINT8
*NextRegBlock OPTIONAL
119 PciIoDevice - A pointer to the PCI_IO_DEVICE.
121 Offset - A pointer to the offset.
122 NextRegBlock - A pointer to the next block.
129 // TODO: EFI_UNSUPPORTED - add return value to function comment
130 // TODO: EFI_SUCCESS - add return value to function comment
131 // TODO: EFI_NOT_FOUND - add return value to function comment
134 UINT16 CapabilityEntry
;
138 // To check the cpability of this device supports
140 if (!PciCapabilitySupport (PciIoDevice
)) {
141 return EFI_UNSUPPORTED
;
145 CapabilityPtr
= *Offset
;
149 if (IS_CARDBUS_BRIDGE (&PciIoDevice
->Pci
)) {
154 EFI_PCI_CARDBUS_BRIDGE_CAPABILITY_PTR
,
163 EFI_PCI_CAPABILITY_PTR
,
170 while (CapabilityPtr
> 0x3F) {
172 // Mask it to DWORD alignment per PCI spec
174 CapabilityPtr
&= 0xFC;
183 CapabilityID
= (UINT8
) CapabilityEntry
;
185 if (CapabilityID
== CapId
) {
186 *Offset
= CapabilityPtr
;
187 if (NextRegBlock
!= NULL
) {
188 *NextRegBlock
= (UINT8
) (CapabilityEntry
>> 8);
194 CapabilityPtr
= (UINT8
) (CapabilityEntry
>> 8);
197 return EFI_NOT_FOUND
;