Skip to contentSkip to conversation

Reference object type?

PATCH Nate Lawson 1 participant 1 message Apr 9, 2004 ACPI

lore
Share & tools
lore
#0 lore raw

Bob and others,

I can't seem to figure out the canonical ways to retrieve a Reference type. The ACPI-CA code seems to indicate:

    Type == ACPI_TYPE_LOCAL_REFERENCE and use obj->Reference.Handle

I also support ACPI_TYPE_ANY since that seems to be the previous type. Strings seem to be another way. This is needed for objects like this:

    Package() {\_SB.PCI0.ISA.GPE, 2}

Anyway, comments on my code below are welcome. It retrieves a handle from various forms of a reference and seems to have worked for a few years, at least for thermal zones.

Thanks,
-Nate

----
njl 2004/04/08 23:55:50 PDT

FreeBSD src repository

Modified files:
sys/dev/acpica acpi_powerres.c acpi_thermal.c
Log:
Replace more ad-hoc versions of acpi_GetReference(). Since the type of Reference objects changed from ACPI_TYPE_ANY to ACPI_TYPE_LOCAL_REFERENCE in Oct. 2002, this may help systems where switching the cooler on failed. We support both types for now until this sorts out.

  Revision  Changes    Path
  1.136     +33 -26    src/sys/dev/acpica/acpi.c
  1.3       +31 -0     src/sys/dev/acpica/acpi_package.c
  1.20      +3 -23     src/sys/dev/acpica/acpi_powerres.c
  1.41      +30 -69    src/sys/dev/acpica/acpi_thermal.c
sys/dev/acpica/acpi_package.c renamed from sys/dev/acpica/acpi_package.c:1.2 +31 -0
@@ -122,4 +122,35 @@
 	return (ENXIO);
 
     return (0);
+}
+
+ACPI_HANDLE
+acpi_GetReference(ACPI_HANDLE scope, ACPI_OBJECT *obj)
+{
+    ACPI_HANDLE h;
+
+    if (obj == NULL)
+	return (NULL);
+
+    switch (obj->Type) {
+    case ACPI_TYPE_LOCAL_REFERENCE:
+    case ACPI_TYPE_ANY:
+	h = obj->Reference.Handle;
+	break;
+    case ACPI_TYPE_STRING:
+	/*
+	 * The String object usually contains a fully-qualified path, so
+	 * scope can be NULL.
+	 *
+	 * XXX This may not always be the case.
+	 */
+	if (ACPI_FAILURE(AcpiGetHandle(scope, obj->String.Pointer, &h)))
+	    h = NULL;
+	break;
+    default:
+	h = NULL;
+	break;
+    }
+
+    return (h);
 }

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click