Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/acpica/acpi.c
Show First 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | |||||
static int acpi_adjust_resource(device_t bus, device_t child, int type, | static int acpi_adjust_resource(device_t bus, device_t child, int type, | ||||
struct resource *r, rman_res_t start, rman_res_t end); | struct resource *r, rman_res_t start, rman_res_t end); | ||||
static int acpi_release_resource(device_t bus, device_t child, int type, | static int acpi_release_resource(device_t bus, device_t child, int type, | ||||
int rid, struct resource *r); | int rid, struct resource *r); | ||||
static void acpi_delete_resource(device_t bus, device_t child, int type, | static void acpi_delete_resource(device_t bus, device_t child, int type, | ||||
int rid); | int rid); | ||||
static uint32_t acpi_isa_get_logicalid(device_t dev); | static uint32_t acpi_isa_get_logicalid(device_t dev); | ||||
static int acpi_isa_get_compatid(device_t dev, uint32_t *cids, int count); | static int acpi_isa_get_compatid(device_t dev, uint32_t *cids, int count); | ||||
static char *acpi_device_id_probe(device_t bus, device_t dev, char **ids); | static int acpi_device_id_probe(device_t bus, device_t dev, char **ids, char **match); | ||||
static ACPI_STATUS acpi_device_eval_obj(device_t bus, device_t dev, | static ACPI_STATUS acpi_device_eval_obj(device_t bus, device_t dev, | ||||
ACPI_STRING pathname, ACPI_OBJECT_LIST *parameters, | ACPI_STRING pathname, ACPI_OBJECT_LIST *parameters, | ||||
ACPI_BUFFER *ret); | ACPI_BUFFER *ret); | ||||
static ACPI_STATUS acpi_device_scan_cb(ACPI_HANDLE h, UINT32 level, | static ACPI_STATUS acpi_device_scan_cb(ACPI_HANDLE h, UINT32 level, | ||||
void *context, void **retval); | void *context, void **retval); | ||||
static ACPI_STATUS acpi_device_scan_children(device_t bus, device_t dev, | static ACPI_STATUS acpi_device_scan_children(device_t bus, device_t dev, | ||||
int max_depth, acpi_scan_cb_t user_fn, void *arg); | int max_depth, acpi_scan_cb_t user_fn, void *arg); | ||||
static int acpi_set_powerstate(device_t child, int state); | static int acpi_set_powerstate(device_t child, int state); | ||||
▲ Show 20 Lines • Show All 1,026 Lines • ▼ Show 20 Lines | acpi_sysres_alloc(device_t dev) | ||||
/* | /* | ||||
* Probe/attach any sysresource devices. This would be unnecessary if we | * Probe/attach any sysresource devices. This would be unnecessary if we | ||||
* had multi-pass probe/attach. | * had multi-pass probe/attach. | ||||
*/ | */ | ||||
if (device_get_children(dev, &children, &child_count) != 0) | if (device_get_children(dev, &children, &child_count) != 0) | ||||
return (ENXIO); | return (ENXIO); | ||||
for (i = 0; i < child_count; i++) { | for (i = 0; i < child_count; i++) { | ||||
if (ACPI_ID_PROBE(dev, children[i], sysres_ids) != NULL) | if (ACPI_ID_PROBE(dev, children[i], sysres_ids, NULL) <= 0) | ||||
imp: There's a mix of styles used here. Some places you test against 0 (eg > 0 is an error) other… | |||||
device_probe_and_attach(children[i]); | device_probe_and_attach(children[i]); | ||||
} | } | ||||
free(children, M_TEMP); | free(children, M_TEMP); | ||||
rl = BUS_GET_RESOURCE_LIST(device_get_parent(dev), dev); | rl = BUS_GET_RESOURCE_LIST(device_get_parent(dev), dev); | ||||
STAILQ_FOREACH(rle, rl, link) { | STAILQ_FOREACH(rle, rl, link) { | ||||
if (rle->res != NULL) { | if (rle->res != NULL) { | ||||
device_printf(dev, "duplicate resource for %jx\n", rle->start); | device_printf(dev, "duplicate resource for %jx\n", rle->start); | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | acpi_reserve_resources(device_t dev) | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
if (device_get_children(dev, &children, &child_count) != 0) | if (device_get_children(dev, &children, &child_count) != 0) | ||||
return; | return; | ||||
for (i = 0; i < child_count; i++) { | for (i = 0; i < child_count; i++) { | ||||
ad = device_get_ivars(children[i]); | ad = device_get_ivars(children[i]); | ||||
rl = &ad->ad_rl; | rl = &ad->ad_rl; | ||||
/* Don't reserve system resources. */ | /* Don't reserve system resources. */ | ||||
if (ACPI_ID_PROBE(dev, children[i], sysres_ids) != NULL) | if (ACPI_ID_PROBE(dev, children[i], sysres_ids, NULL) <= 0) | ||||
continue; | continue; | ||||
STAILQ_FOREACH(rle, rl, link) { | STAILQ_FOREACH(rle, rl, link) { | ||||
/* | /* | ||||
* Don't reserve IRQ resources. There are many sticky things | * Don't reserve IRQ resources. There are many sticky things | ||||
* to get right otherwise (e.g. IRQs for psm, atkbd, and HPET | * to get right otherwise (e.g. IRQs for psm, atkbd, and HPET | ||||
* when using legacy routing). | * when using legacy routing). | ||||
*/ | */ | ||||
Show All 33 Lines | acpi_set_resource(device_t dev, device_t child, int type, int rid, | ||||
struct acpi_device *ad = device_get_ivars(child); | struct acpi_device *ad = device_get_ivars(child); | ||||
struct resource_list *rl = &ad->ad_rl; | struct resource_list *rl = &ad->ad_rl; | ||||
#if defined(__i386__) || defined(__amd64__) | #if defined(__i386__) || defined(__amd64__) | ||||
ACPI_DEVICE_INFO *devinfo; | ACPI_DEVICE_INFO *devinfo; | ||||
#endif | #endif | ||||
rman_res_t end; | rman_res_t end; | ||||
/* Ignore IRQ resources for PCI link devices. */ | /* Ignore IRQ resources for PCI link devices. */ | ||||
if (type == SYS_RES_IRQ && ACPI_ID_PROBE(dev, child, pcilink_ids) != NULL) | if (type == SYS_RES_IRQ && | ||||
ACPI_ID_PROBE(dev, child, pcilink_ids, NULL) <= 0) | |||||
return (0); | return (0); | ||||
/* | /* | ||||
* Ignore most resources for PCI root bridges. Some BIOSes | * Ignore most resources for PCI root bridges. Some BIOSes | ||||
* incorrectly enumerate the memory ranges they decode as plain | * incorrectly enumerate the memory ranges they decode as plain | ||||
* memory resources instead of as ResourceProducer ranges. Other | * memory resources instead of as ResourceProducer ranges. Other | ||||
* BIOSes incorrectly list system resource entries for I/O ranges | * BIOSes incorrectly list system resource entries for I/O ranges | ||||
* under the PCI bridge. Do allow the one known-correct case on | * under the PCI bridge. Do allow the one known-correct case on | ||||
Show All 26 Lines | resource_list_unreserve(rl, dev, child, type, rid); | ||||
end = (start + count - 1); | end = (start + count - 1); | ||||
resource_list_add(rl, type, rid, start, end, count); | resource_list_add(rl, type, rid, start, end, count); | ||||
/* Don't reserve resources until the system resources are allocated. */ | /* Don't reserve resources until the system resources are allocated. */ | ||||
if (!sc->acpi_resources_reserved) | if (!sc->acpi_resources_reserved) | ||||
return (0); | return (0); | ||||
/* Don't reserve system resources. */ | /* Don't reserve system resources. */ | ||||
if (ACPI_ID_PROBE(dev, child, sysres_ids) != NULL) | if (ACPI_ID_PROBE(dev, child, sysres_ids, NULL) <= 0) | ||||
return (0); | return (0); | ||||
/* | /* | ||||
* Don't reserve IRQ resources. There are many sticky things to | * Don't reserve IRQ resources. There are many sticky things to | ||||
* get right otherwise (e.g. IRQs for psm, atkbd, and HPET when | * get right otherwise (e.g. IRQs for psm, atkbd, and HPET when | ||||
* using legacy routing). | * using legacy routing). | ||||
*/ | */ | ||||
if (type == SYS_RES_IRQ) | if (type == SYS_RES_IRQ) | ||||
▲ Show 20 Lines • Show All 288 Lines • ▼ Show 20 Lines | if (ids[i].Length >= ACPI_EISAID_STRING_SIZE && | ||||
*pnpid++ = PNP_EISAID(ids[i].String); | *pnpid++ = PNP_EISAID(ids[i].String); | ||||
valid++; | valid++; | ||||
} | } | ||||
AcpiOsFree(devinfo); | AcpiOsFree(devinfo); | ||||
return_VALUE (valid); | return_VALUE (valid); | ||||
} | } | ||||
static char * | static int | ||||
acpi_device_id_probe(device_t bus, device_t dev, char **ids) | acpi_device_id_probe(device_t bus, device_t dev, char **ids, char **match) | ||||
{ | { | ||||
ACPI_HANDLE h; | ACPI_HANDLE h; | ||||
ACPI_OBJECT_TYPE t; | ACPI_OBJECT_TYPE t; | ||||
int rv; | |||||
int i; | int i; | ||||
h = acpi_get_handle(dev); | h = acpi_get_handle(dev); | ||||
if (ids == NULL || h == NULL) | if (ids == NULL || h == NULL) | ||||
return (NULL); | return (ENXIO); | ||||
t = acpi_get_type(dev); | t = acpi_get_type(dev); | ||||
if (t != ACPI_TYPE_DEVICE && t != ACPI_TYPE_PROCESSOR) | if (t != ACPI_TYPE_DEVICE && t != ACPI_TYPE_PROCESSOR) | ||||
return (NULL); | return (ENXIO); | ||||
/* Try to match one of the array of IDs with a HID or CID. */ | /* Try to match one of the array of IDs with a HID or CID. */ | ||||
for (i = 0; ids[i] != NULL; i++) { | for (i = 0; ids[i] != NULL; i++) { | ||||
Done Inline ActionsI don't think you need this assignment. I think callers can only expect 'match' to be set if the function finds a match (we have other APIs that work similarly) jhb: I don't think you need this assignment. I think callers can only expect 'match' to be set if… | |||||
if (acpi_MatchHid(h, ids[i])) | rv = acpi_MatchHid(h, ids[i]); | ||||
return (ids[i]); | if( rv == ACPI_MATCHHID_NOMATCH) | ||||
Done Inline ActionsPerhaps 'if (rv != ACPI_MATCHHID_NOMATCH)', but you could also use 'continue' to reduce the indentation if you wanted: rv = acpi_MatchHid(h, ids[i]); if (rv == ACPI_MATCHHID_NOMATCH) continue; if (match != NULL) *match = ids[i]; return (...); jhb: Perhaps 'if (rv != ACPI_MATCHHID_NOMATCH)', but you could also use 'continue' to reduce the… | |||||
jhbUnsubmitted Done Inline ActionsMove the space before the open paren instead of after. jhb: Move the space before the open paren instead of after. | |||||
continue; | |||||
if(match != NULL){ | |||||
jhbUnsubmitted Done Inline ActionsSpace after 'if' here and also before '{' jhb: Space after 'if' here and also before '{' | |||||
*match = ids[i]; | |||||
} | } | ||||
return (NULL); | return ((rv == ACPI_MATCHHID_HID)? | ||||
BUS_PROBE_DEFAULT : BUS_PROBE_LOW_PRIORITY); | |||||
} | } | ||||
return (ENXIO); | |||||
} | |||||
static ACPI_STATUS | static ACPI_STATUS | ||||
acpi_device_eval_obj(device_t bus, device_t dev, ACPI_STRING pathname, | acpi_device_eval_obj(device_t bus, device_t dev, ACPI_STRING pathname, | ||||
ACPI_OBJECT_LIST *parameters, ACPI_BUFFER *ret) | ACPI_OBJECT_LIST *parameters, ACPI_BUFFER *ret) | ||||
{ | { | ||||
ACPI_HANDLE h; | ACPI_HANDLE h; | ||||
if (dev == NULL) | if (dev == NULL) | ||||
▲ Show 20 Lines • Show All 599 Lines • ▼ Show 20 Lines | if (devinfo->CompatibleIdList.Count > 0) | ||||
ret = TRUE; | ret = TRUE; | ||||
AcpiOsFree(devinfo); | AcpiOsFree(devinfo); | ||||
return (ret); | return (ret); | ||||
} | } | ||||
/* | /* | ||||
* Match a HID string against a handle | * Match a HID string against a handle | ||||
* returns ACPI_MATCHHID_HID if _HID match | |||||
* ACPI_MATCHHID_CID if _CID match and not _HID match. | |||||
* ACPI_MATCHHID_NOMATCH=0 if no match. | |||||
*/ | */ | ||||
BOOLEAN | int | ||||
acpi_MatchHid(ACPI_HANDLE h, const char *hid) | acpi_MatchHid(ACPI_HANDLE h, const char *hid) | ||||
{ | { | ||||
ACPI_DEVICE_INFO *devinfo; | ACPI_DEVICE_INFO *devinfo; | ||||
BOOLEAN ret; | BOOLEAN ret; | ||||
int i; | int i; | ||||
if (hid == NULL || h == NULL || | if (hid == NULL || h == NULL || | ||||
ACPI_FAILURE(AcpiGetObjectInfo(h, &devinfo))) | ACPI_FAILURE(AcpiGetObjectInfo(h, &devinfo))) | ||||
return (FALSE); | return (ACPI_MATCHHID_NOMATCH); | ||||
ret = FALSE; | ret = FALSE; | ||||
if ((devinfo->Valid & ACPI_VALID_HID) != 0 && | if ((devinfo->Valid & ACPI_VALID_HID) != 0 && | ||||
strcmp(hid, devinfo->HardwareId.String) == 0) | strcmp(hid, devinfo->HardwareId.String) == 0) | ||||
ret = TRUE; | ret = ACPI_MATCHHID_HID; | ||||
else if ((devinfo->Valid & ACPI_VALID_CID) != 0) | else if ((devinfo->Valid & ACPI_VALID_CID) != 0) | ||||
for (i = 0; i < devinfo->CompatibleIdList.Count; i++) { | for (i = 0; i < devinfo->CompatibleIdList.Count; i++) { | ||||
if (strcmp(hid, devinfo->CompatibleIdList.Ids[i].String) == 0) { | if (strcmp(hid, devinfo->CompatibleIdList.Ids[i].String) == 0) { | ||||
ret = TRUE; | ret = ACPI_MATCHHID_CID; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
AcpiOsFree(devinfo); | AcpiOsFree(devinfo); | ||||
return (ret); | return (ret); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,886 Lines • Show Last 20 Lines |
There's a mix of styles used here. Some places you test against 0 (eg > 0 is an error) other places the exact error. I think it would be better to test <= 0 here and other places you explicitly tested against ENXIO.