summaryrefslogtreecommitdiffstats
path: root/sys/dev/acpica/acpi.c
diff options
context:
space:
mode:
authoriwasaki <iwasaki@FreeBSD.org>2001-12-22 16:05:41 +0000
committeriwasaki <iwasaki@FreeBSD.org>2001-12-22 16:05:41 +0000
commit4c7abcd3372368396a11a120c259afdb0fe2b015 (patch)
tree7c96c678372cc5f9e23154023196e80b72311f86 /sys/dev/acpica/acpi.c
parent23a35cbf8dc1e76d3a4e856806e0ee472c65e5af (diff)
downloadFreeBSD-src-4c7abcd3372368396a11a120c259afdb0fe2b015.zip
FreeBSD-src-4c7abcd3372368396a11a120c259afdb0fe2b015.tar.gz
Add OS layer ACPI mutex and threading support.
- Temporary fix a bug of Intel ACPI CA core code. - Add OS layer ACPI mutex support. This can be disabled by specifying option ACPI_NO_SEMAPHORES. - Add ACPI threading support. Now that we have a dedicate taskqueue for ACPI tasks and more ACPI task threads can be created by specifying option ACPI_MAX_THREADS. - Change acpi_EvaluateIntoBuffer() behavior slightly to reuse given caller's buffer unless AE_BUFFER_OVERFLOW occurs. Also CM battery's evaluations were changed to use acpi_EvaluateIntoBuffer(). - Add new utility function acpi_ConvertBufferToInteger(). - Add simple locking for CM battery and temperature updating. - Fix a minor problem on EC locking. - Make the thermal zone polling rate to be changeable. - Change minor things on AcpiOsSignal(); in ACPI_SIGNAL_FATAL case, entering Debugger is easier to investigate the problem rather than panic.
Diffstat (limited to 'sys/dev/acpica/acpi.c')
-rw-r--r--sys/dev/acpica/acpi.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 5bbc688..6ebce70 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -471,6 +471,12 @@ acpi_attach(device_t dev)
acpi_EnterDebugger();
#endif
+#if defined(ACPI_MAX_THREADS) && ACPI_MAX_THREADS > 0
+ if ((error = acpi_task_thread_init())) {
+ goto out;
+ }
+#endif
+
if ((error = acpi_machdep_init(dev))) {
goto out;
}
@@ -1078,7 +1084,7 @@ acpi_GetTableIntoBuffer(ACPI_TABLE_TYPE table, UINT32 instance, ACPI_BUFFER *buf
/*
* Perform the tedious double-evaluate procedure for evaluating something into
- * an ACPI_BUFFER that has not been initialised. Note that this evaluates
+ * an ACPI_BUFFER if it has not been initialised. Note that this evaluates
* twice, so avoid applying this to things that may have side-effects.
*
* This is like AcpiEvaluateObject with automatic buffer allocation.
@@ -1091,11 +1097,10 @@ acpi_EvaluateIntoBuffer(ACPI_HANDLE object, ACPI_STRING pathname, ACPI_OBJECT_LI
ACPI_ASSERTLOCK;
- buf->Length = 0;
- buf->Pointer = NULL;
-
if ((status = AcpiEvaluateObject(object, pathname, params, buf)) != AE_BUFFER_OVERFLOW)
return(status);
+ if (buf->Pointer != NULL)
+ AcpiOsFree(buf->Pointer);
if ((buf->Pointer = AcpiOsCallocate(buf->Length)) == NULL)
return(AE_NO_MEMORY);
return(AcpiEvaluateObject(object, pathname, params, buf));
@@ -1109,8 +1114,7 @@ acpi_EvaluateInteger(ACPI_HANDLE handle, char *path, int *number)
{
ACPI_STATUS error;
ACPI_BUFFER buf;
- ACPI_OBJECT param, *p;
- int i;
+ ACPI_OBJECT param;
ACPI_ASSERTLOCK;
@@ -1144,18 +1148,7 @@ acpi_EvaluateInteger(ACPI_HANDLE handle, char *path, int *number)
error = AE_NO_MEMORY;
} else {
if ((error = AcpiEvaluateObject(handle, path, NULL, &buf)) == AE_OK) {
- p = (ACPI_OBJECT *)buf.Pointer;
- if (p->Type != ACPI_TYPE_BUFFER) {
- error = AE_TYPE;
- } else {
- if (p->Buffer.Length > sizeof(int)) {
- error = AE_BAD_DATA;
- } else {
- *number = 0;
- for (i = 0; i < p->Buffer.Length; i++)
- *number += (*(p->Buffer.Pointer + i) << (i * 8));
- }
- }
+ error = acpi_ConvertBufferToInteger(&buf, number);
}
}
AcpiOsFree(buf.Pointer);
@@ -1163,6 +1156,27 @@ acpi_EvaluateInteger(ACPI_HANDLE handle, char *path, int *number)
return(error);
}
+ACPI_STATUS
+acpi_ConvertBufferToInteger(ACPI_BUFFER *bufp, int *number)
+{
+ ACPI_OBJECT *p;
+ int i;
+
+ p = (ACPI_OBJECT *)bufp->Pointer;
+ if (p->Type == ACPI_TYPE_INTEGER) {
+ *number = p->Integer.Value;
+ return(AE_OK);
+ }
+ if (p->Type != ACPI_TYPE_BUFFER)
+ return(AE_TYPE);
+ if (p->Buffer.Length > sizeof(int))
+ return(AE_BAD_DATA);
+ *number = 0;
+ for (i = 0; i < p->Buffer.Length; i++)
+ *number += (*(p->Buffer.Pointer + i) << (i * 8));
+ return(AE_OK);
+}
+
/*
* Iterate over the elements of an a package object, calling the supplied
* function for each element.
OpenPOWER on IntegriCloud