public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI: implement UUID-labelled vendor-defined resources
@ 2005-03-18 20:19 Bjorn Helgaas
  2005-06-21 20:21 ` Bjorn Helgaas
  0 siblings, 1 reply; 8+ messages in thread
From: Bjorn Helgaas @ 2005-03-18 20:19 UTC (permalink / raw)
  To: ACPI List, linux-ia64

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.

When the code was under arch/ia64, we used EFI GUID stuff, but this time I
defined acpi_uuid equivalents to avoid the need to depend on EFI.

Len, Tony, this touches both acpi and ia64.  Let me know if this is
a problem.

This patch may be used under either the GPL or the BSD license.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

===== arch/ia64/kernel/acpi-ext.c 1.5 vs edited =====
--- 1.5/arch/ia64/kernel/acpi-ext.c	2004-10-05 12:19:50 -06:00
+++ edited/arch/ia64/kernel/acpi-ext.c	2005-03-18 11:29:18 -07:00
@@ -12,89 +12,35 @@
 #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 1.22 vs edited =====
--- 1.22/drivers/acpi/resources/rsxface.c	2005-01-20 22:17:54 -07:00
+++ edited/drivers/acpi/resources/rsxface.c	2005-03-18 12:24:34 -07:00
@@ -435,3 +435,90 @@
 }
 EXPORT_SYMBOL(acpi_resource_to_address64);
 
+static inline int
+acpi_uuidcmp (struct acpi_uuid left, struct acpi_uuid right)
+{
+	return memcmp(&left, &right, sizeof(left));
+}
+
+static 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->uuid_subtype != info->descriptor->uuid_subtype ||
+	    acpi_uuidcmp(descriptor->uuid, info->descriptor->uuid))
+		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;
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_find_vendor_resource
+ *
+ * PARAMETERS:  device_handle   - a handle to the device object for the
+ *                                device we are querying
+ *              id              - a pointer to the acpi_vendor_descriptor
+ *                                for the UUID-identified vendor-defined
+ *                                resource we want
+ *              data            - a pointer to a pointer where the address
+ *                                of the vendor data will be stored
+ *              length          - a pointer to an integer where the length
+ *                                of the vendor data will be stored
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: This function walks the current resources for the specified
+ *              device and looks for a vendor-defined resource that matches
+ *              the supplied UUID and subtype.
+ *
+ *              If the desired resource is found, a buffer is allocated for
+ *              the vendor-defined data (excluding the UUID and other headers),
+ *              and the address and size of the buffer are returned in *data
+ *              and *length.  The caller is responsible for deallocating
+ *              the buffer with acpi_os_free().
+ *
+ *              If the function fails, AE_NOT_FOUND will be returned and
+ *              the values of *data and *length are unchanged.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_find_vendor_resource(
+	acpi_handle			device_handle,
+	struct acpi_vendor_descriptor	*id,
+	u8				**data,
+	u32				*length)
+{
+	struct acpi_vendor_info info;
+
+	info.descriptor = id;
+	info.data = NULL;
+
+	acpi_walk_resources(device_handle, METHOD_NAME__CRS,
+		acpi_vendor_resource_match, &info);
+	if (!info.data)
+		return AE_NOT_FOUND;
+
+	*data = info.data;
+	*length = info.length;
+	return AE_OK;
+}
+EXPORT_SYMBOL(acpi_find_vendor_resource);
===== include/acpi/acpixf.h 1.31 vs edited =====
--- 1.31/include/acpi/acpixf.h	2005-01-20 22:17:55 -07:00
+++ edited/include/acpi/acpixf.h	2005-03-18 12:09:12 -07:00
@@ -425,10 +425,10 @@
 
 acpi_status
 acpi_walk_resources (
-	acpi_handle                             device_handle,
-	char                                    *path,
+	acpi_handle                     device_handle,
+	char                            *path,
 	ACPI_WALK_RESOURCE_CALLBACK     user_function,
-	void                                    *context);
+	void                            *context);
 
 acpi_status
 acpi_set_current_resources (
@@ -443,7 +443,14 @@
 acpi_status
 acpi_resource_to_address64 (
 	struct acpi_resource            *resource,
-	struct acpi_resource_address64 *out);
+	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 1.41 vs edited =====
--- 1.41/include/acpi/actypes.h	2005-01-20 22:17:55 -07:00
+++ edited/include/acpi/actypes.h	2005-03-18 11:23:21 -07:00
@@ -1045,6 +1045,16 @@
 #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
@@ -1097,6 +1107,18 @@
 {
 	u32                                 length;
 	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



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ACPI: implement UUID-labelled vendor-defined resources
  2005-03-18 20:19 [PATCH] ACPI: implement UUID-labelled vendor-defined resources Bjorn Helgaas
@ 2005-06-21 20:21 ` Bjorn Helgaas
  0 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2005-06-21 20:21 UTC (permalink / raw)
  To: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Len Brown; +Cc: linux-ia64

On Friday 18 March 2005 1:19 pm, Bjorn Helgaas wrote:
> 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.

There were some questions about the copyright status of this patch,
and whether it could be licensed appropriately for ACPI.  But I thought
those were all resolved.

I'm only trying to be a good citizen and contribute support for new
stuff in ACPI 3.0.  But if people want this to stay in ia64, I guess
that's OK with me, too.

BTW, is there still an ACPI BK tree?  The ones mentioned here:
    http://ftp.kernel.org/pub/linux/kernel/people/lenb/acpi/patches/README.ACPI
seem to be gone.

> When the code was under arch/ia64, we used EFI GUID stuff, but this time I
> defined acpi_uuid equivalents to avoid the need to depend on EFI.
> 
> Len, Tony, this touches both acpi and ia64.  Let me know if this is
> a problem.
> 
> This patch may be used under either the GPL or the BSD license.
> 
> Signed-off-by: Bjorn Helgaas <bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
> 
> ===== arch/ia64/kernel/acpi-ext.c 1.5 vs edited =====
> --- 1.5/arch/ia64/kernel/acpi-ext.c	2004-10-05 12:19:50 -06:00
> +++ edited/arch/ia64/kernel/acpi-ext.c	2005-03-18 11:29:18 -07:00
> @@ -12,89 +12,35 @@
>  #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 1.22 vs edited =====
> --- 1.22/drivers/acpi/resources/rsxface.c	2005-01-20 22:17:54 -07:00
> +++ edited/drivers/acpi/resources/rsxface.c	2005-03-18 12:24:34 -07:00
> @@ -435,3 +435,90 @@
>  }
>  EXPORT_SYMBOL(acpi_resource_to_address64);
>  
> +static inline int
> +acpi_uuidcmp (struct acpi_uuid left, struct acpi_uuid right)
> +{
> +	return memcmp(&left, &right, sizeof(left));
> +}
> +
> +static 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->uuid_subtype != info->descriptor->uuid_subtype ||
> +	    acpi_uuidcmp(descriptor->uuid, info->descriptor->uuid))
> +		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;
> +}
> +
> +/*******************************************************************************
> + *
> + * FUNCTION:    acpi_find_vendor_resource
> + *
> + * PARAMETERS:  device_handle   - a handle to the device object for the
> + *                                device we are querying
> + *              id              - a pointer to the acpi_vendor_descriptor
> + *                                for the UUID-identified vendor-defined
> + *                                resource we want
> + *              data            - a pointer to a pointer where the address
> + *                                of the vendor data will be stored
> + *              length          - a pointer to an integer where the length
> + *                                of the vendor data will be stored
> + *
> + * RETURN:      Status
> + *
> + * DESCRIPTION: This function walks the current resources for the specified
> + *              device and looks for a vendor-defined resource that matches
> + *              the supplied UUID and subtype.
> + *
> + *              If the desired resource is found, a buffer is allocated for
> + *              the vendor-defined data (excluding the UUID and other headers),
> + *              and the address and size of the buffer are returned in *data
> + *              and *length.  The caller is responsible for deallocating
> + *              the buffer with acpi_os_free().
> + *
> + *              If the function fails, AE_NOT_FOUND will be returned and
> + *              the values of *data and *length are unchanged.
> + *
> + ******************************************************************************/
> +
> +acpi_status
> +acpi_find_vendor_resource(
> +	acpi_handle			device_handle,
> +	struct acpi_vendor_descriptor	*id,
> +	u8				**data,
> +	u32				*length)
> +{
> +	struct acpi_vendor_info info;
> +
> +	info.descriptor = id;
> +	info.data = NULL;
> +
> +	acpi_walk_resources(device_handle, METHOD_NAME__CRS,
> +		acpi_vendor_resource_match, &info);
> +	if (!info.data)
> +		return AE_NOT_FOUND;
> +
> +	*data = info.data;
> +	*length = info.length;
> +	return AE_OK;
> +}
> +EXPORT_SYMBOL(acpi_find_vendor_resource);
> ===== include/acpi/acpixf.h 1.31 vs edited =====
> --- 1.31/include/acpi/acpixf.h	2005-01-20 22:17:55 -07:00
> +++ edited/include/acpi/acpixf.h	2005-03-18 12:09:12 -07:00
> @@ -425,10 +425,10 @@
>  
>  acpi_status
>  acpi_walk_resources (
> -	acpi_handle                             device_handle,
> -	char                                    *path,
> +	acpi_handle                     device_handle,
> +	char                            *path,
>  	ACPI_WALK_RESOURCE_CALLBACK     user_function,
> -	void                                    *context);
> +	void                            *context);
>  
>  acpi_status
>  acpi_set_current_resources (
> @@ -443,7 +443,14 @@
>  acpi_status
>  acpi_resource_to_address64 (
>  	struct acpi_resource            *resource,
> -	struct acpi_resource_address64 *out);
> +	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 1.41 vs edited =====
> --- 1.41/include/acpi/actypes.h	2005-01-20 22:17:55 -07:00
> +++ edited/include/acpi/actypes.h	2005-03-18 11:23:21 -07:00
> @@ -1045,6 +1045,16 @@
>  #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
> @@ -1097,6 +1107,18 @@
>  {
>  	u32                                 length;
>  	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
> 
> 
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Acpi-devel mailing list
> Acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/acpi-devel
> 


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] ACPI: implement UUID-labelled vendor-defined resources
@ 2005-09-16 17:41 Bjorn Helgaas
  0 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2005-09-16 17:41 UTC (permalink / raw)
  To: Len Brown; +Cc: Alex Williamson, acpi-devel, Tony Luck, linux-ia64

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 :-)).

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

===== arch/ia64/kernel/acpi-ext.c 1.5 vs edited =====
Index: work-vga2/arch/ia64/kernel/acpi-ext.c
===================================================================
--- work-vga2.orig/arch/ia64/kernel/acpi-ext.c	2005-09-14 09:28:07.000000000 -0600
+++ work-vga2/arch/ia64/kernel/acpi-ext.c	2005-09-15 14:52:33.000000000 -0600
@@ -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);
Index: work-vga2/drivers/acpi/resources/rsxface.c
===================================================================
--- work-vga2.orig/drivers/acpi/resources/rsxface.c	2005-09-14 09:28:10.000000000 -0600
+++ work-vga2/drivers/acpi/resources/rsxface.c	2005-09-15 14:29:02.000000000 -0600
@@ -410,3 +410,90 @@
 }
 
 EXPORT_SYMBOL(acpi_resource_to_address64);
+
+static inline int
+acpi_uuidcmp (struct acpi_uuid left, struct acpi_uuid right)
+{
+	return memcmp(&left, &right, sizeof(left));
+}
+
+static 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->uuid_subtype != info->descriptor->uuid_subtype ||
+	    acpi_uuidcmp(descriptor->uuid, info->descriptor->uuid))
+		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;
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_find_vendor_resource
+ *
+ * PARAMETERS:  device_handle   - a handle to the device object for the
+ *                                device we are querying
+ *              id              - a pointer to the acpi_vendor_descriptor
+ *                                for the UUID-identified vendor-defined
+ *                                resource we want
+ *              data            - a pointer to a pointer where the address
+ *                                of the vendor data will be stored
+ *              length          - a pointer to an integer where the length
+ *                                of the vendor data will be stored
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: This function walks the current resources for the specified
+ *              device and looks for a vendor-defined resource that matches
+ *              the supplied UUID and subtype.
+ *
+ *              If the desired resource is found, a buffer is allocated for
+ *              the vendor-defined data (excluding the UUID and other headers),
+ *              and the address and size of the buffer are returned in *data
+ *              and *length.  The caller is responsible for deallocating
+ *              the buffer with acpi_os_free().
+ *
+ *              If the function fails, AE_NOT_FOUND will be returned and
+ *              the values of *data and *length are unchanged.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_find_vendor_resource(acpi_handle device_handle,
+	struct acpi_vendor_descriptor *id, u8 **data, u32 *length)
+{
+	struct acpi_vendor_info info;
+
+	info.descriptor = id;
+	info.data = NULL;
+
+	acpi_walk_resources(device_handle, METHOD_NAME__CRS,
+		acpi_vendor_resource_match, &info);
+	if (!info.data)
+		return AE_NOT_FOUND;
+
+	*data = info.data;
+	*length = info.length;
+	return AE_OK;
+}
+
+EXPORT_SYMBOL(acpi_find_vendor_resource);
Index: work-vga2/include/acpi/acpixf.h
===================================================================
--- work-vga2.orig/include/acpi/acpixf.h	2005-09-14 09:29:10.000000000 -0600
+++ work-vga2/include/acpi/acpixf.h	2005-09-15 14:30:59.000000000 -0600
@@ -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
  */
Index: work-vga2/include/acpi/actypes.h
===================================================================
--- work-vga2.orig/include/acpi/actypes.h	2005-09-14 09:29:11.000000000 -0600
+++ work-vga2/include/acpi/actypes.h	2005-09-15 14:33:06.000000000 -0600
@@ -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;
 };

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ACPI: implement UUID-labelled vendor-defined resources
       [not found] ` <971FCB6690CD0E4898387DBF7552B90E02C0B5F2-sBd4vmA9Se5Qxe9IK+vIArfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2005-09-19 15:52   ` Christoph Hellwig
       [not found]     ` <20050919155203.GA24346-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
  2005-10-11 17:31   ` Bjorn Helgaas
  1 sibling, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2005-09-19 15:52 UTC (permalink / raw)
  To: Moore, Robert
  Cc: Bjorn Helgaas, Brown, Len, Alex Williamson,
	acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Luck, Tony,
	linux-ia64-u79uwXL29TY76Z2rM5mHXA

On Fri, Sep 16, 2005 at 02:56:31PM -0700, Moore, Robert wrote:
> And to make things even more interesting, the base ACPICA code looks
> nothing like the final Linux version of the code; it is converted on the
> fly before every release to Linux.

So the Linux code is not the "preferred from of modification"?  You're
on an extremly slipperly slope vs the GPL there.  Not that I want to
sue your or intel, but this is certainly not in the spirit of the
License.



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. 
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ACPI: implement UUID-labelled vendor-defined resources
       [not found]   ` <200509190931.20643.bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
@ 2005-09-20 23:09     ` Bjorn Helgaas
  0 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2005-09-20 23:09 UTC (permalink / raw)
  To: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: Moore, Robert, Brown, Len, Alex Williamson, Luck, Tony,
	linux-ia64-u79uwXL29TY76Z2rM5mHXA

On Monday 19 September 2005 9:31 am, Bjorn Helgaas wrote:
> > BTW, Please explain in more detail what support is needed in ACPICA for
> > the ACPI 3.0 vendor-defined resource.  Also, any idea how we are
> > supposed to determine if the UUID data exists within the descriptor?
> > (i.e., how do we differentiate an ACPI 2.0 vendor descriptor from an
> > ACPI 3.0 descriptor?)
> 
> There's no mark that distinguishes 2.0 and 3.0 vendor descriptors.
> As far as I can tell, a 3.0 descriptor (that contains a UUID and
> sub-type) is also a perfectly valid 2.0 descriptor.
> 
> ACPI 3.0 "strongs recommends," but apparently doesn't actually
> require a UUID, so a 2.0 vendor descriptor should also be a valid
> 3.0 descriptor.
> 
> The idea is that we just look through all the vendor descriptors
> for the supplied UUID.  If we find one, we return the information.
> There's a small possibility that an ACPI 2.0, non-UUID-labelled
> descriptor will contain data that happens to match the random
> 16-byte UUID, and we'll return it by mistake.  But that possibility
> is pretty remote, I think.

Ping...  Did this make any sense, or did I answer the wrong questions?


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. 
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] ACPI: implement UUID-labelled vendor-defined resources
@ 2005-09-20 23:16 Moore, Robert
  0 siblings, 0 replies; 8+ messages in thread
From: Moore, Robert @ 2005-09-20 23:16 UTC (permalink / raw)
  To: Bjorn Helgaas, acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: Brown, Len, Alex Williamson, Luck, Tony,
	linux-ia64-u79uwXL29TY76Z2rM5mHXA

I'll get to this a bit later.
Thx
Bob


> -----Original Message-----
> From: Bjorn Helgaas [mailto:bjorn.helgaas-VXdhtT5mjnY@public.gmane.org]
> Sent: Tuesday, September 20, 2005 4:10 PM
> To: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> Cc: Moore, Robert; Brown, Len; Alex Williamson; Luck, Tony; linux-
> ia64-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Subject: Re: [ACPI] [PATCH] ACPI: implement UUID-labelled
vendor-defined
> resources
> 
> On Monday 19 September 2005 9:31 am, Bjorn Helgaas wrote:
> > > BTW, Please explain in more detail what support is needed in
ACPICA
> for
> > > the ACPI 3.0 vendor-defined resource.  Also, any idea how we are
> > > supposed to determine if the UUID data exists within the
descriptor?
> > > (i.e., how do we differentiate an ACPI 2.0 vendor descriptor from
an
> > > ACPI 3.0 descriptor?)
> >
> > There's no mark that distinguishes 2.0 and 3.0 vendor descriptors.
> > As far as I can tell, a 3.0 descriptor (that contains a UUID and
> > sub-type) is also a perfectly valid 2.0 descriptor.
> >
> > ACPI 3.0 "strongs recommends," but apparently doesn't actually
> > require a UUID, so a 2.0 vendor descriptor should also be a valid
> > 3.0 descriptor.
> >
> > The idea is that we just look through all the vendor descriptors
> > for the supplied UUID.  If we find one, we return the information.
> > There's a small possibility that an ACPI 2.0, non-UUID-labelled
> > descriptor will contain data that happens to match the random
> > 16-byte UUID, and we'll return it by mistake.  But that possibility
> > is pretty remote, I think.
> 
> Ping...  Did this make any sense, or did I answer the wrong questions?


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ACPI: implement UUID-labelled vendor-defined resources
       [not found]     ` <20050919155203.GA24346-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
@ 2005-09-22 17:48       ` Pavel Machek
  0 siblings, 0 replies; 8+ messages in thread
From: Pavel Machek @ 2005-09-22 17:48 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Moore, Robert, Bjorn Helgaas, Brown, Len, Alex Williamson,
	acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Luck, Tony,
	linux-ia64-u79uwXL29TY76Z2rM5mHXA

Hi!

> > And to make things even more interesting, the base ACPICA code looks
> > nothing like the final Linux version of the code; it is converted on the
> > fly before every release to Linux.
> 
> So the Linux code is not the "preferred from of modification"?  You're
> on an extremly slipperly slope vs the GPL there.  Not that I want to
> sue your or intel, but this is certainly not in the spirit of the
> License.

Actually, they change it to conform to kernel coding-style... That
should be okay.

								Pavel
-- 
if you have sharp zaurus hardware you don't need... you know my address


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. 
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ACPI: implement UUID-labelled vendor-defined resources
       [not found] ` <971FCB6690CD0E4898387DBF7552B90E02C0B5F2-sBd4vmA9Se5Qxe9IK+vIArfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  2005-09-19 15:52   ` Christoph Hellwig
@ 2005-10-11 17:31   ` Bjorn Helgaas
  1 sibling, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2005-10-11 17:31 UTC (permalink / raw)
  To: Moore, Robert
  Cc: Brown, Len, acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	Tony Luck

On Friday 16 September 2005 3:56 pm, Moore, Robert wrote:
> And to make things even more interesting, the base ACPICA code looks
> nothing like the final Linux version of the code; it is converted on the
> fly before every release to Linux.

OK, here's the patch to the base ACPICA (prior to the Linux
conversion).

I tried to make it look ACPICA-ish.  When you integrate
this, there will be some breakage (name conflicts with the
old code that lives in arch/ia64/, probably a change required
to acpi_uuid.ByteData[], etc).  I hope it will be obvious
how to fix those up.  Applying the rest of my original
Linux-based patch should take care of most of it.

Let me know if I can help.

diff -u -ur acpica-unix-20050930/include/acpixf.h acpica-unix-20050930-new/include/acpixf.h
--- acpica-unix-20050930/include/acpixf.h	2005-09-30 16:50:25.000000000 -0600
+++ acpica-unix-20050930-new/include/acpixf.h	2005-10-11 11:08:32.000000000 -0600
@@ -498,6 +498,13 @@
     ACPI_RESOURCE           *Resource,
     ACPI_RESOURCE_ADDRESS64 *Out);
 
+ACPI_STATUS
+AcpiFindVendorResource (
+    ACPI_HANDLE		    DeviceHandle,
+    ACPI_VENDOR_DESCRIPTOR  *Id,
+    UINT8		    **Data,
+    UINT32		    *Length);
+
 /*
  * Hardware (ACPI device) interfaces
  */
diff -u -ur acpica-unix-20050930/include/actypes.h acpica-unix-20050930-new/include/actypes.h
--- acpica-unix-20050930/include/actypes.h	2005-09-30 16:50:25.000000000 -0600
+++ acpica-unix-20050930-new/include/actypes.h	2005-10-11 10:15:09.000000000 -0600
@@ -1145,6 +1145,17 @@
 #define ACPI_PRODUCER                   (UINT8) 0x00
 #define ACPI_CONSUMER                   (UINT8) 0x01
 
+typedef struct acpi_uuid
+{
+    UINT8			ByteData[16];
+} ACPI_UUID_STRUCT;
+
+#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
@@ -1209,6 +1220,19 @@
 
 } ACPI_RESOURCE_VENDOR;
 
+typedef struct acpi_vendor_descriptor
+{
+    UINT8			UuidSubtype;
+    ACPI_UUID_STRUCT		Uuid;
+} ACPI_VENDOR_DESCRIPTOR;
+
+typedef struct acpi_vendor_info
+{
+    ACPI_VENDOR_DESCRIPTOR	*Descriptor;
+    UINT8			*Data;
+    UINT32			Length;
+} ACPI_VENDOR_INFO;
+
 typedef struct acpi_resource_end_tag
 {
     UINT8                       Checksum;
diff -u -ur acpica-unix-20050930/resources/rsxface.c acpica-unix-20050930-new/resources/rsxface.c
--- acpica-unix-20050930/resources/rsxface.c	2005-09-30 16:50:33.000000000 -0600
+++ acpica-unix-20050930-new/resources/rsxface.c	2005-10-11 11:10:26.000000000 -0600
@@ -514,3 +514,103 @@
 
     return (AE_OK);
 }
+
+static inline int
+AcpiUuidCmp (
+    ACPI_UUID_STRUCT		Left,
+    ACPI_UUID_STRUCT		Right)
+{
+    return memcmp(&Left, &Right, sizeof (Left));
+}
+
+static ACPI_STATUS
+AcpiVendorResourceMatch (
+    ACPI_RESOURCE		*Resource,
+    void			*Context)
+{
+    ACPI_VENDOR_INFO		*Info = (ACPI_VENDOR_INFO *) Context;
+    ACPI_RESOURCE_VENDOR	*Vendor;
+    ACPI_VENDOR_DESCRIPTOR	*Descriptor;
+    UINT32			Length;
+
+    if (Resource->Type != ACPI_RESOURCE_TYPE_VENDOR)
+    {
+	return AE_OK;
+    }
+
+    Vendor = (ACPI_RESOURCE_VENDOR *) &Resource->Data;
+    Descriptor = (ACPI_VENDOR_DESCRIPTOR *) Vendor->ByteData;
+    if (Vendor->ByteLength <= sizeof (*Info->Descriptor) ||
+	Descriptor->UuidSubtype != Info->Descriptor->UuidSubtype ||
+	AcpiUuidCmp(Descriptor->Uuid, Info->Descriptor->Uuid))
+    {
+	return AE_OK;
+    }
+
+    Length = Vendor->ByteLength - sizeof (ACPI_VENDOR_DESCRIPTOR);
+    Info->Data = AcpiOsAllocate(Length);
+    if (!Info->Data)
+    {
+	return AE_NO_MEMORY;
+    }
+
+    memcpy(Info->Data, Vendor->ByteData +
+	    sizeof (ACPI_VENDOR_DESCRIPTOR), Length);
+    Info->Length = Length;
+    return AE_CTRL_TERMINATE;
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiFindVendorResource
+ *
+ * PARAMETERS:  DeviceHandle    - a handle to the device object for the
+ *                                device we are querying
+ *              Id              - a pointer to the acpi_vendor_descriptor
+ *                                for the UUID-identified vendor-defined
+ *                                resource we want
+ *              Data            - a pointer to a pointer where the address
+ *                                of the vendor data will be stored
+ *              Length          - a pointer to an integer where the length
+ *                                of the vendor data will be stored
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: This function walks the current resources for the specified
+ *              device and looks for a vendor-defined resource that matches
+ *              the supplied UUID and subtype.
+ *
+ *              If the desired resource is found, a buffer is allocated for
+ *              the vendor-defined data (excluding the UUID and other headers),
+ *              and the address and size of the buffer are returned in *Data
+ *              and *Length.  The caller is responsible for deallocating
+ *              the buffer with AcpiOsFree().
+ *
+ *              If the function fails, AE_NOT_FOUND will be returned and
+ *              the values of *Data and *Length are unchanged.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiFindVendorResource (
+    ACPI_HANDLE				DeviceHandle,
+    ACPI_VENDOR_DESCRIPTOR		*Id,
+    UINT8				**Data,
+    UINT32				*Length)
+{
+    ACPI_VENDOR_INFO			Info;
+
+    Info.Descriptor = Id;
+    Info.Data = NULL;
+
+    AcpiWalkResources(DeviceHandle, METHOD_NAME__CRS,
+	    AcpiVendorResourceMatch, &Info);
+    if (!Info.Data)
+    {
+	return AE_NOT_FOUND;
+    }
+
+    *Data = Info.Data;
+    *Length = Info.Length;
+    return AE_OK;
+}



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-10-11 17:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-18 20:19 [PATCH] ACPI: implement UUID-labelled vendor-defined resources Bjorn Helgaas
2005-06-21 20:21 ` Bjorn Helgaas
  -- strict thread matches above, loose matches on Subject: below --
2005-09-16 17:41 Bjorn Helgaas
2005-09-16 21:56 [ACPI] " Moore, Robert
2005-09-19 15:31 ` Bjorn Helgaas
     [not found]   ` <200509190931.20643.bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
2005-09-20 23:09     ` Bjorn Helgaas
     [not found] ` <971FCB6690CD0E4898387DBF7552B90E02C0B5F2-sBd4vmA9Se5Qxe9IK+vIArfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2005-09-19 15:52   ` Christoph Hellwig
     [not found]     ` <20050919155203.GA24346-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2005-09-22 17:48       ` Pavel Machek
2005-10-11 17:31   ` Bjorn Helgaas
2005-09-20 23:16 Moore, Robert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox