Update code to work with 0619 dist
* Use ACPI_BUFFER as the type for AcpiGetObjectInfo * Remove AcpiEnableEvent/AcpiClearEvent for ACPI_EVENT_FIXED (power/sleep buttons) as they are no longer needed * Change calls to use the new GPE functions * Add AcpiOs*Lock functions
This commit is contained in:
parent
17dd0864eb
commit
bce9717b46
@ -69,7 +69,7 @@
|
||||
ACPI_STATUS
|
||||
AcpiOsReadPort (
|
||||
ACPI_IO_ADDRESS InPort,
|
||||
void *Value,
|
||||
UINT32 *Value,
|
||||
UINT32 Width)
|
||||
{
|
||||
switch (Width) {
|
||||
@ -93,7 +93,7 @@ AcpiOsReadPort (
|
||||
ACPI_STATUS
|
||||
AcpiOsWritePort (
|
||||
ACPI_IO_ADDRESS OutPort,
|
||||
ACPI_INTEGER Value,
|
||||
UINT32 Value,
|
||||
UINT32 Width)
|
||||
{
|
||||
switch (Width) {
|
||||
|
@ -94,7 +94,7 @@ AcpiOsWritable (void *Pointer, UINT32 Length)
|
||||
ACPI_STATUS
|
||||
AcpiOsReadMemory (
|
||||
ACPI_PHYSICAL_ADDRESS Address,
|
||||
void *Value,
|
||||
UINT32 *Value,
|
||||
UINT32 Width)
|
||||
{
|
||||
void *LogicalAddress;
|
||||
@ -129,7 +129,7 @@ AcpiOsReadMemory (
|
||||
ACPI_STATUS
|
||||
AcpiOsWriteMemory (
|
||||
ACPI_PHYSICAL_ADDRESS Address,
|
||||
ACPI_INTEGER Value,
|
||||
UINT32 Value,
|
||||
UINT32 Width)
|
||||
{
|
||||
void *LogicalAddress;
|
||||
|
@ -338,3 +338,54 @@ AcpiOsSignalSemaphore(ACPI_HANDLE Handle, UINT32 Units)
|
||||
return(AE_OK);
|
||||
#endif
|
||||
}
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiOsCreateLock (ACPI_HANDLE *OutHandle)
|
||||
{
|
||||
struct mtx *m;
|
||||
|
||||
if (OutHandle == NULL)
|
||||
return (AE_BAD_PARAMETER);
|
||||
MALLOC(m, struct mtx *, sizeof(*m), M_ACPISEM, M_NOWAIT | M_ZERO);
|
||||
if (m == NULL)
|
||||
return (AE_NO_MEMORY);
|
||||
|
||||
mtx_init(m, "acpica subsystem lock", NULL, MTX_DEF);
|
||||
*OutHandle = (ACPI_HANDLE)m;
|
||||
return (AE_OK);
|
||||
}
|
||||
|
||||
void
|
||||
AcpiOsDeleteLock (ACPI_HANDLE Handle)
|
||||
{
|
||||
struct mtx *m = (struct mtx *)Handle;
|
||||
|
||||
if (Handle == NULL)
|
||||
return;
|
||||
mtx_destroy(m);
|
||||
}
|
||||
|
||||
/*
|
||||
* The Flags parameter seems to state whether or not caller is an ISR
|
||||
* (and thus can't block) but since we have ithreads, we don't worry
|
||||
* about potentially blocking.
|
||||
*/
|
||||
void
|
||||
AcpiOsAcquireLock (ACPI_HANDLE Handle, UINT32 Flags)
|
||||
{
|
||||
struct mtx *m = (struct mtx *)Handle;
|
||||
|
||||
if (Handle == NULL)
|
||||
return;
|
||||
mtx_lock(m);
|
||||
}
|
||||
|
||||
void
|
||||
AcpiOsReleaseLock (ACPI_HANDLE Handle, UINT32 Flags)
|
||||
{
|
||||
struct mtx *m = (struct mtx *)Handle;
|
||||
|
||||
if (Handle == NULL)
|
||||
return;
|
||||
mtx_unlock(m);
|
||||
}
|
||||
|
@ -700,6 +700,7 @@ acpi_isa_get_logicalid(device_t dev)
|
||||
{
|
||||
ACPI_HANDLE h;
|
||||
ACPI_DEVICE_INFO devinfo;
|
||||
ACPI_BUFFER buf = {sizeof(devinfo), &devinfo};
|
||||
ACPI_STATUS error;
|
||||
u_int32_t pnpid;
|
||||
ACPI_LOCK_DECL;
|
||||
@ -709,15 +710,16 @@ acpi_isa_get_logicalid(device_t dev)
|
||||
pnpid = 0;
|
||||
ACPI_LOCK;
|
||||
|
||||
/* fetch and validate the HID */
|
||||
/* Fetch and validate the HID. */
|
||||
if ((h = acpi_get_handle(dev)) == NULL)
|
||||
goto out;
|
||||
if (ACPI_FAILURE(error = AcpiGetObjectInfo(h, &devinfo)))
|
||||
error = AcpiGetObjectInfo(h, &buf);
|
||||
if (ACPI_FAILURE(error))
|
||||
goto out;
|
||||
if (!(devinfo.Valid & ACPI_VALID_HID))
|
||||
if ((devinfo.Valid & ACPI_VALID_HID) == 0)
|
||||
goto out;
|
||||
|
||||
pnpid = PNP_EISAID(devinfo.HardwareId);
|
||||
pnpid = PNP_EISAID(devinfo.HardwareId.Value);
|
||||
out:
|
||||
ACPI_UNLOCK;
|
||||
return_VALUE(pnpid);
|
||||
@ -727,7 +729,6 @@ static u_int32_t
|
||||
acpi_isa_get_compatid(device_t dev)
|
||||
{
|
||||
ACPI_HANDLE h;
|
||||
ACPI_DEVICE_INFO devinfo;
|
||||
ACPI_STATUS error;
|
||||
u_int32_t pnpid;
|
||||
ACPI_LOCK_DECL;
|
||||
@ -740,8 +741,6 @@ acpi_isa_get_compatid(device_t dev)
|
||||
/* fetch and validate the HID */
|
||||
if ((h = acpi_get_handle(dev)) == NULL)
|
||||
goto out;
|
||||
if (ACPI_FAILURE(error = AcpiGetObjectInfo(h, &devinfo)))
|
||||
goto out;
|
||||
if (ACPI_FAILURE(error = acpi_EvaluateInteger(h, "_CID", &pnpid)))
|
||||
goto out;
|
||||
|
||||
@ -952,8 +951,6 @@ acpi_enable_fixed_events(struct acpi_softc *sc)
|
||||
|
||||
/* Enable and clear fixed events and install handlers. */
|
||||
if ((AcpiGbl_FADT != NULL) && (AcpiGbl_FADT->PwrButton == 0)) {
|
||||
AcpiEnableEvent(ACPI_EVENT_POWER_BUTTON, ACPI_EVENT_FIXED, 0);
|
||||
AcpiClearEvent(ACPI_EVENT_POWER_BUTTON, ACPI_EVENT_FIXED);
|
||||
AcpiInstallFixedEventHandler(ACPI_EVENT_POWER_BUTTON,
|
||||
acpi_eventhandler_power_button_for_sleep, sc);
|
||||
if (first_time) {
|
||||
@ -961,8 +958,6 @@ acpi_enable_fixed_events(struct acpi_softc *sc)
|
||||
}
|
||||
}
|
||||
if ((AcpiGbl_FADT != NULL) && (AcpiGbl_FADT->SleepButton == 0)) {
|
||||
AcpiEnableEvent(ACPI_EVENT_SLEEP_BUTTON, ACPI_EVENT_FIXED, 0);
|
||||
AcpiClearEvent(ACPI_EVENT_SLEEP_BUTTON, ACPI_EVENT_FIXED);
|
||||
AcpiInstallFixedEventHandler(ACPI_EVENT_SLEEP_BUTTON,
|
||||
acpi_eventhandler_sleep_button_for_sleep, sc);
|
||||
if (first_time) {
|
||||
@ -983,16 +978,18 @@ acpi_DeviceIsPresent(device_t dev)
|
||||
{
|
||||
ACPI_HANDLE h;
|
||||
ACPI_DEVICE_INFO devinfo;
|
||||
ACPI_BUFFER buf = {sizeof(devinfo), &devinfo};
|
||||
ACPI_STATUS error;
|
||||
|
||||
ACPI_ASSERTLOCK;
|
||||
|
||||
if ((h = acpi_get_handle(dev)) == NULL)
|
||||
return(FALSE);
|
||||
if (ACPI_FAILURE(error = AcpiGetObjectInfo(h, &devinfo)))
|
||||
error = AcpiGetObjectInfo(h, &buf);
|
||||
if (ACPI_FAILURE(error))
|
||||
return(FALSE);
|
||||
/* if no _STA method, must be present */
|
||||
if (!(devinfo.Valid & ACPI_VALID_STA))
|
||||
if ((devinfo.Valid & ACPI_VALID_STA) == 0)
|
||||
return(TRUE);
|
||||
/* return true for 'present' and 'functioning' */
|
||||
if ((devinfo.CurrentStatus & 0x9) == 0x9)
|
||||
@ -1008,16 +1005,18 @@ acpi_BatteryIsPresent(device_t dev)
|
||||
{
|
||||
ACPI_HANDLE h;
|
||||
ACPI_DEVICE_INFO devinfo;
|
||||
ACPI_BUFFER buf = {sizeof(devinfo), &devinfo};
|
||||
ACPI_STATUS error;
|
||||
|
||||
ACPI_ASSERTLOCK;
|
||||
|
||||
if ((h = acpi_get_handle(dev)) == NULL)
|
||||
return(FALSE);
|
||||
if (ACPI_FAILURE(error = AcpiGetObjectInfo(h, &devinfo)))
|
||||
error = AcpiGetObjectInfo(h, &buf);
|
||||
if (ACPI_FAILURE(error))
|
||||
return(FALSE);
|
||||
/* if no _STA method, must be present */
|
||||
if (!(devinfo.Valid & ACPI_VALID_STA))
|
||||
if ((devinfo.Valid & ACPI_VALID_STA) == 0)
|
||||
return(TRUE);
|
||||
/* return true for 'present' and 'functioning' */
|
||||
if ((devinfo.CurrentStatus & 0x19) == 0x19)
|
||||
@ -1033,6 +1032,7 @@ acpi_MatchHid(device_t dev, char *hid)
|
||||
{
|
||||
ACPI_HANDLE h;
|
||||
ACPI_DEVICE_INFO devinfo;
|
||||
ACPI_BUFFER buf = {sizeof(devinfo), &devinfo};
|
||||
ACPI_STATUS error;
|
||||
int cid;
|
||||
|
||||
@ -1042,9 +1042,11 @@ acpi_MatchHid(device_t dev, char *hid)
|
||||
return(FALSE);
|
||||
if ((h = acpi_get_handle(dev)) == NULL)
|
||||
return(FALSE);
|
||||
if (ACPI_FAILURE(error = AcpiGetObjectInfo(h, &devinfo)))
|
||||
error = AcpiGetObjectInfo(h, &buf);
|
||||
if (ACPI_FAILURE(error))
|
||||
return(FALSE);
|
||||
if ((devinfo.Valid & ACPI_VALID_HID) && !strcmp(hid, devinfo.HardwareId))
|
||||
if ((devinfo.Valid & ACPI_VALID_HID) != 0 &&
|
||||
strcmp(hid, devinfo.HardwareId.Value) == 0)
|
||||
return(TRUE);
|
||||
if (ACPI_FAILURE(error = acpi_EvaluateInteger(h, "_CID", &cid)))
|
||||
return(FALSE);
|
||||
@ -1392,7 +1394,7 @@ acpi_SetSleepState(struct acpi_softc *sc, int state)
|
||||
acpi_sleep_machdep(sc, state);
|
||||
|
||||
/* AcpiEnterSleepState() maybe incompleted, unlock here if locked. */
|
||||
if (AcpiGbl_AcpiMutexInfo[ACPI_MTX_HARDWARE].OwnerId != ACPI_MUTEX_NOT_ACQUIRED) {
|
||||
if (1/*AcpiGbl_AcpiMutexInfo[ACPI_MTX_HARDWARE].OwnerId != ACPI_MUTEX_NOT_ACQUIRED*/) {
|
||||
AcpiUtReleaseMutex(ACPI_MTX_HARDWARE);
|
||||
}
|
||||
|
||||
@ -1739,8 +1741,8 @@ acpi_device_enable_wake_event(ACPI_HANDLE h)
|
||||
* enabled for the wake event.
|
||||
*/
|
||||
|
||||
status = AcpiEnableEvent(res->Package.Elements[0].Integer.Value,
|
||||
ACPI_EVENT_GPE, ACPI_EVENT_WAKE_ENABLE);
|
||||
status = AcpiEnableGpe(NULL, res->Package.Elements[0].Integer.Value,
|
||||
ACPI_EVENT_WAKE_ENABLE);
|
||||
if (ACPI_FAILURE(status))
|
||||
printf("%s: EnableEvent Failed\n", __func__);
|
||||
break;
|
||||
|
@ -421,8 +421,8 @@ acpi_ec_attach(device_t dev)
|
||||
* behavior.
|
||||
*/
|
||||
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "attaching GPE handler\n"));
|
||||
Status = AcpiInstallGpeHandler(sc->ec_gpebit, ACPI_EVENT_EDGE_TRIGGERED,
|
||||
&EcGpeHandler, sc);
|
||||
Status = AcpiInstallGpeHandler(NULL, sc->ec_gpebit,
|
||||
ACPI_EVENT_EDGE_TRIGGERED, &EcGpeHandler, sc);
|
||||
if (ACPI_FAILURE(Status)) {
|
||||
device_printf(dev, "can't install GPE handler for %s - %s\n",
|
||||
acpi_name(sc->ec_handle), AcpiFormatException(Status));
|
||||
@ -439,7 +439,8 @@ acpi_ec_attach(device_t dev)
|
||||
if (ACPI_FAILURE(Status)) {
|
||||
device_printf(dev, "can't install address space handler for %s - %s\n",
|
||||
acpi_name(sc->ec_handle), AcpiFormatException(Status));
|
||||
Status = AcpiRemoveGpeHandler(sc->ec_gpebit, &EcGpeHandler);
|
||||
Status = AcpiRemoveGpeHandler(sc->ec_handle, sc->ec_gpebit,
|
||||
&EcGpeHandler);
|
||||
if (ACPI_FAILURE(Status))
|
||||
panic("Added GPE handler but can't remove it");
|
||||
errval = ENXIO;
|
||||
@ -538,7 +539,7 @@ EcGpeQueryHandler(void *Context)
|
||||
|
||||
re_enable:
|
||||
/* Re-enable the GPE event so we'll get future requests. */
|
||||
Status = AcpiEnableEvent(sc->ec_gpebit, ACPI_EVENT_GPE, 0);
|
||||
Status = AcpiEnableGpe(NULL, sc->ec_gpebit, ACPI_NOT_ISR);
|
||||
if (ACPI_FAILURE(Status))
|
||||
printf("EcGpeQueryHandler: AcpiEnableEvent failed\n");
|
||||
}
|
||||
@ -557,14 +558,14 @@ EcGpeHandler(void *Context)
|
||||
KASSERT(Context != NULL, ("EcGpeHandler called with NULL"));
|
||||
|
||||
/* Disable further GPEs while we handle this one. */
|
||||
AcpiDisableEvent(sc->ec_gpebit, ACPI_EVENT_GPE, 0);
|
||||
AcpiDisableGpe(NULL, sc->ec_gpebit, ACPI_ISR);
|
||||
|
||||
/* Schedule the GPE query handler. */
|
||||
Status = AcpiOsQueueForExecution(OSD_PRIORITY_GPE, EcGpeQueryHandler,
|
||||
Context);
|
||||
if (ACPI_FAILURE(Status)) {
|
||||
printf("Queuing GPE query handler failed.\n");
|
||||
Status = AcpiEnableEvent(sc->ec_gpebit, ACPI_EVENT_GPE, 0);
|
||||
Status = AcpiEnableGpe(NULL, sc->ec_gpebit, ACPI_ISR);
|
||||
if (ACPI_FAILURE(Status))
|
||||
printf("EcGpeHandler: AcpiEnableEvent failed\n");
|
||||
}
|
||||
|
@ -169,6 +169,7 @@ static ACPI_STATUS
|
||||
acpi_pci_link_get_object_status(ACPI_HANDLE handle, UINT32 *sta)
|
||||
{
|
||||
ACPI_DEVICE_INFO devinfo;
|
||||
ACPI_BUFFER buf = {sizeof(devinfo), &devinfo};
|
||||
ACPI_STATUS error;
|
||||
|
||||
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
||||
@ -179,7 +180,7 @@ acpi_pci_link_get_object_status(ACPI_HANDLE handle, UINT32 *sta)
|
||||
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
error = AcpiGetObjectInfo(handle, &devinfo);
|
||||
error = AcpiGetObjectInfo(handle, &buf);
|
||||
if (ACPI_FAILURE(error)) {
|
||||
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
|
||||
"couldn't get object info %s - %s\n",
|
||||
@ -188,13 +189,13 @@ acpi_pci_link_get_object_status(ACPI_HANDLE handle, UINT32 *sta)
|
||||
}
|
||||
|
||||
if ((devinfo.Valid & ACPI_VALID_HID) == 0 ||
|
||||
strcmp(devinfo.HardwareId, "PNP0C0F") != 0) {
|
||||
strcmp(devinfo.HardwareId.Value, "PNP0C0F") != 0) {
|
||||
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "invalid hardware ID - %s\n",
|
||||
acpi_name(handle)));
|
||||
return_ACPI_STATUS (AE_TYPE);
|
||||
}
|
||||
|
||||
if (devinfo.Valid & ACPI_VALID_STA) {
|
||||
if ((devinfo.Valid & ACPI_VALID_STA) != 0) {
|
||||
*sta = devinfo.CurrentStatus;
|
||||
} else {
|
||||
ACPI_DEBUG_PRINT((ACPI_DB_WARN, "invalid status - %s\n",
|
||||
|
@ -114,6 +114,7 @@ acpi_pcib_route_interrupt(device_t pcib, device_t dev, int pin,
|
||||
ACPI_BUFFER crsbuf, prsbuf;
|
||||
ACPI_RESOURCE *crsres, *prsres, resbuf;
|
||||
ACPI_DEVICE_INFO devinfo;
|
||||
ACPI_BUFFER buf = {sizeof(devinfo), &devinfo};
|
||||
ACPI_STATUS status;
|
||||
u_int8_t *prtp;
|
||||
int interrupt;
|
||||
@ -182,14 +183,14 @@ acpi_pcib_route_interrupt(device_t pcib, device_t dev, int pin,
|
||||
/*
|
||||
* Verify that this is a PCI link device, and that it's present.
|
||||
*/
|
||||
if (ACPI_FAILURE(AcpiGetObjectInfo(lnkdev, &devinfo))) {
|
||||
if (ACPI_FAILURE(AcpiGetObjectInfo(lnkdev, &buf))) {
|
||||
device_printf(pcib, "couldn't validate PCI interrupt link device %s\n",
|
||||
prt->Source);
|
||||
goto out;
|
||||
}
|
||||
if (!(devinfo.Valid & ACPI_VALID_HID) || strcmp("PNP0C0F", devinfo.HardwareId)) {
|
||||
if (!(devinfo.Valid & ACPI_VALID_HID) || strcmp("PNP0C0F", devinfo.HardwareId.Value)) {
|
||||
device_printf(pcib, "PCI interrupt link device %s has wrong _HID (%s)\n",
|
||||
prt->Source, devinfo.HardwareId);
|
||||
prt->Source, devinfo.HardwareId.Value);
|
||||
goto out;
|
||||
}
|
||||
if (devinfo.Valid & ACPI_VALID_STA && (devinfo.CurrentStatus & 0x9) != 0x9) {
|
||||
|
Loading…
Reference in New Issue
Block a user