forked from luck/tmp_suning_uos_patched
50eca3eb89
Completed a major overhaul of the Resource Manager code - specifically, optimizations in the area of the AML/internal resource conversion code. The code has been optimized to simplify and eliminate duplicated code, CPU stack use has been decreased by optimizing function parameters and local variables, and naming conventions across the manager have been standardized for clarity and ease of maintenance (this includes function, parameter, variable, and struct/typedef names.) All Resource Manager dispatch and information tables have been moved to a single location for clarity and ease of maintenance. One new file was created, named "rsinfo.c". The ACPI return macros (return_ACPI_STATUS, etc.) have been modified to guarantee that the argument is not evaluated twice, making them less prone to macro side-effects. However, since there exists the possibility of additional stack use if a particular compiler cannot optimize them (such as in the debug generation case), the original macros are optionally available. Note that some invocations of the return_VALUE macro may now cause size mismatch warnings; the return_UINT8 and return_UINT32 macros are provided to eliminate these. (From Randy Dunlap) Implemented a new mechanism to enable debug tracing for individual control methods. A new external interface, acpi_debug_trace(), is provided to enable this mechanism. The intent is to allow the host OS to easily enable and disable tracing for problematic control methods. This interface can be easily exposed to a user or debugger interface if desired. See the file psxface.c for details. acpi_ut_callocate() will now return a valid pointer if a length of zero is specified - a length of one is used and a warning is issued. This matches the behavior of acpi_ut_allocate(). Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
106 lines
2.4 KiB
C
106 lines
2.4 KiB
C
/*
|
|
* arch/ia64/kernel/acpi-ext.c
|
|
*
|
|
* Copyright (C) 2003 Hewlett-Packard
|
|
* 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 byte_length;
|
|
|
|
if (resource->type != ACPI_RESOURCE_TYPE_VENDOR)
|
|
return AE_OK;
|
|
|
|
vendor = (struct acpi_resource_vendor *)&resource->data;
|
|
descriptor = (struct acpi_vendor_descriptor *)vendor->byte_data;
|
|
if (vendor->byte_length <= sizeof(*info->descriptor) ||
|
|
descriptor->guid_id != info->descriptor->guid_id ||
|
|
efi_guidcmp(descriptor->guid, info->descriptor->guid))
|
|
return AE_OK;
|
|
|
|
byte_length = vendor->byte_length - sizeof(struct acpi_vendor_descriptor);
|
|
info->data = acpi_os_allocate(byte_length);
|
|
if (!info->data)
|
|
return AE_NO_MEMORY;
|
|
|
|
memcpy(info->data,
|
|
vendor->byte_data + sizeof(struct acpi_vendor_descriptor),
|
|
byte_length);
|
|
info->length = byte_length;
|
|
return AE_CTRL_TERMINATE;
|
|
}
|
|
|
|
acpi_status
|
|
acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor * id,
|
|
u8 ** data, u32 * byte_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;
|
|
*byte_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)
|
|
};
|
|
|
|
acpi_status hp_acpi_csr_space(acpi_handle obj, u64 * csr_base, u64 * csr_length)
|
|
{
|
|
acpi_status status;
|
|
u8 *data;
|
|
u32 length;
|
|
|
|
status =
|
|
acpi_find_vendor_resource(obj, &hp_ccsr_descriptor, &data, &length);
|
|
|
|
if (ACPI_FAILURE(status) || length != 16)
|
|
return AE_NOT_FOUND;
|
|
|
|
memcpy(csr_base, data, sizeof(*csr_base));
|
|
memcpy(csr_length, data + 8, sizeof(*csr_length));
|
|
acpi_os_free(data);
|
|
|
|
return AE_OK;
|
|
}
|
|
|
|
EXPORT_SYMBOL(hp_acpi_csr_space);
|