Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/acpica/acpi.c
Show First 20 Lines • Show All 951 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
acpi_get_device_path(device_t bus, device_t child, const char *locator, struct sbuf *sb) | acpi_get_device_path(device_t bus, device_t child, const char *locator, struct sbuf *sb) | ||||
{ | { | ||||
struct acpi_device *dinfo = device_get_ivars(child); | struct acpi_device *dinfo = device_get_ivars(child); | ||||
if (strcmp(locator, BUS_LOCATOR_ACPI) == 0) | if (strcmp(locator, BUS_LOCATOR_ACPI) == 0) | ||||
return (acpi_get_acpi_device_path(bus, child, locator, sb)); | return (acpi_get_acpi_device_path(bus, child, locator, sb)); | ||||
if (strcmp(locator, BUS_LOCATOR_UEFI) == 0) { | |||||
ACPI_DEVICE_INFO *adinfo; | |||||
if (!ACPI_FAILURE(AcpiGetObjectInfo(dinfo->ad_handle, &adinfo)) && | |||||
dinfo->ad_handle != 0 && (adinfo->Valid & ACPI_VALID_HID)) { | |||||
const char *hid = adinfo->HardwareId.String; | |||||
u_long uid = (adinfo->Valid & ACPI_VALID_UID) ? | |||||
strtoul(adinfo->UniqueId.String, NULL, 10) : 0UL; | |||||
u_long hidval; | |||||
/* | |||||
* In UEFI Stanard Version 2.6, Section 9.6.1.6 Text | |||||
* Device Node Reference, there's an insanely long table | |||||
* 98. This implements the relevant bits from that | |||||
* table. Newer versions appear to have not required | |||||
* anything new. The EDK2 firmware presents both PciRoot | |||||
* and PcieRoot as PciRoot. Follow the EDK2 standard. | |||||
*/ | |||||
if (strncmp("PNP", hid, 3) != 0) | |||||
goto nomatch; | |||||
hidval = strtoul(hid + 3, NULL, 16); | |||||
switch (hidval) { | |||||
case 0x0301: | |||||
sbuf_printf(sb, "Keyboard(0x%lx)", uid); | |||||
break; | |||||
case 0x0401: | |||||
sbuf_printf(sb, "ParallelPort(0x%lx)", uid); | |||||
break; | |||||
case 0x0501: | |||||
sbuf_printf(sb, "Serial(0x%lx)", uid); | |||||
break; | |||||
case 0x0604: | |||||
sbuf_printf(sb, "Floppy(0x%lx)", uid); | |||||
break; | |||||
case 0x0a03: | |||||
case 0x0a08: | |||||
sbuf_printf(sb, "PciRoot(0x%lx)", uid); | |||||
break; | |||||
default: /* Everything else gets a generic encode */ | |||||
nomatch: | |||||
sbuf_printf(sb, "Acpi(%s,0x%lx)", hid, uid); | |||||
break; | |||||
} | |||||
} | |||||
/* Not handled: AcpiAdr... unsure how to know it's one */ | |||||
} | |||||
jhb: Hmm, so perhaps refine my earlier suggestion to still keep a helper routine for ACPI, but the… | |||||
/* For the rest, punt to the default handler */ | /* For the rest, punt to the default handler */ | ||||
return (bus_generic_get_device_path(bus, child, locator, sb)); | return (bus_generic_get_device_path(bus, child, locator, sb)); | ||||
} | } | ||||
/* | /* | ||||
* Handle device deletion. | * Handle device deletion. | ||||
*/ | */ | ||||
static void | static void | ||||
▲ Show 20 Lines • Show All 3,571 Lines • Show Last 20 Lines |
Hmm, so perhaps refine my earlier suggestion to still keep a helper routine for ACPI, but the ACPI bus itself would also need to still use a wrapper that handled UEFI as is done here). That may affect how you want to name the shared helper routine.