OsdHardware.c (119539) | OsdHardware.c (126560) |
---|---|
1/*- 2 * Copyright (c) 2000, 2001 Michael Smith 3 * Copyright (c) 2000 BSDi 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * | 1/*- 2 * Copyright (c) 2000, 2001 Michael Smith 3 * Copyright (c) 2000 BSDi 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * |
27 * $FreeBSD: head/sys/dev/acpica/Osd/OsdHardware.c 119539 2003-08-28 21:22:25Z jhb $ | 27 * $FreeBSD: head/sys/dev/acpica/Osd/OsdHardware.c 126560 2004-03-03 18:34:42Z njl $ |
28 */ 29 30/* 31 * 6.7 : Hardware Abstraction 32 */ 33 34#include "acpi.h" 35 --- 125 unchanged lines hidden (view full) --- 161 return(AE_NOT_EXIST); 162 163 pci_cfgregwrite(PciId->Bus, PciId->Device, PciId->Function, Register, Value, byte_width); 164 165 return(AE_OK); 166} 167 168/* XXX should use acpivar.h but too many include dependencies */ | 28 */ 29 30/* 31 * 6.7 : Hardware Abstraction 32 */ 33 34#include "acpi.h" 35 --- 125 unchanged lines hidden (view full) --- 161 return(AE_NOT_EXIST); 162 163 pci_cfgregwrite(PciId->Bus, PciId->Device, PciId->Function, Register, Value, byte_width); 164 165 return(AE_OK); 166} 167 168/* XXX should use acpivar.h but too many include dependencies */ |
169extern ACPI_STATUS acpi_EvaluateInteger(ACPI_HANDLE handle, char *path, int | 169extern ACPI_STATUS acpi_GetInteger(ACPI_HANDLE handle, char *path, int |
170 *number); 171 172/* 173 * Depth-first recursive case for finding the bus, given the slot/function. 174 */ 175static int 176acpi_bus_number(ACPI_HANDLE root, ACPI_HANDLE curr, ACPI_PCI_ID *PciId) 177{ 178 ACPI_HANDLE parent; 179 ACPI_OBJECT_TYPE type; 180 UINT32 adr; 181 int bus, slot, func, class, subclass, header; 182 183 /* Try to get the _BBN object of the root, otherwise assume it is 0 */ 184 bus = 0; 185 if (root == curr) { | 170 *number); 171 172/* 173 * Depth-first recursive case for finding the bus, given the slot/function. 174 */ 175static int 176acpi_bus_number(ACPI_HANDLE root, ACPI_HANDLE curr, ACPI_PCI_ID *PciId) 177{ 178 ACPI_HANDLE parent; 179 ACPI_OBJECT_TYPE type; 180 UINT32 adr; 181 int bus, slot, func, class, subclass, header; 182 183 /* Try to get the _BBN object of the root, otherwise assume it is 0 */ 184 bus = 0; 185 if (root == curr) { |
186 if (ACPI_FAILURE(acpi_EvaluateInteger(root, "_BBN", &bus)) && | 186 if (ACPI_FAILURE(acpi_GetInteger(root, "_BBN", &bus)) && |
187 bootverbose) 188 printf("acpi_bus_number: root bus has no _BBN, assuming 0\n"); 189 return (bus); 190 } 191 if (ACPI_FAILURE(AcpiGetParent(curr, &parent))) 192 return (bus); 193 194 /* First, recurse up the tree until we find the host bus */ 195 bus = acpi_bus_number(root, parent, PciId); 196 197 /* Validate parent bus device type */ 198 if (ACPI_FAILURE(AcpiGetType(parent, &type)) || type != ACPI_TYPE_DEVICE) { 199 printf("acpi_bus_number: not a device, type %d\n", type); 200 return (bus); 201 } 202 /* Get the parent's slot and function */ | 187 bootverbose) 188 printf("acpi_bus_number: root bus has no _BBN, assuming 0\n"); 189 return (bus); 190 } 191 if (ACPI_FAILURE(AcpiGetParent(curr, &parent))) 192 return (bus); 193 194 /* First, recurse up the tree until we find the host bus */ 195 bus = acpi_bus_number(root, parent, PciId); 196 197 /* Validate parent bus device type */ 198 if (ACPI_FAILURE(AcpiGetType(parent, &type)) || type != ACPI_TYPE_DEVICE) { 199 printf("acpi_bus_number: not a device, type %d\n", type); 200 return (bus); 201 } 202 /* Get the parent's slot and function */ |
203 if (ACPI_FAILURE(acpi_EvaluateInteger(parent, "_ADR", &adr))) { | 203 if (ACPI_FAILURE(acpi_GetInteger(parent, "_ADR", &adr))) { |
204 printf("acpi_bus_number: can't get _ADR\n"); 205 return (bus); 206 } 207 slot = ACPI_HIWORD(adr); 208 func = ACPI_LOWORD(adr); 209 210 /* Is this a PCI-PCI or Cardbus-PCI bridge? */ 211 class = pci_cfgregread(bus, slot, func, PCIR_CLASS, 1); --- 26 unchanged lines hidden (view full) --- 238 int bus; 239 240 if (pci_cfgregopen() == 0) 241 panic("AcpiOsDerivePciId unable to initialize pci bus"); 242 243 /* Try to read _BBN for bus number if we're at the root */ 244 bus = 0; 245 if (rhandle == chandle) { | 204 printf("acpi_bus_number: can't get _ADR\n"); 205 return (bus); 206 } 207 slot = ACPI_HIWORD(adr); 208 func = ACPI_LOWORD(adr); 209 210 /* Is this a PCI-PCI or Cardbus-PCI bridge? */ 211 class = pci_cfgregread(bus, slot, func, PCIR_CLASS, 1); --- 26 unchanged lines hidden (view full) --- 238 int bus; 239 240 if (pci_cfgregopen() == 0) 241 panic("AcpiOsDerivePciId unable to initialize pci bus"); 242 243 /* Try to read _BBN for bus number if we're at the root */ 244 bus = 0; 245 if (rhandle == chandle) { |
246 if (ACPI_FAILURE(acpi_EvaluateInteger(rhandle, "_BBN", &bus)) && | 246 if (ACPI_FAILURE(acpi_GetInteger(rhandle, "_BBN", &bus)) && |
247 bootverbose) 248 printf("AcpiOsDerivePciId: root bus has no _BBN, assuming 0\n"); 249 } 250 /* 251 * Get the parent handle and call the recursive case. It is not 252 * clear why we seem to be getting a chandle that points to a child 253 * of the desired slot/function but passing in the parent handle 254 * here works. 255 */ 256 if (ACPI_SUCCESS(AcpiGetParent(chandle, &parent))) 257 bus = acpi_bus_number(rhandle, parent, *PciId); 258 (*PciId)->Bus = bus; 259 if (bootverbose) { 260 printf("AcpiOsDerivePciId: bus %d dev %d func %d\n", 261 (*PciId)->Bus, (*PciId)->Device, (*PciId)->Function); 262 } 263} | 247 bootverbose) 248 printf("AcpiOsDerivePciId: root bus has no _BBN, assuming 0\n"); 249 } 250 /* 251 * Get the parent handle and call the recursive case. It is not 252 * clear why we seem to be getting a chandle that points to a child 253 * of the desired slot/function but passing in the parent handle 254 * here works. 255 */ 256 if (ACPI_SUCCESS(AcpiGetParent(chandle, &parent))) 257 bus = acpi_bus_number(rhandle, parent, *PciId); 258 (*PciId)->Bus = bus; 259 if (bootverbose) { 260 printf("AcpiOsDerivePciId: bus %d dev %d func %d\n", 261 (*PciId)->Bus, (*PciId)->Device, (*PciId)->Function); 262 } 263} |