Skip to contentSkip to conversation

ACPI: implement UUID-labelled vendor-defined resources

PATCH New Bjorn Helgaas 1 participant 1 message Sep 16, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: implement UUID-labelled vendor-defined resources

ACPI 3.0 includes UUID-labelled vendor-defined resources (section 6.4.3.2), so move the code that supports this from arch/ia64 into ACPI proper.

Len, Tony, this touches both acpi and ia64. Probably easiest if Tony acks it and Len decides whether to apply it.

HP owns all the copyrights on the code being moved, and we agree that the code being moved into the ACPI CA may be used under either the GPL or the BSD-style license used by the ACPI CA.

(There should be something in Documentation/acpi about how to contribute to the ACPI CA. It's a royal pain in the rear :-)).

===== arch/ia64/kernel/acpi-ext.c 1.5 vs edited =====

arch/ia64/kernel/acpi-ext.c +16 -76
Index: work-vga2/arch/ia64/kernel/acpi-ext.c
===================================================================
@@ -1,105 +1,45 @@
 /*
- * arch/ia64/kernel/acpi-ext.c
+ * Vendor specific extensions to ACPI.
  *
- * Copyright (C) 2003 Hewlett-Packard
+ * (c) Copyright 2003, 2005 Hewlett-Packard Development Company, L.P.
  * Copyright (C) Alex Williamson
  * Copyright (C) Bjorn Helgaas
- *
- * Vendor specific extensions to ACPI.
  */
 
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/acpi.h>
-#include <linux/efi.h>
 
 #include <asm/acpi-ext.h>
 
-struct acpi_vendor_descriptor {
-	u8 guid_id;
-	efi_guid_t guid;
-};
-
-struct acpi_vendor_info {
-	struct acpi_vendor_descriptor *descriptor;
-	u8 *data;
-	u32 length;
-};
-
-acpi_status
-acpi_vendor_resource_match(struct acpi_resource *resource, void *context)
-{
-	struct acpi_vendor_info *info = (struct acpi_vendor_info *)context;
-	struct acpi_resource_vendor *vendor;
-	struct acpi_vendor_descriptor *descriptor;
-	u32 length;
-
-	if (resource->id != ACPI_RSTYPE_VENDOR)
-		return AE_OK;
-
-	vendor = (struct acpi_resource_vendor *)&resource->data;
-	descriptor = (struct acpi_vendor_descriptor *)vendor->reserved;
-	if (vendor->length <= sizeof(*info->descriptor) ||
-	    descriptor->guid_id != info->descriptor->guid_id ||
-	    efi_guidcmp(descriptor->guid, info->descriptor->guid))
-		return AE_OK;
-
-	length = vendor->length - sizeof(struct acpi_vendor_descriptor);
-	info->data = acpi_os_allocate(length);
-	if (!info->data)
-		return AE_NO_MEMORY;
-
-	memcpy(info->data,
-	       vendor->reserved + sizeof(struct acpi_vendor_descriptor),
-	       length);
-	info->length = length;
-	return AE_CTRL_TERMINATE;
-}
-
-acpi_status
-acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor * id,
-			  u8 ** data, u32 * length)
-{
-	struct acpi_vendor_info info;
-
-	info.descriptor = id;
-	info.data = NULL;
-
-	acpi_walk_resources(obj, METHOD_NAME__CRS, acpi_vendor_resource_match,
-			    &info);
-	if (!info.data)
-		return AE_NOT_FOUND;
-
-	*data = info.data;
-	*length = info.length;
-	return AE_OK;
-}
 
 struct acpi_vendor_descriptor hp_ccsr_descriptor = {
-	.guid_id = 2,
-	.guid =
-	    EFI_GUID(0x69e9adf9, 0x924f, 0xab5f, 0xf6, 0x4a, 0x24, 0xd2, 0x01,
-		     0x37, 0x0e, 0xad)
+	.uuid_subtype = 2,
+	.uuid = ACPI_UUID(0x69e9adf9, 0x924f, 0xab5f, 0xf6, 0x4a, 0x24, 0xd2,
+			  0x01, 0x37, 0x0e, 0xad)
 };
 
 acpi_status hp_acpi_csr_space(acpi_handle obj, u64 * csr_base, u64 * csr_length)
 {
-	acpi_status status;
-	u8 *data;
+	acpi_status status = AE_OK;
+	u8 *data = NULL;
 	u32 length;
 
-	status =
-	    acpi_find_vendor_resource(obj, &hp_ccsr_descriptor, &data, &length);
+	status = acpi_find_vendor_resource(obj, &hp_ccsr_descriptor, &data,
+		&length);
 
-	if (ACPI_FAILURE(status) || length != 16)
-		return AE_NOT_FOUND;
+	if (ACPI_FAILURE(status) || length != 16) {
+		status = AE_NOT_FOUND;
+		goto out;
+	}
 
 	memcpy(csr_base, data, sizeof(*csr_base));
 	memcpy(csr_length, data + 8, sizeof(*csr_length));
-	acpi_os_free(data);
 
-	return AE_OK;
+ out:
+	acpi_os_free(data);
+	return status;
 }
 
 EXPORT_SYMBOL(hp_acpi_csr_space);
drivers/acpi/resources/rsxface.c +87 -0

90 lines not on this page · raw message

include/acpi/acpixf.h +5 -0
Index: work-vga2/include/acpi/acpixf.h
===================================================================
@@ -295,6 +295,11 @@
 acpi_resource_to_address64(struct acpi_resource *resource,
 			   struct acpi_resource_address64 *out);
 
+acpi_status
+acpi_find_vendor_resource (acpi_handle device_handle,
+			   struct acpi_vendor_descriptor *id,
+			   u8 **data, u32 *length);
+
 /*
  * Hardware (ACPI device) interfaces
  */
include/acpi/actypes.h +23 -0
Index: work-vga2/include/acpi/actypes.h
===================================================================
@@ -974,6 +974,17 @@
 #define ACPI_PRODUCER                   (u8) 0x00
 #define ACPI_CONSUMER                   (u8) 0x01
 
+struct acpi_uuid {
+	u8                              b[16];
+};
+
+#define ACPI_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
+    ((struct acpi_uuid) \
+    {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
+      (b) & 0xff, ((b) >> 8) & 0xff, \
+      (c) & 0xff, ((c) >> 8) & 0xff, \
+      (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
+
 /*
  *  Structures used to describe device resources
  */
@@ -1021,6 +1032,18 @@
 	u8 reserved[1];
 };
 
+struct acpi_vendor_descriptor
+{
+	u8 uuid_subtype;
+	struct acpi_uuid uuid;
+};
+
+struct acpi_vendor_info {
+	struct acpi_vendor_descriptor *descriptor;
+	u8 *data;
+	u32 length;
+};
+
 struct acpi_resource_end_tag {
 	u8 checksum;
 };