Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
aiboost fix (Was: aiboost (Was: ACPICA update to 20080321))
On Thursday 2008-04-17 12:38 +1000, Geoff Wing output:
:On Wednesday 2008-04-16 16:55 +1000, Geoff Wing output:
::Removing aiboost and it works, so I guess there's some funny interaction
::with this ACPICA version and aiboost which exposes a bug not visible before.
This fixes it. Take what you want from it. The GetHandle and indexing
changes were for my debugging benefit. Only the
if (elem->Type == ACPI_TYPE_PACKAGE) {
subobj = elem;
buf2.Pointer = NULL;
} else if (elem->Type == ACPI_TYPE_LOCAL_REFERENCE) {
...
section is needed.
Regards,
Geoff
Index: sys/dev/acpi/aiboost.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/aiboost.c,v
retrieving revision 1.22
diff -u -r1.22 aiboost.c
--- sys/dev/acpi/aiboost.c 1 Feb 2008 23:12:30 -0000 1.22
+++ sys/dev/acpi/aiboost.c 17 Apr 2008 06:43:54 -0000
@@ -309,12 +309,19 @@
ACPI_BUFFER buf, buf2;
ACPI_OBJECT *o, *elem, *subobj, *myobj;
ACPI_STATUS status;
+ ACPI_HANDLE h1;
struct aiboost_comp *c = NULL;
- int i;
+ int i, num;
const char *str = NULL;
size_t length, clen = 0;
- status = acpi_eval_struct(h, name, &buf);
+ status = AcpiGetHandle(h, name, &h1);
+ if (ACPI_FAILURE(status)) {
+ DPRINTF(("%s: AcpiGetHandle\n", __func__));
+ return status;
+ }
+
+ status = acpi_eval_struct(h1, NULL, &buf);
if (ACPI_FAILURE(status)) {
DPRINTF(("%s: acpi_eval_struct\n", __func__));
return status;
@@ -331,40 +338,64 @@
DPRINTF(("%s: elem->Type != ACPI_TYPE_INTEGER\n", __func__));
goto error;
}
+ num = (int)elem[0].Integer.Value;
+ if (num != o->Package.Count - 1) {
+ DPRINTF(("%s: bad Package.Count/element[0].value\n", __func__));
+ }
- clen = sizeof(struct aiboost_comp) + sizeof(struct aiboost_elem) *
- (o->Package.Count - 1);
+ clen = sizeof(struct aiboost_comp) + sizeof(struct aiboost_elem) * num;
c = kmem_zalloc(clen, KM_NOSLEEP);
if (!c)
goto error;
*comp = c;
- c->num = o->Package.Count - 1;
+ c->num = num;
- for (i = 1; i < o->Package.Count; i++) {
- elem = &o->Package.Elements[i];
- if (elem->Type != ACPI_TYPE_ANY) {
- DPRINTF(("%s: elem->Type != ACPI_TYPE_ANY\n",
- __func__));
- goto error;
- }
+ DPRINTF(("%s, %d subitems\n", acpi_name(h1), num));
+#ifdef AIBOOST_DEBUG
+ for (i = 0; i < num; i++) {
+ elem = &o->Package.Elements[i+1];
+ DPRINTF(("elem[%d]->Type = %x\n", i+1, elem->Type));
+ if (elem->Type == ACPI_TYPE_PACKAGE) {
+ int j;
- c->elem[i - 1].h = elem->Reference.Handle;
- status = acpi_eval_struct(c->elem[i - 1].h, NULL, &buf2);
- if (ACPI_FAILURE(status)) {
- DPRINTF(("%s; fetching object in buf2\n",
+ j = elem->Package.Elements[0].Integer.Value;
+ DPRINTF((" subelem->Type = %x, %d\n",
elem->Package.Elements[0].Type, j));
+ }
+ }
+#endif
+ for (i = 0; i < num; i++) {
+ elem = &o->Package.Elements[i+1];
+ if (elem->Type == ACPI_TYPE_PACKAGE) {
+ subobj = elem;
+ buf2.Pointer = NULL;
+ } else if (elem->Type == ACPI_TYPE_LOCAL_REFERENCE) {
+ c->elem[i].h = elem->Reference.Handle;
+ status = acpi_eval_struct(c->elem[i].h, NULL, &buf2);
+ if (ACPI_FAILURE(status)) {
+ DPRINTF(("%s: fetching object in buf2\n",
+ __func__));
+ if (buf2.Pointer)
+ AcpiOsFree(buf2.Pointer);
+ continue;
+ }
+ subobj = buf2.Pointer;
+ } else {
+ DPRINTF(("%s: elem->Type cannot be processed\n",
__func__));
goto error;
}
- subobj = buf2.Pointer;
myobj = &subobj->Package.Elements[0];
/* Get UID */
- if (myobj == NULL || myobj->Type != ACPI_TYPE_INTEGER)
+ if (myobj == NULL || myobj->Type != ACPI_TYPE_INTEGER) {
+ DPRINTF(("%s: wrong type for element %d\n", __func__,
+ i + 1));
goto error;
+ }
- c->elem[i - 1].id = myobj->Integer.Value;
+ c->elem[i].id = myobj->Integer.Value;
/* Get string */
myobj = &subobj->Package.Elements[1];
@@ -387,9 +418,9 @@
}
DPRINTF(("%s: id=%d str=%s\n", __func__,
- c->elem[i - 1].id, str));
+ c->elem[i].id, str));
- (void)memcpy(c->elem[i - 1].desc, str, length);
+ (void)memcpy(c->elem[i].desc, str, length);
if (buf2.Pointer)
AcpiOsFree(buf2.Pointer);
Home |
Main Index |
Thread Index |
Old Index