From bda663d36b94c723153246a4231bbc0f1cd1836e Mon Sep 17 00:00:00 2001 From: Robert Moore Date: Fri, 16 Sep 2005 16:51:15 -0400 Subject: [ACPI] ACPICA 20050916 Fixed a problem within the Resource Manager where support for the Generic Register descriptor was not fully implemented. This descriptor is now fully recognized, parsed, disassembled, and displayed. Restructured the Resource Manager code to utilize table-driven dispatch and lookup, eliminating many of the large switch() statements. This reduces overall subsystem code size and code complexity. Affects the resource parsing and construction, disassembly, and debug dump output. Cleaned up and restructured the debug dump output for all resource descriptors. Improved readability of the output and reduced code size. Fixed a problem where changes to internal data structures caused the optional ACPI_MUTEX_DEBUG code to fail compilation if specified. Signed-off-by: Robert Moore Signed-off-by: Len Brown --- include/acpi/acconfig.h | 4 ++-- include/acpi/acdisasm.h | 36 ++++++++++++++-------------- include/acpi/aclocal.h | 23 ++++++++++++++---- include/acpi/acresrc.h | 46 ++++++++++++++++++++++------------- include/acpi/actypes.h | 13 +++++++++- include/acpi/amlresrc.h | 56 +++++++++++++++++-------------------------- include/acpi/platform/acenv.h | 1 + 7 files changed, 104 insertions(+), 75 deletions(-) (limited to 'include') diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index 427cff1a3f83..1427c5cf4304 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -61,9 +61,9 @@ * */ -/* Version string */ +/* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20050902 +#define ACPI_CA_VERSION 0x20050916 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, diff --git a/include/acpi/acdisasm.h b/include/acpi/acdisasm.h index 3d96dcb1bb4b..759b4cff4f88 100644 --- a/include/acpi/acdisasm.h +++ b/include/acpi/acdisasm.h @@ -187,73 +187,73 @@ void acpi_dm_decode_attribute(u8 attribute); * dmresrcl */ void -acpi_dm_word_descriptor(struct asl_word_address_desc *resource, +acpi_dm_word_descriptor(union asl_resource_desc *resource, u32 length, u32 level); void -acpi_dm_dword_descriptor(struct asl_dword_address_desc *resource, +acpi_dm_dword_descriptor(union asl_resource_desc *resource, u32 length, u32 level); void -acpi_dm_extended_descriptor(struct asl_extended_address_desc *resource, +acpi_dm_extended_descriptor(union asl_resource_desc *resource, u32 length, u32 level); void -acpi_dm_qword_descriptor(struct asl_qword_address_desc *resource, +acpi_dm_qword_descriptor(union asl_resource_desc *resource, u32 length, u32 level); void -acpi_dm_memory24_descriptor(struct asl_memory_24_desc *resource, +acpi_dm_memory24_descriptor(union asl_resource_desc *resource, u32 length, u32 level); void -acpi_dm_memory32_descriptor(struct asl_memory_32_desc *resource, +acpi_dm_memory32_descriptor(union asl_resource_desc *resource, u32 length, u32 level); void -acpi_dm_fixed_mem32_descriptor(struct asl_fixed_memory_32_desc *resource, - u32 length, u32 level); +acpi_dm_fixed_memory32_descriptor(union asl_resource_desc *resource, + u32 length, u32 level); void -acpi_dm_generic_register_descriptor(struct asl_general_register_desc *resource, +acpi_dm_generic_register_descriptor(union asl_resource_desc *resource, u32 length, u32 level); void -acpi_dm_interrupt_descriptor(struct asl_extended_xrupt_desc *resource, +acpi_dm_interrupt_descriptor(union asl_resource_desc *resource, u32 length, u32 level); void -acpi_dm_vendor_large_descriptor(struct asl_large_vendor_desc *resource, +acpi_dm_vendor_large_descriptor(union asl_resource_desc *resource, u32 length, u32 level); /* * dmresrcs */ void -acpi_dm_irq_descriptor(struct asl_irq_format_desc *resource, +acpi_dm_irq_descriptor(union asl_resource_desc *resource, u32 length, u32 level); void -acpi_dm_dma_descriptor(struct asl_dma_format_desc *resource, +acpi_dm_dma_descriptor(union asl_resource_desc *resource, u32 length, u32 level); void -acpi_dm_io_descriptor(struct asl_io_port_desc *resource, u32 length, u32 level); +acpi_dm_io_descriptor(union asl_resource_desc *resource, u32 length, u32 level); void -acpi_dm_fixed_io_descriptor(struct asl_fixed_io_port_desc *resource, +acpi_dm_fixed_io_descriptor(union asl_resource_desc *resource, u32 length, u32 level); void -acpi_dm_start_dependent_descriptor(struct asl_start_dependent_desc *resource, +acpi_dm_start_dependent_descriptor(union asl_resource_desc *resource, u32 length, u32 level); void -acpi_dm_end_dependent_descriptor(struct asl_start_dependent_desc *resource, +acpi_dm_end_dependent_descriptor(union asl_resource_desc *resource, u32 length, u32 level); void -acpi_dm_vendor_small_descriptor(struct asl_small_vendor_desc *resource, +acpi_dm_vendor_small_descriptor(union asl_resource_desc *resource, u32 length, u32 level); /* diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h index 9fba0fddda90..76ac1533c405 100644 --- a/include/acpi/aclocal.h +++ b/include/acpi/aclocal.h @@ -744,12 +744,13 @@ struct acpi_bit_register_info { #define ACPI_RDESC_TYPE_LARGE 0x80 #define ACPI_RDESC_TYPE_SMALL 0x00 -#define ACPI_RDESC_TYPE_MASK 0x80 -#define ACPI_RDESC_SMALL_MASK 0x78 /* Only bits 6:3 contain the type */ +#define ACPI_RDESC_SMALL_MASK 0x78 /* Bits 6:3 contain the type */ +#define ACPI_RDESC_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */ +#define ACPI_RDESC_LARGE_MASK 0x7F /* Bits 6:0 contain the type */ /* * Small resource descriptor types - * Note: The 3 length bits (2:0) must be zero + * Note: Bits 2:0 are used for the descriptor length */ #define ACPI_RDESC_TYPE_IRQ_FORMAT 0x20 #define ACPI_RDESC_TYPE_DMA_FORMAT 0x28 @@ -757,6 +758,10 @@ struct acpi_bit_register_info { #define ACPI_RDESC_TYPE_END_DEPENDENT 0x38 #define ACPI_RDESC_TYPE_IO_PORT 0x40 #define ACPI_RDESC_TYPE_FIXED_IO_PORT 0x48 +#define ACPI_RDESC_TYPE_RESERVED_S1 0x50 +#define ACPI_RDESC_TYPE_RESERVED_S2 0x58 +#define ACPI_RDESC_TYPE_RESERVED_S3 0x60 +#define ACPI_RDESC_TYPE_RESERVED_S4 0x68 #define ACPI_RDESC_TYPE_SMALL_VENDOR 0x70 #define ACPI_RDESC_TYPE_END_TAG 0x78 @@ -764,7 +769,8 @@ struct acpi_bit_register_info { * Large resource descriptor types */ #define ACPI_RDESC_TYPE_MEMORY_24 0x81 -#define ACPI_RDESC_TYPE_GENERAL_REGISTER 0x82 +#define ACPI_RDESC_TYPE_GENERIC_REGISTER 0x82 +#define ACPI_RDESC_TYPE_RESERVED_L1 0x83 #define ACPI_RDESC_TYPE_LARGE_VENDOR 0x84 #define ACPI_RDESC_TYPE_MEMORY_32 0x85 #define ACPI_RDESC_TYPE_FIXED_MEMORY_32 0x86 @@ -773,6 +779,15 @@ struct acpi_bit_register_info { #define ACPI_RDESC_TYPE_EXTENDED_XRUPT 0x89 #define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE 0x8A #define ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE 0x8B +#define ACPI_RDESC_LARGE_MAX 0x8B + +/* + * Minimum lengths for descriptors with optional fields + */ +#define ACPI_RDESC_QWORD_MIN 43 +#define ACPI_RDESC_DWORD_MIN 23 +#define ACPI_RDESC_WORD_MIN 13 +#define ACPI_RDESC_EXT_XRUPT_MIN 6 /***************************************************************************** * diff --git a/include/acpi/acresrc.h b/include/acpi/acresrc.h index 38e798b05d08..ce2cf72fd4c8 100644 --- a/include/acpi/acresrc.h +++ b/include/acpi/acresrc.h @@ -110,7 +110,7 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, u32 byte_stream_buffer_length, u8 * output_buffer); acpi_status -acpi_rs_list_to_byte_stream(struct acpi_resource *linked_list, +acpi_rs_list_to_byte_stream(struct acpi_resource *resource, acpi_size byte_stream_size_needed, u8 * output_buffer); @@ -125,11 +125,11 @@ acpi_rs_fixed_io_resource(u8 * byte_stream_buffer, u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_io_stream(struct acpi_resource *linked_list, +acpi_rs_io_stream(struct acpi_resource *resource, u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_fixed_io_stream(struct acpi_resource *linked_list, +acpi_rs_fixed_io_stream(struct acpi_resource *resource, u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status @@ -138,7 +138,7 @@ acpi_rs_irq_resource(u8 * byte_stream_buffer, u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_irq_stream(struct acpi_resource *linked_list, +acpi_rs_irq_stream(struct acpi_resource *resource, u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status @@ -147,7 +147,7 @@ acpi_rs_dma_resource(u8 * byte_stream_buffer, u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_dma_stream(struct acpi_resource *linked_list, +acpi_rs_dma_stream(struct acpi_resource *resource, u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status @@ -156,7 +156,7 @@ acpi_rs_address16_resource(u8 * byte_stream_buffer, u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_address16_stream(struct acpi_resource *linked_list, +acpi_rs_address16_stream(struct acpi_resource *resource, u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status @@ -165,7 +165,7 @@ acpi_rs_address32_resource(u8 * byte_stream_buffer, u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_address32_stream(struct acpi_resource *linked_list, +acpi_rs_address32_stream(struct acpi_resource *resource, u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status @@ -174,7 +174,7 @@ acpi_rs_address64_resource(u8 * byte_stream_buffer, u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_address64_stream(struct acpi_resource *linked_list, +acpi_rs_address64_stream(struct acpi_resource *resource, u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status @@ -190,12 +190,12 @@ acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer, acpi_size * structure_size); acpi_status -acpi_rs_start_depend_fns_stream(struct acpi_resource *linked_list, +acpi_rs_start_depend_fns_stream(struct acpi_resource *resource, u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_end_depend_fns_stream(struct acpi_resource *linked_list, +acpi_rs_end_depend_fns_stream(struct acpi_resource *resource, u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status @@ -204,7 +204,7 @@ acpi_rs_memory24_resource(u8 * byte_stream_buffer, u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_memory24_stream(struct acpi_resource *linked_list, +acpi_rs_memory24_stream(struct acpi_resource *resource, u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status @@ -220,11 +220,11 @@ acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer, acpi_size * structure_size); acpi_status -acpi_rs_memory32_range_stream(struct acpi_resource *linked_list, +acpi_rs_memory32_range_stream(struct acpi_resource *resource, u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status -acpi_rs_fixed_memory32_stream(struct acpi_resource *linked_list, +acpi_rs_fixed_memory32_stream(struct acpi_resource *resource, u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status @@ -233,7 +233,7 @@ acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_extended_irq_stream(struct acpi_resource *linked_list, +acpi_rs_extended_irq_stream(struct acpi_resource *resource, u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status @@ -242,7 +242,7 @@ acpi_rs_end_tag_resource(u8 * byte_stream_buffer, u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_end_tag_stream(struct acpi_resource *linked_list, +acpi_rs_end_tag_stream(struct acpi_resource *resource, u8 ** output_buffer, acpi_size * bytes_consumed); acpi_status @@ -251,9 +251,23 @@ acpi_rs_vendor_resource(u8 * byte_stream_buffer, u8 ** output_buffer, acpi_size * structure_size); acpi_status -acpi_rs_vendor_stream(struct acpi_resource *linked_list, +acpi_rs_vendor_stream(struct acpi_resource *resource, u8 ** output_buffer, acpi_size * bytes_consumed); u8 acpi_rs_get_resource_type(u8 resource_start_byte); +/* + * rsmisc + */ +acpi_status +acpi_rs_generic_register_resource(u8 * byte_stream_buffer, + acpi_size * bytes_consumed, + u8 ** output_buffer, + acpi_size * structure_size); + +acpi_status +acpi_rs_generic_register_stream(struct acpi_resource *resource, + u8 ** output_buffer, + acpi_size * bytes_consumed); + #endif /* __ACRESRC_H__ */ diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 6213b27516e8..1dfa64fae4ec 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -1125,6 +1125,14 @@ struct acpi_resource_ext_irq { u32 interrupts[1]; }; +struct acpi_resource_generic_reg { + u32 space_id; + u32 bit_width; + u32 bit_offset; + u32 address_size; + u64 address; +}; + /* ACPI_RESOURCE_TYPEs */ #define ACPI_RSTYPE_IRQ 0 @@ -1142,6 +1150,8 @@ struct acpi_resource_ext_irq { #define ACPI_RSTYPE_ADDRESS32 12 #define ACPI_RSTYPE_ADDRESS64 13 #define ACPI_RSTYPE_EXT_IRQ 14 +#define ACPI_RSTYPE_GENERIC_REG 15 +#define ACPI_RSTYPE_MAX 15 typedef u32 acpi_resource_type; @@ -1161,10 +1171,11 @@ union acpi_resource_data { struct acpi_resource_address32 address32; struct acpi_resource_address64 address64; struct acpi_resource_ext_irq extended_irq; + struct acpi_resource_generic_reg generic_reg; }; struct acpi_resource { - acpi_resource_type id; + acpi_resource_type type; u32 length; union acpi_resource_data data; }; diff --git a/include/acpi/amlresrc.h b/include/acpi/amlresrc.h index 051786e4b210..a3c46ba6358d 100644 --- a/include/acpi/amlresrc.h +++ b/include/acpi/amlresrc.h @@ -157,10 +157,15 @@ struct asl_end_tag_desc { /* LARGE descriptors */ +#define ASL_LARGE_HEADER_COMMON \ + u8 descriptor_type;\ + u16 length; + +struct asl_large_header { +ASL_LARGE_HEADER_COMMON}; + struct asl_memory_24_desc { - u8 descriptor_type; - u16 length; - u8 information; + ASL_LARGE_HEADER_COMMON u8 information; u16 address_min; u16 address_max; u16 alignment; @@ -168,15 +173,11 @@ struct asl_memory_24_desc { }; struct asl_large_vendor_desc { - u8 descriptor_type; - u16 length; - u8 vendor_defined[1]; + ASL_LARGE_HEADER_COMMON u8 vendor_defined[1]; }; struct asl_memory_32_desc { - u8 descriptor_type; - u16 length; - u8 information; + ASL_LARGE_HEADER_COMMON u8 information; u32 address_min; u32 address_max; u32 alignment; @@ -184,17 +185,13 @@ struct asl_memory_32_desc { }; struct asl_fixed_memory_32_desc { - u8 descriptor_type; - u16 length; - u8 information; + ASL_LARGE_HEADER_COMMON u8 information; u32 base_address; u32 range_length; }; struct asl_extended_address_desc { - u8 descriptor_type; - u16 length; - u8 resource_type; + ASL_LARGE_HEADER_COMMON u8 resource_type; u8 flags; u8 specific_flags; u8 revision_iD; @@ -211,9 +208,7 @@ struct asl_extended_address_desc { #define ASL_EXTENDED_ADDRESS_DESC_REVISION 1 /* ACPI 3.0 */ struct asl_qword_address_desc { - u8 descriptor_type; - u16 length; - u8 resource_type; + ASL_LARGE_HEADER_COMMON u8 resource_type; u8 flags; u8 specific_flags; u64 granularity; @@ -225,9 +220,7 @@ struct asl_qword_address_desc { }; struct asl_dword_address_desc { - u8 descriptor_type; - u16 length; - u8 resource_type; + ASL_LARGE_HEADER_COMMON u8 resource_type; u8 flags; u8 specific_flags; u32 granularity; @@ -239,9 +232,7 @@ struct asl_dword_address_desc { }; struct asl_word_address_desc { - u8 descriptor_type; - u16 length; - u8 resource_type; + ASL_LARGE_HEADER_COMMON u8 resource_type; u8 flags; u8 specific_flags; u16 granularity; @@ -253,18 +244,14 @@ struct asl_word_address_desc { }; struct asl_extended_xrupt_desc { - u8 descriptor_type; - u16 length; - u8 flags; + ASL_LARGE_HEADER_COMMON u8 flags; u8 table_length; u32 interrupt_number[1]; /* res_source_index, res_source optional fields follow */ }; -struct asl_general_register_desc { - u8 descriptor_type; - u16 length; - u8 address_space_id; +struct asl_generic_register_desc { + ASL_LARGE_HEADER_COMMON u8 address_space_id; u8 bit_width; u8 bit_offset; u8 access_size; /* ACPI 3.0, was Reserved */ @@ -280,13 +267,14 @@ struct asl_general_register_desc { union asl_resource_desc { struct asl_irq_format_desc irq; struct asl_dma_format_desc dma; - struct asl_start_dependent_desc std; - struct asl_end_dependent_desc end; struct asl_io_port_desc iop; struct asl_fixed_io_port_desc fio; + struct asl_start_dependent_desc std; + struct asl_end_dependent_desc end; struct asl_small_vendor_desc smv; struct asl_end_tag_desc et; + struct asl_large_header lhd; struct asl_memory_24_desc M24; struct asl_large_vendor_desc lgv; struct asl_memory_32_desc M32; @@ -296,7 +284,7 @@ union asl_resource_desc { struct asl_word_address_desc was; struct asl_extended_address_desc eas; struct asl_extended_xrupt_desc exx; - struct asl_general_register_desc grg; + struct asl_generic_register_desc grg; u32 u32_item; u16 u16_item; u8 U8item; diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h index 16609c1ab2eb..08539125696a 100644 --- a/include/acpi/platform/acenv.h +++ b/include/acpi/platform/acenv.h @@ -68,6 +68,7 @@ #define ACPI_APPLICATION #define ACPI_DEBUGGER #define ACPI_DISASSEMBLER +#define ACPI_MUTEX_DEBUG #endif #ifdef ACPI_ASL_COMPILER -- cgit v1.2.3 From 05131ecc99ea9da7f45ba3058fe8a2c1d0ceeab8 Mon Sep 17 00:00:00 2001 From: Venkatesh Pallipadi Date: Sun, 23 Oct 2005 16:31:00 -0400 Subject: [ACPI] Avoid BIOS inflicted crashes by evaluating _PDC only once Linux invokes the AML _PDC method (Processor Driver Capabilities) to tell the BIOS what features it can handle. While the ACPI spec says nothing about the OS invoking _PDC multiple times, doing so with changing bits seems to hopelessly confuse the BIOS on multiple platforms up to and including crashing the system. Factor out the _PDC invocation so Linux invokes it only once. http://bugzilla.kernel.org/show_bug.cgi?id=5483 Signed-off-by: Venkatesh Pallipadi Signed-off-by: Len Brown --- arch/i386/kernel/acpi/Makefile | 2 +- arch/i386/kernel/acpi/cstate.c | 58 ------------------ arch/i386/kernel/acpi/processor.c | 75 +++++++++++++++++++++++ arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c | 67 -------------------- arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c | 12 ---- arch/ia64/kernel/cpufreq/Makefile | 5 ++ arch/ia64/kernel/cpufreq/acpi-cpufreq.c | 51 --------------- arch/ia64/kernel/cpufreq/acpi-processor.c | 67 ++++++++++++++++++++ arch/x86_64/kernel/acpi/Makefile | 5 ++ arch/x86_64/kernel/acpi/processor.c | 72 ++++++++++++++++++++++ drivers/acpi/processor_core.c | 28 ++++----- drivers/acpi/processor_idle.c | 2 - drivers/acpi/processor_perflib.c | 2 - include/acpi/pdc_intel.h | 4 +- include/acpi/processor.h | 22 ++----- include/asm-i386/acpi.h | 2 +- 16 files changed, 243 insertions(+), 231 deletions(-) create mode 100644 arch/i386/kernel/acpi/processor.c create mode 100644 arch/ia64/kernel/cpufreq/acpi-processor.c create mode 100644 arch/x86_64/kernel/acpi/processor.c (limited to 'include') diff --git a/arch/i386/kernel/acpi/Makefile b/arch/i386/kernel/acpi/Makefile index 267ca48e1b6c..d51c7313cae8 100644 --- a/arch/i386/kernel/acpi/Makefile +++ b/arch/i386/kernel/acpi/Makefile @@ -3,6 +3,6 @@ obj-$(CONFIG_X86_IO_APIC) += earlyquirk.o obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o ifneq ($(CONFIG_ACPI_PROCESSOR),) -obj-y += cstate.o +obj-y += cstate.o processor.o endif diff --git a/arch/i386/kernel/acpi/cstate.c b/arch/i386/kernel/acpi/cstate.c index 4c3036ba65df..25db49ef1770 100644 --- a/arch/i386/kernel/acpi/cstate.c +++ b/arch/i386/kernel/acpi/cstate.c @@ -14,64 +14,6 @@ #include #include -static void acpi_processor_power_init_intel_pdc(struct acpi_processor_power - *pow) -{ - struct acpi_object_list *obj_list; - union acpi_object *obj; - u32 *buf; - - /* allocate and initialize pdc. It will be used later. */ - obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL); - if (!obj_list) { - printk(KERN_ERR "Memory allocation error\n"); - return; - } - - obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL); - if (!obj) { - printk(KERN_ERR "Memory allocation error\n"); - kfree(obj_list); - return; - } - - buf = kmalloc(12, GFP_KERNEL); - if (!buf) { - printk(KERN_ERR "Memory allocation error\n"); - kfree(obj); - kfree(obj_list); - return; - } - - buf[0] = ACPI_PDC_REVISION_ID; - buf[1] = 1; - buf[2] = ACPI_PDC_C_CAPABILITY_SMP; - - obj->type = ACPI_TYPE_BUFFER; - obj->buffer.length = 12; - obj->buffer.pointer = (u8 *) buf; - obj_list->count = 1; - obj_list->pointer = obj; - pow->pdc = obj_list; - - return; -} - -/* Initialize _PDC data based on the CPU vendor */ -void acpi_processor_power_init_pdc(struct acpi_processor_power *pow, - unsigned int cpu) -{ - struct cpuinfo_x86 *c = cpu_data + cpu; - - pow->pdc = NULL; - if (c->x86_vendor == X86_VENDOR_INTEL) - acpi_processor_power_init_intel_pdc(pow); - - return; -} - -EXPORT_SYMBOL(acpi_processor_power_init_pdc); - /* * Initialize bm_flags based on the CPU cache properties * On SMP it depends on cache configuration diff --git a/arch/i386/kernel/acpi/processor.c b/arch/i386/kernel/acpi/processor.c new file mode 100644 index 000000000000..9f4cc02717ec --- /dev/null +++ b/arch/i386/kernel/acpi/processor.c @@ -0,0 +1,75 @@ +/* + * arch/i386/kernel/acpi/processor.c + * + * Copyright (C) 2005 Intel Corporation + * Venkatesh Pallipadi + * - Added _PDC for platforms with Intel CPUs + */ + +#include +#include +#include +#include + +#include +#include + +static void init_intel_pdc(struct acpi_processor *pr, struct cpuinfo_x86 *c) +{ + struct acpi_object_list *obj_list; + union acpi_object *obj; + u32 *buf; + + /* allocate and initialize pdc. It will be used later. */ + obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL); + if (!obj_list) { + printk(KERN_ERR "Memory allocation error\n"); + return; + } + + obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL); + if (!obj) { + printk(KERN_ERR "Memory allocation error\n"); + kfree(obj_list); + return; + } + + buf = kmalloc(12, GFP_KERNEL); + if (!buf) { + printk(KERN_ERR "Memory allocation error\n"); + kfree(obj); + kfree(obj_list); + return; + } + + buf[0] = ACPI_PDC_REVISION_ID; + buf[1] = 1; + buf[2] = ACPI_PDC_C_CAPABILITY_SMP; + + if (cpu_has(c, X86_FEATURE_EST)) + buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP; + + obj->type = ACPI_TYPE_BUFFER; + obj->buffer.length = 12; + obj->buffer.pointer = (u8 *) buf; + obj_list->count = 1; + obj_list->pointer = obj; + pr->pdc = obj_list; + + return; +} + +/* Initialize _PDC data based on the CPU vendor */ +void arch_acpi_processor_init_pdc(struct acpi_processor *pr) +{ + unsigned int cpu = pr->id; + struct cpuinfo_x86 *c = cpu_data + cpu; + + pr->pdc = NULL; + if (c->x86_vendor == X86_VENDOR_INTEL) + init_intel_pdc(pr, c); + + return; +} + +EXPORT_SYMBOL(arch_acpi_processor_init_pdc); diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c index 871366b83b3f..31ce890865d5 100644 --- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c +++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c @@ -297,68 +297,6 @@ acpi_cpufreq_guess_freq ( } -/* - * acpi_processor_cpu_init_pdc_est - let BIOS know about the SMP capabilities - * of this driver - * @perf: processor-specific acpi_io_data struct - * @cpu: CPU being initialized - * - * To avoid issues with legacy OSes, some BIOSes require to be informed of - * the SMP capabilities of OS P-state driver. Here we set the bits in _PDC - * accordingly, for Enhanced Speedstep. Actual call to _PDC is done in - * driver/acpi/processor.c - */ -static void -acpi_processor_cpu_init_pdc_est( - struct acpi_processor_performance *perf, - unsigned int cpu, - struct acpi_object_list *obj_list - ) -{ - union acpi_object *obj; - u32 *buf; - struct cpuinfo_x86 *c = cpu_data + cpu; - dprintk("acpi_processor_cpu_init_pdc_est\n"); - - if (!cpu_has(c, X86_FEATURE_EST)) - return; - - /* Initialize pdc. It will be used later. */ - if (!obj_list) - return; - - if (!(obj_list->count && obj_list->pointer)) - return; - - obj = obj_list->pointer; - if ((obj->buffer.length == 12) && obj->buffer.pointer) { - buf = (u32 *)obj->buffer.pointer; - buf[0] = ACPI_PDC_REVISION_ID; - buf[1] = 1; - buf[2] = ACPI_PDC_EST_CAPABILITY_SMP; - perf->pdc = obj_list; - } - return; -} - - -/* CPU specific PDC initialization */ -static void -acpi_processor_cpu_init_pdc( - struct acpi_processor_performance *perf, - unsigned int cpu, - struct acpi_object_list *obj_list - ) -{ - struct cpuinfo_x86 *c = cpu_data + cpu; - dprintk("acpi_processor_cpu_init_pdc\n"); - perf->pdc = NULL; - if (cpu_has(c, X86_FEATURE_EST)) - acpi_processor_cpu_init_pdc_est(perf, cpu, obj_list); - return; -} - - static int acpi_cpufreq_cpu_init ( struct cpufreq_policy *policy) @@ -373,9 +311,6 @@ acpi_cpufreq_cpu_init ( struct acpi_object_list arg_list = {1, &arg0}; dprintk("acpi_cpufreq_cpu_init\n"); - /* setup arg_list for _PDC settings */ - arg0.buffer.length = 12; - arg0.buffer.pointer = (u8 *) arg0_buf; data = kzalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL); if (!data) @@ -383,9 +318,7 @@ acpi_cpufreq_cpu_init ( acpi_io_data[cpu] = data; - acpi_processor_cpu_init_pdc(&data->acpi_data, cpu, &arg_list); result = acpi_processor_register_performance(&data->acpi_data, cpu); - data->acpi_data.pdc = NULL; if (result) goto err_free; diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c index edb9873e27e3..d93023438c4f 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c @@ -364,22 +364,10 @@ static struct acpi_processor_performance p; */ static int centrino_cpu_init_acpi(struct cpufreq_policy *policy) { - union acpi_object arg0 = {ACPI_TYPE_BUFFER}; - u32 arg0_buf[3]; - struct acpi_object_list arg_list = {1, &arg0}; unsigned long cur_freq; int result = 0, i; unsigned int cpu = policy->cpu; - /* _PDC settings */ - arg0.buffer.length = 12; - arg0.buffer.pointer = (u8 *) arg0_buf; - arg0_buf[0] = ACPI_PDC_REVISION_ID; - arg0_buf[1] = 1; - arg0_buf[2] = ACPI_PDC_EST_CAPABILITY_SMP_MSR; - - p.pdc = &arg_list; - /* register with ACPI core */ if (acpi_processor_register_performance(&p, cpu)) { dprintk(KERN_INFO PFX "obtaining ACPI data failed\n"); diff --git a/arch/ia64/kernel/cpufreq/Makefile b/arch/ia64/kernel/cpufreq/Makefile index f748d34c02f0..642648361ed3 100644 --- a/arch/ia64/kernel/cpufreq/Makefile +++ b/arch/ia64/kernel/cpufreq/Makefile @@ -1 +1,6 @@ obj-$(CONFIG_IA64_ACPI_CPUFREQ) += acpi-cpufreq.o + +ifneq ($(CONFIG_ACPI_PROCESSOR),) +obj-y += acpi-processor.o +endif + diff --git a/arch/ia64/kernel/cpufreq/acpi-cpufreq.c b/arch/ia64/kernel/cpufreq/acpi-cpufreq.c index da4d5cf80a48..5a1bf815282d 100644 --- a/arch/ia64/kernel/cpufreq/acpi-cpufreq.c +++ b/arch/ia64/kernel/cpufreq/acpi-cpufreq.c @@ -269,48 +269,6 @@ acpi_cpufreq_verify ( } -/* - * processor_init_pdc - let BIOS know about the SMP capabilities - * of this driver - * @perf: processor-specific acpi_io_data struct - * @cpu: CPU being initialized - * - * To avoid issues with legacy OSes, some BIOSes require to be informed of - * the SMP capabilities of OS P-state driver. Here we set the bits in _PDC - * accordingly. Actual call to _PDC is done in driver/acpi/processor.c - */ -static void -processor_init_pdc ( - struct acpi_processor_performance *perf, - unsigned int cpu, - struct acpi_object_list *obj_list - ) -{ - union acpi_object *obj; - u32 *buf; - - dprintk("processor_init_pdc\n"); - - perf->pdc = NULL; - /* Initialize pdc. It will be used later. */ - if (!obj_list) - return; - - if (!(obj_list->count && obj_list->pointer)) - return; - - obj = obj_list->pointer; - if ((obj->buffer.length == 12) && obj->buffer.pointer) { - buf = (u32 *)obj->buffer.pointer; - buf[0] = ACPI_PDC_REVISION_ID; - buf[1] = 1; - buf[2] = ACPI_PDC_EST_CAPABILITY_SMP; - perf->pdc = obj_list; - } - return; -} - - static int acpi_cpufreq_cpu_init ( struct cpufreq_policy *policy) @@ -320,14 +278,7 @@ acpi_cpufreq_cpu_init ( struct cpufreq_acpi_io *data; unsigned int result = 0; - union acpi_object arg0 = {ACPI_TYPE_BUFFER}; - u32 arg0_buf[3]; - struct acpi_object_list arg_list = {1, &arg0}; - dprintk("acpi_cpufreq_cpu_init\n"); - /* setup arg_list for _PDC settings */ - arg0.buffer.length = 12; - arg0.buffer.pointer = (u8 *) arg0_buf; data = kmalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL); if (!data) @@ -337,9 +288,7 @@ acpi_cpufreq_cpu_init ( acpi_io_data[cpu] = data; - processor_init_pdc(&data->acpi_data, cpu, &arg_list); result = acpi_processor_register_performance(&data->acpi_data, cpu); - data->acpi_data.pdc = NULL; if (result) goto err_free; diff --git a/arch/ia64/kernel/cpufreq/acpi-processor.c b/arch/ia64/kernel/cpufreq/acpi-processor.c new file mode 100644 index 000000000000..e683630c8ce2 --- /dev/null +++ b/arch/ia64/kernel/cpufreq/acpi-processor.c @@ -0,0 +1,67 @@ +/* + * arch/ia64/kernel/cpufreq/processor.c + * + * Copyright (C) 2005 Intel Corporation + * Venkatesh Pallipadi + * - Added _PDC for platforms with Intel CPUs + */ + +#include +#include +#include +#include + +#include +#include + +static void init_intel_pdc(struct acpi_processor *pr) +{ + struct acpi_object_list *obj_list; + union acpi_object *obj; + u32 *buf; + + /* allocate and initialize pdc. It will be used later. */ + obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL); + if (!obj_list) { + printk(KERN_ERR "Memory allocation error\n"); + return; + } + + obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL); + if (!obj) { + printk(KERN_ERR "Memory allocation error\n"); + kfree(obj_list); + return; + } + + buf = kmalloc(12, GFP_KERNEL); + if (!buf) { + printk(KERN_ERR "Memory allocation error\n"); + kfree(obj); + kfree(obj_list); + return; + } + + buf[0] = ACPI_PDC_REVISION_ID; + buf[1] = 1; + buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP; + + obj->type = ACPI_TYPE_BUFFER; + obj->buffer.length = 12; + obj->buffer.pointer = (u8 *) buf; + obj_list->count = 1; + obj_list->pointer = obj; + pr->pdc = obj_list; + + return; +} + +/* Initialize _PDC data based on the CPU vendor */ +void arch_acpi_processor_init_pdc(struct acpi_processor *pr) +{ + pr->pdc = NULL; + init_intel_pdc(pr); + return; +} + +EXPORT_SYMBOL(arch_acpi_processor_init_pdc); diff --git a/arch/x86_64/kernel/acpi/Makefile b/arch/x86_64/kernel/acpi/Makefile index 7da9ace890bd..4fe97071f297 100644 --- a/arch/x86_64/kernel/acpi/Makefile +++ b/arch/x86_64/kernel/acpi/Makefile @@ -1,3 +1,8 @@ obj-y := boot.o boot-y := ../../../i386/kernel/acpi/boot.o obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o + +ifneq ($(CONFIG_ACPI_PROCESSOR),) +obj-y += processor.o +endif + diff --git a/arch/x86_64/kernel/acpi/processor.c b/arch/x86_64/kernel/acpi/processor.c new file mode 100644 index 000000000000..3bdc2baa5bb1 --- /dev/null +++ b/arch/x86_64/kernel/acpi/processor.c @@ -0,0 +1,72 @@ +/* + * arch/x86_64/kernel/acpi/processor.c + * + * Copyright (C) 2005 Intel Corporation + * Venkatesh Pallipadi + * - Added _PDC for platforms with Intel CPUs + */ + +#include +#include +#include +#include + +#include +#include + +static void init_intel_pdc(struct acpi_processor *pr, struct cpuinfo_x86 *c) +{ + struct acpi_object_list *obj_list; + union acpi_object *obj; + u32 *buf; + + /* allocate and initialize pdc. It will be used later. */ + obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL); + if (!obj_list) { + printk(KERN_ERR "Memory allocation error\n"); + return; + } + + obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL); + if (!obj) { + printk(KERN_ERR "Memory allocation error\n"); + kfree(obj_list); + return; + } + + buf = kmalloc(12, GFP_KERNEL); + if (!buf) { + printk(KERN_ERR "Memory allocation error\n"); + kfree(obj); + kfree(obj_list); + return; + } + + buf[0] = ACPI_PDC_REVISION_ID; + buf[1] = 1; + buf[2] = ACPI_PDC_EST_CAPABILITY_SMP; + + obj->type = ACPI_TYPE_BUFFER; + obj->buffer.length = 12; + obj->buffer.pointer = (u8 *) buf; + obj_list->count = 1; + obj_list->pointer = obj; + pr->pdc = obj_list; + + return; +} + +/* Initialize _PDC data based on the CPU vendor */ +void arch_acpi_processor_init_pdc(struct acpi_processor *pr) +{ + unsigned int cpu = pr->id; + struct cpuinfo_x86 *c = cpu_data + cpu; + + pr->pdc = NULL; + if (c->x86_vendor == X86_VENDOR_INTEL && cpu_has(c, X86_FEATURE_EST)) + init_intel_pdc(pr, c); + + return; +} + +EXPORT_SYMBOL(arch_acpi_processor_init_pdc); diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 421792562642..66bbda78507a 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -253,31 +253,21 @@ static int acpi_processor_errata(struct acpi_processor *pr) * _PDC is required for a BIOS-OS handshake for most of the newer * ACPI processor features. */ - -int acpi_processor_set_pdc(struct acpi_processor *pr, - struct acpi_object_list *pdc_in) +static int acpi_processor_set_pdc(struct acpi_processor *pr) { + struct acpi_object_list *pdc_in = pr->pdc; acpi_status status = AE_OK; - u32 arg0_buf[3]; - union acpi_object arg0 = { ACPI_TYPE_BUFFER }; - struct acpi_object_list no_object = { 1, &arg0 }; - struct acpi_object_list *pdc; ACPI_FUNCTION_TRACE("acpi_processor_set_pdc"); - arg0.buffer.length = 12; - arg0.buffer.pointer = (u8 *) arg0_buf; - arg0_buf[0] = ACPI_PDC_REVISION_ID; - arg0_buf[1] = 0; - arg0_buf[2] = 0; - - pdc = (pdc_in) ? pdc_in : &no_object; + if (!pdc_in) + return_VALUE(status); - status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL); + status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL); - if ((ACPI_FAILURE(status)) && (pdc_in)) + if (ACPI_FAILURE(status)) ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Error evaluating _PDC, using legacy perf. control...\n")); + "Could not evaluate _PDC, using legacy perf. control...\n")); return_VALUE(status); } @@ -574,6 +564,10 @@ static int acpi_processor_start(struct acpi_device *device) "Error installing device notify handler\n")); } + /* _PDC call should be done before doing anything else (if reqd.). */ + arch_acpi_processor_init_pdc(pr); + acpi_processor_set_pdc(pr); + acpi_processor_power_init(pr, device); if (pr->flags.throttling) { diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 70d8a6ec0920..1915c377bfc6 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -1014,8 +1014,6 @@ int acpi_processor_power_init(struct acpi_processor *pr, } } - acpi_processor_power_init_pdc(&(pr->power), pr->id); - acpi_processor_set_pdc(pr, pr->power.pdc); acpi_processor_get_power_info(pr); /* diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index 22c7bb66c200..532370734c68 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c @@ -315,8 +315,6 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr) if (!pr || !pr->performance || !pr->handle) return_VALUE(-EINVAL); - acpi_processor_set_pdc(pr, pr->performance->pdc); - status = acpi_get_handle(pr->handle, "_PCT", &handle); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, diff --git a/include/acpi/pdc_intel.h b/include/acpi/pdc_intel.h index 91f4a12a99a1..3fa81d55cd0c 100644 --- a/include/acpi/pdc_intel.h +++ b/include/acpi/pdc_intel.h @@ -15,9 +15,7 @@ #define ACPI_PDC_C_C1_FFH (0x0100) #define ACPI_PDC_EST_CAPABILITY_SMP (ACPI_PDC_SMP_C1PT | \ - ACPI_PDC_C_C1_HALT) - -#define ACPI_PDC_EST_CAPABILITY_SMP_MSR (ACPI_PDC_EST_CAPABILITY_SMP | \ + ACPI_PDC_C_C1_HALT | \ ACPI_PDC_P_FFH) #define ACPI_PDC_C_CAPABILITY_SMP (ACPI_PDC_SMP_C2C3 | \ diff --git a/include/acpi/processor.h b/include/acpi/processor.h index 7a00d5089de9..82a9b7d430ec 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h @@ -62,9 +62,6 @@ struct acpi_processor_power { u32 bm_activity; int count; struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER]; - - /* the _PDC objects passed by the driver, if any */ - struct acpi_object_list *pdc; }; /* Performance Management */ @@ -96,8 +93,6 @@ struct acpi_processor_performance { unsigned int state_count; struct acpi_processor_px *states; - /* the _PDC objects passed by the driver, if any */ - struct acpi_object_list *pdc; }; /* Throttling Control */ @@ -151,6 +146,9 @@ struct acpi_processor { struct acpi_processor_performance *performance; struct acpi_processor_throttling throttling; struct acpi_processor_limit limit; + + /* the _PDC objects for this processor, if any */ + struct acpi_object_list *pdc; }; struct acpi_processor_errata { @@ -178,22 +176,12 @@ int acpi_processor_notify_smm(struct module *calling_module); extern struct acpi_processor *processors[NR_CPUS]; extern struct acpi_processor_errata errata; -int acpi_processor_set_pdc(struct acpi_processor *pr, - struct acpi_object_list *pdc_in); +void arch_acpi_processor_init_pdc(struct acpi_processor *pr); -#ifdef ARCH_HAS_POWER_PDC_INIT -void acpi_processor_power_init_pdc(struct acpi_processor_power *pow, - unsigned int cpu); +#ifdef ARCH_HAS_POWER_INIT void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags, unsigned int cpu); #else -static inline void acpi_processor_power_init_pdc(struct acpi_processor_power - *pow, unsigned int cpu) -{ - pow->pdc = NULL; - return; -} - static inline void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags, unsigned int cpu) diff --git a/include/asm-i386/acpi.h b/include/asm-i386/acpi.h index df4ed323aa4d..55059abf9c95 100644 --- a/include/asm-i386/acpi.h +++ b/include/asm-i386/acpi.h @@ -179,7 +179,7 @@ extern void acpi_reserve_bootmem(void); extern u8 x86_acpiid_to_apicid[]; -#define ARCH_HAS_POWER_PDC_INIT 1 +#define ARCH_HAS_POWER_INIT 1 #endif /*__KERNEL__*/ -- cgit v1.2.3 From 50eca3eb89d73d9f0aa070b126c7ee6a616016ab Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Fri, 30 Sep 2005 19:03:00 -0400 Subject: [ACPI] ACPICA 20050930 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 Signed-off-by: Len Brown --- arch/ia64/kernel/acpi-ext.c | 22 +- arch/ia64/pci/pci.c | 8 +- arch/x86_64/kernel/io_apic.c | 10 +- arch/x86_64/kernel/mpparse.c | 8 +- drivers/acpi/acpi_memhotplug.c | 4 +- drivers/acpi/dispatcher/dsutils.c | 12 +- drivers/acpi/ec.c | 4 +- drivers/acpi/events/evgpe.c | 10 +- drivers/acpi/events/evsci.c | 4 +- drivers/acpi/executer/exdump.c | 10 +- drivers/acpi/executer/exnames.c | 4 +- drivers/acpi/executer/exprep.c | 4 +- drivers/acpi/executer/exresop.c | 2 +- drivers/acpi/executer/exutils.c | 6 +- drivers/acpi/glue.c | 8 +- drivers/acpi/hardware/hwacpi.c | 8 +- drivers/acpi/motherboard.c | 30 +- drivers/acpi/namespace/nsaccess.c | 2 +- drivers/acpi/namespace/nsnames.c | 2 +- drivers/acpi/namespace/nsutils.c | 12 +- drivers/acpi/parser/psargs.c | 2 +- drivers/acpi/parser/psxface.c | 142 +++++ drivers/acpi/pci_irq.c | 48 +- drivers/acpi/pci_link.c | 92 +-- drivers/acpi/pci_root.c | 8 +- drivers/acpi/resources/Makefile | 2 +- drivers/acpi/resources/rsaddr.c | 1132 ++++++++++++------------------------- drivers/acpi/resources/rscalc.c | 282 +++------ drivers/acpi/resources/rscreate.c | 59 +- drivers/acpi/resources/rsdump.c | 313 +++++----- drivers/acpi/resources/rsinfo.c | 2 +- drivers/acpi/resources/rsio.c | 451 +++++---------- drivers/acpi/resources/rsirq.c | 494 ++++++---------- drivers/acpi/resources/rslist.c | 290 +++++----- drivers/acpi/resources/rsmemory.c | 472 +++++----------- drivers/acpi/resources/rsmisc.c | 711 ++++++++--------------- drivers/acpi/resources/rsutils.c | 437 +++++++++++++- drivers/acpi/resources/rsxface.c | 14 +- drivers/acpi/tables/tbrsdt.c | 2 +- drivers/acpi/tables/tbxfroot.c | 2 +- drivers/acpi/utilities/utalloc.c | 6 +- drivers/acpi/utilities/utglobal.c | 3 + drivers/acpi/utilities/utmisc.c | 6 +- drivers/char/hpet.c | 26 +- drivers/pnp/pnpacpi/rsparser.c | 364 ++++++------ drivers/serial/8250_acpi.c | 22 +- include/acpi/acconfig.h | 2 +- include/acpi/acdisasm.h | 40 +- include/acpi/acglobal.h | 9 + include/acpi/aclocal.h | 79 ++- include/acpi/acmacros.h | 58 +- include/acpi/acpi_drivers.h | 4 +- include/acpi/acpixf.h | 3 + include/acpi/acresrc.h | 313 ++++++---- include/acpi/actypes.h | 152 ++--- include/acpi/amlresrc.h | 242 ++++---- include/asm-x86_64/mpspec.h | 2 +- include/linux/acpi.h | 2 +- 58 files changed, 2949 insertions(+), 3509 deletions(-) (limited to 'include') diff --git a/arch/ia64/kernel/acpi-ext.c b/arch/ia64/kernel/acpi-ext.c index a146016d7ad7..4a5574ff007b 100644 --- a/arch/ia64/kernel/acpi-ext.c +++ b/arch/ia64/kernel/acpi-ext.c @@ -33,33 +33,33 @@ 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; + u32 byte_length; - if (resource->type != ACPI_RSTYPE_VENDOR) + if (resource->type != ACPI_RESOURCE_TYPE_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 = (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; - length = vendor->length - sizeof(struct acpi_vendor_descriptor); - info->data = acpi_os_allocate(length); + 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->reserved + sizeof(struct acpi_vendor_descriptor), - length); - info->length = length; + 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 * length) + u8 ** data, u32 * byte_length) { struct acpi_vendor_info info; @@ -72,7 +72,7 @@ acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor * id, return AE_NOT_FOUND; *data = info.data; - *length = info.length; + *byte_length = info.length; return AE_OK; } diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 20d76fae24e8..25f923d050e3 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c @@ -193,12 +193,12 @@ add_io_space (struct pci_root_info *info, struct acpi_resource_address64 *addr) goto free_resource; } - min = addr->min_address_range; + min = addr->minimum; max = min + addr->address_length - 1; if (addr->attribute.io.translation_attribute == ACPI_SPARSE_TRANSLATION) sparse = 1; - space_nr = new_space(addr->address_translation_offset, sparse); + space_nr = new_space(addr->translation_offset, sparse); if (space_nr == ~0) goto free_name; @@ -285,7 +285,7 @@ static __devinit acpi_status add_window(struct acpi_resource *res, void *data) if (addr.resource_type == ACPI_MEMORY_RANGE) { flags = IORESOURCE_MEM; root = &iomem_resource; - offset = addr.address_translation_offset; + offset = addr.translation_offset; } else if (addr.resource_type == ACPI_IO_RANGE) { flags = IORESOURCE_IO; root = &ioport_resource; @@ -298,7 +298,7 @@ static __devinit acpi_status add_window(struct acpi_resource *res, void *data) window = &info->controller->window[info->controller->windows++]; window->resource.name = info->name; window->resource.flags = flags; - window->resource.start = addr.min_address_range + offset; + window->resource.start = addr.minimum + offset; window->resource.end = window->resource.start + addr.address_length - 1; window->resource.child = NULL; window->offset = offset; diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c index 97154ab058b4..619767d3ea2b 100644 --- a/arch/x86_64/kernel/io_apic.c +++ b/arch/x86_64/kernel/io_apic.c @@ -1956,7 +1956,7 @@ int __init io_apic_get_redir_entries (int ioapic) } -int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low) +int io_apic_set_pci_routing (int ioapic, int pin, int irq, int triggering, int polarity) { struct IO_APIC_route_entry entry; unsigned long flags; @@ -1978,8 +1978,8 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a entry.delivery_mode = INT_DELIVERY_MODE; entry.dest_mode = INT_DEST_MODE; entry.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS); - entry.trigger = edge_level; - entry.polarity = active_high_low; + entry.trigger = triggering; + entry.polarity = polarity; entry.mask = 1; /* Disabled (masked) */ irq = gsi_irq_sharing(irq); @@ -1994,9 +1994,9 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a apic_printk(APIC_VERBOSE,KERN_DEBUG "IOAPIC[%d]: Set PCI routing entry (%d-%d -> 0x%x -> " "IRQ %d Mode:%i Active:%i)\n", ioapic, mp_ioapics[ioapic].mpc_apicid, pin, entry.vector, irq, - edge_level, active_high_low); + triggering, polarity); - ioapic_register_intr(irq, entry.vector, edge_level); + ioapic_register_intr(irq, entry.vector, triggering); if (!ioapic && (irq < 16)) disable_8259A_irq(irq); diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c index 1105250bf02c..ba817e7454b2 100644 --- a/arch/x86_64/kernel/mpparse.c +++ b/arch/x86_64/kernel/mpparse.c @@ -915,7 +915,7 @@ void __init mp_config_acpi_legacy_irqs (void) #define MAX_GSI_NUM 4096 -int mp_register_gsi(u32 gsi, int edge_level, int active_high_low) +int mp_register_gsi(u32 gsi, int triggering, int polarity) { int ioapic = -1; int ioapic_pin = 0; @@ -964,7 +964,7 @@ int mp_register_gsi(u32 gsi, int edge_level, int active_high_low) mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<read_write_attribute = address64.attribute.memory.read_write_attribute; - mem_device->start_addr = address64.min_address_range; - mem_device->end_addr = address64.max_address_range; + mem_device->start_addr = address64.minimum; + mem_device->end_addr = address64.maximum; } } diff --git a/drivers/acpi/dispatcher/dsutils.c b/drivers/acpi/dispatcher/dsutils.c index 83ae1c1aa286..2cc53da5c0bd 100644 --- a/drivers/acpi/dispatcher/dsutils.c +++ b/drivers/acpi/dispatcher/dsutils.c @@ -177,7 +177,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, if (!op) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n")); - return_VALUE(TRUE); + return_UINT8(TRUE); } /* @@ -208,7 +208,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, "At Method level, result of [%s] not used\n", acpi_ps_get_opcode_name(op->common. aml_opcode))); - return_VALUE(FALSE); + return_UINT8(FALSE); } /* Get info on the parent. The root_op is AML_SCOPE */ @@ -218,7 +218,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, if (parent_info->class == AML_CLASS_UNKNOWN) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown parent opcode. Op=%p\n", op)); - return_VALUE(FALSE); + return_UINT8(FALSE); } /* @@ -304,7 +304,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, acpi_ps_get_opcode_name(op->common.parent->common. aml_opcode), op)); - return_VALUE(TRUE); + return_UINT8(TRUE); result_not_used: ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, @@ -313,7 +313,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, acpi_ps_get_opcode_name(op->common.parent->common. aml_opcode), op)); - return_VALUE(FALSE); + return_UINT8(FALSE); } /******************************************************************************* @@ -616,7 +616,7 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state, if (op_info->flags & AML_HAS_RETVAL) { ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, - "Argument previously created, already stacked \n")); + "Argument previously created, already stacked\n")); ACPI_DEBUGGER_EXEC(acpi_db_display_argument_object (walk_state-> diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index c33bfba5df8f..0ecbfa5db1ba 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -1151,7 +1151,7 @@ acpi_ec_io_ports(struct acpi_resource *resource, void *context) union acpi_ec *ec = (union acpi_ec *)context; struct acpi_generic_address *addr; - if (resource->type != ACPI_RSTYPE_IO) { + if (resource->type != ACPI_RESOURCE_TYPE_IO) { return AE_OK; } @@ -1171,7 +1171,7 @@ acpi_ec_io_ports(struct acpi_resource *resource, void *context) addr->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO; addr->register_bit_width = 8; addr->register_bit_offset = 0; - addr->address = resource->data.io.min_base_address; + addr->address = resource->data.io.minimum; return AE_OK; } diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c index b2f232df13d8..f51c3b16c608 100644 --- a/drivers/acpi/events/evgpe.c +++ b/drivers/acpi/events/evgpe.c @@ -600,7 +600,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) status = acpi_hw_clear_gpe(gpe_event_info); if (ACPI_FAILURE(status)) { ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); - return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); + return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); } } @@ -638,7 +638,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) status = acpi_hw_clear_gpe(gpe_event_info); if (ACPI_FAILURE(status)) { ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); - return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); + return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); } } break; @@ -652,7 +652,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) status = acpi_ev_disable_gpe(gpe_event_info); if (ACPI_FAILURE(status)) { ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number)); - return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); + return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); } /* @@ -680,12 +680,12 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) status = acpi_ev_disable_gpe(gpe_event_info); if (ACPI_FAILURE(status)) { ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number)); - return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); + return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); } break; } - return_VALUE(ACPI_INTERRUPT_HANDLED); + return_UINT32(ACPI_INTERRUPT_HANDLED); } #ifdef ACPI_GPE_NOTIFY_CHECK diff --git a/drivers/acpi/events/evsci.c b/drivers/acpi/events/evsci.c index 141835977002..e2c0b48a7e9f 100644 --- a/drivers/acpi/events/evsci.c +++ b/drivers/acpi/events/evsci.c @@ -88,7 +88,7 @@ static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context) */ interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); - return_VALUE(interrupt_handled); + return_UINT32(interrupt_handled); } /******************************************************************************* @@ -121,7 +121,7 @@ u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context) */ interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); - return_VALUE(interrupt_handled); + return_UINT32(interrupt_handled); } /****************************************************************************** diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index bc2fa996047e..4477a62fed56 100644 --- a/drivers/acpi/executer/exdump.c +++ b/drivers/acpi/executer/exdump.c @@ -214,7 +214,7 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) case ACPI_TYPE_BUFFER: - acpi_os_printf("Buffer len %X @ %p \n", + acpi_os_printf("Buffer len %X @ %p\n", obj_desc->buffer.length, obj_desc->buffer.pointer); @@ -320,17 +320,17 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) case ACPI_TYPE_BUFFER_FIELD: - acpi_os_printf("buffer_field: %X bits at byte %X bit %X of \n", + acpi_os_printf("buffer_field: %X bits at byte %X bit %X of\n", obj_desc->buffer_field.bit_length, obj_desc->buffer_field.base_byte_offset, obj_desc->buffer_field.start_field_bit_offset); if (!obj_desc->buffer_field.buffer_obj) { - ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL* \n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL*\n")); } else if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj) != ACPI_TYPE_BUFFER) { - acpi_os_printf("*not a Buffer* \n"); + acpi_os_printf("*not a Buffer*\n"); } else { acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj, depth + 1); @@ -618,7 +618,7 @@ acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index) case ACPI_TYPE_PACKAGE: - acpi_os_printf("[Package] Contains %d Elements: \n", + acpi_os_printf("[Package] Contains %d Elements:\n", obj_desc->package.count); for (i = 0; i < obj_desc->package.count; i++) { diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c index 239d8473e9a5..dff41121a304 100644 --- a/drivers/acpi/executer/exnames.c +++ b/drivers/acpi/executer/exnames.c @@ -191,10 +191,10 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string) if (name_string) { ACPI_STRCAT(name_string, char_buf); ACPI_DEBUG_PRINT((ACPI_DB_NAMES, - "Appended to - %s \n", name_string)); + "Appended to - %s\n", name_string)); } else { ACPI_DEBUG_PRINT((ACPI_DB_NAMES, - "No Name string - %s \n", char_buf)); + "No Name string - %s\n", char_buf)); } } else if (index == 0) { /* diff --git a/drivers/acpi/executer/exprep.c b/drivers/acpi/executer/exprep.c index 7476c363e407..88ccbf3b29d0 100644 --- a/drivers/acpi/executer/exprep.c +++ b/drivers/acpi/executer/exprep.c @@ -276,7 +276,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc, ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown field access type %X\n", access)); - return_VALUE(0); + return_UINT32(0); } if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_BUFFER_FIELD) { @@ -289,7 +289,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc, } *return_byte_alignment = byte_alignment; - return_VALUE(bit_length); + return_UINT32(bit_length); } /******************************************************************************* diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c index ff064e79ab90..b04e4a3707a1 100644 --- a/drivers/acpi/executer/exresop.c +++ b/drivers/acpi/executer/exresop.c @@ -157,7 +157,7 @@ acpi_ex_resolve_operands(u16 opcode, } ACPI_DEBUG_PRINT((ACPI_DB_EXEC, - "Opcode %X [%s] required_operand_types=%8.8X \n", + "Opcode %X [%s] required_operand_types=%8.8X\n", opcode, op_info->name, arg_types)); /* diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c index 1ee79d8c8f88..9f4e547d7734 100644 --- a/drivers/acpi/executer/exutils.c +++ b/drivers/acpi/executer/exutils.c @@ -206,7 +206,7 @@ u8 acpi_ex_acquire_global_lock(u32 field_flags) } } - return_VALUE(locked); + return_UINT8(locked); } /******************************************************************************* @@ -268,7 +268,7 @@ static u32 acpi_ex_digits_needed(acpi_integer value, u32 base) /* acpi_integer is unsigned, so we don't worry about a '-' prefix */ if (value == 0) { - return_VALUE(1); + return_UINT32(1); } current_value = value; @@ -282,7 +282,7 @@ static u32 acpi_ex_digits_needed(acpi_integer value, u32 base) num_digits++; } - return_VALUE(num_digits); + return_UINT32(num_digits); } /******************************************************************************* diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index fcb881db5b0b..8daef57b994c 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -99,15 +99,15 @@ do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) unsigned long *busnr = (unsigned long *)data; struct acpi_resource_address64 address; - if (resource->type != ACPI_RSTYPE_ADDRESS16 && - resource->type != ACPI_RSTYPE_ADDRESS32 && - resource->type != ACPI_RSTYPE_ADDRESS64) + if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 && + resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 && + resource->type != ACPI_RESOURCE_TYPE_ADDRESS64) return AE_OK; acpi_resource_to_address64(resource, &address); if ((address.address_length > 0) && (address.resource_type == ACPI_BUS_NUMBER_RANGE)) - *busnr = address.min_address_range; + *busnr = address.minimum; return AE_OK; } diff --git a/drivers/acpi/hardware/hwacpi.c b/drivers/acpi/hardware/hwacpi.c index 1bb3463d7040..20a335cc9bea 100644 --- a/drivers/acpi/hardware/hwacpi.c +++ b/drivers/acpi/hardware/hwacpi.c @@ -204,18 +204,18 @@ u32 acpi_hw_get_mode(void) * system does not support mode transition. */ if (!acpi_gbl_FADT->smi_cmd) { - return_VALUE(ACPI_SYS_MODE_ACPI); + return_UINT32(ACPI_SYS_MODE_ACPI); } status = acpi_get_register(ACPI_BITREG_SCI_ENABLE, &value, ACPI_MTX_LOCK); if (ACPI_FAILURE(status)) { - return_VALUE(ACPI_SYS_MODE_LEGACY); + return_UINT32(ACPI_SYS_MODE_LEGACY); } if (value) { - return_VALUE(ACPI_SYS_MODE_ACPI); + return_UINT32(ACPI_SYS_MODE_ACPI); } else { - return_VALUE(ACPI_SYS_MODE_LEGACY); + return_UINT32(ACPI_SYS_MODE_LEGACY); } } diff --git a/drivers/acpi/motherboard.c b/drivers/acpi/motherboard.c index 85c1fb5c9a5a..468244147ec1 100644 --- a/drivers/acpi/motherboard.c +++ b/drivers/acpi/motherboard.c @@ -54,36 +54,36 @@ static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data) ACPI_FUNCTION_TRACE("acpi_reserve_io_ranges"); - if (res->type == ACPI_RSTYPE_IO) { + if (res->type == ACPI_RESOURCE_TYPE_IO) { struct acpi_resource_io *io_res = &res->data.io; - if (io_res->min_base_address != io_res->max_base_address) + if (io_res->minimum != io_res->maximum) return_VALUE(AE_OK); if (IS_RESERVED_ADDR - (io_res->min_base_address, io_res->range_length)) { + (io_res->minimum, io_res->address_length)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Motherboard resources 0x%08x - 0x%08x\n", - io_res->min_base_address, - io_res->min_base_address + - io_res->range_length)); + io_res->minimum, + io_res->minimum + + io_res->address_length)); requested_res = - request_region(io_res->min_base_address, - io_res->range_length, "motherboard"); + request_region(io_res->minimum, + io_res->address_length, "motherboard"); } - } else if (res->type == ACPI_RSTYPE_FIXED_IO) { + } else if (res->type == ACPI_RESOURCE_TYPE_FIXED_IO) { struct acpi_resource_fixed_io *fixed_io_res = &res->data.fixed_io; if (IS_RESERVED_ADDR - (fixed_io_res->base_address, fixed_io_res->range_length)) { + (fixed_io_res->address, fixed_io_res->address_length)) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Motherboard resources 0x%08x - 0x%08x\n", - fixed_io_res->base_address, - fixed_io_res->base_address + - fixed_io_res->range_length)); + fixed_io_res->address, + fixed_io_res->address + + fixed_io_res->address_length)); requested_res = - request_region(fixed_io_res->base_address, - fixed_io_res->range_length, + request_region(fixed_io_res->address, + fixed_io_res->address_length, "motherboard"); } } else { diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c index edfbe34600f5..6923059ba3c7 100644 --- a/drivers/acpi/namespace/nsaccess.c +++ b/drivers/acpi/namespace/nsaccess.c @@ -498,7 +498,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, path++; ACPI_DEBUG_PRINT((ACPI_DB_NAMES, - "Multi Pathname (%d Segments, Flags=%X) \n", + "Multi Pathname (%d Segments, Flags=%X)\n", num_segments, flags)); break; diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c index d5e8dea61c27..5400728eb791 100644 --- a/drivers/acpi/namespace/nsnames.c +++ b/drivers/acpi/namespace/nsnames.c @@ -241,7 +241,7 @@ acpi_ns_handle_to_pathname(acpi_handle target_handle, acpi_ns_build_external_path(node, required_size, buffer->pointer); - ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X] \n", + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X]\n", (char *)buffer->pointer, (u32) required_size)); return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c index ebec036423c9..549075fb9f88 100644 --- a/drivers/acpi/namespace/nsutils.c +++ b/drivers/acpi/namespace/nsutils.c @@ -249,10 +249,10 @@ acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node) if (!node) { ACPI_REPORT_WARNING(("ns_get_type: Null Node input pointer\n")); - return_VALUE(ACPI_TYPE_ANY); + return_UINT32(ACPI_TYPE_ANY); } - return_VALUE((acpi_object_type) node->type); + return_UINT32((acpi_object_type) node->type); } /******************************************************************************* @@ -276,10 +276,10 @@ u32 acpi_ns_local(acpi_object_type type) /* Type code out of range */ ACPI_REPORT_WARNING(("ns_local: Invalid Object Type\n")); - return_VALUE(ACPI_NS_NORMAL); + return_UINT32(ACPI_NS_NORMAL); } - return_VALUE((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); + return_UINT32((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); } /******************************************************************************* @@ -805,10 +805,10 @@ u32 acpi_ns_opens_scope(acpi_object_type type) ACPI_REPORT_WARNING(("ns_opens_scope: Invalid Object Type %X\n", type)); - return_VALUE(ACPI_NS_NORMAL); + return_UINT32(ACPI_NS_NORMAL); } - return_VALUE(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE); + return_UINT32(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE); } /******************************************************************************* diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c index 5858188f94a6..562d0f822ab1 100644 --- a/drivers/acpi/parser/psargs.c +++ b/drivers/acpi/parser/psargs.c @@ -116,7 +116,7 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) break; } - return_VALUE(length); + return_UINT32(length); } /******************************************************************************* diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c index 4dcbd443160e..4c426f4c6af6 100644 --- a/drivers/acpi/parser/psxface.c +++ b/drivers/acpi/parser/psxface.c @@ -50,11 +50,145 @@ ACPI_MODULE_NAME("psxface") /* Local Prototypes */ +static void acpi_ps_start_trace(struct acpi_parameter_info *info); + +static void acpi_ps_stop_trace(struct acpi_parameter_info *info); + static acpi_status acpi_ps_execute_pass(struct acpi_parameter_info *info); static void acpi_ps_update_parameter_list(struct acpi_parameter_info *info, u16 action); +/******************************************************************************* + * + * FUNCTION: acpi_debug_trace + * + * PARAMETERS: method_name - Valid ACPI name string + * debug_level - Optional level mask. 0 to use default + * debug_layer - Optional layer mask. 0 to use default + * Flags - bit 1: one shot(1) or persistent(0) + * + * RETURN: Status + * + * DESCRIPTION: External interface to enable debug tracing during control + * method execution + * + ******************************************************************************/ + +acpi_status +acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags) +{ + acpi_status status; + + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return (status); + } + + /* TBDs: Validate name, allow full path or just nameseg */ + + acpi_gbl_trace_method_name = *(u32 *) name; + acpi_gbl_trace_flags = flags; + + if (debug_level) { + acpi_gbl_trace_dbg_level = debug_level; + } + if (debug_layer) { + acpi_gbl_trace_dbg_layer = debug_layer; + } + + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return (AE_OK); +} + +/******************************************************************************* + * + * FUNCTION: acpi_ps_start_trace + * + * PARAMETERS: Info - Method info struct + * + * RETURN: None + * + * DESCRIPTION: Start control method execution trace + * + ******************************************************************************/ + +static void acpi_ps_start_trace(struct acpi_parameter_info *info) +{ + acpi_status status; + + ACPI_FUNCTION_ENTRY(); + + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return; + } + + if ((!acpi_gbl_trace_method_name) || + (acpi_gbl_trace_method_name != info->node->name.integer)) { + goto exit; + } + + acpi_gbl_original_dbg_level = acpi_dbg_level; + acpi_gbl_original_dbg_layer = acpi_dbg_layer; + + acpi_dbg_level = 0x00FFFFFF; + acpi_dbg_layer = ACPI_UINT32_MAX; + + if (acpi_gbl_trace_dbg_level) { + acpi_dbg_level = acpi_gbl_trace_dbg_level; + } + if (acpi_gbl_trace_dbg_layer) { + acpi_dbg_layer = acpi_gbl_trace_dbg_layer; + } + + exit: + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); +} + +/******************************************************************************* + * + * FUNCTION: acpi_ps_stop_trace + * + * PARAMETERS: Info - Method info struct + * + * RETURN: None + * + * DESCRIPTION: Stop control method execution trace + * + ******************************************************************************/ + +static void acpi_ps_stop_trace(struct acpi_parameter_info *info) +{ + acpi_status status; + + ACPI_FUNCTION_ENTRY(); + + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return; + } + + if ((!acpi_gbl_trace_method_name) || + (acpi_gbl_trace_method_name != info->node->name.integer)) { + goto exit; + } + + /* Disable further tracing if type is one-shot */ + + if (acpi_gbl_trace_flags & 1) { + acpi_gbl_trace_method_name = 0; + acpi_gbl_trace_dbg_level = 0; + acpi_gbl_trace_dbg_layer = 0; + } + + acpi_dbg_level = acpi_gbl_original_dbg_level; + acpi_dbg_layer = acpi_gbl_original_dbg_layer; + + exit: + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); +} + /******************************************************************************* * * FUNCTION: acpi_ps_execute_method @@ -104,6 +238,10 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info) */ acpi_ps_update_parameter_list(info, REF_INCREMENT); + /* Begin tracing if requested */ + + acpi_ps_start_trace(info); + /* * 1) Perform the first pass parse of the method to enter any * named objects that it creates into the namespace @@ -129,6 +267,10 @@ acpi_status acpi_ps_execute_method(struct acpi_parameter_info *info) status = acpi_ps_execute_pass(info); cleanup: + /* End optional tracing */ + + acpi_ps_stop_trace(info); + /* Take away the extra reference that we gave the parameters above */ acpi_ps_update_parameter_list(info, REF_DECREMENT); diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index 09567c2edcfb..726dda1fce1c 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c @@ -258,7 +258,7 @@ typedef int (*irq_lookup_func) (struct acpi_prt_entry *, int *, int *, char **); static int acpi_pci_allocate_irq(struct acpi_prt_entry *entry, - int *edge_level, int *active_high_low, char **link) + int *triggering, int *polarity, char **link) { int irq; @@ -266,8 +266,8 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry, if (entry->link.handle) { irq = acpi_pci_link_allocate_irq(entry->link.handle, - entry->link.index, edge_level, - active_high_low, link); + entry->link.index, triggering, + polarity, link); if (irq < 0) { ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ link routing entry\n")); @@ -275,8 +275,8 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry, } } else { irq = entry->link.index; - *edge_level = ACPI_LEVEL_SENSITIVE; - *active_high_low = ACPI_ACTIVE_LOW; + *triggering = ACPI_LEVEL_SENSITIVE; + *polarity = ACPI_ACTIVE_LOW; } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq)); @@ -285,7 +285,7 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry, static int acpi_pci_free_irq(struct acpi_prt_entry *entry, - int *edge_level, int *active_high_low, char **link) + int *triggering, int *polarity, char **link) { int irq; @@ -307,8 +307,8 @@ static int acpi_pci_irq_lookup(struct pci_bus *bus, int device, int pin, - int *edge_level, - int *active_high_low, char **link, irq_lookup_func func) + int *triggering, + int *polarity, char **link, irq_lookup_func func) { struct acpi_prt_entry *entry = NULL; int segment = pci_domain_nr(bus); @@ -327,7 +327,7 @@ acpi_pci_irq_lookup(struct pci_bus *bus, return_VALUE(-1); } - ret = func(entry, edge_level, active_high_low, link); + ret = func(entry, triggering, polarity, link); return_VALUE(ret); } @@ -339,8 +339,8 @@ acpi_pci_irq_lookup(struct pci_bus *bus, static int acpi_pci_irq_derive(struct pci_dev *dev, int pin, - int *edge_level, - int *active_high_low, char **link, irq_lookup_func func) + int *triggering, + int *polarity, char **link, irq_lookup_func func) { struct pci_dev *bridge = dev; int irq = -1; @@ -375,7 +375,7 @@ acpi_pci_irq_derive(struct pci_dev *dev, } irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn), - pin, edge_level, active_high_low, + pin, triggering, polarity, link, func); } @@ -402,8 +402,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev) { int irq = 0; u8 pin = 0; - int edge_level = ACPI_LEVEL_SENSITIVE; - int active_high_low = ACPI_ACTIVE_LOW; + int triggering = ACPI_LEVEL_SENSITIVE; + int polarity = ACPI_ACTIVE_LOW; char *link = NULL; int rc; @@ -432,7 +432,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev) * values override any BIOS-assigned IRQs set during boot. */ irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, - &edge_level, &active_high_low, &link, + &triggering, &polarity, &link, acpi_pci_allocate_irq); /* @@ -440,8 +440,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev) * device's parent bridge. */ if (irq < 0) - irq = acpi_pci_irq_derive(dev, pin, &edge_level, - &active_high_low, &link, + irq = acpi_pci_irq_derive(dev, pin, &triggering, + &polarity, &link, acpi_pci_allocate_irq); /* @@ -463,7 +463,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev) } } - rc = acpi_register_gsi(irq, edge_level, active_high_low); + rc = acpi_register_gsi(irq, triggering, polarity); if (rc < 0) { printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed " "to register GSI\n", pci_name(dev), ('A' + pin)); @@ -478,8 +478,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev) printk("Link [%s] -> ", link); printk("GSI %u (%s, %s) -> IRQ %d\n", irq, - (edge_level == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", - (active_high_low == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); + (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", + (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); return_VALUE(0); } @@ -495,8 +495,8 @@ void acpi_pci_irq_disable(struct pci_dev *dev) { int gsi = 0; u8 pin = 0; - int edge_level = ACPI_LEVEL_SENSITIVE; - int active_high_low = ACPI_ACTIVE_LOW; + int triggering = ACPI_LEVEL_SENSITIVE; + int polarity = ACPI_ACTIVE_LOW; ACPI_FUNCTION_TRACE("acpi_pci_irq_disable"); @@ -512,7 +512,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev) * First we check the PCI IRQ routing table (PRT) for an IRQ. */ gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, - &edge_level, &active_high_low, NULL, + &triggering, &polarity, NULL, acpi_pci_free_irq); /* * If no PRT entry was found, we'll try to derive an IRQ from the @@ -520,7 +520,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev) */ if (gsi < 0) gsi = acpi_pci_irq_derive(dev, pin, - &edge_level, &active_high_low, NULL, + &triggering, &polarity, NULL, acpi_pci_free_irq); if (gsi < 0) return_VOID; diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index d8956c0bf143..492170373494 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -70,8 +70,8 @@ static struct acpi_driver acpi_pci_link_driver = { */ struct acpi_pci_link_irq { u8 active; /* Current IRQ */ - u8 edge_level; /* All IRQs */ - u8 active_high_low; /* All IRQs */ + u8 triggering; /* All IRQs */ + u8 polarity; /* All IRQs */ u8 resource_type; u8 possible_count; u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; @@ -109,18 +109,18 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context) ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible"); switch (resource->type) { - case ACPI_RSTYPE_START_DPF: + case ACPI_RESOURCE_TYPE_START_DEPENDENT: return_ACPI_STATUS(AE_OK); - case ACPI_RSTYPE_IRQ: + case ACPI_RESOURCE_TYPE_IRQ: { struct acpi_resource_irq *p = &resource->data.irq; - if (!p || !p->number_of_interrupts) { + if (!p || !p->interrupt_count) { ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Blank IRQ resource\n")); return_ACPI_STATUS(AE_OK); } for (i = 0; - (i < p->number_of_interrupts + (i < p->interrupt_count && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { if (!p->interrupts[i]) { ACPI_DEBUG_PRINT((ACPI_DB_WARN, @@ -131,22 +131,22 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context) link->irq.possible[i] = p->interrupts[i]; link->irq.possible_count++; } - link->irq.edge_level = p->edge_level; - link->irq.active_high_low = p->active_high_low; - link->irq.resource_type = ACPI_RSTYPE_IRQ; + link->irq.triggering = p->triggering; + link->irq.polarity = p->polarity; + link->irq.resource_type = ACPI_RESOURCE_TYPE_IRQ; break; } - case ACPI_RSTYPE_EXT_IRQ: + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: { - struct acpi_resource_ext_irq *p = + struct acpi_resource_extended_irq *p = &resource->data.extended_irq; - if (!p || !p->number_of_interrupts) { + if (!p || !p->interrupt_count) { ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Blank EXT IRQ resource\n")); return_ACPI_STATUS(AE_OK); } for (i = 0; - (i < p->number_of_interrupts + (i < p->interrupt_count && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { if (!p->interrupts[i]) { ACPI_DEBUG_PRINT((ACPI_DB_WARN, @@ -157,9 +157,9 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context) link->irq.possible[i] = p->interrupts[i]; link->irq.possible_count++; } - link->irq.edge_level = p->edge_level; - link->irq.active_high_low = p->active_high_low; - link->irq.resource_type = ACPI_RSTYPE_EXT_IRQ; + link->irq.triggering = p->triggering; + link->irq.polarity = p->polarity; + link->irq.resource_type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; break; } default: @@ -202,10 +202,10 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context) ACPI_FUNCTION_TRACE("acpi_pci_link_check_current"); switch (resource->type) { - case ACPI_RSTYPE_IRQ: + case ACPI_RESOURCE_TYPE_IRQ: { struct acpi_resource_irq *p = &resource->data.irq; - if (!p || !p->number_of_interrupts) { + if (!p || !p->interrupt_count) { /* * IRQ descriptors may have no IRQ# bits set, * particularly those those w/ _STA disabled @@ -217,11 +217,11 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context) *irq = p->interrupts[0]; break; } - case ACPI_RSTYPE_EXT_IRQ: + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: { - struct acpi_resource_ext_irq *p = + struct acpi_resource_extended_irq *p = &resource->data.extended_irq; - if (!p || !p->number_of_interrupts) { + if (!p || !p->interrupt_count) { /* * extended IRQ descriptors must * return at least 1 IRQ @@ -325,36 +325,36 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) buffer.pointer = resource; switch (link->irq.resource_type) { - case ACPI_RSTYPE_IRQ: - resource->res.type = ACPI_RSTYPE_IRQ; + case ACPI_RESOURCE_TYPE_IRQ: + resource->res.type = ACPI_RESOURCE_TYPE_IRQ; resource->res.length = sizeof(struct acpi_resource); - resource->res.data.irq.edge_level = link->irq.edge_level; - resource->res.data.irq.active_high_low = - link->irq.active_high_low; - if (link->irq.edge_level == ACPI_EDGE_SENSITIVE) - resource->res.data.irq.shared_exclusive = + resource->res.data.irq.triggering = link->irq.triggering; + resource->res.data.irq.polarity = + link->irq.polarity; + if (link->irq.triggering == ACPI_EDGE_SENSITIVE) + resource->res.data.irq.sharable = ACPI_EXCLUSIVE; else - resource->res.data.irq.shared_exclusive = ACPI_SHARED; - resource->res.data.irq.number_of_interrupts = 1; + resource->res.data.irq.sharable = ACPI_SHARED; + resource->res.data.irq.interrupt_count = 1; resource->res.data.irq.interrupts[0] = irq; break; - case ACPI_RSTYPE_EXT_IRQ: - resource->res.type = ACPI_RSTYPE_EXT_IRQ; + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + resource->res.type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; resource->res.length = sizeof(struct acpi_resource); resource->res.data.extended_irq.producer_consumer = ACPI_CONSUMER; - resource->res.data.extended_irq.edge_level = - link->irq.edge_level; - resource->res.data.extended_irq.active_high_low = - link->irq.active_high_low; - if (link->irq.edge_level == ACPI_EDGE_SENSITIVE) - resource->res.data.irq.shared_exclusive = + resource->res.data.extended_irq.triggering = + link->irq.triggering; + resource->res.data.extended_irq.polarity = + link->irq.polarity; + if (link->irq.triggering == ACPI_EDGE_SENSITIVE) + resource->res.data.irq.sharable = ACPI_EXCLUSIVE; else - resource->res.data.irq.shared_exclusive = ACPI_SHARED; - resource->res.data.extended_irq.number_of_interrupts = 1; + resource->res.data.irq.sharable = ACPI_SHARED; + resource->res.data.extended_irq.interrupt_count = 1; resource->res.data.extended_irq.interrupts[0] = irq; /* ignore resource_source, it's optional */ break; @@ -364,7 +364,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) goto end; } - resource->end.type = ACPI_RSTYPE_END_TAG; + resource->end.type = ACPI_RESOURCE_TYPE_END_TAG; /* Attempt to set the resource */ status = acpi_set_current_resources(link->handle, &buffer); @@ -613,7 +613,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link) int acpi_pci_link_allocate_irq(acpi_handle handle, int index, - int *edge_level, int *active_high_low, char **name) + int *triggering, int *polarity, char **name) { int result = 0; struct acpi_device *device = NULL; @@ -653,10 +653,10 @@ acpi_pci_link_allocate_irq(acpi_handle handle, link->refcnt++; up(&acpi_link_lock); - if (edge_level) - *edge_level = link->irq.edge_level; - if (active_high_low) - *active_high_low = link->irq.active_high_low; + if (triggering) + *triggering = link->irq.triggering; + if (polarity) + *polarity = link->irq.polarity; if (name) *name = acpi_device_bid(link->device); ACPI_DEBUG_PRINT((ACPI_DB_INFO, diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 5d6bc815fe72..4c313eab6313 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -122,15 +122,15 @@ get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) int *busnr = (int *)data; struct acpi_resource_address64 address; - if (resource->type != ACPI_RSTYPE_ADDRESS16 && - resource->type != ACPI_RSTYPE_ADDRESS32 && - resource->type != ACPI_RSTYPE_ADDRESS64) + if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 && + resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 && + resource->type != ACPI_RESOURCE_TYPE_ADDRESS64) return AE_OK; acpi_resource_to_address64(resource, &address); if ((address.address_length > 0) && (address.resource_type == ACPI_BUS_NUMBER_RANGE)) - *busnr = address.min_address_range; + *busnr = address.minimum; return AE_OK; } diff --git a/drivers/acpi/resources/Makefile b/drivers/acpi/resources/Makefile index 2130b74170c3..8de4f69dfa09 100644 --- a/drivers/acpi/resources/Makefile +++ b/drivers/acpi/resources/Makefile @@ -2,7 +2,7 @@ # Makefile for all Linux ACPI interpreter subdirectories # -obj-y := rsaddr.o rscreate.o rsio.o rslist.o rsmisc.o rsxface.o \ +obj-y := rsaddr.o rscreate.o rsinfo.o rsio.o rslist.o rsmisc.o rsxface.o \ rscalc.o rsirq.o rsmemory.o rsutils.o obj-$(ACPI_FUTURE_USAGE) += rsdump.o diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c index 798778261fb9..6f48ebf3304e 100644 --- a/drivers/acpi/resources/rsaddr.c +++ b/drivers/acpi/resources/rsaddr.c @@ -58,12 +58,20 @@ acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags); static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource); +static void +acpi_rs_set_address_common(union aml_resource *aml, + struct acpi_resource *resource); + +static u8 +acpi_rs_get_address_common(struct acpi_resource *resource, + union aml_resource *aml); + /******************************************************************************* * * FUNCTION: acpi_rs_decode_general_flags * * PARAMETERS: Resource - Address resource data struct - * Flags - Actual flag byte + * Flags - Raw AML flag byte * * RETURN: Decoded flag bits in resource struct * @@ -107,27 +115,19 @@ acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags) static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource) { - u8 flags; - ACPI_FUNCTION_ENTRY(); - /* Producer / Consumer - flag bit[0] */ - - flags = (u8) (resource->address.producer_consumer & 0x01); - - /* Decode (_DEC) - flag bit[1] */ - - flags |= (u8) ((resource->address.decode & 0x01) << 1); - - /* Min Address Fixed (_MIF) - flag bit[2] */ - - flags |= (u8) ((resource->address.min_address_fixed & 0x01) << 2); - - /* Max Address Fixed (_MAF) - flag bit[3] */ - - flags |= (u8) ((resource->address.max_address_fixed & 0x01) << 3); - - return (flags); + return ((u8) + + /* Producer / Consumer - flag bit[0] */ + ((resource->address.producer_consumer & 0x01) | + /* Decode (_DEC) - flag bit[1] */ + ((resource->address.decode & 0x01) << 1) | + /* Min Address Fixed (_MIF) - flag bit[2] */ + ((resource->address.min_address_fixed & 0x01) << 2) | + /* Max Address Fixed (_MAF) - flag bit[3] */ + ((resource->address.max_address_fixed & 0x01) << 3)) + ); } /******************************************************************************* @@ -135,7 +135,7 @@ static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource) * FUNCTION: acpi_rs_decode_specific_flags * * PARAMETERS: Resource - Address resource data struct - * Flags - Actual flag byte + * Flags - Raw AML flag byte * * RETURN: Decoded flag bits in attribute struct * @@ -189,921 +189,541 @@ acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags) static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource) { - u8 flags = 0; - ACPI_FUNCTION_ENTRY(); if (resource->address.resource_type == ACPI_MEMORY_RANGE) { - /* Write Status (_RW) - flag bit[0] */ - - flags = (u8) - (resource->address.attribute.memory. - read_write_attribute & 0x01); - - /* Memory Attributes (_MEM) - flag bits[2:1] */ - - flags |= (u8) - ((resource->address.attribute.memory. - cache_attribute & 0x03) << 1); + return ((u8) + + /* Write Status (_RW) - flag bit[0] */ + ((resource->address.attribute.memory. + read_write_attribute & 0x01) | + /* Memory Attributes (_MEM) - flag bits[2:1] */ + ((resource->address.attribute.memory. + cache_attribute & 0x03) << 1))); } else if (resource->address.resource_type == ACPI_IO_RANGE) { - /* Ranges (_RNG) - flag bits[1:0] */ - - flags = (u8) - (resource->address.attribute.io.range_attribute & 0x03); - - /* Translations (_TTP and _TRS) - flag bits[5:4] */ - - flags |= (u8) - ((resource->address.attribute.io. - translation_attribute & 0x03) << 4); + return ((u8) + + /* Ranges (_RNG) - flag bits[1:0] */ + ((resource->address.attribute.io. + range_attribute & 0x03) | + /* Translations (_TTP and _TRS) - flag bits[5:4] */ + ((resource->address.attribute.io. + translation_attribute & 0x03) << 4))); } - return (flags); + return (0); } /******************************************************************************* * - * FUNCTION: acpi_rs_address16_resource + * FUNCTION: acpi_rs_set_address_common * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * Resource - Pointer to the internal resource struct * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert common flag fields from a resource descriptor to an + * AML descriptor * ******************************************************************************/ -acpi_status -acpi_rs_address16_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size) +static void +acpi_rs_set_address_common(union aml_resource *aml, + struct acpi_resource *resource) { - u32 index; - u16 temp16; - u8 temp8; - u8 *temp_ptr; - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; - acpi_size struct_size = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16); + ACPI_FUNCTION_ENTRY(); - ACPI_FUNCTION_TRACE("rs_address16_resource"); + /* Set the Resource Type (Memory, Io, bus_number, etc.) */ - /* Get the Descriptor Length field */ + aml->address.resource_type = (u8) resource->data.address.resource_type; - buffer += 1; - ACPI_MOVE_16_TO_16(&temp16, buffer); + /* Set the general flags */ - /* Validate minimum descriptor length */ + aml->address.flags = acpi_rs_encode_general_flags(&resource->data); - if (temp16 < 13) { - return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); - } + /* Set the type-specific flags */ - *bytes_consumed = temp16 + 3; - output_struct->type = ACPI_RSTYPE_ADDRESS16; + aml->address.specific_flags = + acpi_rs_encode_specific_flags(&resource->data); +} - /* Get the Resource Type (Byte3) */ +/******************************************************************************* + * + * FUNCTION: acpi_rs_get_address_common + * + * PARAMETERS: Resource - Pointer to the internal resource struct + * Aml - Pointer to the AML resource descriptor + * + * RETURN: TRUE if the resource_type field is OK, FALSE otherwise + * + * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor + * to an internal resource descriptor + * + ******************************************************************************/ - buffer += 2; - temp8 = *buffer; +static u8 +acpi_rs_get_address_common(struct acpi_resource *resource, + union aml_resource *aml) +{ + ACPI_FUNCTION_ENTRY(); - /* Values 0-2 and 0xC0-0xFF are valid */ + /* Validate resource type */ - if ((temp8 > 2) && (temp8 < 0xC0)) { - return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); + if ((aml->address.resource_type > 2) + && (aml->address.resource_type < 0xC0)) { + return (FALSE); } - output_struct->data.address16.resource_type = temp8; - - /* Get the General Flags (Byte4) */ - - buffer += 1; - acpi_rs_decode_general_flags(&output_struct->data, *buffer); - - /* Get the Type Specific Flags (Byte5) */ - - buffer += 1; - acpi_rs_decode_specific_flags(&output_struct->data, *buffer); - - /* Get Granularity (Bytes 6-7) */ - - buffer += 1; - ACPI_MOVE_16_TO_32(&output_struct->data.address16.granularity, buffer); + /* Get the Resource Type (Memory, Io, bus_number, etc.) */ - /* Get min_address_range (Bytes 8-9) */ + resource->data.address.resource_type = aml->address.resource_type; - buffer += 2; - ACPI_MOVE_16_TO_32(&output_struct->data.address16.min_address_range, - buffer); + /* Get the General Flags */ - /* Get max_address_range (Bytes 10-11) */ + acpi_rs_decode_general_flags(&resource->data, aml->address.flags); - buffer += 2; - ACPI_MOVE_16_TO_32(&output_struct->data.address16.max_address_range, - buffer); + /* Get the Type-Specific Flags */ - /* Get address_translation_offset (Bytes 12-13) */ - - buffer += 2; - ACPI_MOVE_16_TO_32(&output_struct->data.address16. - address_translation_offset, buffer); + acpi_rs_decode_specific_flags(&resource->data, + aml->address.specific_flags); + return (TRUE); +} - /* Get address_length (Bytes 14-15) */ +/******************************************************************************* + * + * FUNCTION: acpi_rs_get_address16 + * + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned + * + * RETURN: Status + * + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. + * + ******************************************************************************/ - buffer += 2; - ACPI_MOVE_16_TO_32(&output_struct->data.address16.address_length, - buffer); +acpi_status +acpi_rs_get_address16(union aml_resource * aml, + u16 aml_resource_length, struct acpi_resource * resource) +{ + ACPI_FUNCTION_TRACE("rs_get_address16"); - /* Resource Source Index (if present) */ + /* Get the Resource Type, general flags, and type-specific flags */ - buffer += 2; + if (!acpi_rs_get_address_common(resource, aml)) { + return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); + } /* - * This will leave us pointing to the Resource Source Index - * If it is present, then save it off and calculate the - * pointer to where the null terminated string goes: - * Each Interrupt takes 32-bits + the 5 bytes of the - * stream that are default. - * - * Note: Some resource descriptors will have an additional null, so - * we add 1 to the length. + * Get the following contiguous fields from the AML descriptor: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length */ - if (*bytes_consumed > (16 + 1)) { - /* Dereference the Index */ - - output_struct->data.address16.resource_source.index = - (u32) * buffer; - - /* Point to the String */ + acpi_rs_move_data(&resource->data.address16.granularity, + &aml->address16.granularity, 5, + ACPI_MOVE_TYPE_16_TO_32); - buffer += 1; + /* Get the optional resource_source (index and string) */ - /* Point the String pointer to the end of this structure */ + resource->length = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16) + + acpi_rs_get_resource_source(aml_resource_length, + sizeof(struct aml_resource_address16), + &resource->data.address16. + resource_source, aml, NULL); - output_struct->data.address16.resource_source.string_ptr = - (char *)((u8 *) output_struct + struct_size); + /* Complete the resource header */ - temp_ptr = (u8 *) - output_struct->data.address16.resource_source.string_ptr; - - /* Copy the resource_source string into the buffer */ - - index = 0; - while (*buffer) { - *temp_ptr = *buffer; - - temp_ptr++; - buffer++; - index++; - } - - /* Add the terminating null and set the string length */ - - *temp_ptr = 0; - output_struct->data.address16.resource_source.string_length = - index + 1; - - /* - * In order for the struct_size to fall on a 32-bit boundary, - * calculate the length of the string and expand the - * struct_size to the next 32-bit boundary. - */ - temp8 = (u8) (index + 1); - struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); - } else { - output_struct->data.address16.resource_source.index = 0; - output_struct->data.address16.resource_source.string_length = 0; - output_struct->data.address16.resource_source.string_ptr = NULL; - } - - /* Set the Length parameter */ - - output_struct->length = (u32) struct_size; - - /* Return the final size of the structure */ - - *structure_size = struct_size; + resource->type = ACPI_RESOURCE_TYPE_ADDRESS16; return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_address16_stream + * FUNCTION: acpi_rs_set_address16 * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - Pointer to where the number of bytes - * used in the output_buffer is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_address16_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_set_address16(struct acpi_resource *resource, union aml_resource *aml) { - u8 *buffer = *output_buffer; - u8 *length_field; - acpi_size actual_bytes; - - ACPI_FUNCTION_TRACE("rs_address16_stream"); - - /* Set the Descriptor Type field */ + acpi_size descriptor_length; - *buffer = ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE; - buffer += 1; + ACPI_FUNCTION_TRACE("rs_set_address16"); - /* Save a pointer to the Length field - to be filled in later */ + /* Set the Resource Type, General Flags, and Type-Specific Flags */ - length_field = buffer; - buffer += 2; - - /* Set the Resource Type (Memory, Io, bus_number) */ - - *buffer = (u8) (resource->data.address16.resource_type & 0x03); - buffer += 1; - - /* Set the general flags */ + acpi_rs_set_address_common(aml, resource); - *buffer = acpi_rs_encode_general_flags(&resource->data); - buffer += 1; - - /* Set the type specific flags */ - - *buffer = acpi_rs_encode_specific_flags(&resource->data); - buffer += 1; - - /* Set the address space granularity */ - - ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.granularity); - buffer += 2; - - /* Set the address range minimum */ - - ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.min_address_range); - buffer += 2; - - /* Set the address range maximum */ - - ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.max_address_range); - buffer += 2; - - /* Set the address translation offset */ - - ACPI_MOVE_32_TO_16(buffer, - &resource->data.address16. - address_translation_offset); - buffer += 2; - - /* Set the address length */ - - ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.address_length); - buffer += 2; + /* + * Set the following contiguous fields in the AML descriptor: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + */ + acpi_rs_move_data(&aml->address16.granularity, + &resource->data.address16.granularity, 5, + ACPI_MOVE_TYPE_32_TO_16); /* Resource Source Index and Resource Source are optional */ - if (resource->data.address16.resource_source.string_length) { - *buffer = (u8) resource->data.address16.resource_source.index; - buffer += 1; + descriptor_length = acpi_rs_set_resource_source(aml, + sizeof(struct + aml_resource_address16), + &resource->data. + address16. + resource_source); - /* Copy the resource_source string */ + /* Complete the AML descriptor header */ - ACPI_STRCPY((char *)buffer, - resource->data.address16.resource_source. - string_ptr); - - /* - * Buffer needs to be set to the length of the string + one for the - * terminating null - */ - buffer += - (acpi_size) (ACPI_STRLEN - (resource->data.address16.resource_source. - string_ptr) + 1); - } - - /* Return the number of bytes consumed in this operation */ - - actual_bytes = ACPI_PTR_DIFF(buffer, *output_buffer); - *bytes_consumed = actual_bytes; - - /* - * Set the length field to the number of bytes consumed - * minus the header size (3 bytes) - */ - actual_bytes -= 3; - ACPI_MOVE_SIZE_TO_16(length_field, &actual_bytes); + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS16, + descriptor_length, aml); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_address32_resource + * FUNCTION: acpi_rs_get_address32 * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. * ******************************************************************************/ acpi_status -acpi_rs_address32_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size) +acpi_rs_get_address32(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource) { - u16 temp16; - u8 temp8; - u8 *temp_ptr; - u32 index; - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; - acpi_size struct_size = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32); - - ACPI_FUNCTION_TRACE("rs_address32_resource"); - - /* Get the Descriptor Length field */ - - buffer += 1; - ACPI_MOVE_16_TO_16(&temp16, buffer); - /* Validate minimum descriptor length */ + ACPI_FUNCTION_TRACE("rs_get_address32"); - if (temp16 < 23) { - return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); - } - - *bytes_consumed = temp16 + 3; - output_struct->type = ACPI_RSTYPE_ADDRESS32; - - /* Get the Resource Type (Byte3) */ - - buffer += 2; - temp8 = *buffer; + /* Get the Resource Type, general flags, and type-specific flags */ - /* Values 0-2 and 0xC0-0xFF are valid */ - - if ((temp8 > 2) && (temp8 < 0xC0)) { + if (!acpi_rs_get_address_common(resource, (void *)aml)) { return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); } - output_struct->data.address32.resource_type = temp8; - - /* Get the General Flags (Byte4) */ - - buffer += 1; - acpi_rs_decode_general_flags(&output_struct->data, *buffer); - - /* Get the Type Specific Flags (Byte5) */ - - buffer += 1; - acpi_rs_decode_specific_flags(&output_struct->data, *buffer); - - /* Get Granularity (Bytes 6-9) */ - - buffer += 1; - ACPI_MOVE_32_TO_32(&output_struct->data.address32.granularity, buffer); - - /* Get min_address_range (Bytes 10-13) */ - - buffer += 4; - ACPI_MOVE_32_TO_32(&output_struct->data.address32.min_address_range, - buffer); - - /* Get max_address_range (Bytes 14-17) */ - - buffer += 4; - ACPI_MOVE_32_TO_32(&output_struct->data.address32.max_address_range, - buffer); - - /* Get address_translation_offset (Bytes 18-21) */ - - buffer += 4; - ACPI_MOVE_32_TO_32(&output_struct->data.address32. - address_translation_offset, buffer); - - /* Get address_length (Bytes 22-25) */ - - buffer += 4; - ACPI_MOVE_32_TO_32(&output_struct->data.address32.address_length, - buffer); - - /* Resource Source Index (if present) */ - - buffer += 4; - /* - * This will leave us pointing to the Resource Source Index - * If it is present, then save it off and calculate the - * pointer to where the null terminated string goes: - * - * Note: Some resource descriptors will have an additional null, so - * we add 1 to the length. + * Get the following contiguous fields from the AML descriptor: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length */ - if (*bytes_consumed > (26 + 1)) { - /* Dereference the Index */ - - output_struct->data.address32.resource_source.index = - (u32) * buffer; - - /* Point to the String */ + acpi_rs_move_data(&resource->data.address32.granularity, + &aml->address32.granularity, 5, + ACPI_MOVE_TYPE_32_TO_32); - buffer += 1; + /* Get the optional resource_source (index and string) */ - /* Point the String pointer to the end of this structure */ + resource->length = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32) + + acpi_rs_get_resource_source(aml_resource_length, + sizeof(struct aml_resource_address32), + &resource->data.address32. + resource_source, aml, NULL); - output_struct->data.address32.resource_source.string_ptr = - (char *)((u8 *) output_struct + struct_size); + /* Complete the resource header */ - temp_ptr = (u8 *) - output_struct->data.address32.resource_source.string_ptr; - - /* Copy the resource_source string into the buffer */ - - index = 0; - while (*buffer) { - *temp_ptr = *buffer; - - temp_ptr++; - buffer++; - index++; - } - - /* Add the terminating null and set the string length */ - - *temp_ptr = 0; - output_struct->data.address32.resource_source.string_length = - index + 1; - - /* - * In order for the struct_size to fall on a 32-bit boundary, - * calculate the length of the string and expand the - * struct_size to the next 32-bit boundary. - */ - temp8 = (u8) (index + 1); - struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); - } else { - output_struct->data.address32.resource_source.index = 0; - output_struct->data.address32.resource_source.string_length = 0; - output_struct->data.address32.resource_source.string_ptr = NULL; - } - - /* Set the Length parameter */ - - output_struct->length = (u32) struct_size; - - /* Return the final size of the structure */ - - *structure_size = struct_size; + resource->type = ACPI_RESOURCE_TYPE_ADDRESS32; return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_address32_stream + * FUNCTION: acpi_rs_set_address32 * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - Pointer to where the number of bytes - * used in the output_buffer is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_address32_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_set_address32(struct acpi_resource *resource, union aml_resource *aml) { - u8 *buffer; - u16 *length_field; - - ACPI_FUNCTION_TRACE("rs_address32_stream"); - - buffer = *output_buffer; + acpi_size descriptor_length; - /* Set the Descriptor Type field */ + ACPI_FUNCTION_TRACE("rs_set_address32"); - *buffer = ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE; - buffer += 1; + /* Set the Resource Type, General Flags, and Type-Specific Flags */ - /* Save a pointer to the Length field - to be filled in later */ + acpi_rs_set_address_common(aml, resource); - length_field = ACPI_CAST_PTR(u16, buffer); - buffer += 2; - - /* Set the Resource Type (Memory, Io, bus_number) */ - - *buffer = (u8) (resource->data.address32.resource_type & 0x03); - buffer += 1; - - /* Set the general flags */ - - *buffer = acpi_rs_encode_general_flags(&resource->data); - buffer += 1; - - /* Set the type specific flags */ - - *buffer = acpi_rs_encode_specific_flags(&resource->data); - buffer += 1; - - /* Set the address space granularity */ - - ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.granularity); - buffer += 4; - - /* Set the address range minimum */ - - ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.min_address_range); - buffer += 4; - - /* Set the address range maximum */ - - ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.max_address_range); - buffer += 4; - - /* Set the address translation offset */ - - ACPI_MOVE_32_TO_32(buffer, - &resource->data.address32. - address_translation_offset); - buffer += 4; - - /* Set the address length */ - - ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.address_length); - buffer += 4; + /* + * Set the following contiguous fields in the AML descriptor: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + */ + acpi_rs_move_data(&aml->address32.granularity, + &resource->data.address32.granularity, 5, + ACPI_MOVE_TYPE_32_TO_32); /* Resource Source Index and Resource Source are optional */ - if (resource->data.address32.resource_source.string_length) { - *buffer = (u8) resource->data.address32.resource_source.index; - buffer += 1; - - /* Copy the resource_source string */ + descriptor_length = acpi_rs_set_resource_source(aml, + sizeof(struct + aml_resource_address32), + &resource->data. + address32. + resource_source); - ACPI_STRCPY((char *)buffer, - resource->data.address32.resource_source. - string_ptr); + /* Complete the AML descriptor header */ - /* - * Buffer needs to be set to the length of the string + one for the - * terminating null - */ - buffer += - (acpi_size) (ACPI_STRLEN - (resource->data.address32.resource_source. - string_ptr) + 1); - } - - /* Return the number of bytes consumed in this operation */ - - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); - - /* - * Set the length field to the number of bytes consumed - * minus the header size (3 bytes) - */ - *length_field = (u16) (*bytes_consumed - 3); + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS32, + descriptor_length, aml); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_address64_resource + * FUNCTION: acpi_rs_get_address64 * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. * ******************************************************************************/ acpi_status -acpi_rs_address64_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size) +acpi_rs_get_address64(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource) { - u16 temp16; - u8 temp8; - u8 resource_type; - u8 *temp_ptr; - u32 index; - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; - acpi_size struct_size = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64); - - ACPI_FUNCTION_TRACE("rs_address64_resource"); - - /* Get the Descriptor Type */ - - resource_type = *buffer; - - /* Get the Descriptor Length field */ - - buffer += 1; - ACPI_MOVE_16_TO_16(&temp16, buffer); - - /* Validate minimum descriptor length */ - - if (temp16 < 43) { - return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); - } - - *bytes_consumed = temp16 + 3; - output_struct->type = ACPI_RSTYPE_ADDRESS64; - - /* Get the Resource Type (Byte3) */ + ACPI_FUNCTION_TRACE("rs_get_address64"); - buffer += 2; - temp8 = *buffer; + /* Get the Resource Type, general Flags, and type-specific Flags */ - /* Values 0-2 and 0xC0-0xFF are valid */ - - if ((temp8 > 2) && (temp8 < 0xC0)) { + if (!acpi_rs_get_address_common(resource, aml)) { return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); } - output_struct->data.address64.resource_type = temp8; - - /* Get the General Flags (Byte4) */ - - buffer += 1; - acpi_rs_decode_general_flags(&output_struct->data, *buffer); - - /* Get the Type Specific Flags (Byte5) */ - - buffer += 1; - acpi_rs_decode_specific_flags(&output_struct->data, *buffer); - - if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { - /* Move past revision_id and Reserved byte */ - - buffer += 2; - } - - /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */ - - buffer += 1; - ACPI_MOVE_64_TO_64(&output_struct->data.address64.granularity, buffer); - - /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */ - - buffer += 8; - ACPI_MOVE_64_TO_64(&output_struct->data.address64.min_address_range, - buffer); - - /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */ - - buffer += 8; - ACPI_MOVE_64_TO_64(&output_struct->data.address64.max_address_range, - buffer); - - /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */ - - buffer += 8; - ACPI_MOVE_64_TO_64(&output_struct->data.address64. - address_translation_offset, buffer); + /* + * Get the following contiguous fields from the AML descriptor: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + */ + acpi_rs_move_data(&resource->data.address64.granularity, + &aml->address64.granularity, 5, + ACPI_MOVE_TYPE_64_TO_64); - /* Get address_length (Bytes 38-45) or (Bytes 40-47) */ + /* Get the optional resource_source (index and string) */ - buffer += 8; - ACPI_MOVE_64_TO_64(&output_struct->data.address64.address_length, - buffer); + resource->length = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64) + + acpi_rs_get_resource_source(aml_resource_length, + sizeof(struct aml_resource_address64), + &resource->data.address64. + resource_source, aml, NULL); - output_struct->data.address64.resource_source.index = 0; - output_struct->data.address64.resource_source.string_length = 0; - output_struct->data.address64.resource_source.string_ptr = NULL; + /* Complete the resource header */ - if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { - /* Get type_specific_attribute (Bytes 48-55) */ + resource->type = ACPI_RESOURCE_TYPE_ADDRESS64; + return_ACPI_STATUS(AE_OK); +} - buffer += 8; - ACPI_MOVE_64_TO_64(&output_struct->data.address64. - type_specific_attributes, buffer); - } else { - output_struct->data.address64.type_specific_attributes = 0; +/******************************************************************************* + * + * FUNCTION: acpi_rs_set_address64 + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned + * + * RETURN: Status + * + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. + * + ******************************************************************************/ - /* Resource Source Index (if present) */ +acpi_status +acpi_rs_set_address64(struct acpi_resource *resource, union aml_resource *aml) +{ + acpi_size descriptor_length; - buffer += 8; + ACPI_FUNCTION_TRACE("rs_set_address64"); - /* - * This will leave us pointing to the Resource Source Index - * If it is present, then save it off and calculate the - * pointer to where the null terminated string goes: - * Each Interrupt takes 32-bits + the 5 bytes of the - * stream that are default. - * - * Note: Some resource descriptors will have an additional null, so - * we add 1 to the length. - */ - if (*bytes_consumed > (46 + 1)) { - /* Dereference the Index */ + /* Set the Resource Type, General Flags, and Type-Specific Flags */ - output_struct->data.address64.resource_source.index = - (u32) * buffer; + acpi_rs_set_address_common(aml, resource); - /* Point to the String */ + /* + * Set the following contiguous fields in the AML descriptor: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + */ + acpi_rs_move_data(&aml->address64.granularity, + &resource->data.address64.granularity, 5, + ACPI_MOVE_TYPE_64_TO_64); - buffer += 1; + /* Resource Source Index and Resource Source are optional */ - /* Point the String pointer to the end of this structure */ + descriptor_length = acpi_rs_set_resource_source(aml, + sizeof(struct + aml_resource_address64), + &resource->data. + address64. + resource_source); - output_struct->data.address64.resource_source. - string_ptr = - (char *)((u8 *) output_struct + struct_size); + /* Complete the AML descriptor header */ - temp_ptr = (u8 *) - output_struct->data.address64.resource_source. - string_ptr; + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS64, + descriptor_length, aml); + return_ACPI_STATUS(AE_OK); +} - /* Copy the resource_source string into the buffer */ +/******************************************************************************* + * + * FUNCTION: acpi_rs_get_ext_address64 + * + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned + * + * RETURN: Status + * + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. + * + ******************************************************************************/ - index = 0; - while (*buffer) { - *temp_ptr = *buffer; +acpi_status +acpi_rs_get_ext_address64(union aml_resource *aml, + u16 aml_resource_length, + struct acpi_resource *resource) +{ - temp_ptr++; - buffer++; - index++; - } + ACPI_FUNCTION_TRACE("rs_get_ext_address64"); - /* - * Add the terminating null and set the string length - */ - *temp_ptr = 0; - output_struct->data.address64.resource_source. - string_length = index + 1; + /* Get the Resource Type, general flags, and type-specific flags */ - /* - * In order for the struct_size to fall on a 32-bit boundary, - * calculate the length of the string and expand the - * struct_size to the next 32-bit boundary. - */ - temp8 = (u8) (index + 1); - struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); - } + if (!acpi_rs_get_address_common(resource, aml)) { + return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); } - /* Set the Length parameter */ + /* + * Get and validate the Revision ID + * Note: Only one revision ID is currently supported + */ + resource->data.ext_address64.revision_iD = + aml->ext_address64.revision_iD; + if (aml->ext_address64.revision_iD != + AML_RESOURCE_EXTENDED_ADDRESS_REVISION) { + return_ACPI_STATUS(AE_SUPPORT); + } - output_struct->length = (u32) struct_size; + /* + * Get the following contiguous fields from the AML descriptor: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + * Type-Specific Attribute + */ + acpi_rs_move_data(&resource->data.ext_address64.granularity, + &aml->ext_address64.granularity, 6, + ACPI_MOVE_TYPE_64_TO_64); - /* Return the final size of the structure */ + /* Complete the resource header */ - *structure_size = struct_size; + resource->type = ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64; + resource->length = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_address64); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_address64_stream + * FUNCTION: acpi_rs_set_ext_address64 * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - Pointer to where the number of bytes - * used in the output_buffer is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_address64_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_set_ext_address64(struct acpi_resource *resource, + union aml_resource *aml) { - u8 *buffer; - u16 *length_field; - - ACPI_FUNCTION_TRACE("rs_address64_stream"); - - buffer = *output_buffer; - - /* Set the Descriptor Type field */ - - *buffer = ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE; - buffer += 1; - - /* Save a pointer to the Length field - to be filled in later */ - - length_field = ACPI_CAST_PTR(u16, buffer); - buffer += 2; - - /* Set the Resource Type (Memory, Io, bus_number) */ - - *buffer = (u8) (resource->data.address64.resource_type & 0x03); - buffer += 1; - - /* Set the general flags */ - - *buffer = acpi_rs_encode_general_flags(&resource->data); - buffer += 1; - - /* Set the type specific flags */ - - *buffer = acpi_rs_encode_specific_flags(&resource->data); - buffer += 1; - - /* Set the address space granularity */ + ACPI_FUNCTION_TRACE("rs_set_ext_address64"); - ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.granularity); - buffer += 8; + /* Set the Resource Type, General Flags, and Type-Specific Flags */ - /* Set the address range minimum */ + acpi_rs_set_address_common(aml, resource); - ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.min_address_range); - buffer += 8; + /* Only one Revision ID is currently supported */ - /* Set the address range maximum */ - - ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.max_address_range); - buffer += 8; - - /* Set the address translation offset */ - - ACPI_MOVE_64_TO_64(buffer, - &resource->data.address64. - address_translation_offset); - buffer += 8; - - /* Set the address length */ - - ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.address_length); - buffer += 8; - - /* Resource Source Index and Resource Source are optional */ - - if (resource->data.address64.resource_source.string_length) { - *buffer = (u8) resource->data.address64.resource_source.index; - buffer += 1; - - /* Copy the resource_source string */ - - ACPI_STRCPY((char *)buffer, - resource->data.address64.resource_source. - string_ptr); - - /* - * Buffer needs to be set to the length of the string + one for the - * terminating null - */ - buffer += - (acpi_size) (ACPI_STRLEN - (resource->data.address64.resource_source. - string_ptr) + 1); - } - - /* Return the number of bytes consumed in this operation */ - - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + aml->ext_address64.revision_iD = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + aml->ext_address64.reserved = 0; /* - * Set the length field to the number of bytes consumed - * minus the header size (3 bytes) + * Set the following contiguous fields in the AML descriptor: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + * Type-Specific Attribute */ - *length_field = (u16) (*bytes_consumed - 3); + acpi_rs_move_data(&aml->ext_address64.granularity, + &resource->data.address64.granularity, 6, + ACPI_MOVE_TYPE_64_TO_64); + + /* Complete the AML descriptor header */ + + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64, + sizeof(struct + aml_resource_extended_address64), + aml); return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c index 2da7c6a8182e..d170dee07ce9 100644 --- a/drivers/acpi/resources/rscalc.c +++ b/drivers/acpi/resources/rscalc.c @@ -44,87 +44,14 @@ #include #include #include -#include #include #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME("rscalc") -/* - * Base sizes for external resource descriptors, indexed by internal type. - * Includes size of the descriptor header (1 byte for small descriptors, - * 3 bytes for large descriptors) - */ -static u8 acpi_gbl_stream_sizes[] = { - 4, /* ACPI_RSTYPE_IRQ (Byte 3 is optional, but always created) */ - 3, /* ACPI_RSTYPE_DMA */ - 2, /* ACPI_RSTYPE_START_DPF (Byte 1 is optional, but always created) */ - 1, /* ACPI_RSTYPE_END_DPF */ - 8, /* ACPI_RSTYPE_IO */ - 4, /* ACPI_RSTYPE_FIXED_IO */ - 1, /* ACPI_RSTYPE_VENDOR */ - 2, /* ACPI_RSTYPE_END_TAG */ - 12, /* ACPI_RSTYPE_MEM24 */ - 20, /* ACPI_RSTYPE_MEM32 */ - 12, /* ACPI_RSTYPE_FIXED_MEM32 */ - 16, /* ACPI_RSTYPE_ADDRESS16 */ - 26, /* ACPI_RSTYPE_ADDRESS32 */ - 46, /* ACPI_RSTYPE_ADDRESS64 */ - 9, /* ACPI_RSTYPE_EXT_IRQ */ - 15 /* ACPI_RSTYPE_GENERIC_REG */ -}; - -/* - * Base sizes of resource descriptors, both the actual AML stream length and - * size of the internal struct representation. - */ -struct acpi_resource_sizes { - u8 minimum_stream_size; - u8 minimum_struct_size; -}; - -static struct acpi_resource_sizes acpi_gbl_sm_resource_sizes[] = { - {0, 0}, /* 0x00, Reserved */ - {0, 0}, /* 0x01, Reserved */ - {0, 0}, /* 0x02, Reserved */ - {0, 0}, /* 0x03, Reserved */ - {3, ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq)}, /* ACPI_RDESC_TYPE_IRQ_FORMAT */ - {3, ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma)}, /* ACPI_RDESC_TYPE_DMA_FORMAT */ - {1, ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf)}, /* ACPI_RDESC_TYPE_START_DEPENDENT */ - {1, ACPI_RESOURCE_LENGTH}, /* ACPI_RDESC_TYPE_END_DEPENDENT */ - {8, ACPI_SIZEOF_RESOURCE(struct acpi_resource_io)}, /* ACPI_RDESC_TYPE_IO_PORT */ - {4, ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io)}, /* ACPI_RDESC_TYPE_FIXED_IO_PORT */ - {0, 0}, /* 0x0A, Reserved */ - {0, 0}, /* 0x0B, Reserved */ - {0, 0}, /* 0x0C, Reserved */ - {0, 0}, /* 0x0D, Reserved */ - {1, ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, /* ACPI_RDESC_TYPE_SMALL_VENDOR */ - {2, ACPI_RESOURCE_LENGTH}, /* ACPI_RDESC_TYPE_END_TAG */ -}; - -static struct acpi_resource_sizes acpi_gbl_lg_resource_sizes[] = { - {0, 0}, /* 0x00, Reserved */ - {12, ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24)}, /* ACPI_RDESC_TYPE_MEMORY_24 */ - {15, ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_reg)}, /* ACPI_RDESC_TYPE_GENERIC_REGISTER */ - {0, 0}, /* 0x03, Reserved */ - {3, ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, /* ACPI_RDESC_TYPE_LARGE_VENDOR */ - {20, ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32)}, /* ACPI_RDESC_TYPE_MEMORY_32 */ - {12, ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_mem32)}, /* ACPI_RDESC_TYPE_FIXED_MEMORY_32 */ - {26, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32)}, /* ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE */ - {16, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16)}, /* ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE */ - {9, ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq)}, /* ACPI_RDESC_TYPE_EXTENDED_XRUPT */ - {46, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)}, /* ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE */ - {56, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)}, /* ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE */ -}; - /* Local prototypes */ - static u8 acpi_rs_count_set_bits(u16 bit_field); -static struct acpi_resource_sizes *acpi_rs_get_resource_sizes(u8 resource_type); - -static u16 acpi_rs_get_resource_length(u8 * resource); - static acpi_size acpi_rs_struct_option_length(struct acpi_resource_source *resource_source); @@ -159,90 +86,6 @@ static u8 acpi_rs_count_set_bits(u16 bit_field) return (bits_set); } -/******************************************************************************* - * - * FUNCTION: acpi_rs_get_resource_sizes - * - * PARAMETERS: resource_type - Byte 0 of a resource descriptor - * - * RETURN: Pointer to the resource conversion handler - * - * DESCRIPTION: Extract the Resource Type/Name from the first byte of - * a resource descriptor. - * - ******************************************************************************/ - -static struct acpi_resource_sizes *acpi_rs_get_resource_sizes(u8 resource_type) -{ - struct acpi_resource_sizes *size_info; - - ACPI_FUNCTION_ENTRY(); - - /* Determine if this is a small or large resource */ - - if (resource_type & ACPI_RDESC_TYPE_LARGE) { - /* Large Resource Type -- bits 6:0 contain the name */ - - if (resource_type > ACPI_RDESC_LARGE_MAX) { - return (NULL); - } - - size_info = &acpi_gbl_lg_resource_sizes[(resource_type & - ACPI_RDESC_LARGE_MASK)]; - } else { - /* Small Resource Type -- bits 6:3 contain the name */ - - size_info = &acpi_gbl_sm_resource_sizes[((resource_type & - ACPI_RDESC_SMALL_MASK) - >> 3)]; - } - - /* Zero entry indicates an invalid resource type */ - - if (!size_info->minimum_stream_size) { - return (NULL); - } - - return (size_info); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_get_resource_length - * - * PARAMETERS: Resource - Pointer to the resource descriptor - * - * RETURN: Byte length of the (AML byte stream) descriptor. By definition, - * this does not include the size of the descriptor header and the - * length field itself. - * - * DESCRIPTION: Extract the length of a resource descriptor. - * - ******************************************************************************/ - -static u16 acpi_rs_get_resource_length(u8 * resource) -{ - u16 resource_length; - - ACPI_FUNCTION_ENTRY(); - - /* Determine if this is a small or large resource */ - - if (*resource & ACPI_RDESC_TYPE_LARGE) { - /* Large Resource type -- length is in bytes 1-2 */ - - ACPI_MOVE_16_TO_16(&resource_length, (resource + 1)); - - } else { - /* Small Resource Type -- bits 2:0 of byte 0 contain the length */ - - resource_length = - (u16) (*resource & ACPI_RDESC_SMALL_LENGTH_MASK); - } - - return (resource_length); -} - /******************************************************************************* * * FUNCTION: acpi_rs_struct_option_length @@ -291,10 +134,10 @@ acpi_rs_struct_option_length(struct acpi_resource_source *resource_source) ******************************************************************************/ static u32 -acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length) +acpi_rs_stream_option_length(u32 resource_length, + u32 minimum_aml_resource_length) { u32 string_length = 0; - u32 minimum_resource_length; ACPI_FUNCTION_ENTRY(); @@ -303,11 +146,6 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length) * Large-type resource descriptors. */ - /* Compute minimum size of the data part of the resource descriptor */ - - minimum_resource_length = - minimum_total_length - sizeof(struct asl_large_header); - /* * If the length of the actual resource descriptor is greater than the ACPI * spec-defined minimum length, it means that a resource_source_index exists @@ -315,10 +153,11 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length) * (including the null terminator) is the resource length minus the minimum * length, minus one byte for the resource_source_index itself. */ - if (resource_length > minimum_resource_length) { + if (resource_length > minimum_aml_resource_length) { /* Compute the length of the optional string */ - string_length = resource_length - minimum_resource_length - 1; + string_length = + resource_length - minimum_aml_resource_length - 1; } /* Round up length to 32 bits for internal structure alignment */ @@ -328,7 +167,7 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length) /******************************************************************************* * - * FUNCTION: acpi_rs_get_byte_stream_length + * FUNCTION: acpi_rs_get_aml_length * * PARAMETERS: Resource - Pointer to the resource linked list * size_needed - Where the required size is returned @@ -342,62 +181,62 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length) ******************************************************************************/ acpi_status -acpi_rs_get_byte_stream_length(struct acpi_resource * resource, - acpi_size * size_needed) +acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) { - acpi_size byte_stream_size_needed = 0; + acpi_size aml_size_needed = 0; acpi_size segment_size; - ACPI_FUNCTION_TRACE("rs_get_byte_stream_length"); + ACPI_FUNCTION_TRACE("rs_get_aml_length"); /* Traverse entire list of internal resource descriptors */ while (resource) { /* Validate the descriptor type */ - if (resource->type > ACPI_RSTYPE_MAX) { + if (resource->type > ACPI_RESOURCE_TYPE_MAX) { return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); } /* Get the base size of the (external stream) resource descriptor */ - segment_size = acpi_gbl_stream_sizes[resource->type]; + segment_size = acpi_gbl_aml_resource_sizes[resource->type]; /* * Augment the base size for descriptors with optional and/or * variable-length fields */ switch (resource->type) { - case ACPI_RSTYPE_VENDOR: + case ACPI_RESOURCE_TYPE_VENDOR: /* * Vendor Defined Resource: * For a Vendor Specific resource, if the Length is between 1 and 7 * it will be created as a Small Resource data type, otherwise it * is a Large Resource data type. */ - if (resource->data.vendor_specific.length > 7) { + if (resource->data.vendor.byte_length > 7) { /* Base size of a Large resource descriptor */ - segment_size = 3; + segment_size = + sizeof(struct aml_resource_large_header); } /* Add the size of the vendor-specific data */ - segment_size += resource->data.vendor_specific.length; + segment_size += resource->data.vendor.byte_length; break; - case ACPI_RSTYPE_END_TAG: + case ACPI_RESOURCE_TYPE_END_TAG: /* * End Tag: * We are done -- return the accumulated total size. */ - *size_needed = byte_stream_size_needed + segment_size; + *size_needed = aml_size_needed + segment_size; /* Normal exit */ return_ACPI_STATUS(AE_OK); - case ACPI_RSTYPE_ADDRESS16: + case ACPI_RESOURCE_TYPE_ADDRESS16: /* * 16-Bit Address Resource: * Add the size of the optional resource_source info @@ -408,7 +247,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource, resource_source); break; - case ACPI_RSTYPE_ADDRESS32: + case ACPI_RESOURCE_TYPE_ADDRESS32: /* * 32-Bit Address Resource: * Add the size of the optional resource_source info @@ -419,7 +258,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource, resource_source); break; - case ACPI_RSTYPE_ADDRESS64: + case ACPI_RESOURCE_TYPE_ADDRESS64: /* * 64-Bit Address Resource: * Add the size of the optional resource_source info @@ -430,7 +269,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource, resource_source); break; - case ACPI_RSTYPE_EXT_IRQ: + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: /* * Extended IRQ Resource: * Add the size of each additional optional interrupt beyond the @@ -438,7 +277,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource, */ segment_size += (((acpi_size) resource->data.extended_irq. - number_of_interrupts - 1) * 4); + interrupt_count - 1) * 4); /* Add the size of the optional resource_source info */ @@ -454,7 +293,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource, /* Update the total */ - byte_stream_size_needed += segment_size; + aml_size_needed += segment_size; /* Point to the next object */ @@ -471,9 +310,9 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource, * * FUNCTION: acpi_rs_get_list_length * - * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream - * byte_stream_buffer_length - Size of byte_stream_buffer - * size_needed - Where the size needed is returned + * PARAMETERS: aml_buffer - Pointer to the resource byte stream + * aml_buffer_length - Size of aml_buffer + * size_needed - Where the size needed is returned * * RETURN: Status * @@ -484,11 +323,11 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource, ******************************************************************************/ acpi_status -acpi_rs_get_list_length(u8 * byte_stream_buffer, - u32 byte_stream_buffer_length, acpi_size * size_needed) +acpi_rs_get_list_length(u8 * aml_buffer, + u32 aml_buffer_length, acpi_size * size_needed) { u8 *buffer; - struct acpi_resource_sizes *resource_info; + struct acpi_resource_info *resource_info; u32 buffer_size = 0; u32 bytes_parsed = 0; u8 resource_type; @@ -499,14 +338,14 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, ACPI_FUNCTION_TRACE("rs_get_list_length"); - while (bytes_parsed < byte_stream_buffer_length) { + while (bytes_parsed < aml_buffer_length) { /* The next byte in the stream is the resource descriptor type */ - resource_type = acpi_rs_get_resource_type(*byte_stream_buffer); + resource_type = acpi_rs_get_resource_type(*aml_buffer); /* Get the base stream size and structure sizes for the descriptor */ - resource_info = acpi_rs_get_resource_sizes(resource_type); + resource_info = acpi_rs_get_resource_info(resource_type); if (!resource_info) { return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); } @@ -514,43 +353,46 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, /* Get the Length field from the input resource descriptor */ resource_length = - acpi_rs_get_resource_length(byte_stream_buffer); + acpi_rs_get_resource_length(ACPI_CAST_PTR + (union aml_resource, + aml_buffer)); /* Augment the size for descriptors with optional fields */ extra_struct_bytes = 0; - if (!(resource_type & ACPI_RDESC_TYPE_LARGE)) { + if (!(resource_type & ACPI_RESOURCE_NAME_LARGE)) { /* * Small resource descriptors */ - header_length = 1; - buffer = byte_stream_buffer + header_length; + header_length = + sizeof(struct aml_resource_small_header); + buffer = aml_buffer + header_length; switch (resource_type) { - case ACPI_RDESC_TYPE_IRQ_FORMAT: + case ACPI_RESOURCE_NAME_IRQ: /* * IRQ Resource: * Get the number of bits set in the IRQ word */ ACPI_MOVE_16_TO_16(&temp16, buffer); - extra_struct_bytes = (acpi_rs_count_set_bits(temp16) * sizeof(u32)); break; - case ACPI_RDESC_TYPE_DMA_FORMAT: + case ACPI_RESOURCE_NAME_DMA: /* * DMA Resource: * Get the number of bits set in the DMA channels byte */ + ACPI_MOVE_16_TO_16(&temp16, buffer); extra_struct_bytes = - (acpi_rs_count_set_bits((u16) * buffer) * + (acpi_rs_count_set_bits(temp16) * sizeof(u32)); break; - case ACPI_RDESC_TYPE_SMALL_VENDOR: + case ACPI_RESOURCE_NAME_VENDOR_SMALL: /* * Vendor Specific Resource: * Ensure a 32-bit boundary for the structure @@ -559,12 +401,12 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, ACPI_ROUND_UP_to_32_bITS(resource_length); break; - case ACPI_RDESC_TYPE_END_TAG: + case ACPI_RESOURCE_NAME_END_TAG: /* * End Tag: * Terminate the loop now */ - byte_stream_buffer_length = bytes_parsed; + aml_buffer_length = bytes_parsed; break; default: @@ -574,11 +416,12 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, /* * Large resource descriptors */ - header_length = sizeof(struct asl_large_header); - buffer = byte_stream_buffer + header_length; + header_length = + sizeof(struct aml_resource_large_header); + buffer = aml_buffer + header_length; switch (resource_type) { - case ACPI_RDESC_TYPE_LARGE_VENDOR: + case ACPI_RESOURCE_NAME_VENDOR_LARGE: /* * Vendor Defined Resource: * Add vendor data and ensure a 32-bit boundary for the structure @@ -587,8 +430,8 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, ACPI_ROUND_UP_to_32_bITS(resource_length); break; - case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: - case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: + case ACPI_RESOURCE_NAME_ADDRESS32: + case ACPI_RESOURCE_NAME_ADDRESS16: /* * 32-Bit or 16-bit Address Resource: * Add the size of any optional data (resource_source) @@ -596,10 +439,11 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, extra_struct_bytes = acpi_rs_stream_option_length (resource_length, - resource_info->minimum_stream_size); + resource_info-> + minimum_aml_resource_length); break; - case ACPI_RDESC_TYPE_EXTENDED_XRUPT: + case ACPI_RESOURCE_NAME_EXTENDED_IRQ: /* * Extended IRQ: * Point past the interrupt_vector_flags to get the @@ -622,10 +466,10 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, - extra_struct_bytes, resource_info-> - minimum_stream_size); + minimum_aml_resource_length); break; - case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: + case ACPI_RESOURCE_NAME_ADDRESS64: /* * 64-Bit Address Resource: * Add the size of any optional data (resource_source) @@ -635,7 +479,8 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, ACPI_ROUND_UP_to_64_bITS (acpi_rs_stream_option_length (resource_length, - resource_info->minimum_stream_size)); + resource_info-> + minimum_aml_resource_length)); break; default: @@ -646,7 +491,7 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, /* Update the required buffer size for the internal descriptor structs */ temp16 = - (u16) (resource_info->minimum_struct_size + + (u16) (resource_info->minimum_internal_struct_length + extra_struct_bytes); buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16); @@ -656,7 +501,7 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, */ temp16 = (u16) (header_length + resource_length); bytes_parsed += temp16; - byte_stream_buffer += temp16; + aml_buffer += temp16; } /* This is the data the caller needs */ @@ -758,8 +603,7 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, (*sub_object_list)->string. length + 1); } else { - temp_size_needed += - acpi_ns_get_pathname_length((*sub_object_list)->reference.node); + temp_size_needed += acpi_ns_get_pathname_length((*sub_object_list)->reference.node); } } else { /* diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c index 0911526b7ad8..6c7c6c560635 100644 --- a/drivers/acpi/resources/rscreate.c +++ b/drivers/acpi/resources/rscreate.c @@ -53,10 +53,10 @@ ACPI_MODULE_NAME("rscreate") * * FUNCTION: acpi_rs_create_resource_list * - * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream - * output_buffer - Pointer to the user's buffer + * PARAMETERS: aml_buffer - Pointer to the resource byte stream + * output_buffer - Pointer to the user's buffer * - * RETURN: Status - AE_OK if okay, else a valid acpi_status code + * RETURN: Status: AE_OK if okay, else a valid acpi_status code * If output_buffer is not large enough, output_buffer_length * indicates how large output_buffer should be, else it * indicates how may u8 elements of output_buffer are valid. @@ -67,33 +67,30 @@ ACPI_MODULE_NAME("rscreate") * ******************************************************************************/ acpi_status -acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer, +acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, struct acpi_buffer *output_buffer) { acpi_status status; - u8 *byte_stream_start; + u8 *aml_start; acpi_size list_size_needed = 0; - u32 byte_stream_buffer_length; + u32 aml_buffer_length; ACPI_FUNCTION_TRACE("rs_create_resource_list"); - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_buffer = %p\n", - byte_stream_buffer)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_buffer = %p\n", aml_buffer)); /* Params already validated, so we don't re-validate here */ - byte_stream_buffer_length = byte_stream_buffer->buffer.length; - byte_stream_start = byte_stream_buffer->buffer.pointer; + aml_buffer_length = aml_buffer->buffer.length; + aml_start = aml_buffer->buffer.pointer; /* - * Pass the byte_stream_buffer into a module that can calculate + * Pass the aml_buffer into a module that can calculate * the buffer size needed for the linked list */ - status = - acpi_rs_get_list_length(byte_stream_start, - byte_stream_buffer_length, - &list_size_needed); + status = acpi_rs_get_list_length(aml_start, aml_buffer_length, + &list_size_needed); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n", status, (u32) list_size_needed)); @@ -110,10 +107,8 @@ acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer, /* Do the conversion */ - status = - acpi_rs_byte_stream_to_list(byte_stream_start, - byte_stream_buffer_length, - output_buffer->pointer); + status = acpi_rs_convert_aml_to_resources(aml_start, aml_buffer_length, + output_buffer->pointer); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -360,7 +355,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, /******************************************************************************* * - * FUNCTION: acpi_rs_create_byte_stream + * FUNCTION: acpi_rs_create_aml_resources * * PARAMETERS: linked_list_buffer - Pointer to the resource linked list * output_buffer - Pointer to the user's buffer @@ -377,13 +372,13 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, ******************************************************************************/ acpi_status -acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, - struct acpi_buffer *output_buffer) +acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, + struct acpi_buffer *output_buffer) { acpi_status status; - acpi_size byte_stream_size_needed = 0; + acpi_size aml_size_needed = 0; - ACPI_FUNCTION_TRACE("rs_create_byte_stream"); + ACPI_FUNCTION_TRACE("rs_create_aml_resources"); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n", linked_list_buffer)); @@ -394,11 +389,10 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, * Pass the linked_list_buffer into a module that calculates * the buffer size needed for the byte stream. */ - status = acpi_rs_get_byte_stream_length(linked_list_buffer, - &byte_stream_size_needed); + status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed); - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_size_needed=%X, %s\n", - (u32) byte_stream_size_needed, + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_size_needed=%X, %s\n", + (u32) aml_size_needed, acpi_format_exception(status))); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); @@ -406,8 +400,7 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, /* Validate/Allocate/Clear caller buffer */ - status = - acpi_ut_initialize_buffer(output_buffer, byte_stream_size_needed); + status = acpi_ut_initialize_buffer(output_buffer, aml_size_needed); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -415,9 +408,9 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, /* Do the conversion */ status = - acpi_rs_list_to_byte_stream(linked_list_buffer, - byte_stream_size_needed, - output_buffer->pointer); + acpi_rs_convert_resources_to_aml(linked_list_buffer, + aml_size_needed, + output_buffer->pointer); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c index 9d93ee5f0060..2f8990845b2d 100644 --- a/drivers/acpi/resources/rsdump.c +++ b/drivers/acpi/resources/rsdump.c @@ -49,38 +49,6 @@ ACPI_MODULE_NAME("rsdump") #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) /* Local prototypes */ -static void acpi_rs_dump_irq(union acpi_resource_data *resource); - -static void acpi_rs_dump_address16(union acpi_resource_data *resource); - -static void acpi_rs_dump_address32(union acpi_resource_data *resource); - -static void acpi_rs_dump_address64(union acpi_resource_data *resource); - -static void acpi_rs_dump_dma(union acpi_resource_data *resource); - -static void acpi_rs_dump_io(union acpi_resource_data *resource); - -static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource); - -static void acpi_rs_dump_fixed_io(union acpi_resource_data *resource); - -static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource); - -static void acpi_rs_dump_memory24(union acpi_resource_data *resource); - -static void acpi_rs_dump_memory32(union acpi_resource_data *resource); - -static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *resource); - -static void acpi_rs_dump_vendor_specific(union acpi_resource_data *resource); - -static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource); - -static void acpi_rs_dump_end_depend_fns(union acpi_resource_data *resource); - -static void acpi_rs_dump_end_tag(union acpi_resource_data *resource); - static void acpi_rs_out_string(char *title, char *value); static void acpi_rs_out_integer8(char *title, u8 value); @@ -104,30 +72,6 @@ acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source); static void acpi_rs_dump_address_common(union acpi_resource_data *resource); -/* Dispatch table for resource dump functions */ - -typedef -void (*ACPI_DUMP_RESOURCE) (union acpi_resource_data * data); - -static ACPI_DUMP_RESOURCE acpi_gbl_dump_resource_dispatch[] = { - acpi_rs_dump_irq, /* ACPI_RSTYPE_IRQ */ - acpi_rs_dump_dma, /* ACPI_RSTYPE_DMA */ - acpi_rs_dump_start_depend_fns, /* ACPI_RSTYPE_START_DPF */ - acpi_rs_dump_end_depend_fns, /* ACPI_RSTYPE_END_DPF */ - acpi_rs_dump_io, /* ACPI_RSTYPE_IO */ - acpi_rs_dump_fixed_io, /* ACPI_RSTYPE_FIXED_IO */ - acpi_rs_dump_vendor_specific, /* ACPI_RSTYPE_VENDOR */ - acpi_rs_dump_end_tag, /* ACPI_RSTYPE_END_TAG */ - acpi_rs_dump_memory24, /* ACPI_RSTYPE_MEM24 */ - acpi_rs_dump_memory32, /* ACPI_RSTYPE_MEM32 */ - acpi_rs_dump_fixed_memory32, /* ACPI_RSTYPE_FIXED_MEM32 */ - acpi_rs_dump_address16, /* ACPI_RSTYPE_ADDRESS16 */ - acpi_rs_dump_address32, /* ACPI_RSTYPE_ADDRESS32 */ - acpi_rs_dump_address64, /* ACPI_RSTYPE_ADDRESS64 */ - acpi_rs_dump_extended_irq, /* ACPI_RSTYPE_EXT_IRQ */ - acpi_rs_dump_generic_reg /* ACPI_RSTYPE_GENERIC_REG */ -}; - /******************************************************************************* * * FUNCTION: acpi_rs_out* @@ -144,32 +88,32 @@ static ACPI_DUMP_RESOURCE acpi_gbl_dump_resource_dispatch[] = { static void acpi_rs_out_string(char *title, char *value) { - acpi_os_printf("%30s : %s\n", title, value); + acpi_os_printf("%27s : %s\n", title, value); } static void acpi_rs_out_integer8(char *title, u8 value) { - acpi_os_printf("%30s : %2.2X\n", title, value); + acpi_os_printf("%27s : %2.2X\n", title, value); } static void acpi_rs_out_integer16(char *title, u16 value) { - acpi_os_printf("%30s : %4.4X\n", title, value); + acpi_os_printf("%27s : %4.4X\n", title, value); } static void acpi_rs_out_integer32(char *title, u32 value) { - acpi_os_printf("%30s : %8.8X\n", title, value); + acpi_os_printf("%27s : %8.8X\n", title, value); } static void acpi_rs_out_integer64(char *title, u64 value) { - acpi_os_printf("%30s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value)); + acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value)); } static void acpi_rs_out_title(char *title) { - acpi_os_printf("%30s : ", title); + acpi_os_printf("%27s : ", title); } /******************************************************************************* @@ -190,7 +134,7 @@ static void acpi_rs_dump_byte_list(u32 length, u8 * data) u32 i; for (i = 0; i < length; i++) { - acpi_os_printf("%28s%2.2X : %2.2X\n", "Byte", i, data[i]); + acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]); } } @@ -199,7 +143,7 @@ static void acpi_rs_dump_dword_list(u32 length, u32 * data) u32 i; for (i = 0; i < length; i++) { - acpi_os_printf("%28s%2.2X : %8.8X\n", "Dword", i, data[i]); + acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]); } } @@ -213,6 +157,14 @@ static void acpi_rs_dump_short_byte_list(u32 length, u32 * data) acpi_os_printf("\n"); } +static void acpi_rs_dump_memory_attribute(u32 read_write_attribute) +{ + + acpi_rs_out_string("Read/Write Attribute", + ACPI_READ_WRITE_MEMORY == read_write_attribute ? + "Read/Write" : "Read-Only"); +} + /******************************************************************************* * * FUNCTION: acpi_rs_dump_resource_source @@ -229,6 +181,7 @@ static void acpi_rs_dump_short_byte_list(u32 length, u32 * data) static void acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source) { + ACPI_FUNCTION_ENTRY(); if (resource_source->index == 0xFF) { return; @@ -290,11 +243,8 @@ static void acpi_rs_dump_address_common(union acpi_resource_data *resource) break; } - acpi_rs_out_string("Read/Write Attribute", - ACPI_READ_WRITE_MEMORY == - resource->address.attribute.memory. - read_write_attribute ? "Read/Write" : - "Read Only"); + acpi_rs_dump_memory_attribute(resource->address.attribute. + memory.read_write_attribute); break; case ACPI_IO_RANGE: @@ -392,7 +342,7 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list) /* Validate Type before dispatch */ - if (resource_list->type > ACPI_RSTYPE_MAX) { + if (resource_list->type > ACPI_RESOURCE_TYPE_MAX) { acpi_os_printf ("Invalid descriptor type (%X) in resource list\n", resource_list->type); @@ -406,7 +356,7 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list) /* Exit on end tag */ - if (resource_list->type == ACPI_RSTYPE_END_TAG) { + if (resource_list->type == ACPI_RESOURCE_TYPE_END_TAG) { return; } @@ -431,7 +381,7 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list) * ******************************************************************************/ -static void acpi_rs_dump_irq(union acpi_resource_data *resource) +void acpi_rs_dump_irq(union acpi_resource_data *resource) { ACPI_FUNCTION_ENTRY(); @@ -439,22 +389,21 @@ static void acpi_rs_dump_irq(union acpi_resource_data *resource) acpi_rs_out_string("Triggering", ACPI_LEVEL_SENSITIVE == - resource->irq.edge_level ? "Level" : "Edge"); + resource->irq.triggering ? "Level" : "Edge"); acpi_rs_out_string("Active", ACPI_ACTIVE_LOW == - resource->irq.active_high_low ? "Low" : "High"); + resource->irq.polarity ? "Low" : "High"); acpi_rs_out_string("Sharing", ACPI_SHARED == - resource->irq. - shared_exclusive ? "Shared" : "Exclusive"); + resource->irq.sharable ? "Shared" : "Exclusive"); acpi_rs_out_integer8("Interrupt Count", - (u8) resource->irq.number_of_interrupts); + (u8) resource->irq.interrupt_count); acpi_rs_out_title("Interrupt List"); - acpi_rs_dump_short_byte_list(resource->irq.number_of_interrupts, + acpi_rs_dump_short_byte_list(resource->irq.interrupt_count, resource->irq.interrupts); } @@ -470,7 +419,7 @@ static void acpi_rs_dump_irq(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_dump_dma(union acpi_resource_data *resource) +void acpi_rs_dump_dma(union acpi_resource_data *resource) { ACPI_FUNCTION_ENTRY(); @@ -523,16 +472,16 @@ static void acpi_rs_dump_dma(union acpi_resource_data *resource) } acpi_rs_out_integer8("DMA Channel Count", - (u8) resource->dma.number_of_channels); + (u8) resource->dma.channel_count); acpi_rs_out_title("Channel List"); - acpi_rs_dump_short_byte_list(resource->dma.number_of_channels, + acpi_rs_dump_short_byte_list(resource->dma.channel_count, resource->dma.channels); } /******************************************************************************* * - * FUNCTION: acpi_rs_dump_start_depend_fns + * FUNCTION: acpi_rs_dump_start_dpf * * PARAMETERS: Resource - Pointer to an internal resource descriptor * @@ -542,7 +491,7 @@ static void acpi_rs_dump_dma(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *resource) +void acpi_rs_dump_start_dpf(union acpi_resource_data *resource) { ACPI_FUNCTION_ENTRY(); @@ -600,7 +549,7 @@ static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_dump_io(union acpi_resource_data *resource) +void acpi_rs_dump_io(union acpi_resource_data *resource) { ACPI_FUNCTION_ENTRY(); @@ -610,15 +559,13 @@ static void acpi_rs_dump_io(union acpi_resource_data *resource) ACPI_DECODE_16 == resource->io.io_decode ? "16-bit" : "10-bit"); - acpi_rs_out_integer32("Range Minimum Base", - resource->io.min_base_address); + acpi_rs_out_integer32("Address Minimum", resource->io.minimum); - acpi_rs_out_integer32("Range Maximum Base", - resource->io.max_base_address); + acpi_rs_out_integer32("Address Maximum", resource->io.maximum); acpi_rs_out_integer32("Alignment", resource->io.alignment); - acpi_rs_out_integer32("Range Length", resource->io.range_length); + acpi_rs_out_integer32("Address Length", resource->io.address_length); } /******************************************************************************* @@ -633,21 +580,21 @@ static void acpi_rs_dump_io(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_dump_fixed_io(union acpi_resource_data *resource) +void acpi_rs_dump_fixed_io(union acpi_resource_data *resource) { ACPI_FUNCTION_ENTRY(); acpi_os_printf("Fixed I/O Resource\n"); - acpi_rs_out_integer32("Range Base Address", - resource->fixed_io.base_address); + acpi_rs_out_integer32("Address", resource->fixed_io.address); - acpi_rs_out_integer32("Range Length", resource->fixed_io.range_length); + acpi_rs_out_integer32("Address Length", + resource->fixed_io.address_length); } /******************************************************************************* * - * FUNCTION: acpi_rs_dump_vendor_specific + * FUNCTION: acpi_rs_dump_vendor * * PARAMETERS: Resource - Pointer to an internal resource descriptor * @@ -657,16 +604,16 @@ static void acpi_rs_dump_fixed_io(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_dump_vendor_specific(union acpi_resource_data *resource) +void acpi_rs_dump_vendor(union acpi_resource_data *resource) { ACPI_FUNCTION_ENTRY(); acpi_os_printf("Vendor Specific Resource\n"); - acpi_rs_out_integer16("Length", (u16) resource->vendor_specific.length); + acpi_rs_out_integer16("Length", (u16) resource->vendor.byte_length); - acpi_rs_dump_byte_list(resource->vendor_specific.length, - resource->vendor_specific.reserved); + acpi_rs_dump_byte_list(resource->vendor.byte_length, + resource->vendor.byte_data); } /******************************************************************************* @@ -681,27 +628,24 @@ static void acpi_rs_dump_vendor_specific(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_dump_memory24(union acpi_resource_data *resource) +void acpi_rs_dump_memory24(union acpi_resource_data *resource) { ACPI_FUNCTION_ENTRY(); acpi_os_printf("24-Bit Memory Range Resource\n"); - acpi_rs_out_string("Attribute", - ACPI_READ_WRITE_MEMORY == - resource->memory24.read_write_attribute ? - "Read/Write" : "Read Only"); + acpi_rs_dump_memory_attribute(resource->memory24.read_write_attribute); - acpi_rs_out_integer16("Range Minimum Base", - (u16) resource->memory24.min_base_address); + acpi_rs_out_integer16("Address Minimum", + (u16) resource->memory24.minimum); - acpi_rs_out_integer16("Range Maximum Base", - (u16) resource->memory24.max_base_address); + acpi_rs_out_integer16("Address Maximum", + (u16) resource->memory24.maximum); acpi_rs_out_integer16("Alignment", (u16) resource->memory24.alignment); - acpi_rs_out_integer16("Range Length", - (u16) resource->memory24.range_length); + acpi_rs_out_integer16("Address Length", + (u16) resource->memory24.address_length); } /******************************************************************************* @@ -716,26 +660,22 @@ static void acpi_rs_dump_memory24(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_dump_memory32(union acpi_resource_data *resource) +void acpi_rs_dump_memory32(union acpi_resource_data *resource) { ACPI_FUNCTION_ENTRY(); acpi_os_printf("32-Bit Memory Range Resource\n"); - acpi_rs_out_string("Attribute", - ACPI_READ_WRITE_MEMORY == - resource->memory32.read_write_attribute ? - "Read/Write" : "Read Only"); + acpi_rs_dump_memory_attribute(resource->memory32.read_write_attribute); - acpi_rs_out_integer32("Range Minimum Base", - resource->memory32.min_base_address); + acpi_rs_out_integer32("Address Minimum", resource->memory32.minimum); - acpi_rs_out_integer32("Range Maximum Base", - resource->memory32.max_base_address); + acpi_rs_out_integer32("Address Maximum", resource->memory32.maximum); acpi_rs_out_integer32("Alignment", resource->memory32.alignment); - acpi_rs_out_integer32("Range Length", resource->memory32.range_length); + acpi_rs_out_integer32("Address Length", + resource->memory32.address_length); } /******************************************************************************* @@ -750,22 +690,19 @@ static void acpi_rs_dump_memory32(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource) +void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource) { ACPI_FUNCTION_ENTRY(); acpi_os_printf("32-Bit Fixed Location Memory Range Resource\n"); - acpi_rs_out_string("Attribute", - ACPI_READ_WRITE_MEMORY == - resource->fixed_memory32.read_write_attribute ? - "Read/Write" : "Read Only"); + acpi_rs_dump_memory_attribute(resource->fixed_memory32. + read_write_attribute); - acpi_rs_out_integer32("Range Base Address", - resource->fixed_memory32.range_base_address); + acpi_rs_out_integer32("Address", resource->fixed_memory32.address); - acpi_rs_out_integer32("Range Length", - resource->fixed_memory32.range_length); + acpi_rs_out_integer32("Address Length", + resource->fixed_memory32.address_length); } /******************************************************************************* @@ -780,26 +717,25 @@ static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_dump_address16(union acpi_resource_data *resource) +void acpi_rs_dump_address16(union acpi_resource_data *resource) { ACPI_FUNCTION_ENTRY(); - acpi_os_printf("16-Bit Address Space Resource\n"); + acpi_os_printf("16-Bit WORD Address Space Resource\n"); acpi_rs_dump_address_common(resource); acpi_rs_out_integer16("Granularity", (u16) resource->address16.granularity); - acpi_rs_out_integer16("Address Range Min", - (u16) resource->address16.min_address_range); + acpi_rs_out_integer16("Address Minimum", + (u16) resource->address16.minimum); - acpi_rs_out_integer16("Address Range Max", - (u16) resource->address16.max_address_range); + acpi_rs_out_integer16("Address Maximum", + (u16) resource->address16.maximum); - acpi_rs_out_integer16("Address Translation Offset", - (u16) resource->address16. - address_translation_offset); + acpi_rs_out_integer16("Translation Offset", + (u16) resource->address16.translation_offset); acpi_rs_out_integer16("Address Length", (u16) resource->address16.address_length); @@ -819,24 +755,22 @@ static void acpi_rs_dump_address16(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_dump_address32(union acpi_resource_data *resource) +void acpi_rs_dump_address32(union acpi_resource_data *resource) { ACPI_FUNCTION_ENTRY(); - acpi_os_printf("32-Bit Address Space Resource\n"); + acpi_os_printf("32-Bit DWORD Address Space Resource\n"); acpi_rs_dump_address_common(resource); acpi_rs_out_integer32("Granularity", resource->address32.granularity); - acpi_rs_out_integer32("Address Range Min", - resource->address32.min_address_range); + acpi_rs_out_integer32("Address Minimum", resource->address32.minimum); - acpi_rs_out_integer32("Address Range Max", - resource->address32.max_address_range); + acpi_rs_out_integer32("Address Maximum", resource->address32.maximum); - acpi_rs_out_integer32("Address Translation Offset", - resource->address32.address_translation_offset); + acpi_rs_out_integer32("Translation Offset", + resource->address32.translation_offset); acpi_rs_out_integer32("Address Length", resource->address32.address_length); @@ -856,37 +790,32 @@ static void acpi_rs_dump_address32(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_dump_address64(union acpi_resource_data *resource) +void acpi_rs_dump_address64(union acpi_resource_data *resource) { ACPI_FUNCTION_ENTRY(); - acpi_os_printf("64-Bit Address Space Resource\n"); + acpi_os_printf("64-Bit QWORD Address Space Resource\n"); acpi_rs_dump_address_common(resource); acpi_rs_out_integer64("Granularity", resource->address64.granularity); - acpi_rs_out_integer64("Address Range Min", - resource->address64.min_address_range); + acpi_rs_out_integer64("Address Minimum", resource->address64.minimum); - acpi_rs_out_integer64("Address Range Max", - resource->address64.max_address_range); + acpi_rs_out_integer64("Address Maximum", resource->address64.maximum); - acpi_rs_out_integer64("Address Translation Offset", - resource->address64.address_translation_offset); + acpi_rs_out_integer64("Translation Offset", + resource->address64.translation_offset); acpi_rs_out_integer64("Address Length", resource->address64.address_length); - acpi_rs_out_integer64("Type Specific Attributes", - resource->address64.type_specific_attributes); - acpi_rs_dump_resource_source(&resource->address64.resource_source); } /******************************************************************************* * - * FUNCTION: acpi_rs_dump_extended_irq + * FUNCTION: acpi_rs_dump_ext_address64 * * PARAMETERS: Resource - Pointer to an internal resource descriptor * @@ -896,7 +825,46 @@ static void acpi_rs_dump_address64(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource) +void acpi_rs_dump_ext_address64(union acpi_resource_data *resource) +{ + ACPI_FUNCTION_ENTRY(); + + acpi_os_printf("64-Bit Extended Address Space Resource\n"); + + acpi_rs_dump_address_common(resource); + + acpi_rs_out_integer64("Granularity", + resource->ext_address64.granularity); + + acpi_rs_out_integer64("Address Minimum", + resource->ext_address64.minimum); + + acpi_rs_out_integer64("Address Maximum", + resource->ext_address64.maximum); + + acpi_rs_out_integer64("Translation Offset", + resource->ext_address64.translation_offset); + + acpi_rs_out_integer64("Address Length", + resource->ext_address64.address_length); + + acpi_rs_out_integer64("Type-Specific Attribute", + resource->ext_address64.type_specific_attributes); +} + +/******************************************************************************* + * + * FUNCTION: acpi_rs_dump_ext_irq + * + * PARAMETERS: Resource - Pointer to an internal resource descriptor + * + * RETURN: None + * + * DESCRIPTION: Dump the field names and values of the resource descriptor + * + ******************************************************************************/ + +void acpi_rs_dump_ext_irq(union acpi_resource_data *resource) { ACPI_FUNCTION_ENTRY(); @@ -910,24 +878,22 @@ static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource) acpi_rs_out_string("Triggering", ACPI_LEVEL_SENSITIVE == resource->extended_irq. - edge_level ? "Level" : "Edge"); + triggering ? "Level" : "Edge"); acpi_rs_out_string("Active", - ACPI_ACTIVE_LOW == - resource->extended_irq. - active_high_low ? "Low" : "High"); + ACPI_ACTIVE_LOW == resource->extended_irq.polarity ? + "Low" : "High"); acpi_rs_out_string("Sharing", - ACPI_SHARED == - resource->extended_irq. - shared_exclusive ? "Shared" : "Exclusive"); + ACPI_SHARED == resource->extended_irq.sharable ? + "Shared" : "Exclusive"); acpi_rs_dump_resource_source(&resource->extended_irq.resource_source); acpi_rs_out_integer8("Interrupts", - (u8) resource->extended_irq.number_of_interrupts); + (u8) resource->extended_irq.interrupt_count); - acpi_rs_dump_dword_list(resource->extended_irq.number_of_interrupts, + acpi_rs_dump_dword_list(resource->extended_irq.interrupt_count, resource->extended_irq.interrupts); } @@ -943,9 +909,8 @@ static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource) +void acpi_rs_dump_generic_reg(union acpi_resource_data *resource) { - ACPI_FUNCTION_ENTRY(); acpi_os_printf("Generic Register Resource\n"); @@ -957,15 +922,15 @@ static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource) acpi_rs_out_integer8("Bit Offset", (u8) resource->generic_reg.bit_offset); - acpi_rs_out_integer8("Address Size", - (u8) resource->generic_reg.address_size); + acpi_rs_out_integer8("Access Size", + (u8) resource->generic_reg.access_size); acpi_rs_out_integer64("Address", resource->generic_reg.address); } /******************************************************************************* * - * FUNCTION: acpi_rs_dump_end_depend_fns + * FUNCTION: acpi_rs_dump_end_dpf * * PARAMETERS: Resource - Pointer to an internal resource descriptor * @@ -975,7 +940,7 @@ static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_dump_end_depend_fns(union acpi_resource_data *resource) +void acpi_rs_dump_end_dpf(union acpi_resource_data *resource) { ACPI_FUNCTION_ENTRY(); @@ -994,7 +959,7 @@ static void acpi_rs_dump_end_depend_fns(union acpi_resource_data *resource) * ******************************************************************************/ -static void acpi_rs_dump_end_tag(union acpi_resource_data *resource) +void acpi_rs_dump_end_tag(union acpi_resource_data *resource) { ACPI_FUNCTION_ENTRY(); diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/resources/rsinfo.c index 49a5f81c727b..b31cb33ec565 100644 --- a/drivers/acpi/resources/rsinfo.c +++ b/drivers/acpi/resources/rsinfo.c @@ -207,7 +207,7 @@ struct acpi_resource_info acpi_gbl_lg_resource_info[] = { {0, ACPI_RLARGE(struct aml_resource_memory24), ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24)}, {0, ACPI_RLARGE(struct aml_resource_generic_register), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_registerister)}, + ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register)}, {0, 0, 0}, {1, ACPI_RLARGE(struct aml_resource_vendor_large), ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c index 6574e2ae2e52..0dab8cdfa800 100644 --- a/drivers/acpi/resources/rsio.c +++ b/drivers/acpi/resources/rsio.c @@ -49,426 +49,269 @@ ACPI_MODULE_NAME("rsio") /******************************************************************************* * - * FUNCTION: acpi_rs_io_resource + * FUNCTION: acpi_rs_get_io * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. * ******************************************************************************/ acpi_status -acpi_rs_io_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size) +acpi_rs_get_io(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io); + ACPI_FUNCTION_TRACE("rs_get_io"); - ACPI_FUNCTION_TRACE("rs_io_resource"); + /* Get the Decode flag */ - /* The number of bytes consumed are Constant */ + resource->data.io.io_decode = aml->io.information & 0x01; - *bytes_consumed = 8; + /* + * Get the following contiguous fields from the AML descriptor: + * Minimum Base Address + * Maximum Base Address + * Address Alignment + * Length + */ + ACPI_MOVE_16_TO_32(&resource->data.io.minimum, &aml->io.minimum); + ACPI_MOVE_16_TO_32(&resource->data.io.maximum, &aml->io.maximum); + resource->data.io.alignment = aml->io.alignment; + resource->data.io.address_length = aml->io.address_length; - output_struct->type = ACPI_RSTYPE_IO; + /* Complete the resource header */ - /* Check Decode */ - - buffer += 1; - temp8 = *buffer; - - output_struct->data.io.io_decode = temp8 & 0x01; - - /* Check min_base Address */ - - buffer += 1; - ACPI_MOVE_16_TO_16(&temp16, buffer); - - output_struct->data.io.min_base_address = temp16; - - /* Check max_base Address */ - - buffer += 2; - ACPI_MOVE_16_TO_16(&temp16, buffer); - - output_struct->data.io.max_base_address = temp16; - - /* Check Base alignment */ - - buffer += 2; - temp8 = *buffer; - - output_struct->data.io.alignment = temp8; - - /* Check range_length */ - - buffer += 1; - temp8 = *buffer; - - output_struct->data.io.range_length = temp8; - - /* Set the Length parameter */ - - output_struct->length = (u32) struct_size; - - /* Return the final size of the structure */ - - *structure_size = struct_size; + resource->type = ACPI_RESOURCE_TYPE_IO; + resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_fixed_io_resource + * FUNCTION: acpi_rs_set_io * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_fixed_io_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size) +acpi_rs_set_io(struct acpi_resource *resource, union aml_resource *aml) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - acpi_size struct_size = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); - - ACPI_FUNCTION_TRACE("rs_fixed_io_resource"); + ACPI_FUNCTION_TRACE("rs_set_io"); - /* The number of bytes consumed are Constant */ + /* I/O Information Byte */ - *bytes_consumed = 4; + aml->io.information = (u8) (resource->data.io.io_decode & 0x01); - output_struct->type = ACPI_RSTYPE_FIXED_IO; + /* + * Set the following contiguous fields in the AML descriptor: + * Minimum Base Address + * Maximum Base Address + * Address Alignment + * Length + */ + ACPI_MOVE_32_TO_16(&aml->io.minimum, &resource->data.io.minimum); + ACPI_MOVE_32_TO_16(&aml->io.maximum, &resource->data.io.maximum); + aml->io.alignment = (u8) resource->data.io.alignment; + aml->io.address_length = (u8) resource->data.io.address_length; - /* Check Range Base Address */ + /* Complete the AML descriptor header */ - buffer += 1; - ACPI_MOVE_16_TO_16(&temp16, buffer); - - output_struct->data.fixed_io.base_address = temp16; - - /* Check range_length */ - - buffer += 2; - temp8 = *buffer; - - output_struct->data.fixed_io.range_length = temp8; - - /* Set the Length parameter */ - - output_struct->length = (u32) struct_size; - - /* Return the final size of the structure */ - - *structure_size = struct_size; + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IO, + sizeof(struct aml_resource_io), aml); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_io_stream + * FUNCTION: acpi_rs_get_fixed_io * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - Pointer to where the number of bytes - * used in the output_buffer is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. * ******************************************************************************/ acpi_status -acpi_rs_io_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_get_fixed_io(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - - ACPI_FUNCTION_TRACE("rs_io_stream"); - - /* The Descriptor Type field is static */ - - *buffer = ACPI_RDESC_TYPE_IO_PORT | 0x07; - buffer += 1; - - /* Io Information Byte */ - - temp8 = (u8) (resource->data.io.io_decode & 0x01); - - *buffer = temp8; - buffer += 1; - - /* Set the Range minimum base address */ - - temp16 = (u16) resource->data.io.min_base_address; - - ACPI_MOVE_16_TO_16(buffer, &temp16); - buffer += 2; - - /* Set the Range maximum base address */ + ACPI_FUNCTION_TRACE("rs_get_fixed_io"); - temp16 = (u16) resource->data.io.max_base_address; + /* + * Get the following contiguous fields from the AML descriptor: + * Base Address + * Length + */ + ACPI_MOVE_16_TO_32(&resource->data.fixed_io.address, + &aml->fixed_io.address); + resource->data.fixed_io.address_length = aml->fixed_io.address_length; - ACPI_MOVE_16_TO_16(buffer, &temp16); - buffer += 2; + /* Complete the resource header */ - /* Set the base alignment */ - - temp8 = (u8) resource->data.io.alignment; - - *buffer = temp8; - buffer += 1; - - /* Set the range length */ - - temp8 = (u8) resource->data.io.range_length; - - *buffer = temp8; - buffer += 1; - - /* Return the number of bytes consumed in this operation */ - - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + resource->type = ACPI_RESOURCE_TYPE_FIXED_IO; + resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_fixed_io_stream + * FUNCTION: acpi_rs_set_fixed_io * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - Pointer to where the number of bytes - * used in the output_buffer is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_fixed_io_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_set_fixed_io(struct acpi_resource *resource, union aml_resource *aml) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - - ACPI_FUNCTION_TRACE("rs_fixed_io_stream"); - - /* The Descriptor Type field is static */ - - *buffer = ACPI_RDESC_TYPE_FIXED_IO_PORT | 0x03; - buffer += 1; - - /* Set the Range base address */ - - temp16 = (u16) resource->data.fixed_io.base_address; - - ACPI_MOVE_16_TO_16(buffer, &temp16); - buffer += 2; - - /* Set the range length */ - - temp8 = (u8) resource->data.fixed_io.range_length; - - *buffer = temp8; - buffer += 1; - - /* Return the number of bytes consumed in this operation */ - - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + ACPI_FUNCTION_TRACE("rs_set_fixed_io"); + + /* + * Set the following contiguous fields in the AML descriptor: + * Base Address + * Length + */ + ACPI_MOVE_32_TO_16(&aml->fixed_io.address, + &resource->data.fixed_io.address); + aml->fixed_io.address_length = + (u8) resource->data.fixed_io.address_length; + + /* Complete the AML descriptor header */ + + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_IO, + sizeof(struct aml_resource_fixed_io), aml); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_dma_resource + * FUNCTION: acpi_rs_get_dma * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. * ******************************************************************************/ acpi_status -acpi_rs_dma_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size) +acpi_rs_get_dma(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; - u8 temp8 = 0; - u8 index; - u8 i; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma); + u32 channel_count = 0; + u32 i; + u8 temp8; - ACPI_FUNCTION_TRACE("rs_dma_resource"); - - /* The number of bytes consumed are Constant */ - - *bytes_consumed = 3; - output_struct->type = ACPI_RSTYPE_DMA; - - /* Point to the 8-bits of Byte 1 */ - - buffer += 1; - temp8 = *buffer; + ACPI_FUNCTION_TRACE("rs_get_dma"); /* Decode the DMA channel bits */ - for (i = 0, index = 0; index < 8; index++) { - if ((temp8 >> index) & 0x01) { - output_struct->data.dma.channels[i] = index; - i++; + for (i = 0; i < 8; i++) { + if ((aml->dma.dma_channel_mask >> i) & 0x01) { + resource->data.dma.channels[channel_count] = i; + channel_count++; } } - /* Zero DMA channels is valid */ - - output_struct->data.dma.number_of_channels = i; - if (i > 0) { - /* Calculate the structure size based upon the number of interrupts */ + resource->length = 0; + resource->data.dma.channel_count = channel_count; - struct_size += ((acpi_size) i - 1) * 4; + /* + * Calculate the structure size based upon the number of channels + * Note: Zero DMA channels is valid + */ + if (channel_count > 0) { + resource->length = (u32) (channel_count - 1) * 4; } - /* Point to Byte 2 */ + /* Get the flags: transfer preference, bus mastering, channel speed */ - buffer += 1; - temp8 = *buffer; + temp8 = aml->dma.flags; + resource->data.dma.transfer = temp8 & 0x03; + resource->data.dma.bus_master = (temp8 >> 2) & 0x01; + resource->data.dma.type = (temp8 >> 5) & 0x03; - /* Check for transfer preference (Bits[1:0]) */ - - output_struct->data.dma.transfer = temp8 & 0x03; - - if (0x03 == output_struct->data.dma.transfer) { + if (resource->data.dma.transfer == 0x03) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid DMA.Transfer preference (3)\n")); return_ACPI_STATUS(AE_BAD_DATA); } - /* Get bus master preference (Bit[2]) */ - - output_struct->data.dma.bus_master = (temp8 >> 2) & 0x01; - - /* Get channel speed support (Bits[6:5]) */ + /* Complete the resource header */ - output_struct->data.dma.type = (temp8 >> 5) & 0x03; - - /* Set the Length parameter */ - - output_struct->length = (u32) struct_size; - - /* Return the final size of the structure */ - - *structure_size = struct_size; + resource->type = ACPI_RESOURCE_TYPE_DMA; + resource->length += ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_dma_stream + * FUNCTION: acpi_rs_set_dma * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - Pointer to where the number of bytes - * used in the output_buffer is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_dma_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_set_dma(struct acpi_resource *resource, union aml_resource *aml) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - - ACPI_FUNCTION_TRACE("rs_dma_stream"); - - /* The Descriptor Type field is static */ + u8 i; - *buffer = ACPI_RDESC_TYPE_DMA_FORMAT | 0x02; - buffer += 1; - temp8 = 0; + ACPI_FUNCTION_TRACE("rs_set_dma"); - /* Loop through all of the Channels and set the mask bits */ + /* Convert channel list to 8-bit DMA channel bitmask */ - for (index = 0; index < resource->data.dma.number_of_channels; index++) { - temp16 = (u16) resource->data.dma.channels[index]; - temp8 |= 0x1 << temp16; + aml->dma.dma_channel_mask = 0; + for (i = 0; i < resource->data.dma.channel_count; i++) { + aml->dma.dma_channel_mask |= + (1 << resource->data.dma.channels[i]); } - *buffer = temp8; - buffer += 1; - - /* Set the DMA Info */ - - temp8 = (u8) ((resource->data.dma.type & 0x03) << 5); - temp8 |= ((resource->data.dma.bus_master & 0x01) << 2); - temp8 |= (resource->data.dma.transfer & 0x03); + /* Set the DMA Flag bits */ - *buffer = temp8; - buffer += 1; + aml->dma.flags = (u8) + (((resource->data.dma.type & 0x03) << 5) | + ((resource->data.dma.bus_master & 0x01) << 2) | + (resource->data.dma.transfer & 0x03)); - /* Return the number of bytes consumed in this operation */ + /* Complete the AML descriptor header */ - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_DMA, + sizeof(struct aml_resource_dma), aml); return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c index 75df962115cc..4e854ba70811 100644 --- a/drivers/acpi/resources/rsirq.c +++ b/drivers/acpi/resources/rsirq.c @@ -49,93 +49,67 @@ ACPI_MODULE_NAME("rsirq") /******************************************************************************* * - * FUNCTION: acpi_rs_irq_resource + * FUNCTION: acpi_rs_get_irq * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. * ******************************************************************************/ acpi_status -acpi_rs_irq_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size) +acpi_rs_get_irq(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - u8 i; - acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq); - - ACPI_FUNCTION_TRACE("rs_irq_resource"); - - /* - * The number of bytes consumed are contained in the descriptor - * (Bits:0-1) - */ - temp8 = *buffer; - *bytes_consumed = (temp8 & 0x03) + 1; - output_struct->type = ACPI_RSTYPE_IRQ; + u32 interrupt_count = 0; + u32 i; + u32 resource_length; - /* Point to the 16-bits of Bytes 1 and 2 */ + ACPI_FUNCTION_TRACE("rs_get_irq"); - buffer += 1; - ACPI_MOVE_16_TO_16(&temp16, buffer); + /* Get the IRQ mask (bytes 1:2) */ - output_struct->data.irq.number_of_interrupts = 0; + ACPI_MOVE_16_TO_16(&temp16, &aml->irq.irq_mask); - /* Decode the IRQ bits */ + /* Decode the IRQ bits (up to 16 possible) */ - for (i = 0, index = 0; index < 16; index++) { - if ((temp16 >> index) & 0x01) { - output_struct->data.irq.interrupts[i] = index; - i++; + for (i = 0; i < 16; i++) { + if ((temp16 >> i) & 0x01) { + resource->data.irq.interrupts[interrupt_count] = i; + interrupt_count++; } } /* Zero interrupts is valid */ - output_struct->data.irq.number_of_interrupts = i; - if (i > 0) { + resource_length = 0; + resource->data.irq.interrupt_count = interrupt_count; + if (interrupt_count > 0) { /* Calculate the structure size based upon the number of interrupts */ - struct_size += ((acpi_size) i - 1) * 4; + resource_length = (u32) (interrupt_count - 1) * 4; } - /* Point to Byte 3 if it is used */ - - if (4 == *bytes_consumed) { - buffer += 2; - temp8 = *buffer; + /* Get Flags (Byte 3) if it is used */ + if (aml_resource_length == 3) { /* Check for HE, LL interrupts */ - switch (temp8 & 0x09) { + switch (aml->irq.flags & 0x09) { case 0x01: /* HE */ - output_struct->data.irq.edge_level = - ACPI_EDGE_SENSITIVE; - output_struct->data.irq.active_high_low = - ACPI_ACTIVE_HIGH; + resource->data.irq.triggering = ACPI_EDGE_SENSITIVE; + resource->data.irq.polarity = ACPI_ACTIVE_HIGH; break; case 0x08: /* LL */ - output_struct->data.irq.edge_level = - ACPI_LEVEL_SENSITIVE; - output_struct->data.irq.active_high_low = - ACPI_ACTIVE_LOW; + resource->data.irq.triggering = ACPI_LEVEL_SENSITIVE; + resource->data.irq.polarity = ACPI_ACTIVE_LOW; break; default: @@ -146,170 +120,131 @@ acpi_rs_irq_resource(u8 * byte_stream_buffer, */ ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid interrupt polarity/trigger in resource list, %X\n", - temp8)); + aml->irq.flags)); return_ACPI_STATUS(AE_BAD_DATA); } - /* Check for sharable */ + /* Get Sharing flag */ - output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01; + resource->data.irq.sharable = (aml->irq.flags >> 3) & 0x01; } else { /* - * Assume Edge Sensitive, Active High, Non-Sharable - * per ACPI Specification + * Default configuration: assume Edge Sensitive, Active High, + * Non-Sharable as per the ACPI Specification */ - output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE; - output_struct->data.irq.active_high_low = ACPI_ACTIVE_HIGH; - output_struct->data.irq.shared_exclusive = ACPI_EXCLUSIVE; + resource->data.irq.triggering = ACPI_EDGE_SENSITIVE; + resource->data.irq.polarity = ACPI_ACTIVE_HIGH; + resource->data.irq.sharable = ACPI_EXCLUSIVE; } - /* Set the Length parameter */ + /* Complete the resource header */ - output_struct->length = (u32) struct_size; - - /* Return the final size of the structure */ - - *structure_size = struct_size; + resource->type = ACPI_RESOURCE_TYPE_IRQ; + resource->length = + resource_length + ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_irq_stream + * FUNCTION: acpi_rs_set_irq * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - Pointer to where the number of bytes - * used in the output_buffer is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_irq_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_set_irq(struct acpi_resource *resource, union aml_resource *aml) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - u8 IRqinfo_byte_needed; + acpi_size descriptor_length; + u16 irq_mask; + u8 i; + + ACPI_FUNCTION_TRACE("rs_set_irq"); - ACPI_FUNCTION_TRACE("rs_irq_stream"); + /* Convert interrupt list to 16-bit IRQ bitmask */ + + irq_mask = 0; + for (i = 0; i < resource->data.irq.interrupt_count; i++) { + irq_mask |= (1 << resource->data.irq.interrupts[i]); + } + + /* Set the interrupt mask */ + + ACPI_MOVE_16_TO_16(&aml->irq.irq_mask, &irq_mask); /* * The descriptor field is set based upon whether a third byte is * needed to contain the IRQ Information. */ - if (ACPI_EDGE_SENSITIVE == resource->data.irq.edge_level && - ACPI_ACTIVE_HIGH == resource->data.irq.active_high_low && - ACPI_EXCLUSIVE == resource->data.irq.shared_exclusive) { - *buffer = ACPI_RDESC_TYPE_IRQ_FORMAT | 0x02; - IRqinfo_byte_needed = FALSE; - } else { - *buffer = ACPI_RDESC_TYPE_IRQ_FORMAT | 0x03; - IRqinfo_byte_needed = TRUE; - } - - buffer += 1; - temp16 = 0; - - /* Loop through all of the interrupts and set the mask bits */ + if ((resource->data.irq.triggering == ACPI_EDGE_SENSITIVE) && + (resource->data.irq.polarity == ACPI_ACTIVE_HIGH) && + (resource->data.irq.sharable == ACPI_EXCLUSIVE)) { + /* irq_no_flags() descriptor can be used */ - for (index = 0; - index < resource->data.irq.number_of_interrupts; index++) { - temp8 = (u8) resource->data.irq.interrupts[index]; - temp16 |= 0x1 << temp8; - } + descriptor_length = sizeof(struct aml_resource_irq_noflags); + } else { + /* Irq() descriptor must be used */ - ACPI_MOVE_16_TO_16(buffer, &temp16); - buffer += 2; + descriptor_length = sizeof(struct aml_resource_irq); - /* Set the IRQ Info byte if needed. */ + /* Set the IRQ Info byte */ - if (IRqinfo_byte_needed) { - temp8 = 0; - temp8 = (u8) ((resource->data.irq.shared_exclusive & - 0x01) << 4); + aml->irq.flags = (u8) + ((resource->data.irq.sharable & 0x01) << 4); - if (ACPI_LEVEL_SENSITIVE == resource->data.irq.edge_level && - ACPI_ACTIVE_LOW == resource->data.irq.active_high_low) { - temp8 |= 0x08; + if (ACPI_LEVEL_SENSITIVE == resource->data.irq.triggering && + ACPI_ACTIVE_LOW == resource->data.irq.polarity) { + aml->irq.flags |= 0x08; } else { - temp8 |= 0x01; + aml->irq.flags |= 0x01; } - - *buffer = temp8; - buffer += 1; } - /* Return the number of bytes consumed in this operation */ + /* Complete the AML descriptor header */ - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IRQ, descriptor_length, + aml); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_extended_irq_resource + * FUNCTION: acpi_rs_get_ext_irq * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. * ******************************************************************************/ acpi_status -acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size) +acpi_rs_get_ext_irq(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 *temp_ptr; - u8 index; - acpi_size struct_size = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq); - - ACPI_FUNCTION_TRACE("rs_extended_irq_resource"); + char *out_resource_string; + u8 temp8; - /* Get the Descriptor Length field */ + ACPI_FUNCTION_TRACE("rs_get_ext_irq"); - buffer += 1; - ACPI_MOVE_16_TO_16(&temp16, buffer); + /* Get the flag bits */ - /* Validate minimum descriptor length */ - - if (temp16 < 6) { - return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); - } - - *bytes_consumed = temp16 + 3; - output_struct->type = ACPI_RSTYPE_EXT_IRQ; - - /* Point to the Byte3 */ - - buffer += 2; - temp8 = *buffer; - - output_struct->data.extended_irq.producer_consumer = temp8 & 0x01; + temp8 = aml->extended_irq.flags; + resource->data.extended_irq.producer_consumer = temp8 & 0x01; + resource->data.extended_irq.polarity = (temp8 >> 2) & 0x01; + resource->data.extended_irq.sharable = (temp8 >> 3) & 0x01; /* * Check for Interrupt Mode @@ -319,165 +254,80 @@ acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, * * - Edge/Level are defined opposite in the table vs the headers */ - output_struct->data.extended_irq.edge_level = + resource->data.extended_irq.triggering = (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; - /* Check Interrupt Polarity */ - - output_struct->data.extended_irq.active_high_low = (temp8 >> 2) & 0x1; - - /* Check for sharable */ - - output_struct->data.extended_irq.shared_exclusive = (temp8 >> 3) & 0x01; - - /* Point to Byte4 (IRQ Table length) */ - - buffer += 1; - temp8 = *buffer; - - /* Must have at least one IRQ */ + /* Get the IRQ Table length (Byte4) */ + temp8 = aml->extended_irq.table_length; + resource->data.extended_irq.interrupt_count = temp8; if (temp8 < 1) { + /* Must have at least one IRQ */ + return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); } - output_struct->data.extended_irq.number_of_interrupts = temp8; - /* * Add any additional structure size to properly calculate * the next pointer at the end of this function */ - struct_size += (temp8 - 1) * 4; + resource->length = (temp8 - 1) * 4; + out_resource_string = ACPI_CAST_PTR(char, + (&resource->data.extended_irq. + interrupts[0] + temp8)); - /* Point to Byte5 (First IRQ Number) */ + /* Get every IRQ in the table, each is 32 bits */ - buffer += 1; + acpi_rs_move_data(resource->data.extended_irq.interrupts, + aml->extended_irq.interrupt_number, + (u16) temp8, ACPI_MOVE_TYPE_32_TO_32); - /* Cycle through every IRQ in the table */ + /* Get the optional resource_source (index and string) */ - for (index = 0; index < temp8; index++) { - ACPI_MOVE_32_TO_32(&output_struct->data.extended_irq. - interrupts[index], buffer); + resource->length += + acpi_rs_get_resource_source(aml_resource_length, + (acpi_size) resource->length + + sizeof(struct + aml_resource_extended_irq), + &resource->data.extended_irq. + resource_source, aml, + out_resource_string); - /* Point to the next IRQ */ + /* Complete the resource header */ - buffer += 4; - } - - /* - * This will leave us pointing to the Resource Source Index - * If it is present, then save it off and calculate the - * pointer to where the null terminated string goes: - * Each Interrupt takes 32-bits + the 5 bytes of the - * stream that are default. - * - * Note: Some resource descriptors will have an additional null, so - * we add 1 to the length. - */ - if (*bytes_consumed > - ((acpi_size) output_struct->data.extended_irq.number_of_interrupts * - 4) + (5 + 1)) { - /* Dereference the Index */ - - temp8 = *buffer; - output_struct->data.extended_irq.resource_source.index = - (u32) temp8; - - /* Point to the String */ - - buffer += 1; - - /* Point the String pointer to the end of this structure. */ - - output_struct->data.extended_irq.resource_source.string_ptr = - (char *)((char *)output_struct + struct_size); - - temp_ptr = (u8 *) - output_struct->data.extended_irq.resource_source.string_ptr; - - /* Copy the string into the buffer */ - - index = 0; - while (*buffer) { - *temp_ptr = *buffer; - - temp_ptr += 1; - buffer += 1; - index += 1; - } - - /* Add the terminating null */ - - *temp_ptr = 0; - output_struct->data.extended_irq.resource_source.string_length = - index + 1; - - /* - * In order for the struct_size to fall on a 32-bit boundary, - * calculate the length of the string and expand the - * struct_size to the next 32-bit boundary. - */ - temp8 = (u8) (index + 1); - struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); - } else { - output_struct->data.extended_irq.resource_source.index = 0; - output_struct->data.extended_irq.resource_source.string_length = - 0; - output_struct->data.extended_irq.resource_source.string_ptr = - NULL; - } - - /* Set the Length parameter */ - - output_struct->length = (u32) struct_size; - - /* Return the final size of the structure */ - - *structure_size = struct_size; + resource->type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; + resource->length += + ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_irq); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_extended_irq_stream + * FUNCTION: acpi_rs_set_ext_irq * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - Pointer to where the number of bytes - * used in the output_buffer is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_extended_irq_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_set_ext_irq(struct acpi_resource *resource, union aml_resource *aml) { - u8 *buffer = *output_buffer; - u16 *length_field; - u8 temp8 = 0; - u8 index; - - ACPI_FUNCTION_TRACE("rs_extended_irq_stream"); - - /* Set the Descriptor Type field */ - - *buffer = ACPI_RDESC_TYPE_EXTENDED_XRUPT; - buffer += 1; + acpi_size descriptor_length; - /* Save a pointer to the Length field - to be filled in later */ - - length_field = ACPI_CAST_PTR(u16, buffer); - buffer += 2; + ACPI_FUNCTION_TRACE("rs_set_ext_irq"); /* Set the Interrupt vector flags */ - temp8 = (u8) (resource->data.extended_irq.producer_consumer & 0x01); - temp8 |= ((resource->data.extended_irq.shared_exclusive & 0x01) << 3); + aml->extended_irq.flags = (u8) + ((resource->data.extended_irq.producer_consumer & 0x01) | + ((resource->data.extended_irq.sharable & 0x01) << 3) | + ((resource->data.extended_irq.polarity & 0x1) << 2)); /* * Set the Interrupt Mode @@ -488,64 +338,36 @@ acpi_rs_extended_irq_stream(struct acpi_resource *resource, * * - Edge/Level are defined opposite in the table vs the headers */ - if (ACPI_EDGE_SENSITIVE == resource->data.extended_irq.edge_level) { - temp8 |= 0x2; + if (resource->data.extended_irq.triggering == ACPI_EDGE_SENSITIVE) { + aml->extended_irq.flags |= 0x02; } - /* Set the Interrupt Polarity */ - - temp8 |= ((resource->data.extended_irq.active_high_low & 0x1) << 2); - - *buffer = temp8; - buffer += 1; - /* Set the Interrupt table length */ - temp8 = (u8) resource->data.extended_irq.number_of_interrupts; - - *buffer = temp8; - buffer += 1; + aml->extended_irq.table_length = (u8) + resource->data.extended_irq.interrupt_count; - for (index = 0; - index < resource->data.extended_irq.number_of_interrupts; - index++) { - ACPI_MOVE_32_TO_32(buffer, - &resource->data.extended_irq. - interrupts[index]); - buffer += 4; - } - - /* Resource Source Index and Resource Source are optional */ + descriptor_length = (sizeof(struct aml_resource_extended_irq) - 4) + + ((acpi_size) resource->data.extended_irq.interrupt_count * + sizeof(u32)); - if (0 != resource->data.extended_irq.resource_source.string_length) { - *buffer = - (u8) resource->data.extended_irq.resource_source.index; - buffer += 1; + /* Set each interrupt value */ - /* Copy the string */ + acpi_rs_move_data(aml->extended_irq.interrupt_number, + resource->data.extended_irq.interrupts, + (u16) resource->data.extended_irq.interrupt_count, + ACPI_MOVE_TYPE_32_TO_32); - ACPI_STRCPY((char *)buffer, - resource->data.extended_irq.resource_source. - string_ptr); - - /* - * Buffer needs to be set to the length of the string + one for the - * terminating null - */ - buffer += - (acpi_size) (ACPI_STRLEN - (resource->data.extended_irq.resource_source. - string_ptr) + 1); - } + /* Resource Source Index and Resource Source are optional */ - /* Return the number of bytes consumed in this operation */ + descriptor_length = acpi_rs_set_resource_source(aml, descriptor_length, + &resource->data. + extended_irq. + resource_source); - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + /* Complete the AML descriptor header */ - /* - * Set the length field to the number of bytes consumed - * minus the header size (3 bytes) - */ - *length_field = (u16) (*bytes_consumed - 3); + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_EXTENDED_IRQ, + descriptor_length, aml); return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c index 87e75349dd0a..f72d42e0927b 100644 --- a/drivers/acpi/resources/rslist.c +++ b/drivers/acpi/resources/rslist.c @@ -47,106 +47,70 @@ #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME("rslist") -/* Dispatch table for convert-to-stream functions */ -typedef -acpi_status(*ACPI_STREAM_HANDLER) (struct acpi_resource * resource, - u8 ** output_buffer, - acpi_size * bytes_consumed); - -static ACPI_STREAM_HANDLER acpi_gbl_stream_dispatch[] = { - acpi_rs_irq_stream, /* ACPI_RSTYPE_IRQ */ - acpi_rs_dma_stream, /* ACPI_RSTYPE_DMA */ - acpi_rs_start_depend_fns_stream, /* ACPI_RSTYPE_START_DPF */ - acpi_rs_end_depend_fns_stream, /* ACPI_RSTYPE_END_DPF */ - acpi_rs_io_stream, /* ACPI_RSTYPE_IO */ - acpi_rs_fixed_io_stream, /* ACPI_RSTYPE_FIXED_IO */ - acpi_rs_vendor_stream, /* ACPI_RSTYPE_VENDOR */ - acpi_rs_end_tag_stream, /* ACPI_RSTYPE_END_TAG */ - acpi_rs_memory24_stream, /* ACPI_RSTYPE_MEM24 */ - acpi_rs_memory32_range_stream, /* ACPI_RSTYPE_MEM32 */ - acpi_rs_fixed_memory32_stream, /* ACPI_RSTYPE_FIXED_MEM32 */ - acpi_rs_address16_stream, /* ACPI_RSTYPE_ADDRESS16 */ - acpi_rs_address32_stream, /* ACPI_RSTYPE_ADDRESS32 */ - acpi_rs_address64_stream, /* ACPI_RSTYPE_ADDRESS64 */ - acpi_rs_extended_irq_stream, /* ACPI_RSTYPE_EXT_IRQ */ - acpi_rs_generic_register_stream /* ACPI_RSTYPE_GENERIC_REG */ -}; - -/* Dispatch tables for convert-to-resource functions */ - -typedef -acpi_status(*ACPI_RESOURCE_HANDLER) (u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, - acpi_size * structure_size); - -static ACPI_RESOURCE_HANDLER acpi_gbl_sm_resource_dispatch[] = { - NULL, /* 0x00, Reserved */ - NULL, /* 0x01, Reserved */ - NULL, /* 0x02, Reserved */ - NULL, /* 0x03, Reserved */ - acpi_rs_irq_resource, /* ACPI_RDESC_TYPE_IRQ_FORMAT */ - acpi_rs_dma_resource, /* ACPI_RDESC_TYPE_DMA_FORMAT */ - acpi_rs_start_depend_fns_resource, /* ACPI_RDESC_TYPE_START_DEPENDENT */ - acpi_rs_end_depend_fns_resource, /* ACPI_RDESC_TYPE_END_DEPENDENT */ - acpi_rs_io_resource, /* ACPI_RDESC_TYPE_IO_PORT */ - acpi_rs_fixed_io_resource, /* ACPI_RDESC_TYPE_FIXED_IO_PORT */ - NULL, /* 0x0A, Reserved */ - NULL, /* 0x0B, Reserved */ - NULL, /* 0x0C, Reserved */ - NULL, /* 0x0D, Reserved */ - acpi_rs_vendor_resource, /* ACPI_RDESC_TYPE_SMALL_VENDOR */ - acpi_rs_end_tag_resource /* ACPI_RDESC_TYPE_END_TAG */ -}; - -static ACPI_RESOURCE_HANDLER acpi_gbl_lg_resource_dispatch[] = { - NULL, /* 0x00, Reserved */ - acpi_rs_memory24_resource, /* ACPI_RDESC_TYPE_MEMORY_24 */ - acpi_rs_generic_register_resource, /* ACPI_RDESC_TYPE_GENERIC_REGISTER */ - NULL, /* 0x03, Reserved */ - acpi_rs_vendor_resource, /* ACPI_RDESC_TYPE_LARGE_VENDOR */ - acpi_rs_memory32_range_resource, /* ACPI_RDESC_TYPE_MEMORY_32 */ - acpi_rs_fixed_memory32_resource, /* ACPI_RDESC_TYPE_FIXED_MEMORY_32 */ - acpi_rs_address32_resource, /* ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE */ - acpi_rs_address16_resource, /* ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE */ - acpi_rs_extended_irq_resource, /* ACPI_RDESC_TYPE_EXTENDED_XRUPT */ - acpi_rs_address64_resource, /* ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE */ - acpi_rs_address64_resource /* ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE */ -}; - /* Local prototypes */ +static ACPI_GET_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type); -static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type); +static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml); /******************************************************************************* * - * FUNCTION: acpi_rs_get_resource_type + * FUNCTION: acpi_rs_validate_resource_length * - * PARAMETERS: resource_type - Byte 0 of a resource descriptor + * PARAMETERS: Aml - Pointer to the AML resource descriptor * - * RETURN: The Resource Type with no extraneous bits (except the large/ - * small bit -- left alone) + * RETURN: Status - AE_OK if the resource length appears valid * - * DESCRIPTION: Extract the Resource Type/Name from the first byte of - * a resource descriptor. + * DESCRIPTION: Validate the resource_length. Fixed-length descriptors must + * have the exact length; variable-length descriptors must be + * at least as long as the minimum. Certain Small descriptors + * can vary in size by at most one byte. * ******************************************************************************/ -u8 acpi_rs_get_resource_type(u8 resource_type) +static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml) { + struct acpi_resource_info *resource_info; + u16 minimum_aml_resource_length; + u16 resource_length; + ACPI_FUNCTION_ENTRY(); - /* Determine if this is a small or large resource */ + /* Get the size and type info about this resource descriptor */ - if (resource_type & ACPI_RDESC_TYPE_LARGE) { - /* Large Resource Type -- bits 6:0 contain the name */ + resource_info = + acpi_rs_get_resource_info(aml->small_header.descriptor_type); + if (!resource_info) { + return (AE_AML_INVALID_RESOURCE_TYPE); + } + + resource_length = acpi_rs_get_resource_length(aml); + minimum_aml_resource_length = + resource_info->minimum_aml_resource_length; + + /* Validate based upon the type of resource, fixed length or variable */ + + if (resource_info->length_type == ACPI_FIXED_LENGTH) { + /* Fixed length resource, length must match exactly */ - return (resource_type); + if (resource_length != minimum_aml_resource_length) { + return (AE_AML_BAD_RESOURCE_LENGTH); + } + } else if (resource_info->length_type == ACPI_VARIABLE_LENGTH) { + /* Variable length resource, must be at least the minimum */ + + if (resource_length < minimum_aml_resource_length) { + return (AE_AML_BAD_RESOURCE_LENGTH); + } } else { - /* Small Resource Type -- bits 6:3 contain the name */ + /* Small variable length resource, allowed to be (Min) or (Min-1) */ - return ((u8) (resource_type & ACPI_RDESC_SMALL_MASK)); + if ((resource_length > minimum_aml_resource_length) || + (resource_length < (minimum_aml_resource_length - 1))) { + return (AE_AML_BAD_RESOURCE_LENGTH); + } } + + return (AE_OK); } /******************************************************************************* @@ -162,38 +126,38 @@ u8 acpi_rs_get_resource_type(u8 resource_type) * ******************************************************************************/ -static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type) +static ACPI_GET_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type) { ACPI_FUNCTION_ENTRY(); /* Determine if this is a small or large resource */ - if (resource_type & ACPI_RDESC_TYPE_LARGE) { + if (resource_type & ACPI_RESOURCE_NAME_LARGE) { /* Large Resource Type -- bits 6:0 contain the name */ - if (resource_type > ACPI_RDESC_LARGE_MAX) { + if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { return (NULL); } - return (acpi_gbl_lg_resource_dispatch[(resource_type & - ACPI_RDESC_LARGE_MASK)]); + return (acpi_gbl_lg_get_resource_dispatch[(resource_type & + ACPI_RESOURCE_NAME_LARGE_MASK)]); } else { /* Small Resource Type -- bits 6:3 contain the name */ - return (acpi_gbl_sm_resource_dispatch[((resource_type & - ACPI_RDESC_SMALL_MASK) - >> 3)]); + return (acpi_gbl_sm_get_resource_dispatch[((resource_type & + ACPI_RESOURCE_NAME_SMALL_MASK) + >> 3)]); } } /******************************************************************************* * - * FUNCTION: acpi_rs_byte_stream_to_list + * FUNCTION: acpi_rs_convert_aml_to_resources * - * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream - * byte_stream_buffer_length - Length of byte_stream_buffer - * output_buffer - Pointer to the buffer that will - * contain the output structures + * PARAMETERS: aml_buffer - Pointer to the resource byte stream + * aml_buffer_length - Length of aml_buffer + * output_buffer - Pointer to the buffer that will + * contain the output structures * * RETURN: Status * @@ -203,37 +167,60 @@ static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type) ******************************************************************************/ acpi_status -acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, - u32 byte_stream_buffer_length, u8 * output_buffer) +acpi_rs_convert_aml_to_resources(u8 * aml_buffer, + u32 aml_buffer_length, u8 * output_buffer) { u8 *buffer = output_buffer; acpi_status status; acpi_size bytes_parsed = 0; - acpi_size bytes_consumed = 0; - acpi_size structure_size = 0; struct acpi_resource *resource; - ACPI_RESOURCE_HANDLER handler; + u16 resource_length; + u32 descriptor_length; + ACPI_GET_RESOURCE_HANDLER handler; - ACPI_FUNCTION_TRACE("rs_byte_stream_to_list"); + ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources"); /* Loop until end-of-buffer or an end_tag is found */ - while (bytes_parsed < byte_stream_buffer_length) { + while (bytes_parsed < aml_buffer_length) { /* Get the handler associated with this Descriptor Type */ - handler = acpi_rs_get_resource_handler(*byte_stream_buffer); - if (handler) { - /* Convert a byte stream resource to local resource struct */ + handler = acpi_rs_get_resource_handler(*aml_buffer); + if (!handler) { + /* No handler indicates invalid resource type */ - status = handler(byte_stream_buffer, &bytes_consumed, - &buffer, &structure_size); - } else { - /* Invalid resource type */ + return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); + } - status = AE_AML_INVALID_RESOURCE_TYPE; + resource_length = + acpi_rs_get_resource_length(ACPI_CAST_PTR + (union aml_resource, + aml_buffer)); + + descriptor_length = + acpi_rs_get_descriptor_length(ACPI_CAST_PTR + (union aml_resource, + aml_buffer)); + + /* + * Perform limited validation of the resource length, based upon + * what we know about the resource type + */ + status = + acpi_rs_validate_resource_length(ACPI_CAST_PTR + (union aml_resource, + aml_buffer)); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } + /* Convert a byte stream resource to local resource struct */ + + status = handler(ACPI_CAST_PTR(union aml_resource, aml_buffer), + resource_length, + ACPI_CAST_PTR(struct acpi_resource, buffer)); if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not convert AML resource (type %X) to resource, %s\n", *aml_buffer, acpi_format_exception(status))); return_ACPI_STATUS(status); } @@ -245,19 +232,19 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, /* Normal exit on completion of an end_tag resource descriptor */ - if (acpi_rs_get_resource_type(*byte_stream_buffer) == - ACPI_RDESC_TYPE_END_TAG) { + if (acpi_rs_get_resource_type(*aml_buffer) == + ACPI_RESOURCE_NAME_END_TAG) { return_ACPI_STATUS(AE_OK); } /* Update counter and point to the next input resource */ - bytes_parsed += bytes_consumed; - byte_stream_buffer += bytes_consumed; + bytes_parsed += descriptor_length; + aml_buffer += descriptor_length; /* Point to the next structure in the output buffer */ - buffer += ACPI_ALIGN_RESOURCE_SIZE(structure_size); + buffer += resource->length; } /* Completed buffer, but did not find an end_tag resource descriptor */ @@ -267,17 +254,15 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, /******************************************************************************* * - * FUNCTION: acpi_rs_list_to_byte_stream + * FUNCTION: acpi_rs_convert_resources_to_aml * - * PARAMETERS: Resource - Pointer to the resource linked list - * byte_steam_size_needed - Calculated size of the byte stream - * needed from calling - * acpi_rs_get_byte_stream_length() - * The size of the output_buffer is - * guaranteed to be >= - * byte_stream_size_needed - * output_buffer - Pointer to the buffer that will - * contain the byte stream + * PARAMETERS: Resource - Pointer to the resource linked list + * aml_size_needed - Calculated size of the byte stream + * needed from calling acpi_rs_get_aml_length() + * The size of the output_buffer is + * guaranteed to be >= aml_size_needed + * output_buffer - Pointer to the buffer that will + * contain the byte stream * * RETURN: Status * @@ -287,52 +272,69 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, ******************************************************************************/ acpi_status -acpi_rs_list_to_byte_stream(struct acpi_resource *resource, - acpi_size byte_stream_size_needed, - u8 * output_buffer) +acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, + acpi_size aml_size_needed, u8 * output_buffer) { - u8 *buffer = output_buffer; - acpi_size bytes_consumed = 0; + u8 *aml_buffer = output_buffer; acpi_status status; - ACPI_FUNCTION_TRACE("rs_list_to_byte_stream"); + ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml"); /* Convert each resource descriptor in the list */ while (1) { - /* Validate Type before dispatch */ + /* Validate Resource Descriptor Type before dispatch */ - if (resource->type > ACPI_RSTYPE_MAX) { + if (resource->type > ACPI_RESOURCE_TYPE_MAX) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid descriptor type (%X) in resource list\n", resource->type)); return_ACPI_STATUS(AE_BAD_DATA); } - /* Perform the conversion, per resource type */ + /* Perform the conversion per resource type */ + + status = + acpi_gbl_set_resource_dispatch[resource->type] (resource, + ACPI_CAST_PTR + (union + aml_resource, + aml_buffer)); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not convert resource (type %X) to AML, %s\n", resource->type, acpi_format_exception(status))); + return_ACPI_STATUS(status); + } + + /* Perform final sanity check on the new AML resource descriptor */ - status = acpi_gbl_stream_dispatch[resource->type] (resource, - &buffer, - &bytes_consumed); + status = + acpi_rs_validate_resource_length(ACPI_CAST_PTR + (union aml_resource, + aml_buffer)); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } - /* Check for end-of-list */ + /* Check for end-of-list, normal exit */ - if (resource->type == ACPI_RSTYPE_END_TAG) { - /* An End Tag indicates the end of the Resource Template */ + if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) { + /* An End Tag indicates the end of the input Resource Template */ return_ACPI_STATUS(AE_OK); } - /* Set the Buffer to point to the next (output) resource descriptor */ + /* Extract the total length of the new descriptor */ + /* Set the aml_buffer to point to the next (output) resource descriptor */ - buffer += bytes_consumed; + aml_buffer += + acpi_rs_get_descriptor_length(ACPI_CAST_PTR + (union aml_resource, + aml_buffer)); - /* Point to the next input resource object */ + /* Point to the next input resource descriptor */ - resource = ACPI_PTR_ADD(struct acpi_resource, - resource, resource->length); + resource = + ACPI_PTR_ADD(struct acpi_resource, resource, + resource->length); } } diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c index 418f1afb10a3..47e979e7ba35 100644 --- a/drivers/acpi/resources/rsmemory.c +++ b/drivers/acpi/resources/rsmemory.c @@ -49,446 +49,260 @@ ACPI_MODULE_NAME("rsmemory") /******************************************************************************* * - * FUNCTION: acpi_rs_memory24_resource + * FUNCTION: acpi_rs_get_memory24 * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. * ******************************************************************************/ acpi_status -acpi_rs_memory24_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size) +acpi_rs_get_memory24(union aml_resource * aml, + u16 aml_resource_length, struct acpi_resource * resource) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - acpi_size struct_size = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24); + ACPI_FUNCTION_TRACE("rs_get_memory24"); - ACPI_FUNCTION_TRACE("rs_memory24_resource"); + /* Get the Read/Write bit */ - /* Point past the Descriptor to get the number of bytes consumed */ + resource->data.memory24.read_write_attribute = + (aml->memory24.information & 0x01); - buffer += 1; - ACPI_MOVE_16_TO_16(&temp16, buffer); - - buffer += 2; - *bytes_consumed = (acpi_size) temp16 + 3; - output_struct->type = ACPI_RSTYPE_MEM24; - - /* Check Byte 3 the Read/Write bit */ - - temp8 = *buffer; - buffer += 1; - output_struct->data.memory24.read_write_attribute = temp8 & 0x01; - - /* Get min_base_address (Bytes 4-5) */ - - ACPI_MOVE_16_TO_16(&temp16, buffer); - buffer += 2; - output_struct->data.memory24.min_base_address = temp16; - - /* Get max_base_address (Bytes 6-7) */ - - ACPI_MOVE_16_TO_16(&temp16, buffer); - buffer += 2; - output_struct->data.memory24.max_base_address = temp16; - - /* Get Alignment (Bytes 8-9) */ - - ACPI_MOVE_16_TO_16(&temp16, buffer); - buffer += 2; - output_struct->data.memory24.alignment = temp16; - - /* Get range_length (Bytes 10-11) */ - - ACPI_MOVE_16_TO_16(&temp16, buffer); - output_struct->data.memory24.range_length = temp16; - - /* Set the Length parameter */ - - output_struct->length = (u32) struct_size; + /* + * Get the following contiguous fields from the AML descriptor: + * Minimum Base Address + * Maximum Base Address + * Address Base Alignment + * Range Length + */ + acpi_rs_move_data(&resource->data.memory24.minimum, + &aml->memory24.minimum, 4, ACPI_MOVE_TYPE_16_TO_32); - /* Return the final size of the structure */ + /* Complete the resource header */ - *structure_size = struct_size; + resource->type = ACPI_RESOURCE_TYPE_MEMORY24; + resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_memory24_stream + * FUNCTION: acpi_rs_set_memory24 * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - Pointer to where the number of bytes - * used in the output_buffer is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_memory24_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_set_memory24(struct acpi_resource *resource, union aml_resource *aml) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - - ACPI_FUNCTION_TRACE("rs_memory24_stream"); - - /* The Descriptor Type field is static */ - - *buffer = ACPI_RDESC_TYPE_MEMORY_24; - buffer += 1; - - /* The length field is static */ - - temp16 = 0x09; - ACPI_MOVE_16_TO_16(buffer, &temp16); - buffer += 2; + ACPI_FUNCTION_TRACE("rs_set_memory24"); /* Set the Information Byte */ - temp8 = (u8) (resource->data.memory24.read_write_attribute & 0x01); - *buffer = temp8; - buffer += 1; - - /* Set the Range minimum base address */ + aml->memory24.information = (u8) + (resource->data.memory24.read_write_attribute & 0x01); - ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.min_base_address); - buffer += 2; - - /* Set the Range maximum base address */ - - ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.max_base_address); - buffer += 2; - - /* Set the base alignment */ - - ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.alignment); - buffer += 2; - - /* Set the range length */ - - ACPI_MOVE_32_TO_16(buffer, &resource->data.memory24.range_length); - buffer += 2; + /* + * Set the following contiguous fields in the AML descriptor: + * Minimum Base Address + * Maximum Base Address + * Address Base Alignment + * Range Length + */ + acpi_rs_move_data(&aml->memory24.minimum, + &resource->data.memory24.minimum, 4, + ACPI_MOVE_TYPE_32_TO_16); - /* Return the number of bytes consumed in this operation */ + /* Complete the AML descriptor header */ - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY24, + sizeof(struct aml_resource_memory24), aml); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_memory32_range_resource + * FUNCTION: acpi_rs_get_memory32 * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. * ******************************************************************************/ acpi_status -acpi_rs_memory32_range_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size) +acpi_rs_get_memory32(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - acpi_size struct_size = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32); - - ACPI_FUNCTION_TRACE("rs_memory32_range_resource"); + ACPI_FUNCTION_TRACE("rs_get_memory32"); - /* Point past the Descriptor to get the number of bytes consumed */ + /* Get the Read/Write bit */ - buffer += 1; - ACPI_MOVE_16_TO_16(&temp16, buffer); - - buffer += 2; - *bytes_consumed = (acpi_size) temp16 + 3; - output_struct->type = ACPI_RSTYPE_MEM32; + resource->data.memory32.read_write_attribute = + (aml->memory32.information & 0x01); /* - * Point to the place in the output buffer where the data portion will - * begin. - * 1. Set the RESOURCE_DATA * Data to point to its own address, then - * 2. Set the pointer to the next address. - * - * NOTE: output_struct->Data is cast to u8, otherwise, this addition adds - * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8) + * Get the following contiguous fields from the AML descriptor: + * Minimum Base Address + * Maximum Base Address + * Address Base Alignment + * Range Length */ + acpi_rs_move_data(&resource->data.memory32.minimum, + &aml->memory32.minimum, 4, ACPI_MOVE_TYPE_32_TO_32); - /* Check Byte 3 the Read/Write bit */ - - temp8 = *buffer; - buffer += 1; - - output_struct->data.memory32.read_write_attribute = temp8 & 0x01; - - /* Get min_base_address (Bytes 4-7) */ - - ACPI_MOVE_32_TO_32(&output_struct->data.memory32.min_base_address, - buffer); - buffer += 4; - - /* Get max_base_address (Bytes 8-11) */ - - ACPI_MOVE_32_TO_32(&output_struct->data.memory32.max_base_address, - buffer); - buffer += 4; - - /* Get Alignment (Bytes 12-15) */ - - ACPI_MOVE_32_TO_32(&output_struct->data.memory32.alignment, buffer); - buffer += 4; - - /* Get range_length (Bytes 16-19) */ - - ACPI_MOVE_32_TO_32(&output_struct->data.memory32.range_length, buffer); - - /* Set the Length parameter */ + /* Complete the resource header */ - output_struct->length = (u32) struct_size; - - /* Return the final size of the structure */ - - *structure_size = struct_size; + resource->type = ACPI_RESOURCE_TYPE_MEMORY32; + resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory32); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_fixed_memory32_resource + * FUNCTION: acpi_rs_set_memory32 * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size) +acpi_rs_set_memory32(struct acpi_resource *resource, union aml_resource *aml) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - acpi_size struct_size = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_mem32); - - ACPI_FUNCTION_TRACE("rs_fixed_memory32_resource"); - - /* Point past the Descriptor to get the number of bytes consumed */ - - buffer += 1; - ACPI_MOVE_16_TO_16(&temp16, buffer); - - buffer += 2; - *bytes_consumed = (acpi_size) temp16 + 3; - output_struct->type = ACPI_RSTYPE_FIXED_MEM32; - - /* Check Byte 3 the Read/Write bit */ - - temp8 = *buffer; - buffer += 1; - output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01; - - /* Get range_base_address (Bytes 4-7) */ - - ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32. - range_base_address, buffer); - buffer += 4; - - /* Get range_length (Bytes 8-11) */ + ACPI_FUNCTION_TRACE("rs_set_memory32"); - ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.range_length, - buffer); + /* Set the Information Byte */ - /* Set the Length parameter */ + aml->memory32.information = (u8) + (resource->data.memory32.read_write_attribute & 0x01); - output_struct->length = (u32) struct_size; + /* + * Set the following contiguous fields in the AML descriptor: + * Minimum Base Address + * Maximum Base Address + * Address Base Alignment + * Range Length + */ + acpi_rs_move_data(&aml->memory32.minimum, + &resource->data.memory32.minimum, 4, + ACPI_MOVE_TYPE_32_TO_32); - /* Return the final size of the structure */ + /* Complete the AML descriptor header */ - *structure_size = struct_size; + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY32, + sizeof(struct aml_resource_memory32), aml); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_memory32_range_stream + * FUNCTION: acpi_rs_get_fixed_memory32 * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - Pointer to where the number of bytes - * used in the output_buffer is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. * ******************************************************************************/ acpi_status -acpi_rs_memory32_range_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_get_fixed_memory32(union aml_resource *aml, + u16 aml_resource_length, + struct acpi_resource *resource) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - - ACPI_FUNCTION_TRACE("rs_memory32_range_stream"); - - /* The Descriptor Type field is static */ + ACPI_FUNCTION_TRACE("rs_get_fixed_memory32"); - *buffer = ACPI_RDESC_TYPE_MEMORY_32; - buffer += 1; - - /* The length field is static */ - - temp16 = 0x11; - - ACPI_MOVE_16_TO_16(buffer, &temp16); - buffer += 2; - - /* Set the Information Byte */ + /* Get the Read/Write bit */ - temp8 = (u8) (resource->data.memory32.read_write_attribute & 0x01); - *buffer = temp8; - buffer += 1; + resource->data.fixed_memory32.read_write_attribute = + (aml->fixed_memory32.information & 0x01); - /* Set the Range minimum base address */ - - ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.min_base_address); - buffer += 4; - - /* Set the Range maximum base address */ - - ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.max_base_address); - buffer += 4; - - /* Set the base alignment */ - - ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.alignment); - buffer += 4; - - /* Set the range length */ - - ACPI_MOVE_32_TO_32(buffer, &resource->data.memory32.range_length); - buffer += 4; + /* + * Get the following contiguous fields from the AML descriptor: + * Base Address + * Range Length + */ + ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address, + &aml->fixed_memory32.address); + ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address_length, + &aml->fixed_memory32.address_length); - /* Return the number of bytes consumed in this operation */ + /* Complete the resource header */ - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32; + resource->length = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_memory32); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_fixed_memory32_stream + * FUNCTION: acpi_rs_set_fixed_memory32 * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - Pointer to where the number of bytes - * used in the output_buffer is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_fixed_memory32_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_set_fixed_memory32(struct acpi_resource *resource, + union aml_resource *aml) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - - ACPI_FUNCTION_TRACE("rs_fixed_memory32_stream"); - - /* The Descriptor Type field is static */ - - *buffer = ACPI_RDESC_TYPE_FIXED_MEMORY_32; - buffer += 1; - - /* The length field is static */ - - temp16 = 0x09; - - ACPI_MOVE_16_TO_16(buffer, &temp16); - buffer += 2; + ACPI_FUNCTION_TRACE("rs_set_fixed_memory32"); /* Set the Information Byte */ - temp8 = - (u8) (resource->data.fixed_memory32.read_write_attribute & 0x01); - *buffer = temp8; - buffer += 1; + aml->fixed_memory32.information = (u8) + (resource->data.fixed_memory32.read_write_attribute & 0x01); - /* Set the Range base address */ - - ACPI_MOVE_32_TO_32(buffer, - &resource->data.fixed_memory32.range_base_address); - buffer += 4; - - /* Set the range length */ - - ACPI_MOVE_32_TO_32(buffer, &resource->data.fixed_memory32.range_length); - buffer += 4; + /* + * Set the following contiguous fields in the AML descriptor: + * Base Address + * Range Length + */ + ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address, + &resource->data.fixed_memory32.address); + ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address_length, + &resource->data.fixed_memory32.address_length); - /* Return the number of bytes consumed in this operation */ + /* Complete the AML descriptor header */ - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_MEMORY32, + sizeof(struct aml_resource_fixed_memory32), + aml); return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c index fa7f5a85b61d..337a0f01cb23 100644 --- a/drivers/acpi/resources/rsmisc.c +++ b/drivers/acpi/resources/rsmisc.c @@ -49,641 +49,432 @@ ACPI_MODULE_NAME("rsmisc") /******************************************************************************* * - * FUNCTION: acpi_rs_generic_register_resource + * FUNCTION: acpi_rs_get_generic_reg * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. * ******************************************************************************/ acpi_status -acpi_rs_generic_register_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, - acpi_size * structure_size) +acpi_rs_get_generic_reg(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; - u16 temp16; - u8 temp8; - acpi_size struct_size = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_reg); + ACPI_FUNCTION_TRACE("rs_get_generic_reg"); - ACPI_FUNCTION_TRACE("rs_generic_register_resource"); - - /* Byte 0 is the Descriptor Type */ - - buffer += 1; - - /* Get the Descriptor Length field (Bytes 1-2) */ - - ACPI_MOVE_16_TO_16(&temp16, buffer); - buffer += 2; - - /* Validate the descriptor length */ - - if (temp16 != 12) { - return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); - } - - /* The number of bytes consumed is fixed (12 + 3) */ - - *bytes_consumed = 15; - - /* Fill out the structure */ - - output_struct->type = ACPI_RSTYPE_GENERIC_REG; - - /* Get space_id (Byte 3) */ - - temp8 = *buffer; - output_struct->data.generic_reg.space_id = temp8; - buffer += 1; - - /* Get register_bit_width (Byte 4) */ - - temp8 = *buffer; - output_struct->data.generic_reg.bit_width = temp8; - buffer += 1; - - /* Get register_bit_offset (Byte 5) */ - - temp8 = *buffer; - output_struct->data.generic_reg.bit_offset = temp8; - buffer += 1; - - /* Get address_size (Byte 6) */ - - temp8 = *buffer; - output_struct->data.generic_reg.address_size = temp8; - buffer += 1; - - /* Get register_address (Bytes 7-14) */ - - ACPI_MOVE_64_TO_64(&output_struct->data.generic_reg.address, buffer); - - /* Set the Length parameter */ - - output_struct->length = (u32) struct_size; - - /* Return the final size of the structure */ - - *structure_size = struct_size; + /* + * Get the following fields from the AML descriptor: + * Address Space ID + * Register Bit Width + * Register Bit Offset + * Access Size + * Register Address + */ + resource->data.generic_reg.space_id = aml->generic_reg.address_space_id; + resource->data.generic_reg.bit_width = aml->generic_reg.bit_width; + resource->data.generic_reg.bit_offset = aml->generic_reg.bit_offset; + resource->data.generic_reg.access_size = aml->generic_reg.access_size; + ACPI_MOVE_64_TO_64(&resource->data.generic_reg.address, + &aml->generic_reg.address); + + /* Complete the resource header */ + + resource->type = ACPI_RESOURCE_TYPE_GENERIC_REGISTER; + resource->length = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_generic_register_stream + * FUNCTION: acpi_rs_set_generic_reg * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - Pointer to where the number of bytes - * used in the output_buffer is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_generic_register_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_set_generic_reg(struct acpi_resource *resource, union aml_resource *aml) { - u8 *buffer = *output_buffer; - u16 temp16; - - ACPI_FUNCTION_TRACE("rs_generic_register_stream"); - - /* Set the Descriptor Type (Byte 0) */ - - *buffer = ACPI_RDESC_TYPE_GENERIC_REGISTER; - buffer += 1; - - /* Set the Descriptor Length (Bytes 1-2) */ - - temp16 = 12; - ACPI_MOVE_16_TO_16(buffer, &temp16); - buffer += 2; - - /* Set space_id (Byte 3) */ - - *buffer = (u8) resource->data.generic_reg.space_id; - buffer += 1; - - /* Set register_bit_width (Byte 4) */ - - *buffer = (u8) resource->data.generic_reg.bit_width; - buffer += 1; - - /* Set register_bit_offset (Byte 5) */ - - *buffer = (u8) resource->data.generic_reg.bit_offset; - buffer += 1; - - /* Set address_size (Byte 6) */ - - *buffer = (u8) resource->data.generic_reg.address_size; - buffer += 1; - - /* Set register_address (Bytes 7-14) */ + ACPI_FUNCTION_TRACE("rs_set_generic_reg"); - ACPI_MOVE_64_TO_64(buffer, &resource->data.generic_reg.address); - buffer += 8; - - /* Return the number of bytes consumed in this operation */ - - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + /* + * Set the following fields in the AML descriptor: + * Address Space ID + * Register Bit Width + * Register Bit Offset + * Access Size + * Register Address + */ + aml->generic_reg.address_space_id = + (u8) resource->data.generic_reg.space_id; + aml->generic_reg.bit_width = (u8) resource->data.generic_reg.bit_width; + aml->generic_reg.bit_offset = + (u8) resource->data.generic_reg.bit_offset; + aml->generic_reg.access_size = + (u8) resource->data.generic_reg.access_size; + ACPI_MOVE_64_TO_64(&aml->generic_reg.address, + &resource->data.generic_reg.address); + + /* Complete the AML descriptor header */ + + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_GENERIC_REGISTER, + sizeof(struct + aml_resource_generic_register), aml); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_end_tag_resource + * FUNCTION: acpi_rs_get_vendor * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. * ******************************************************************************/ acpi_status -acpi_rs_end_tag_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size) +acpi_rs_get_vendor(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource) { - struct acpi_resource *output_struct = (void *)*output_buffer; - acpi_size struct_size = ACPI_RESOURCE_LENGTH; - - ACPI_FUNCTION_TRACE("rs_end_tag_resource"); + u8 *aml_byte_data; - /* The number of bytes consumed is static */ + ACPI_FUNCTION_TRACE("rs_get_vendor"); - *bytes_consumed = 2; + /* Determine if this is a large or small vendor specific item */ - /* Fill out the structure */ + if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { + /* Large item, Point to the first vendor byte */ - output_struct->type = ACPI_RSTYPE_END_TAG; + aml_byte_data = + ((u8 *) aml) + sizeof(struct aml_resource_large_header); + } else { + /* Small item, Point to the first vendor byte */ - /* Set the Length parameter */ + aml_byte_data = + ((u8 *) aml) + sizeof(struct aml_resource_small_header); + } - output_struct->length = 0; + /* Copy the vendor-specific bytes */ - /* Return the final size of the structure */ + ACPI_MEMCPY(resource->data.vendor.byte_data, + aml_byte_data, aml_resource_length); + resource->data.vendor.byte_length = aml_resource_length; - *structure_size = struct_size; + /* + * In order for the struct_size to fall on a 32-bit boundary, + * calculate the length of the vendor string and expand the + * struct_size to the next 32-bit boundary. + */ + resource->type = ACPI_RESOURCE_TYPE_VENDOR; + resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) + + ACPI_ROUND_UP_to_32_bITS(aml_resource_length); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_end_tag_stream + * FUNCTION: acpi_rs_set_vendor * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - Pointer to where the number of bytes - * used in the output_buffer is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_end_tag_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_set_vendor(struct acpi_resource *resource, union aml_resource *aml) { - u8 *buffer = *output_buffer; - u8 temp8 = 0; + u32 resource_length; + u8 *source; + u8 *destination; - ACPI_FUNCTION_TRACE("rs_end_tag_stream"); + ACPI_FUNCTION_TRACE("rs_set_vendor"); - /* The Descriptor Type field is static */ + resource_length = resource->data.vendor.byte_length; + source = ACPI_CAST_PTR(u8, resource->data.vendor.byte_data); - *buffer = ACPI_RDESC_TYPE_END_TAG | 0x01; - buffer += 1; + /* Length determines if this is a large or small resource */ - /* - * Set the Checksum - zero means that the resource data is treated as if - * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) - */ - temp8 = 0; + if (resource_length > 7) { + /* Large item, get pointer to the data part of the descriptor */ + + destination = + ((u8 *) aml) + sizeof(struct aml_resource_large_header); + + /* Complete the AML descriptor header */ + + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_LARGE, + (u32) (resource_length + + sizeof(struct + aml_resource_large_header)), + aml); + } else { + /* Small item, get pointer to the data part of the descriptor */ - *buffer = temp8; - buffer += 1; + destination = + ((u8 *) aml) + sizeof(struct aml_resource_small_header); - /* Return the number of bytes consumed in this operation */ + /* Complete the AML descriptor header */ - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_SMALL, + (u32) (resource_length + + sizeof(struct + aml_resource_small_header)), + aml); + } + + /* Copy the vendor-specific bytes */ + + ACPI_MEMCPY(destination, source, resource_length); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_vendor_resource + * FUNCTION: acpi_rs_get_start_dpf * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. * ******************************************************************************/ acpi_status -acpi_rs_vendor_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size) +acpi_rs_get_start_dpf(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - acpi_size struct_size = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor); - - ACPI_FUNCTION_TRACE("rs_vendor_resource"); - - /* Dereference the Descriptor to find if this is a large or small item. */ + ACPI_FUNCTION_TRACE("rs_get_start_dpf"); - temp8 = *buffer; + /* Get the flags byte if present */ - if (temp8 & ACPI_RDESC_TYPE_LARGE) { - /* Large Item, point to the length field */ + if (aml_resource_length == 1) { + /* Get the Compatibility priority */ - buffer += 1; + resource->data.start_dpf.compatibility_priority = + (aml->start_dpf.flags & 0x03); - /* Dereference */ - - ACPI_MOVE_16_TO_16(&temp16, buffer); - - /* Calculate bytes consumed */ + if (resource->data.start_dpf.compatibility_priority >= 3) { + return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); + } - *bytes_consumed = (acpi_size) temp16 + 3; + /* Get the Performance/Robustness preference */ - /* Point to the first vendor byte */ + resource->data.start_dpf.performance_robustness = + ((aml->start_dpf.flags >> 2) & 0x03); - buffer += 2; + if (resource->data.start_dpf.performance_robustness >= 3) { + return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); + } } else { - /* Small Item, dereference the size */ - - temp16 = (u8) (*buffer & 0x07); - - /* Calculate bytes consumed */ + /* start_dependent_no_pri(), no flags byte, set defaults */ - *bytes_consumed = (acpi_size) temp16 + 1; - - /* Point to the first vendor byte */ + resource->data.start_dpf.compatibility_priority = + ACPI_ACCEPTABLE_CONFIGURATION; - buffer += 1; + resource->data.start_dpf.performance_robustness = + ACPI_ACCEPTABLE_CONFIGURATION; } - output_struct->type = ACPI_RSTYPE_VENDOR; - output_struct->data.vendor_specific.length = temp16; - - for (index = 0; index < temp16; index++) { - output_struct->data.vendor_specific.reserved[index] = *buffer; - buffer += 1; - } + /* Complete the resource header */ - /* - * In order for the struct_size to fall on a 32-bit boundary, - * calculate the length of the vendor string and expand the - * struct_size to the next 32-bit boundary. - */ - struct_size += ACPI_ROUND_UP_to_32_bITS(temp16); - - /* Set the Length parameter */ - - output_struct->length = (u32) struct_size; - - /* Return the final size of the structure */ - - *structure_size = struct_size; + resource->type = ACPI_RESOURCE_TYPE_START_DEPENDENT; + resource->length = + ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dependent); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_vendor_stream + * FUNCTION: acpi_rs_set_start_dpf * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - Pointer to where the number of bytes - * used in the output_buffer is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_vendor_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_set_start_dpf(struct acpi_resource *resource, union aml_resource *aml) { - u8 *buffer = *output_buffer; - u16 temp16 = 0; - u8 temp8 = 0; - u8 index; - - ACPI_FUNCTION_TRACE("rs_vendor_stream"); - - /* Dereference the length to find if this is a large or small item. */ - - if (resource->data.vendor_specific.length > 7) { - /* Large Item, Set the descriptor field and length bytes */ + ACPI_FUNCTION_TRACE("rs_set_start_dpf"); - *buffer = ACPI_RDESC_TYPE_LARGE_VENDOR; - buffer += 1; - - temp16 = (u16) resource->data.vendor_specific.length; - - ACPI_MOVE_16_TO_16(buffer, &temp16); - buffer += 2; + /* + * The descriptor type field is set based upon whether a byte is needed + * to contain Priority data. + */ + if (ACPI_ACCEPTABLE_CONFIGURATION == + resource->data.start_dpf.compatibility_priority && + ACPI_ACCEPTABLE_CONFIGURATION == + resource->data.start_dpf.performance_robustness) { + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT, + sizeof(struct + aml_resource_start_dependent_noprio), + aml); } else { - /* Small Item, Set the descriptor field */ - - temp8 = ACPI_RDESC_TYPE_SMALL_VENDOR; - temp8 |= (u8) resource->data.vendor_specific.length; - - *buffer = temp8; - buffer += 1; - } - - /* Loop through all of the Vendor Specific fields */ - - for (index = 0; index < resource->data.vendor_specific.length; index++) { - temp8 = resource->data.vendor_specific.reserved[index]; - - *buffer = temp8; - buffer += 1; + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT, + sizeof(struct + aml_resource_start_dependent), + aml); + + /* Set the Flags byte */ + + aml->start_dpf.flags = (u8) + (((resource->data.start_dpf. + performance_robustness & 0x03) << 2) | (resource->data. + start_dpf. + compatibility_priority + & 0x03)); } - - /* Return the number of bytes consumed in this operation */ - - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_start_depend_fns_resource + * FUNCTION: acpi_rs_get_end_dpf * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. * ******************************************************************************/ acpi_status -acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, - acpi_size * structure_size) +acpi_rs_get_end_dpf(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource) { - u8 *buffer = byte_stream_buffer; - struct acpi_resource *output_struct = (void *)*output_buffer; - u8 temp8 = 0; - acpi_size struct_size = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf); - - ACPI_FUNCTION_TRACE("rs_start_depend_fns_resource"); - - /* The number of bytes consumed are found in the descriptor (Bits:0-1) */ - - temp8 = *buffer; - - *bytes_consumed = (temp8 & 0x01) + 1; - - output_struct->type = ACPI_RSTYPE_START_DPF; - - /* Point to Byte 1 if it is used */ - - if (2 == *bytes_consumed) { - buffer += 1; - temp8 = *buffer; - - /* Check Compatibility priority */ - - output_struct->data.start_dpf.compatibility_priority = - temp8 & 0x03; - - if (3 == output_struct->data.start_dpf.compatibility_priority) { - return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); - } + ACPI_FUNCTION_TRACE("rs_get_end_dpf"); - /* Check Performance/Robustness preference */ + /* Complete the resource header */ - output_struct->data.start_dpf.performance_robustness = - (temp8 >> 2) & 0x03; - - if (3 == output_struct->data.start_dpf.performance_robustness) { - return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); - } - } else { - output_struct->data.start_dpf.compatibility_priority = - ACPI_ACCEPTABLE_CONFIGURATION; - - output_struct->data.start_dpf.performance_robustness = - ACPI_ACCEPTABLE_CONFIGURATION; - } - - /* Set the Length parameter */ - - output_struct->length = (u32) struct_size; - - /* Return the final size of the structure */ - - *structure_size = struct_size; + resource->type = ACPI_RESOURCE_TYPE_END_DEPENDENT; + resource->length = (u32) ACPI_RESOURCE_LENGTH; return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_end_depend_fns_resource + * FUNCTION: acpi_rs_set_end_dpf * - * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte - * stream - * bytes_consumed - Pointer to where the number of bytes - * consumed the byte_stream_buffer is - * returned - * output_buffer - Pointer to the return data buffer - * structure_size - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the output_buffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size) +acpi_rs_set_end_dpf(struct acpi_resource *resource, union aml_resource *aml) { - struct acpi_resource *output_struct = (void *)*output_buffer; - acpi_size struct_size = ACPI_RESOURCE_LENGTH; - - ACPI_FUNCTION_TRACE("rs_end_depend_fns_resource"); - - /* The number of bytes consumed is static */ - - *bytes_consumed = 1; + ACPI_FUNCTION_TRACE("rs_set_end_dpf"); - /* Fill out the structure */ + /* Complete the AML descriptor header */ - output_struct->type = ACPI_RSTYPE_END_DPF; - - /* Set the Length parameter */ - - output_struct->length = (u32) struct_size; - - /* Return the final size of the structure */ - - *structure_size = struct_size; + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_DEPENDENT, + sizeof(struct aml_resource_end_dependent), + aml); return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_start_depend_fns_stream + * FUNCTION: acpi_rs_get_end_tag * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - u32 pointer that is filled with - * the number of bytes of the - * output_buffer used + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * aml_resource_length - Length of the resource from the AML header + * Resource - Where the internal resource is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding + * internal resource descriptor, simplifying bitflags and handling + * alignment and endian issues if necessary. * ******************************************************************************/ acpi_status -acpi_rs_start_depend_fns_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_get_end_tag(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource) { - u8 *buffer = *output_buffer; - u8 temp8 = 0; - - ACPI_FUNCTION_TRACE("rs_start_depend_fns_stream"); + ACPI_FUNCTION_TRACE("rs_get_end_tag"); - /* - * The descriptor type field is set based upon whether a byte is needed - * to contain Priority data. - */ - if (ACPI_ACCEPTABLE_CONFIGURATION == - resource->data.start_dpf.compatibility_priority && - ACPI_ACCEPTABLE_CONFIGURATION == - resource->data.start_dpf.performance_robustness) { - *buffer = ACPI_RDESC_TYPE_START_DEPENDENT; - } else { - *buffer = ACPI_RDESC_TYPE_START_DEPENDENT | 0x01; - buffer += 1; - - /* Set the Priority Byte Definition */ + /* Complete the resource header */ - temp8 = 0; - temp8 = (u8) ((resource->data.start_dpf.performance_robustness & - 0x03) << 2); - temp8 |= (resource->data.start_dpf.compatibility_priority & - 0x03); - *buffer = temp8; - } - - buffer += 1; - - /* Return the number of bytes consumed in this operation */ - - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + resource->type = ACPI_RESOURCE_TYPE_END_TAG; + resource->length = ACPI_RESOURCE_LENGTH; return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_end_depend_fns_stream + * FUNCTION: acpi_rs_set_end_tag * - * PARAMETERS: Resource - Pointer to the resource linked list - * output_buffer - Pointer to the user's return buffer - * bytes_consumed - Pointer to where the number of bytes - * used in the output_buffer is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ acpi_status -acpi_rs_end_depend_fns_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed) +acpi_rs_set_end_tag(struct acpi_resource *resource, union aml_resource *aml) { - u8 *buffer = *output_buffer; - - ACPI_FUNCTION_TRACE("rs_end_depend_fns_stream"); + ACPI_FUNCTION_TRACE("rs_set_end_tag"); - /* The Descriptor Type field is static */ - - *buffer = ACPI_RDESC_TYPE_END_DEPENDENT; - buffer += 1; + /* + * Set the Checksum - zero means that the resource data is treated as if + * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) + */ + aml->end_tag.checksum = 0; - /* Return the number of bytes consumed in this operation */ + /* Complete the AML descriptor header */ - *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); + acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_TAG, + sizeof(struct aml_resource_end_tag), aml); return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c index 4446778eaf79..9d503de1a349 100644 --- a/drivers/acpi/resources/rsutils.c +++ b/drivers/acpi/resources/rsutils.c @@ -48,6 +48,438 @@ #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME("rsutils") +/******************************************************************************* + * + * FUNCTION: acpi_rs_move_data + * + * PARAMETERS: Destination - Pointer to the destination descriptor + * Source - Pointer to the source descriptor + * item_count - How many items to move + * move_type - Byte width + * + * RETURN: None + * + * DESCRIPTION: Move multiple data items from one descriptor to another. Handles + * alignment issues and endian issues if necessary, as configured + * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) + * + ******************************************************************************/ +void +acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) +{ + acpi_native_uint i; + + /* One move per item */ + + for (i = 0; i < item_count; i++) { + switch (move_type) { + case ACPI_MOVE_TYPE_16_TO_32: + ACPI_MOVE_16_TO_32(&((u32 *) destination)[i], + &((u16 *) source)[i]); + break; + + case ACPI_MOVE_TYPE_32_TO_16: + ACPI_MOVE_32_TO_16(&((u16 *) destination)[i], + &((u32 *) source)[i]); + break; + + case ACPI_MOVE_TYPE_32_TO_32: + ACPI_MOVE_32_TO_32(&((u32 *) destination)[i], + &((u32 *) source)[i]); + break; + + case ACPI_MOVE_TYPE_64_TO_64: + ACPI_MOVE_64_TO_64(&((u64 *) destination)[i], + &((u64 *) source)[i]); + break; + + default: + return; + } + } +} + +/******************************************************************************* + * + * FUNCTION: acpi_rs_get_resource_info + * + * PARAMETERS: resource_type - Byte 0 of a resource descriptor + * + * RETURN: Pointer to the resource conversion handler + * + * DESCRIPTION: Extract the Resource Type/Name from the first byte of + * a resource descriptor. + * + ******************************************************************************/ + +struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type) +{ + struct acpi_resource_info *size_info; + + ACPI_FUNCTION_ENTRY(); + + /* Determine if this is a small or large resource */ + + if (resource_type & ACPI_RESOURCE_NAME_LARGE) { + /* Large Resource Type -- bits 6:0 contain the name */ + + if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { + return (NULL); + } + + size_info = &acpi_gbl_lg_resource_info[(resource_type & + ACPI_RESOURCE_NAME_LARGE_MASK)]; + } else { + /* Small Resource Type -- bits 6:3 contain the name */ + + size_info = &acpi_gbl_sm_resource_info[((resource_type & + ACPI_RESOURCE_NAME_SMALL_MASK) + >> 3)]; + } + + /* Zero entry indicates an invalid resource type */ + + if (!size_info->minimum_internal_struct_length) { + return (NULL); + } + + return (size_info); +} + +/******************************************************************************* + * + * FUNCTION: acpi_rs_get_resource_length + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Byte Length + * + * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By + * definition, this does not include the size of the descriptor + * header or the length field itself. + * + ******************************************************************************/ + +u16 acpi_rs_get_resource_length(union aml_resource * aml) +{ + u16 resource_length; + + ACPI_FUNCTION_ENTRY(); + + /* Determine if this is a small or large resource */ + + if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { + /* Large Resource type -- bytes 1-2 contain the 16-bit length */ + + ACPI_MOVE_16_TO_16(&resource_length, + &aml->large_header.resource_length); + + } else { + /* Small Resource type -- bits 2:0 of byte 0 contain the length */ + + resource_length = (u16) (aml->small_header.descriptor_type & + ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); + } + + return (resource_length); +} + +/******************************************************************************* + * + * FUNCTION: acpi_rs_get_descriptor_length + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Byte length + * + * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the + * length of the descriptor header and the length field itself. + * Used to walk descriptor lists. + * + ******************************************************************************/ + +u32 acpi_rs_get_descriptor_length(union aml_resource * aml) +{ + u32 descriptor_length; + + ACPI_FUNCTION_ENTRY(); + + /* Determine if this is a small or large resource */ + + if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { + /* Large Resource type -- bytes 1-2 contain the 16-bit length */ + + ACPI_MOVE_16_TO_32(&descriptor_length, + &aml->large_header.resource_length); + descriptor_length += sizeof(struct aml_resource_large_header); + + } else { + /* Small Resource type -- bits 2:0 of byte 0 contain the length */ + + descriptor_length = (u32) (aml->small_header.descriptor_type & + ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); + descriptor_length += sizeof(struct aml_resource_small_header); + } + + return (descriptor_length); +} + +/******************************************************************************* + * + * FUNCTION: acpi_rs_set_resource_header + * + * PARAMETERS: descriptor_type - Byte to be inserted as the type + * total_length - Length of the AML descriptor, including + * the header and length fields. + * Aml - Pointer to the raw AML descriptor + * + * RETURN: None + * + * DESCRIPTION: Set the descriptor_type and resource_length fields of an AML + * resource descriptor, both Large and Small descriptors are + * supported automatically + * + ******************************************************************************/ + +void +acpi_rs_set_resource_header(u8 descriptor_type, + acpi_size total_length, union aml_resource *aml) +{ + u16 resource_length; + + ACPI_FUNCTION_ENTRY(); + + /* Set the descriptor type */ + + aml->small_header.descriptor_type = descriptor_type; + + /* Determine if this is a small or large resource */ + + if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { + /* Large Resource type -- bytes 1-2 contain the 16-bit length */ + + resource_length = + (u16) (total_length - + sizeof(struct aml_resource_large_header)); + + /* Insert length into the Large descriptor length field */ + + ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, + &resource_length); + } else { + /* Small Resource type -- bits 2:0 of byte 0 contain the length */ + + resource_length = + (u16) (total_length - + sizeof(struct aml_resource_small_header)); + + /* Insert length into the descriptor type byte */ + + aml->small_header.descriptor_type |= (u8) resource_length; + } +} + +/******************************************************************************* + * + * FUNCTION: acpi_rs_get_resource_type + * + * PARAMETERS: resource_type - Byte 0 of a resource descriptor + * + * RETURN: The Resource Type with no extraneous bits (except the + * Large/Small descriptor bit -- this is left alone) + * + * DESCRIPTION: Extract the Resource Type/Name from the first byte of + * a resource descriptor. + * + ******************************************************************************/ + +u8 acpi_rs_get_resource_type(u8 resource_type) +{ + ACPI_FUNCTION_ENTRY(); + + /* Determine if this is a small or large resource */ + + if (resource_type & ACPI_RESOURCE_NAME_LARGE) { + /* Large Resource Type -- bits 6:0 contain the name */ + + return (resource_type); + } else { + /* Small Resource Type -- bits 6:3 contain the name */ + + return ((u8) (resource_type & ACPI_RESOURCE_NAME_SMALL_MASK)); + } +} + +/******************************************************************************* + * + * FUNCTION: acpi_rs_strcpy + * + * PARAMETERS: Destination - Pointer to the destination string + * Source - Pointer to the source string + * + * RETURN: String length, including NULL terminator + * + * DESCRIPTION: Local string copy that returns the string length, saving a + * strcpy followed by a strlen. + * + ******************************************************************************/ + +static u16 acpi_rs_strcpy(char *destination, char *source) +{ + u16 i; + + ACPI_FUNCTION_ENTRY(); + + for (i = 0; source[i]; i++) { + destination[i] = source[i]; + } + + destination[i] = 0; + + /* Return string length including the NULL terminator */ + + return ((u16) (i + 1)); +} + +/******************************************************************************* + * + * FUNCTION: acpi_rs_get_resource_source + * + * PARAMETERS: resource_length - Length field of the descriptor + * minimum_length - Minimum length of the descriptor (minus + * any optional fields) + * resource_source - Where the resource_source is returned + * Aml - Pointer to the raw AML descriptor + * string_ptr - (optional) where to store the actual + * resource_source string + * + * RETURN: Length of the string plus NULL terminator, rounded up to 32 bit + * + * DESCRIPTION: Copy the optional resource_source data from a raw AML descriptor + * to an internal resource descriptor + * + ******************************************************************************/ + +u16 +acpi_rs_get_resource_source(u16 resource_length, + acpi_size minimum_length, + struct acpi_resource_source * resource_source, + union aml_resource * aml, char *string_ptr) +{ + acpi_size total_length; + u8 *aml_resource_source; + + ACPI_FUNCTION_ENTRY(); + + total_length = + resource_length + sizeof(struct aml_resource_large_header); + aml_resource_source = ((u8 *) aml) + minimum_length; + + /* + * resource_source is present if the length of the descriptor is longer than + * the minimum length. + * + * Note: Some resource descriptors will have an additional null, so + * we add 1 to the minimum length. + */ + if (total_length > (minimum_length + 1)) { + /* Get the resource_source_index */ + + resource_source->index = aml_resource_source[0]; + + resource_source->string_ptr = string_ptr; + if (!string_ptr) { + /* + * String destination pointer is not specified; Set the String + * pointer to the end of the current resource_source structure. + */ + resource_source->string_ptr = (char *) + ((u8 *) resource_source) + + sizeof(struct acpi_resource_source); + } + + /* Copy the resource_source string to the destination */ + + resource_source->string_length = + acpi_rs_strcpy(resource_source->string_ptr, + (char *)&aml_resource_source[1]); + + /* + * In order for the struct_size to fall on a 32-bit boundary, + * calculate the length of the string and expand the + * struct_size to the next 32-bit boundary. + */ + return ((u16) + ACPI_ROUND_UP_to_32_bITS(resource_source-> + string_length)); + } else { + /* resource_source is not present */ + + resource_source->index = 0; + resource_source->string_length = 0; + resource_source->string_ptr = NULL; + return (0); + } +} + +/******************************************************************************* + * + * FUNCTION: acpi_rs_set_resource_source + * + * PARAMETERS: Aml - Pointer to the raw AML descriptor + * minimum_length - Minimum length of the descriptor (minus + * any optional fields) + * resource_source - Internal resource_source + + * + * RETURN: Total length of the AML descriptor + * + * DESCRIPTION: Convert an optoinal resource_source from internal format to a + * raw AML resource descriptor + * + ******************************************************************************/ + +acpi_size +acpi_rs_set_resource_source(union aml_resource * aml, + acpi_size minimum_length, + struct acpi_resource_source * resource_source) +{ + u8 *aml_resource_source; + acpi_size descriptor_length; + + ACPI_FUNCTION_ENTRY(); + + descriptor_length = minimum_length; + + /* Non-zero string length indicates presence of a resource_source */ + + if (resource_source->string_length) { + /* Point to the end of the AML descriptor */ + + aml_resource_source = ((u8 *) aml) + minimum_length; + + /* Copy the resource_source_index */ + + aml_resource_source[0] = (u8) resource_source->index; + + /* Copy the resource_source string */ + + ACPI_STRCPY((char *)&aml_resource_source[1], + resource_source->string_ptr); + + /* + * Add the length of the string (+ 1 for null terminator) to the + * final descriptor length + */ + descriptor_length += + ((acpi_size) resource_source->string_length + 1); + } + + /* Return the new total length of the AML descriptor */ + + return (descriptor_length); +} + /******************************************************************************* * * FUNCTION: acpi_rs_get_prt_method_data @@ -65,8 +497,9 @@ ACPI_MODULE_NAME("rsutils") * and the contents of the callers buffer is undefined. * ******************************************************************************/ + acpi_status -acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) +acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer * ret_buffer) { union acpi_operand_object *obj_desc; acpi_status status; @@ -284,7 +717,7 @@ acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *in_buffer) * Convert the linked list into a byte stream */ buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; - status = acpi_rs_create_byte_stream(in_buffer->pointer, &buffer); + status = acpi_rs_create_aml_resources(in_buffer->pointer, &buffer); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c index 1a87c4c7bd97..9d179beb17ae 100644 --- a/drivers/acpi/resources/rsxface.c +++ b/drivers/acpi/resources/rsxface.c @@ -59,9 +59,9 @@ ACPI_MODULE_NAME("rsxface") ACPI_COPY_FIELD(out, in, max_address_fixed); \ ACPI_COPY_FIELD(out, in, attribute); \ ACPI_COPY_FIELD(out, in, granularity); \ - ACPI_COPY_FIELD(out, in, min_address_range); \ - ACPI_COPY_FIELD(out, in, max_address_range); \ - ACPI_COPY_FIELD(out, in, address_translation_offset); \ + ACPI_COPY_FIELD(out, in, minimum); \ + ACPI_COPY_FIELD(out, in, maximum); \ + ACPI_COPY_FIELD(out, in, translation_offset); \ ACPI_COPY_FIELD(out, in, address_length); \ ACPI_COPY_FIELD(out, in, resource_source); /******************************************************************************* @@ -269,7 +269,7 @@ acpi_walk_resources(acpi_handle device_handle, /* Walk the resource list */ for (;;) { - if (!resource || resource->type == ACPI_RSTYPE_END_TAG) { + if (!resource || resource->type == ACPI_RESOURCE_TYPE_END_TAG) { break; } @@ -382,19 +382,19 @@ acpi_resource_to_address64(struct acpi_resource *resource, struct acpi_resource_address32 *address32; switch (resource->type) { - case ACPI_RSTYPE_ADDRESS16: + case ACPI_RESOURCE_TYPE_ADDRESS16: address16 = (struct acpi_resource_address16 *)&resource->data; ACPI_COPY_ADDRESS(out, address16); break; - case ACPI_RSTYPE_ADDRESS32: + case ACPI_RESOURCE_TYPE_ADDRESS32: address32 = (struct acpi_resource_address32 *)&resource->data; ACPI_COPY_ADDRESS(out, address32); break; - case ACPI_RSTYPE_ADDRESS64: + case ACPI_RESOURCE_TYPE_ADDRESS64: /* Simple copy for 64 bit source */ diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c index ad0252c2f7db..3cee0cee4cc2 100644 --- a/drivers/acpi/tables/tbrsdt.c +++ b/drivers/acpi/tables/tbrsdt.c @@ -251,7 +251,7 @@ acpi_status acpi_tb_get_table_rsdt(void) } ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "RSDP located at %p, points to RSDT physical=%8.8X%8.8X \n", + "RSDP located at %p, points to RSDT physical=%8.8X%8.8X\n", acpi_gbl_RSDP, ACPI_FORMAT_UINT64(address.pointer.value))); diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c index 3b8a7e063e8a..b01a4b2ae7da 100644 --- a/drivers/acpi/tables/tbxfroot.c +++ b/drivers/acpi/tables/tbxfroot.c @@ -251,7 +251,7 @@ acpi_get_firmware_table(acpi_string signature, acpi_tb_get_rsdt_address(&address); ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", + "RSDP located at %p, RSDT physical=%8.8X%8.8X\n", acpi_gbl_RSDP, ACPI_FORMAT_UINT64(address.pointer.value))); diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c index 068450b36475..dc7f24b3a1c0 100644 --- a/drivers/acpi/utilities/utalloc.c +++ b/drivers/acpi/utilities/utalloc.c @@ -304,7 +304,7 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line) if (!size) { _ACPI_REPORT_ERROR(module, line, component, - ("ut_allocate: Attempt to allocate zero bytes\n")); + ("ut_allocate: Attempt to allocate zero bytes, allocating 1 byte\n")); size = 1; } @@ -347,8 +347,8 @@ void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line) if (!size) { _ACPI_REPORT_ERROR(module, line, component, - ("ut_callocate: Attempt to allocate zero bytes\n")); - return_PTR(NULL); + ("ut_callocate: Attempt to allocate zero bytes, allocating 1 byte\n")); + size = 1; } allocation = acpi_os_allocate(size); diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index 399e64b51886..7f72839841ca 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c @@ -825,6 +825,9 @@ void acpi_ut_init_globals(void) acpi_gbl_ps_find_count = 0; acpi_gbl_acpi_hardware_present = TRUE; acpi_gbl_owner_id_mask = 0; + acpi_gbl_trace_method_name = 0; + acpi_gbl_trace_dbg_level = 0; + acpi_gbl_trace_dbg_layer = 0; acpi_gbl_debugger_configuration = DEBUGGER_THREADING; acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index aa1dcd851f89..b57afa7421e8 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -811,15 +811,15 @@ u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc) while (buffer < end_buffer) { buffer_byte = *buffer; - if (buffer_byte & ACPI_RDESC_TYPE_LARGE) { + if (buffer_byte & ACPI_RESOURCE_NAME_LARGE) { /* Large Descriptor - Length is next 2 bytes */ buffer += ((*(buffer + 1) | (*(buffer + 2) << 8)) + 3); } else { /* Small Descriptor. End Tag will be found here */ - if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == - ACPI_RDESC_TYPE_END_TAG) { + if ((buffer_byte & ACPI_RESOURCE_NAME_SMALL_MASK) == + ACPI_RESOURCE_NAME_END_TAG) { /* Found the end tag descriptor, all done. */ return (buffer); diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index 5172d4e1236c..66a2fee06eb9 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -927,9 +927,9 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data) if (ACPI_SUCCESS(status)) { unsigned long size; - size = addr.max_address_range - addr.min_address_range + 1; - hdp->hd_phys_address = addr.min_address_range; - hdp->hd_address = ioremap(addr.min_address_range, size); + size = addr.maximum - addr.minimum + 1; + hdp->hd_phys_address = addr.minimum; + hdp->hd_address = ioremap(addr.minimum, size); if (hpet_is_known(hdp)) { printk(KERN_DEBUG "%s: 0x%lx is busy\n", @@ -937,15 +937,15 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data) iounmap(hdp->hd_address); return -EBUSY; } - } else if (res->type == ACPI_RSTYPE_FIXED_MEM32) { - struct acpi_resource_fixed_mem32 *fixmem32; + } else if (res->type == ACPI_RESOURCE_TYPE_FIXED_MEMORY32) { + struct acpi_resource_fixed_memory32 *fixmem32; fixmem32 = &res->data.fixed_memory32; if (!fixmem32) return -EINVAL; - hdp->hd_phys_address = fixmem32->range_base_address; - hdp->hd_address = ioremap(fixmem32->range_base_address, + hdp->hd_phys_address = fixmem32->address; + hdp->hd_address = ioremap(fixmem32->address, HPET_RANGE_SIZE); if (hpet_is_known(hdp)) { @@ -954,20 +954,20 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data) iounmap(hdp->hd_address); return -EBUSY; } - } else if (res->type == ACPI_RSTYPE_EXT_IRQ) { - struct acpi_resource_ext_irq *irqp; + } else if (res->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ) { + struct acpi_resource_extended_irq *irqp; int i; irqp = &res->data.extended_irq; - if (irqp->number_of_interrupts > 0) { - hdp->hd_nirqs = irqp->number_of_interrupts; + if (irqp->interrupt_count > 0) { + hdp->hd_nirqs = irqp->interrupt_count; for (i = 0; i < hdp->hd_nirqs; i++) { int rc = acpi_register_gsi(irqp->interrupts[i], - irqp->edge_level, - irqp->active_high_low); + irqp->triggering, + irqp->polarity); if (rc < 0) return AE_ERROR; hdp->hd_irq[i] = rc; diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 15ec05f69ddd..f4adebde6155 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -3,7 +3,7 @@ * * Copyright (c) 2004 Matthieu Castet * Copyright (c) 2004 Li Shaohua - * + * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2, or (at your option) any @@ -32,17 +32,17 @@ /* * Allocated Resources */ -static int irq_flags(int edge_level, int active_high_low) +static int irq_flags(int triggering, int polarity) { int flag; - if (edge_level == ACPI_LEVEL_SENSITIVE) { - if(active_high_low == ACPI_ACTIVE_LOW) + if (triggering == ACPI_LEVEL_SENSITIVE) { + if(polarity == ACPI_ACTIVE_LOW) flag = IORESOURCE_IRQ_LOWLEVEL; else flag = IORESOURCE_IRQ_HIGHLEVEL; } else { - if(active_high_low == ACPI_ACTIVE_LOW) + if(polarity == ACPI_ACTIVE_LOW) flag = IORESOURCE_IRQ_LOWEDGE; else flag = IORESOURCE_IRQ_HIGHEDGE; @@ -50,31 +50,31 @@ static int irq_flags(int edge_level, int active_high_low) return flag; } -static void decode_irq_flags(int flag, int *edge_level, int *active_high_low) +static void decode_irq_flags(int flag, int *triggering, int *polarity) { switch (flag) { case IORESOURCE_IRQ_LOWLEVEL: - *edge_level = ACPI_LEVEL_SENSITIVE; - *active_high_low = ACPI_ACTIVE_LOW; + *triggering = ACPI_LEVEL_SENSITIVE; + *polarity = ACPI_ACTIVE_LOW; break; case IORESOURCE_IRQ_HIGHLEVEL: - *edge_level = ACPI_LEVEL_SENSITIVE; - *active_high_low = ACPI_ACTIVE_HIGH; + *triggering = ACPI_LEVEL_SENSITIVE; + *polarity = ACPI_ACTIVE_HIGH; break; case IORESOURCE_IRQ_LOWEDGE: - *edge_level = ACPI_EDGE_SENSITIVE; - *active_high_low = ACPI_ACTIVE_LOW; + *triggering = ACPI_EDGE_SENSITIVE; + *polarity = ACPI_ACTIVE_LOW; break; case IORESOURCE_IRQ_HIGHEDGE: - *edge_level = ACPI_EDGE_SENSITIVE; - *active_high_low = ACPI_ACTIVE_HIGH; + *triggering = ACPI_EDGE_SENSITIVE; + *polarity = ACPI_ACTIVE_HIGH; break; } } static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi, - int edge_level, int active_high_low) + int triggering, int polarity) { int i = 0; int irq; @@ -89,7 +89,7 @@ pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi, return; res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag - irq = acpi_register_gsi(gsi, edge_level, active_high_low); + irq = acpi_register_gsi(gsi, triggering, polarity); if (irq < 0) { res->irq_resource[i].flags |= IORESOURCE_DISABLED; return; @@ -164,73 +164,73 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, int i; switch (res->type) { - case ACPI_RSTYPE_IRQ: + case ACPI_RESOURCE_TYPE_IRQ: /* * Per spec, only one interrupt per descriptor is allowed in * _CRS, but some firmware violates this, so parse them all. */ - for (i = 0; i < res->data.irq.number_of_interrupts; i++) { + for (i = 0; i < res->data.irq.interrupt_count; i++) { pnpacpi_parse_allocated_irqresource(res_table, res->data.irq.interrupts[i], - res->data.irq.edge_level, - res->data.irq.active_high_low); + res->data.irq.triggering, + res->data.irq.polarity); } break; - case ACPI_RSTYPE_EXT_IRQ: - for (i = 0; i < res->data.extended_irq.number_of_interrupts; i++) { + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + for (i = 0; i < res->data.extended_irq.interrupt_count; i++) { pnpacpi_parse_allocated_irqresource(res_table, res->data.extended_irq.interrupts[i], - res->data.extended_irq.edge_level, - res->data.extended_irq.active_high_low); + res->data.extended_irq.triggering, + res->data.extended_irq.polarity); } break; - case ACPI_RSTYPE_DMA: - if (res->data.dma.number_of_channels > 0) - pnpacpi_parse_allocated_dmaresource(res_table, + case ACPI_RESOURCE_TYPE_DMA: + if (res->data.dma.channel_count > 0) + pnpacpi_parse_allocated_dmaresource(res_table, res->data.dma.channels[0]); break; - case ACPI_RSTYPE_IO: - pnpacpi_parse_allocated_ioresource(res_table, - res->data.io.min_base_address, - res->data.io.range_length); + case ACPI_RESOURCE_TYPE_IO: + pnpacpi_parse_allocated_ioresource(res_table, + res->data.io.minimum, + res->data.io.address_length); break; - case ACPI_RSTYPE_FIXED_IO: - pnpacpi_parse_allocated_ioresource(res_table, - res->data.fixed_io.base_address, - res->data.fixed_io.range_length); + case ACPI_RESOURCE_TYPE_FIXED_IO: + pnpacpi_parse_allocated_ioresource(res_table, + res->data.fixed_io.address, + res->data.fixed_io.address_length); break; - case ACPI_RSTYPE_MEM24: - pnpacpi_parse_allocated_memresource(res_table, - res->data.memory24.min_base_address, - res->data.memory24.range_length); + case ACPI_RESOURCE_TYPE_MEMORY24: + pnpacpi_parse_allocated_memresource(res_table, + res->data.memory24.minimum, + res->data.memory24.address_length); break; - case ACPI_RSTYPE_MEM32: - pnpacpi_parse_allocated_memresource(res_table, - res->data.memory32.min_base_address, - res->data.memory32.range_length); + case ACPI_RESOURCE_TYPE_MEMORY32: + pnpacpi_parse_allocated_memresource(res_table, + res->data.memory32.minimum, + res->data.memory32.address_length); break; - case ACPI_RSTYPE_FIXED_MEM32: - pnpacpi_parse_allocated_memresource(res_table, - res->data.fixed_memory32.range_base_address, - res->data.fixed_memory32.range_length); + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: + pnpacpi_parse_allocated_memresource(res_table, + res->data.fixed_memory32.address, + res->data.fixed_memory32.address_length); break; - case ACPI_RSTYPE_ADDRESS16: - pnpacpi_parse_allocated_memresource(res_table, - res->data.address16.min_address_range, + case ACPI_RESOURCE_TYPE_ADDRESS16: + pnpacpi_parse_allocated_memresource(res_table, + res->data.address16.minimum, res->data.address16.address_length); break; - case ACPI_RSTYPE_ADDRESS32: - pnpacpi_parse_allocated_memresource(res_table, - res->data.address32.min_address_range, + case ACPI_RESOURCE_TYPE_ADDRESS32: + pnpacpi_parse_allocated_memresource(res_table, + res->data.address32.minimum, res->data.address32.address_length); break; - case ACPI_RSTYPE_ADDRESS64: - pnpacpi_parse_allocated_memresource(res_table, - res->data.address64.min_address_range, + case ACPI_RESOURCE_TYPE_ADDRESS64: + pnpacpi_parse_allocated_memresource(res_table, + res->data.address64.minimum, res->data.address64.address_length); break; - case ACPI_RSTYPE_VENDOR: + case ACPI_RESOURCE_TYPE_VENDOR: break; default: pnp_warn("PnPACPI: unknown resource type %d", res->type); @@ -253,13 +253,13 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso int i; struct pnp_dma * dma; - if (p->number_of_channels == 0) + if (p->channel_count == 0) return; dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); if (!dma) return; - for(i = 0; i < p->number_of_channels; i++) + for(i = 0; i < p->channel_count; i++) dma->map |= 1 << p->channels[i]; dma->flags = 0; if (p->bus_master) @@ -309,37 +309,37 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option, int i; struct pnp_irq * irq; - if (p->number_of_interrupts == 0) + if (p->interrupt_count == 0) return; irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); if (!irq) return; - for(i = 0; i < p->number_of_interrupts; i++) + for(i = 0; i < p->interrupt_count; i++) if (p->interrupts[i]) __set_bit(p->interrupts[i], irq->map); - irq->flags = irq_flags(p->edge_level, p->active_high_low); + irq->flags = irq_flags(p->triggering, p->polarity); pnp_register_irq_resource(option, irq); return; } static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, - struct acpi_resource_ext_irq *p) + struct acpi_resource_extended_irq *p) { int i; struct pnp_irq * irq; - if (p->number_of_interrupts == 0) + if (p->interrupt_count == 0) return; irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); if (!irq) return; - for(i = 0; i < p->number_of_interrupts; i++) + for(i = 0; i < p->interrupt_count; i++) if (p->interrupts[i]) __set_bit(p->interrupts[i], irq->map); - irq->flags = irq_flags(p->edge_level, p->active_high_low); + irq->flags = irq_flags(p->triggering, p->polarity); pnp_register_irq_resource(option, irq); return; @@ -351,16 +351,16 @@ pnpacpi_parse_port_option(struct pnp_option *option, { struct pnp_port * port; - if (io->range_length == 0) + if (io->address_length == 0) return; port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); if (!port) return; - port->min = io->min_base_address; - port->max = io->max_base_address; + port->min = io->minimum; + port->max = io->maximum; port->align = io->alignment; - port->size = io->range_length; - port->flags = ACPI_DECODE_16 == io->io_decode ? + port->size = io->address_length; + port->flags = ACPI_DECODE_16 == io->io_decode ? PNP_PORT_FLAG_16BITADDR : 0; pnp_register_port_resource(option,port); return; @@ -372,13 +372,13 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option, { struct pnp_port * port; - if (io->range_length == 0) + if (io->address_length == 0) return; port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); if (!port) return; - port->min = port->max = io->base_address; - port->size = io->range_length; + port->min = port->max = io->address; + port->size = io->address_length; port->align = 0; port->flags = PNP_PORT_FLAG_FIXED; pnp_register_port_resource(option,port); @@ -387,19 +387,19 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option, static void pnpacpi_parse_mem24_option(struct pnp_option *option, - struct acpi_resource_mem24 *p) + struct acpi_resource_memory24 *p) { struct pnp_mem * mem; - if (p->range_length == 0) + if (p->address_length == 0) return; mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); if (!mem) return; - mem->min = p->min_base_address; - mem->max = p->max_base_address; + mem->min = p->minimum; + mem->max = p->maximum; mem->align = p->alignment; - mem->size = p->range_length; + mem->size = p->address_length; mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? IORESOURCE_MEM_WRITEABLE : 0; @@ -410,19 +410,19 @@ pnpacpi_parse_mem24_option(struct pnp_option *option, static void pnpacpi_parse_mem32_option(struct pnp_option *option, - struct acpi_resource_mem32 *p) + struct acpi_resource_memory32 *p) { struct pnp_mem * mem; - if (p->range_length == 0) + if (p->address_length == 0) return; mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); if (!mem) return; - mem->min = p->min_base_address; - mem->max = p->max_base_address; + mem->min = p->minimum; + mem->max = p->maximum; mem->align = p->alignment; - mem->size = p->range_length; + mem->size = p->address_length; mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? IORESOURCE_MEM_WRITEABLE : 0; @@ -433,17 +433,17 @@ pnpacpi_parse_mem32_option(struct pnp_option *option, static void pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, - struct acpi_resource_fixed_mem32 *p) + struct acpi_resource_fixed_memory32 *p) { struct pnp_mem * mem; - if (p->range_length == 0) + if (p->address_length == 0) return; mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); if (!mem) return; - mem->min = mem->max = p->range_base_address; - mem->size = p->range_length; + mem->min = mem->max = p->address; + mem->size = p->address_length; mem->align = 0; mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? @@ -459,7 +459,7 @@ struct acpipnp_parse_option_s { struct pnp_dev *dev; }; -static acpi_status pnpacpi_option_resource(struct acpi_resource *res, +static acpi_status pnpacpi_option_resource(struct acpi_resource *res, void *data) { int priority = 0; @@ -468,34 +468,34 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res, struct pnp_option *option = parse_data->option; switch (res->type) { - case ACPI_RSTYPE_IRQ: + case ACPI_RESOURCE_TYPE_IRQ: pnpacpi_parse_irq_option(option, &res->data.irq); break; - case ACPI_RSTYPE_EXT_IRQ: + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: pnpacpi_parse_ext_irq_option(option, &res->data.extended_irq); break; - case ACPI_RSTYPE_DMA: + case ACPI_RESOURCE_TYPE_DMA: pnpacpi_parse_dma_option(option, &res->data.dma); break; - case ACPI_RSTYPE_IO: + case ACPI_RESOURCE_TYPE_IO: pnpacpi_parse_port_option(option, &res->data.io); break; - case ACPI_RSTYPE_FIXED_IO: + case ACPI_RESOURCE_TYPE_FIXED_IO: pnpacpi_parse_fixed_port_option(option, &res->data.fixed_io); break; - case ACPI_RSTYPE_MEM24: + case ACPI_RESOURCE_TYPE_MEMORY24: pnpacpi_parse_mem24_option(option, &res->data.memory24); break; - case ACPI_RSTYPE_MEM32: + case ACPI_RESOURCE_TYPE_MEMORY32: pnpacpi_parse_mem32_option(option, &res->data.memory32); break; - case ACPI_RSTYPE_FIXED_MEM32: + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: pnpacpi_parse_fixed_mem32_option(option, &res->data.fixed_memory32); break; - case ACPI_RSTYPE_START_DPF: + case ACPI_RESOURCE_TYPE_START_DEPENDENT: switch (res->data.start_dpf.compatibility_priority) { case ACPI_GOOD_CONFIGURATION: priority = PNP_RES_PRIORITY_PREFERRED; @@ -518,7 +518,7 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res, return AE_ERROR; parse_data->option = option; break; - case ACPI_RSTYPE_END_DPF: + case ACPI_RESOURCE_TYPE_END_DEPENDENT: /*only one EndDependentFn is allowed*/ if (!parse_data->option_independent) { pnp_warn("PnPACPI: more than one EndDependentFn"); @@ -535,7 +535,7 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res, return AE_OK; } -acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, +acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, struct pnp_dev *dev) { acpi_status status; @@ -546,7 +546,7 @@ acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, return AE_ERROR; parse_data.option_independent = parse_data.option; parse_data.dev = dev; - status = acpi_walk_resources(handle, METHOD_NAME__PRS, + status = acpi_walk_resources(handle, METHOD_NAME__PRS, pnpacpi_option_resource, &parse_data); return status; @@ -560,18 +560,18 @@ static acpi_status pnpacpi_count_resources(struct acpi_resource *res, { int *res_cnt = (int *)data; switch (res->type) { - case ACPI_RSTYPE_IRQ: - case ACPI_RSTYPE_EXT_IRQ: - case ACPI_RSTYPE_DMA: - case ACPI_RSTYPE_IO: - case ACPI_RSTYPE_FIXED_IO: - case ACPI_RSTYPE_MEM24: - case ACPI_RSTYPE_MEM32: - case ACPI_RSTYPE_FIXED_MEM32: + case ACPI_RESOURCE_TYPE_IRQ: + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + case ACPI_RESOURCE_TYPE_DMA: + case ACPI_RESOURCE_TYPE_IO: + case ACPI_RESOURCE_TYPE_FIXED_IO: + case ACPI_RESOURCE_TYPE_MEMORY24: + case ACPI_RESOURCE_TYPE_MEMORY32: + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: #if 0 - case ACPI_RSTYPE_ADDRESS16: - case ACPI_RSTYPE_ADDRESS32: - case ACPI_RSTYPE_ADDRESS64: + case ACPI_RESOURCE_TYPE_ADDRESS16: + case ACPI_RESOURCE_TYPE_ADDRESS32: + case ACPI_RESOURCE_TYPE_ADDRESS64: #endif (*res_cnt) ++; default: @@ -585,18 +585,18 @@ static acpi_status pnpacpi_type_resources(struct acpi_resource *res, { struct acpi_resource **resource = (struct acpi_resource **)data; switch (res->type) { - case ACPI_RSTYPE_IRQ: - case ACPI_RSTYPE_EXT_IRQ: - case ACPI_RSTYPE_DMA: - case ACPI_RSTYPE_IO: - case ACPI_RSTYPE_FIXED_IO: - case ACPI_RSTYPE_MEM24: - case ACPI_RSTYPE_MEM32: - case ACPI_RSTYPE_FIXED_MEM32: + case ACPI_RESOURCE_TYPE_IRQ: + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + case ACPI_RESOURCE_TYPE_DMA: + case ACPI_RESOURCE_TYPE_IO: + case ACPI_RESOURCE_TYPE_FIXED_IO: + case ACPI_RESOURCE_TYPE_MEMORY24: + case ACPI_RESOURCE_TYPE_MEMORY32: + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: #if 0 - case ACPI_RSTYPE_ADDRESS16: - case ACPI_RSTYPE_ADDRESS32: - case ACPI_RSTYPE_ADDRESS64: + case ACPI_RESOURCE_TYPE_ADDRESS16: + case ACPI_RESOURCE_TYPE_ADDRESS32: + case ACPI_RESOURCE_TYPE_ADDRESS64: #endif (*resource)->type = res->type; (*resource)++; @@ -607,14 +607,14 @@ static acpi_status pnpacpi_type_resources(struct acpi_resource *res, return AE_OK; } -int pnpacpi_build_resource_template(acpi_handle handle, +int pnpacpi_build_resource_template(acpi_handle handle, struct acpi_buffer *buffer) { struct acpi_resource *resource; int res_cnt = 0; acpi_status status; - status = acpi_walk_resources(handle, METHOD_NAME__CRS, + status = acpi_walk_resources(handle, METHOD_NAME__CRS, pnpacpi_count_resources, &res_cnt); if (ACPI_FAILURE(status)) { pnp_err("Evaluate _CRS failed"); @@ -628,7 +628,7 @@ int pnpacpi_build_resource_template(acpi_handle handle, return -ENOMEM; pnp_dbg("Res cnt %d", res_cnt); resource = (struct acpi_resource *)buffer->pointer; - status = acpi_walk_resources(handle, METHOD_NAME__CRS, + status = acpi_walk_resources(handle, METHOD_NAME__CRS, pnpacpi_type_resources, &resource); if (ACPI_FAILURE(status)) { kfree(buffer->pointer); @@ -636,54 +636,54 @@ int pnpacpi_build_resource_template(acpi_handle handle, return -EINVAL; } /* resource will pointer the end resource now */ - resource->type = ACPI_RSTYPE_END_TAG; + resource->type = ACPI_RESOURCE_TYPE_END_TAG; return 0; } -static void pnpacpi_encode_irq(struct acpi_resource *resource, +static void pnpacpi_encode_irq(struct acpi_resource *resource, struct resource *p) { - int edge_level, active_high_low; + int triggering, polarity; - decode_irq_flags(p->flags & IORESOURCE_BITS, &edge_level, - &active_high_low); - resource->type = ACPI_RSTYPE_IRQ; + decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, + &polarity); + resource->type = ACPI_RESOURCE_TYPE_IRQ; resource->length = sizeof(struct acpi_resource); - resource->data.irq.edge_level = edge_level; - resource->data.irq.active_high_low = active_high_low; - if (edge_level == ACPI_EDGE_SENSITIVE) - resource->data.irq.shared_exclusive = ACPI_EXCLUSIVE; + resource->data.irq.triggering = triggering; + resource->data.irq.polarity = polarity; + if (triggering == ACPI_EDGE_SENSITIVE) + resource->data.irq.sharable = ACPI_EXCLUSIVE; else - resource->data.irq.shared_exclusive = ACPI_SHARED; - resource->data.irq.number_of_interrupts = 1; + resource->data.irq.sharable = ACPI_SHARED; + resource->data.irq.interrupt_count = 1; resource->data.irq.interrupts[0] = p->start; } static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, struct resource *p) { - int edge_level, active_high_low; + int triggering, polarity; - decode_irq_flags(p->flags & IORESOURCE_BITS, &edge_level, - &active_high_low); - resource->type = ACPI_RSTYPE_EXT_IRQ; + decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, + &polarity); + resource->type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; resource->length = sizeof(struct acpi_resource); resource->data.extended_irq.producer_consumer = ACPI_CONSUMER; - resource->data.extended_irq.edge_level = edge_level; - resource->data.extended_irq.active_high_low = active_high_low; - if (edge_level == ACPI_EDGE_SENSITIVE) - resource->data.irq.shared_exclusive = ACPI_EXCLUSIVE; + resource->data.extended_irq.triggering = triggering; + resource->data.extended_irq.polarity = polarity; + if (triggering == ACPI_EDGE_SENSITIVE) + resource->data.irq.sharable = ACPI_EXCLUSIVE; else - resource->data.irq.shared_exclusive = ACPI_SHARED; - resource->data.extended_irq.number_of_interrupts = 1; + resource->data.irq.sharable = ACPI_SHARED; + resource->data.extended_irq.interrupt_count = 1; resource->data.extended_irq.interrupts[0] = p->start; } static void pnpacpi_encode_dma(struct acpi_resource *resource, struct resource *p) { - resource->type = ACPI_RSTYPE_DMA; + resource->type = ACPI_RESOURCE_TYPE_DMA; resource->length = sizeof(struct acpi_resource); /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ if (p->flags & IORESOURCE_DMA_COMPATIBLE) @@ -701,75 +701,75 @@ static void pnpacpi_encode_dma(struct acpi_resource *resource, else if (p->flags & IORESOURCE_DMA_16BIT) resource->data.dma.transfer = ACPI_TRANSFER_16; resource->data.dma.bus_master = p->flags & IORESOURCE_DMA_MASTER; - resource->data.dma.number_of_channels = 1; + resource->data.dma.channel_count = 1; resource->data.dma.channels[0] = p->start; } static void pnpacpi_encode_io(struct acpi_resource *resource, struct resource *p) { - resource->type = ACPI_RSTYPE_IO; + resource->type = ACPI_RESOURCE_TYPE_IO; resource->length = sizeof(struct acpi_resource); /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */ resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)? - ACPI_DECODE_16 : ACPI_DECODE_10; - resource->data.io.min_base_address = p->start; - resource->data.io.max_base_address = p->end; + ACPI_DECODE_16 : ACPI_DECODE_10; + resource->data.io.minimum = p->start; + resource->data.io.maximum = p->end; resource->data.io.alignment = 0; /* Correct? */ - resource->data.io.range_length = p->end - p->start + 1; + resource->data.io.address_length = p->end - p->start + 1; } static void pnpacpi_encode_fixed_io(struct acpi_resource *resource, struct resource *p) { - resource->type = ACPI_RSTYPE_FIXED_IO; + resource->type = ACPI_RESOURCE_TYPE_FIXED_IO; resource->length = sizeof(struct acpi_resource); - resource->data.fixed_io.base_address = p->start; - resource->data.fixed_io.range_length = p->end - p->start + 1; + resource->data.fixed_io.address = p->start; + resource->data.fixed_io.address_length = p->end - p->start + 1; } static void pnpacpi_encode_mem24(struct acpi_resource *resource, struct resource *p) { - resource->type = ACPI_RSTYPE_MEM24; + resource->type = ACPI_RESOURCE_TYPE_MEMORY24; resource->length = sizeof(struct acpi_resource); /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ resource->data.memory24.read_write_attribute = (p->flags & IORESOURCE_MEM_WRITEABLE) ? ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; - resource->data.memory24.min_base_address = p->start; - resource->data.memory24.max_base_address = p->end; + resource->data.memory24.minimum = p->start; + resource->data.memory24.maximum = p->end; resource->data.memory24.alignment = 0; - resource->data.memory24.range_length = p->end - p->start + 1; + resource->data.memory24.address_length = p->end - p->start + 1; } static void pnpacpi_encode_mem32(struct acpi_resource *resource, struct resource *p) { - resource->type = ACPI_RSTYPE_MEM32; + resource->type = ACPI_RESOURCE_TYPE_MEMORY32; resource->length = sizeof(struct acpi_resource); resource->data.memory32.read_write_attribute = (p->flags & IORESOURCE_MEM_WRITEABLE) ? ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; - resource->data.memory32.min_base_address = p->start; - resource->data.memory32.max_base_address = p->end; + resource->data.memory32.minimum = p->start; + resource->data.memory32.maximum = p->end; resource->data.memory32.alignment = 0; - resource->data.memory32.range_length = p->end - p->start + 1; + resource->data.memory32.address_length = p->end - p->start + 1; } static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, struct resource *p) { - resource->type = ACPI_RSTYPE_FIXED_MEM32; + resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32; resource->length = sizeof(struct acpi_resource); resource->data.fixed_memory32.read_write_attribute = (p->flags & IORESOURCE_MEM_WRITEABLE) ? ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; - resource->data.fixed_memory32.range_base_address = p->start; - resource->data.fixed_memory32.range_length = p->end - p->start + 1; + resource->data.fixed_memory32.address = p->start; + resource->data.fixed_memory32.address_length = p->end - p->start + 1; } -int pnpacpi_encode_resources(struct pnp_resource_table *res_table, +int pnpacpi_encode_resources(struct pnp_resource_table *res_table, struct acpi_buffer *buffer) { int i = 0; @@ -781,50 +781,50 @@ int pnpacpi_encode_resources(struct pnp_resource_table *res_table, pnp_dbg("res cnt %d", res_cnt); while (i < res_cnt) { switch(resource->type) { - case ACPI_RSTYPE_IRQ: + case ACPI_RESOURCE_TYPE_IRQ: pnp_dbg("Encode irq"); - pnpacpi_encode_irq(resource, + pnpacpi_encode_irq(resource, &res_table->irq_resource[irq]); irq++; break; - case ACPI_RSTYPE_EXT_IRQ: + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: pnp_dbg("Encode ext irq"); - pnpacpi_encode_ext_irq(resource, + pnpacpi_encode_ext_irq(resource, &res_table->irq_resource[irq]); irq++; break; - case ACPI_RSTYPE_DMA: + case ACPI_RESOURCE_TYPE_DMA: pnp_dbg("Encode dma"); - pnpacpi_encode_dma(resource, + pnpacpi_encode_dma(resource, &res_table->dma_resource[dma]); dma ++; break; - case ACPI_RSTYPE_IO: + case ACPI_RESOURCE_TYPE_IO: pnp_dbg("Encode io"); - pnpacpi_encode_io(resource, + pnpacpi_encode_io(resource, &res_table->port_resource[port]); port ++; break; - case ACPI_RSTYPE_FIXED_IO: + case ACPI_RESOURCE_TYPE_FIXED_IO: pnp_dbg("Encode fixed io"); pnpacpi_encode_fixed_io(resource, &res_table->port_resource[port]); port ++; break; - case ACPI_RSTYPE_MEM24: + case ACPI_RESOURCE_TYPE_MEMORY24: pnp_dbg("Encode mem24"); pnpacpi_encode_mem24(resource, &res_table->mem_resource[mem]); mem ++; break; - case ACPI_RSTYPE_MEM32: + case ACPI_RESOURCE_TYPE_MEMORY32: pnp_dbg("Encode mem32"); pnpacpi_encode_mem32(resource, &res_table->mem_resource[mem]); mem ++; break; - case ACPI_RSTYPE_FIXED_MEM32: + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: pnp_dbg("Encode fixed mem32"); pnpacpi_encode_fixed_mem32(resource, &res_table->mem_resource[mem]); diff --git a/drivers/serial/8250_acpi.c b/drivers/serial/8250_acpi.c index 36681ba7b033..809f89ab965c 100644 --- a/drivers/serial/8250_acpi.c +++ b/drivers/serial/8250_acpi.c @@ -27,7 +27,7 @@ struct serial_private { static acpi_status acpi_serial_mmio(struct uart_port *port, struct acpi_resource_address64 *addr) { - port->mapbase = addr->min_address_range; + port->mapbase = addr->minimum; port->iotype = UPIO_MEM; port->flags |= UPF_IOREMAP; return AE_OK; @@ -36,8 +36,8 @@ static acpi_status acpi_serial_mmio(struct uart_port *port, static acpi_status acpi_serial_port(struct uart_port *port, struct acpi_resource_io *io) { - if (io->range_length) { - port->iobase = io->min_base_address; + if (io->address_length) { + port->iobase = io->minimum; port->iotype = UPIO_PORT; } else printk(KERN_ERR "%s: zero-length IO port range?\n", __FUNCTION__); @@ -45,13 +45,13 @@ static acpi_status acpi_serial_port(struct uart_port *port, } static acpi_status acpi_serial_ext_irq(struct uart_port *port, - struct acpi_resource_ext_irq *ext_irq) + struct acpi_resource_extended_irq *ext_irq) { int rc; - if (ext_irq->number_of_interrupts > 0) { + if (ext_irq->interrupt_count > 0) { rc = acpi_register_gsi(ext_irq->interrupts[0], - ext_irq->edge_level, ext_irq->active_high_low); + ext_irq->triggering, ext_irq->polarity); if (rc < 0) return AE_ERROR; port->irq = rc; @@ -64,9 +64,9 @@ static acpi_status acpi_serial_irq(struct uart_port *port, { int rc; - if (irq->number_of_interrupts > 0) { + if (irq->interrupt_count > 0) { rc = acpi_register_gsi(irq->interrupts[0], - irq->edge_level, irq->active_high_low); + irq->triggering, irq->polarity); if (rc < 0) return AE_ERROR; port->irq = rc; @@ -83,11 +83,11 @@ static acpi_status acpi_serial_resource(struct acpi_resource *res, void *data) status = acpi_resource_to_address64(res, &addr); if (ACPI_SUCCESS(status)) return acpi_serial_mmio(port, &addr); - else if (res->type == ACPI_RSTYPE_IO) + else if (res->type == ACPI_RESOURCE_TYPE_IO) return acpi_serial_port(port, &res->data.io); - else if (res->type == ACPI_RSTYPE_EXT_IRQ) + else if (res->type == ACPI_RESOURCE_TYPE_EXTENDED_IRQ) return acpi_serial_ext_irq(port, &res->data.extended_irq); - else if (res->type == ACPI_RSTYPE_IRQ) + else if (res->type == ACPI_RESOURCE_TYPE_IRQ) return acpi_serial_irq(port, &res->data.irq); return AE_OK; } diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index 1427c5cf4304..cb59b018c84c 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -63,7 +63,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20050916 +#define ACPI_CA_VERSION 0x20050930 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, diff --git a/include/acpi/acdisasm.h b/include/acpi/acdisasm.h index 759b4cff4f88..b2921b869bb4 100644 --- a/include/acpi/acdisasm.h +++ b/include/acpi/acdisasm.h @@ -187,73 +187,67 @@ void acpi_dm_decode_attribute(u8 attribute); * dmresrcl */ void -acpi_dm_word_descriptor(union asl_resource_desc *resource, - u32 length, u32 level); +acpi_dm_word_descriptor(union aml_resource *resource, u32 length, u32 level); void -acpi_dm_dword_descriptor(union asl_resource_desc *resource, - u32 length, u32 level); +acpi_dm_dword_descriptor(union aml_resource *resource, u32 length, u32 level); void -acpi_dm_extended_descriptor(union asl_resource_desc *resource, +acpi_dm_extended_descriptor(union aml_resource *resource, u32 length, u32 level); void -acpi_dm_qword_descriptor(union asl_resource_desc *resource, - u32 length, u32 level); +acpi_dm_qword_descriptor(union aml_resource *resource, u32 length, u32 level); void -acpi_dm_memory24_descriptor(union asl_resource_desc *resource, +acpi_dm_memory24_descriptor(union aml_resource *resource, u32 length, u32 level); void -acpi_dm_memory32_descriptor(union asl_resource_desc *resource, +acpi_dm_memory32_descriptor(union aml_resource *resource, u32 length, u32 level); void -acpi_dm_fixed_memory32_descriptor(union asl_resource_desc *resource, +acpi_dm_fixed_memory32_descriptor(union aml_resource *resource, u32 length, u32 level); void -acpi_dm_generic_register_descriptor(union asl_resource_desc *resource, +acpi_dm_generic_register_descriptor(union aml_resource *resource, u32 length, u32 level); void -acpi_dm_interrupt_descriptor(union asl_resource_desc *resource, +acpi_dm_interrupt_descriptor(union aml_resource *resource, u32 length, u32 level); void -acpi_dm_vendor_large_descriptor(union asl_resource_desc *resource, +acpi_dm_vendor_large_descriptor(union aml_resource *resource, u32 length, u32 level); /* * dmresrcs */ void -acpi_dm_irq_descriptor(union asl_resource_desc *resource, - u32 length, u32 level); +acpi_dm_irq_descriptor(union aml_resource *resource, u32 length, u32 level); void -acpi_dm_dma_descriptor(union asl_resource_desc *resource, - u32 length, u32 level); +acpi_dm_dma_descriptor(union aml_resource *resource, u32 length, u32 level); -void -acpi_dm_io_descriptor(union asl_resource_desc *resource, u32 length, u32 level); +void acpi_dm_io_descriptor(union aml_resource *resource, u32 length, u32 level); void -acpi_dm_fixed_io_descriptor(union asl_resource_desc *resource, +acpi_dm_fixed_io_descriptor(union aml_resource *resource, u32 length, u32 level); void -acpi_dm_start_dependent_descriptor(union asl_resource_desc *resource, +acpi_dm_start_dependent_descriptor(union aml_resource *resource, u32 length, u32 level); void -acpi_dm_end_dependent_descriptor(union asl_resource_desc *resource, +acpi_dm_end_dependent_descriptor(union aml_resource *resource, u32 length, u32 level); void -acpi_dm_vendor_small_descriptor(union asl_resource_desc *resource, +acpi_dm_vendor_small_descriptor(union aml_resource *resource, u32 length, u32 level); /* diff --git a/include/acpi/acglobal.h b/include/acpi/acglobal.h index e9c2790139ec..cef51b1ddf94 100644 --- a/include/acpi/acglobal.h +++ b/include/acpi/acglobal.h @@ -80,6 +80,15 @@ extern u32 acpi_dbg_layer; extern u32 acpi_gbl_nesting_level; +/* Support for dynamic control method tracing mechanism */ + +ACPI_EXTERN u32 acpi_gbl_original_dbg_level; +ACPI_EXTERN u32 acpi_gbl_original_dbg_layer; +ACPI_EXTERN acpi_name acpi_gbl_trace_method_name; +ACPI_EXTERN u32 acpi_gbl_trace_dbg_level; +ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer; +ACPI_EXTERN u32 acpi_gbl_trace_flags; + /***************************************************************************** * * Runtime configuration (static defaults that can be overriden at runtime) diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h index 76ac1533c405..dca0d40ea395 100644 --- a/include/acpi/aclocal.h +++ b/include/acpi/aclocal.h @@ -735,59 +735,52 @@ struct acpi_bit_register_info { /* resource_type values */ -#define ACPI_RESOURCE_TYPE_MEMORY_RANGE 0 -#define ACPI_RESOURCE_TYPE_IO_RANGE 1 -#define ACPI_RESOURCE_TYPE_BUS_NUMBER_RANGE 2 +#define ACPI_ADDRESS_TYPE_MEMORY_RANGE 0 +#define ACPI_ADDRESS_TYPE_IO_RANGE 1 +#define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE 2 /* Resource descriptor types and masks */ -#define ACPI_RDESC_TYPE_LARGE 0x80 -#define ACPI_RDESC_TYPE_SMALL 0x00 +#define ACPI_RESOURCE_NAME_LARGE 0x80 +#define ACPI_RESOURCE_NAME_SMALL 0x00 -#define ACPI_RDESC_SMALL_MASK 0x78 /* Bits 6:3 contain the type */ -#define ACPI_RDESC_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */ -#define ACPI_RDESC_LARGE_MASK 0x7F /* Bits 6:0 contain the type */ +#define ACPI_RESOURCE_NAME_SMALL_MASK 0x78 /* Bits 6:3 contain the type */ +#define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */ +#define ACPI_RESOURCE_NAME_LARGE_MASK 0x7F /* Bits 6:0 contain the type */ /* - * Small resource descriptor types + * Small resource descriptor "names" as defined by the ACPI specification. * Note: Bits 2:0 are used for the descriptor length */ -#define ACPI_RDESC_TYPE_IRQ_FORMAT 0x20 -#define ACPI_RDESC_TYPE_DMA_FORMAT 0x28 -#define ACPI_RDESC_TYPE_START_DEPENDENT 0x30 -#define ACPI_RDESC_TYPE_END_DEPENDENT 0x38 -#define ACPI_RDESC_TYPE_IO_PORT 0x40 -#define ACPI_RDESC_TYPE_FIXED_IO_PORT 0x48 -#define ACPI_RDESC_TYPE_RESERVED_S1 0x50 -#define ACPI_RDESC_TYPE_RESERVED_S2 0x58 -#define ACPI_RDESC_TYPE_RESERVED_S3 0x60 -#define ACPI_RDESC_TYPE_RESERVED_S4 0x68 -#define ACPI_RDESC_TYPE_SMALL_VENDOR 0x70 -#define ACPI_RDESC_TYPE_END_TAG 0x78 +#define ACPI_RESOURCE_NAME_IRQ 0x20 +#define ACPI_RESOURCE_NAME_DMA 0x28 +#define ACPI_RESOURCE_NAME_START_DEPENDENT 0x30 +#define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38 +#define ACPI_RESOURCE_NAME_IO 0x40 +#define ACPI_RESOURCE_NAME_FIXED_IO 0x48 +#define ACPI_RESOURCE_NAME_RESERVED_S1 0x50 +#define ACPI_RESOURCE_NAME_RESERVED_S2 0x58 +#define ACPI_RESOURCE_NAME_RESERVED_S3 0x60 +#define ACPI_RESOURCE_NAME_RESERVED_S4 0x68 +#define ACPI_RESOURCE_NAME_VENDOR_SMALL 0x70 +#define ACPI_RESOURCE_NAME_END_TAG 0x78 /* - * Large resource descriptor types + * Large resource descriptor "names" as defined by the ACPI specification. + * Note: includes the Large Descriptor bit in bit[7] */ -#define ACPI_RDESC_TYPE_MEMORY_24 0x81 -#define ACPI_RDESC_TYPE_GENERIC_REGISTER 0x82 -#define ACPI_RDESC_TYPE_RESERVED_L1 0x83 -#define ACPI_RDESC_TYPE_LARGE_VENDOR 0x84 -#define ACPI_RDESC_TYPE_MEMORY_32 0x85 -#define ACPI_RDESC_TYPE_FIXED_MEMORY_32 0x86 -#define ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE 0x87 -#define ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE 0x88 -#define ACPI_RDESC_TYPE_EXTENDED_XRUPT 0x89 -#define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE 0x8A -#define ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE 0x8B -#define ACPI_RDESC_LARGE_MAX 0x8B - -/* - * Minimum lengths for descriptors with optional fields - */ -#define ACPI_RDESC_QWORD_MIN 43 -#define ACPI_RDESC_DWORD_MIN 23 -#define ACPI_RDESC_WORD_MIN 13 -#define ACPI_RDESC_EXT_XRUPT_MIN 6 +#define ACPI_RESOURCE_NAME_MEMORY24 0x81 +#define ACPI_RESOURCE_NAME_GENERIC_REGISTER 0x82 +#define ACPI_RESOURCE_NAME_RESERVED_L1 0x83 +#define ACPI_RESOURCE_NAME_VENDOR_LARGE 0x84 +#define ACPI_RESOURCE_NAME_MEMORY32 0x85 +#define ACPI_RESOURCE_NAME_FIXED_MEMORY32 0x86 +#define ACPI_RESOURCE_NAME_ADDRESS32 0x87 +#define ACPI_RESOURCE_NAME_ADDRESS16 0x88 +#define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89 +#define ACPI_RESOURCE_NAME_ADDRESS64 0x8A +#define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B +#define ACPI_RESOURCE_NAME_LARGE_MAX 0x8B /***************************************************************************** * @@ -795,7 +788,7 @@ struct acpi_bit_register_info { * ****************************************************************************/ -#define ACPI_ASCII_ZERO 0x30 +#define ACPI_ASCII_ZERO 0x30 /***************************************************************************** * diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h index 702cc4e57f5f..258cfe5e2aac 100644 --- a/include/acpi/acmacros.h +++ b/include/acpi/acmacros.h @@ -525,6 +525,9 @@ * bad form, but having a separate exit macro is very ugly and difficult to maintain. * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros * so that "_acpi_function_name" is defined. + * + * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining + * about these constructs. */ #ifdef ACPI_USE_DO_WHILE_0 #define ACPI_DO_WHILE0(a) do a while(0) @@ -532,10 +535,55 @@ #define ACPI_DO_WHILE0(a) a #endif -#define return_VOID ACPI_DO_WHILE0 ({acpi_ut_exit(ACPI_DEBUG_PARAMETERS);return;}) -#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({acpi_ut_status_exit(ACPI_DEBUG_PARAMETERS,(s));return((s));}) -#define return_VALUE(s) ACPI_DO_WHILE0 ({acpi_ut_value_exit(ACPI_DEBUG_PARAMETERS,(acpi_integer)(s));return((s));}) -#define return_PTR(s) ACPI_DO_WHILE0 ({acpi_ut_ptr_exit(ACPI_DEBUG_PARAMETERS,(u8 *)(s));return((s));}) +#define return_VOID ACPI_DO_WHILE0 ({ \ + acpi_ut_exit (ACPI_DEBUG_PARAMETERS); \ + return;}) +/* + * There are two versions of most of the return macros. The default version is + * safer, since it avoids side-effects by guaranteeing that the argument will + * not be evaluated twice. + * + * A less-safe version of the macros is provided for optional use if the + * compiler uses excessive CPU stack (for example, this may happen in the + * debug case if code optimzation is disabled.) + */ +#ifndef ACPI_SIMPLE_RETURN_MACROS + +#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \ + register acpi_status _s = (s); \ + acpi_ut_status_exit (ACPI_DEBUG_PARAMETERS, _s); \ + return (_s); }) +#define return_PTR(s) ACPI_DO_WHILE0 ({ \ + register void *_s = (void *) (s); \ + acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) _s); \ + return (_s); }) +#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ + register acpi_integer _s = (s); \ + acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \ + return (_s); }) +#define return_UINT8(s) ACPI_DO_WHILE0 ({ \ + register u8 _s = (u8) (s); \ + acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \ + return (_s); }) +#define return_UINT32(s) ACPI_DO_WHILE0 ({ \ + register u32 _s = (u32) (s); \ + acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \ + return (_s); }) +#else /* Use original less-safe macros */ + +#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \ + acpi_ut_status_exit (ACPI_DEBUG_PARAMETERS, (s)); \ + return((s)); }) +#define return_PTR(s) ACPI_DO_WHILE0 ({ \ + acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) (s)); \ + return((s)); }) +#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ + acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) (s)); \ + return((s)); }) +#define return_UINT8(s) return_VALUE(s) +#define return_UINT32(s) return_VALUE(s) + +#endif /* ACPI_SIMPLE_RETURN_MACROS */ /* Conditional execution */ @@ -612,6 +660,8 @@ #define return_VOID return #define return_ACPI_STATUS(s) return(s) #define return_VALUE(s) return(s) +#define return_UINT8(s) return(s) +#define return_UINT32(s) return(s) #define return_PTR(s) return(s) #endif diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h index c1b4e1f882e4..b425f9bb6d43 100644 --- a/include/acpi/acpi_drivers.h +++ b/include/acpi/acpi_drivers.h @@ -52,8 +52,8 @@ /* ACPI PCI Interrupt Link (pci_link.c) */ int acpi_irq_penalty_init(void); -int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *edge_level, - int *active_high_low, char **name); +int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering, + int *polarity, char **name); int acpi_pci_link_free_irq(acpi_handle handle); /* ACPI PCI Interrupt Routing (pci_irq.c) */ diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index 2a9dbc13b0f2..02f00a8fee03 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -149,6 +149,9 @@ acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler); acpi_status acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data); +acpi_status +acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags); + /* * Object manipulation and enumeration */ diff --git a/include/acpi/acresrc.h b/include/acpi/acresrc.h index ce2cf72fd4c8..b66994e9e4ee 100644 --- a/include/acpi/acresrc.h +++ b/include/acpi/acresrc.h @@ -44,6 +44,51 @@ #ifndef __ACRESRC_H__ #define __ACRESRC_H__ +/* Need the AML resource descriptor structs */ + +#include "amlresrc.h" + +/* + * Resource dispatch and info tables + */ +struct acpi_resource_info { + u8 length_type; + u8 minimum_aml_resource_length; + u8 minimum_internal_struct_length; +}; + +/* Types for length_type above */ + +#define ACPI_FIXED_LENGTH 0 +#define ACPI_VARIABLE_LENGTH 1 +#define ACPI_SMALL_VARIABLE_LENGTH 2 + +/* Handlers */ + +typedef acpi_status(*ACPI_SET_RESOURCE_HANDLER) (struct acpi_resource * + resource, + union aml_resource * aml); + +typedef acpi_status(*ACPI_GET_RESOURCE_HANDLER) (union aml_resource * aml, + u16 aml_resource_length, + struct acpi_resource * + resource); + +typedef void (*ACPI_DUMP_RESOURCE_HANDLER) (union acpi_resource_data * data); + +/* Tables indexed by internal resource type */ + +extern u8 acpi_gbl_aml_resource_sizes[]; +extern ACPI_SET_RESOURCE_HANDLER acpi_gbl_set_resource_dispatch[]; +extern ACPI_DUMP_RESOURCE_HANDLER acpi_gbl_dump_resource_dispatch[]; + +/* Tables indexed by raw AML resource descriptor type */ + +extern struct acpi_resource_info acpi_gbl_sm_resource_info[]; +extern struct acpi_resource_info acpi_gbl_lg_resource_info[]; +extern ACPI_GET_RESOURCE_HANDLER acpi_gbl_sm_get_resource_dispatch[]; +extern ACPI_GET_RESOURCE_HANDLER acpi_gbl_lg_get_resource_dispatch[]; + /* * Function prototypes called from Acpi* APIs */ @@ -66,12 +111,12 @@ acpi_status acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer); acpi_status -acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer, +acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, struct acpi_buffer *output_buffer); acpi_status -acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, - struct acpi_buffer *output_buffer); +acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, + struct acpi_buffer *output_buffer); acpi_status acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, @@ -90,184 +135,240 @@ void acpi_rs_dump_irq_list(u8 * route_table); * rscalc */ acpi_status -acpi_rs_get_byte_stream_start(u8 * byte_stream_buffer, - u8 ** byte_stream_start, u32 * size); - -acpi_status -acpi_rs_get_list_length(u8 * byte_stream_buffer, - u32 byte_stream_buffer_length, acpi_size * size_needed); +acpi_rs_get_list_length(u8 * aml_buffer, + u32 aml_buffer_length, acpi_size * size_needed); acpi_status -acpi_rs_get_byte_stream_length(struct acpi_resource *linked_list_buffer, - acpi_size * size_needed); +acpi_rs_get_aml_length(struct acpi_resource *linked_list_buffer, + acpi_size * size_needed); acpi_status acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, acpi_size * buffer_size_needed); acpi_status -acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, - u32 byte_stream_buffer_length, u8 * output_buffer); +acpi_rs_convert_aml_to_resources(u8 * aml_buffer, + u32 aml_buffer_length, u8 * output_buffer); acpi_status -acpi_rs_list_to_byte_stream(struct acpi_resource *resource, - acpi_size byte_stream_size_needed, - u8 * output_buffer); +acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, + acpi_size aml_size_needed, u8 * output_buffer); +/* + * rsio + */ acpi_status -acpi_rs_io_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size); +acpi_rs_get_io(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource); acpi_status -acpi_rs_fixed_io_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size); +acpi_rs_set_io(struct acpi_resource *resource, union aml_resource *aml); acpi_status -acpi_rs_io_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed); +acpi_rs_get_fixed_io(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource); acpi_status -acpi_rs_fixed_io_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed); +acpi_rs_set_fixed_io(struct acpi_resource *resource, union aml_resource *aml); acpi_status -acpi_rs_irq_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size); +acpi_rs_get_dma(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource); acpi_status -acpi_rs_irq_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed); +acpi_rs_set_dma(struct acpi_resource *resource, union aml_resource *aml); +/* + * rsirq + */ acpi_status -acpi_rs_dma_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size); +acpi_rs_get_irq(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource); acpi_status -acpi_rs_dma_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed); +acpi_rs_set_irq(struct acpi_resource *resource, union aml_resource *aml); acpi_status -acpi_rs_address16_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size); +acpi_rs_get_ext_irq(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource); acpi_status -acpi_rs_address16_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed); +acpi_rs_set_ext_irq(struct acpi_resource *resource, union aml_resource *aml); + +/* + * rsaddr + */ +acpi_status +acpi_rs_get_address16(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource); acpi_status -acpi_rs_address32_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size); +acpi_rs_set_address16(struct acpi_resource *resource, union aml_resource *aml); acpi_status -acpi_rs_address32_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed); +acpi_rs_get_address32(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource); acpi_status -acpi_rs_address64_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size); +acpi_rs_set_address32(struct acpi_resource *resource, union aml_resource *aml); acpi_status -acpi_rs_address64_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed); +acpi_rs_get_address64(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource); acpi_status -acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, - acpi_size * structure_size); +acpi_rs_set_address64(struct acpi_resource *resource, union aml_resource *aml); + +acpi_status +acpi_rs_get_ext_address64(union aml_resource *aml, + u16 aml_resource_length, + struct acpi_resource *resource); + +acpi_status +acpi_rs_set_ext_address64(struct acpi_resource *resource, + union aml_resource *aml); + +/* + * rsmemory + */ +acpi_status +acpi_rs_get_memory24(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource); acpi_status -acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, - acpi_size * structure_size); +acpi_rs_set_memory24(struct acpi_resource *resource, union aml_resource *aml); acpi_status -acpi_rs_start_depend_fns_stream(struct acpi_resource *resource, - u8 ** output_buffer, - acpi_size * bytes_consumed); +acpi_rs_get_memory32(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource); acpi_status -acpi_rs_end_depend_fns_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed); +acpi_rs_set_memory32(struct acpi_resource *resource, union aml_resource *aml); acpi_status -acpi_rs_memory24_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size); +acpi_rs_get_fixed_memory32(union aml_resource *aml, + u16 aml_resource_length, + struct acpi_resource *resource); acpi_status -acpi_rs_memory24_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed); +acpi_rs_set_fixed_memory32(struct acpi_resource *resource, + union aml_resource *aml); +/* + * rsmisc + */ acpi_status -acpi_rs_memory32_range_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, - acpi_size * structure_size); +acpi_rs_get_generic_reg(union aml_resource *aml, + u16 aml_resource_length, + struct acpi_resource *resource); acpi_status -acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, - acpi_size * structure_size); +acpi_rs_set_generic_reg(struct acpi_resource *resource, + union aml_resource *aml); acpi_status -acpi_rs_memory32_range_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed); +acpi_rs_get_vendor(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource); acpi_status -acpi_rs_fixed_memory32_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed); +acpi_rs_set_vendor(struct acpi_resource *resource, union aml_resource *aml); acpi_status -acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size); +acpi_rs_get_start_dpf(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource); acpi_status -acpi_rs_extended_irq_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed); +acpi_rs_set_start_dpf(struct acpi_resource *resource, union aml_resource *aml); acpi_status -acpi_rs_end_tag_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size); +acpi_rs_get_end_dpf(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource); acpi_status -acpi_rs_end_tag_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed); +acpi_rs_set_end_dpf(struct acpi_resource *resource, union aml_resource *aml); acpi_status -acpi_rs_vendor_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, acpi_size * structure_size); +acpi_rs_get_end_tag(union aml_resource *aml, + u16 aml_resource_length, struct acpi_resource *resource); acpi_status -acpi_rs_vendor_stream(struct acpi_resource *resource, - u8 ** output_buffer, acpi_size * bytes_consumed); +acpi_rs_set_end_tag(struct acpi_resource *resource, union aml_resource *aml); + +/* + * rsutils + */ +void +acpi_rs_move_data(void *destination, + void *source, u16 item_count, u8 move_type); + +/* Types used in move_type above */ + +#define ACPI_MOVE_TYPE_16_TO_32 0 +#define ACPI_MOVE_TYPE_32_TO_16 1 +#define ACPI_MOVE_TYPE_32_TO_32 2 +#define ACPI_MOVE_TYPE_64_TO_64 3 + +u16 +acpi_rs_get_resource_source(u16 resource_length, + acpi_size minimum_length, + struct acpi_resource_source *resource_source, + union aml_resource *aml, char *string_ptr); + +acpi_size +acpi_rs_set_resource_source(union aml_resource *aml, + acpi_size minimum_length, + struct acpi_resource_source *resource_source); u8 acpi_rs_get_resource_type(u8 resource_start_byte); +u32 acpi_rs_get_descriptor_length(union aml_resource *aml); + +u16 acpi_rs_get_resource_length(union aml_resource *aml); + +void +acpi_rs_set_resource_header(u8 descriptor_type, + acpi_size total_length, union aml_resource *aml); + +struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type); + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) /* - * rsmisc + * rsdump */ -acpi_status -acpi_rs_generic_register_resource(u8 * byte_stream_buffer, - acpi_size * bytes_consumed, - u8 ** output_buffer, - acpi_size * structure_size); +void acpi_rs_dump_irq(union acpi_resource_data *resource); -acpi_status -acpi_rs_generic_register_stream(struct acpi_resource *resource, - u8 ** output_buffer, - acpi_size * bytes_consumed); +void acpi_rs_dump_address16(union acpi_resource_data *resource); + +void acpi_rs_dump_address32(union acpi_resource_data *resource); + +void acpi_rs_dump_address64(union acpi_resource_data *resource); + +void acpi_rs_dump_ext_address64(union acpi_resource_data *resource); + +void acpi_rs_dump_dma(union acpi_resource_data *resource); + +void acpi_rs_dump_io(union acpi_resource_data *resource); + +void acpi_rs_dump_ext_irq(union acpi_resource_data *resource); + +void acpi_rs_dump_fixed_io(union acpi_resource_data *resource); + +void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource); + +void acpi_rs_dump_memory24(union acpi_resource_data *resource); + +void acpi_rs_dump_memory32(union acpi_resource_data *resource); + +void acpi_rs_dump_start_dpf(union acpi_resource_data *resource); + +void acpi_rs_dump_vendor(union acpi_resource_data *resource); + +void acpi_rs_dump_generic_reg(union acpi_resource_data *resource); + +void acpi_rs_dump_end_dpf(union acpi_resource_data *resource); + +void acpi_rs_dump_end_tag(union acpi_resource_data *resource); + +#endif #endif /* __ACRESRC_H__ */ diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 1dfa64fae4ec..43f7c509317a 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -978,10 +978,10 @@ struct acpi_mem_space_context { * Structures used to describe device resources */ struct acpi_resource_irq { - u32 edge_level; - u32 active_high_low; - u32 shared_exclusive; - u32 number_of_interrupts; + u32 triggering; + u32 polarity; + u32 sharable; + u32 interrupt_count; u32 interrupts[1]; }; @@ -989,11 +989,11 @@ struct acpi_resource_dma { u32 type; u32 bus_master; u32 transfer; - u32 number_of_channels; + u32 channel_count; u32 channels[1]; }; -struct acpi_resource_start_dpf { +struct acpi_resource_start_dependent { u32 compatibility_priority; u32 performance_robustness; }; @@ -1005,46 +1005,46 @@ struct acpi_resource_start_dpf { struct acpi_resource_io { u32 io_decode; - u32 min_base_address; - u32 max_base_address; + u32 minimum; + u32 maximum; u32 alignment; - u32 range_length; + u32 address_length; }; struct acpi_resource_fixed_io { - u32 base_address; - u32 range_length; + u32 address; + u32 address_length; }; struct acpi_resource_vendor { - u32 length; - u8 reserved[1]; + u32 byte_length; + u8 byte_data[1]; }; struct acpi_resource_end_tag { u8 checksum; }; -struct acpi_resource_mem24 { +struct acpi_resource_memory24 { u32 read_write_attribute; - u32 min_base_address; - u32 max_base_address; + u32 minimum; + u32 maximum; u32 alignment; - u32 range_length; + u32 address_length; }; -struct acpi_resource_mem32 { +struct acpi_resource_memory32 { u32 read_write_attribute; - u32 min_base_address; - u32 max_base_address; + u32 minimum; + u32 maximum; u32 alignment; - u32 range_length; + u32 address_length; }; -struct acpi_resource_fixed_mem32 { +struct acpi_resource_fixed_memory32 { u32 read_write_attribute; - u32 range_base_address; - u32 range_length; + u32 address; + u32 address_length; }; struct acpi_memory_attribute { @@ -1089,93 +1089,105 @@ ACPI_RESOURCE_ADDRESS_COMMON}; struct acpi_resource_address16 { ACPI_RESOURCE_ADDRESS_COMMON u32 granularity; - u32 min_address_range; - u32 max_address_range; - u32 address_translation_offset; + u32 minimum; + u32 maximum; + u32 translation_offset; u32 address_length; struct acpi_resource_source resource_source; }; struct acpi_resource_address32 { ACPI_RESOURCE_ADDRESS_COMMON u32 granularity; - u32 min_address_range; - u32 max_address_range; - u32 address_translation_offset; + u32 minimum; + u32 maximum; + u32 translation_offset; u32 address_length; struct acpi_resource_source resource_source; }; struct acpi_resource_address64 { ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; - u64 min_address_range; - u64 max_address_range; - u64 address_translation_offset; + u64 minimum; + u64 maximum; + u64 translation_offset; u64 address_length; - u64 type_specific_attributes; struct acpi_resource_source resource_source; }; -struct acpi_resource_ext_irq { +struct acpi_resource_extended_address64 { + ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; + u64 minimum; + u64 maximum; + u64 translation_offset; + u64 address_length; + u64 type_specific_attributes; + u8 revision_iD; +}; + +struct acpi_resource_extended_irq { u32 producer_consumer; - u32 edge_level; - u32 active_high_low; - u32 shared_exclusive; - u32 number_of_interrupts; + u32 triggering; + u32 polarity; + u32 sharable; + u32 interrupt_count; struct acpi_resource_source resource_source; u32 interrupts[1]; }; -struct acpi_resource_generic_reg { +struct acpi_resource_generic_register { u32 space_id; u32 bit_width; u32 bit_offset; - u32 address_size; + u32 access_size; u64 address; }; /* ACPI_RESOURCE_TYPEs */ -#define ACPI_RSTYPE_IRQ 0 -#define ACPI_RSTYPE_DMA 1 -#define ACPI_RSTYPE_START_DPF 2 -#define ACPI_RSTYPE_END_DPF 3 -#define ACPI_RSTYPE_IO 4 -#define ACPI_RSTYPE_FIXED_IO 5 -#define ACPI_RSTYPE_VENDOR 6 -#define ACPI_RSTYPE_END_TAG 7 -#define ACPI_RSTYPE_MEM24 8 -#define ACPI_RSTYPE_MEM32 9 -#define ACPI_RSTYPE_FIXED_MEM32 10 -#define ACPI_RSTYPE_ADDRESS16 11 -#define ACPI_RSTYPE_ADDRESS32 12 -#define ACPI_RSTYPE_ADDRESS64 13 -#define ACPI_RSTYPE_EXT_IRQ 14 -#define ACPI_RSTYPE_GENERIC_REG 15 -#define ACPI_RSTYPE_MAX 15 - -typedef u32 acpi_resource_type; +#define ACPI_RESOURCE_TYPE_IRQ 0 +#define ACPI_RESOURCE_TYPE_DMA 1 +#define ACPI_RESOURCE_TYPE_START_DEPENDENT 2 +#define ACPI_RESOURCE_TYPE_END_DEPENDENT 3 +#define ACPI_RESOURCE_TYPE_IO 4 +#define ACPI_RESOURCE_TYPE_FIXED_IO 5 +#define ACPI_RESOURCE_TYPE_VENDOR 6 +#define ACPI_RESOURCE_TYPE_END_TAG 7 +#define ACPI_RESOURCE_TYPE_MEMORY24 8 +#define ACPI_RESOURCE_TYPE_MEMORY32 9 +#define ACPI_RESOURCE_TYPE_FIXED_MEMORY32 10 +#define ACPI_RESOURCE_TYPE_ADDRESS16 11 +#define ACPI_RESOURCE_TYPE_ADDRESS32 12 +#define ACPI_RESOURCE_TYPE_ADDRESS64 13 +#define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 14 /* ACPI 3.0 */ +#define ACPI_RESOURCE_TYPE_EXTENDED_IRQ 15 +#define ACPI_RESOURCE_TYPE_GENERIC_REGISTER 16 +#define ACPI_RESOURCE_TYPE_MAX 16 union acpi_resource_data { struct acpi_resource_irq irq; struct acpi_resource_dma dma; - struct acpi_resource_start_dpf start_dpf; + struct acpi_resource_start_dependent start_dpf; struct acpi_resource_io io; struct acpi_resource_fixed_io fixed_io; - struct acpi_resource_vendor vendor_specific; + struct acpi_resource_vendor vendor; struct acpi_resource_end_tag end_tag; - struct acpi_resource_mem24 memory24; - struct acpi_resource_mem32 memory32; - struct acpi_resource_fixed_mem32 fixed_memory32; - struct acpi_resource_address address; /* Common 16/32/64 address fields */ + struct acpi_resource_memory24 memory24; + struct acpi_resource_memory32 memory32; + struct acpi_resource_fixed_memory32 fixed_memory32; struct acpi_resource_address16 address16; struct acpi_resource_address32 address32; struct acpi_resource_address64 address64; - struct acpi_resource_ext_irq extended_irq; - struct acpi_resource_generic_reg generic_reg; + struct acpi_resource_extended_address64 ext_address64; + struct acpi_resource_extended_irq extended_irq; + struct acpi_resource_generic_register generic_reg; + + /* Common fields */ + + struct acpi_resource_address address; /* Common 16/32/64 address fields */ }; struct acpi_resource { - acpi_resource_type type; + u32 type; u32 length; union acpi_resource_data data; }; @@ -1183,7 +1195,7 @@ struct acpi_resource { #define ACPI_RESOURCE_LENGTH 12 #define ACPI_RESOURCE_LENGTH_NO_DATA 8 /* Id + Length fields */ -#define ACPI_SIZEOF_RESOURCE(type) (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type)) +#define ACPI_SIZEOF_RESOURCE(type) (u32) (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type)) #define ACPI_NEXT_RESOURCE(res) (struct acpi_resource *)((u8 *) res + res->length) diff --git a/include/acpi/amlresrc.h b/include/acpi/amlresrc.h index a3c46ba6358d..103aff07db18 100644 --- a/include/acpi/amlresrc.h +++ b/include/acpi/amlresrc.h @@ -96,165 +96,159 @@ struct asl_resource_node { * Resource descriptors defined in the ACPI specification. * * Packing/alignment must be BYTE because these descriptors - * are used to overlay the AML byte stream. + * are used to overlay the raw AML byte stream. */ #pragma pack(1) -struct asl_irq_format_desc { - u8 descriptor_type; - u16 irq_mask; +/* + * SMALL descriptors + */ +#define AML_RESOURCE_SMALL_HEADER_COMMON \ + u8 descriptor_type; + +struct aml_resource_small_header { +AML_RESOURCE_SMALL_HEADER_COMMON}; + +struct aml_resource_irq { + AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask; u8 flags; }; -struct asl_irq_noflags_desc { - u8 descriptor_type; - u16 irq_mask; +struct aml_resource_irq_noflags { + AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask; }; -struct asl_dma_format_desc { - u8 descriptor_type; - u8 dma_channel_mask; +struct aml_resource_dma { + AML_RESOURCE_SMALL_HEADER_COMMON u8 dma_channel_mask; u8 flags; }; -struct asl_start_dependent_desc { - u8 descriptor_type; - u8 flags; +struct aml_resource_start_dependent { + AML_RESOURCE_SMALL_HEADER_COMMON u8 flags; }; -struct asl_start_dependent_noprio_desc { - u8 descriptor_type; -}; +struct aml_resource_start_dependent_noprio { +AML_RESOURCE_SMALL_HEADER_COMMON}; -struct asl_end_dependent_desc { - u8 descriptor_type; -}; +struct aml_resource_end_dependent { +AML_RESOURCE_SMALL_HEADER_COMMON}; -struct asl_io_port_desc { - u8 descriptor_type; - u8 information; - u16 address_min; - u16 address_max; +struct aml_resource_io { + AML_RESOURCE_SMALL_HEADER_COMMON u8 information; + u16 minimum; + u16 maximum; u8 alignment; - u8 length; + u8 address_length; }; -struct asl_fixed_io_port_desc { - u8 descriptor_type; - u16 base_address; - u8 length; +struct aml_resource_fixed_io { + AML_RESOURCE_SMALL_HEADER_COMMON u16 address; + u8 address_length; }; -struct asl_small_vendor_desc { - u8 descriptor_type; - u8 vendor_defined[7]; -}; +struct aml_resource_vendor_small { +AML_RESOURCE_SMALL_HEADER_COMMON}; -struct asl_end_tag_desc { - u8 descriptor_type; - u8 checksum; +struct aml_resource_end_tag { + AML_RESOURCE_SMALL_HEADER_COMMON u8 checksum; }; -/* LARGE descriptors */ - -#define ASL_LARGE_HEADER_COMMON \ +/* + * LARGE descriptors + */ +#define AML_RESOURCE_LARGE_HEADER_COMMON \ u8 descriptor_type;\ - u16 length; + u16 resource_length; -struct asl_large_header { -ASL_LARGE_HEADER_COMMON}; +struct aml_resource_large_header { +AML_RESOURCE_LARGE_HEADER_COMMON}; -struct asl_memory_24_desc { - ASL_LARGE_HEADER_COMMON u8 information; - u16 address_min; - u16 address_max; +struct aml_resource_memory24 { + AML_RESOURCE_LARGE_HEADER_COMMON u8 information; + u16 minimum; + u16 maximum; u16 alignment; - u16 range_length; + u16 address_length; }; -struct asl_large_vendor_desc { - ASL_LARGE_HEADER_COMMON u8 vendor_defined[1]; -}; +struct aml_resource_vendor_large { +AML_RESOURCE_LARGE_HEADER_COMMON}; -struct asl_memory_32_desc { - ASL_LARGE_HEADER_COMMON u8 information; - u32 address_min; - u32 address_max; +struct aml_resource_memory32 { + AML_RESOURCE_LARGE_HEADER_COMMON u8 information; + u32 minimum; + u32 maximum; u32 alignment; - u32 range_length; + u32 address_length; }; -struct asl_fixed_memory_32_desc { - ASL_LARGE_HEADER_COMMON u8 information; - u32 base_address; - u32 range_length; +struct aml_resource_fixed_memory32 { + AML_RESOURCE_LARGE_HEADER_COMMON u8 information; + u32 address; + u32 address_length; }; -struct asl_extended_address_desc { - ASL_LARGE_HEADER_COMMON u8 resource_type; - u8 flags; - u8 specific_flags; - u8 revision_iD; +#define AML_RESOURCE_ADDRESS_COMMON \ + u8 resource_type; \ + u8 flags; \ + u8 specific_flags; + +struct aml_resource_address { +AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON}; + +struct aml_resource_extended_address64 { + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON u8 revision_iD; u8 reserved; u64 granularity; - u64 address_min; - u64 address_max; + u64 minimum; + u64 maximum; u64 translation_offset; u64 address_length; u64 type_specific_attributes; - u8 optional_fields[2]; /* Used for length calculation only */ }; -#define ASL_EXTENDED_ADDRESS_DESC_REVISION 1 /* ACPI 3.0 */ +#define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */ -struct asl_qword_address_desc { - ASL_LARGE_HEADER_COMMON u8 resource_type; - u8 flags; - u8 specific_flags; - u64 granularity; - u64 address_min; - u64 address_max; +struct aml_resource_address64 { + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON u64 granularity; + u64 minimum; + u64 maximum; u64 translation_offset; u64 address_length; - u8 optional_fields[2]; }; -struct asl_dword_address_desc { - ASL_LARGE_HEADER_COMMON u8 resource_type; - u8 flags; - u8 specific_flags; - u32 granularity; - u32 address_min; - u32 address_max; +struct aml_resource_address32 { + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON u32 granularity; + u32 minimum; + u32 maximum; u32 translation_offset; u32 address_length; - u8 optional_fields[2]; }; -struct asl_word_address_desc { - ASL_LARGE_HEADER_COMMON u8 resource_type; - u8 flags; - u8 specific_flags; - u16 granularity; - u16 address_min; - u16 address_max; +struct aml_resource_address16 { + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON u16 granularity; + u16 minimum; + u16 maximum; u16 translation_offset; u16 address_length; - u8 optional_fields[2]; }; -struct asl_extended_xrupt_desc { - ASL_LARGE_HEADER_COMMON u8 flags; +struct aml_resource_extended_irq { + AML_RESOURCE_LARGE_HEADER_COMMON u8 flags; u8 table_length; u32 interrupt_number[1]; /* res_source_index, res_source optional fields follow */ }; -struct asl_generic_register_desc { - ASL_LARGE_HEADER_COMMON u8 address_space_id; +struct aml_resource_generic_register { + AML_RESOURCE_LARGE_HEADER_COMMON u8 address_space_id; u8 bit_width; u8 bit_offset; - u8 access_size; /* ACPI 3.0, was Reserved */ + u8 access_size; /* ACPI 3.0, was previously Reserved */ u64 address; }; @@ -264,27 +258,39 @@ struct asl_generic_register_desc { /* Union of all resource descriptors, so we can allocate the worst case */ -union asl_resource_desc { - struct asl_irq_format_desc irq; - struct asl_dma_format_desc dma; - struct asl_io_port_desc iop; - struct asl_fixed_io_port_desc fio; - struct asl_start_dependent_desc std; - struct asl_end_dependent_desc end; - struct asl_small_vendor_desc smv; - struct asl_end_tag_desc et; - - struct asl_large_header lhd; - struct asl_memory_24_desc M24; - struct asl_large_vendor_desc lgv; - struct asl_memory_32_desc M32; - struct asl_fixed_memory_32_desc F32; - struct asl_qword_address_desc qas; - struct asl_dword_address_desc das; - struct asl_word_address_desc was; - struct asl_extended_address_desc eas; - struct asl_extended_xrupt_desc exx; - struct asl_generic_register_desc grg; +union aml_resource { + /* Descriptor headers */ + + struct aml_resource_small_header small_header; + struct aml_resource_large_header large_header; + + /* Small resource descriptors */ + + struct aml_resource_irq irq; + struct aml_resource_dma dma; + struct aml_resource_start_dependent start_dpf; + struct aml_resource_end_dependent end_dpf; + struct aml_resource_io io; + struct aml_resource_fixed_io fixed_io; + struct aml_resource_vendor_small vendor_small; + struct aml_resource_end_tag end_tag; + + /* Large resource descriptors */ + + struct aml_resource_memory24 memory24; + struct aml_resource_generic_register generic_reg; + struct aml_resource_vendor_large vendor_large; + struct aml_resource_memory32 memory32; + struct aml_resource_fixed_memory32 fixed_memory32; + struct aml_resource_address16 address16; + struct aml_resource_address32 address32; + struct aml_resource_address64 address64; + struct aml_resource_extended_address64 ext_address64; + struct aml_resource_extended_irq extended_irq; + + /* Utility overlays */ + + struct aml_resource_address address; u32 u32_item; u16 u16_item; u8 U8item; diff --git a/include/asm-x86_64/mpspec.h b/include/asm-x86_64/mpspec.h index 6f8a17d105ab..ac59045e7bab 100644 --- a/include/asm-x86_64/mpspec.h +++ b/include/asm-x86_64/mpspec.h @@ -188,7 +188,7 @@ extern void mp_register_lapic_address (u64 address); extern void mp_register_ioapic (u8 id, u32 address, u32 gsi_base); extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 gsi); extern void mp_config_acpi_legacy_irqs (void); -extern int mp_register_gsi (u32 gsi, int edge_level, int active_high_low); +extern int mp_register_gsi (u32 gsi, int triggering, int polarity); #endif /*CONFIG_X86_IO_APIC*/ #endif diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 026c3c011dc0..84d3d9f034ce 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -435,7 +435,7 @@ extern int sbf_port ; #endif /* !CONFIG_ACPI */ -int acpi_register_gsi (u32 gsi, int edge_level, int active_high_low); +int acpi_register_gsi (u32 gsi, int triggering, int polarity); int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); /* -- cgit v1.2.3 From 0897831bb54eb36fd9e2a22da7f0f64be1b20d09 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Fri, 21 Oct 2005 00:00:00 -0400 Subject: [ACPI] ACPICA 20051021 Implemented support for the EM64T and other x86_64 processors. This essentially entails recognizing that these processors support non-aligned memory transfers. Previously, all 64-bit processors were assumed to lack hardware support for non-aligned transfers. Completed conversion of the Resource Manager to nearly full table-driven operation. Specifically, the resource conversion code (convert AML to internal format and the reverse) and the debug code to dump internal resource descriptors are fully table-driven, reducing code and data size and improving maintainability. The OSL interfaces for Acquire and Release Lock now use a 64-bit flag word on 64-bit processors instead of a fixed 32-bit word. (Alexey Starikovskiy) Implemented support within the resource conversion code for the Type-Specific byte within the various ACPI 3.0 *WordSpace macros. Fixed some issues within the resource conversion code for the type-specific flags for both Memory and I/O address resource descriptors. For Memory, implemented support for the MTP and TTP flags. For I/O, split the TRS and TTP flags into two separate fields. Signed-off-by: Bob Moore Signed-off-by: Len Brown --- arch/ia64/pci/pci.c | 2 +- drivers/acpi/events/evgpe.c | 8 +- drivers/acpi/events/evgpeblk.c | 10 +- drivers/acpi/events/evxface.c | 4 +- drivers/acpi/executer/exmisc.c | 5 +- drivers/acpi/executer/exregion.c | 4 +- drivers/acpi/osl.c | 6 +- drivers/acpi/resources/rsaddr.c | 745 ++++++----------------- drivers/acpi/resources/rscalc.c | 71 ++- drivers/acpi/resources/rsdump.c | 1207 +++++++++++++++---------------------- drivers/acpi/resources/rsinfo.c | 115 ++-- drivers/acpi/resources/rsio.c | 333 +++++----- drivers/acpi/resources/rsirq.c | 393 ++++-------- drivers/acpi/resources/rslist.c | 92 +-- drivers/acpi/resources/rsmemory.c | 303 ++++------ drivers/acpi/resources/rsmisc.c | 814 +++++++++++++------------ drivers/acpi/resources/rsutils.c | 269 ++++----- drivers/acpi/resources/rsxface.c | 2 +- drivers/acpi/tables/tbutils.c | 5 +- drivers/acpi/utilities/utalloc.c | 2 +- drivers/acpi/utilities/utglobal.c | 64 +- drivers/acpi/utilities/utmisc.c | 146 ++++- drivers/pnp/pnpacpi/rsparser.c | 12 +- include/acpi/acconfig.h | 2 +- include/acpi/acdisasm.h | 17 +- include/acpi/acmacros.h | 6 +- include/acpi/acpiosxf.h | 4 +- include/acpi/acresrc.h | 401 ++++++------ include/acpi/actypes.h | 183 +++--- include/acpi/acutils.h | 7 +- include/acpi/amlresrc.h | 14 +- include/acpi/platform/acenv.h | 11 +- 32 files changed, 2275 insertions(+), 2982 deletions(-) (limited to 'include') diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 25f923d050e3..5536027da9d8 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c @@ -195,7 +195,7 @@ add_io_space (struct pci_root_info *info, struct acpi_resource_address64 *addr) min = addr->minimum; max = min + addr->address_length - 1; - if (addr->attribute.io.translation_attribute == ACPI_SPARSE_TRANSLATION) + if (addr->info.io.translation_type == ACPI_SPARSE_TRANSLATION) sparse = 1; space_nr = new_space(addr->translation_offset, sparse); diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c index f51c3b16c608..bdd86537738e 100644 --- a/drivers/acpi/events/evgpe.c +++ b/drivers/acpi/events/evgpe.c @@ -372,14 +372,14 @@ struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device, u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) { + acpi_status status; + struct acpi_gpe_block_info *gpe_block; + struct acpi_gpe_register_info *gpe_register_info; u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; u8 enabled_status_byte; - struct acpi_gpe_register_info *gpe_register_info; u32 status_reg; u32 enable_reg; - u32 flags; - acpi_status status; - struct acpi_gpe_block_info *gpe_block; + acpi_native_uint flags; acpi_native_uint i; acpi_native_uint j; diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c index b312eb33c43e..7ca10c5f2914 100644 --- a/drivers/acpi/events/evgpeblk.c +++ b/drivers/acpi/events/evgpeblk.c @@ -136,7 +136,7 @@ acpi_status acpi_ev_walk_gpe_list(ACPI_GPE_CALLBACK gpe_walk_callback) struct acpi_gpe_block_info *gpe_block; struct acpi_gpe_xrupt_info *gpe_xrupt_info; acpi_status status = AE_OK; - u32 flags; + acpi_native_uint flags; ACPI_FUNCTION_TRACE("ev_walk_gpe_list"); @@ -479,7 +479,7 @@ static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 struct acpi_gpe_xrupt_info *next_gpe_xrupt; struct acpi_gpe_xrupt_info *gpe_xrupt; acpi_status status; - u32 flags; + acpi_native_uint flags; ACPI_FUNCTION_TRACE("ev_get_gpe_xrupt_block"); @@ -553,7 +553,7 @@ static acpi_status acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt) { acpi_status status; - u32 flags; + acpi_native_uint flags; ACPI_FUNCTION_TRACE("ev_delete_gpe_xrupt"); @@ -610,7 +610,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, struct acpi_gpe_block_info *next_gpe_block; struct acpi_gpe_xrupt_info *gpe_xrupt_block; acpi_status status; - u32 flags; + acpi_native_uint flags; ACPI_FUNCTION_TRACE("ev_install_gpe_block"); @@ -663,7 +663,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block) { acpi_status status; - u32 flags; + acpi_native_uint flags; ACPI_FUNCTION_TRACE("ev_install_gpe_block"); diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c index 43b33d19cdf9..57d73299298e 100644 --- a/drivers/acpi/events/evxface.c +++ b/drivers/acpi/events/evxface.c @@ -562,7 +562,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device, struct acpi_gpe_event_info *gpe_event_info; struct acpi_handler_info *handler; acpi_status status; - u32 flags; + acpi_native_uint flags; ACPI_FUNCTION_TRACE("acpi_install_gpe_handler"); @@ -653,7 +653,7 @@ acpi_remove_gpe_handler(acpi_handle gpe_device, struct acpi_gpe_event_info *gpe_event_info; struct acpi_handler_info *handler; acpi_status status; - u32 flags; + acpi_native_uint flags; ACPI_FUNCTION_TRACE("acpi_remove_gpe_handler"); diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c index a3f4d72bedc9..1899ab251393 100644 --- a/drivers/acpi/executer/exmisc.c +++ b/drivers/acpi/executer/exmisc.c @@ -625,9 +625,8 @@ acpi_ex_do_logical_op(u16 opcode, /* Lexicographic compare: compare the data bytes */ - compare = ACPI_MEMCMP((const char *)operand0->buffer.pointer, - (const char *)local_operand1->buffer. - pointer, + compare = ACPI_MEMCMP(operand0->buffer.pointer, + local_operand1->buffer.pointer, (length0 > length1) ? length1 : length0); switch (opcode) { diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c index 9a2f5bea3afe..1897379b5f90 100644 --- a/drivers/acpi/executer/exregion.c +++ b/drivers/acpi/executer/exregion.c @@ -77,7 +77,7 @@ acpi_ex_system_memory_space_handler(u32 function, struct acpi_mem_space_context *mem_info = region_context; u32 length; acpi_size window_size; -#ifndef ACPI_MISALIGNED_TRANSFERS +#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED u32 remainder; #endif @@ -109,7 +109,7 @@ acpi_ex_system_memory_space_handler(u32 function, return_ACPI_STATUS(AE_AML_OPERAND_VALUE); } -#ifndef ACPI_MISALIGNED_TRANSFERS +#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED /* * Hardware does not support non-aligned data transfers, we must verify * the request. diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index e3cd0b16031a..4ece850b2af1 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -1058,11 +1058,9 @@ EXPORT_SYMBOL(max_cstate); * Acquire a spinlock. * * handle is a pointer to the spinlock_t. - * flags is *not* the result of save_flags - it is an ACPI-specific flag variable - * that indicates whether we are at interrupt level. */ -unsigned long acpi_os_acquire_lock(acpi_handle handle) +acpi_native_uint acpi_os_acquire_lock(acpi_handle handle) { unsigned long flags; spin_lock_irqsave((spinlock_t *) handle, flags); @@ -1073,7 +1071,7 @@ unsigned long acpi_os_acquire_lock(acpi_handle handle) * Release a spinlock. See above. */ -void acpi_os_release_lock(acpi_handle handle, unsigned long flags) +void acpi_os_release_lock(acpi_handle handle, acpi_native_uint flags) { spin_unlock_irqrestore((spinlock_t *) handle, flags); } diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c index 6f48ebf3304e..4ac942badbc0 100644 --- a/drivers/acpi/resources/rsaddr.c +++ b/drivers/acpi/resources/rsaddr.c @@ -47,683 +47,334 @@ #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME("rsaddr") -/* Local prototypes */ -static void -acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags); - -static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource); - -static void -acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags); - -static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource); - -static void -acpi_rs_set_address_common(union aml_resource *aml, - struct acpi_resource *resource); - -static u8 -acpi_rs_get_address_common(struct acpi_resource *resource, - union aml_resource *aml); - -/******************************************************************************* - * - * FUNCTION: acpi_rs_decode_general_flags - * - * PARAMETERS: Resource - Address resource data struct - * Flags - Raw AML flag byte - * - * RETURN: Decoded flag bits in resource struct - * - * DESCRIPTION: Decode a general flag byte to an address resource struct - * - ******************************************************************************/ - -static void -acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags) -{ - ACPI_FUNCTION_ENTRY(); - - /* Producer / Consumer - flag bit[0] */ - - resource->address.producer_consumer = (u32) (flags & 0x01); - - /* Decode (_DEC) - flag bit[1] */ - - resource->address.decode = (u32) ((flags >> 1) & 0x01); - - /* Min Address Fixed (_MIF) - flag bit[2] */ - - resource->address.min_address_fixed = (u32) ((flags >> 2) & 0x01); - - /* Max Address Fixed (_MAF) - flag bit[3] */ - - resource->address.max_address_fixed = (u32) ((flags >> 3) & 0x01); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_encode_general_flags - * - * PARAMETERS: Resource - Address resource data struct - * - * RETURN: Encoded general flag byte - * - * DESCRIPTION: Construct a general flag byte from an address resource struct - * - ******************************************************************************/ - -static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource) -{ - ACPI_FUNCTION_ENTRY(); - - return ((u8) - - /* Producer / Consumer - flag bit[0] */ - ((resource->address.producer_consumer & 0x01) | - /* Decode (_DEC) - flag bit[1] */ - ((resource->address.decode & 0x01) << 1) | - /* Min Address Fixed (_MIF) - flag bit[2] */ - ((resource->address.min_address_fixed & 0x01) << 2) | - /* Max Address Fixed (_MAF) - flag bit[3] */ - ((resource->address.max_address_fixed & 0x01) << 3)) - ); -} - /******************************************************************************* * - * FUNCTION: acpi_rs_decode_specific_flags - * - * PARAMETERS: Resource - Address resource data struct - * Flags - Raw AML flag byte - * - * RETURN: Decoded flag bits in attribute struct - * - * DESCRIPTION: Decode a type-specific flag byte to an attribute struct. - * Type-specific flags are only defined for the Memory and IO - * resource types. + * acpi_rs_convert_address16 - All WORD (16-bit) address resources * ******************************************************************************/ +struct acpi_rsconvert_info acpi_rs_convert_address16[5] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16, + ACPI_RS_SIZE(struct acpi_resource_address16), + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address16)}, -static void -acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags) -{ - ACPI_FUNCTION_ENTRY(); - - if (resource->address.resource_type == ACPI_MEMORY_RANGE) { - /* Write Status (_RW) - flag bit[0] */ - - resource->address.attribute.memory.read_write_attribute = - (u16) (flags & 0x01); + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16, + sizeof(struct aml_resource_address16), + 0}, - /* Memory Attributes (_MEM) - flag bits[2:1] */ + /* Resource Type, General Flags, and Type-Specific Flags */ - resource->address.attribute.memory.cache_attribute = - (u16) ((flags >> 1) & 0x03); - } else if (resource->address.resource_type == ACPI_IO_RANGE) { - /* Ranges (_RNG) - flag bits[1:0] */ - - resource->address.attribute.io.range_attribute = - (u16) (flags & 0x03); - - /* Translations (_TTP and _TRS) - flag bits[5:4] */ - - resource->address.attribute.io.translation_attribute = - (u16) ((flags >> 4) & 0x03); - } -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_encode_specific_flags - * - * PARAMETERS: Resource - Address resource data struct - * - * RETURN: Encoded type-specific flag byte - * - * DESCRIPTION: Construct a type-specific flag byte from an attribute struct. - * Type-specific flags are only defined for the Memory and IO - * resource types. - * - ******************************************************************************/ - -static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource) -{ - ACPI_FUNCTION_ENTRY(); - - if (resource->address.resource_type == ACPI_MEMORY_RANGE) { - return ((u8) - - /* Write Status (_RW) - flag bit[0] */ - ((resource->address.attribute.memory. - read_write_attribute & 0x01) | - /* Memory Attributes (_MEM) - flag bits[2:1] */ - ((resource->address.attribute.memory. - cache_attribute & 0x03) << 1))); - } else if (resource->address.resource_type == ACPI_IO_RANGE) { - return ((u8) - - /* Ranges (_RNG) - flag bits[1:0] */ - ((resource->address.attribute.io. - range_attribute & 0x03) | - /* Translations (_TTP and _TRS) - flag bits[5:4] */ - ((resource->address.attribute.io. - translation_attribute & 0x03) << 4))); - } - - return (0); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_set_address_common - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * Resource - Pointer to the internal resource struct - * - * RETURN: None - * - * DESCRIPTION: Convert common flag fields from a resource descriptor to an - * AML descriptor - * - ******************************************************************************/ - -static void -acpi_rs_set_address_common(union aml_resource *aml, - struct acpi_resource *resource) -{ - ACPI_FUNCTION_ENTRY(); - - /* Set the Resource Type (Memory, Io, bus_number, etc.) */ - - aml->address.resource_type = (u8) resource->data.address.resource_type; - - /* Set the general flags */ - - aml->address.flags = acpi_rs_encode_general_flags(&resource->data); - - /* Set the type-specific flags */ - - aml->address.specific_flags = - acpi_rs_encode_specific_flags(&resource->data); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_get_address_common - * - * PARAMETERS: Resource - Pointer to the internal resource struct - * Aml - Pointer to the AML resource descriptor - * - * RETURN: TRUE if the resource_type field is OK, FALSE otherwise - * - * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor - * to an internal resource descriptor - * - ******************************************************************************/ - -static u8 -acpi_rs_get_address_common(struct acpi_resource *resource, - union aml_resource *aml) -{ - ACPI_FUNCTION_ENTRY(); - - /* Validate resource type */ - - if ((aml->address.resource_type > 2) - && (aml->address.resource_type < 0xC0)) { - return (FALSE); - } - - /* Get the Resource Type (Memory, Io, bus_number, etc.) */ - - resource->data.address.resource_type = aml->address.resource_type; - - /* Get the General Flags */ - - acpi_rs_decode_general_flags(&resource->data, aml->address.flags); - - /* Get the Type-Specific Flags */ - - acpi_rs_decode_specific_flags(&resource->data, - aml->address.specific_flags); - return (TRUE); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_get_address16 - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. - * - ******************************************************************************/ - -acpi_status -acpi_rs_get_address16(union aml_resource * aml, - u16 aml_resource_length, struct acpi_resource * resource) -{ - ACPI_FUNCTION_TRACE("rs_get_address16"); - - /* Get the Resource Type, general flags, and type-specific flags */ - - if (!acpi_rs_get_address_common(resource, aml)) { - return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); - } + {ACPI_RSC_ADDRESS, 0, 0, 0}, /* - * Get the following contiguous fields from the AML descriptor: + * These fields are contiguous in both the source and destination: * Address Granularity * Address Range Minimum * Address Range Maximum * Address Translation Offset * Address Length */ - acpi_rs_move_data(&resource->data.address16.granularity, - &aml->address16.granularity, 5, - ACPI_MOVE_TYPE_16_TO_32); - - /* Get the optional resource_source (index and string) */ - - resource->length = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16) + - acpi_rs_get_resource_source(aml_resource_length, - sizeof(struct aml_resource_address16), - &resource->data.address16. - resource_source, aml, NULL); + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.address16.granularity), + AML_OFFSET(address16.granularity), + 5}, - /* Complete the resource header */ + /* Optional resource_source (Index and String) */ - resource->type = ACPI_RESOURCE_TYPE_ADDRESS16; - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address16.resource_source), + 0, + sizeof(struct aml_resource_address16)} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_set_address16 - * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Aml - Where the AML descriptor is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. + * acpi_rs_convert_address32 - All DWORD (32-bit) address resources * ******************************************************************************/ -acpi_status -acpi_rs_set_address16(struct acpi_resource *resource, union aml_resource *aml) -{ - acpi_size descriptor_length; +struct acpi_rsconvert_info acpi_rs_convert_address32[5] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32, + ACPI_RS_SIZE(struct acpi_resource_address32), + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address32)}, - ACPI_FUNCTION_TRACE("rs_set_address16"); + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32, + sizeof(struct aml_resource_address32), + 0}, - /* Set the Resource Type, General Flags, and Type-Specific Flags */ + /* Resource Type, General Flags, and Type-Specific Flags */ - acpi_rs_set_address_common(aml, resource); + {ACPI_RSC_ADDRESS, 0, 0, 0}, /* - * Set the following contiguous fields in the AML descriptor: + * These fields are contiguous in both the source and destination: * Address Granularity * Address Range Minimum * Address Range Maximum * Address Translation Offset * Address Length */ - acpi_rs_move_data(&aml->address16.granularity, - &resource->data.address16.granularity, 5, - ACPI_MOVE_TYPE_32_TO_16); - - /* Resource Source Index and Resource Source are optional */ + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.address32.granularity), + AML_OFFSET(address32.granularity), + 5}, - descriptor_length = acpi_rs_set_resource_source(aml, - sizeof(struct - aml_resource_address16), - &resource->data. - address16. - resource_source); + /* Optional resource_source (Index and String) */ - /* Complete the AML descriptor header */ - - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS16, - descriptor_length, aml); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address32.resource_source), + 0, + sizeof(struct aml_resource_address32)} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_get_address32 - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. + * acpi_rs_convert_address64 - All QWORD (64-bit) address resources * ******************************************************************************/ -acpi_status -acpi_rs_get_address32(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource) -{ +struct acpi_rsconvert_info acpi_rs_convert_address64[5] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64, + ACPI_RS_SIZE(struct acpi_resource_address64), + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address64)}, - ACPI_FUNCTION_TRACE("rs_get_address32"); + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64, + sizeof(struct aml_resource_address64), + 0}, - /* Get the Resource Type, general flags, and type-specific flags */ + /* Resource Type, General Flags, and Type-Specific Flags */ - if (!acpi_rs_get_address_common(resource, (void *)aml)) { - return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); - } + {ACPI_RSC_ADDRESS, 0, 0, 0}, /* - * Get the following contiguous fields from the AML descriptor: + * These fields are contiguous in both the source and destination: * Address Granularity * Address Range Minimum * Address Range Maximum * Address Translation Offset * Address Length */ - acpi_rs_move_data(&resource->data.address32.granularity, - &aml->address32.granularity, 5, - ACPI_MOVE_TYPE_32_TO_32); + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.address64.granularity), + AML_OFFSET(address64.granularity), + 5}, - /* Get the optional resource_source (index and string) */ + /* Optional resource_source (Index and String) */ - resource->length = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32) + - acpi_rs_get_resource_source(aml_resource_length, - sizeof(struct aml_resource_address32), - &resource->data.address32. - resource_source, aml, NULL); - - /* Complete the resource header */ - - resource->type = ACPI_RESOURCE_TYPE_ADDRESS32; - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address64.resource_source), + 0, + sizeof(struct aml_resource_address64)} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_set_address32 - * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Aml - Where the AML descriptor is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. + * acpi_rs_convert_ext_address64 - All Extended (64-bit) address resources * ******************************************************************************/ -acpi_status -acpi_rs_set_address32(struct acpi_resource *resource, union aml_resource *aml) -{ - acpi_size descriptor_length; +struct acpi_rsconvert_info acpi_rs_convert_ext_address64[5] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, + ACPI_RS_SIZE(struct acpi_resource_extended_address64), + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_address64)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64, + sizeof(struct aml_resource_extended_address64), + 0}, - ACPI_FUNCTION_TRACE("rs_set_address32"); + /* Resource Type, General Flags, and Type-Specific Flags */ - /* Set the Resource Type, General Flags, and Type-Specific Flags */ + {ACPI_RSC_ADDRESS, 0, 0, 0}, - acpi_rs_set_address_common(aml, resource); + /* Revision ID */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.ext_address64.revision_iD), + AML_OFFSET(ext_address64.revision_iD), + 1}, /* - * Set the following contiguous fields in the AML descriptor: + * These fields are contiguous in both the source and destination: * Address Granularity * Address Range Minimum * Address Range Maximum * Address Translation Offset * Address Length + * Type-Specific Attribute */ - acpi_rs_move_data(&aml->address32.granularity, - &resource->data.address32.granularity, 5, - ACPI_MOVE_TYPE_32_TO_32); - - /* Resource Source Index and Resource Source are optional */ - - descriptor_length = acpi_rs_set_resource_source(aml, - sizeof(struct - aml_resource_address32), - &resource->data. - address32. - resource_source); - - /* Complete the AML descriptor header */ - - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS32, - descriptor_length, aml); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.ext_address64.granularity), + AML_OFFSET(ext_address64.granularity), + 6} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_get_address64 - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. + * acpi_rs_convert_general_flags - Flags common to all address descriptors * ******************************************************************************/ -acpi_status -acpi_rs_get_address64(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource) -{ - ACPI_FUNCTION_TRACE("rs_get_address64"); +static struct acpi_rsconvert_info acpi_rs_convert_general_flags[6] = { + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.flags), + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_general_flags)}, - /* Get the Resource Type, general Flags, and type-specific Flags */ + /* Resource Type (Memory, Io, bus_number, etc.) */ - if (!acpi_rs_get_address_common(resource, aml)) { - return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); - } + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.address.resource_type), + AML_OFFSET(address.resource_type), + 1}, - /* - * Get the following contiguous fields from the AML descriptor: - * Address Granularity - * Address Range Minimum - * Address Range Maximum - * Address Translation Offset - * Address Length - */ - acpi_rs_move_data(&resource->data.address64.granularity, - &aml->address64.granularity, 5, - ACPI_MOVE_TYPE_64_TO_64); + /* General Flags - Consume, Decode, min_fixed, max_fixed */ - /* Get the optional resource_source (index and string) */ + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.producer_consumer), + AML_OFFSET(address.flags), + 0}, - resource->length = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64) + - acpi_rs_get_resource_source(aml_resource_length, - sizeof(struct aml_resource_address64), - &resource->data.address64. - resource_source, aml, NULL); + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.decode), + AML_OFFSET(address.flags), + 1}, - /* Complete the resource header */ + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.min_address_fixed), + AML_OFFSET(address.flags), + 2}, - resource->type = ACPI_RESOURCE_TYPE_ADDRESS64; - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.max_address_fixed), + AML_OFFSET(address.flags), + 3} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_set_address64 - * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Aml - Where the AML descriptor is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. + * acpi_rs_convert_mem_flags - Flags common to Memory address descriptors * ******************************************************************************/ -acpi_status -acpi_rs_set_address64(struct acpi_resource *resource, union aml_resource *aml) -{ - acpi_size descriptor_length; +static struct acpi_rsconvert_info acpi_rs_convert_mem_flags[5] = { + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.specific_flags), + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_mem_flags)}, - ACPI_FUNCTION_TRACE("rs_set_address64"); + /* Memory-specific flags */ - /* Set the Resource Type, General Flags, and Type-Specific Flags */ + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.write_protect), + AML_OFFSET(address.specific_flags), + 0}, - acpi_rs_set_address_common(aml, resource); + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.caching), + AML_OFFSET(address.specific_flags), + 1}, - /* - * Set the following contiguous fields in the AML descriptor: - * Address Granularity - * Address Range Minimum - * Address Range Maximum - * Address Translation Offset - * Address Length - */ - acpi_rs_move_data(&aml->address64.granularity, - &resource->data.address64.granularity, 5, - ACPI_MOVE_TYPE_64_TO_64); + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.range_type), + AML_OFFSET(address.specific_flags), + 3}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.translation), + AML_OFFSET(address.specific_flags), + 5} +}; + +/******************************************************************************* + * + * acpi_rs_convert_io_flags - Flags common to I/O address descriptors + * + ******************************************************************************/ - /* Resource Source Index and Resource Source are optional */ +static struct acpi_rsconvert_info acpi_rs_convert_io_flags[4] = { + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.specific_flags), + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io_flags)}, - descriptor_length = acpi_rs_set_resource_source(aml, - sizeof(struct - aml_resource_address64), - &resource->data. - address64. - resource_source); + /* I/O-specific flags */ - /* Complete the AML descriptor header */ + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.io.range_type), + AML_OFFSET(address.specific_flags), + 0}, - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS64, - descriptor_length, aml); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.io.translation), + AML_OFFSET(address.specific_flags), + 4}, + + {ACPI_RSC_1BITFLAG, + ACPI_RS_OFFSET(data.address.info.io.translation_type), + AML_OFFSET(address.specific_flags), + 5} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_get_ext_address64 + * FUNCTION: acpi_rs_get_address_common * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned + * PARAMETERS: Resource - Pointer to the internal resource struct + * Aml - Pointer to the AML resource descriptor * - * RETURN: Status + * RETURN: TRUE if the resource_type field is OK, FALSE otherwise * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. + * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor + * to an internal resource descriptor * ******************************************************************************/ -acpi_status -acpi_rs_get_ext_address64(union aml_resource *aml, - u16 aml_resource_length, - struct acpi_resource *resource) +u8 +acpi_rs_get_address_common(struct acpi_resource *resource, + union aml_resource *aml) { + ACPI_FUNCTION_ENTRY(); - ACPI_FUNCTION_TRACE("rs_get_ext_address64"); - - /* Get the Resource Type, general flags, and type-specific flags */ + /* Validate the Resource Type */ - if (!acpi_rs_get_address_common(resource, aml)) { - return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); + if ((aml->address.resource_type > 2) + && (aml->address.resource_type < 0xC0)) { + return (FALSE); } - /* - * Get and validate the Revision ID - * Note: Only one revision ID is currently supported - */ - resource->data.ext_address64.revision_iD = - aml->ext_address64.revision_iD; - if (aml->ext_address64.revision_iD != - AML_RESOURCE_EXTENDED_ADDRESS_REVISION) { - return_ACPI_STATUS(AE_SUPPORT); - } + /* Get the Resource Type and General Flags */ - /* - * Get the following contiguous fields from the AML descriptor: - * Address Granularity - * Address Range Minimum - * Address Range Maximum - * Address Translation Offset - * Address Length - * Type-Specific Attribute - */ - acpi_rs_move_data(&resource->data.ext_address64.granularity, - &aml->ext_address64.granularity, 6, - ACPI_MOVE_TYPE_64_TO_64); + (void)acpi_rs_convert_aml_to_resource(resource, aml, + acpi_rs_convert_general_flags); + + /* Get the Type-Specific Flags (Memory and I/O descriptors only) */ - /* Complete the resource header */ + if (resource->data.address.resource_type == ACPI_MEMORY_RANGE) { + (void)acpi_rs_convert_aml_to_resource(resource, aml, + acpi_rs_convert_mem_flags); + } else if (resource->data.address.resource_type == ACPI_IO_RANGE) { + (void)acpi_rs_convert_aml_to_resource(resource, aml, + acpi_rs_convert_io_flags); + } else { + /* Generic resource type, just grab the type_specific byte */ - resource->type = ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64; - resource->length = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_address64); - return_ACPI_STATUS(AE_OK); + resource->data.address.info.type_specific = + aml->address.specific_flags; + } + + return (TRUE); } /******************************************************************************* * - * FUNCTION: acpi_rs_set_ext_address64 + * FUNCTION: acpi_rs_set_address_common * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Aml - Where the AML descriptor is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * Resource - Pointer to the internal resource struct * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. + * DESCRIPTION: Convert common flag fields from a resource descriptor to an + * AML descriptor * ******************************************************************************/ -acpi_status -acpi_rs_set_ext_address64(struct acpi_resource *resource, - union aml_resource *aml) +void +acpi_rs_set_address_common(union aml_resource *aml, + struct acpi_resource *resource) { - ACPI_FUNCTION_TRACE("rs_set_ext_address64"); + ACPI_FUNCTION_ENTRY(); - /* Set the Resource Type, General Flags, and Type-Specific Flags */ + /* Set the Resource Type and General Flags */ - acpi_rs_set_address_common(aml, resource); + (void)acpi_rs_convert_resource_to_aml(resource, aml, + acpi_rs_convert_general_flags); - /* Only one Revision ID is currently supported */ + /* Set the Type-Specific Flags (Memory and I/O descriptors only) */ - aml->ext_address64.revision_iD = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; - aml->ext_address64.reserved = 0; + if (resource->data.address.resource_type == ACPI_MEMORY_RANGE) { + (void)acpi_rs_convert_resource_to_aml(resource, aml, + acpi_rs_convert_mem_flags); + } else if (resource->data.address.resource_type == ACPI_IO_RANGE) { + (void)acpi_rs_convert_resource_to_aml(resource, aml, + acpi_rs_convert_io_flags); + } else { + /* Generic resource type, just copy the type_specific byte */ - /* - * Set the following contiguous fields in the AML descriptor: - * Address Granularity - * Address Range Minimum - * Address Range Maximum - * Address Translation Offset - * Address Length - * Type-Specific Attribute - */ - acpi_rs_move_data(&aml->ext_address64.granularity, - &resource->data.address64.granularity, 6, - ACPI_MOVE_TYPE_64_TO_64); - - /* Complete the AML descriptor header */ - - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64, - sizeof(struct - aml_resource_extended_address64), - aml); - return_ACPI_STATUS(AE_OK); + aml->address.specific_flags = + resource->data.address.info.type_specific; + } } diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c index d170dee07ce9..c29d3a447278 100644 --- a/drivers/acpi/resources/rscalc.c +++ b/drivers/acpi/resources/rscalc.c @@ -52,7 +52,7 @@ ACPI_MODULE_NAME("rscalc") /* Local prototypes */ static u8 acpi_rs_count_set_bits(u16 bit_field); -static acpi_size +static acpi_rs_length acpi_rs_struct_option_length(struct acpi_resource_source *resource_source); static u32 @@ -100,7 +100,7 @@ static u8 acpi_rs_count_set_bits(u16 bit_field) * ******************************************************************************/ -static acpi_size +static acpi_rs_length acpi_rs_struct_option_length(struct acpi_resource_source *resource_source) { ACPI_FUNCTION_ENTRY(); @@ -111,7 +111,7 @@ acpi_rs_struct_option_length(struct acpi_resource_source *resource_source) * resource_source_index (1). */ if (resource_source->string_ptr) { - return ((acpi_size) resource_source->string_length + 1); + return ((acpi_rs_length) (resource_source->string_length + 1)); } return (0); @@ -184,7 +184,7 @@ acpi_status acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) { acpi_size aml_size_needed = 0; - acpi_size segment_size; + acpi_rs_length total_size; ACPI_FUNCTION_TRACE("rs_get_aml_length"); @@ -199,7 +199,7 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) /* Get the base size of the (external stream) resource descriptor */ - segment_size = acpi_gbl_aml_resource_sizes[resource->type]; + total_size = acpi_gbl_aml_resource_sizes[resource->type]; /* * Augment the base size for descriptors with optional and/or @@ -216,13 +216,14 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) if (resource->data.vendor.byte_length > 7) { /* Base size of a Large resource descriptor */ - segment_size = + total_size = sizeof(struct aml_resource_large_header); } /* Add the size of the vendor-specific data */ - segment_size += resource->data.vendor.byte_length; + total_size = (acpi_rs_length) + (total_size + resource->data.vendor.byte_length); break; case ACPI_RESOURCE_TYPE_END_TAG: @@ -230,7 +231,7 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) * End Tag: * We are done -- return the accumulated total size. */ - *size_needed = aml_size_needed + segment_size; + *size_needed = aml_size_needed + total_size; /* Normal exit */ @@ -241,10 +242,11 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) * 16-Bit Address Resource: * Add the size of the optional resource_source info */ - segment_size += - acpi_rs_struct_option_length(&resource->data. - address16. - resource_source); + total_size = (acpi_rs_length) + (total_size + + acpi_rs_struct_option_length(&resource->data. + address16. + resource_source)); break; case ACPI_RESOURCE_TYPE_ADDRESS32: @@ -252,10 +254,11 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) * 32-Bit Address Resource: * Add the size of the optional resource_source info */ - segment_size += - acpi_rs_struct_option_length(&resource->data. - address32. - resource_source); + total_size = (acpi_rs_length) + (total_size + + acpi_rs_struct_option_length(&resource->data. + address32. + resource_source)); break; case ACPI_RESOURCE_TYPE_ADDRESS64: @@ -263,10 +266,11 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) * 64-Bit Address Resource: * Add the size of the optional resource_source info */ - segment_size += - acpi_rs_struct_option_length(&resource->data. - address64. - resource_source); + total_size = (acpi_rs_length) + (total_size + + acpi_rs_struct_option_length(&resource->data. + address64. + resource_source)); break; case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: @@ -275,16 +279,14 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) * Add the size of each additional optional interrupt beyond the * required 1 (4 bytes for each u32 interrupt number) */ - segment_size += (((acpi_size) - resource->data.extended_irq. - interrupt_count - 1) * 4); - - /* Add the size of the optional resource_source info */ - - segment_size += - acpi_rs_struct_option_length(&resource->data. - extended_irq. - resource_source); + total_size = (acpi_rs_length) + (total_size + + ((resource->data.extended_irq.interrupt_count - + 1) * 4) + + /* Add the size of the optional resource_source info */ + acpi_rs_struct_option_length(&resource->data. + extended_irq. + resource_source)); break; default: @@ -293,7 +295,7 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) /* Update the total */ - aml_size_needed += segment_size; + aml_size_needed += total_size; /* Point to the next object */ @@ -341,7 +343,7 @@ acpi_rs_get_list_length(u8 * aml_buffer, while (bytes_parsed < aml_buffer_length) { /* The next byte in the stream is the resource descriptor type */ - resource_type = acpi_rs_get_resource_type(*aml_buffer); + resource_type = acpi_ut_get_resource_type(aml_buffer); /* Get the base stream size and structure sizes for the descriptor */ @@ -352,10 +354,7 @@ acpi_rs_get_list_length(u8 * aml_buffer, /* Get the Length field from the input resource descriptor */ - resource_length = - acpi_rs_get_resource_length(ACPI_CAST_PTR - (union aml_resource, - aml_buffer)); + resource_length = acpi_ut_get_resource_length(aml_buffer); /* Augment the size for descriptors with optional fields */ diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c index 2f8990845b2d..27172a3d55d7 100644 --- a/drivers/acpi/resources/rsdump.c +++ b/drivers/acpi/resources/rsdump.c @@ -43,6 +43,7 @@ #include #include +#include #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME("rsdump") @@ -61,108 +62,448 @@ static void acpi_rs_out_integer64(char *title, u64 value); static void acpi_rs_out_title(char *title); -static void acpi_rs_dump_byte_list(u32 length, u8 * data); +static void acpi_rs_dump_byte_list(u16 length, u8 * data); -static void acpi_rs_dump_dword_list(u32 length, u32 * data); +static void acpi_rs_dump_dword_list(u8 length, u32 * data); -static void acpi_rs_dump_short_byte_list(u32 length, u32 * data); +static void acpi_rs_dump_short_byte_list(u8 length, u8 * data); static void acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source); static void acpi_rs_dump_address_common(union acpi_resource_data *resource); +static void +acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table); + +#define ACPI_RSD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_resource_data,f) +#define ACPI_PRT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_pci_routing_table,f) +#define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_rsdump_info)) + /******************************************************************************* * - * FUNCTION: acpi_rs_out* - * - * PARAMETERS: Title - Name of the resource field - * Value - Value of the resource field - * - * RETURN: None + * Resource Descriptor info tables * - * DESCRIPTION: Miscellaneous helper functions to consistently format the - * output of the resource dump routines + * Note: The first table entry must be a Title or Literal and must contain + * the table length (number of table entries) * ******************************************************************************/ -static void acpi_rs_out_string(char *title, char *value) -{ - acpi_os_printf("%27s : %s\n", title, value); -} +struct acpi_rsdump_info acpi_rs_dump_irq[6] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_irq), "IRQ", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.triggering), "Triggering", + acpi_gbl_HEdecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.polarity), "Polarity", + acpi_gbl_LLdecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.sharable), "Sharing", + acpi_gbl_SHRdecode}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.interrupt_count), + "Interrupt Count", NULL}, + {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(irq.interrupts[0]), + "Interrupt List", NULL} +}; + +struct acpi_rsdump_info acpi_rs_dump_dma[6] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_dma), "DMA", NULL}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.type), "Speed", + acpi_gbl_TYPdecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(dma.bus_master), "Mastering", + acpi_gbl_BMdecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.transfer), "Transfer Type", + acpi_gbl_SIZdecode}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(dma.channel_count), "Channel Count", + NULL}, + {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(dma.channels[0]), "Channel List", + NULL} +}; + +struct acpi_rsdump_info acpi_rs_dump_start_dpf[3] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_start_dpf), + "Start-Dependent-Functions", NULL}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.compatibility_priority), + "Compatibility Priority", acpi_gbl_config_decode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.performance_robustness), + "Performance/Robustness", acpi_gbl_config_decode} +}; + +struct acpi_rsdump_info acpi_rs_dump_end_dpf[1] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_dpf), + "End-Dependent-Functions", NULL} +}; + +struct acpi_rsdump_info acpi_rs_dump_io[6] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io), "I/O", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(io.io_decode), "Address Decoding", + acpi_gbl_io_decode}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.alignment), "Alignment", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.address_length), "Address Length", + NULL} +}; + +struct acpi_rsdump_info acpi_rs_dump_fixed_io[3] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_io), + "Fixed I/O", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_io.address), "Address", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_io.address_length), + "Address Length", NULL} +}; + +struct acpi_rsdump_info acpi_rs_dump_vendor[3] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_vendor), + "Vendor Specific", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(vendor.byte_length), "Length", NULL}, + {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET(vendor.byte_data[0]), "Vendor Data", + NULL} +}; + +struct acpi_rsdump_info acpi_rs_dump_end_tag[1] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_tag), "end_tag", + NULL} +}; + +struct acpi_rsdump_info acpi_rs_dump_memory24[6] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory24), + "24-Bit Memory Range", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory24.write_protect), + "Write Protect", acpi_gbl_RWdecode}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.minimum), "Address Minimum", + NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.maximum), "Address Maximum", + NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.alignment), "Alignment", + NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.address_length), + "Address Length", NULL} +}; + +struct acpi_rsdump_info acpi_rs_dump_memory32[6] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory32), + "32-Bit Memory Range", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory32.write_protect), + "Write Protect", acpi_gbl_RWdecode}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.minimum), "Address Minimum", + NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.maximum), "Address Maximum", + NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.alignment), "Alignment", + NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.address_length), + "Address Length", NULL} +}; + +struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[4] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_memory32), + "32-Bit Fixed Memory Range", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(fixed_memory32.write_protect), + "Write Protect", acpi_gbl_RWdecode}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address), "Address", + NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address_length), + "Address Length", NULL} +}; + +struct acpi_rsdump_info acpi_rs_dump_address16[8] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address16), + "16-Bit WORD Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.granularity), "Granularity", + NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.minimum), "Address Minimum", + NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.maximum), "Address Maximum", + NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.translation_offset), + "Translation Offset", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address_length), + "Address Length", NULL}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address16.resource_source), NULL, NULL} +}; + +struct acpi_rsdump_info acpi_rs_dump_address32[8] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address32), + "32-Bit DWORD Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.granularity), "Granularity", + NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.minimum), "Address Minimum", + NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.maximum), "Address Maximum", + NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.translation_offset), + "Translation Offset", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address_length), + "Address Length", NULL}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address32.resource_source), NULL, NULL} +}; + +struct acpi_rsdump_info acpi_rs_dump_address64[8] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address64), + "64-Bit QWORD Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.granularity), "Granularity", + NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.minimum), "Address Minimum", + NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.maximum), "Address Maximum", + NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.translation_offset), + "Translation Offset", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address_length), + "Address Length", NULL}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address64.resource_source), NULL, NULL} +}; + +struct acpi_rsdump_info acpi_rs_dump_ext_address64[8] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_address64), + "64-Bit Extended Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.granularity), + "Granularity", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.minimum), + "Address Minimum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.maximum), + "Address Maximum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.translation_offset), + "Translation Offset", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address_length), + "Address Length", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.type_specific), + "Type-Specific Attribute", NULL} +}; + +struct acpi_rsdump_info acpi_rs_dump_ext_irq[8] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_irq), + "Extended IRQ", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.producer_consumer), + "Type", acpi_gbl_consume_decode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.triggering), + "Triggering", acpi_gbl_HEdecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.polarity), "Polarity", + acpi_gbl_LLdecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.sharable), "Sharing", + acpi_gbl_SHRdecode}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(extended_irq.resource_source), NULL, + NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(extended_irq.interrupt_count), + "Interrupt Count", NULL}, + {ACPI_RSD_DWORDLIST, ACPI_RSD_OFFSET(extended_irq.interrupts[0]), + "Interrupt List", NULL} +}; + +struct acpi_rsdump_info acpi_rs_dump_generic_reg[6] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_generic_reg), + "Generic Register", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.space_id), "Space ID", + NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_width), "Bit Width", + NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_offset), "Bit Offset", + NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.access_size), + "Access Size", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(generic_reg.address), "Address", NULL} +}; -static void acpi_rs_out_integer8(char *title, u8 value) -{ - acpi_os_printf("%27s : %2.2X\n", title, value); -} - -static void acpi_rs_out_integer16(char *title, u16 value) -{ - acpi_os_printf("%27s : %4.4X\n", title, value); -} - -static void acpi_rs_out_integer32(char *title, u32 value) -{ - acpi_os_printf("%27s : %8.8X\n", title, value); -} - -static void acpi_rs_out_integer64(char *title, u64 value) -{ - acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value)); -} +/* + * Tables used for common address descriptor flag fields + */ +static struct acpi_rsdump_info acpi_rs_dump_general_flags[5] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_general_flags), NULL, + NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.producer_consumer), + "Consumer/Producer", acpi_gbl_consume_decode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.decode), "Address Decode", + acpi_gbl_DECdecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.min_address_fixed), + "Min Relocatability", acpi_gbl_min_decode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.max_address_fixed), + "Max Relocatability", acpi_gbl_max_decode} +}; + +static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = { + {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags), + "Resource Type", "Memory Range"}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect), + "Write Protect", acpi_gbl_RWdecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching), + "Caching", acpi_gbl_MEMdecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.range_type), + "Range Type", acpi_gbl_MTPdecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.translation), + "Translation", acpi_gbl_TTPdecode} +}; + +static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = { + {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags), + "Resource Type", "I/O Range"}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type), + "Range Type", acpi_gbl_RNGdecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation), + "Translation", acpi_gbl_TTPdecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation_type), + "Translation Type", acpi_gbl_TRSdecode} +}; -static void acpi_rs_out_title(char *title) -{ - acpi_os_printf("%27s : ", title); -} +/* + * Table used to dump _PRT contents + */ +static struct acpi_rsdump_info acpi_rs_dump_prt[5] = { + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_prt), NULL, NULL}, + {ACPI_RSD_UINT64, ACPI_PRT_OFFSET(address), "Address", NULL}, + {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(pin), "Pin", NULL}, + {ACPI_RSD_STRING, ACPI_PRT_OFFSET(source[0]), "Source", NULL}, + {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(source_index), "Source Index", NULL} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_dump*List + * FUNCTION: acpi_rs_dump_descriptor * - * PARAMETERS: Length - Number of elements in the list - * Data - Start of the list + * PARAMETERS: Resource * * RETURN: None * - * DESCRIPTION: Miscellaneous functions to dump lists of raw data + * DESCRIPTION: * ******************************************************************************/ -static void acpi_rs_dump_byte_list(u32 length, u8 * data) +static void +acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) { - u32 i; + void *target = NULL; + void *previous_target; + char *name; + u8 count; + + /* First table entry must contain the table length (# of table entries) */ + + count = table->offset; + + while (count) { + previous_target = target; + target = ((u8 *) resource) + table->offset; + name = table->name; + + switch (table->opcode) { + case ACPI_RSD_TITLE: + /* + * Optional resource title + */ + if (table->name) { + acpi_os_printf("%s Resource\n", name); + } + break; - for (i = 0; i < length; i++) { - acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]); - } -} + /* Strings */ -static void acpi_rs_dump_dword_list(u32 length, u32 * data) -{ - u32 i; + case ACPI_RSD_LITERAL: + acpi_rs_out_string(name, (char *)table->pointer); + break; - for (i = 0; i < length; i++) { - acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]); - } -} + case ACPI_RSD_STRING: + acpi_rs_out_string(name, (char *)target); + break; -static void acpi_rs_dump_short_byte_list(u32 length, u32 * data) -{ - u32 i; + /* Data items, 8/16/32/64 bit */ - for (i = 0; i < length; i++) { - acpi_os_printf("%X ", data[i]); - } - acpi_os_printf("\n"); -} + case ACPI_RSD_UINT8: + acpi_rs_out_integer8(name, *(u8 *) target); + break; -static void acpi_rs_dump_memory_attribute(u32 read_write_attribute) -{ + case ACPI_RSD_UINT16: + acpi_rs_out_integer16(name, *(u16 *) target); + break; + + case ACPI_RSD_UINT32: + acpi_rs_out_integer32(name, *(u32 *) target); + break; - acpi_rs_out_string("Read/Write Attribute", - ACPI_READ_WRITE_MEMORY == read_write_attribute ? - "Read/Write" : "Read-Only"); + case ACPI_RSD_UINT64: + acpi_rs_out_integer64(name, *(u64 *) target); + break; + + /* Flags: 1-bit and 2-bit flags supported */ + + case ACPI_RSD_1BITFLAG: + acpi_rs_out_string(name, (char *) + ((const char **)table-> + pointer)[(*(u8 *) target) & 0x01]); + break; + + case ACPI_RSD_2BITFLAG: + acpi_rs_out_string(name, (char *) + ((const char **)table-> + pointer)[(*(u8 *) target) & 0x03]); + break; + + case ACPI_RSD_SHORTLIST: + /* + * Short byte list (single line output) for DMA and IRQ resources + * Note: The list length is obtained from the previous table entry + */ + if (previous_target) { + acpi_rs_out_title(name); + acpi_rs_dump_short_byte_list(* + ((u8 *) + previous_target), + (u8 *) target); + } + break; + + case ACPI_RSD_LONGLIST: + /* + * Long byte list for Vendor resource data + * Note: The list length is obtained from the previous table entry + */ + if (previous_target) { + acpi_rs_dump_byte_list(* + ((u16 *) + previous_target), + (u8 *) target); + } + break; + + case ACPI_RSD_DWORDLIST: + /* + * Dword list for Extended Interrupt resources + * Note: The list length is obtained from the previous table entry + */ + if (previous_target) { + acpi_rs_dump_dword_list(* + ((u8 *) + previous_target), + (u32 *) target); + } + break; + + case ACPI_RSD_ADDRESS: + /* + * Common flags for all Address resources + */ + acpi_rs_dump_address_common((union acpi_resource_data *) + target); + break; + + case ACPI_RSD_SOURCE: + /* + * Optional resource_source for Address resources + */ + acpi_rs_dump_resource_source((struct + acpi_resource_source *) + target); + break; + + default: + acpi_os_printf("**** Invalid table opcode [%X] ****\n", + table->opcode); + return; + } + + table++; + count--; + } } /******************************************************************************* @@ -187,8 +528,7 @@ acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source) return; } - acpi_rs_out_integer8("Resource Source Index", - (u8) resource_source->index); + acpi_rs_out_integer8("Resource Source Index", resource_source->index); acpi_rs_out_string("Resource Source", resource_source->string_ptr ? @@ -217,65 +557,12 @@ static void acpi_rs_dump_address_common(union acpi_resource_data *resource) switch (resource->address.resource_type) { case ACPI_MEMORY_RANGE: - acpi_rs_out_string("Resource Type", "Memory Range"); - - acpi_rs_out_title("Type-Specific Flags"); - - switch (resource->address.attribute.memory.cache_attribute) { - case ACPI_NON_CACHEABLE_MEMORY: - acpi_os_printf("Noncacheable memory\n"); - break; - - case ACPI_CACHABLE_MEMORY: - acpi_os_printf("Cacheable memory\n"); - break; - - case ACPI_WRITE_COMBINING_MEMORY: - acpi_os_printf("Write-combining memory\n"); - break; - - case ACPI_PREFETCHABLE_MEMORY: - acpi_os_printf("Prefetchable memory\n"); - break; - - default: - acpi_os_printf("Invalid cache attribute\n"); - break; - } - - acpi_rs_dump_memory_attribute(resource->address.attribute. - memory.read_write_attribute); + acpi_rs_dump_descriptor(resource, acpi_rs_dump_memory_flags); break; case ACPI_IO_RANGE: - acpi_rs_out_string("Resource Type", "I/O Range"); - - acpi_rs_out_title("Type-Specific Flags"); - - switch (resource->address.attribute.io.range_attribute) { - case ACPI_NON_ISA_ONLY_RANGES: - acpi_os_printf("Non-ISA I/O Addresses\n"); - break; - - case ACPI_ISA_ONLY_RANGES: - acpi_os_printf("ISA I/O Addresses\n"); - break; - - case ACPI_ENTIRE_RANGE: - acpi_os_printf("ISA and non-ISA I/O Addresses\n"); - break; - - default: - acpi_os_printf("Invalid range attribute\n"); - break; - } - - acpi_rs_out_string("Translation Attribute", - ACPI_SPARSE_TRANSLATION == - resource->address.attribute.io. - translation_attribute ? "Sparse Translation" - : "Dense Translation"); + acpi_rs_dump_descriptor(resource, acpi_rs_dump_io_flags); break; case ACPI_BUS_NUMBER_RANGE: @@ -292,24 +579,7 @@ static void acpi_rs_dump_address_common(union acpi_resource_data *resource) /* Decode the general flags */ - acpi_rs_out_string("Resource", - ACPI_CONSUMER == - resource->address. - producer_consumer ? "Consumer" : "Producer"); - - acpi_rs_out_string("Decode", - ACPI_SUB_DECODE == resource->address.decode ? - "Subtractive" : "Positive"); - - acpi_rs_out_string("Min Address", - ACPI_ADDRESS_FIXED == - resource->address. - min_address_fixed ? "Fixed" : "Not Fixed"); - - acpi_rs_out_string("Max Address", - ACPI_ADDRESS_FIXED == - resource->address. - max_address_fixed ? "Fixed" : "Not Fixed"); + acpi_rs_dump_descriptor(resource, acpi_rs_dump_general_flags); } /******************************************************************************* @@ -327,6 +597,7 @@ static void acpi_rs_dump_address_common(union acpi_resource_data *resource) void acpi_rs_dump_resource_list(struct acpi_resource *resource_list) { u32 count = 0; + u32 type; ACPI_FUNCTION_ENTRY(); @@ -335,14 +606,16 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list) return; } - /* Dump all resource descriptors in the list */ + /* Walk list and dump all resource descriptors (END_TAG terminates) */ - while (resource_list) { + do { acpi_os_printf("\n[%02X] ", count); + count++; /* Validate Type before dispatch */ - if (resource_list->type > ACPI_RESOURCE_TYPE_MAX) { + type = resource_list->type; + if (type > ACPI_RESOURCE_TYPE_MAX) { acpi_os_printf ("Invalid descriptor type (%X) in resource list\n", resource_list->type); @@ -351,665 +624,141 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list) /* Dump the resource descriptor */ - acpi_gbl_dump_resource_dispatch[resource_list-> - type] (&resource_list->data); - - /* Exit on end tag */ - - if (resource_list->type == ACPI_RESOURCE_TYPE_END_TAG) { - return; - } + acpi_rs_dump_descriptor(&resource_list->data, + acpi_gbl_dump_resource_dispatch[type]); - /* Get the next resource structure */ + /* Point to the next resource structure */ resource_list = ACPI_PTR_ADD(struct acpi_resource, resource_list, resource_list->length); - count++; - } -} -/******************************************************************************* - * - * FUNCTION: acpi_rs_dump_irq - * - * PARAMETERS: Resource - Pointer to an internal resource descriptor - * - * RETURN: None - * - * DESCRIPTION: Dump the field names and values of the resource descriptor - * - ******************************************************************************/ + /* Exit when END_TAG descriptor is reached */ -void acpi_rs_dump_irq(union acpi_resource_data *resource) -{ - ACPI_FUNCTION_ENTRY(); - - acpi_os_printf("IRQ Resource\n"); - - acpi_rs_out_string("Triggering", - ACPI_LEVEL_SENSITIVE == - resource->irq.triggering ? "Level" : "Edge"); - - acpi_rs_out_string("Active", - ACPI_ACTIVE_LOW == - resource->irq.polarity ? "Low" : "High"); - - acpi_rs_out_string("Sharing", - ACPI_SHARED == - resource->irq.sharable ? "Shared" : "Exclusive"); - - acpi_rs_out_integer8("Interrupt Count", - (u8) resource->irq.interrupt_count); - - acpi_rs_out_title("Interrupt List"); - acpi_rs_dump_short_byte_list(resource->irq.interrupt_count, - resource->irq.interrupts); + } while (type != ACPI_RESOURCE_TYPE_END_TAG); } /******************************************************************************* * - * FUNCTION: acpi_rs_dump_dma + * FUNCTION: acpi_rs_dump_irq_list * - * PARAMETERS: Resource - Pointer to an internal resource descriptor + * PARAMETERS: route_table - Pointer to the routing table to dump. * * RETURN: None * - * DESCRIPTION: Dump the field names and values of the resource descriptor + * DESCRIPTION: Print IRQ routing table * ******************************************************************************/ -void acpi_rs_dump_dma(union acpi_resource_data *resource) +void acpi_rs_dump_irq_list(u8 * route_table) { - ACPI_FUNCTION_ENTRY(); - - acpi_os_printf("DMA Resource\n"); - - acpi_rs_out_title("DMA Type"); - switch (resource->dma.type) { - case ACPI_COMPATIBILITY: - acpi_os_printf("Compatibility mode\n"); - break; - - case ACPI_TYPE_A: - acpi_os_printf("Type A\n"); - break; - - case ACPI_TYPE_B: - acpi_os_printf("Type B\n"); - break; - - case ACPI_TYPE_F: - acpi_os_printf("Type F\n"); - break; - - default: - acpi_os_printf("**** Invalid DMA type\n"); - break; - } - - acpi_rs_out_string("Bus Master", - ACPI_BUS_MASTER == - resource->dma.bus_master ? "Yes" : "No"); - - acpi_rs_out_title("Transfer Type"); - switch (resource->dma.transfer) { - case ACPI_TRANSFER_8: - acpi_os_printf("8-bit transfers only\n"); - break; - - case ACPI_TRANSFER_8_16: - acpi_os_printf("8-bit and 16-bit transfers\n"); - break; - - case ACPI_TRANSFER_16: - acpi_os_printf("16-bit transfers only\n"); - break; - - default: - acpi_os_printf("**** Invalid transfer preference\n"); - break; - } - - acpi_rs_out_integer8("DMA Channel Count", - (u8) resource->dma.channel_count); - - acpi_rs_out_title("Channel List"); - acpi_rs_dump_short_byte_list(resource->dma.channel_count, - resource->dma.channels); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_dump_start_dpf - * - * PARAMETERS: Resource - Pointer to an internal resource descriptor - * - * RETURN: None - * - * DESCRIPTION: Dump the field names and values of the resource descriptor - * - ******************************************************************************/ + struct acpi_pci_routing_table *prt_element; + u8 count; -void acpi_rs_dump_start_dpf(union acpi_resource_data *resource) -{ ACPI_FUNCTION_ENTRY(); - acpi_os_printf("Start Dependent Functions Resource\n"); - - acpi_rs_out_title("Compatibility Priority"); - switch (resource->start_dpf.compatibility_priority) { - case ACPI_GOOD_CONFIGURATION: - acpi_os_printf("Good configuration\n"); - break; - - case ACPI_ACCEPTABLE_CONFIGURATION: - acpi_os_printf("Acceptable configuration\n"); - break; - - case ACPI_SUB_OPTIMAL_CONFIGURATION: - acpi_os_printf("Sub-optimal configuration\n"); - break; - - default: - acpi_os_printf("**** Invalid compatibility priority\n"); - break; + if (!(acpi_dbg_level & ACPI_LV_RESOURCES) + || !(_COMPONENT & acpi_dbg_layer)) { + return; } - acpi_rs_out_title("Performance/Robustness"); - switch (resource->start_dpf.performance_robustness) { - case ACPI_GOOD_CONFIGURATION: - acpi_os_printf("Good configuration\n"); - break; + prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table, route_table); - case ACPI_ACCEPTABLE_CONFIGURATION: - acpi_os_printf("Acceptable configuration\n"); - break; + /* Dump all table elements, Exit on zero length element */ - case ACPI_SUB_OPTIMAL_CONFIGURATION: - acpi_os_printf("Sub-optimal configuration\n"); - break; + for (count = 0; prt_element->length; count++) { + acpi_os_printf("\n[%02X] PCI IRQ Routing Table Package\n", + count); + acpi_rs_dump_descriptor(prt_element, acpi_rs_dump_prt); - default: - acpi_os_printf - ("**** Invalid performance robustness preference\n"); - break; + prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table, + ((u8 *) prt_element) + + prt_element->length); } } /******************************************************************************* * - * FUNCTION: acpi_rs_dump_io - * - * PARAMETERS: Resource - Pointer to an internal resource descriptor - * - * RETURN: None - * - * DESCRIPTION: Dump the field names and values of the resource descriptor - * - ******************************************************************************/ - -void acpi_rs_dump_io(union acpi_resource_data *resource) -{ - ACPI_FUNCTION_ENTRY(); - - acpi_os_printf("I/O Resource\n"); - - acpi_rs_out_string("Decode", - ACPI_DECODE_16 == - resource->io.io_decode ? "16-bit" : "10-bit"); - - acpi_rs_out_integer32("Address Minimum", resource->io.minimum); - - acpi_rs_out_integer32("Address Maximum", resource->io.maximum); - - acpi_rs_out_integer32("Alignment", resource->io.alignment); - - acpi_rs_out_integer32("Address Length", resource->io.address_length); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_dump_fixed_io - * - * PARAMETERS: Resource - Pointer to an internal resource descriptor - * - * RETURN: None - * - * DESCRIPTION: Dump the field names and values of the resource descriptor - * - ******************************************************************************/ - -void acpi_rs_dump_fixed_io(union acpi_resource_data *resource) -{ - ACPI_FUNCTION_ENTRY(); - - acpi_os_printf("Fixed I/O Resource\n"); - - acpi_rs_out_integer32("Address", resource->fixed_io.address); - - acpi_rs_out_integer32("Address Length", - resource->fixed_io.address_length); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_dump_vendor - * - * PARAMETERS: Resource - Pointer to an internal resource descriptor - * - * RETURN: None - * - * DESCRIPTION: Dump the field names and values of the resource descriptor - * - ******************************************************************************/ - -void acpi_rs_dump_vendor(union acpi_resource_data *resource) -{ - ACPI_FUNCTION_ENTRY(); - - acpi_os_printf("Vendor Specific Resource\n"); - - acpi_rs_out_integer16("Length", (u16) resource->vendor.byte_length); - - acpi_rs_dump_byte_list(resource->vendor.byte_length, - resource->vendor.byte_data); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_dump_memory24 - * - * PARAMETERS: Resource - Pointer to an internal resource descriptor - * - * RETURN: None - * - * DESCRIPTION: Dump the field names and values of the resource descriptor - * - ******************************************************************************/ - -void acpi_rs_dump_memory24(union acpi_resource_data *resource) -{ - ACPI_FUNCTION_ENTRY(); - - acpi_os_printf("24-Bit Memory Range Resource\n"); - - acpi_rs_dump_memory_attribute(resource->memory24.read_write_attribute); - - acpi_rs_out_integer16("Address Minimum", - (u16) resource->memory24.minimum); - - acpi_rs_out_integer16("Address Maximum", - (u16) resource->memory24.maximum); - - acpi_rs_out_integer16("Alignment", (u16) resource->memory24.alignment); - - acpi_rs_out_integer16("Address Length", - (u16) resource->memory24.address_length); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_dump_memory32 - * - * PARAMETERS: Resource - Pointer to an internal resource descriptor - * - * RETURN: None - * - * DESCRIPTION: Dump the field names and values of the resource descriptor - * - ******************************************************************************/ - -void acpi_rs_dump_memory32(union acpi_resource_data *resource) -{ - ACPI_FUNCTION_ENTRY(); - - acpi_os_printf("32-Bit Memory Range Resource\n"); - - acpi_rs_dump_memory_attribute(resource->memory32.read_write_attribute); - - acpi_rs_out_integer32("Address Minimum", resource->memory32.minimum); - - acpi_rs_out_integer32("Address Maximum", resource->memory32.maximum); - - acpi_rs_out_integer32("Alignment", resource->memory32.alignment); - - acpi_rs_out_integer32("Address Length", - resource->memory32.address_length); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_dump_fixed_memory32 - * - * PARAMETERS: Resource - Pointer to an internal resource descriptor - * - * RETURN: - * - * DESCRIPTION: Dump the field names and values of the resource descriptor - * - ******************************************************************************/ - -void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource) -{ - ACPI_FUNCTION_ENTRY(); - - acpi_os_printf("32-Bit Fixed Location Memory Range Resource\n"); - - acpi_rs_dump_memory_attribute(resource->fixed_memory32. - read_write_attribute); - - acpi_rs_out_integer32("Address", resource->fixed_memory32.address); - - acpi_rs_out_integer32("Address Length", - resource->fixed_memory32.address_length); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_dump_address16 + * FUNCTION: acpi_rs_out* * - * PARAMETERS: Resource - Pointer to an internal resource descriptor + * PARAMETERS: Title - Name of the resource field + * Value - Value of the resource field * * RETURN: None * - * DESCRIPTION: Dump the field names and values of the resource descriptor + * DESCRIPTION: Miscellaneous helper functions to consistently format the + * output of the resource dump routines * ******************************************************************************/ -void acpi_rs_dump_address16(union acpi_resource_data *resource) +static void acpi_rs_out_string(char *title, char *value) { - ACPI_FUNCTION_ENTRY(); - - acpi_os_printf("16-Bit WORD Address Space Resource\n"); - - acpi_rs_dump_address_common(resource); - - acpi_rs_out_integer16("Granularity", - (u16) resource->address16.granularity); - - acpi_rs_out_integer16("Address Minimum", - (u16) resource->address16.minimum); - - acpi_rs_out_integer16("Address Maximum", - (u16) resource->address16.maximum); - - acpi_rs_out_integer16("Translation Offset", - (u16) resource->address16.translation_offset); - - acpi_rs_out_integer16("Address Length", - (u16) resource->address16.address_length); - - acpi_rs_dump_resource_source(&resource->address16.resource_source); + acpi_os_printf("%27s : %s\n", title, value); } -/******************************************************************************* - * - * FUNCTION: acpi_rs_dump_address32 - * - * PARAMETERS: Resource - Pointer to an internal resource descriptor - * - * RETURN: None - * - * DESCRIPTION: Dump the field names and values of the resource descriptor - * - ******************************************************************************/ - -void acpi_rs_dump_address32(union acpi_resource_data *resource) +static void acpi_rs_out_integer8(char *title, u8 value) { - ACPI_FUNCTION_ENTRY(); - - acpi_os_printf("32-Bit DWORD Address Space Resource\n"); - - acpi_rs_dump_address_common(resource); - - acpi_rs_out_integer32("Granularity", resource->address32.granularity); - - acpi_rs_out_integer32("Address Minimum", resource->address32.minimum); - - acpi_rs_out_integer32("Address Maximum", resource->address32.maximum); - - acpi_rs_out_integer32("Translation Offset", - resource->address32.translation_offset); - - acpi_rs_out_integer32("Address Length", - resource->address32.address_length); - - acpi_rs_dump_resource_source(&resource->address32.resource_source); + acpi_os_printf("%27s : %2.2X\n", title, value); } -/******************************************************************************* - * - * FUNCTION: acpi_rs_dump_address64 - * - * PARAMETERS: Resource - Pointer to an internal resource descriptor - * - * RETURN: None - * - * DESCRIPTION: Dump the field names and values of the resource descriptor - * - ******************************************************************************/ - -void acpi_rs_dump_address64(union acpi_resource_data *resource) +static void acpi_rs_out_integer16(char *title, u16 value) { - ACPI_FUNCTION_ENTRY(); - - acpi_os_printf("64-Bit QWORD Address Space Resource\n"); - - acpi_rs_dump_address_common(resource); - - acpi_rs_out_integer64("Granularity", resource->address64.granularity); - - acpi_rs_out_integer64("Address Minimum", resource->address64.minimum); - - acpi_rs_out_integer64("Address Maximum", resource->address64.maximum); - - acpi_rs_out_integer64("Translation Offset", - resource->address64.translation_offset); - - acpi_rs_out_integer64("Address Length", - resource->address64.address_length); - - acpi_rs_dump_resource_source(&resource->address64.resource_source); + acpi_os_printf("%27s : %4.4X\n", title, value); } -/******************************************************************************* - * - * FUNCTION: acpi_rs_dump_ext_address64 - * - * PARAMETERS: Resource - Pointer to an internal resource descriptor - * - * RETURN: None - * - * DESCRIPTION: Dump the field names and values of the resource descriptor - * - ******************************************************************************/ - -void acpi_rs_dump_ext_address64(union acpi_resource_data *resource) +static void acpi_rs_out_integer32(char *title, u32 value) { - ACPI_FUNCTION_ENTRY(); - - acpi_os_printf("64-Bit Extended Address Space Resource\n"); - - acpi_rs_dump_address_common(resource); - - acpi_rs_out_integer64("Granularity", - resource->ext_address64.granularity); - - acpi_rs_out_integer64("Address Minimum", - resource->ext_address64.minimum); - - acpi_rs_out_integer64("Address Maximum", - resource->ext_address64.maximum); - - acpi_rs_out_integer64("Translation Offset", - resource->ext_address64.translation_offset); - - acpi_rs_out_integer64("Address Length", - resource->ext_address64.address_length); - - acpi_rs_out_integer64("Type-Specific Attribute", - resource->ext_address64.type_specific_attributes); + acpi_os_printf("%27s : %8.8X\n", title, value); } -/******************************************************************************* - * - * FUNCTION: acpi_rs_dump_ext_irq - * - * PARAMETERS: Resource - Pointer to an internal resource descriptor - * - * RETURN: None - * - * DESCRIPTION: Dump the field names and values of the resource descriptor - * - ******************************************************************************/ - -void acpi_rs_dump_ext_irq(union acpi_resource_data *resource) +static void acpi_rs_out_integer64(char *title, u64 value) { - ACPI_FUNCTION_ENTRY(); - - acpi_os_printf("Extended IRQ Resource\n"); - - acpi_rs_out_string("Resource", - ACPI_CONSUMER == - resource->extended_irq. - producer_consumer ? "Consumer" : "Producer"); - - acpi_rs_out_string("Triggering", - ACPI_LEVEL_SENSITIVE == - resource->extended_irq. - triggering ? "Level" : "Edge"); - - acpi_rs_out_string("Active", - ACPI_ACTIVE_LOW == resource->extended_irq.polarity ? - "Low" : "High"); - - acpi_rs_out_string("Sharing", - ACPI_SHARED == resource->extended_irq.sharable ? - "Shared" : "Exclusive"); - - acpi_rs_dump_resource_source(&resource->extended_irq.resource_source); - - acpi_rs_out_integer8("Interrupts", - (u8) resource->extended_irq.interrupt_count); - - acpi_rs_dump_dword_list(resource->extended_irq.interrupt_count, - resource->extended_irq.interrupts); + acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value)); } -/******************************************************************************* - * - * FUNCTION: acpi_rs_dump_generic_reg - * - * PARAMETERS: Resource - Pointer to an internal resource descriptor - * - * RETURN: None - * - * DESCRIPTION: Dump the field names and values of the resource descriptor - * - ******************************************************************************/ - -void acpi_rs_dump_generic_reg(union acpi_resource_data *resource) +static void acpi_rs_out_title(char *title) { - ACPI_FUNCTION_ENTRY(); - - acpi_os_printf("Generic Register Resource\n"); - - acpi_rs_out_integer8("Space ID", (u8) resource->generic_reg.space_id); - - acpi_rs_out_integer8("Bit Width", (u8) resource->generic_reg.bit_width); - - acpi_rs_out_integer8("Bit Offset", - (u8) resource->generic_reg.bit_offset); - - acpi_rs_out_integer8("Access Size", - (u8) resource->generic_reg.access_size); - - acpi_rs_out_integer64("Address", resource->generic_reg.address); + acpi_os_printf("%27s : ", title); } /******************************************************************************* * - * FUNCTION: acpi_rs_dump_end_dpf + * FUNCTION: acpi_rs_dump*List * - * PARAMETERS: Resource - Pointer to an internal resource descriptor + * PARAMETERS: Length - Number of elements in the list + * Data - Start of the list * * RETURN: None * - * DESCRIPTION: Print type, no data. + * DESCRIPTION: Miscellaneous functions to dump lists of raw data * ******************************************************************************/ -void acpi_rs_dump_end_dpf(union acpi_resource_data *resource) +static void acpi_rs_dump_byte_list(u16 length, u8 * data) { - ACPI_FUNCTION_ENTRY(); + u8 i; - acpi_os_printf("end_dependent_functions Resource\n"); + for (i = 0; i < length; i++) { + acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]); + } } -/******************************************************************************* - * - * FUNCTION: acpi_rs_dump_end_tag - * - * PARAMETERS: Resource - Pointer to an internal resource descriptor - * - * RETURN: None - * - * DESCRIPTION: Print type, no data. - * - ******************************************************************************/ - -void acpi_rs_dump_end_tag(union acpi_resource_data *resource) +static void acpi_rs_dump_short_byte_list(u8 length, u8 * data) { - ACPI_FUNCTION_ENTRY(); + u8 i; - acpi_os_printf("end_tag Resource\n"); + for (i = 0; i < length; i++) { + acpi_os_printf("%X ", data[i]); + } + acpi_os_printf("\n"); } -/******************************************************************************* - * - * FUNCTION: acpi_rs_dump_irq_list - * - * PARAMETERS: route_table - Pointer to the routing table to dump. - * - * RETURN: None - * - * DESCRIPTION: Print IRQ routing table - * - ******************************************************************************/ - -void acpi_rs_dump_irq_list(u8 * route_table) +static void acpi_rs_dump_dword_list(u8 length, u32 * data) { - u8 *buffer = route_table; - u8 count = 0; - struct acpi_pci_routing_table *prt_element; - - ACPI_FUNCTION_ENTRY(); + u8 i; - if (!(acpi_dbg_level & ACPI_LV_RESOURCES) - || !(_COMPONENT & acpi_dbg_layer)) { - return; - } - - prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table, buffer); - - /* Dump all table elements, Exit on null length element */ - - while (prt_element->length) { - acpi_os_printf("\n[%02X] PCI IRQ Routing Table Package\n", - count); - - acpi_rs_out_integer64("Address", prt_element->address); - - acpi_rs_out_integer32("Pin", prt_element->pin); - acpi_rs_out_string("Source", prt_element->source); - acpi_rs_out_integer32("Source Index", - prt_element->source_index); - - buffer += prt_element->length; - prt_element = - ACPI_CAST_PTR(struct acpi_pci_routing_table, buffer); - count++; + for (i = 0; i < length; i++) { + acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]); } } diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/resources/rsinfo.c index b31cb33ec565..973fc2834cbb 100644 --- a/drivers/acpi/resources/rsinfo.c +++ b/drivers/acpi/resources/rsinfo.c @@ -58,60 +58,60 @@ ACPI_MODULE_NAME("rsinfo") * descriptors are indexed by the acpi_resource_type field. */ /* Dispatch table for resource-to-AML (Set Resource) conversion functions */ -ACPI_SET_RESOURCE_HANDLER acpi_gbl_set_resource_dispatch[] = { +struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[] = { acpi_rs_set_irq, /* 0x00, ACPI_RESOURCE_TYPE_IRQ */ - acpi_rs_set_dma, /* 0x01, ACPI_RESOURCE_TYPE_DMA */ + acpi_rs_convert_dma, /* 0x01, ACPI_RESOURCE_TYPE_DMA */ acpi_rs_set_start_dpf, /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */ - acpi_rs_set_end_dpf, /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */ - acpi_rs_set_io, /* 0x04, ACPI_RESOURCE_TYPE_IO */ - acpi_rs_set_fixed_io, /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */ + acpi_rs_convert_end_dpf, /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */ + acpi_rs_convert_io, /* 0x04, ACPI_RESOURCE_TYPE_IO */ + acpi_rs_convert_fixed_io, /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */ acpi_rs_set_vendor, /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */ - acpi_rs_set_end_tag, /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */ - acpi_rs_set_memory24, /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */ - acpi_rs_set_memory32, /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */ - acpi_rs_set_fixed_memory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */ - acpi_rs_set_address16, /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */ - acpi_rs_set_address32, /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */ - acpi_rs_set_address64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */ - acpi_rs_set_ext_address64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ - acpi_rs_set_ext_irq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ - acpi_rs_set_generic_reg /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ + acpi_rs_convert_end_tag, /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */ + acpi_rs_convert_memory24, /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */ + acpi_rs_convert_memory32, /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */ + acpi_rs_convert_fixed_memory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */ + acpi_rs_convert_address16, /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */ + acpi_rs_convert_address32, /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */ + acpi_rs_convert_address64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */ + acpi_rs_convert_ext_address64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ + acpi_rs_convert_ext_irq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ + acpi_rs_convert_generic_reg /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ }; /* Dispatch tables for AML-to-resource (Get Resource) conversion functions */ -ACPI_GET_RESOURCE_HANDLER acpi_gbl_sm_get_resource_dispatch[] = { +struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[] = { NULL, /* 0x00, Reserved */ NULL, /* 0x01, Reserved */ NULL, /* 0x02, Reserved */ NULL, /* 0x03, Reserved */ acpi_rs_get_irq, /* 0x04, ACPI_RESOURCE_NAME_IRQ */ - acpi_rs_get_dma, /* 0x05, ACPI_RESOURCE_NAME_DMA */ + acpi_rs_convert_dma, /* 0x05, ACPI_RESOURCE_NAME_DMA */ acpi_rs_get_start_dpf, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */ - acpi_rs_get_end_dpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */ - acpi_rs_get_io, /* 0x08, ACPI_RESOURCE_NAME_IO */ - acpi_rs_get_fixed_io, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */ + acpi_rs_convert_end_dpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */ + acpi_rs_convert_io, /* 0x08, ACPI_RESOURCE_NAME_IO */ + acpi_rs_convert_fixed_io, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */ NULL, /* 0x0A, Reserved */ NULL, /* 0x0B, Reserved */ NULL, /* 0x0C, Reserved */ NULL, /* 0x0D, Reserved */ - acpi_rs_get_vendor, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */ - acpi_rs_get_end_tag /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ + acpi_rs_get_vendor_small, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */ + acpi_rs_convert_end_tag /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ }; -ACPI_GET_RESOURCE_HANDLER acpi_gbl_lg_get_resource_dispatch[] = { +struct acpi_rsconvert_info *acpi_gbl_lg_get_resource_dispatch[] = { NULL, /* 0x00, Reserved */ - acpi_rs_get_memory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */ - acpi_rs_get_generic_reg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */ + acpi_rs_convert_memory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */ + acpi_rs_convert_generic_reg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */ NULL, /* 0x03, Reserved */ - acpi_rs_get_vendor, /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */ - acpi_rs_get_memory32, /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */ - acpi_rs_get_fixed_memory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */ - acpi_rs_get_address32, /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */ - acpi_rs_get_address16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */ - acpi_rs_get_ext_irq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */ - acpi_rs_get_address64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */ - acpi_rs_get_ext_address64 /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */ + acpi_rs_get_vendor_large, /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */ + acpi_rs_convert_memory32, /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */ + acpi_rs_convert_fixed_memory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */ + acpi_rs_convert_address32, /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */ + acpi_rs_convert_address16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */ + acpi_rs_convert_ext_irq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */ + acpi_rs_convert_address64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */ + acpi_rs_convert_ext_address64 /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */ }; #ifdef ACPI_FUTURE_USAGE @@ -119,7 +119,7 @@ ACPI_GET_RESOURCE_HANDLER acpi_gbl_lg_get_resource_dispatch[] = { /* Dispatch table for resource dump functions */ -ACPI_DUMP_RESOURCE_HANDLER acpi_gbl_dump_resource_dispatch[] = { +struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[] = { acpi_rs_dump_irq, /* ACPI_RESOURCE_TYPE_IRQ */ acpi_rs_dump_dma, /* ACPI_RESOURCE_TYPE_DMA */ acpi_rs_dump_start_dpf, /* ACPI_RESOURCE_TYPE_START_DEPENDENT */ @@ -136,17 +136,17 @@ ACPI_DUMP_RESOURCE_HANDLER acpi_gbl_dump_resource_dispatch[] = { acpi_rs_dump_address64, /* ACPI_RESOURCE_TYPE_ADDRESS64 */ acpi_rs_dump_ext_address64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ - acpi_rs_dump_generic_reg /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ + acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ }; + #endif #endif /* ACPI_FUTURE_USAGE */ - /* * Base sizes for external AML resource descriptors, indexed by internal type. * Includes size of the descriptor header (1 byte for small descriptors, * 3 bytes for large descriptors) */ -u8 acpi_gbl_aml_resource_sizes[] = { +const u8 acpi_gbl_aml_resource_sizes[] = { sizeof(struct aml_resource_irq), /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */ sizeof(struct aml_resource_dma), /* ACPI_RESOURCE_TYPE_DMA */ sizeof(struct aml_resource_start_dependent), /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */ @@ -168,8 +168,8 @@ u8 acpi_gbl_aml_resource_sizes[] = { /* Macros used in the tables below */ -#define ACPI_RLARGE(r) sizeof (r) - sizeof (struct aml_resource_large_header) -#define ACPI_RSMALL(r) sizeof (r) - sizeof (struct aml_resource_small_header) +#define ACPI_RLARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header)) +#define ACPI_RSMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header)) /* * Base sizes of resource descriptors, both the AML stream resource length @@ -182,47 +182,46 @@ struct acpi_resource_info acpi_gbl_sm_resource_info[] = { {0, 0, 0}, {0, 0, 0}, {2, ACPI_RSMALL(struct aml_resource_irq), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq)}, + ACPI_RS_SIZE(struct acpi_resource_irq)}, {0, ACPI_RSMALL(struct aml_resource_dma), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma)}, + ACPI_RS_SIZE(struct acpi_resource_dma)}, {2, ACPI_RSMALL(struct aml_resource_start_dependent), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dependent)}, - {0, ACPI_RSMALL(struct aml_resource_end_dependent), - ACPI_RESOURCE_LENGTH}, + ACPI_RS_SIZE(struct acpi_resource_start_dependent)}, + {0, ACPI_RSMALL(struct aml_resource_end_dependent), ACPI_RS_SIZE_MIN}, {0, ACPI_RSMALL(struct aml_resource_io), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_io)}, + ACPI_RS_SIZE(struct acpi_resource_io)}, {0, ACPI_RSMALL(struct aml_resource_fixed_io), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io)}, + ACPI_RS_SIZE(struct acpi_resource_fixed_io)}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {1, ACPI_RSMALL(struct aml_resource_vendor_small), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, - {0, ACPI_RSMALL(struct aml_resource_end_tag), ACPI_RESOURCE_LENGTH} + ACPI_RS_SIZE(struct acpi_resource_vendor)}, + {0, ACPI_RSMALL(struct aml_resource_end_tag), ACPI_RS_SIZE_MIN} }; struct acpi_resource_info acpi_gbl_lg_resource_info[] = { {0, 0, 0}, {0, ACPI_RLARGE(struct aml_resource_memory24), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24)}, + ACPI_RS_SIZE(struct acpi_resource_memory24)}, {0, ACPI_RLARGE(struct aml_resource_generic_register), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register)}, + ACPI_RS_SIZE(struct acpi_resource_generic_register)}, {0, 0, 0}, {1, ACPI_RLARGE(struct aml_resource_vendor_large), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, + ACPI_RS_SIZE(struct acpi_resource_vendor)}, {0, ACPI_RLARGE(struct aml_resource_memory32), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory32)}, + ACPI_RS_SIZE(struct acpi_resource_memory32)}, {0, ACPI_RLARGE(struct aml_resource_fixed_memory32), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_memory32)}, + ACPI_RS_SIZE(struct acpi_resource_fixed_memory32)}, {1, ACPI_RLARGE(struct aml_resource_address32), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32)}, + ACPI_RS_SIZE(struct acpi_resource_address32)}, {1, ACPI_RLARGE(struct aml_resource_address16), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16)}, + ACPI_RS_SIZE(struct acpi_resource_address16)}, {1, ACPI_RLARGE(struct aml_resource_extended_irq), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_irq)}, + ACPI_RS_SIZE(struct acpi_resource_extended_irq)}, {1, ACPI_RLARGE(struct aml_resource_address64), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)}, + ACPI_RS_SIZE(struct acpi_resource_address64)}, {0, ACPI_RLARGE(struct aml_resource_extended_address64), - ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_address64)} + ACPI_RS_SIZE(struct acpi_resource_extended_address64)} }; diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c index 0dab8cdfa800..ef24ba110c6e 100644 --- a/drivers/acpi/resources/rsio.c +++ b/drivers/acpi/resources/rsio.c @@ -49,269 +49,206 @@ ACPI_MODULE_NAME("rsio") /******************************************************************************* * - * FUNCTION: acpi_rs_get_io - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. + * acpi_rs_convert_io * ******************************************************************************/ -acpi_status -acpi_rs_get_io(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource) -{ - ACPI_FUNCTION_TRACE("rs_get_io"); +struct acpi_rsconvert_info acpi_rs_convert_io[5] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO, + ACPI_RS_SIZE(struct acpi_resource_io), + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io)}, - /* Get the Decode flag */ + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO, + sizeof(struct aml_resource_io), + 0}, - resource->data.io.io_decode = aml->io.information & 0x01; + /* Decode flag */ + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.io.io_decode), + AML_OFFSET(io.flags), + 0}, /* - * Get the following contiguous fields from the AML descriptor: - * Minimum Base Address - * Maximum Base Address + * These fields are contiguous in both the source and destination: * Address Alignment * Length + * Minimum Base Address + * Maximum Base Address */ - ACPI_MOVE_16_TO_32(&resource->data.io.minimum, &aml->io.minimum); - ACPI_MOVE_16_TO_32(&resource->data.io.maximum, &aml->io.maximum); - resource->data.io.alignment = aml->io.alignment; - resource->data.io.address_length = aml->io.address_length; - - /* Complete the resource header */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.io.alignment), + AML_OFFSET(io.alignment), + 2}, - resource->type = ACPI_RESOURCE_TYPE_IO; - resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.io.minimum), + AML_OFFSET(io.minimum), + 2} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_set_io - * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Aml - Where the AML descriptor is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. + * acpi_rs_convert_fixed_io * ******************************************************************************/ -acpi_status -acpi_rs_set_io(struct acpi_resource *resource, union aml_resource *aml) -{ - ACPI_FUNCTION_TRACE("rs_set_io"); - - /* I/O Information Byte */ - - aml->io.information = (u8) (resource->data.io.io_decode & 0x01); +struct acpi_rsconvert_info acpi_rs_convert_fixed_io[4] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO, + ACPI_RS_SIZE(struct acpi_resource_fixed_io), + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_io)}, + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO, + sizeof(struct aml_resource_fixed_io), + 0}, /* - * Set the following contiguous fields in the AML descriptor: - * Minimum Base Address - * Maximum Base Address - * Address Alignment + * These fields are contiguous in both the source and destination: + * Base Address * Length */ - ACPI_MOVE_32_TO_16(&aml->io.minimum, &resource->data.io.minimum); - ACPI_MOVE_32_TO_16(&aml->io.maximum, &resource->data.io.maximum); - aml->io.alignment = (u8) resource->data.io.alignment; - aml->io.address_length = (u8) resource->data.io.address_length; - - /* Complete the AML descriptor header */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_io.address_length), + AML_OFFSET(fixed_io.address_length), + 1}, - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IO, - sizeof(struct aml_resource_io), aml); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_io.address), + AML_OFFSET(fixed_io.address), + 1} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_get_fixed_io - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. + * acpi_rs_convert_generic_reg * ******************************************************************************/ -acpi_status -acpi_rs_get_fixed_io(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource) -{ - ACPI_FUNCTION_TRACE("rs_get_fixed_io"); +struct acpi_rsconvert_info acpi_rs_convert_generic_reg[4] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER, + ACPI_RS_SIZE(struct acpi_resource_generic_register), + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_generic_reg)}, + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER, + sizeof(struct aml_resource_generic_register), + 0}, /* - * Get the following contiguous fields from the AML descriptor: - * Base Address - * Length + * These fields are contiguous in both the source and destination: + * Address Space ID + * Register Bit Width + * Register Bit Offset + * Access Size */ - ACPI_MOVE_16_TO_32(&resource->data.fixed_io.address, - &aml->fixed_io.address); - resource->data.fixed_io.address_length = aml->fixed_io.address_length; + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.generic_reg.space_id), + AML_OFFSET(generic_reg.address_space_id), + 4}, - /* Complete the resource header */ + /* Get the Register Address */ - resource->type = ACPI_RESOURCE_TYPE_FIXED_IO; - resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.generic_reg.address), + AML_OFFSET(generic_reg.address), + 1} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_set_fixed_io - * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Aml - Where the AML descriptor is returned + * acpi_rs_convert_end_dpf * - * RETURN: Status + ******************************************************************************/ + +struct acpi_rsconvert_info acpi_rs_convert_end_dpf[2] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT, + ACPI_RS_SIZE_MIN, + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_dpf)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT, + sizeof(struct aml_resource_end_dependent), + 0} +}; + +/******************************************************************************* * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. + * acpi_rs_convert_end_tag * ******************************************************************************/ -acpi_status -acpi_rs_set_fixed_io(struct acpi_resource *resource, union aml_resource *aml) -{ - ACPI_FUNCTION_TRACE("rs_set_fixed_io"); +struct acpi_rsconvert_info acpi_rs_convert_end_tag[2] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG, + ACPI_RS_SIZE_MIN, + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_tag)}, /* - * Set the following contiguous fields in the AML descriptor: - * Base Address - * Length + * Note: The checksum field is set to zero, meaning that the resource + * data is treated as if the checksum operation succeeded. + * (ACPI Spec 1.0b Section 6.4.2.8) */ - ACPI_MOVE_32_TO_16(&aml->fixed_io.address, - &resource->data.fixed_io.address); - aml->fixed_io.address_length = - (u8) resource->data.fixed_io.address_length; - - /* Complete the AML descriptor header */ - - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_IO, - sizeof(struct aml_resource_fixed_io), aml); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG, + sizeof(struct aml_resource_end_tag), + 0} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_get_dma - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. + * acpi_rs_get_start_dpf * ******************************************************************************/ -acpi_status -acpi_rs_get_dma(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource) -{ - u32 channel_count = 0; - u32 i; - u8 temp8; +struct acpi_rsconvert_info acpi_rs_get_start_dpf[5] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT, + ACPI_RS_SIZE(struct acpi_resource_start_dependent), + ACPI_RSC_TABLE_SIZE(acpi_rs_get_start_dpf)}, - ACPI_FUNCTION_TRACE("rs_get_dma"); + /* Defaults for Compatibility and Performance priorities */ - /* Decode the DMA channel bits */ + {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.start_dpf.compatibility_priority), + ACPI_ACCEPTABLE_CONFIGURATION, + 2}, - for (i = 0; i < 8; i++) { - if ((aml->dma.dma_channel_mask >> i) & 0x01) { - resource->data.dma.channels[channel_count] = i; - channel_count++; - } - } + /* All done if there is no flag byte present in the descriptor */ - resource->length = 0; - resource->data.dma.channel_count = channel_count; + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1}, - /* - * Calculate the structure size based upon the number of channels - * Note: Zero DMA channels is valid - */ - if (channel_count > 0) { - resource->length = (u32) (channel_count - 1) * 4; - } - - /* Get the flags: transfer preference, bus mastering, channel speed */ + /* Flag byte is present, get the flags */ - temp8 = aml->dma.flags; - resource->data.dma.transfer = temp8 & 0x03; - resource->data.dma.bus_master = (temp8 >> 2) & 0x01; - resource->data.dma.type = (temp8 >> 5) & 0x03; + {ACPI_RSC_2BITFLAG, + ACPI_RS_OFFSET(data.start_dpf.compatibility_priority), + AML_OFFSET(start_dpf.flags), + 0}, - if (resource->data.dma.transfer == 0x03) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid DMA.Transfer preference (3)\n")); - return_ACPI_STATUS(AE_BAD_DATA); - } - - /* Complete the resource header */ - - resource->type = ACPI_RESOURCE_TYPE_DMA; - resource->length += ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_2BITFLAG, + ACPI_RS_OFFSET(data.start_dpf.performance_robustness), + AML_OFFSET(start_dpf.flags), + 2} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_set_dma - * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Aml - Where the AML descriptor is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. + * acpi_rs_set_start_dpf * ******************************************************************************/ -acpi_status -acpi_rs_set_dma(struct acpi_resource *resource, union aml_resource *aml) -{ - u8 i; - - ACPI_FUNCTION_TRACE("rs_set_dma"); +struct acpi_rsconvert_info acpi_rs_set_start_dpf[6] = { + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT, + sizeof(struct aml_resource_start_dependent), + ACPI_RSC_TABLE_SIZE(acpi_rs_set_start_dpf)}, - /* Convert channel list to 8-bit DMA channel bitmask */ + /* Set the default flag values */ - aml->dma.dma_channel_mask = 0; - for (i = 0; i < resource->data.dma.channel_count; i++) { - aml->dma.dma_channel_mask |= - (1 << resource->data.dma.channels[i]); - } + {ACPI_RSC_2BITFLAG, + ACPI_RS_OFFSET(data.start_dpf.compatibility_priority), + AML_OFFSET(start_dpf.flags), + 0}, - /* Set the DMA Flag bits */ + {ACPI_RSC_2BITFLAG, + ACPI_RS_OFFSET(data.start_dpf.performance_robustness), + AML_OFFSET(start_dpf.flags), + 2}, + /* + * All done if flags byte is necessary -- if either priority value + * is not ACPI_ACCEPTABLE_CONFIGURATION + */ + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(data.start_dpf.compatibility_priority), + ACPI_ACCEPTABLE_CONFIGURATION}, - aml->dma.flags = (u8) - (((resource->data.dma.type & 0x03) << 5) | - ((resource->data.dma.bus_master & 0x01) << 2) | - (resource->data.dma.transfer & 0x03)); + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(data.start_dpf.performance_robustness), + ACPI_ACCEPTABLE_CONFIGURATION}, - /* Complete the AML descriptor header */ + /* Flag byte is not necessary */ - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_DMA, - sizeof(struct aml_resource_dma), aml); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_LENGTH, 0, 0, + sizeof(struct aml_resource_start_dependent_noprio)} +}; diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c index 4e854ba70811..79e71257b69a 100644 --- a/drivers/acpi/resources/rsirq.c +++ b/drivers/acpi/resources/rsirq.c @@ -49,325 +49,182 @@ ACPI_MODULE_NAME("rsirq") /******************************************************************************* * - * FUNCTION: acpi_rs_get_irq - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. + * acpi_rs_get_irq * ******************************************************************************/ -acpi_status -acpi_rs_get_irq(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource) -{ - u16 temp16 = 0; - u32 interrupt_count = 0; - u32 i; - u32 resource_length; - - ACPI_FUNCTION_TRACE("rs_get_irq"); +struct acpi_rsconvert_info acpi_rs_get_irq[7] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ, + ACPI_RS_SIZE(struct acpi_resource_irq), + ACPI_RSC_TABLE_SIZE(acpi_rs_get_irq)}, /* Get the IRQ mask (bytes 1:2) */ - ACPI_MOVE_16_TO_16(&temp16, &aml->irq.irq_mask); - - /* Decode the IRQ bits (up to 16 possible) */ - - for (i = 0; i < 16; i++) { - if ((temp16 >> i) & 0x01) { - resource->data.irq.interrupts[interrupt_count] = i; - interrupt_count++; - } - } - - /* Zero interrupts is valid */ - - resource_length = 0; - resource->data.irq.interrupt_count = interrupt_count; - if (interrupt_count > 0) { - /* Calculate the structure size based upon the number of interrupts */ - - resource_length = (u32) (interrupt_count - 1) * 4; - } - - /* Get Flags (Byte 3) if it is used */ - - if (aml_resource_length == 3) { - /* Check for HE, LL interrupts */ - - switch (aml->irq.flags & 0x09) { - case 0x01: /* HE */ - resource->data.irq.triggering = ACPI_EDGE_SENSITIVE; - resource->data.irq.polarity = ACPI_ACTIVE_HIGH; - break; - - case 0x08: /* LL */ - resource->data.irq.triggering = ACPI_LEVEL_SENSITIVE; - resource->data.irq.polarity = ACPI_ACTIVE_LOW; - break; - - default: - /* - * Only _LL and _HE polarity/trigger interrupts - * are allowed (ACPI spec, section "IRQ Format") - * so 0x00 and 0x09 are illegal. - */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid interrupt polarity/trigger in resource list, %X\n", - aml->irq.flags)); - return_ACPI_STATUS(AE_BAD_DATA); - } - - /* Get Sharing flag */ - - resource->data.irq.sharable = (aml->irq.flags >> 3) & 0x01; - } else { - /* - * Default configuration: assume Edge Sensitive, Active High, - * Non-Sharable as per the ACPI Specification - */ - resource->data.irq.triggering = ACPI_EDGE_SENSITIVE; - resource->data.irq.polarity = ACPI_ACTIVE_HIGH; - resource->data.irq.sharable = ACPI_EXCLUSIVE; - } - - /* Complete the resource header */ - - resource->type = ACPI_RESOURCE_TYPE_IRQ; - resource->length = - resource_length + ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_BITMASK16, ACPI_RS_OFFSET(data.irq.interrupts[0]), + AML_OFFSET(irq.irq_mask), + ACPI_RS_OFFSET(data.irq.interrupt_count)}, + + /* Set default flags (others are zero) */ + + {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.irq.triggering), + ACPI_EDGE_SENSITIVE, + 1}, + + /* All done if no flag byte present in descriptor */ + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3}, + + /* Get flags: Triggering[0], Polarity[3], Sharing[4] */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering), + AML_OFFSET(irq.flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity), + AML_OFFSET(irq.flags), + 3}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable), + AML_OFFSET(irq.flags), + 4} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_set_irq - * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Aml - Where the AML descriptor is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. + * acpi_rs_set_irq * ******************************************************************************/ -acpi_status -acpi_rs_set_irq(struct acpi_resource *resource, union aml_resource *aml) -{ - acpi_size descriptor_length; - u16 irq_mask; - u8 i; - - ACPI_FUNCTION_TRACE("rs_set_irq"); +struct acpi_rsconvert_info acpi_rs_set_irq[9] = { + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ, + sizeof(struct aml_resource_irq), + ACPI_RSC_TABLE_SIZE(acpi_rs_set_irq)}, /* Convert interrupt list to 16-bit IRQ bitmask */ - irq_mask = 0; - for (i = 0; i < resource->data.irq.interrupt_count; i++) { - irq_mask |= (1 << resource->data.irq.interrupts[i]); - } + {ACPI_RSC_BITMASK16, ACPI_RS_OFFSET(data.irq.interrupts[0]), + AML_OFFSET(irq.irq_mask), + ACPI_RS_OFFSET(data.irq.interrupt_count)}, + + /* Set the flags byte by default */ - /* Set the interrupt mask */ + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering), + AML_OFFSET(irq.flags), + 0}, - ACPI_MOVE_16_TO_16(&aml->irq.irq_mask, &irq_mask); + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity), + AML_OFFSET(irq.flags), + 3}, + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable), + AML_OFFSET(irq.flags), + 4}, /* - * The descriptor field is set based upon whether a third byte is - * needed to contain the IRQ Information. + * Check if the flags byte is necessary. Not needed if the flags are: + * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE */ - if ((resource->data.irq.triggering == ACPI_EDGE_SENSITIVE) && - (resource->data.irq.polarity == ACPI_ACTIVE_HIGH) && - (resource->data.irq.sharable == ACPI_EXCLUSIVE)) { - /* irq_no_flags() descriptor can be used */ - - descriptor_length = sizeof(struct aml_resource_irq_noflags); - } else { - /* Irq() descriptor must be used */ - - descriptor_length = sizeof(struct aml_resource_irq); - - /* Set the IRQ Info byte */ + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(data.irq.triggering), + ACPI_EDGE_SENSITIVE}, - aml->irq.flags = (u8) - ((resource->data.irq.sharable & 0x01) << 4); + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(data.irq.polarity), + ACPI_ACTIVE_HIGH}, - if (ACPI_LEVEL_SENSITIVE == resource->data.irq.triggering && - ACPI_ACTIVE_LOW == resource->data.irq.polarity) { - aml->irq.flags |= 0x08; - } else { - aml->irq.flags |= 0x01; - } - } + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(data.irq.sharable), + ACPI_EXCLUSIVE}, - /* Complete the AML descriptor header */ + /* irq_no_flags() descriptor can be used */ - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IRQ, descriptor_length, - aml); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_irq_noflags)} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_get_ext_irq - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. + * acpi_rs_convert_ext_irq * ******************************************************************************/ -acpi_status -acpi_rs_get_ext_irq(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource) -{ - char *out_resource_string; - u8 temp8; - - ACPI_FUNCTION_TRACE("rs_get_ext_irq"); - - /* Get the flag bits */ +struct acpi_rsconvert_info acpi_rs_convert_ext_irq[9] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ, + ACPI_RS_SIZE(struct acpi_resource_extended_irq), + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_irq)}, - temp8 = aml->extended_irq.flags; - resource->data.extended_irq.producer_consumer = temp8 & 0x01; - resource->data.extended_irq.polarity = (temp8 >> 2) & 0x01; - resource->data.extended_irq.sharable = (temp8 >> 3) & 0x01; + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ, + sizeof(struct aml_resource_extended_irq), + 0}, - /* - * Check for Interrupt Mode - * - * The definition of an Extended IRQ changed between ACPI spec v1.0b - * and ACPI spec 2.0 (section 6.4.3.6 in both). - * - * - Edge/Level are defined opposite in the table vs the headers - */ - resource->data.extended_irq.triggering = - (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; + /* Flag bits */ - /* Get the IRQ Table length (Byte4) */ + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.producer_consumer), + AML_OFFSET(extended_irq.flags), + 0}, - temp8 = aml->extended_irq.table_length; - resource->data.extended_irq.interrupt_count = temp8; - if (temp8 < 1) { - /* Must have at least one IRQ */ + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.triggering), + AML_OFFSET(extended_irq.flags), + 1}, - return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); - } + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.polarity), + AML_OFFSET(extended_irq.flags), + 2}, - /* - * Add any additional structure size to properly calculate - * the next pointer at the end of this function - */ - resource->length = (temp8 - 1) * 4; - out_resource_string = ACPI_CAST_PTR(char, - (&resource->data.extended_irq. - interrupts[0] + temp8)); + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.sharable), + AML_OFFSET(extended_irq.flags), + 3}, - /* Get every IRQ in the table, each is 32 bits */ + /* IRQ Table length (Byte4) */ - acpi_rs_move_data(resource->data.extended_irq.interrupts, - aml->extended_irq.interrupt_number, - (u16) temp8, ACPI_MOVE_TYPE_32_TO_32); + {ACPI_RSC_COUNT, ACPI_RS_OFFSET(data.extended_irq.interrupt_count), + AML_OFFSET(extended_irq.interrupt_count), + sizeof(u32)} + , - /* Get the optional resource_source (index and string) */ + /* Copy every IRQ in the table, each is 32 bits */ - resource->length += - acpi_rs_get_resource_source(aml_resource_length, - (acpi_size) resource->length + - sizeof(struct - aml_resource_extended_irq), - &resource->data.extended_irq. - resource_source, aml, - out_resource_string); + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.extended_irq.interrupts[0]), + AML_OFFSET(extended_irq.interrupts[0]), + 0} + , - /* Complete the resource header */ + /* Optional resource_source (Index and String) */ - resource->type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; - resource->length += - ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_irq); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_SOURCEX, ACPI_RS_OFFSET(data.extended_irq.resource_source), + ACPI_RS_OFFSET(data.extended_irq.interrupts[0]), + sizeof(struct aml_resource_extended_irq)} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_set_ext_irq - * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Aml - Where the AML descriptor is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. + * acpi_rs_convert_dma * ******************************************************************************/ -acpi_status -acpi_rs_set_ext_irq(struct acpi_resource *resource, union aml_resource *aml) -{ - acpi_size descriptor_length; - - ACPI_FUNCTION_TRACE("rs_set_ext_irq"); - - /* Set the Interrupt vector flags */ - - aml->extended_irq.flags = (u8) - ((resource->data.extended_irq.producer_consumer & 0x01) | - ((resource->data.extended_irq.sharable & 0x01) << 3) | - ((resource->data.extended_irq.polarity & 0x1) << 2)); - - /* - * Set the Interrupt Mode - * - * The definition of an Extended IRQ changed between ACPI spec v1.0b - * and ACPI spec 2.0 (section 6.4.3.6 in both). This code does not - * implement the more restrictive definition of 1.0b - * - * - Edge/Level are defined opposite in the table vs the headers - */ - if (resource->data.extended_irq.triggering == ACPI_EDGE_SENSITIVE) { - aml->extended_irq.flags |= 0x02; - } - - /* Set the Interrupt table length */ - - aml->extended_irq.table_length = (u8) - resource->data.extended_irq.interrupt_count; +struct acpi_rsconvert_info acpi_rs_convert_dma[6] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_DMA, + ACPI_RS_SIZE(struct acpi_resource_dma), + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_dma)}, - descriptor_length = (sizeof(struct aml_resource_extended_irq) - 4) + - ((acpi_size) resource->data.extended_irq.interrupt_count * - sizeof(u32)); + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA, + sizeof(struct aml_resource_dma), + 0}, - /* Set each interrupt value */ + /* Flags: transfer preference, bus mastering, channel speed */ - acpi_rs_move_data(aml->extended_irq.interrupt_number, - resource->data.extended_irq.interrupts, - (u16) resource->data.extended_irq.interrupt_count, - ACPI_MOVE_TYPE_32_TO_32); + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.transfer), + AML_OFFSET(dma.flags), + 0}, - /* Resource Source Index and Resource Source are optional */ + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.dma.bus_master), + AML_OFFSET(dma.flags), + 2}, - descriptor_length = acpi_rs_set_resource_source(aml, descriptor_length, - &resource->data. - extended_irq. - resource_source); + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.type), + AML_OFFSET(dma.flags), + 5}, - /* Complete the AML descriptor header */ + /* DMA channel mask bits */ - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_EXTENDED_IRQ, - descriptor_length, aml); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_BITMASK, ACPI_RS_OFFSET(data.dma.channels[0]), + AML_OFFSET(dma.dma_channel_mask), + ACPI_RS_OFFSET(data.dma.channel_count)} +}; diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c index f72d42e0927b..ee17ef3315f8 100644 --- a/drivers/acpi/resources/rslist.c +++ b/drivers/acpi/resources/rslist.c @@ -48,7 +48,8 @@ ACPI_MODULE_NAME("rslist") /* Local prototypes */ -static ACPI_GET_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type); +static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8 + resource_type); static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml); @@ -83,7 +84,7 @@ static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml) return (AE_AML_INVALID_RESOURCE_TYPE); } - resource_length = acpi_rs_get_resource_length(aml); + resource_length = acpi_ut_get_resource_length(aml); minimum_aml_resource_length = resource_info->minimum_aml_resource_length; @@ -115,18 +116,17 @@ static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml) /******************************************************************************* * - * FUNCTION: acpi_rs_get_resource_handler + * FUNCTION: acpi_rs_get_conversion_info * * PARAMETERS: resource_type - Byte 0 of a resource descriptor * - * RETURN: Pointer to the resource conversion handler + * RETURN: Pointer to the resource conversion info table * - * DESCRIPTION: Extract the Resource Type/Name from the first byte of - * a resource descriptor. + * DESCRIPTION: Get the conversion table associated with this resource type * ******************************************************************************/ -static ACPI_GET_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type) +static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8 resource_type) { ACPI_FUNCTION_ENTRY(); @@ -174,33 +174,24 @@ acpi_rs_convert_aml_to_resources(u8 * aml_buffer, acpi_status status; acpi_size bytes_parsed = 0; struct acpi_resource *resource; - u16 resource_length; - u32 descriptor_length; - ACPI_GET_RESOURCE_HANDLER handler; + acpi_rsdesc_size descriptor_length; + struct acpi_rsconvert_info *info; ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources"); /* Loop until end-of-buffer or an end_tag is found */ while (bytes_parsed < aml_buffer_length) { - /* Get the handler associated with this Descriptor Type */ + /* Get the conversion table associated with this Descriptor Type */ - handler = acpi_rs_get_resource_handler(*aml_buffer); - if (!handler) { - /* No handler indicates invalid resource type */ + info = acpi_rs_get_conversion_info(*aml_buffer); + if (!info) { + /* No table indicates an invalid resource type */ return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); } - resource_length = - acpi_rs_get_resource_length(ACPI_CAST_PTR - (union aml_resource, - aml_buffer)); - - descriptor_length = - acpi_rs_get_descriptor_length(ACPI_CAST_PTR - (union aml_resource, - aml_buffer)); + descriptor_length = acpi_ut_get_descriptor_length(aml_buffer); /* * Perform limited validation of the resource length, based upon @@ -214,11 +205,16 @@ acpi_rs_convert_aml_to_resources(u8 * aml_buffer, return_ACPI_STATUS(status); } - /* Convert a byte stream resource to local resource struct */ + /* Convert the AML byte stream resource to a local resource struct */ - status = handler(ACPI_CAST_PTR(union aml_resource, aml_buffer), - resource_length, - ACPI_CAST_PTR(struct acpi_resource, buffer)); + status = + acpi_rs_convert_aml_to_resource(ACPI_CAST_PTR + (struct acpi_resource, + buffer), + ACPI_CAST_PTR(union + aml_resource, + aml_buffer), + info); if (ACPI_FAILURE(status)) { ACPI_REPORT_ERROR(("Could not convert AML resource (type %X) to resource, %s\n", *aml_buffer, acpi_format_exception(status))); return_ACPI_STATUS(status); @@ -232,7 +228,7 @@ acpi_rs_convert_aml_to_resources(u8 * aml_buffer, /* Normal exit on completion of an end_tag resource descriptor */ - if (acpi_rs_get_resource_type(*aml_buffer) == + if (acpi_ut_get_resource_type(aml_buffer) == ACPI_RESOURCE_NAME_END_TAG) { return_ACPI_STATUS(AE_OK); } @@ -276,14 +272,15 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, acpi_size aml_size_needed, u8 * output_buffer) { u8 *aml_buffer = output_buffer; + u8 *end_aml_buffer = output_buffer + aml_size_needed; acpi_status status; ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml"); - /* Convert each resource descriptor in the list */ + /* Walk the resource descriptor list, convert each descriptor */ - while (1) { - /* Validate Resource Descriptor Type before dispatch */ + while (aml_buffer < end_aml_buffer) { + /* Validate the Resource Type */ if (resource->type > ACPI_RESOURCE_TYPE_MAX) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, @@ -292,14 +289,14 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, return_ACPI_STATUS(AE_BAD_DATA); } - /* Perform the conversion per resource type */ + /* Perform the conversion */ - status = - acpi_gbl_set_resource_dispatch[resource->type] (resource, - ACPI_CAST_PTR - (union - aml_resource, - aml_buffer)); + status = acpi_rs_convert_resource_to_aml(resource, + ACPI_CAST_PTR(union + aml_resource, + aml_buffer), + acpi_gbl_set_resource_dispatch + [resource->type]); if (ACPI_FAILURE(status)) { ACPI_REPORT_ERROR(("Could not convert resource (type %X) to AML, %s\n", resource->type, acpi_format_exception(status))); return_ACPI_STATUS(status); @@ -323,18 +320,23 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, return_ACPI_STATUS(AE_OK); } - /* Extract the total length of the new descriptor */ - /* Set the aml_buffer to point to the next (output) resource descriptor */ - - aml_buffer += - acpi_rs_get_descriptor_length(ACPI_CAST_PTR - (union aml_resource, - aml_buffer)); + /* + * Extract the total length of the new descriptor and set the + * aml_buffer to point to the next (output) resource descriptor + */ + aml_buffer += acpi_ut_get_descriptor_length(aml_buffer); /* Point to the next input resource descriptor */ resource = ACPI_PTR_ADD(struct acpi_resource, resource, resource->length); + + /* Check for end-of-list, normal exit */ + } + + /* Completed buffer, but did not find an end_tag resource descriptor */ + + return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); } diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c index 47e979e7ba35..418a3fb64077 100644 --- a/drivers/acpi/resources/rsmemory.c +++ b/drivers/acpi/resources/rsmemory.c @@ -49,260 +49,187 @@ ACPI_MODULE_NAME("rsmemory") /******************************************************************************* * - * FUNCTION: acpi_rs_get_memory24 - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. + * acpi_rs_convert_memory24 * ******************************************************************************/ -acpi_status -acpi_rs_get_memory24(union aml_resource * aml, - u16 aml_resource_length, struct acpi_resource * resource) -{ - ACPI_FUNCTION_TRACE("rs_get_memory24"); +struct acpi_rsconvert_info acpi_rs_convert_memory24[4] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY24, + ACPI_RS_SIZE(struct acpi_resource_memory24), + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_memory24)}, - /* Get the Read/Write bit */ + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY24, + sizeof(struct aml_resource_memory24), + 0}, - resource->data.memory24.read_write_attribute = - (aml->memory24.information & 0x01); + /* Read/Write bit */ + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.memory24.write_protect), + AML_OFFSET(memory24.flags), + 0}, /* - * Get the following contiguous fields from the AML descriptor: + * These fields are contiguous in both the source and destination: * Minimum Base Address * Maximum Base Address * Address Base Alignment * Range Length */ - acpi_rs_move_data(&resource->data.memory24.minimum, - &aml->memory24.minimum, 4, ACPI_MOVE_TYPE_16_TO_32); - - /* Complete the resource header */ - - resource->type = ACPI_RESOURCE_TYPE_MEMORY24; - resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.memory24.minimum), + AML_OFFSET(memory24.minimum), + 4} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_set_memory24 - * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Aml - Where the AML descriptor is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. + * acpi_rs_convert_memory32 * ******************************************************************************/ -acpi_status -acpi_rs_set_memory24(struct acpi_resource *resource, union aml_resource *aml) -{ - ACPI_FUNCTION_TRACE("rs_set_memory24"); +struct acpi_rsconvert_info acpi_rs_convert_memory32[4] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY32, + ACPI_RS_SIZE(struct acpi_resource_memory32), + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_memory32)}, - /* Set the Information Byte */ + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY32, + sizeof(struct aml_resource_memory32), + 0}, - aml->memory24.information = (u8) - (resource->data.memory24.read_write_attribute & 0x01); + /* Read/Write bit */ + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.memory32.write_protect), + AML_OFFSET(memory32.flags), + 0}, /* - * Set the following contiguous fields in the AML descriptor: + * These fields are contiguous in both the source and destination: * Minimum Base Address * Maximum Base Address * Address Base Alignment * Range Length */ - acpi_rs_move_data(&aml->memory24.minimum, - &resource->data.memory24.minimum, 4, - ACPI_MOVE_TYPE_32_TO_16); - - /* Complete the AML descriptor header */ - - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY24, - sizeof(struct aml_resource_memory24), aml); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.memory32.minimum), + AML_OFFSET(memory32.minimum), + 4} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_get_memory32 - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. + * acpi_rs_convert_fixed_memory32 * ******************************************************************************/ -acpi_status -acpi_rs_get_memory32(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource) -{ - ACPI_FUNCTION_TRACE("rs_get_memory32"); +struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[4] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_MEMORY32, + ACPI_RS_SIZE(struct acpi_resource_fixed_memory32), + ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_memory32)}, - /* Get the Read/Write bit */ + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_MEMORY32, + sizeof(struct aml_resource_fixed_memory32), + 0}, - resource->data.memory32.read_write_attribute = - (aml->memory32.information & 0x01); + /* Read/Write bit */ + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.fixed_memory32.write_protect), + AML_OFFSET(fixed_memory32.flags), + 0}, /* - * Get the following contiguous fields from the AML descriptor: - * Minimum Base Address - * Maximum Base Address - * Address Base Alignment + * These fields are contiguous in both the source and destination: + * Base Address * Range Length */ - acpi_rs_move_data(&resource->data.memory32.minimum, - &aml->memory32.minimum, 4, ACPI_MOVE_TYPE_32_TO_32); - - /* Complete the resource header */ - - resource->type = ACPI_RESOURCE_TYPE_MEMORY32; - resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory32); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.fixed_memory32.address), + AML_OFFSET(fixed_memory32.address), + 2} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_set_memory32 - * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Aml - Where the AML descriptor is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. + * acpi_rs_get_vendor_small * ******************************************************************************/ -acpi_status -acpi_rs_set_memory32(struct acpi_resource *resource, union aml_resource *aml) -{ - ACPI_FUNCTION_TRACE("rs_set_memory32"); - - /* Set the Information Byte */ +struct acpi_rsconvert_info acpi_rs_get_vendor_small[3] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR, + ACPI_RS_SIZE(struct acpi_resource_vendor), + ACPI_RSC_TABLE_SIZE(acpi_rs_get_vendor_small)}, - aml->memory32.information = (u8) - (resource->data.memory32.read_write_attribute & 0x01); + /* Length of the vendor data (byte count) */ - /* - * Set the following contiguous fields in the AML descriptor: - * Minimum Base Address - * Maximum Base Address - * Address Base Alignment - * Range Length - */ - acpi_rs_move_data(&aml->memory32.minimum, - &resource->data.memory32.minimum, 4, - ACPI_MOVE_TYPE_32_TO_32); + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length), + 0, + sizeof(u8)} + , - /* Complete the AML descriptor header */ + /* Vendor data */ - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_MEMORY32, - sizeof(struct aml_resource_memory32), aml); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]), + sizeof(struct aml_resource_small_header), + 0} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_get_fixed_memory32 - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. + * acpi_rs_get_vendor_large * ******************************************************************************/ -acpi_status -acpi_rs_get_fixed_memory32(union aml_resource *aml, - u16 aml_resource_length, - struct acpi_resource *resource) -{ - ACPI_FUNCTION_TRACE("rs_get_fixed_memory32"); - - /* Get the Read/Write bit */ +struct acpi_rsconvert_info acpi_rs_get_vendor_large[3] = { + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR, + ACPI_RS_SIZE(struct acpi_resource_vendor), + ACPI_RSC_TABLE_SIZE(acpi_rs_get_vendor_large)}, - resource->data.fixed_memory32.read_write_attribute = - (aml->fixed_memory32.information & 0x01); + /* Length of the vendor data (byte count) */ - /* - * Get the following contiguous fields from the AML descriptor: - * Base Address - * Range Length - */ - ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address, - &aml->fixed_memory32.address); - ACPI_MOVE_32_TO_32(&resource->data.fixed_memory32.address_length, - &aml->fixed_memory32.address_length); + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length), + 0, + sizeof(u8)} + , - /* Complete the resource header */ + /* Vendor data */ - resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32; - resource->length = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_memory32); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]), + sizeof(struct aml_resource_large_header), + 0} +}; /******************************************************************************* * - * FUNCTION: acpi_rs_set_fixed_memory32 - * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Aml - Where the AML descriptor is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. + * acpi_rs_set_vendor * ******************************************************************************/ -acpi_status -acpi_rs_set_fixed_memory32(struct acpi_resource *resource, - union aml_resource *aml) -{ - ACPI_FUNCTION_TRACE("rs_set_fixed_memory32"); +struct acpi_rsconvert_info acpi_rs_set_vendor[7] = { + /* Default is a small vendor descriptor */ + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_SMALL, + sizeof(struct aml_resource_small_header), + ACPI_RSC_TABLE_SIZE(acpi_rs_set_vendor)}, + + /* Get the length and copy the data */ - /* Set the Information Byte */ + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length), + 0, + 0}, - aml->fixed_memory32.information = (u8) - (resource->data.fixed_memory32.read_write_attribute & 0x01); + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]), + sizeof(struct aml_resource_small_header), + 0}, /* - * Set the following contiguous fields in the AML descriptor: - * Base Address - * Range Length + * All done if the Vendor byte length is 7 or less, meaning that it will + * fit within a small descriptor */ - ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address, - &resource->data.fixed_memory32.address); - ACPI_MOVE_32_TO_32(&aml->fixed_memory32.address_length, - &resource->data.fixed_memory32.address_length); - - /* Complete the AML descriptor header */ - - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_MEMORY32, - sizeof(struct aml_resource_fixed_memory32), - aml); - return_ACPI_STATUS(AE_OK); -} + {ACPI_RSC_EXIT_LE, 0, 0, 7}, + + /* Must create a large vendor descriptor */ + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_LARGE, + sizeof(struct aml_resource_large_header), + 0}, + + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length), + 0, + 0}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]), + sizeof(struct aml_resource_large_header), + 0} +}; diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c index 337a0f01cb23..16ad3bfbee2a 100644 --- a/drivers/acpi/resources/rsmisc.c +++ b/drivers/acpi/resources/rsmisc.c @@ -47,156 +47,267 @@ #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME("rsmisc") +#define INIT_RESOURCE_TYPE(i) i->resource_offset +#define INIT_RESOURCE_LENGTH(i) i->aml_offset +#define INIT_TABLE_LENGTH(i) i->value +#define COMPARE_OPCODE(i) i->resource_offset +#define COMPARE_TARGET(i) i->aml_offset +#define COMPARE_VALUE(i) i->value /******************************************************************************* * - * FUNCTION: acpi_rs_get_generic_reg - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. - * - ******************************************************************************/ -acpi_status -acpi_rs_get_generic_reg(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource) -{ - ACPI_FUNCTION_TRACE("rs_get_generic_reg"); - - /* - * Get the following fields from the AML descriptor: - * Address Space ID - * Register Bit Width - * Register Bit Offset - * Access Size - * Register Address - */ - resource->data.generic_reg.space_id = aml->generic_reg.address_space_id; - resource->data.generic_reg.bit_width = aml->generic_reg.bit_width; - resource->data.generic_reg.bit_offset = aml->generic_reg.bit_offset; - resource->data.generic_reg.access_size = aml->generic_reg.access_size; - ACPI_MOVE_64_TO_64(&resource->data.generic_reg.address, - &aml->generic_reg.address); - - /* Complete the resource header */ - - resource->type = ACPI_RESOURCE_TYPE_GENERIC_REGISTER; - resource->length = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register); - return_ACPI_STATUS(AE_OK); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_set_generic_reg + * FUNCTION: acpi_rs_convert_aml_to_resource * * PARAMETERS: Resource - Pointer to the resource descriptor * Aml - Where the AML descriptor is returned + * Info - Pointer to appropriate conversion table * * RETURN: Status * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. - * - ******************************************************************************/ - -acpi_status -acpi_rs_set_generic_reg(struct acpi_resource *resource, union aml_resource *aml) -{ - ACPI_FUNCTION_TRACE("rs_set_generic_reg"); - - /* - * Set the following fields in the AML descriptor: - * Address Space ID - * Register Bit Width - * Register Bit Offset - * Access Size - * Register Address - */ - aml->generic_reg.address_space_id = - (u8) resource->data.generic_reg.space_id; - aml->generic_reg.bit_width = (u8) resource->data.generic_reg.bit_width; - aml->generic_reg.bit_offset = - (u8) resource->data.generic_reg.bit_offset; - aml->generic_reg.access_size = - (u8) resource->data.generic_reg.access_size; - ACPI_MOVE_64_TO_64(&aml->generic_reg.address, - &resource->data.generic_reg.address); - - /* Complete the AML descriptor header */ - - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_GENERIC_REGISTER, - sizeof(struct - aml_resource_generic_register), aml); - return_ACPI_STATUS(AE_OK); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_get_vendor - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. + * DESCRIPTION: Convert an external AML resource descriptor to the corresponding + * internal resource descriptor * ******************************************************************************/ - acpi_status -acpi_rs_get_vendor(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource) +acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, + union aml_resource *aml, + struct acpi_rsconvert_info *info) { - u8 *aml_byte_data; - - ACPI_FUNCTION_TRACE("rs_get_vendor"); + acpi_rs_length aml_resource_length; + void *source; + void *destination; + char *target; + u8 count; + u8 flags_mode = FALSE; + u16 item_count = 0; + u16 temp16 = 0; + + ACPI_FUNCTION_TRACE("rs_get_resource"); + + if (((acpi_native_uint) resource) & 0x3) { + acpi_os_printf + ("**** GET: Misaligned resource pointer: %p Type %2.2X Len %X\n", + resource, resource->type, resource->length); + } - /* Determine if this is a large or small vendor specific item */ + /* Extract the resource Length field (does not include header length) */ - if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { - /* Large item, Point to the first vendor byte */ + aml_resource_length = acpi_ut_get_resource_length(aml); - aml_byte_data = - ((u8 *) aml) + sizeof(struct aml_resource_large_header); - } else { - /* Small item, Point to the first vendor byte */ + /* + * First table entry must be ACPI_RSC_INITxxx and must contain the + * table length (# of table entries) + */ + count = INIT_TABLE_LENGTH(info); + + while (count) { + /* + * Source is the external AML byte stream buffer, + * destination is the internal resource descriptor + */ + source = ((u8 *) aml) + info->aml_offset; + destination = ((u8 *) resource) + info->resource_offset; + + switch (info->opcode) { + case ACPI_RSC_INITGET: + /* + * Get the resource type and the initial (minimum) length + */ + ACPI_MEMSET(resource, 0, INIT_RESOURCE_LENGTH(info)); + resource->type = INIT_RESOURCE_TYPE(info); + resource->length = INIT_RESOURCE_LENGTH(info); + break; + + case ACPI_RSC_INITSET: + break; + + case ACPI_RSC_FLAGINIT: + + flags_mode = TRUE; + break; + + case ACPI_RSC_1BITFLAG: + /* + * Mask and shift the flag bit + */ + *((u8 *) destination) = (u8) + ((*((u8 *) source) >> info->value) & 0x01); + break; + + case ACPI_RSC_2BITFLAG: + /* + * Mask and shift the flag bits + */ + *((u8 *) destination) = (u8) + ((*((u8 *) source) >> info->value) & 0x03); + break; + + case ACPI_RSC_COUNT: + + item_count = *((u8 *) source); + *((u8 *) destination) = (u8) item_count; + + resource->length = resource->length + + (info->value * (item_count - 1)); + break; + + case ACPI_RSC_COUNT16: + + item_count = aml_resource_length; + *((u16 *) destination) = item_count; + + resource->length = resource->length + + (info->value * (item_count - 1)); + break; + + case ACPI_RSC_LENGTH: + + resource->length = resource->length + info->value; + break; + + case ACPI_RSC_MOVE8: + case ACPI_RSC_MOVE16: + case ACPI_RSC_MOVE32: + case ACPI_RSC_MOVE64: + /* + * Raw data move. Use the Info value field unless item_count has + * been previously initialized via a COUNT opcode + */ + if (info->value) { + item_count = info->value; + } + acpi_rs_move_data(destination, source, item_count, + info->opcode); + break; + + case ACPI_RSC_SET8: + + ACPI_MEMSET(destination, info->aml_offset, info->value); + break; + + case ACPI_RSC_DATA8: + + target = ((char *)resource) + info->value; + ACPI_MEMCPY(destination, source, + *(ACPI_CAST_PTR(u16, target))); + break; + + case ACPI_RSC_ADDRESS: + /* + * Common handler for address descriptor flags + */ + if (!acpi_rs_get_address_common(resource, aml)) { + return_ACPI_STATUS + (AE_AML_INVALID_RESOURCE_TYPE); + } + break; + + case ACPI_RSC_SOURCE: + /* + * Optional resource_source (Index and String) + */ + resource->length += + acpi_rs_get_resource_source(aml_resource_length, + info->value, + destination, aml, NULL); + break; + + case ACPI_RSC_SOURCEX: + /* + * Optional resource_source (Index and String). This is the more + * complicated case used by the Interrupt() macro + */ + target = + ((char *)resource) + info->aml_offset + + (item_count * 4); + + resource->length += + acpi_rs_get_resource_source(aml_resource_length, + (acpi_rs_length) (((item_count - 1) * sizeof(u32)) + info->value), destination, aml, target); + break; + + case ACPI_RSC_BITMASK: + /* + * 8-bit encoded bitmask (DMA macro) + */ + item_count = + acpi_rs_decode_bitmask(*((u8 *) source), + destination); + if (item_count) { + resource->length += + resource->length + (item_count - 1); + } + + target = ((char *)resource) + info->value; + *((u8 *) target) = (u8) item_count; + break; + + case ACPI_RSC_BITMASK16: + /* + * 16-bit encoded bitmask (IRQ macro) + */ + ACPI_MOVE_16_TO_16(&temp16, source); + + item_count = + acpi_rs_decode_bitmask(temp16, destination); + if (item_count) { + resource->length = + resource->length + (item_count - 1); + } + + target = ((char *)resource) + info->value; + *((u8 *) target) = (u8) item_count; + break; + + case ACPI_RSC_EXIT_NE: + /* + * Control - Exit conversion if not equal + */ + switch (info->resource_offset) { + case ACPI_RSC_COMPARE_AML_LENGTH: + if (aml_resource_length != info->value) { + goto exit; + } + break; + + case ACPI_RSC_COMPARE_VALUE: + if (*((u8 *) source) != info->value) { + goto exit; + } + break; + + default: + acpi_os_printf + ("*** Invalid conversion sub-opcode\n"); + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + break; + + default: + + acpi_os_printf("*** Invalid conversion opcode\n"); + return_ACPI_STATUS(AE_BAD_PARAMETER); + } - aml_byte_data = - ((u8 *) aml) + sizeof(struct aml_resource_small_header); + count--; + info++; } - /* Copy the vendor-specific bytes */ - - ACPI_MEMCPY(resource->data.vendor.byte_data, - aml_byte_data, aml_resource_length); - resource->data.vendor.byte_length = aml_resource_length; + exit: + if (!flags_mode) { + /* Round the resource struct length up to the next 32-bit boundary */ - /* - * In order for the struct_size to fall on a 32-bit boundary, - * calculate the length of the vendor string and expand the - * struct_size to the next 32-bit boundary. - */ - resource->type = ACPI_RESOURCE_TYPE_VENDOR; - resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) + - ACPI_ROUND_UP_to_32_bITS(aml_resource_length); + resource->length = ACPI_ROUND_UP_to_32_bITS(resource->length); + } return_ACPI_STATUS(AE_OK); } /******************************************************************************* * - * FUNCTION: acpi_rs_set_vendor + * FUNCTION: acpi_rs_convert_resource_to_aml * * PARAMETERS: Resource - Pointer to the resource descriptor * Aml - Where the AML descriptor is returned + * Info - Pointer to appropriate conversion table * * RETURN: Status * @@ -206,275 +317,236 @@ acpi_rs_get_vendor(union aml_resource *aml, ******************************************************************************/ acpi_status -acpi_rs_set_vendor(struct acpi_resource *resource, union aml_resource *aml) +acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, + union aml_resource *aml, + struct acpi_rsconvert_info *info) { - u32 resource_length; - u8 *source; - u8 *destination; - - ACPI_FUNCTION_TRACE("rs_set_vendor"); - - resource_length = resource->data.vendor.byte_length; - source = ACPI_CAST_PTR(u8, resource->data.vendor.byte_data); - - /* Length determines if this is a large or small resource */ + void *source = NULL; + void *destination; + acpi_rsdesc_size aml_length = 0; + u8 count; + u16 temp16 = 0; + u16 item_count = 0; - if (resource_length > 7) { - /* Large item, get pointer to the data part of the descriptor */ + ACPI_FUNCTION_TRACE("rs_convert_resource_to_aml"); - destination = - ((u8 *) aml) + sizeof(struct aml_resource_large_header); + /* Validate the Resource pointer, must be 32-bit aligned */ - /* Complete the AML descriptor header */ - - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_LARGE, - (u32) (resource_length + - sizeof(struct - aml_resource_large_header)), - aml); - } else { - /* Small item, get pointer to the data part of the descriptor */ - - destination = - ((u8 *) aml) + sizeof(struct aml_resource_small_header); - - /* Complete the AML descriptor header */ - - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_SMALL, - (u32) (resource_length + - sizeof(struct - aml_resource_small_header)), - aml); + if (((acpi_native_uint) resource) & 0x3) { + acpi_os_printf + ("**** SET: Misaligned resource pointer: %p Type %2.2X Len %X\n", + resource, resource->type, resource->length); } - /* Copy the vendor-specific bytes */ - - ACPI_MEMCPY(destination, source, resource_length); - return_ACPI_STATUS(AE_OK); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_get_start_dpf - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. - * - ******************************************************************************/ - -acpi_status -acpi_rs_get_start_dpf(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource) -{ - ACPI_FUNCTION_TRACE("rs_get_start_dpf"); - - /* Get the flags byte if present */ - - if (aml_resource_length == 1) { - /* Get the Compatibility priority */ - - resource->data.start_dpf.compatibility_priority = - (aml->start_dpf.flags & 0x03); - - if (resource->data.start_dpf.compatibility_priority >= 3) { - return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); - } - - /* Get the Performance/Robustness preference */ - - resource->data.start_dpf.performance_robustness = - ((aml->start_dpf.flags >> 2) & 0x03); - - if (resource->data.start_dpf.performance_robustness >= 3) { - return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); + /* + * First table entry must be ACPI_RSC_INITxxx and must contain the + * table length (# of table entries) + */ + count = INIT_TABLE_LENGTH(info); + + while (count) { + /* + * Source is the internal resource descriptor, + * destination is the external AML byte stream buffer + */ + source = ((u8 *) resource) + info->resource_offset; + destination = ((u8 *) aml) + info->aml_offset; + + switch (info->opcode) { + case ACPI_RSC_INITSET: + + ACPI_MEMSET(aml, 0, INIT_RESOURCE_LENGTH(info)); + aml_length = INIT_RESOURCE_LENGTH(info); + acpi_rs_set_resource_header(INIT_RESOURCE_TYPE(info), + aml_length, aml); + break; + + case ACPI_RSC_INITGET: + break; + + case ACPI_RSC_FLAGINIT: + /* + * Clear the flag byte + */ + *((u8 *) destination) = 0; + break; + + case ACPI_RSC_1BITFLAG: + /* + * Mask and shift the flag bit + */ + *((u8 *) destination) |= (u8) + ((*((u8 *) source) & 0x01) << info->value); + break; + + case ACPI_RSC_2BITFLAG: + /* + * Mask and shift the flag bits + */ + *((u8 *) destination) |= (u8) + ((*((u8 *) source) & 0x03) << info->value); + break; + + case ACPI_RSC_COUNT: + + item_count = *((u8 *) source); + *((u8 *) destination) = (u8) item_count; + + aml_length = (u16) (aml_length + + (info->value * (item_count - 1))); + break; + + case ACPI_RSC_COUNT16: + + item_count = *((u16 *) source); + aml_length = (u16) (aml_length + item_count); + acpi_rs_set_resource_length(aml_length, aml); + break; + + case ACPI_RSC_LENGTH: + + acpi_rs_set_resource_length(info->value, aml); + break; + + case ACPI_RSC_MOVE8: + case ACPI_RSC_MOVE16: + case ACPI_RSC_MOVE32: + case ACPI_RSC_MOVE64: + + if (info->value) { + item_count = info->value; + } + acpi_rs_move_data(destination, source, item_count, + info->opcode); + break; + + case ACPI_RSC_ADDRESS: + + /* Set the Resource Type, General Flags, and Type-Specific Flags */ + + acpi_rs_set_address_common(aml, resource); + break; + + case ACPI_RSC_SOURCEX: + /* + * Optional resource_source (Index and String) + */ + aml_length = + acpi_rs_set_resource_source(aml, + (acpi_rs_length) + aml_length, source); + acpi_rs_set_resource_length(aml_length, aml); + break; + + case ACPI_RSC_SOURCE: + /* + * Optional resource_source (Index and String). This is the more + * complicated case used by the Interrupt() macro + */ + aml_length = + acpi_rs_set_resource_source(aml, info->value, + source); + acpi_rs_set_resource_length(aml_length, aml); + break; + + case ACPI_RSC_BITMASK: + /* + * 8-bit encoded bitmask (DMA macro) + */ + *((u8 *) destination) = (u8) + acpi_rs_encode_bitmask(source, + *(((u8 *) resource) + + info->value)); + break; + + case ACPI_RSC_BITMASK16: + /* + * 16-bit encoded bitmask (IRQ macro) + */ + temp16 = + acpi_rs_encode_bitmask(source, + *(((u8 *) resource) + + info->value)); + ACPI_MOVE_16_TO_16(destination, &temp16); + break; + + case ACPI_RSC_EXIT_LE: + /* + * Control - Exit conversion if less than or equal + */ + if (item_count <= info->value) { + goto exit; + } + break; + + case ACPI_RSC_EXIT_NE: + /* + * Control - Exit conversion if not equal + */ + switch (COMPARE_OPCODE(info)) { + case ACPI_RSC_COMPARE_VALUE: + if (* + ((u8 *) (((u8 *) resource) + + COMPARE_TARGET(info))) != + COMPARE_VALUE(info)) { + goto exit; + } + break; + + default: + acpi_os_printf + ("*** Invalid conversion sub-opcode\n"); + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + break; + + default: + + acpi_os_printf("*** Invalid conversion opcode\n"); + return_ACPI_STATUS(AE_BAD_PARAMETER); } - } else { - /* start_dependent_no_pri(), no flags byte, set defaults */ - - resource->data.start_dpf.compatibility_priority = - ACPI_ACCEPTABLE_CONFIGURATION; - resource->data.start_dpf.performance_robustness = - ACPI_ACCEPTABLE_CONFIGURATION; + count--; + info++; } - /* Complete the resource header */ - - resource->type = ACPI_RESOURCE_TYPE_START_DEPENDENT; - resource->length = - ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dependent); + exit: return_ACPI_STATUS(AE_OK); } -/******************************************************************************* - * - * FUNCTION: acpi_rs_set_start_dpf - * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Aml - Where the AML descriptor is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. - * - ******************************************************************************/ - -acpi_status -acpi_rs_set_start_dpf(struct acpi_resource *resource, union aml_resource *aml) -{ - ACPI_FUNCTION_TRACE("rs_set_start_dpf"); +#if 0 +/* Previous resource validations */ - /* - * The descriptor type field is set based upon whether a byte is needed - * to contain Priority data. - */ - if (ACPI_ACCEPTABLE_CONFIGURATION == - resource->data.start_dpf.compatibility_priority && - ACPI_ACCEPTABLE_CONFIGURATION == - resource->data.start_dpf.performance_robustness) { - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT, - sizeof(struct - aml_resource_start_dependent_noprio), - aml); - } else { - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT, - sizeof(struct - aml_resource_start_dependent), - aml); - - /* Set the Flags byte */ - - aml->start_dpf.flags = (u8) - (((resource->data.start_dpf. - performance_robustness & 0x03) << 2) | (resource->data. - start_dpf. - compatibility_priority - & 0x03)); - } - return_ACPI_STATUS(AE_OK); +if (aml->ext_address64.revision_iD != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) { + return_ACPI_STATUS(AE_SUPPORT); } -/******************************************************************************* - * - * FUNCTION: acpi_rs_get_end_dpf - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. - * - ******************************************************************************/ - -acpi_status -acpi_rs_get_end_dpf(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource) -{ - ACPI_FUNCTION_TRACE("rs_get_end_dpf"); - - /* Complete the resource header */ - - resource->type = ACPI_RESOURCE_TYPE_END_DEPENDENT; - resource->length = (u32) ACPI_RESOURCE_LENGTH; - return_ACPI_STATUS(AE_OK); +if (resource->data.start_dpf.performance_robustness >= 3) { + return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); } -/******************************************************************************* - * - * FUNCTION: acpi_rs_set_end_dpf - * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Aml - Where the AML descriptor is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. - * - ******************************************************************************/ - -acpi_status -acpi_rs_set_end_dpf(struct acpi_resource *resource, union aml_resource *aml) -{ - ACPI_FUNCTION_TRACE("rs_set_end_dpf"); - - /* Complete the AML descriptor header */ - - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_DEPENDENT, - sizeof(struct aml_resource_end_dependent), - aml); - return_ACPI_STATUS(AE_OK); +if (((aml->irq.flags & 0x09) == 0x00) || ((aml->irq.flags & 0x09) == 0x09)) { + /* + * Only [active_high, edge_sensitive] or [active_low, level_sensitive] + * polarity/trigger interrupts are allowed (ACPI spec, section + * "IRQ Format"), so 0x00 and 0x09 are illegal. + */ + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid interrupt polarity/trigger in resource list, %X\n", + aml->irq.flags)); + return_ACPI_STATUS(AE_BAD_DATA); } -/******************************************************************************* - * - * FUNCTION: acpi_rs_get_end_tag - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * aml_resource_length - Length of the resource from the AML header - * Resource - Where the internal resource is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding - * internal resource descriptor, simplifying bitflags and handling - * alignment and endian issues if necessary. - * - ******************************************************************************/ - -acpi_status -acpi_rs_get_end_tag(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource) -{ - ACPI_FUNCTION_TRACE("rs_get_end_tag"); - - /* Complete the resource header */ +resource->data.extended_irq.interrupt_count = temp8; +if (temp8 < 1) { + /* Must have at least one IRQ */ - resource->type = ACPI_RESOURCE_TYPE_END_TAG; - resource->length = ACPI_RESOURCE_LENGTH; - return_ACPI_STATUS(AE_OK); + return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); } -/******************************************************************************* - * - * FUNCTION: acpi_rs_set_end_tag - * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Aml - Where the AML descriptor is returned - * - * RETURN: Status - * - * DESCRIPTION: Convert an internal resource descriptor to the corresponding - * external AML resource descriptor. - * - ******************************************************************************/ - -acpi_status -acpi_rs_set_end_tag(struct acpi_resource *resource, union aml_resource *aml) -{ - ACPI_FUNCTION_TRACE("rs_set_end_tag"); - - /* - * Set the Checksum - zero means that the resource data is treated as if - * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) - */ - aml->end_tag.checksum = 0; - - /* Complete the AML descriptor header */ - - acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_TAG, - sizeof(struct aml_resource_end_tag), aml); - return_ACPI_STATUS(AE_OK); +if (resource->data.dma.transfer == 0x03) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Invalid DMA.Transfer preference (3)\n")); + return_ACPI_STATUS(AE_BAD_DATA); } +#endif diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c index 9d503de1a349..7613033f5dcf 100644 --- a/drivers/acpi/resources/rsutils.c +++ b/drivers/acpi/resources/rsutils.c @@ -48,6 +48,64 @@ #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME("rsutils") +/******************************************************************************* + * + * FUNCTION: acpi_rs_decode_bitmask + * + * PARAMETERS: Mask - Bitmask to decode + * List - Where the converted list is returned + * + * RETURN: Count of bits set (length of list) + * + * DESCRIPTION: Convert a bit mask into a list of values + * + ******************************************************************************/ +u8 acpi_rs_decode_bitmask(u16 mask, u8 * list) +{ + acpi_native_uint i; + u8 bit_count; + + /* Decode the mask bits */ + + for (i = 0, bit_count = 0; mask; i++) { + if (mask & 0x0001) { + list[bit_count] = (u8) i; + bit_count++; + } + + mask >>= 1; + } + + return (bit_count); +} + +/******************************************************************************* + * + * FUNCTION: acpi_rs_encode_bitmask + * + * PARAMETERS: List - List of values to encode + * Count - Length of list + * + * RETURN: Encoded bitmask + * + * DESCRIPTION: Convert a list of values to an encoded bitmask + * + ******************************************************************************/ + +u16 acpi_rs_encode_bitmask(u8 * list, u8 count) +{ + acpi_native_uint i; + u16 mask; + + /* Encode the list into a single bitmask */ + + for (i = 0, mask = 0; i < count; i++) { + mask |= (0x0001 << list[i]); + } + + return (mask); +} + /******************************************************************************* * * FUNCTION: acpi_rs_move_data @@ -64,6 +122,7 @@ ACPI_MODULE_NAME("rsutils") * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) * ******************************************************************************/ + void acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) { @@ -73,22 +132,30 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) for (i = 0; i < item_count; i++) { switch (move_type) { - case ACPI_MOVE_TYPE_16_TO_32: - ACPI_MOVE_16_TO_32(&((u32 *) destination)[i], - &((u16 *) source)[i]); - break; + /* + * For the 8-bit case, we can perform the move all at once + * since there are no alignment or endian issues + */ + case ACPI_RSC_MOVE8: + ACPI_MEMCPY(destination, source, item_count); + return; - case ACPI_MOVE_TYPE_32_TO_16: - ACPI_MOVE_32_TO_16(&((u16 *) destination)[i], - &((u32 *) source)[i]); + /* + * 16-, 32-, and 64-bit cases must use the move macros that perform + * endian conversion and/or accomodate hardware that cannot perform + * misaligned memory transfers + */ + case ACPI_RSC_MOVE16: + ACPI_MOVE_16_TO_16(&((u16 *) destination)[i], + &((u16 *) source)[i]); break; - case ACPI_MOVE_TYPE_32_TO_32: + case ACPI_RSC_MOVE32: ACPI_MOVE_32_TO_32(&((u32 *) destination)[i], &((u32 *) source)[i]); break; - case ACPI_MOVE_TYPE_64_TO_64: + case ACPI_RSC_MOVE64: ACPI_MOVE_64_TO_64(&((u64 *) destination)[i], &((u64 *) source)[i]); break; @@ -148,80 +215,57 @@ struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type) /******************************************************************************* * - * FUNCTION: acpi_rs_get_resource_length + * FUNCTION: acpi_rs_set_resource_length * - * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * PARAMETERS: total_length - Length of the AML descriptor, including + * the header and length fields. + * Aml - Pointer to the raw AML descriptor * - * RETURN: Byte Length + * RETURN: None * - * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By - * definition, this does not include the size of the descriptor - * header or the length field itself. + * DESCRIPTION: Set the resource_length field of an AML + * resource descriptor, both Large and Small descriptors are + * supported automatically. Note: Descriptor Type field must + * be valid. * ******************************************************************************/ -u16 acpi_rs_get_resource_length(union aml_resource * aml) +void +acpi_rs_set_resource_length(acpi_rsdesc_size total_length, + union aml_resource *aml) { - u16 resource_length; + acpi_rs_length resource_length; ACPI_FUNCTION_ENTRY(); /* Determine if this is a small or large resource */ - if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { + if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { /* Large Resource type -- bytes 1-2 contain the 16-bit length */ - ACPI_MOVE_16_TO_16(&resource_length, - &aml->large_header.resource_length); + resource_length = (acpi_rs_length) + (total_length - sizeof(struct aml_resource_large_header)); + + /* Insert length into the Large descriptor length field */ + ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, + &resource_length); } else { /* Small Resource type -- bits 2:0 of byte 0 contain the length */ - resource_length = (u16) (aml->small_header.descriptor_type & - ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); - } - - return (resource_length); -} + resource_length = (acpi_rs_length) + (total_length - sizeof(struct aml_resource_small_header)); -/******************************************************************************* - * - * FUNCTION: acpi_rs_get_descriptor_length - * - * PARAMETERS: Aml - Pointer to the raw AML resource descriptor - * - * RETURN: Byte length - * - * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the - * length of the descriptor header and the length field itself. - * Used to walk descriptor lists. - * - ******************************************************************************/ - -u32 acpi_rs_get_descriptor_length(union aml_resource * aml) -{ - u32 descriptor_length; - - ACPI_FUNCTION_ENTRY(); - - /* Determine if this is a small or large resource */ - - if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { - /* Large Resource type -- bytes 1-2 contain the 16-bit length */ + /* Insert length into the descriptor type byte */ - ACPI_MOVE_16_TO_32(&descriptor_length, - &aml->large_header.resource_length); - descriptor_length += sizeof(struct aml_resource_large_header); + aml->small_header.descriptor_type = (u8) - } else { - /* Small Resource type -- bits 2:0 of byte 0 contain the length */ + /* Clear any existing length, preserving descriptor type bits */ + ((aml->small_header. + descriptor_type & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK) - descriptor_length = (u32) (aml->small_header.descriptor_type & - ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); - descriptor_length += sizeof(struct aml_resource_small_header); + | resource_length); } - - return (descriptor_length); } /******************************************************************************* @@ -243,71 +287,18 @@ u32 acpi_rs_get_descriptor_length(union aml_resource * aml) void acpi_rs_set_resource_header(u8 descriptor_type, - acpi_size total_length, union aml_resource *aml) + acpi_rsdesc_size total_length, + union aml_resource *aml) { - u16 resource_length; - ACPI_FUNCTION_ENTRY(); - /* Set the descriptor type */ + /* Set the Descriptor Type */ aml->small_header.descriptor_type = descriptor_type; - /* Determine if this is a small or large resource */ - - if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { - /* Large Resource type -- bytes 1-2 contain the 16-bit length */ - - resource_length = - (u16) (total_length - - sizeof(struct aml_resource_large_header)); - - /* Insert length into the Large descriptor length field */ - - ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, - &resource_length); - } else { - /* Small Resource type -- bits 2:0 of byte 0 contain the length */ - - resource_length = - (u16) (total_length - - sizeof(struct aml_resource_small_header)); - - /* Insert length into the descriptor type byte */ - - aml->small_header.descriptor_type |= (u8) resource_length; - } -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_get_resource_type - * - * PARAMETERS: resource_type - Byte 0 of a resource descriptor - * - * RETURN: The Resource Type with no extraneous bits (except the - * Large/Small descriptor bit -- this is left alone) - * - * DESCRIPTION: Extract the Resource Type/Name from the first byte of - * a resource descriptor. - * - ******************************************************************************/ - -u8 acpi_rs_get_resource_type(u8 resource_type) -{ - ACPI_FUNCTION_ENTRY(); + /* Set the Resource Length */ - /* Determine if this is a small or large resource */ - - if (resource_type & ACPI_RESOURCE_NAME_LARGE) { - /* Large Resource Type -- bits 6:0 contain the name */ - - return (resource_type); - } else { - /* Small Resource Type -- bits 6:3 contain the name */ - - return ((u8) (resource_type & ACPI_RESOURCE_NAME_SMALL_MASK)); - } + acpi_rs_set_resource_length(total_length, aml); } /******************************************************************************* @@ -360,13 +351,13 @@ static u16 acpi_rs_strcpy(char *destination, char *source) * ******************************************************************************/ -u16 -acpi_rs_get_resource_source(u16 resource_length, - acpi_size minimum_length, +acpi_rs_length +acpi_rs_get_resource_source(acpi_rs_length resource_length, + acpi_rs_length minimum_length, struct acpi_resource_source * resource_source, union aml_resource * aml, char *string_ptr) { - acpi_size total_length; + acpi_rsdesc_size total_length; u8 *aml_resource_source; ACPI_FUNCTION_ENTRY(); @@ -382,7 +373,7 @@ acpi_rs_get_resource_source(u16 resource_length, * Note: Some resource descriptors will have an additional null, so * we add 1 to the minimum length. */ - if (total_length > (minimum_length + 1)) { + if (total_length > (acpi_rsdesc_size) (minimum_length + 1)) { /* Get the resource_source_index */ resource_source->index = aml_resource_source[0]; @@ -398,20 +389,26 @@ acpi_rs_get_resource_source(u16 resource_length, sizeof(struct acpi_resource_source); } + /* + * In order for the struct_size to fall on a 32-bit boundary, calculate + * the length of the string (+1 for the NULL terminator) and expand the + * struct_size to the next 32-bit boundary. + * + * Zero the entire area of the buffer. + */ + total_length = + ACPI_ROUND_UP_to_32_bITS(ACPI_STRLEN + ((char *)&aml_resource_source[1]) + + 1); + ACPI_MEMSET(resource_source->string_ptr, 0, total_length); + /* Copy the resource_source string to the destination */ resource_source->string_length = acpi_rs_strcpy(resource_source->string_ptr, (char *)&aml_resource_source[1]); - /* - * In order for the struct_size to fall on a 32-bit boundary, - * calculate the length of the string and expand the - * struct_size to the next 32-bit boundary. - */ - return ((u16) - ACPI_ROUND_UP_to_32_bITS(resource_source-> - string_length)); + return ((acpi_rs_length) total_length); } else { /* resource_source is not present */ @@ -434,18 +431,18 @@ acpi_rs_get_resource_source(u16 resource_length, * * RETURN: Total length of the AML descriptor * - * DESCRIPTION: Convert an optoinal resource_source from internal format to a + * DESCRIPTION: Convert an optional resource_source from internal format to a * raw AML resource descriptor * ******************************************************************************/ -acpi_size +acpi_rsdesc_size acpi_rs_set_resource_source(union aml_resource * aml, - acpi_size minimum_length, + acpi_rs_length minimum_length, struct acpi_resource_source * resource_source) { u8 *aml_resource_source; - acpi_size descriptor_length; + acpi_rsdesc_size descriptor_length; ACPI_FUNCTION_ENTRY(); @@ -472,7 +469,7 @@ acpi_rs_set_resource_source(union aml_resource * aml, * final descriptor length */ descriptor_length += - ((acpi_size) resource_source->string_length + 1); + ((acpi_rsdesc_size) resource_source->string_length + 1); } /* Return the new total length of the AML descriptor */ diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c index 9d179beb17ae..09d250ab9872 100644 --- a/drivers/acpi/resources/rsxface.c +++ b/drivers/acpi/resources/rsxface.c @@ -57,7 +57,7 @@ ACPI_MODULE_NAME("rsxface") ACPI_COPY_FIELD(out, in, decode); \ ACPI_COPY_FIELD(out, in, min_address_fixed); \ ACPI_COPY_FIELD(out, in, max_address_fixed); \ - ACPI_COPY_FIELD(out, in, attribute); \ + ACPI_COPY_FIELD(out, in, info); \ ACPI_COPY_FIELD(out, in, granularity); \ ACPI_COPY_FIELD(out, in, minimum); \ ACPI_COPY_FIELD(out, in, maximum); \ diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c index 4b2fbb592f49..e6dfe688b76b 100644 --- a/drivers/acpi/tables/tbutils.c +++ b/drivers/acpi/tables/tbutils.c @@ -94,9 +94,8 @@ acpi_status acpi_tb_is_table_installed(struct acpi_table_desc *new_table_desc) new_table_desc->pointer->length) && (!ACPI_MEMCMP - ((const char *)table_desc->pointer, - (const char *)new_table_desc->pointer, - (acpi_size) new_table_desc->pointer->length))) { + (table_desc->pointer, new_table_desc->pointer, + new_table_desc->pointer->length))) { /* Match: this table is already installed */ ACPI_DEBUG_PRINT((ACPI_DB_TABLES, diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c index dc7f24b3a1c0..e04b6119a4d7 100644 --- a/drivers/acpi/utilities/utalloc.c +++ b/drivers/acpi/utilities/utalloc.c @@ -866,7 +866,7 @@ void acpi_ut_dump_allocations(u32 component, char *module) if (!num_outstanding) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "No outstanding allocations.\n")); + "No outstanding allocations\n")); } else { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "%d(%X) Outstanding allocations\n", diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index 7f72839841ca..413e1dd8ae36 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c @@ -217,23 +217,23 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = { * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to * perform a Notify() operation on it. */ -const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = - { {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, -{"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, -{"_SB_", ACPI_TYPE_DEVICE, NULL}, -{"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, -{"_TZ_", ACPI_TYPE_THERMAL, NULL}, -{"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL}, -{"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, -{"_GL_", ACPI_TYPE_MUTEX, (char *)1}, +const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = { + {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, + {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, + {"_SB_", ACPI_TYPE_DEVICE, NULL}, + {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, + {"_TZ_", ACPI_TYPE_THERMAL, NULL}, + {"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL}, + {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, + {"_GL_", ACPI_TYPE_MUTEX, (char *)1}, #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) -{"_OSI", ACPI_TYPE_METHOD, (char *)1}, + {"_OSI", ACPI_TYPE_METHOD, (char *)1}, #endif /* Table terminator */ -{NULL, ACPI_TYPE_ANY, NULL} + {NULL, ACPI_TYPE_ANY, NULL} }; /* @@ -503,11 +503,13 @@ char *acpi_ut_get_region_name(u8 space_id) /* Event type decoding */ static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = { +/*! [Begin] no source code translation (keep these strings as-is) */ "PM_Timer", - "global_lock", - "power_button", - "sleep_button", - "real_time_clock", + "GlobalLock", + "PowerButton", + "SleepButton", + "RealTimeClock", +/*! [End] no source code translation !*/ }; char *acpi_ut_get_event_name(u32 event_id) @@ -545,12 +547,13 @@ static const char acpi_gbl_bad_type[] = "UNDEFINED"; /* Printable names of the ACPI object types */ static const char *acpi_gbl_ns_type_names[] = { +/*! [Begin] no source code translation (keep these strings as-is) */ /* 00 */ "Untyped", /* 01 */ "Integer", /* 02 */ "String", /* 03 */ "Buffer", /* 04 */ "Package", - /* 05 */ "field_unit", + /* 05 */ "FieldUnit", /* 06 */ "Device", /* 07 */ "Event", /* 08 */ "Method", @@ -559,23 +562,24 @@ static const char *acpi_gbl_ns_type_names[] = { /* 11 */ "Power", /* 12 */ "Processor", /* 13 */ "Thermal", - /* 14 */ "buffer_field", - /* 15 */ "ddb_handle", - /* 16 */ "debug_object", - /* 17 */ "region_field", - /* 18 */ "bank_field", - /* 19 */ "index_field", + /* 14 */ "BufferField", + /* 15 */ "DdbHandle", + /* 16 */ "DebugObject", + /* 17 */ "RegionField", + /* 18 */ "BankField", + /* 19 */ "IndexField", /* 20 */ "Reference", /* 21 */ "Alias", - /* 22 */ "method_alias", + /* 22 */ "MethodAlias", /* 23 */ "Notify", - /* 24 */ "addr_handler", - /* 25 */ "resource_desc", - /* 26 */ "resource_fld", + /* 24 */ "AddrHandler", + /* 25 */ "ResourceDesc", + /* 26 */ "ResourceFld", /* 27 */ "Scope", /* 28 */ "Extra", /* 29 */ "Data", /* 30 */ "Invalid" +/*! [End] no source code translation !*/ }; char *acpi_ut_get_type_name(acpi_object_type type) @@ -658,15 +662,16 @@ char *acpi_ut_get_node_name(void *object) /* Printable names of object descriptor types */ static const char *acpi_gbl_desc_type_names[] = { +/*! [Begin] no source code translation (keep these ASL Keywords as-is) */ /* 00 */ "Invalid", /* 01 */ "Cached", /* 02 */ "State-Generic", /* 03 */ "State-Update", /* 04 */ "State-Package", /* 05 */ "State-Control", - /* 06 */ "State-root_parse_scope", - /* 07 */ "State-parse_scope", - /* 08 */ "State-walk_scope", + /* 06 */ "State-RootParseScope", + /* 07 */ "State-ParseScope", + /* 08 */ "State-WalkScope", /* 09 */ "State-Result", /* 10 */ "State-Notify", /* 11 */ "State-Thread", @@ -674,6 +679,7 @@ static const char *acpi_gbl_desc_type_names[] = { /* 13 */ "Parser", /* 14 */ "Operand", /* 15 */ "Node" +/*! [End] no source code translation !*/ }; char *acpi_ut_get_descriptor_name(void *object) diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index b57afa7421e8..e9058d4da122 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -43,6 +43,7 @@ #include #include +#include #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME("utmisc") @@ -788,6 +789,113 @@ u8 acpi_ut_generate_checksum(u8 * buffer, u32 length) return ((u8) (0 - sum)); } +/******************************************************************************* + * + * FUNCTION: acpi_ut_get_resource_type + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: The Resource Type with no extraneous bits (except the + * Large/Small descriptor bit -- this is left alone) + * + * DESCRIPTION: Extract the Resource Type/Name from the first byte of + * a resource descriptor. + * + ******************************************************************************/ + +u8 acpi_ut_get_resource_type(void *aml) +{ + ACPI_FUNCTION_ENTRY(); + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Determine if this is a small or large resource + */ + if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { + /* Large Resource Type -- bits 6:0 contain the name */ + + return (*((u8 *) aml)); + } else { + /* Small Resource Type -- bits 6:3 contain the name */ + + return ((u8) (*((u8 *) aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); + } +} + +/******************************************************************************* + * + * FUNCTION: acpi_ut_get_resource_length + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Byte Length + * + * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By + * definition, this does not include the size of the descriptor + * header or the length field itself. + * + ******************************************************************************/ + +u16 acpi_ut_get_resource_length(void *aml) +{ + u16 resource_length; + + ACPI_FUNCTION_ENTRY(); + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Determine if this is a small or large resource + */ + if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { + /* Large Resource type -- bytes 1-2 contain the 16-bit length */ + + ACPI_MOVE_16_TO_16(&resource_length, &((u8 *) aml)[1]); + + } else { + /* Small Resource type -- bits 2:0 of byte 0 contain the length */ + + resource_length = (u16) (*((u8 *) aml) & + ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); + } + + return (resource_length); +} + +/******************************************************************************* + * + * FUNCTION: acpi_ut_get_descriptor_length + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Byte length + * + * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the + * length of the descriptor header and the length field itself. + * Used to walk descriptor lists. + * + ******************************************************************************/ + +u32 acpi_ut_get_descriptor_length(void *aml) +{ + u32 descriptor_length; + + ACPI_FUNCTION_ENTRY(); + + /* First get the Resource Length (Does not include header length) */ + + descriptor_length = acpi_ut_get_resource_length(aml); + + /* Determine if this is a small or large resource */ + + if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { + descriptor_length += sizeof(struct aml_resource_large_header); + } else { + descriptor_length += sizeof(struct aml_resource_small_header); + } + + return (descriptor_length); +} + /******************************************************************************* * * FUNCTION: acpi_ut_get_resource_end_tag @@ -796,42 +904,34 @@ u8 acpi_ut_generate_checksum(u8 * buffer, u32 length) * * RETURN: Pointer to the end tag * - * DESCRIPTION: Find the END_TAG resource descriptor in a resource template + * DESCRIPTION: Find the END_TAG resource descriptor in an AML resource template * ******************************************************************************/ u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc) { - u8 buffer_byte; - u8 *buffer; - u8 *end_buffer; - - buffer = obj_desc->buffer.pointer; - end_buffer = buffer + obj_desc->buffer.length; + u8 *aml; + u8 *end_aml; - while (buffer < end_buffer) { - buffer_byte = *buffer; - if (buffer_byte & ACPI_RESOURCE_NAME_LARGE) { - /* Large Descriptor - Length is next 2 bytes */ + aml = obj_desc->buffer.pointer; + end_aml = aml + obj_desc->buffer.length; - buffer += ((*(buffer + 1) | (*(buffer + 2) << 8)) + 3); - } else { - /* Small Descriptor. End Tag will be found here */ + /* Walk the resource template, one descriptor per loop */ - if ((buffer_byte & ACPI_RESOURCE_NAME_SMALL_MASK) == - ACPI_RESOURCE_NAME_END_TAG) { - /* Found the end tag descriptor, all done. */ + while (aml < end_aml) { + if (acpi_ut_get_resource_type(aml) == + ACPI_RESOURCE_NAME_END_TAG) { + /* Found the end_tag descriptor, all done */ - return (buffer); - } + return (aml); + } - /* Length is in the header */ + /* Point to the next resource descriptor */ - buffer += ((buffer_byte & 0x07) + 1); - } + aml += acpi_ut_get_resource_length(aml); } - /* End tag not found */ + /* End tag was not found */ return (NULL); } diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index f4adebde6155..b8b46ab54f4e 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -401,7 +401,7 @@ pnpacpi_parse_mem24_option(struct pnp_option *option, mem->align = p->alignment; mem->size = p->address_length; - mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? + mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? IORESOURCE_MEM_WRITEABLE : 0; pnp_register_mem_resource(option,mem); @@ -424,7 +424,7 @@ pnpacpi_parse_mem32_option(struct pnp_option *option, mem->align = p->alignment; mem->size = p->address_length; - mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? + mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? IORESOURCE_MEM_WRITEABLE : 0; pnp_register_mem_resource(option,mem); @@ -446,7 +446,7 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, mem->size = p->address_length; mem->align = 0; - mem->flags = (ACPI_READ_WRITE_MEMORY == p->read_write_attribute) ? + mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? IORESOURCE_MEM_WRITEABLE : 0; pnp_register_mem_resource(option,mem); @@ -734,7 +734,7 @@ static void pnpacpi_encode_mem24(struct acpi_resource *resource, resource->type = ACPI_RESOURCE_TYPE_MEMORY24; resource->length = sizeof(struct acpi_resource); /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ - resource->data.memory24.read_write_attribute = + resource->data.memory24.write_protect = (p->flags & IORESOURCE_MEM_WRITEABLE) ? ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; resource->data.memory24.minimum = p->start; @@ -748,7 +748,7 @@ static void pnpacpi_encode_mem32(struct acpi_resource *resource, { resource->type = ACPI_RESOURCE_TYPE_MEMORY32; resource->length = sizeof(struct acpi_resource); - resource->data.memory32.read_write_attribute = + resource->data.memory32.write_protect = (p->flags & IORESOURCE_MEM_WRITEABLE) ? ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; resource->data.memory32.minimum = p->start; @@ -762,7 +762,7 @@ static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, { resource->type = ACPI_RESOURCE_TYPE_FIXED_MEMORY32; resource->length = sizeof(struct acpi_resource); - resource->data.fixed_memory32.read_write_attribute = + resource->data.fixed_memory32.write_protect = (p->flags & IORESOURCE_MEM_WRITEABLE) ? ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; resource->data.fixed_memory32.address = p->start; diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index cb59b018c84c..7676afec09a2 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -63,7 +63,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20050930 +#define ACPI_CA_VERSION 0x20051021 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, diff --git a/include/acpi/acdisasm.h b/include/acpi/acdisasm.h index b2921b869bb4..99250ee1b9d1 100644 --- a/include/acpi/acdisasm.h +++ b/include/acpi/acdisasm.h @@ -60,6 +60,7 @@ extern struct acpi_external_list *acpi_gbl_external_list; extern const char *acpi_gbl_io_decode[2]; extern const char *acpi_gbl_word_decode[4]; extern const char *acpi_gbl_consume_decode[2]; +extern const char *acpi_gbl_config_decode[4]; extern const char *acpi_gbl_min_decode[2]; extern const char *acpi_gbl_max_decode[2]; extern const char *acpi_gbl_DECdecode[2]; @@ -171,11 +172,19 @@ u8 acpi_dm_is_string_buffer(union acpi_parse_object *op); /* * dmresrc */ +void acpi_dm_dump_integer8(u8 value, char *name); + +void acpi_dm_dump_integer16(u16 value, char *name); + +void acpi_dm_dump_integer32(u32 value, char *name); + +void acpi_dm_dump_integer64(u64 value, char *name); + void -acpi_dm_resource_descriptor(struct acpi_op_walk_info *info, - u8 * byte_data, u32 byte_count); +acpi_dm_resource_template(struct acpi_op_walk_info *info, + u8 * byte_data, u32 byte_count); -u8 acpi_dm_is_resource_descriptor(union acpi_parse_object *op); +u8 acpi_dm_is_resource_template(union acpi_parse_object *op); void acpi_dm_indent(u32 level); @@ -223,6 +232,8 @@ void acpi_dm_vendor_large_descriptor(union aml_resource *resource, u32 length, u32 level); +void acpi_dm_vendor_common(char *name, u8 * byte_data, u32 length, u32 level); + /* * dmresrcs */ diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h index 258cfe5e2aac..e42222c3d34c 100644 --- a/include/acpi/acmacros.h +++ b/include/acpi/acmacros.h @@ -202,7 +202,7 @@ #define ACPI_BUFFER_INDEX(buf_len,buf_offset,byte_gran) (buf_offset) -#ifdef ACPI_MISALIGNED_TRANSFERS +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED /* The hardware supports unaligned transfers, just do the little-endian move */ @@ -563,11 +563,11 @@ return (_s); }) #define return_UINT8(s) ACPI_DO_WHILE0 ({ \ register u8 _s = (u8) (s); \ - acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \ + acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) _s); \ return (_s); }) #define return_UINT32(s) ACPI_DO_WHILE0 ({ \ register u32 _s = (u32) (s); \ - acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \ + acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) _s); \ return (_s); }) #else /* Use original less-safe macros */ diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h index 98e0b8cd14ed..58473f60755f 100644 --- a/include/acpi/acpiosxf.h +++ b/include/acpi/acpiosxf.h @@ -108,9 +108,9 @@ acpi_status acpi_os_create_lock(acpi_handle * out_handle); void acpi_os_delete_lock(acpi_handle handle); -unsigned long acpi_os_acquire_lock(acpi_handle handle); +acpi_native_uint acpi_os_acquire_lock(acpi_handle handle); -void acpi_os_release_lock(acpi_handle handle, unsigned long flags); +void acpi_os_release_lock(acpi_handle handle, acpi_native_uint flags); /* * Memory allocation and mapping diff --git a/include/acpi/acresrc.h b/include/acpi/acresrc.h index b66994e9e4ee..25cff0d5ba58 100644 --- a/include/acpi/acresrc.h +++ b/include/acpi/acresrc.h @@ -48,49 +48,133 @@ #include "amlresrc.h" +/* + * If possible, pack the following structures to byte alignment, since we + * don't care about performance for debug output + */ +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#pragma pack(1) +#endif + +/* + * Individual entry for the resource conversion tables + */ +typedef const struct acpi_rsconvert_info { + u8 opcode; + u8 resource_offset; + u8 aml_offset; + u8 value; + +} acpi_rsconvert_info; + +/* Resource conversion opcodes */ + +#define ACPI_RSC_INITGET 0 +#define ACPI_RSC_INITSET 1 +#define ACPI_RSC_FLAGINIT 2 +#define ACPI_RSC_1BITFLAG 3 +#define ACPI_RSC_2BITFLAG 4 +#define ACPI_RSC_COUNT 5 +#define ACPI_RSC_COUNT16 6 +#define ACPI_RSC_LENGTH 7 +#define ACPI_RSC_MOVE8 8 +#define ACPI_RSC_MOVE16 9 +#define ACPI_RSC_MOVE32 10 +#define ACPI_RSC_MOVE64 11 +#define ACPI_RSC_SET8 12 +#define ACPI_RSC_DATA8 13 +#define ACPI_RSC_ADDRESS 14 +#define ACPI_RSC_SOURCE 15 +#define ACPI_RSC_SOURCEX 16 +#define ACPI_RSC_BITMASK 17 +#define ACPI_RSC_BITMASK16 18 +#define ACPI_RSC_EXIT_NE 19 +#define ACPI_RSC_EXIT_LE 20 + +/* Resource Conversion sub-opcodes */ + +#define ACPI_RSC_COMPARE_AML_LENGTH 0 +#define ACPI_RSC_COMPARE_VALUE 1 + +#define ACPI_RSC_TABLE_SIZE(d) (sizeof (d) / sizeof (struct acpi_rsconvert_info)) + +#define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f) +#define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f) + /* * Resource dispatch and info tables */ -struct acpi_resource_info { +typedef const struct acpi_resource_info { u8 length_type; u8 minimum_aml_resource_length; u8 minimum_internal_struct_length; -}; + +} acpi_resource_info; /* Types for length_type above */ -#define ACPI_FIXED_LENGTH 0 -#define ACPI_VARIABLE_LENGTH 1 -#define ACPI_SMALL_VARIABLE_LENGTH 2 +#define ACPI_FIXED_LENGTH 0 +#define ACPI_VARIABLE_LENGTH 1 +#define ACPI_SMALL_VARIABLE_LENGTH 2 + +typedef const struct acpi_rsdump_info { + u8 opcode; + u8 offset; + char *name; + const void *pointer; -/* Handlers */ +} acpi_rsdump_info; -typedef acpi_status(*ACPI_SET_RESOURCE_HANDLER) (struct acpi_resource * - resource, - union aml_resource * aml); +/* Values for the Opcode field above */ -typedef acpi_status(*ACPI_GET_RESOURCE_HANDLER) (union aml_resource * aml, - u16 aml_resource_length, - struct acpi_resource * - resource); +#define ACPI_RSD_TITLE 0 +#define ACPI_RSD_LITERAL 1 +#define ACPI_RSD_STRING 2 +#define ACPI_RSD_UINT8 3 +#define ACPI_RSD_UINT16 4 +#define ACPI_RSD_UINT32 5 +#define ACPI_RSD_UINT64 6 +#define ACPI_RSD_1BITFLAG 7 +#define ACPI_RSD_2BITFLAG 8 +#define ACPI_RSD_SHORTLIST 9 +#define ACPI_RSD_LONGLIST 10 +#define ACPI_RSD_DWORDLIST 11 +#define ACPI_RSD_ADDRESS 12 +#define ACPI_RSD_SOURCE 13 -typedef void (*ACPI_DUMP_RESOURCE_HANDLER) (union acpi_resource_data * data); +/* restore default alignment */ -/* Tables indexed by internal resource type */ +#pragma pack() -extern u8 acpi_gbl_aml_resource_sizes[]; -extern ACPI_SET_RESOURCE_HANDLER acpi_gbl_set_resource_dispatch[]; -extern ACPI_DUMP_RESOURCE_HANDLER acpi_gbl_dump_resource_dispatch[]; +/* Resource tables indexed by internal resource type */ -/* Tables indexed by raw AML resource descriptor type */ +extern const u8 acpi_gbl_aml_resource_sizes[]; +extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[]; + +/* Resource tables indexed by raw AML resource descriptor type */ extern struct acpi_resource_info acpi_gbl_sm_resource_info[]; extern struct acpi_resource_info acpi_gbl_lg_resource_info[]; -extern ACPI_GET_RESOURCE_HANDLER acpi_gbl_sm_get_resource_dispatch[]; -extern ACPI_GET_RESOURCE_HANDLER acpi_gbl_lg_get_resource_dispatch[]; +extern struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[]; +extern struct acpi_rsconvert_info *acpi_gbl_lg_get_resource_dispatch[]; + +/* + * rscreate + */ +acpi_status +acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, + struct acpi_buffer *output_buffer); + +acpi_status +acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, + struct acpi_buffer *output_buffer); + +acpi_status +acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, + struct acpi_buffer *output_buffer); /* - * Function prototypes called from Acpi* APIs + * rsutils */ acpi_status acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer); @@ -110,27 +194,6 @@ acpi_rs_get_method_data(acpi_handle handle, acpi_status acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer); -acpi_status -acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, - struct acpi_buffer *output_buffer); - -acpi_status -acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, - struct acpi_buffer *output_buffer); - -acpi_status -acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, - struct acpi_buffer *output_buffer); - -/* - * rsdump - */ -#ifdef ACPI_FUTURE_USAGE -void acpi_rs_dump_resource_list(struct acpi_resource *resource); - -void acpi_rs_dump_irq_list(u8 * route_table); -#endif /* ACPI_FUTURE_USAGE */ - /* * rscalc */ @@ -154,145 +217,29 @@ acpi_status acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, acpi_size aml_size_needed, u8 * output_buffer); -/* - * rsio - */ -acpi_status -acpi_rs_get_io(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource); - -acpi_status -acpi_rs_set_io(struct acpi_resource *resource, union aml_resource *aml); - -acpi_status -acpi_rs_get_fixed_io(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource); - -acpi_status -acpi_rs_set_fixed_io(struct acpi_resource *resource, union aml_resource *aml); - -acpi_status -acpi_rs_get_dma(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource); - -acpi_status -acpi_rs_set_dma(struct acpi_resource *resource, union aml_resource *aml); - -/* - * rsirq - */ -acpi_status -acpi_rs_get_irq(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource); - -acpi_status -acpi_rs_set_irq(struct acpi_resource *resource, union aml_resource *aml); - -acpi_status -acpi_rs_get_ext_irq(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource); - -acpi_status -acpi_rs_set_ext_irq(struct acpi_resource *resource, union aml_resource *aml); - /* * rsaddr */ -acpi_status -acpi_rs_get_address16(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource); - -acpi_status -acpi_rs_set_address16(struct acpi_resource *resource, union aml_resource *aml); - -acpi_status -acpi_rs_get_address32(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource); - -acpi_status -acpi_rs_set_address32(struct acpi_resource *resource, union aml_resource *aml); - -acpi_status -acpi_rs_get_address64(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource); - -acpi_status -acpi_rs_set_address64(struct acpi_resource *resource, union aml_resource *aml); - -acpi_status -acpi_rs_get_ext_address64(union aml_resource *aml, - u16 aml_resource_length, - struct acpi_resource *resource); - -acpi_status -acpi_rs_set_ext_address64(struct acpi_resource *resource, - union aml_resource *aml); - -/* - * rsmemory - */ -acpi_status -acpi_rs_get_memory24(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource); - -acpi_status -acpi_rs_set_memory24(struct acpi_resource *resource, union aml_resource *aml); - -acpi_status -acpi_rs_get_memory32(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource); - -acpi_status -acpi_rs_set_memory32(struct acpi_resource *resource, union aml_resource *aml); - -acpi_status -acpi_rs_get_fixed_memory32(union aml_resource *aml, - u16 aml_resource_length, +void +acpi_rs_set_address_common(union aml_resource *aml, struct acpi_resource *resource); -acpi_status -acpi_rs_set_fixed_memory32(struct acpi_resource *resource, +u8 +acpi_rs_get_address_common(struct acpi_resource *resource, union aml_resource *aml); /* * rsmisc */ acpi_status -acpi_rs_get_generic_reg(union aml_resource *aml, - u16 aml_resource_length, - struct acpi_resource *resource); - -acpi_status -acpi_rs_set_generic_reg(struct acpi_resource *resource, - union aml_resource *aml); - -acpi_status -acpi_rs_get_vendor(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource); - -acpi_status -acpi_rs_set_vendor(struct acpi_resource *resource, union aml_resource *aml); - -acpi_status -acpi_rs_get_start_dpf(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource); - -acpi_status -acpi_rs_set_start_dpf(struct acpi_resource *resource, union aml_resource *aml); - -acpi_status -acpi_rs_get_end_dpf(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource); - -acpi_status -acpi_rs_set_end_dpf(struct acpi_resource *resource, union aml_resource *aml); +acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, + union aml_resource *aml, + struct acpi_rsconvert_info *info); acpi_status -acpi_rs_get_end_tag(union aml_resource *aml, - u16 aml_resource_length, struct acpi_resource *resource); - -acpi_status -acpi_rs_set_end_tag(struct acpi_resource *resource, union aml_resource *aml); +acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, + union aml_resource *aml, + struct acpi_rsconvert_info *info); /* * rsutils @@ -301,74 +248,94 @@ void acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type); -/* Types used in move_type above */ +u8 acpi_rs_decode_bitmask(u16 mask, u8 * list); -#define ACPI_MOVE_TYPE_16_TO_32 0 -#define ACPI_MOVE_TYPE_32_TO_16 1 -#define ACPI_MOVE_TYPE_32_TO_32 2 -#define ACPI_MOVE_TYPE_64_TO_64 3 +u16 acpi_rs_encode_bitmask(u8 * list, u8 count); -u16 -acpi_rs_get_resource_source(u16 resource_length, - acpi_size minimum_length, +acpi_rs_length +acpi_rs_get_resource_source(acpi_rs_length resource_length, + acpi_rs_length minimum_length, struct acpi_resource_source *resource_source, union aml_resource *aml, char *string_ptr); -acpi_size +acpi_rsdesc_size acpi_rs_set_resource_source(union aml_resource *aml, - acpi_size minimum_length, + acpi_rs_length minimum_length, struct acpi_resource_source *resource_source); -u8 acpi_rs_get_resource_type(u8 resource_start_byte); - -u32 acpi_rs_get_descriptor_length(union aml_resource *aml); - -u16 acpi_rs_get_resource_length(union aml_resource *aml); - void acpi_rs_set_resource_header(u8 descriptor_type, - acpi_size total_length, union aml_resource *aml); + acpi_rsdesc_size total_length, + union aml_resource *aml); + +void +acpi_rs_set_resource_length(acpi_rsdesc_size total_length, + union aml_resource *aml); struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type); -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) /* * rsdump */ -void acpi_rs_dump_irq(union acpi_resource_data *resource); - -void acpi_rs_dump_address16(union acpi_resource_data *resource); - -void acpi_rs_dump_address32(union acpi_resource_data *resource); - -void acpi_rs_dump_address64(union acpi_resource_data *resource); - -void acpi_rs_dump_ext_address64(union acpi_resource_data *resource); - -void acpi_rs_dump_dma(union acpi_resource_data *resource); - -void acpi_rs_dump_io(union acpi_resource_data *resource); - -void acpi_rs_dump_ext_irq(union acpi_resource_data *resource); - -void acpi_rs_dump_fixed_io(union acpi_resource_data *resource); - -void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource); - -void acpi_rs_dump_memory24(union acpi_resource_data *resource); - -void acpi_rs_dump_memory32(union acpi_resource_data *resource); - -void acpi_rs_dump_start_dpf(union acpi_resource_data *resource); - -void acpi_rs_dump_vendor(union acpi_resource_data *resource); +void acpi_rs_dump_resource_list(struct acpi_resource *resource); -void acpi_rs_dump_generic_reg(union acpi_resource_data *resource); +void acpi_rs_dump_irq_list(u8 * route_table); -void acpi_rs_dump_end_dpf(union acpi_resource_data *resource); +/* + * Resource conversion tables + */ +extern struct acpi_rsconvert_info acpi_rs_convert_dma[]; +extern struct acpi_rsconvert_info acpi_rs_convert_end_dpf[]; +extern struct acpi_rsconvert_info acpi_rs_convert_io[]; +extern struct acpi_rsconvert_info acpi_rs_convert_fixed_io[]; +extern struct acpi_rsconvert_info acpi_rs_convert_end_tag[]; +extern struct acpi_rsconvert_info acpi_rs_convert_memory24[]; +extern struct acpi_rsconvert_info acpi_rs_convert_generic_reg[]; +extern struct acpi_rsconvert_info acpi_rs_convert_memory32[]; +extern struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[]; +extern struct acpi_rsconvert_info acpi_rs_convert_address32[]; +extern struct acpi_rsconvert_info acpi_rs_convert_address16[]; +extern struct acpi_rsconvert_info acpi_rs_convert_ext_irq[]; +extern struct acpi_rsconvert_info acpi_rs_convert_address64[]; +extern struct acpi_rsconvert_info acpi_rs_convert_ext_address64[]; + +/* These resources require separate get/set tables */ + +extern struct acpi_rsconvert_info acpi_rs_get_irq[]; +extern struct acpi_rsconvert_info acpi_rs_get_start_dpf[]; +extern struct acpi_rsconvert_info acpi_rs_get_vendor_small[]; +extern struct acpi_rsconvert_info acpi_rs_get_vendor_large[]; + +extern struct acpi_rsconvert_info acpi_rs_set_irq[]; +extern struct acpi_rsconvert_info acpi_rs_set_start_dpf[]; +extern struct acpi_rsconvert_info acpi_rs_set_vendor[]; -void acpi_rs_dump_end_tag(union acpi_resource_data *resource); +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +/* + * rsinfo + */ +extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[]; +/* + * rsdump + */ +extern struct acpi_rsdump_info acpi_rs_dump_irq[]; +extern struct acpi_rsdump_info acpi_rs_dump_dma[]; +extern struct acpi_rsdump_info acpi_rs_dump_start_dpf[]; +extern struct acpi_rsdump_info acpi_rs_dump_end_dpf[]; +extern struct acpi_rsdump_info acpi_rs_dump_io[]; +extern struct acpi_rsdump_info acpi_rs_dump_fixed_io[]; +extern struct acpi_rsdump_info acpi_rs_dump_vendor[]; +extern struct acpi_rsdump_info acpi_rs_dump_end_tag[]; +extern struct acpi_rsdump_info acpi_rs_dump_memory24[]; +extern struct acpi_rsdump_info acpi_rs_dump_memory32[]; +extern struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[]; +extern struct acpi_rsdump_info acpi_rs_dump_address16[]; +extern struct acpi_rsdump_info acpi_rs_dump_address32[]; +extern struct acpi_rsdump_info acpi_rs_dump_address64[]; +extern struct acpi_rsdump_info acpi_rs_dump_ext_address64[]; +extern struct acpi_rsdump_info acpi_rs_dump_ext_irq[]; +extern struct acpi_rsdump_info acpi_rs_dump_generic_reg[]; #endif #endif /* __ACRESRC_H__ */ diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 43f7c509317a..29b887017b18 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -83,10 +83,11 @@ typedef COMPILER_DEPENDENT_UINT64 u64; * UINT32 32-bit (4 byte) unsigned value * INT64 64-bit (8 byte) signed value * UINT64 64-bit (8 byte) unsigned value - * ACPI_NATIVE_INT 32-bit on IA-32, 64-bit on IA-64 signed value - * ACPI_NATIVE_UINT 32-bit on IA-32, 64-bit on IA-64 unsigned value + * ACPI_NATIVE_UINT 32-bit on IA-32, 64-bit on x86_64/IA-64 unsigned value */ +typedef unsigned long acpi_native_uint; + #ifndef ACPI_MACHINE_WIDTH #error ACPI_MACHINE_WIDTH not defined #endif @@ -108,9 +109,6 @@ typedef COMPILER_DEPENDENT_UINT64 UINT64; /*! [End] no source code translation !*/ -typedef s64 acpi_native_int; -typedef u64 acpi_native_uint; - typedef u64 acpi_table_ptr; typedef u64 acpi_io_address; typedef u64 acpi_physical_address; @@ -121,9 +119,22 @@ typedef u64 acpi_size; #define ACPI_MAX_PTR ACPI_UINT64_MAX #define ACPI_SIZE_MAX ACPI_UINT64_MAX +/* + * In the case of the Itanium Processor Family (IPF), the hardware does not + * support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED flag + * to indicate that special precautions must be taken to avoid alignment faults. + * (IA64 or ia64 is currently used by existing compilers to indicate IPF.) + * + * Note: Em64_t and other X86-64 processors do support misaligned transfers, + * so there is no need to define this flag. + */ +#if defined (__IA64__) || defined (__ia64__) +#define ACPI_MISALIGNMENT_NOT_SUPPORTED +#endif + #elif ACPI_MACHINE_WIDTH == 16 -/*! [Begin] no source code translation (keep the typedefs) */ +/*! [Begin] no source code translation (keep the typedefs as-is) */ /* * 16-bit type definitions @@ -142,16 +153,12 @@ struct { /*! [End] no source code translation !*/ -typedef u16 acpi_native_uint; -typedef s16 acpi_native_int; - typedef u32 acpi_table_ptr; typedef u32 acpi_io_address; typedef char *acpi_physical_address; typedef u16 acpi_size; #define ALIGNED_ADDRESS_BOUNDARY 0x00000002 -#define ACPI_MISALIGNED_TRANSFERS #define ACPI_USE_NATIVE_DIVIDE /* No 64-bit integers, ok to use native divide */ #define ACPI_MAX_PTR ACPI_UINT16_MAX #define ACPI_SIZE_MAX ACPI_UINT16_MAX @@ -179,16 +186,12 @@ typedef COMPILER_DEPENDENT_UINT64 UINT64; /*! [End] no source code translation !*/ -typedef s32 acpi_native_int; -typedef u32 acpi_native_uint; - typedef u64 acpi_table_ptr; typedef u32 acpi_io_address; typedef u64 acpi_physical_address; typedef u32 acpi_size; #define ALIGNED_ADDRESS_BOUNDARY 0x00000004 -#define ACPI_MISALIGNED_TRANSFERS #define ACPI_MAX_PTR ACPI_UINT32_MAX #define ACPI_SIZE_MAX ACPI_UINT32_MAX @@ -895,6 +898,8 @@ struct acpi_mem_space_context { /* * Definitions for Resource Attributes */ +typedef u16 acpi_rs_length; /* Resource Length field is fixed at 16 bits */ +typedef u32 acpi_rsdesc_size; /* Max Resource Descriptor size is (length+3) = (64_k-1)+3 */ /* * Memory Attributes @@ -927,8 +932,8 @@ struct acpi_mem_space_context { /* * IRQ Attributes */ -#define ACPI_EDGE_SENSITIVE (u8) 0x00 -#define ACPI_LEVEL_SENSITIVE (u8) 0x01 +#define ACPI_LEVEL_SENSITIVE (u8) 0x00 +#define ACPI_EDGE_SENSITIVE (u8) 0x01 #define ACPI_ACTIVE_HIGH (u8) 0x00 #define ACPI_ACTIVE_LOW (u8) 0x01 @@ -974,28 +979,35 @@ struct acpi_mem_space_context { #define ACPI_PRODUCER (u8) 0x00 #define ACPI_CONSUMER (u8) 0x01 +/* + * If possible, pack the following structures to byte alignment + */ +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#pragma pack(1) +#endif + /* * Structures used to describe device resources */ struct acpi_resource_irq { - u32 triggering; - u32 polarity; - u32 sharable; - u32 interrupt_count; - u32 interrupts[1]; + u8 triggering; + u8 polarity; + u8 sharable; + u8 interrupt_count; + u8 interrupts[1]; }; struct acpi_resource_dma { - u32 type; - u32 bus_master; - u32 transfer; - u32 channel_count; - u32 channels[1]; + u8 type; + u8 bus_master; + u8 transfer; + u8 channel_count; + u8 channels[1]; }; struct acpi_resource_start_dependent { - u32 compatibility_priority; - u32 performance_robustness; + u8 compatibility_priority; + u8 performance_robustness; }; /* @@ -1004,20 +1016,20 @@ struct acpi_resource_start_dependent { */ struct acpi_resource_io { - u32 io_decode; - u32 minimum; - u32 maximum; - u32 alignment; - u32 address_length; + u8 io_decode; + u8 alignment; + u8 address_length; + u16 minimum; + u16 maximum; }; struct acpi_resource_fixed_io { - u32 address; - u32 address_length; + u16 address; + u8 address_length; }; struct acpi_resource_vendor { - u32 byte_length; + u16 byte_length; u8 byte_data[1]; }; @@ -1026,15 +1038,15 @@ struct acpi_resource_end_tag { }; struct acpi_resource_memory24 { - u32 read_write_attribute; - u32 minimum; - u32 maximum; - u32 alignment; - u32 address_length; + u8 write_protect; + u16 minimum; + u16 maximum; + u16 alignment; + u16 address_length; }; struct acpi_resource_memory32 { - u32 read_write_attribute; + u8 write_protect; u32 minimum; u32 maximum; u32 alignment; @@ -1042,57 +1054,59 @@ struct acpi_resource_memory32 { }; struct acpi_resource_fixed_memory32 { - u32 read_write_attribute; + u8 write_protect; u32 address; u32 address_length; }; struct acpi_memory_attribute { - u16 cache_attribute; - u16 read_write_attribute; + u8 write_protect; + u8 caching; + u8 range_type; + u8 translation; }; struct acpi_io_attribute { - u16 range_attribute; - u16 translation_attribute; -}; - -struct acpi_bus_attribute { - u16 reserved1; - u16 reserved2; + u8 range_type; + u8 translation; + u8 translation_type; + u8 reserved1; }; union acpi_resource_attribute { - struct acpi_memory_attribute memory; + struct acpi_memory_attribute mem; struct acpi_io_attribute io; - struct acpi_bus_attribute bus; + + /* Used for the *word_space macros */ + + u8 type_specific; }; struct acpi_resource_source { - u32 index; - u32 string_length; + u8 index; + u16 string_length; char *string_ptr; }; /* Fields common to all address descriptors, 16/32/64 bit */ #define ACPI_RESOURCE_ADDRESS_COMMON \ - u32 resource_type; \ - u32 producer_consumer; \ - u32 decode; \ - u32 min_address_fixed; \ - u32 max_address_fixed; \ - union acpi_resource_attribute attribute; + u8 resource_type; \ + u8 producer_consumer; \ + u8 decode; \ + u8 min_address_fixed; \ + u8 max_address_fixed; \ + union acpi_resource_attribute info; struct acpi_resource_address { ACPI_RESOURCE_ADDRESS_COMMON}; struct acpi_resource_address16 { - ACPI_RESOURCE_ADDRESS_COMMON u32 granularity; - u32 minimum; - u32 maximum; - u32 translation_offset; - u32 address_length; + ACPI_RESOURCE_ADDRESS_COMMON u16 granularity; + u16 minimum; + u16 maximum; + u16 translation_offset; + u16 address_length; struct acpi_resource_source resource_source; }; @@ -1115,30 +1129,30 @@ struct acpi_resource_address64 { }; struct acpi_resource_extended_address64 { - ACPI_RESOURCE_ADDRESS_COMMON u64 granularity; + ACPI_RESOURCE_ADDRESS_COMMON u8 revision_iD; + u64 granularity; u64 minimum; u64 maximum; u64 translation_offset; u64 address_length; - u64 type_specific_attributes; - u8 revision_iD; + u64 type_specific; }; struct acpi_resource_extended_irq { - u32 producer_consumer; - u32 triggering; - u32 polarity; - u32 sharable; - u32 interrupt_count; + u8 producer_consumer; + u8 triggering; + u8 polarity; + u8 sharable; + u8 interrupt_count; struct acpi_resource_source resource_source; u32 interrupts[1]; }; struct acpi_resource_generic_register { - u32 space_id; - u32 bit_width; - u32 bit_offset; - u32 access_size; + u8 space_id; + u8 bit_width; + u8 bit_offset; + u8 access_size; u64 address; }; @@ -1192,14 +1206,17 @@ struct acpi_resource { union acpi_resource_data data; }; -#define ACPI_RESOURCE_LENGTH 12 -#define ACPI_RESOURCE_LENGTH_NO_DATA 8 /* Id + Length fields */ +/* restore default alignment */ + +#pragma pack() -#define ACPI_SIZEOF_RESOURCE(type) (u32) (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (type)) +#define ACPI_RS_SIZE_MIN 12 +#define ACPI_RS_SIZE_NO_DATA 8 /* Id + Length fields */ +#define ACPI_RS_SIZE(type) (u32) (ACPI_RS_SIZE_NO_DATA + sizeof (type)) #define ACPI_NEXT_RESOURCE(res) (struct acpi_resource *)((u8 *) res + res->length) -#ifdef ACPI_MISALIGNED_TRANSFERS +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED #define ACPI_ALIGN_RESOURCE_SIZE(length) (length) #else #define ACPI_ALIGN_RESOURCE_SIZE(length) ACPI_ROUND_UP_TO_NATIVE_WORD(length) diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h index c1086452696e..7386eb81bd2a 100644 --- a/include/acpi/acutils.h +++ b/include/acpi/acutils.h @@ -159,7 +159,6 @@ extern const u8 _acpi_ctype[]; #define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) #define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU)) #define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) -#define ACPI_IS_ASCII(c) ((c) < 0x80) #endif /* ACPI_USE_SYSTEM_CLIBRARY */ @@ -419,6 +418,12 @@ acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer); #define ACPI_ANY_BASE 0 +u32 acpi_ut_get_descriptor_length(void *aml); + +u16 acpi_ut_get_resource_length(void *aml); + +u8 acpi_ut_get_resource_type(void *aml); + u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc); u8 acpi_ut_generate_checksum(u8 * buffer, u32 length); diff --git a/include/acpi/amlresrc.h b/include/acpi/amlresrc.h index 103aff07db18..3112be527731 100644 --- a/include/acpi/amlresrc.h +++ b/include/acpi/amlresrc.h @@ -134,7 +134,7 @@ struct aml_resource_end_dependent { AML_RESOURCE_SMALL_HEADER_COMMON}; struct aml_resource_io { - AML_RESOURCE_SMALL_HEADER_COMMON u8 information; + AML_RESOURCE_SMALL_HEADER_COMMON u8 flags; u16 minimum; u16 maximum; u8 alignment; @@ -164,7 +164,7 @@ struct aml_resource_large_header { AML_RESOURCE_LARGE_HEADER_COMMON}; struct aml_resource_memory24 { - AML_RESOURCE_LARGE_HEADER_COMMON u8 information; + AML_RESOURCE_LARGE_HEADER_COMMON u8 flags; u16 minimum; u16 maximum; u16 alignment; @@ -175,7 +175,7 @@ struct aml_resource_vendor_large { AML_RESOURCE_LARGE_HEADER_COMMON}; struct aml_resource_memory32 { - AML_RESOURCE_LARGE_HEADER_COMMON u8 information; + AML_RESOURCE_LARGE_HEADER_COMMON u8 flags; u32 minimum; u32 maximum; u32 alignment; @@ -183,7 +183,7 @@ struct aml_resource_memory32 { }; struct aml_resource_fixed_memory32 { - AML_RESOURCE_LARGE_HEADER_COMMON u8 information; + AML_RESOURCE_LARGE_HEADER_COMMON u8 flags; u32 address; u32 address_length; }; @@ -205,7 +205,7 @@ struct aml_resource_extended_address64 { u64 maximum; u64 translation_offset; u64 address_length; - u64 type_specific_attributes; + u64 type_specific; }; #define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */ @@ -239,8 +239,8 @@ struct aml_resource_address16 { struct aml_resource_extended_irq { AML_RESOURCE_LARGE_HEADER_COMMON u8 flags; - u8 table_length; - u32 interrupt_number[1]; + u8 interrupt_count; + u32 interrupts[1]; /* res_source_index, res_source optional fields follow */ }; diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h index 08539125696a..53aa997f05fc 100644 --- a/include/acpi/platform/acenv.h +++ b/include/acpi/platform/acenv.h @@ -206,6 +206,8 @@ * *****************************************************************************/ +#define ACPI_IS_ASCII(c) ((c) < 0x80) + #ifdef ACPI_USE_SYSTEM_CLIBRARY /* * Use the standard C library headers. @@ -235,7 +237,7 @@ #define ACPI_STRCAT(d,s) (void) strcat((d), (s)) #define ACPI_STRNCAT(d,s,n) strncat((d), (s), (acpi_size)(n)) #define ACPI_STRTOUL(d,s,n) strtoul((d), (s), (acpi_size)(n)) -#define ACPI_MEMCMP(s1,s2,n) memcmp((s1), (s2), (acpi_size)(n)) +#define ACPI_MEMCMP(s1,s2,n) memcmp((const char *)(s1), (const char *)(s2), (acpi_size)(n)) #define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (acpi_size)(n)) #define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (acpi_size)(n)) @@ -247,7 +249,6 @@ #define ACPI_IS_UPPER(i) isupper((int) (i)) #define ACPI_IS_PRINT(i) isprint((int) (i)) #define ACPI_IS_ALPHA(i) isalpha((int) (i)) -#define ACPI_IS_ASCII(i) isascii((int) (i)) #else @@ -274,8 +275,8 @@ typedef char *va_list; /* * Storage alignment properties */ -#define _AUPBND (sizeof (acpi_native_int) - 1) -#define _ADNBND (sizeof (acpi_native_int) - 1) +#define _AUPBND (sizeof (acpi_native_uint) - 1) +#define _ADNBND (sizeof (acpi_native_uint) - 1) /* * Variable argument list macro definitions @@ -297,7 +298,7 @@ typedef char *va_list; #define ACPI_STRCAT(d,s) (void) acpi_ut_strcat ((d), (s)) #define ACPI_STRNCAT(d,s,n) acpi_ut_strncat ((d), (s), (acpi_size)(n)) #define ACPI_STRTOUL(d,s,n) acpi_ut_strtoul ((d), (s), (acpi_size)(n)) -#define ACPI_MEMCMP(s1,s2,n) acpi_ut_memcmp((s1), (s2), (acpi_size)(n)) +#define ACPI_MEMCMP(s1,s2,n) acpi_ut_memcmp((const char *)(s1), (const char *)(s2), (acpi_size)(n)) #define ACPI_MEMCPY(d,s,n) (void) acpi_ut_memcpy ((d), (s), (acpi_size)(n)) #define ACPI_MEMSET(d,v,n) (void) acpi_ut_memset ((d), (v), (acpi_size)(n)) #define ACPI_TOUPPER acpi_ut_to_upper -- cgit v1.2.3 From 96db255c8f014ae3497507104e8df809785a619f Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Wed, 2 Nov 2005 00:00:00 -0500 Subject: [ACPI] ACPICA 20051102 Modified the subsystem initialization sequence to improve GPE support. The GPE initialization has been split into two parts in order to defer execution of the _PRW methods (Power Resources for Wake) until after the hardware is fully initialized and the SCI handler is installed. This allows the _PRW methods to access fields protected by the Global Lock. This will fix systems where a NO_GLOBAL_LOCK exception has been seen during initialization. Fixed a regression with the ConcatenateResTemplate() ASL operator introduced in the 20051021 release. Implemented support for "local" internal ACPI object types within the debugger "Object" command and the acpi_walk_namespace() external interfaces. These local types include RegionFields, BankFields, IndexFields, Alias, and reference objects. Moved common AML resource handling code into a new file, "utresrc.c". This code is shared by both the Resource Manager and the AML Debugger. Signed-off-by: Bob Moore Signed-off-by: Len Brown --- drivers/acpi/events/evevent.c | 42 +++ drivers/acpi/events/evgpeblk.c | 159 +++++---- drivers/acpi/events/evxfevnt.c | 7 + drivers/acpi/executer/exdump.c | 656 +++++++++++++++++++++++--------------- drivers/acpi/executer/exmisc.c | 47 ++- drivers/acpi/namespace/nsxfeval.c | 2 +- drivers/acpi/resources/rscalc.c | 253 +++++++-------- drivers/acpi/resources/rsdump.c | 70 ++-- drivers/acpi/resources/rsinfo.c | 97 +++--- drivers/acpi/resources/rslist.c | 195 ++--------- drivers/acpi/resources/rsutils.c | 88 ++--- drivers/acpi/utilities/Makefile | 5 +- drivers/acpi/utilities/utmisc.c | 148 --------- drivers/acpi/utilities/utresrc.c | 428 +++++++++++++++++++++++++ drivers/acpi/utilities/utstate.c | 2 +- drivers/acpi/utilities/utxface.c | 52 ++- include/acpi/acconfig.h | 2 +- include/acpi/acevents.h | 6 + include/acpi/acinterp.h | 46 ++- include/acpi/acresrc.h | 27 +- include/acpi/acutils.h | 17 +- include/acpi/amlresrc.h | 5 + 22 files changed, 1368 insertions(+), 986 deletions(-) create mode 100644 drivers/acpi/utilities/utresrc.c (limited to 'include') diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/events/evevent.c index 842d1e3fb37b..9522c643b88b 100644 --- a/drivers/acpi/events/evevent.c +++ b/drivers/acpi/events/evevent.c @@ -98,6 +98,48 @@ acpi_status acpi_ev_initialize_events(void) return_ACPI_STATUS(status); } +/******************************************************************************* + * + * FUNCTION: acpi_ev_install_fadt_gpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Completes initialization of the FADT-defined GPE blocks + * (0 and 1). This causes the _PRW methods to be run, so the HW + * must be fully initialized at this point, including global lock + * support. + * + ******************************************************************************/ + +acpi_status acpi_ev_install_fadt_gpes(void) +{ + acpi_status status; + + ACPI_FUNCTION_TRACE("ev_install_fadt_gpes"); + + /* Namespace must be locked */ + + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + return (status); + } + + /* FADT GPE Block 0 */ + + (void)acpi_ev_initialize_gpe_block(acpi_gbl_fadt_gpe_device, + acpi_gbl_gpe_fadt_blocks[0]); + + /* FADT GPE Block 1 */ + + (void)acpi_ev_initialize_gpe_block(acpi_gbl_fadt_gpe_device, + acpi_gbl_gpe_fadt_blocks[1]); + + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + return_ACPI_STATUS(AE_OK); +} + /******************************************************************************* * * FUNCTION: acpi_ev_install_xrupt_handlers diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c index 7ca10c5f2914..8efca2eac27e 100644 --- a/drivers/acpi/events/evgpeblk.c +++ b/drivers/acpi/events/evgpeblk.c @@ -78,7 +78,7 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block); * * RETURN: TRUE if the gpe_event is valid * - * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. + * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. * Should be called only when the GPE lists are semaphore locked * and not subject to change. * @@ -264,7 +264,7 @@ acpi_ev_save_method_info(acpi_handle obj_handle, * 2) Edge/Level determination is based on the 2nd character * of the method name * - * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE + * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE * if a _PRW object is found that points to this GPE. */ switch (name[1]) { @@ -313,14 +313,14 @@ acpi_ev_save_method_info(acpi_handle obj_handle, /* * Now we can add this information to the gpe_event_info block - * for use during dispatch of this GPE. Default type is RUNTIME, although + * for use during dispatch of this GPE. Default type is RUNTIME, although * this may change when the _PRW methods are executed later. */ gpe_event_info = &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; - gpe_event_info->flags = (u8) (type | ACPI_GPE_DISPATCH_METHOD | - ACPI_GPE_TYPE_RUNTIME); + gpe_event_info->flags = (u8) + (type | ACPI_GPE_DISPATCH_METHOD | ACPI_GPE_TYPE_RUNTIME); gpe_event_info->dispatch.method_node = (struct acpi_namespace_node *)obj_handle; @@ -341,11 +341,11 @@ acpi_ev_save_method_info(acpi_handle obj_handle, * * PARAMETERS: Callback from walk_namespace * - * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is + * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is * not aborted on a single _PRW failure. * * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a - * Device. Run the _PRW method. If present, extract the GPE + * Device. Run the _PRW method. If present, extract the GPE * number and mark the GPE as a WAKE GPE. * ******************************************************************************/ @@ -443,6 +443,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, gpe_event_info->flags &= ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); + status = acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE); if (ACPI_FAILURE(status)) { @@ -466,7 +467,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, * * RETURN: A GPE interrupt block * - * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt + * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt * block per unique interrupt level used for GPEs. * Should be called only when the GPE lists are semaphore locked * and not subject to change. @@ -566,8 +567,9 @@ acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt) /* Disable this interrupt */ - status = acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number, - acpi_ev_gpe_xrupt_handler); + status = + acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number, + acpi_ev_gpe_xrupt_handler); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -750,7 +752,7 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block) /* * Allocate the GPE event_info block. There are eight distinct GPEs - * per register. Initialization to zeros is sufficient. + * per register. Initialization to zeros is sufficient. */ gpe_event_info = ACPI_MEM_CALLOCATE(((acpi_size) gpe_block-> register_count * @@ -769,9 +771,9 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block) gpe_block->event_info = gpe_event_info; /* - * Initialize the GPE Register and Event structures. A goal of these + * Initialize the GPE Register and Event structures. A goal of these * tables is to hide the fact that there are two separate GPE register sets - * in a given gpe hardware block, the status registers occupy the first half, + * in a given GPE hardware block, the status registers occupy the first half, * and the enable registers occupy the second half. */ this_register = gpe_register_info; @@ -812,11 +814,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block) this_event++; } - /* - * Clear the status/enable registers. Note that status registers - * are cleared by writing a '1', while enable registers are cleared - * by writing a '0'. - */ + /* Disable all GPEs within this register */ + status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00, &this_register-> enable_address); @@ -824,6 +823,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block) goto error_exit; } + /* Clear any pending GPE events within this register */ + status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF, &this_register-> status_address); @@ -860,7 +861,9 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block) * * RETURN: Status * - * DESCRIPTION: Create and Install a block of GPE registers + * DESCRIPTION: Create and Install a block of GPE registers. All GPEs within + * the block are disabled at exit. + * Note: Assumes namespace is locked. * ******************************************************************************/ @@ -872,14 +875,8 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, u32 interrupt_number, struct acpi_gpe_block_info **return_gpe_block) { - struct acpi_gpe_block_info *gpe_block; - struct acpi_gpe_event_info *gpe_event_info; - acpi_native_uint i; - acpi_native_uint j; - u32 wake_gpe_count; - u32 gpe_enabled_count; acpi_status status; - struct acpi_gpe_walk_info gpe_info; + struct acpi_gpe_block_info *gpe_block; ACPI_FUNCTION_TRACE("ev_create_gpe_block"); @@ -896,22 +893,24 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, /* Initialize the new GPE block */ + gpe_block->node = gpe_device; gpe_block->register_count = register_count; gpe_block->block_base_number = gpe_block_base_number; - gpe_block->node = gpe_device; ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address, sizeof(struct acpi_generic_address)); - /* Create the register_info and event_info sub-structures */ - + /* + * Create the register_info and event_info sub-structures + * Note: disables and clears all GPEs in the block + */ status = acpi_ev_create_gpe_info_blocks(gpe_block); if (ACPI_FAILURE(status)) { ACPI_MEM_FREE(gpe_block); return_ACPI_STATUS(status); } - /* Install the new block in the global list(s) */ + /* Install the new block in the global lists */ status = acpi_ev_install_gpe_block(gpe_block, interrupt_number); if (ACPI_FAILURE(status)) { @@ -926,16 +925,70 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, acpi_ev_save_method_info, gpe_block, NULL); + /* Return the new block */ + + if (return_gpe_block) { + (*return_gpe_block) = gpe_block; + } + + ACPI_DEBUG_PRINT((ACPI_DB_INIT, + "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", + (u32) gpe_block->block_base_number, + (u32) (gpe_block->block_base_number + + ((gpe_block->register_count * + ACPI_GPE_REGISTER_WIDTH) - 1)), + gpe_device->name.ascii, gpe_block->register_count, + interrupt_number)); + + return_ACPI_STATUS(AE_OK); +} + +/******************************************************************************* + * + * FUNCTION: acpi_ev_initialize_gpe_block + * + * PARAMETERS: gpe_device - Handle to the parent GPE block + * gpe_block - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Initialize and enable a GPE block. First find and run any + * _PRT methods associated with the block, then enable the + * appropriate GPEs. + * Note: Assumes namespace is locked. + * + ******************************************************************************/ + +acpi_status +acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, + struct acpi_gpe_block_info *gpe_block) +{ + acpi_status status; + struct acpi_gpe_event_info *gpe_event_info; + struct acpi_gpe_walk_info gpe_info; + u32 wake_gpe_count; + u32 gpe_enabled_count; + acpi_native_uint i; + acpi_native_uint j; + + ACPI_FUNCTION_TRACE("ev_initialize_gpe_block"); + + /* Ignore a null GPE block (e.g., if no GPE block 1 exists) */ + + if (!gpe_block) { + return_ACPI_STATUS(AE_OK); + } + /* - * Runtime option: Should Wake GPEs be enabled at runtime? The default - * is No, they should only be enabled just as the machine goes to sleep. + * Runtime option: Should wake GPEs be enabled at runtime? The default + * is no, they should only be enabled just as the machine goes to sleep. */ if (acpi_gbl_leave_wake_gpes_disabled) { /* - * Differentiate RUNTIME vs WAKE GPEs, via the _PRW control methods. - * (Each GPE that has one or more _PRWs that reference it is by - * definition a WAKE GPE and will not be enabled while the machine - * is running.) + * Differentiate runtime vs wake GPEs, via the _PRW control methods. + * Each GPE that has one or more _PRWs that reference it is by + * definition a wake GPE and will not be enabled while the machine + * is running. */ gpe_info.gpe_block = gpe_block; gpe_info.gpe_device = gpe_device; @@ -948,9 +1001,12 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, } /* - * Enable all GPEs in this block that are 1) "runtime" or "run/wake" GPEs, - * and 2) have a corresponding _Lxx or _Exx method. All other GPEs must - * be enabled via the acpi_enable_gpe() external interface. + * Enable all GPEs in this block that have these attributes: + * 1) are "runtime" or "run/wake" GPEs, and + * 2) have a corresponding _Lxx or _Exx method + * + * Any other GPEs within this block must be enabled via the acpi_enable_gpe() + * external interface. */ wake_gpe_count = 0; gpe_enabled_count = 0; @@ -976,32 +1032,19 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, } } - /* Dump info about this GPE block */ - - ACPI_DEBUG_PRINT((ACPI_DB_INIT, - "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", - (u32) gpe_block->block_base_number, - (u32) (gpe_block->block_base_number + - ((gpe_block->register_count * - ACPI_GPE_REGISTER_WIDTH) - 1)), - gpe_device->name.ascii, gpe_block->register_count, - interrupt_number)); - - /* Enable all valid GPEs found above */ - - status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block); - ACPI_DEBUG_PRINT((ACPI_DB_INIT, "Found %u Wake, Enabled %u Runtime GPEs in this block\n", wake_gpe_count, gpe_enabled_count)); - /* Return the new block */ + /* Enable all valid runtime GPEs found above */ - if (return_gpe_block) { - (*return_gpe_block) = gpe_block; + status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block); + if (ACPI_FAILURE(status)) { + ACPI_REPORT_ERROR(("Could not enable GPEs in gpe_block %p\n", + gpe_block)); } - return_ACPI_STATUS(AE_OK); + return_ACPI_STATUS(status); } /******************************************************************************* diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c index 887ff9f28a0d..c1b898928256 100644 --- a/drivers/acpi/events/evxfevnt.c +++ b/drivers/acpi/events/evxfevnt.c @@ -626,6 +626,13 @@ acpi_install_gpe_block(acpi_handle gpe_device, goto unlock_and_exit; } + /* Run the _PRW methods and enable the GPEs */ + + status = acpi_ev_initialize_gpe_block(node, gpe_block); + if (ACPI_FAILURE(status)) { + goto unlock_and_exit; + } + /* Get the device_object attached to the node */ obj_desc = acpi_ns_get_attached_object(node); diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index 4477a62fed56..5a4cca171af6 100644 --- a/drivers/acpi/executer/exdump.c +++ b/drivers/acpi/executer/exdump.c @@ -55,20 +55,386 @@ ACPI_MODULE_NAME("exdump") */ #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) /* Local prototypes */ -#ifdef ACPI_FUTURE_USAGE static void acpi_ex_out_string(char *title, char *value); static void acpi_ex_out_pointer(char *title, void *value); -static void acpi_ex_out_integer(char *title, u32 value); - static void acpi_ex_out_address(char *title, acpi_physical_address value); -static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc); +static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc); static void -acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index); -#endif /* ACPI_FUTURE_USAGE */ +acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc, + u32 level, u32 index); + +/******************************************************************************* + * + * Object Descriptor info tables + * + * Note: The first table entry must be an INIT opcode and must contain + * the table length (number of table entries) + * + ******************************************************************************/ + +static struct acpi_exdump_info acpi_ex_dump_integer[2] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_integer), NULL}, + {ACPI_EXD_UINT64, ACPI_EXD_OFFSET(integer.value), "Value"} +}; + +static struct acpi_exdump_info acpi_ex_dump_string[4] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_string), NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(string.length), "Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(string.pointer), "Pointer"}, + {ACPI_EXD_STRING, 0, NULL} +}; + +static struct acpi_exdump_info acpi_ex_dump_buffer[4] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer), NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(buffer.length), "Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer.pointer), "Pointer"}, + {ACPI_EXD_BUFFER, 0, NULL} +}; + +static struct acpi_exdump_info acpi_ex_dump_package[5] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_package), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(package.flags), "Flags"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(package.count), "Elements"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(package.elements), "Element List"}, + {ACPI_EXD_PACKAGE, 0, NULL} +}; + +static struct acpi_exdump_info acpi_ex_dump_device[4] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_device), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.handler), "Handler"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.system_notify), + "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.device_notify), + "Device Notify"} +}; + +static struct acpi_exdump_info acpi_ex_dump_event[2] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_event), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.semaphore), "Semaphore"} +}; + +static struct acpi_exdump_info acpi_ex_dump_method[7] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "param_count"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.concurrency), "Concurrency"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.semaphore), "Semaphore"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.aml_start), "Aml Start"} +}; + +static struct acpi_exdump_info acpi_ex_dump_mutex[5] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"}, + {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth), + "Acquire Depth"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.semaphore), "Semaphore"} +}; + +static struct acpi_exdump_info acpi_ex_dump_region[7] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.space_id), "Space Id"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.flags), "Flags"}, + {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(region.address), "Address"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(region.length), "Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.handler), "Handler"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.next), "Next"} +}; + +static struct acpi_exdump_info acpi_ex_dump_power[5] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_power), NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.system_level), + "System Level"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.resource_order), + "Resource Order"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.system_notify), + "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.device_notify), + "Device Notify"} +}; + +static struct acpi_exdump_info acpi_ex_dump_processor[7] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_processor), NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(processor.proc_id), "Processor ID"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(processor.length), "Length"}, + {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(processor.address), "Address"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.system_notify), + "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.device_notify), + "Device Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.handler), "Handler"} +}; + +static struct acpi_exdump_info acpi_ex_dump_thermal[4] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_thermal), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.system_notify), + "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.device_notify), + "Device Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.handler), "Handler"} +}; + +static struct acpi_exdump_info acpi_ex_dump_buffer_field[3] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer_field), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer_field.buffer_obj), + "Buffer Object"} +}; + +static struct acpi_exdump_info acpi_ex_dump_region_field[3] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region_field), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(field.region_obj), "Region Object"} +}; + +static struct acpi_exdump_info acpi_ex_dump_bank_field[5] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(bank_field.value), "Value"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.region_obj), + "Region Object"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.bank_obj), "Bank Object"} +}; + +static struct acpi_exdump_info acpi_ex_dump_index_field[5] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(index_field.value), "Value"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.index_obj), + "Index Object"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.data_obj), "Data Object"} +}; + +static struct acpi_exdump_info acpi_ex_dump_reference[7] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_reference), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.target_type), "Target Type"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(reference.offset), "Offset"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.object), "Object Desc"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.node), "Node"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.where), "Where"}, + {ACPI_EXD_REFERENCE, 0, NULL} +}; + +static struct acpi_exdump_info acpi_ex_dump_address_handler[6] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_address_handler), + NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(address_space.space_id), "Space Id"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.next), "Next"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.region_list), + "Region List"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.node), "Node"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.context), "Context"} +}; + +static struct acpi_exdump_info acpi_ex_dump_notify[3] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_notify), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.node), "Node"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.context), "Context"} +}; + +/* Miscellaneous tables */ + +static struct acpi_exdump_info acpi_ex_dump_common[4] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_common), NULL}, + {ACPI_EXD_TYPE, 0, NULL}, + {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(common.reference_count), + "Reference Count"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common.flags), "Flags"} +}; + +static struct acpi_exdump_info acpi_ex_dump_field_common[7] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_field_common), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.field_flags), + "Field Flags"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.access_byte_width), + "Access Byte Width"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.bit_length), + "Bit Length"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.start_field_bit_offset), + "Field Bit Offset"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.base_byte_offset), + "Base Byte Offset"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(common_field.node), "Parent Node"} +}; + +static struct acpi_exdump_info acpi_ex_dump_node[6] = { + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_node), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(flags), "Flags"}, + {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(owner_id), "Owner Id"}, + {ACPI_EXD_UINT16, ACPI_EXD_NSOFFSET(reference_count), + "Reference Count"}, + {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(child), "Child List"}, + {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(peer), "Next Peer"} +}; + +/* Dispatch table, indexed by object type */ + +static struct acpi_exdump_info *acpi_ex_dump_info[] = { + NULL, + acpi_ex_dump_integer, + acpi_ex_dump_string, + acpi_ex_dump_buffer, + acpi_ex_dump_package, + NULL, + acpi_ex_dump_device, + acpi_ex_dump_event, + acpi_ex_dump_method, + acpi_ex_dump_mutex, + acpi_ex_dump_region, + acpi_ex_dump_power, + acpi_ex_dump_processor, + acpi_ex_dump_thermal, + acpi_ex_dump_buffer_field, + NULL, + NULL, + acpi_ex_dump_region_field, + acpi_ex_dump_bank_field, + acpi_ex_dump_index_field, + acpi_ex_dump_reference, + NULL, + NULL, + acpi_ex_dump_notify, + acpi_ex_dump_address_handler, + NULL, + NULL, + NULL +}; + +/******************************************************************************* + * + * FUNCTION: acpi_ex_dump_object + * + * PARAMETERS: obj_desc - Descriptor to dump + * Info - Info table corresponding to this object + * type + * + * RETURN: None + * + * DESCRIPTION: Walk the info table for this object + * + ******************************************************************************/ + +static void +acpi_ex_dump_object(union acpi_operand_object *obj_desc, + struct acpi_exdump_info *info) +{ + u8 *target; + char *name; + u8 count; + + if (!info) { + acpi_os_printf + ("ex_dump_object: Display not implemented for object type %s\n", + acpi_ut_get_object_type_name(obj_desc)); + return; + } + + /* First table entry must contain the table length (# of table entries) */ + + count = info->offset; + + while (count) { + target = ((u8 *) obj_desc) + info->offset; + name = info->name; + + switch (info->opcode) { + case ACPI_EXD_INIT: + break; + + case ACPI_EXD_TYPE: + acpi_ex_out_string("Type", + acpi_ut_get_object_type_name + (obj_desc)); + break; + + case ACPI_EXD_UINT8: + + acpi_os_printf("%20s : %2.2X\n", name, *target); + break; + + case ACPI_EXD_UINT16: + + acpi_os_printf("%20s : %4.4X\n", name, + *ACPI_CAST_PTR(u16, target)); + break; + + case ACPI_EXD_UINT32: + + acpi_os_printf("%20s : %8.8X\n", name, + *ACPI_CAST_PTR(u32, target)); + break; + + case ACPI_EXD_UINT64: + + acpi_os_printf("%20s : %8.8X%8.8X\n", "Value", + ACPI_FORMAT_UINT64(*ACPI_CAST_PTR + (u64, target))); + break; + + case ACPI_EXD_POINTER: + + acpi_ex_out_pointer(name, + *ACPI_CAST_PTR(void *, target)); + break; + + case ACPI_EXD_ADDRESS: + + acpi_ex_out_address(name, + *ACPI_CAST_PTR + (acpi_physical_address, target)); + break; + + case ACPI_EXD_STRING: + + acpi_ut_print_string(obj_desc->string.pointer, + ACPI_UINT8_MAX); + acpi_os_printf("\n"); + break; + + case ACPI_EXD_BUFFER: + + ACPI_DUMP_BUFFER(obj_desc->buffer.pointer, + obj_desc->buffer.length); + break; + + case ACPI_EXD_PACKAGE: + + /* Dump the package contents */ + + acpi_os_printf("\nPackage Contents:\n"); + acpi_ex_dump_package_obj(obj_desc, 0, 0); + break; + + case ACPI_EXD_FIELD: + + acpi_ex_dump_object(obj_desc, + acpi_ex_dump_field_common); + break; + + case ACPI_EXD_REFERENCE: + + acpi_ex_out_string("Opcode", + (acpi_ps_get_opcode_info + (obj_desc->reference.opcode))-> + name); + acpi_ex_dump_reference_obj(obj_desc); + break; + + default: + acpi_os_printf("**** Invalid table opcode [%X] ****\n", + info->opcode); + return; + } + + info++; + count--; + } +} /******************************************************************************* * @@ -441,7 +807,6 @@ acpi_ex_dump_operands(union acpi_operand_object **operands, return; } -#ifdef ACPI_FUTURE_USAGE /******************************************************************************* * * FUNCTION: acpi_ex_out* functions @@ -465,11 +830,6 @@ static void acpi_ex_out_pointer(char *title, void *value) acpi_os_printf("%20s : %p\n", title, value); } -static void acpi_ex_out_integer(char *title, u32 value) -{ - acpi_os_printf("%20s : %.2X\n", title, value); -} - static void acpi_ex_out_address(char *title, acpi_physical_address value) { @@ -482,16 +842,16 @@ static void acpi_ex_out_address(char *title, acpi_physical_address value) /******************************************************************************* * - * FUNCTION: acpi_ex_dump_node + * FUNCTION: acpi_ex_dump_namespace_node * - * PARAMETERS: *Node - Descriptor to dump + * PARAMETERS: Node - Descriptor to dump * Flags - Force display if TRUE * * DESCRIPTION: Dumps the members of the given.Node * ******************************************************************************/ -void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags) +void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags) { ACPI_FUNCTION_ENTRY(); @@ -506,19 +866,17 @@ void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags) acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node)); acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type)); - acpi_ex_out_integer("Flags", node->flags); - acpi_ex_out_integer("Owner Id", node->owner_id); - acpi_ex_out_integer("Reference Count", node->reference_count); acpi_ex_out_pointer("Attached Object", acpi_ns_get_attached_object(node)); - acpi_ex_out_pointer("child_list", node->child); - acpi_ex_out_pointer("next_peer", node->peer); acpi_ex_out_pointer("Parent", acpi_ns_get_parent_node(node)); + + acpi_ex_dump_object(ACPI_CAST_PTR(union acpi_operand_object, node), + acpi_ex_dump_node); } /******************************************************************************* * - * FUNCTION: acpi_ex_dump_reference + * FUNCTION: acpi_ex_dump_reference_obj * * PARAMETERS: Object - Descriptor to dump * @@ -526,14 +884,16 @@ void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags) * ******************************************************************************/ -static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc) +static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc) { struct acpi_buffer ret_buf; acpi_status status; + ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER; + if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) { acpi_os_printf("Named Object %p ", obj_desc->reference.node); - ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER; + status = acpi_ns_handle_to_pathname(obj_desc->reference.node, &ret_buf); @@ -551,9 +911,9 @@ static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc) /******************************************************************************* * - * FUNCTION: acpi_ex_dump_package + * FUNCTION: acpi_ex_dump_package_obj * - * PARAMETERS: Object - Descriptor to dump + * PARAMETERS: obj_desc - Descriptor to dump * Level - Indentation Level * Index - Package index for this object * @@ -562,7 +922,8 @@ static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc) ******************************************************************************/ static void -acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index) +acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc, + u32 level, u32 index) { u32 i; @@ -622,15 +983,15 @@ acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index) obj_desc->package.count); for (i = 0; i < obj_desc->package.count; i++) { - acpi_ex_dump_package(obj_desc->package.elements[i], - level + 1, i); + acpi_ex_dump_package_obj(obj_desc->package.elements[i], + level + 1, i); } break; case ACPI_TYPE_LOCAL_REFERENCE: acpi_os_printf("[Object Reference] "); - acpi_ex_dump_reference(obj_desc); + acpi_ex_dump_reference_obj(obj_desc); break; default: @@ -645,7 +1006,7 @@ acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index) * * FUNCTION: acpi_ex_dump_object_descriptor * - * PARAMETERS: Object - Descriptor to dump + * PARAMETERS: obj_desc - Descriptor to dump * Flags - Force display if TRUE * * DESCRIPTION: Dumps the members of the object descriptor given. @@ -670,11 +1031,13 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags) } if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) { - acpi_ex_dump_node((struct acpi_namespace_node *)obj_desc, - flags); + acpi_ex_dump_namespace_node((struct acpi_namespace_node *) + obj_desc, flags); + acpi_os_printf("\nAttached Object (%p):\n", ((struct acpi_namespace_node *)obj_desc)-> object); + acpi_ex_dump_object_descriptor(((struct acpi_namespace_node *) obj_desc)->object, flags); return_VOID; @@ -687,233 +1050,18 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags) return_VOID; } - /* Common Fields */ - - acpi_ex_out_string("Type", acpi_ut_get_object_type_name(obj_desc)); - acpi_ex_out_integer("Reference Count", - obj_desc->common.reference_count); - acpi_ex_out_integer("Flags", obj_desc->common.flags); - - /* Object-specific Fields */ - - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { - case ACPI_TYPE_INTEGER: - - acpi_os_printf("%20s : %8.8X%8.8X\n", "Value", - ACPI_FORMAT_UINT64(obj_desc->integer.value)); - break; - - case ACPI_TYPE_STRING: - - acpi_ex_out_integer("Length", obj_desc->string.length); - - acpi_os_printf("%20s : %p ", "Pointer", - obj_desc->string.pointer); - acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX); - acpi_os_printf("\n"); - break; - - case ACPI_TYPE_BUFFER: - - acpi_ex_out_integer("Length", obj_desc->buffer.length); - acpi_ex_out_pointer("Pointer", obj_desc->buffer.pointer); - ACPI_DUMP_BUFFER(obj_desc->buffer.pointer, - obj_desc->buffer.length); - break; - - case ACPI_TYPE_PACKAGE: - - acpi_ex_out_integer("Flags", obj_desc->package.flags); - acpi_ex_out_integer("Elements", obj_desc->package.count); - acpi_ex_out_pointer("Element List", obj_desc->package.elements); - - /* Dump the package contents */ - - acpi_os_printf("\nPackage Contents:\n"); - acpi_ex_dump_package(obj_desc, 0, 0); - break; - - case ACPI_TYPE_DEVICE: - - acpi_ex_out_pointer("Handler", obj_desc->device.handler); - acpi_ex_out_pointer("system_notify", - obj_desc->device.system_notify); - acpi_ex_out_pointer("device_notify", - obj_desc->device.device_notify); - break; - - case ACPI_TYPE_EVENT: - - acpi_ex_out_pointer("Semaphore", obj_desc->event.semaphore); - break; - - case ACPI_TYPE_METHOD: - - acpi_ex_out_integer("param_count", - obj_desc->method.param_count); - acpi_ex_out_integer("Concurrency", - obj_desc->method.concurrency); - acpi_ex_out_pointer("Semaphore", obj_desc->method.semaphore); - acpi_ex_out_integer("owner_id", obj_desc->method.owner_id); - acpi_ex_out_integer("aml_length", obj_desc->method.aml_length); - acpi_ex_out_pointer("aml_start", obj_desc->method.aml_start); - break; - - case ACPI_TYPE_MUTEX: - - acpi_ex_out_integer("sync_level", obj_desc->mutex.sync_level); - acpi_ex_out_pointer("owner_thread", - obj_desc->mutex.owner_thread); - acpi_ex_out_integer("acquire_depth", - obj_desc->mutex.acquisition_depth); - acpi_ex_out_pointer("Semaphore", obj_desc->mutex.semaphore); - break; - - case ACPI_TYPE_REGION: - - acpi_ex_out_integer("space_id", obj_desc->region.space_id); - acpi_ex_out_integer("Flags", obj_desc->region.flags); - acpi_ex_out_address("Address", obj_desc->region.address); - acpi_ex_out_integer("Length", obj_desc->region.length); - acpi_ex_out_pointer("Handler", obj_desc->region.handler); - acpi_ex_out_pointer("Next", obj_desc->region.next); - break; - - case ACPI_TYPE_POWER: - - acpi_ex_out_integer("system_level", - obj_desc->power_resource.system_level); - acpi_ex_out_integer("resource_order", - obj_desc->power_resource.resource_order); - acpi_ex_out_pointer("system_notify", - obj_desc->power_resource.system_notify); - acpi_ex_out_pointer("device_notify", - obj_desc->power_resource.device_notify); - break; - - case ACPI_TYPE_PROCESSOR: - - acpi_ex_out_integer("Processor ID", - obj_desc->processor.proc_id); - acpi_ex_out_integer("Length", obj_desc->processor.length); - acpi_ex_out_address("Address", - (acpi_physical_address) obj_desc->processor. - address); - acpi_ex_out_pointer("system_notify", - obj_desc->processor.system_notify); - acpi_ex_out_pointer("device_notify", - obj_desc->processor.device_notify); - acpi_ex_out_pointer("Handler", obj_desc->processor.handler); - break; - - case ACPI_TYPE_THERMAL: - - acpi_ex_out_pointer("system_notify", - obj_desc->thermal_zone.system_notify); - acpi_ex_out_pointer("device_notify", - obj_desc->thermal_zone.device_notify); - acpi_ex_out_pointer("Handler", obj_desc->thermal_zone.handler); - break; - - case ACPI_TYPE_BUFFER_FIELD: - case ACPI_TYPE_LOCAL_REGION_FIELD: - case ACPI_TYPE_LOCAL_BANK_FIELD: - case ACPI_TYPE_LOCAL_INDEX_FIELD: - - acpi_ex_out_integer("field_flags", - obj_desc->common_field.field_flags); - acpi_ex_out_integer("access_byte_width", - obj_desc->common_field.access_byte_width); - acpi_ex_out_integer("bit_length", - obj_desc->common_field.bit_length); - acpi_ex_out_integer("fld_bit_offset", - obj_desc->common_field. - start_field_bit_offset); - acpi_ex_out_integer("base_byte_offset", - obj_desc->common_field.base_byte_offset); - acpi_ex_out_pointer("parent_node", obj_desc->common_field.node); - - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { - case ACPI_TYPE_BUFFER_FIELD: - acpi_ex_out_pointer("buffer_obj", - obj_desc->buffer_field.buffer_obj); - break; - - case ACPI_TYPE_LOCAL_REGION_FIELD: - acpi_ex_out_pointer("region_obj", - obj_desc->field.region_obj); - break; - - case ACPI_TYPE_LOCAL_BANK_FIELD: - acpi_ex_out_integer("Value", - obj_desc->bank_field.value); - acpi_ex_out_pointer("region_obj", - obj_desc->bank_field.region_obj); - acpi_ex_out_pointer("bank_obj", - obj_desc->bank_field.bank_obj); - break; - - case ACPI_TYPE_LOCAL_INDEX_FIELD: - acpi_ex_out_integer("Value", - obj_desc->index_field.value); - acpi_ex_out_pointer("Index", - obj_desc->index_field.index_obj); - acpi_ex_out_pointer("Data", - obj_desc->index_field.data_obj); - break; - - default: - /* All object types covered above */ - break; - } - break; - - case ACPI_TYPE_LOCAL_REFERENCE: - - acpi_ex_out_integer("target_type", - obj_desc->reference.target_type); - acpi_ex_out_string("Opcode", - (acpi_ps_get_opcode_info - (obj_desc->reference.opcode))->name); - acpi_ex_out_integer("Offset", obj_desc->reference.offset); - acpi_ex_out_pointer("obj_desc", obj_desc->reference.object); - acpi_ex_out_pointer("Node", obj_desc->reference.node); - acpi_ex_out_pointer("Where", obj_desc->reference.where); - - acpi_ex_dump_reference(obj_desc); - break; - - case ACPI_TYPE_LOCAL_ADDRESS_HANDLER: - - acpi_ex_out_integer("space_id", - obj_desc->address_space.space_id); - acpi_ex_out_pointer("Next", obj_desc->address_space.next); - acpi_ex_out_pointer("region_list", - obj_desc->address_space.region_list); - acpi_ex_out_pointer("Node", obj_desc->address_space.node); - acpi_ex_out_pointer("Context", obj_desc->address_space.context); - break; + if (obj_desc->common.type > ACPI_TYPE_NS_NODE_MAX) { + return_VOID; + } - case ACPI_TYPE_LOCAL_NOTIFY: + /* Common Fields */ - acpi_ex_out_pointer("Node", obj_desc->notify.node); - acpi_ex_out_pointer("Context", obj_desc->notify.context); - break; + acpi_ex_dump_object(obj_desc, acpi_ex_dump_common); - case ACPI_TYPE_LOCAL_ALIAS: - case ACPI_TYPE_LOCAL_METHOD_ALIAS: - case ACPI_TYPE_LOCAL_EXTRA: - case ACPI_TYPE_LOCAL_DATA: - default: - - acpi_os_printf - ("ex_dump_object_descriptor: Display not implemented for object type %s\n", - acpi_ut_get_object_type_name(obj_desc)); - break; - } + /* Object-specific fields */ + acpi_ex_dump_object(obj_desc, acpi_ex_dump_info[obj_desc->common.type]); return_VOID; } -#endif /* ACPI_FUTURE_USAGE */ #endif diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c index 1899ab251393..00a25f8188f4 100644 --- a/drivers/acpi/executer/exmisc.c +++ b/drivers/acpi/executer/exmisc.c @@ -45,6 +45,7 @@ #include #include #include +#include #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME("exmisc") @@ -157,40 +158,52 @@ acpi_ex_concat_template(union acpi_operand_object *operand0, union acpi_operand_object **actual_return_desc, struct acpi_walk_state *walk_state) { + acpi_status status; union acpi_operand_object *return_desc; u8 *new_buf; - u8 *end_tag1; - u8 *end_tag2; + u8 *end_tag; + acpi_size length0; acpi_size length1; - acpi_size length2; ACPI_FUNCTION_TRACE("ex_concat_template"); - /* Find the end_tags in each resource template */ + /* + * Find the end_tag descriptor in each resource template. + * Note: returned pointers point TO the end_tag, not past it. + * + * Compute the length of each resource template + */ + status = acpi_ut_get_resource_end_tag(operand0, &end_tag); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } - end_tag1 = acpi_ut_get_resource_end_tag(operand0); - end_tag2 = acpi_ut_get_resource_end_tag(operand1); - if (!end_tag1 || !end_tag2) { - return_ACPI_STATUS(AE_AML_OPERAND_TYPE); + length0 = ACPI_PTR_DIFF(end_tag, operand0->buffer.pointer); + + status = acpi_ut_get_resource_end_tag(operand1, &end_tag); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - /* Compute the length of each part */ + /* Include the end_tag in the second template length */ - length1 = ACPI_PTR_DIFF(end_tag1, operand0->buffer.pointer); - length2 = ACPI_PTR_DIFF(end_tag2, operand1->buffer.pointer) + 2; /* Size of END_TAG */ + length1 = ACPI_PTR_DIFF(end_tag, operand1->buffer.pointer) + + sizeof(struct aml_resource_end_tag); /* Create a new buffer object for the result */ - return_desc = acpi_ut_create_buffer_object(length1 + length2); + return_desc = acpi_ut_create_buffer_object(length0 + length1); if (!return_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } - /* Copy the templates to the new descriptor */ - + /* + * Copy the templates to the new buffer, 0 first, then 1 follows. One + * end_tag descriptor is copied from Operand1. + */ new_buf = return_desc->buffer.pointer; - ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length1); - ACPI_MEMCPY(new_buf + length1, operand1->buffer.pointer, length2); + ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length0); + ACPI_MEMCPY(new_buf + length0, operand1->buffer.pointer, length1); /* Compute the new checksum */ @@ -198,7 +211,7 @@ acpi_ex_concat_template(union acpi_operand_object *operand0, acpi_ut_generate_checksum(return_desc->buffer.pointer, (return_desc->buffer.length - 1)); - /* Return the completed template descriptor */ + /* Return the completed resource template */ *actual_return_desc = return_desc; return_ACPI_STATUS(AE_OK); diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c index c07b046659ff..8167af1fa57b 100644 --- a/drivers/acpi/namespace/nsxfeval.c +++ b/drivers/acpi/namespace/nsxfeval.c @@ -399,7 +399,7 @@ acpi_walk_namespace(acpi_object_type type, /* Parameter validation */ - if ((type > ACPI_TYPE_EXTERNAL_MAX) || (!max_depth) || (!user_function)) { + if ((type > ACPI_TYPE_LOCAL_MAX) || (!max_depth) || (!user_function)) { return_ACPI_STATUS(AE_BAD_PARAMETER); } diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c index c29d3a447278..eca7439ee9da 100644 --- a/drivers/acpi/resources/rscalc.c +++ b/drivers/acpi/resources/rscalc.c @@ -299,13 +299,14 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) /* Point to the next object */ - resource = ACPI_PTR_ADD(struct acpi_resource, - resource, resource->length); + resource = + ACPI_PTR_ADD(struct acpi_resource, resource, + resource->length); } - /* Did not find an END_TAG descriptor */ + /* Did not find an end_tag resource descriptor */ - return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); + return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); } /******************************************************************************* @@ -328,185 +329,155 @@ acpi_status acpi_rs_get_list_length(u8 * aml_buffer, u32 aml_buffer_length, acpi_size * size_needed) { + acpi_status status; + u8 *end_aml; u8 *buffer; - struct acpi_resource_info *resource_info; u32 buffer_size = 0; - u32 bytes_parsed = 0; - u8 resource_type; u16 temp16; u16 resource_length; - u16 header_length; u32 extra_struct_bytes; + u8 resource_index; + u8 minimum_aml_resource_length; ACPI_FUNCTION_TRACE("rs_get_list_length"); - while (bytes_parsed < aml_buffer_length) { - /* The next byte in the stream is the resource descriptor type */ + end_aml = aml_buffer + aml_buffer_length; - resource_type = acpi_ut_get_resource_type(aml_buffer); + /* Walk the list of AML resource descriptors */ - /* Get the base stream size and structure sizes for the descriptor */ + while (aml_buffer < end_aml) { + /* Validate the Resource Type and Resource Length */ - resource_info = acpi_rs_get_resource_info(resource_type); - if (!resource_info) { - return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); + status = acpi_ut_validate_resource(aml_buffer, &resource_index); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - /* Get the Length field from the input resource descriptor */ + /* Get the resource length and base (minimum) AML size */ resource_length = acpi_ut_get_resource_length(aml_buffer); + minimum_aml_resource_length = + acpi_gbl_resource_aml_sizes[resource_index]; - /* Augment the size for descriptors with optional fields */ - + /* + * Augment the size for descriptors with optional + * and/or variable length fields + */ extra_struct_bytes = 0; + buffer = + aml_buffer + acpi_ut_get_resource_header_length(aml_buffer); - if (!(resource_type & ACPI_RESOURCE_NAME_LARGE)) { + switch (acpi_ut_get_resource_type(aml_buffer)) { + case ACPI_RESOURCE_NAME_IRQ: /* - * Small resource descriptors + * IRQ Resource: + * Get the number of bits set in the 16-bit IRQ mask */ - header_length = - sizeof(struct aml_resource_small_header); - buffer = aml_buffer + header_length; - - switch (resource_type) { - case ACPI_RESOURCE_NAME_IRQ: - /* - * IRQ Resource: - * Get the number of bits set in the IRQ word - */ - ACPI_MOVE_16_TO_16(&temp16, buffer); - extra_struct_bytes = - (acpi_rs_count_set_bits(temp16) * - sizeof(u32)); - break; - - case ACPI_RESOURCE_NAME_DMA: - /* - * DMA Resource: - * Get the number of bits set in the DMA channels byte - */ - ACPI_MOVE_16_TO_16(&temp16, buffer); - extra_struct_bytes = - (acpi_rs_count_set_bits(temp16) * - sizeof(u32)); - break; - - case ACPI_RESOURCE_NAME_VENDOR_SMALL: - /* - * Vendor Specific Resource: - * Ensure a 32-bit boundary for the structure - */ - extra_struct_bytes = - ACPI_ROUND_UP_to_32_bITS(resource_length); - break; + ACPI_MOVE_16_TO_16(&temp16, buffer); + extra_struct_bytes = + acpi_rs_count_set_bits(temp16) * sizeof(u32); + break; - case ACPI_RESOURCE_NAME_END_TAG: - /* - * End Tag: - * Terminate the loop now - */ - aml_buffer_length = bytes_parsed; - break; + case ACPI_RESOURCE_NAME_DMA: + /* + * DMA Resource: + * Get the number of bits set in the 8-bit DMA mask + */ + extra_struct_bytes = + acpi_rs_count_set_bits(*buffer) * sizeof(u32); + break; - default: - break; - } - } else { + case ACPI_RESOURCE_NAME_VENDOR_SMALL: /* - * Large resource descriptors + * Vendor Resource: + * Ensure a 32-bit boundary for the structure */ - header_length = - sizeof(struct aml_resource_large_header); - buffer = aml_buffer + header_length; + extra_struct_bytes = + ACPI_ROUND_UP_to_32_bITS(resource_length) - + resource_length; + break; - switch (resource_type) { - case ACPI_RESOURCE_NAME_VENDOR_LARGE: - /* - * Vendor Defined Resource: - * Add vendor data and ensure a 32-bit boundary for the structure - */ - extra_struct_bytes = - ACPI_ROUND_UP_to_32_bITS(resource_length); - break; + case ACPI_RESOURCE_NAME_END_TAG: + /* + * End Tag: This is the normal exit + */ + *size_needed = buffer_size; + return_ACPI_STATUS(AE_OK); - case ACPI_RESOURCE_NAME_ADDRESS32: - case ACPI_RESOURCE_NAME_ADDRESS16: - /* - * 32-Bit or 16-bit Address Resource: - * Add the size of any optional data (resource_source) - */ - extra_struct_bytes = - acpi_rs_stream_option_length - (resource_length, - resource_info-> - minimum_aml_resource_length); - break; - - case ACPI_RESOURCE_NAME_EXTENDED_IRQ: - /* - * Extended IRQ: - * Point past the interrupt_vector_flags to get the - * interrupt_table_length. - */ - buffer++; + case ACPI_RESOURCE_NAME_VENDOR_LARGE: + /* + * Vendor Resource: + * Add vendor data and ensure a 32-bit boundary for the structure + */ + extra_struct_bytes = + ACPI_ROUND_UP_to_32_bITS(resource_length) - + resource_length; + break; - /* - * Add 4 bytes for each additional interrupt. Note: at least one - * interrupt is required and is included in the minimum - * descriptor size - */ - extra_struct_bytes = - ((*buffer - 1) * sizeof(u32)); + case ACPI_RESOURCE_NAME_ADDRESS32: + case ACPI_RESOURCE_NAME_ADDRESS16: + /* + * 32-Bit or 16-bit Address Resource: + * Add the size of any optional data (resource_source) + */ + extra_struct_bytes = + acpi_rs_stream_option_length(resource_length, + minimum_aml_resource_length); + break; - /* Add the size of any optional data (resource_source) */ + case ACPI_RESOURCE_NAME_EXTENDED_IRQ: + /* + * Extended IRQ: + * Point past the interrupt_vector_flags to get the + * interrupt_table_length. + */ + buffer++; + + extra_struct_bytes = + /* + * Add 4 bytes for each additional interrupt. Note: at + * least one interrupt is required and is included in + * the minimum descriptor size + */ + ((*buffer - 1) * sizeof(u32)) + + /* Add the size of any optional data (resource_source) */ + acpi_rs_stream_option_length(resource_length - + extra_struct_bytes, + minimum_aml_resource_length); + break; - extra_struct_bytes += - acpi_rs_stream_option_length(resource_length - - - extra_struct_bytes, - resource_info-> - minimum_aml_resource_length); - break; + case ACPI_RESOURCE_NAME_ADDRESS64: + /* + * 64-Bit Address Resource: + * Add the size of any optional data (resource_source) + * Ensure a 64-bit boundary for the structure + */ + extra_struct_bytes = + ACPI_ROUND_UP_to_64_bITS + (acpi_rs_stream_option_length + (resource_length, minimum_aml_resource_length)); + break; - case ACPI_RESOURCE_NAME_ADDRESS64: - /* - * 64-Bit Address Resource: - * Add the size of any optional data (resource_source) - * Ensure a 64-bit boundary for the structure - */ - extra_struct_bytes = - ACPI_ROUND_UP_to_64_bITS - (acpi_rs_stream_option_length - (resource_length, - resource_info-> - minimum_aml_resource_length)); - break; - - default: - break; - } + default: + break; } /* Update the required buffer size for the internal descriptor structs */ - temp16 = - (u16) (resource_info->minimum_internal_struct_length + - extra_struct_bytes); + temp16 = (u16) (acpi_gbl_resource_struct_sizes[resource_index] + + extra_struct_bytes); buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16); /* - * Update byte count and point to the next resource within the stream + * Point to the next resource within the stream * using the size of the header plus the length contained in the header */ - temp16 = (u16) (header_length + resource_length); - bytes_parsed += temp16; - aml_buffer += temp16; + aml_buffer += acpi_ut_get_descriptor_length(aml_buffer); } - /* This is the data the caller needs */ + /* Did not find an end_tag resource descriptor */ - *size_needed = buffer_size; - return_ACPI_STATUS(AE_OK); + return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); } /******************************************************************************* diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c index 27172a3d55d7..f617ca80c5a6 100644 --- a/drivers/acpi/resources/rsdump.c +++ b/drivers/acpi/resources/rsdump.c @@ -324,7 +324,7 @@ static struct acpi_rsdump_info acpi_rs_dump_general_flags[5] = { static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = { {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags), - "Resource Type", "Memory Range"}, + "Resource Type", (void *)"Memory Range"}, {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect), "Write Protect", acpi_gbl_RWdecode}, {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching), @@ -337,7 +337,7 @@ static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = { static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = { {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags), - "Resource Type", "I/O Range"}, + "Resource Type", (void *)"I/O Range"}, {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type), "Range Type", acpi_gbl_RNGdecode}, {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation), @@ -372,8 +372,8 @@ static struct acpi_rsdump_info acpi_rs_dump_prt[5] = { static void acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) { - void *target = NULL; - void *previous_target; + u8 *target = NULL; + u8 *previous_target; char *name; u8 count; @@ -399,43 +399,49 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) /* Strings */ case ACPI_RSD_LITERAL: - acpi_rs_out_string(name, (char *)table->pointer); + acpi_rs_out_string(name, + ACPI_CAST_PTR(char, table->pointer)); break; case ACPI_RSD_STRING: - acpi_rs_out_string(name, (char *)target); + acpi_rs_out_string(name, ACPI_CAST_PTR(char, target)); break; /* Data items, 8/16/32/64 bit */ case ACPI_RSD_UINT8: - acpi_rs_out_integer8(name, *(u8 *) target); + acpi_rs_out_integer8(name, *ACPI_CAST_PTR(u8, target)); break; case ACPI_RSD_UINT16: - acpi_rs_out_integer16(name, *(u16 *) target); + acpi_rs_out_integer16(name, + *ACPI_CAST_PTR(u16, target)); break; case ACPI_RSD_UINT32: - acpi_rs_out_integer32(name, *(u32 *) target); + acpi_rs_out_integer32(name, + *ACPI_CAST_PTR(u32, target)); break; case ACPI_RSD_UINT64: - acpi_rs_out_integer64(name, *(u64 *) target); + acpi_rs_out_integer64(name, + *ACPI_CAST_PTR(u64, target)); break; /* Flags: 1-bit and 2-bit flags supported */ case ACPI_RSD_1BITFLAG: - acpi_rs_out_string(name, (char *) - ((const char **)table-> - pointer)[(*(u8 *) target) & 0x01]); + acpi_rs_out_string(name, ACPI_CAST_PTR(char, + table-> + pointer[*target & + 0x01])); break; case ACPI_RSD_2BITFLAG: - acpi_rs_out_string(name, (char *) - ((const char **)table-> - pointer)[(*(u8 *) target) & 0x03]); + acpi_rs_out_string(name, ACPI_CAST_PTR(char, + table-> + pointer[*target & + 0x03])); break; case ACPI_RSD_SHORTLIST: @@ -445,10 +451,8 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) */ if (previous_target) { acpi_rs_out_title(name); - acpi_rs_dump_short_byte_list(* - ((u8 *) - previous_target), - (u8 *) target); + acpi_rs_dump_short_byte_list(*previous_target, + target); } break; @@ -458,10 +462,9 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) * Note: The list length is obtained from the previous table entry */ if (previous_target) { - acpi_rs_dump_byte_list(* - ((u16 *) - previous_target), - (u8 *) target); + acpi_rs_dump_byte_list(*ACPI_CAST_PTR + (u16, previous_target), + target); } break; @@ -471,10 +474,9 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) * Note: The list length is obtained from the previous table entry */ if (previous_target) { - acpi_rs_dump_dword_list(* - ((u8 *) - previous_target), - (u32 *) target); + acpi_rs_dump_dword_list(*previous_target, + ACPI_CAST_PTR(u32, + target)); } break; @@ -482,17 +484,19 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) /* * Common flags for all Address resources */ - acpi_rs_dump_address_common((union acpi_resource_data *) - target); + acpi_rs_dump_address_common(ACPI_CAST_PTR + (union acpi_resource_data, + target)); break; case ACPI_RSD_SOURCE: /* * Optional resource_source for Address resources */ - acpi_rs_dump_resource_source((struct - acpi_resource_source *) - target); + acpi_rs_dump_resource_source(ACPI_CAST_PTR + (struct + acpi_resource_source, + target)); break; default: diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/resources/rsinfo.c index 973fc2834cbb..623b06689336 100644 --- a/drivers/acpi/resources/rsinfo.c +++ b/drivers/acpi/resources/rsinfo.c @@ -80,7 +80,9 @@ struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[] = { /* Dispatch tables for AML-to-resource (Get Resource) conversion functions */ -struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[] = { +struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[] = { + /* Small descriptors */ + NULL, /* 0x00, Reserved */ NULL, /* 0x01, Reserved */ NULL, /* 0x02, Reserved */ @@ -96,10 +98,10 @@ struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[] = { NULL, /* 0x0C, Reserved */ NULL, /* 0x0D, Reserved */ acpi_rs_get_vendor_small, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */ - acpi_rs_convert_end_tag /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ -}; + acpi_rs_convert_end_tag, /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ + + /* Large descriptors */ -struct acpi_rsconvert_info *acpi_gbl_lg_get_resource_dispatch[] = { NULL, /* 0x00, Reserved */ acpi_rs_convert_memory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */ acpi_rs_convert_generic_reg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */ @@ -138,7 +140,6 @@ struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[] = { acpi_rs_dump_ext_irq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ acpi_rs_dump_generic_reg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ }; - #endif #endif /* ACPI_FUTURE_USAGE */ /* @@ -166,62 +167,38 @@ const u8 acpi_gbl_aml_resource_sizes[] = { sizeof(struct aml_resource_generic_register) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ }; -/* Macros used in the tables below */ +const u8 acpi_gbl_resource_struct_sizes[] = { + /* Small descriptors */ -#define ACPI_RLARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header)) -#define ACPI_RSMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header)) + 0, + 0, + 0, + 0, + ACPI_RS_SIZE(struct acpi_resource_irq), + ACPI_RS_SIZE(struct acpi_resource_dma), + ACPI_RS_SIZE(struct acpi_resource_start_dependent), + ACPI_RS_SIZE_MIN, + ACPI_RS_SIZE(struct acpi_resource_io), + ACPI_RS_SIZE(struct acpi_resource_fixed_io), + 0, + 0, + 0, + 0, + ACPI_RS_SIZE(struct acpi_resource_vendor), + ACPI_RS_SIZE_MIN, -/* - * Base sizes of resource descriptors, both the AML stream resource length - * (minus size of header and length fields),and the size of the internal - * struct representation. - */ -struct acpi_resource_info acpi_gbl_sm_resource_info[] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - {2, ACPI_RSMALL(struct aml_resource_irq), - ACPI_RS_SIZE(struct acpi_resource_irq)}, - {0, ACPI_RSMALL(struct aml_resource_dma), - ACPI_RS_SIZE(struct acpi_resource_dma)}, - {2, ACPI_RSMALL(struct aml_resource_start_dependent), - ACPI_RS_SIZE(struct acpi_resource_start_dependent)}, - {0, ACPI_RSMALL(struct aml_resource_end_dependent), ACPI_RS_SIZE_MIN}, - {0, ACPI_RSMALL(struct aml_resource_io), - ACPI_RS_SIZE(struct acpi_resource_io)}, - {0, ACPI_RSMALL(struct aml_resource_fixed_io), - ACPI_RS_SIZE(struct acpi_resource_fixed_io)}, - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - {1, ACPI_RSMALL(struct aml_resource_vendor_small), - ACPI_RS_SIZE(struct acpi_resource_vendor)}, - {0, ACPI_RSMALL(struct aml_resource_end_tag), ACPI_RS_SIZE_MIN} -}; + /* Large descriptors */ -struct acpi_resource_info acpi_gbl_lg_resource_info[] = { - {0, 0, 0}, - {0, ACPI_RLARGE(struct aml_resource_memory24), - ACPI_RS_SIZE(struct acpi_resource_memory24)}, - {0, ACPI_RLARGE(struct aml_resource_generic_register), - ACPI_RS_SIZE(struct acpi_resource_generic_register)}, - {0, 0, 0}, - {1, ACPI_RLARGE(struct aml_resource_vendor_large), - ACPI_RS_SIZE(struct acpi_resource_vendor)}, - {0, ACPI_RLARGE(struct aml_resource_memory32), - ACPI_RS_SIZE(struct acpi_resource_memory32)}, - {0, ACPI_RLARGE(struct aml_resource_fixed_memory32), - ACPI_RS_SIZE(struct acpi_resource_fixed_memory32)}, - {1, ACPI_RLARGE(struct aml_resource_address32), - ACPI_RS_SIZE(struct acpi_resource_address32)}, - {1, ACPI_RLARGE(struct aml_resource_address16), - ACPI_RS_SIZE(struct acpi_resource_address16)}, - {1, ACPI_RLARGE(struct aml_resource_extended_irq), - ACPI_RS_SIZE(struct acpi_resource_extended_irq)}, - {1, ACPI_RLARGE(struct aml_resource_address64), - ACPI_RS_SIZE(struct acpi_resource_address64)}, - {0, ACPI_RLARGE(struct aml_resource_extended_address64), - ACPI_RS_SIZE(struct acpi_resource_extended_address64)} + 0, + ACPI_RS_SIZE(struct acpi_resource_memory24), + ACPI_RS_SIZE(struct acpi_resource_generic_register), + 0, + ACPI_RS_SIZE(struct acpi_resource_vendor), + ACPI_RS_SIZE(struct acpi_resource_memory32), + ACPI_RS_SIZE(struct acpi_resource_fixed_memory32), + ACPI_RS_SIZE(struct acpi_resource_address32), + ACPI_RS_SIZE(struct acpi_resource_address16), + ACPI_RS_SIZE(struct acpi_resource_extended_irq), + ACPI_RS_SIZE(struct acpi_resource_address64), + ACPI_RS_SIZE(struct acpi_resource_extended_address64) }; diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c index ee17ef3315f8..b83996233c1d 100644 --- a/drivers/acpi/resources/rslist.c +++ b/drivers/acpi/resources/rslist.c @@ -47,115 +47,12 @@ #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME("rslist") -/* Local prototypes */ -static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8 - resource_type); - -static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml); - -/******************************************************************************* - * - * FUNCTION: acpi_rs_validate_resource_length - * - * PARAMETERS: Aml - Pointer to the AML resource descriptor - * - * RETURN: Status - AE_OK if the resource length appears valid - * - * DESCRIPTION: Validate the resource_length. Fixed-length descriptors must - * have the exact length; variable-length descriptors must be - * at least as long as the minimum. Certain Small descriptors - * can vary in size by at most one byte. - * - ******************************************************************************/ - -static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml) -{ - struct acpi_resource_info *resource_info; - u16 minimum_aml_resource_length; - u16 resource_length; - - ACPI_FUNCTION_ENTRY(); - - /* Get the size and type info about this resource descriptor */ - - resource_info = - acpi_rs_get_resource_info(aml->small_header.descriptor_type); - if (!resource_info) { - return (AE_AML_INVALID_RESOURCE_TYPE); - } - - resource_length = acpi_ut_get_resource_length(aml); - minimum_aml_resource_length = - resource_info->minimum_aml_resource_length; - - /* Validate based upon the type of resource, fixed length or variable */ - - if (resource_info->length_type == ACPI_FIXED_LENGTH) { - /* Fixed length resource, length must match exactly */ - - if (resource_length != minimum_aml_resource_length) { - return (AE_AML_BAD_RESOURCE_LENGTH); - } - } else if (resource_info->length_type == ACPI_VARIABLE_LENGTH) { - /* Variable length resource, must be at least the minimum */ - - if (resource_length < minimum_aml_resource_length) { - return (AE_AML_BAD_RESOURCE_LENGTH); - } - } else { - /* Small variable length resource, allowed to be (Min) or (Min-1) */ - - if ((resource_length > minimum_aml_resource_length) || - (resource_length < (minimum_aml_resource_length - 1))) { - return (AE_AML_BAD_RESOURCE_LENGTH); - } - } - - return (AE_OK); -} - -/******************************************************************************* - * - * FUNCTION: acpi_rs_get_conversion_info - * - * PARAMETERS: resource_type - Byte 0 of a resource descriptor - * - * RETURN: Pointer to the resource conversion info table - * - * DESCRIPTION: Get the conversion table associated with this resource type - * - ******************************************************************************/ - -static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8 resource_type) -{ - ACPI_FUNCTION_ENTRY(); - - /* Determine if this is a small or large resource */ - - if (resource_type & ACPI_RESOURCE_NAME_LARGE) { - /* Large Resource Type -- bits 6:0 contain the name */ - - if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { - return (NULL); - } - - return (acpi_gbl_lg_get_resource_dispatch[(resource_type & - ACPI_RESOURCE_NAME_LARGE_MASK)]); - } else { - /* Small Resource Type -- bits 6:3 contain the name */ - - return (acpi_gbl_sm_get_resource_dispatch[((resource_type & - ACPI_RESOURCE_NAME_SMALL_MASK) - >> 3)]); - } -} - /******************************************************************************* * * FUNCTION: acpi_rs_convert_aml_to_resources * - * PARAMETERS: aml_buffer - Pointer to the resource byte stream - * aml_buffer_length - Length of aml_buffer + * PARAMETERS: Aml - Pointer to the resource byte stream + * aml_length - Length of Aml * output_buffer - Pointer to the buffer that will * contain the output structures * @@ -165,42 +62,24 @@ static struct acpi_rsconvert_info *acpi_rs_get_conversion_info(u8 resource_type) * linked list of resources in the caller's output buffer * ******************************************************************************/ - acpi_status -acpi_rs_convert_aml_to_resources(u8 * aml_buffer, - u32 aml_buffer_length, u8 * output_buffer) +acpi_rs_convert_aml_to_resources(u8 * aml, u32 aml_length, u8 * output_buffer) { - u8 *buffer = output_buffer; + struct acpi_resource *resource = (void *)output_buffer; acpi_status status; - acpi_size bytes_parsed = 0; - struct acpi_resource *resource; - acpi_rsdesc_size descriptor_length; - struct acpi_rsconvert_info *info; + u8 resource_index; + u8 *end_aml; ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources"); - /* Loop until end-of-buffer or an end_tag is found */ - - while (bytes_parsed < aml_buffer_length) { - /* Get the conversion table associated with this Descriptor Type */ - - info = acpi_rs_get_conversion_info(*aml_buffer); - if (!info) { - /* No table indicates an invalid resource type */ + end_aml = aml + aml_length; - return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); - } + /* Loop until end-of-buffer or an end_tag is found */ - descriptor_length = acpi_ut_get_descriptor_length(aml_buffer); + while (aml < end_aml) { + /* Validate the Resource Type and Resource Length */ - /* - * Perform limited validation of the resource length, based upon - * what we know about the resource type - */ - status = - acpi_rs_validate_resource_length(ACPI_CAST_PTR - (union aml_resource, - aml_buffer)); + status = acpi_ut_validate_resource(aml, &resource_index); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -208,42 +87,36 @@ acpi_rs_convert_aml_to_resources(u8 * aml_buffer, /* Convert the AML byte stream resource to a local resource struct */ status = - acpi_rs_convert_aml_to_resource(ACPI_CAST_PTR - (struct acpi_resource, - buffer), + acpi_rs_convert_aml_to_resource(resource, ACPI_CAST_PTR(union aml_resource, - aml_buffer), - info); + aml), + acpi_gbl_get_resource_dispatch + [resource_index]); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not convert AML resource (type %X) to resource, %s\n", *aml_buffer, acpi_format_exception(status))); + ACPI_REPORT_ERROR(("Could not convert AML resource (Type %X) to resource, %s\n", *aml, acpi_format_exception(status))); return_ACPI_STATUS(status); } - /* Set the aligned length of the new resource descriptor */ - - resource = ACPI_CAST_PTR(struct acpi_resource, buffer); - resource->length = - (u32) ACPI_ALIGN_RESOURCE_SIZE(resource->length); - /* Normal exit on completion of an end_tag resource descriptor */ - if (acpi_ut_get_resource_type(aml_buffer) == + if (acpi_ut_get_resource_type(aml) == ACPI_RESOURCE_NAME_END_TAG) { return_ACPI_STATUS(AE_OK); } - /* Update counter and point to the next input resource */ + /* Point to the next input AML resource */ - bytes_parsed += descriptor_length; - aml_buffer += descriptor_length; + aml += acpi_ut_get_descriptor_length(aml); /* Point to the next structure in the output buffer */ - buffer += resource->length; + resource = + ACPI_PTR_ADD(struct acpi_resource, resource, + resource->length); } - /* Completed buffer, but did not find an end_tag resource descriptor */ + /* Did not find an end_tag resource descriptor */ return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); } @@ -271,16 +144,16 @@ acpi_status acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, acpi_size aml_size_needed, u8 * output_buffer) { - u8 *aml_buffer = output_buffer; - u8 *end_aml_buffer = output_buffer + aml_size_needed; + u8 *aml = output_buffer; + u8 *end_aml = output_buffer + aml_size_needed; acpi_status status; ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml"); /* Walk the resource descriptor list, convert each descriptor */ - while (aml_buffer < end_aml_buffer) { - /* Validate the Resource Type */ + while (aml < end_aml) { + /* Validate the (internal) Resource Type */ if (resource->type > ACPI_RESOURCE_TYPE_MAX) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, @@ -294,7 +167,7 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, status = acpi_rs_convert_resource_to_aml(resource, ACPI_CAST_PTR(union aml_resource, - aml_buffer), + aml), acpi_gbl_set_resource_dispatch [resource->type]); if (ACPI_FAILURE(status)) { @@ -305,9 +178,8 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, /* Perform final sanity check on the new AML resource descriptor */ status = - acpi_rs_validate_resource_length(ACPI_CAST_PTR - (union aml_resource, - aml_buffer)); + acpi_ut_validate_resource(ACPI_CAST_PTR + (union aml_resource, aml), NULL); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } @@ -322,18 +194,15 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, /* * Extract the total length of the new descriptor and set the - * aml_buffer to point to the next (output) resource descriptor + * Aml to point to the next (output) resource descriptor */ - aml_buffer += acpi_ut_get_descriptor_length(aml_buffer); + aml += acpi_ut_get_descriptor_length(aml); /* Point to the next input resource descriptor */ resource = ACPI_PTR_ADD(struct acpi_resource, resource, resource->length); - - /* Check for end-of-list, normal exit */ - } /* Completed buffer, but did not find an end_tag resource descriptor */ diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c index 7613033f5dcf..a1eac0f1df54 100644 --- a/drivers/acpi/resources/rsutils.c +++ b/drivers/acpi/resources/rsutils.c @@ -65,6 +65,8 @@ u8 acpi_rs_decode_bitmask(u16 mask, u8 * list) acpi_native_uint i; u8 bit_count; + ACPI_FUNCTION_ENTRY(); + /* Decode the mask bits */ for (i = 0, bit_count = 0; mask; i++) { @@ -97,6 +99,8 @@ u16 acpi_rs_encode_bitmask(u8 * list, u8 count) acpi_native_uint i; u16 mask; + ACPI_FUNCTION_ENTRY(); + /* Encode the list into a single bitmask */ for (i = 0, mask = 0; i < count; i++) { @@ -128,6 +132,8 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) { acpi_native_uint i; + ACPI_FUNCTION_ENTRY(); + /* One move per item */ for (i = 0; i < item_count; i++) { @@ -166,53 +172,6 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) } } -/******************************************************************************* - * - * FUNCTION: acpi_rs_get_resource_info - * - * PARAMETERS: resource_type - Byte 0 of a resource descriptor - * - * RETURN: Pointer to the resource conversion handler - * - * DESCRIPTION: Extract the Resource Type/Name from the first byte of - * a resource descriptor. - * - ******************************************************************************/ - -struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type) -{ - struct acpi_resource_info *size_info; - - ACPI_FUNCTION_ENTRY(); - - /* Determine if this is a small or large resource */ - - if (resource_type & ACPI_RESOURCE_NAME_LARGE) { - /* Large Resource Type -- bits 6:0 contain the name */ - - if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { - return (NULL); - } - - size_info = &acpi_gbl_lg_resource_info[(resource_type & - ACPI_RESOURCE_NAME_LARGE_MASK)]; - } else { - /* Small Resource Type -- bits 6:3 contain the name */ - - size_info = &acpi_gbl_sm_resource_info[((resource_type & - ACPI_RESOURCE_NAME_SMALL_MASK) - >> 3)]; - } - - /* Zero entry indicates an invalid resource type */ - - if (!size_info->minimum_internal_struct_length) { - return (NULL); - } - - return (size_info); -} - /******************************************************************************* * * FUNCTION: acpi_rs_set_resource_length @@ -238,25 +197,20 @@ acpi_rs_set_resource_length(acpi_rsdesc_size total_length, ACPI_FUNCTION_ENTRY(); - /* Determine if this is a small or large resource */ + /* Length is the total descriptor length minus the header length */ - if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { - /* Large Resource type -- bytes 1-2 contain the 16-bit length */ + resource_length = (acpi_rs_length) + (total_length - acpi_ut_get_resource_header_length(aml)); - resource_length = (acpi_rs_length) - (total_length - sizeof(struct aml_resource_large_header)); + /* Length is stored differently for large and small descriptors */ - /* Insert length into the Large descriptor length field */ + if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { + /* Large descriptor -- bytes 1-2 contain the 16-bit length */ ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, &resource_length); } else { - /* Small Resource type -- bits 2:0 of byte 0 contain the length */ - - resource_length = (acpi_rs_length) - (total_length - sizeof(struct aml_resource_small_header)); - - /* Insert length into the descriptor type byte */ + /* Small descriptor -- bits 2:0 of byte 0 contain the length */ aml->small_header.descriptor_type = (u8) @@ -292,7 +246,7 @@ acpi_rs_set_resource_header(u8 descriptor_type, { ACPI_FUNCTION_ENTRY(); - /* Set the Descriptor Type */ + /* Set the Resource Type */ aml->small_header.descriptor_type = descriptor_type; @@ -409,14 +363,14 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length, (char *)&aml_resource_source[1]); return ((acpi_rs_length) total_length); - } else { - /* resource_source is not present */ - - resource_source->index = 0; - resource_source->string_length = 0; - resource_source->string_ptr = NULL; - return (0); } + + /* resource_source is not present */ + + resource_source->index = 0; + resource_source->string_length = 0; + resource_source->string_ptr = NULL; + return (0); } /******************************************************************************* diff --git a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile index e87108b7338a..88eff14c4894 100644 --- a/drivers/acpi/utilities/Makefile +++ b/drivers/acpi/utilities/Makefile @@ -2,7 +2,8 @@ # Makefile for all Linux ACPI interpreter subdirectories # -obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ - utcopy.o utdelete.o utglobal.o utmath.o utobject.o utstate.o utmutex.o utobject.o utcache.o +obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ + utcopy.o utdelete.o utglobal.o utmath.o utobject.o \ + utstate.o utmutex.o utobject.o utcache.o utresrc.o EXTRA_CFLAGS += $(ACPI_CFLAGS) diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index e9058d4da122..2a9110c06391 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -43,7 +43,6 @@ #include #include -#include #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME("utmisc") @@ -789,153 +788,6 @@ u8 acpi_ut_generate_checksum(u8 * buffer, u32 length) return ((u8) (0 - sum)); } -/******************************************************************************* - * - * FUNCTION: acpi_ut_get_resource_type - * - * PARAMETERS: Aml - Pointer to the raw AML resource descriptor - * - * RETURN: The Resource Type with no extraneous bits (except the - * Large/Small descriptor bit -- this is left alone) - * - * DESCRIPTION: Extract the Resource Type/Name from the first byte of - * a resource descriptor. - * - ******************************************************************************/ - -u8 acpi_ut_get_resource_type(void *aml) -{ - ACPI_FUNCTION_ENTRY(); - - /* - * Byte 0 contains the descriptor name (Resource Type) - * Determine if this is a small or large resource - */ - if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { - /* Large Resource Type -- bits 6:0 contain the name */ - - return (*((u8 *) aml)); - } else { - /* Small Resource Type -- bits 6:3 contain the name */ - - return ((u8) (*((u8 *) aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); - } -} - -/******************************************************************************* - * - * FUNCTION: acpi_ut_get_resource_length - * - * PARAMETERS: Aml - Pointer to the raw AML resource descriptor - * - * RETURN: Byte Length - * - * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By - * definition, this does not include the size of the descriptor - * header or the length field itself. - * - ******************************************************************************/ - -u16 acpi_ut_get_resource_length(void *aml) -{ - u16 resource_length; - - ACPI_FUNCTION_ENTRY(); - - /* - * Byte 0 contains the descriptor name (Resource Type) - * Determine if this is a small or large resource - */ - if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { - /* Large Resource type -- bytes 1-2 contain the 16-bit length */ - - ACPI_MOVE_16_TO_16(&resource_length, &((u8 *) aml)[1]); - - } else { - /* Small Resource type -- bits 2:0 of byte 0 contain the length */ - - resource_length = (u16) (*((u8 *) aml) & - ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); - } - - return (resource_length); -} - -/******************************************************************************* - * - * FUNCTION: acpi_ut_get_descriptor_length - * - * PARAMETERS: Aml - Pointer to the raw AML resource descriptor - * - * RETURN: Byte length - * - * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the - * length of the descriptor header and the length field itself. - * Used to walk descriptor lists. - * - ******************************************************************************/ - -u32 acpi_ut_get_descriptor_length(void *aml) -{ - u32 descriptor_length; - - ACPI_FUNCTION_ENTRY(); - - /* First get the Resource Length (Does not include header length) */ - - descriptor_length = acpi_ut_get_resource_length(aml); - - /* Determine if this is a small or large resource */ - - if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { - descriptor_length += sizeof(struct aml_resource_large_header); - } else { - descriptor_length += sizeof(struct aml_resource_small_header); - } - - return (descriptor_length); -} - -/******************************************************************************* - * - * FUNCTION: acpi_ut_get_resource_end_tag - * - * PARAMETERS: obj_desc - The resource template buffer object - * - * RETURN: Pointer to the end tag - * - * DESCRIPTION: Find the END_TAG resource descriptor in an AML resource template - * - ******************************************************************************/ - -u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc) -{ - u8 *aml; - u8 *end_aml; - - aml = obj_desc->buffer.pointer; - end_aml = aml + obj_desc->buffer.length; - - /* Walk the resource template, one descriptor per loop */ - - while (aml < end_aml) { - if (acpi_ut_get_resource_type(aml) == - ACPI_RESOURCE_NAME_END_TAG) { - /* Found the end_tag descriptor, all done */ - - return (aml); - } - - /* Point to the next resource descriptor */ - - aml += acpi_ut_get_resource_length(aml); - } - - /* End tag was not found */ - - return (NULL); -} - /******************************************************************************* * * FUNCTION: acpi_ut_report_error diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c new file mode 100644 index 000000000000..07a314c710d8 --- /dev/null +++ b/drivers/acpi/utilities/utresrc.c @@ -0,0 +1,428 @@ +/******************************************************************************* + * + * Module Name: utresrc - Resource managment utilities + * + ******************************************************************************/ + +/* + * Copyright (C) 2000 - 2005, R. Byron Moore + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include +#include + +#define _COMPONENT ACPI_UTILITIES +ACPI_MODULE_NAME("utmisc") + +/* + * Base sizes of the raw AML resource descriptors, indexed by resource type. + * Zero indicates a reserved (and therefore invalid) resource type. + */ +const u8 acpi_gbl_resource_aml_sizes[] = { + /* Small descriptors */ + + 0, + 0, + 0, + 0, + ACPI_AML_SIZE_SMALL(struct aml_resource_irq), + ACPI_AML_SIZE_SMALL(struct aml_resource_dma), + ACPI_AML_SIZE_SMALL(struct aml_resource_start_dependent), + ACPI_AML_SIZE_SMALL(struct aml_resource_end_dependent), + ACPI_AML_SIZE_SMALL(struct aml_resource_io), + ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_io), + 0, + 0, + 0, + 0, + ACPI_AML_SIZE_SMALL(struct aml_resource_vendor_small), + ACPI_AML_SIZE_SMALL(struct aml_resource_end_tag), + + /* Large descriptors */ + + 0, + ACPI_AML_SIZE_LARGE(struct aml_resource_memory24), + ACPI_AML_SIZE_LARGE(struct aml_resource_generic_register), + 0, + ACPI_AML_SIZE_LARGE(struct aml_resource_vendor_large), + ACPI_AML_SIZE_LARGE(struct aml_resource_memory32), + ACPI_AML_SIZE_LARGE(struct aml_resource_fixed_memory32), + ACPI_AML_SIZE_LARGE(struct aml_resource_address32), + ACPI_AML_SIZE_LARGE(struct aml_resource_address16), + ACPI_AML_SIZE_LARGE(struct aml_resource_extended_irq), + ACPI_AML_SIZE_LARGE(struct aml_resource_address64), + ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64) +}; + +/* + * Resource types, used to validate the resource length field. + * The length of fixed-length types must match exactly, variable + * lengths must meet the minimum required length, etc. + * Zero indicates a reserved (and therefore invalid) resource type. + */ +static const u8 acpi_gbl_resource_types[] = { + /* Small descriptors */ + + 0, + 0, + 0, + 0, + ACPI_SMALL_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_SMALL_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + 0, + 0, + 0, + 0, + ACPI_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + + /* Large descriptors */ + + 0, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + 0, + ACPI_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH +}; + +/******************************************************************************* + * + * FUNCTION: acpi_ut_validate_resource + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * return_index - Where the resource index is returned. NULL + * if the index is not required. + * + * RETURN: Status, and optionally the Index into the global resource tables + * + * DESCRIPTION: Validate an AML resource descriptor by checking the Resource + * Type and Resource Length. Returns an index into the global + * resource information/dispatch tables for later use. + * + ******************************************************************************/ + +acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index) +{ + u8 resource_type; + u8 resource_index; + acpi_rs_length resource_length; + acpi_rs_length minimum_resource_length; + + ACPI_FUNCTION_ENTRY(); + + /* + * 1) Validate the resource_type field (Byte 0) + */ + resource_type = *((u8 *) aml); + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Examine the large/small bit in the resource header + */ + if (resource_type & ACPI_RESOURCE_NAME_LARGE) { + /* Verify the large resource type (name) against the max */ + + if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { + return (AE_AML_INVALID_RESOURCE_TYPE); + } + + /* + * Large Resource Type -- bits 6:0 contain the name + * Translate range 0x80-0x8B to index range 0x10-0x1B + */ + resource_index = (u8) (resource_type - 0x70); + } else { + /* + * Small Resource Type -- bits 6:3 contain the name + * Shift range to index range 0x00-0x0F + */ + resource_index = (u8) + ((resource_type & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3); + } + + /* Check validity of the resource type, zero indicates name is invalid */ + + if (!acpi_gbl_resource_types[resource_index]) { + return (AE_AML_INVALID_RESOURCE_TYPE); + } + + /* + * 2) Validate the resource_length field. This ensures that the length + * is at least reasonable, and guarantees that it is non-zero. + */ + resource_length = acpi_ut_get_resource_length(aml); + minimum_resource_length = acpi_gbl_resource_aml_sizes[resource_index]; + + /* Validate based upon the type of resource - fixed length or variable */ + + switch (acpi_gbl_resource_types[resource_index]) { + case ACPI_FIXED_LENGTH: + + /* Fixed length resource, length must match exactly */ + + if (resource_length != minimum_resource_length) { + return (AE_AML_BAD_RESOURCE_LENGTH); + } + break; + + case ACPI_VARIABLE_LENGTH: + + /* Variable length resource, length must be at least the minimum */ + + if (resource_length < minimum_resource_length) { + return (AE_AML_BAD_RESOURCE_LENGTH); + } + break; + + case ACPI_SMALL_VARIABLE_LENGTH: + + /* Small variable length resource, length can be (Min) or (Min-1) */ + + if ((resource_length > minimum_resource_length) || + (resource_length < (minimum_resource_length - 1))) { + return (AE_AML_BAD_RESOURCE_LENGTH); + } + break; + + default: + + /* Shouldn't happen (because of validation earlier), but be sure */ + + return (AE_AML_INVALID_RESOURCE_TYPE); + } + + /* Optionally return the resource table index */ + + if (return_index) { + *return_index = resource_index; + } + + return (AE_OK); +} + +/******************************************************************************* + * + * FUNCTION: acpi_ut_get_resource_type + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: The Resource Type with no extraneous bits (except the + * Large/Small descriptor bit -- this is left alone) + * + * DESCRIPTION: Extract the Resource Type/Name from the first byte of + * a resource descriptor. + * + ******************************************************************************/ + +u8 acpi_ut_get_resource_type(void *aml) +{ + ACPI_FUNCTION_ENTRY(); + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Examine the large/small bit in the resource header + */ + if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { + /* Large Resource Type -- bits 6:0 contain the name */ + + return (*((u8 *) aml)); + } else { + /* Small Resource Type -- bits 6:3 contain the name */ + + return ((u8) (*((u8 *) aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); + } +} + +/******************************************************************************* + * + * FUNCTION: acpi_ut_get_resource_length + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Byte Length + * + * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By + * definition, this does not include the size of the descriptor + * header or the length field itself. + * + ******************************************************************************/ + +u16 acpi_ut_get_resource_length(void *aml) +{ + acpi_rs_length resource_length; + + ACPI_FUNCTION_ENTRY(); + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Examine the large/small bit in the resource header + */ + if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { + /* Large Resource type -- bytes 1-2 contain the 16-bit length */ + + ACPI_MOVE_16_TO_16(&resource_length, &((u8 *) aml)[1]); + + } else { + /* Small Resource type -- bits 2:0 of byte 0 contain the length */ + + resource_length = (u16) (*((u8 *) aml) & + ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); + } + + return (resource_length); +} + +/******************************************************************************* + * + * FUNCTION: acpi_ut_get_resource_header_length + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Length of the AML header (depends on large/small descriptor) + * + * DESCRIPTION: Get the length of the header for this resource. + * + ******************************************************************************/ + +u8 acpi_ut_get_resource_header_length(void *aml) +{ + ACPI_FUNCTION_ENTRY(); + + /* Examine the large/small bit in the resource header */ + + if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { + return (sizeof(struct aml_resource_large_header)); + } else { + return (sizeof(struct aml_resource_small_header)); + } +} + +/******************************************************************************* + * + * FUNCTION: acpi_ut_get_descriptor_length + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Byte length + * + * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the + * length of the descriptor header and the length field itself. + * Used to walk descriptor lists. + * + ******************************************************************************/ + +u32 acpi_ut_get_descriptor_length(void *aml) +{ + ACPI_FUNCTION_ENTRY(); + + /* + * Get the Resource Length (does not include header length) and add + * the header length (depends on if this is a small or large resource) + */ + return (acpi_ut_get_resource_length(aml) + + acpi_ut_get_resource_header_length(aml)); +} + +/******************************************************************************* + * + * FUNCTION: acpi_ut_get_resource_end_tag + * + * PARAMETERS: obj_desc - The resource template buffer object + * + * RETURN: Pointer to the end tag + * + * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template + * + ******************************************************************************/ + +acpi_status +acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc, + u8 ** end_tag) +{ + acpi_status status; + u8 *aml; + u8 *end_aml; + + ACPI_FUNCTION_TRACE("ut_get_resource_end_tag"); + + /* Get start and end pointers */ + + aml = obj_desc->buffer.pointer; + end_aml = aml + obj_desc->buffer.length; + + /* Walk the resource template, one descriptor per iteration */ + + while (aml < end_aml) { + /* Validate the Resource Type and Resource Length */ + + status = acpi_ut_validate_resource(aml, NULL); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + + /* end_tag resource indicates the end of the resource template */ + + if (acpi_ut_get_resource_type(aml) == + ACPI_RESOURCE_NAME_END_TAG) { + /* Return the pointer to the end_tag */ + + *end_tag = aml; + return_ACPI_STATUS(AE_OK); + } + + /* + * Point to the next resource descriptor in the AML buffer. The + * descriptor length is guaranteed to be non-zero by resource + * validation above. + */ + aml += acpi_ut_get_descriptor_length(aml); + } + + /* Did not find an end_tag resource descriptor */ + + return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); +} diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c index c1cb27583be8..6ff1d7073349 100644 --- a/drivers/acpi/utilities/utstate.c +++ b/drivers/acpi/utilities/utstate.c @@ -63,7 +63,7 @@ acpi_status acpi_ut_create_pkg_state_and_push(void *internal_object, void *external_object, u16 index, - union acpi_generic_state ** state_list) + union acpi_generic_state **state_list) { union acpi_generic_state *state; diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c index f06bd5e5e9d1..57adc5bc02f3 100644 --- a/drivers/acpi/utilities/utxface.c +++ b/drivers/acpi/utilities/utxface.c @@ -178,10 +178,14 @@ acpi_status acpi_enable_subsystem(u32 flags) /* * Initialize ACPI Event handling (Fixed and General Purpose) * - * NOTE: We must have the hardware AND events initialized before we can - * execute ANY control methods SAFELY. Any control method can require - * ACPI hardware support, so the hardware MUST be initialized before - * execution! + * Note1: We must have the hardware and events initialized before we can + * execute any control methods safely. Any control method can require + * ACPI hardware support, so the hardware must be fully initialized before + * any method execution! + * + * Note2: Fixed events are initialized and enabled here. GPEs are + * initialized, but cannot be enabled until after the hardware is + * completely initialized (SCI and global_lock activated) */ if (!(flags & ACPI_NO_EVENT_INIT)) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, @@ -193,8 +197,10 @@ acpi_status acpi_enable_subsystem(u32 flags) } } - /* Install the SCI handler and Global Lock handler */ - + /* + * Install the SCI handler and Global Lock handler. This completes the + * hardware initialization. + */ if (!(flags & ACPI_NO_HANDLER_INIT)) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[Init] Installing SCI/GL handlers\n")); @@ -205,6 +211,24 @@ acpi_status acpi_enable_subsystem(u32 flags) } } + /* + * Complete the GPE initialization for the GPE blocks defined in the FADT + * (GPE block 0 and 1). + * + * Note1: This is where the _PRW methods are executed for the GPEs. These + * methods can only be executed after the SCI and Global Lock handlers are + * installed and initialized. + * + * Note2: Currently, there seems to be no need to run the _REG methods + * before execution of the _PRW methods and enabling of the GPEs. + */ + if (!(flags & ACPI_NO_EVENT_INIT)) { + status = acpi_ev_install_fadt_gpes(); + if (ACPI_FAILURE(status)) { + return (status); + } + } + return_ACPI_STATUS(status); } @@ -230,9 +254,9 @@ acpi_status acpi_initialize_objects(u32 flags) /* * Run all _REG methods * - * NOTE: Any objects accessed - * by the _REG methods will be automatically initialized, even if they - * contain executable AML (see call to acpi_ns_initialize_objects below). + * Note: Any objects accessed by the _REG methods will be automatically + * initialized, even if they contain executable AML (see the call to + * acpi_ns_initialize_objects below). */ if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, @@ -245,9 +269,9 @@ acpi_status acpi_initialize_objects(u32 flags) } /* - * Initialize the objects that remain uninitialized. This - * runs the executable AML that may be part of the declaration of these - * objects: operation_regions, buffer_fields, Buffers, and Packages. + * Initialize the objects that remain uninitialized. This runs the + * executable AML that may be part of the declaration of these objects: + * operation_regions, buffer_fields, Buffers, and Packages. */ if (!(flags & ACPI_NO_OBJECT_INIT)) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, @@ -260,8 +284,8 @@ acpi_status acpi_initialize_objects(u32 flags) } /* - * Initialize all device objects in the namespace - * This runs the _STA and _INI methods. + * Initialize all device objects in the namespace. This runs the device + * _STA and _INI methods. */ if (!(flags & ACPI_NO_DEVICE_INIT)) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index 7676afec09a2..d371ec6b9812 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -63,7 +63,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20051021 +#define ACPI_CA_VERSION 0x20051102 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, diff --git a/include/acpi/acevents.h b/include/acpi/acevents.h index bfa54600ecd9..b40062c3ba7a 100644 --- a/include/acpi/acevents.h +++ b/include/acpi/acevents.h @@ -51,6 +51,8 @@ acpi_status acpi_ev_initialize_events(void); acpi_status acpi_ev_install_xrupt_handlers(void); +acpi_status acpi_ev_install_fadt_gpes(void); + u32 acpi_ev_fixed_event_detect(void); /* @@ -105,6 +107,10 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, u32 interrupt_number, struct acpi_gpe_block_info **return_gpe_block); +acpi_status +acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, + struct acpi_gpe_block_info *gpe_block); + acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block); u32 diff --git a/include/acpi/acinterp.h b/include/acpi/acinterp.h index 2c9c1a1d1b7f..87e5e44572ca 100644 --- a/include/acpi/acinterp.h +++ b/include/acpi/acinterp.h @@ -44,7 +44,49 @@ #ifndef __ACINTERP_H__ #define __ACINTERP_H__ -#define ACPI_WALK_OPERANDS (&(walk_state->operands [walk_state->num_operands -1])) +#define ACPI_WALK_OPERANDS (&(walk_state->operands [walk_state->num_operands -1])) + +/* Macros for tables used for debug output */ + +#define ACPI_EXD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_operand_object,f) +#define ACPI_EXD_NSOFFSET(f) (u8) ACPI_OFFSET (struct acpi_namespace_node,f) +#define ACPI_EXD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_exdump_info)) + +/* + * If possible, pack the following structure to byte alignment, since we + * don't care about performance for debug output + */ +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#pragma pack(1) +#endif + +typedef const struct acpi_exdump_info { + u8 opcode; + u8 offset; + char *name; + +} acpi_exdump_info; + +/* Values for the Opcode field above */ + +#define ACPI_EXD_INIT 0 +#define ACPI_EXD_TYPE 1 +#define ACPI_EXD_UINT8 2 +#define ACPI_EXD_UINT16 3 +#define ACPI_EXD_UINT32 4 +#define ACPI_EXD_UINT64 5 +#define ACPI_EXD_LITERAL 6 +#define ACPI_EXD_POINTER 7 +#define ACPI_EXD_ADDRESS 8 +#define ACPI_EXD_STRING 9 +#define ACPI_EXD_BUFFER 10 +#define ACPI_EXD_PACKAGE 11 +#define ACPI_EXD_FIELD 12 +#define ACPI_EXD_REFERENCE 13 + +/* restore default alignment */ + +#pragma pack() /* * exconvrt - object conversion @@ -327,7 +369,7 @@ acpi_ex_dump_operands(union acpi_operand_object **operands, void acpi_ex_dump_object_descriptor(union acpi_operand_object *object, u32 flags); -void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags); +void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags); #endif /* ACPI_FUTURE_USAGE */ /* diff --git a/include/acpi/acresrc.h b/include/acpi/acresrc.h index 25cff0d5ba58..2bf53940f259 100644 --- a/include/acpi/acresrc.h +++ b/include/acpi/acresrc.h @@ -101,27 +101,11 @@ typedef const struct acpi_rsconvert_info { #define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f) #define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f) -/* - * Resource dispatch and info tables - */ -typedef const struct acpi_resource_info { - u8 length_type; - u8 minimum_aml_resource_length; - u8 minimum_internal_struct_length; - -} acpi_resource_info; - -/* Types for length_type above */ - -#define ACPI_FIXED_LENGTH 0 -#define ACPI_VARIABLE_LENGTH 1 -#define ACPI_SMALL_VARIABLE_LENGTH 2 - typedef const struct acpi_rsdump_info { u8 opcode; u8 offset; char *name; - const void *pointer; + const char **pointer; } acpi_rsdump_info; @@ -153,10 +137,9 @@ extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[]; /* Resource tables indexed by raw AML resource descriptor type */ -extern struct acpi_resource_info acpi_gbl_sm_resource_info[]; -extern struct acpi_resource_info acpi_gbl_lg_resource_info[]; -extern struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[]; -extern struct acpi_rsconvert_info *acpi_gbl_lg_get_resource_dispatch[]; +extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[]; + +extern const u8 acpi_gbl_resource_struct_sizes[]; /* * rscreate @@ -272,8 +255,6 @@ void acpi_rs_set_resource_length(acpi_rsdesc_size total_length, union aml_resource *aml); -struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type); - /* * rsdump */ diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h index 7386eb81bd2a..4ff963323de3 100644 --- a/include/acpi/acutils.h +++ b/include/acpi/acutils.h @@ -44,6 +44,15 @@ #ifndef _ACUTILS_H #define _ACUTILS_H +extern const u8 acpi_gbl_resource_aml_sizes[]; + +/* Types for Resource descriptor entries */ + +#define ACPI_INVALID_RESOURCE 0 +#define ACPI_FIXED_LENGTH 1 +#define ACPI_VARIABLE_LENGTH 2 +#define ACPI_SMALL_VARIABLE_LENGTH 3 + typedef acpi_status(*acpi_pkg_callback) (u8 object_type, union acpi_operand_object * source_object, @@ -418,13 +427,19 @@ acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer); #define ACPI_ANY_BASE 0 +acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index); + u32 acpi_ut_get_descriptor_length(void *aml); u16 acpi_ut_get_resource_length(void *aml); +u8 acpi_ut_get_resource_header_length(void *aml); + u8 acpi_ut_get_resource_type(void *aml); -u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc); +acpi_status +acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, + u8 ** end_tag); u8 acpi_ut_generate_checksum(u8 * buffer, u32 length); diff --git a/include/acpi/amlresrc.h b/include/acpi/amlresrc.h index 3112be527731..2e3382c1e5e3 100644 --- a/include/acpi/amlresrc.h +++ b/include/acpi/amlresrc.h @@ -92,6 +92,11 @@ struct asl_resource_node { struct asl_resource_node *next; }; +/* Macros used to generate AML resource length fields */ + +#define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header)) +#define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header)) + /* * Resource descriptors defined in the ACPI specification. * -- cgit v1.2.3 From c51a4de85de720670f2fbc592a6f8040af72ad87 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Thu, 17 Nov 2005 13:07:00 -0500 Subject: [ACPI] ACPICA 20051117 Fixed a problem in the AML parser where the method thread count could be decremented below zero if any errors occurred during the method parse phase. This should eliminate AE_AML_METHOD_LIMIT exceptions seen on some machines. This also fixed a related regression with the mechanism that detects and corrects methods that cannot properly handle reentrancy (related to the deployment of the new OwnerId mechanism.) Eliminated the pre-parsing of control methods (to detect errors) during table load. Related to the problem above, this was causing unwind issues if any errors occurred during the parse, and it seemed to be overkill. A table load should not be aborted if there are problems with any single control method, thus rendering this feature rather pointless. Fixed a problem with the new table-driven resource manager where an internal buffer overflow could occur for small resource templates. Implemented a new external interface, acpi_get_vendor_resource() This interface will find and return a vendor-defined resource descriptor within a _CRS or _PRS method via an ACPI 3.0 UUID match. (from Bjorn Helgaas) Removed the length limit (200) on string objects as per the upcoming ACPI 3.0A specification. This affects the following areas of the interpreter: 1) any implicit conversion of a Buffer to a String, 2) a String object result of the ASL Concatentate operator, 3) the String object result of the ASL ToString operator. Signed-off-by: Bob Moore Signed-off-by: Len Brown --- drivers/acpi/dispatcher/dsinit.c | 25 +++-- drivers/acpi/dispatcher/dswload.c | 2 +- drivers/acpi/executer/exconvrt.c | 12 +-- drivers/acpi/executer/exdump.c | 15 +-- drivers/acpi/executer/exmisc.c | 38 +++---- drivers/acpi/executer/exnames.c | 2 +- drivers/acpi/executer/exoparg2.c | 10 +- drivers/acpi/executer/exregion.c | 16 +-- drivers/acpi/executer/exstorob.c | 4 +- drivers/acpi/parser/psargs.c | 152 +++++++++++++--------------- drivers/acpi/parser/psparse.c | 35 ++++--- drivers/acpi/parser/psxface.c | 2 +- drivers/acpi/resources/rscalc.c | 14 ++- drivers/acpi/resources/rsdump.c | 24 ++--- drivers/acpi/resources/rslist.c | 4 +- drivers/acpi/resources/rsmisc.c | 92 ++++++++--------- drivers/acpi/resources/rsutils.c | 22 ++-- drivers/acpi/resources/rsxface.c | 208 +++++++++++++++++++++++++++++--------- drivers/acpi/scan.c | 2 +- drivers/acpi/tables/tbconvrt.c | 4 +- drivers/acpi/tables/tbgetall.c | 4 +- drivers/acpi/tables/tbutils.c | 8 +- drivers/acpi/utilities/utcopy.c | 19 ++-- drivers/acpi/utilities/utglobal.c | 4 +- drivers/acpi/utilities/utmisc.c | 34 +++++-- drivers/acpi/utilities/utresrc.c | 19 ++-- include/acpi/acconfig.h | 14 +-- include/acpi/acglobal.h | 1 + include/acpi/aclocal.h | 4 +- include/acpi/acmacros.h | 27 +++-- include/acpi/acpixf.h | 8 +- include/acpi/acresrc.h | 7 +- include/acpi/actypes.h | 23 ++++- include/acpi/platform/aclinux.h | 4 + 34 files changed, 515 insertions(+), 344 deletions(-) (limited to 'include') diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c index 8693c704aea6..4fa80abfe6c0 100644 --- a/drivers/acpi/dispatcher/dsinit.c +++ b/drivers/acpi/dispatcher/dsinit.c @@ -117,14 +117,6 @@ acpi_ds_init_one_object(acpi_handle obj_handle, case ACPI_TYPE_METHOD: - /* - * Print a dot for each method unless we are going to print - * the entire pathname - */ - if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { - ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, ".")); - } - /* * Set the execution data width (32 or 64) based upon the * revision number of the parent ACPI table. @@ -134,6 +126,21 @@ acpi_ds_init_one_object(acpi_handle obj_handle, if (info->table_desc->pointer->revision == 1) { node->flags |= ANOBJ_DATA_WIDTH_32; } +#ifdef ACPI_INIT_PARSE_METHODS + /* + * Note 11/2005: Removed this code to parse all methods during table + * load because it causes problems if there are any errors during the + * parse. Also, it seems like overkill and we probably don't want to + * abort a table load because of an issue with a single method. + */ + + /* + * Print a dot for each method unless we are going to print + * the entire pathname + */ + if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { + ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, ".")); + } /* * Always parse methods to detect errors, we will delete @@ -149,7 +156,7 @@ acpi_ds_init_one_object(acpi_handle obj_handle, /* This parse failed, but we will continue parsing more methods */ } - +#endif info->method_count++; break; diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c index 411731261c29..89d318cbc8a3 100644 --- a/drivers/acpi/dispatcher/dswload.c +++ b/drivers/acpi/dispatcher/dswload.c @@ -311,7 +311,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, op->named.name = node->name.integer; #if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)) - op->named.path = (u8 *) path; + op->named.path = ACPI_CAST_PTR(u8, path); #endif /* diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c index 04e5194989a6..fa9e75d4ec65 100644 --- a/drivers/acpi/executer/exconvrt.c +++ b/drivers/acpi/executer/exconvrt.c @@ -504,18 +504,12 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, } /* - * Perform the conversion. + * Create a new string object and string buffer * (-1 because of extra separator included in string_length from above) */ - string_length--; - if (string_length > ACPI_MAX_STRING_CONVERSION) { /* ACPI limit */ - return_ACPI_STATUS(AE_AML_STRING_LIMIT); - } - - /* Create a new string object and string buffer */ - return_desc = - acpi_ut_create_string_object((acpi_size) string_length); + acpi_ut_create_string_object((acpi_size) + (string_length - 1)); if (!return_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index 5a4cca171af6..17c79cd91b31 100644 --- a/drivers/acpi/executer/exdump.c +++ b/drivers/acpi/executer/exdump.c @@ -117,12 +117,13 @@ static struct acpi_exdump_info acpi_ex_dump_event[2] = { {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.semaphore), "Semaphore"} }; -static struct acpi_exdump_info acpi_ex_dump_method[7] = { +static struct acpi_exdump_info acpi_ex_dump_method[8] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "param_count"}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.concurrency), "Concurrency"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.semaphore), "Semaphore"}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.thread_count), "Thread Count"}, {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.aml_start), "Aml Start"} }; @@ -339,7 +340,7 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc, count = info->offset; while (count) { - target = ((u8 *) obj_desc) + info->offset; + target = ACPI_ADD_PTR(u8, obj_desc, info->offset); name = info->name; switch (info->opcode) { @@ -360,20 +361,19 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc, case ACPI_EXD_UINT16: acpi_os_printf("%20s : %4.4X\n", name, - *ACPI_CAST_PTR(u16, target)); + ACPI_GET16(target)); break; case ACPI_EXD_UINT32: acpi_os_printf("%20s : %8.8X\n", name, - *ACPI_CAST_PTR(u32, target)); + ACPI_GET32(target)); break; case ACPI_EXD_UINT64: acpi_os_printf("%20s : %8.8X%8.8X\n", "Value", - ACPI_FORMAT_UINT64(*ACPI_CAST_PTR - (u64, target))); + ACPI_FORMAT_UINT64(ACPI_GET64(target))); break; case ACPI_EXD_POINTER: @@ -969,7 +969,8 @@ acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc, acpi_os_printf("[Buffer] Length %.2X = ", obj_desc->buffer.length); if (obj_desc->buffer.length) { - acpi_ut_dump_buffer((u8 *) obj_desc->buffer.pointer, + acpi_ut_dump_buffer(ACPI_CAST_PTR + (u8, obj_desc->buffer.pointer), obj_desc->buffer.length, DB_DWORD_DISPLAY, _COMPONENT); } else { diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c index 00a25f8188f4..0778bff632bf 100644 --- a/drivers/acpi/executer/exmisc.c +++ b/drivers/acpi/executer/exmisc.c @@ -205,11 +205,9 @@ acpi_ex_concat_template(union acpi_operand_object *operand0, ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length0); ACPI_MEMCPY(new_buf + length0, operand1->buffer.pointer, length1); - /* Compute the new checksum */ + /* Set the end_tag checksum to zero, means "ignore checksum" */ - new_buf[return_desc->buffer.length - 1] = - acpi_ut_generate_checksum(return_desc->buffer.pointer, - (return_desc->buffer.length - 1)); + new_buf[return_desc->buffer.length - 1] = 0; /* Return the completed resource template */ @@ -242,7 +240,6 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, union acpi_operand_object *return_desc; char *new_buf; acpi_status status; - acpi_size new_length; ACPI_FUNCTION_TRACE("ex_do_concatenate"); @@ -269,7 +266,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, break; default: - ACPI_REPORT_ERROR(("Concat - invalid obj type: %X\n", + ACPI_REPORT_ERROR(("Concatanate - invalid object type: %X\n", ACPI_GET_OBJECT_TYPE(operand0))); status = AE_AML_INTERNAL; } @@ -309,8 +306,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, /* Copy the first integer, LSB first */ - ACPI_MEMCPY(new_buf, - &operand0->integer.value, + ACPI_MEMCPY(new_buf, &operand0->integer.value, acpi_gbl_integer_byte_width); /* Copy the second integer (LSB first) after the first */ @@ -324,14 +320,11 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, /* Result of two Strings is a String */ - new_length = (acpi_size) operand0->string.length + - (acpi_size) local_operand1->string.length; - if (new_length > ACPI_MAX_STRING_CONVERSION) { - status = AE_AML_STRING_LIMIT; - goto cleanup; - } - - return_desc = acpi_ut_create_string_object(new_length); + return_desc = acpi_ut_create_string_object((acpi_size) + (operand0->string. + length + + local_operand1-> + string.length)); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -351,11 +344,10 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, /* Result of two Buffers is a Buffer */ return_desc = acpi_ut_create_buffer_object((acpi_size) - operand0->buffer. - length + - (acpi_size) - local_operand1-> - buffer.length); + (operand0->buffer. + length + + local_operand1-> + buffer.length)); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; @@ -365,8 +357,8 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, /* Concatenate the buffers */ - ACPI_MEMCPY(new_buf, - operand0->buffer.pointer, operand0->buffer.length); + ACPI_MEMCPY(new_buf, operand0->buffer.pointer, + operand0->buffer.length); ACPI_MEMCPY(new_buf + operand0->buffer.length, local_operand1->buffer.pointer, local_operand1->buffer.length); diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c index dff41121a304..7bb5e17b5680 100644 --- a/drivers/acpi/executer/exnames.c +++ b/drivers/acpi/executer/exnames.c @@ -216,7 +216,7 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string) *aml_address, aml_address)); } - *in_aml_address = (u8 *) aml_address; + *in_aml_address = ACPI_CAST_PTR(u8, aml_address); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/executer/exoparg2.c index 8d70c6beef00..d8472842c1fd 100644 --- a/drivers/acpi/executer/exoparg2.c +++ b/drivers/acpi/executer/exoparg2.c @@ -344,10 +344,6 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) (length < operand[1]->integer.value) && (operand[0]->buffer.pointer[length])) { length++; - if (length > ACPI_MAX_STRING_CONVERSION) { - status = AE_AML_STRING_LIMIT; - goto cleanup; - } } /* Allocate a new string object */ @@ -358,8 +354,10 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) goto cleanup; } - /* Copy the raw buffer data with no transform. NULL terminated already */ - + /* + * Copy the raw buffer data with no transform. + * (NULL terminated already) + */ ACPI_MEMCPY(return_desc->string.pointer, operand[0]->buffer.pointer, length); break; diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c index 1897379b5f90..80118be3f544 100644 --- a/drivers/acpi/executer/exregion.c +++ b/drivers/acpi/executer/exregion.c @@ -199,20 +199,20 @@ acpi_ex_system_memory_space_handler(u32 function, *value = 0; switch (bit_width) { case 8: - *value = (acpi_integer) * ((u8 *) logical_addr_ptr); + *value = (acpi_integer) ACPI_GET8(logical_addr_ptr); break; case 16: - *value = (acpi_integer) * ((u16 *) logical_addr_ptr); + *value = (acpi_integer) ACPI_GET16(logical_addr_ptr); break; case 32: - *value = (acpi_integer) * ((u32 *) logical_addr_ptr); + *value = (acpi_integer) ACPI_GET32(logical_addr_ptr); break; #if ACPI_MACHINE_WIDTH != 16 case 64: - *value = (acpi_integer) * ((u64 *) logical_addr_ptr); + *value = (acpi_integer) ACPI_GET64(logical_addr_ptr); break; #endif default: @@ -225,20 +225,20 @@ acpi_ex_system_memory_space_handler(u32 function, switch (bit_width) { case 8: - *(u8 *) logical_addr_ptr = (u8) * value; + ACPI_SET8(logical_addr_ptr) = (u8) * value; break; case 16: - *(u16 *) logical_addr_ptr = (u16) * value; + ACPI_SET16(logical_addr_ptr) = (u16) * value; break; case 32: - *(u32 *) logical_addr_ptr = (u32) * value; + ACPI_SET32(logical_addr_ptr) = (u32) * value; break; #if ACPI_MACHINE_WIDTH != 16 case 64: - *(u64 *) logical_addr_ptr = (u64) * value; + ACPI_SET64(logical_addr_ptr) = (u64) * value; break; #endif diff --git a/drivers/acpi/executer/exstorob.c b/drivers/acpi/executer/exstorob.c index c4ff654a6697..855db7130751 100644 --- a/drivers/acpi/executer/exstorob.c +++ b/drivers/acpi/executer/exstorob.c @@ -71,7 +71,7 @@ acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc, /* We know that source_desc is a buffer by now */ - buffer = (u8 *) source_desc->buffer.pointer; + buffer = ACPI_CAST_PTR(u8, source_desc->buffer.pointer); length = source_desc->buffer.length; /* @@ -160,7 +160,7 @@ acpi_ex_store_string_to_string(union acpi_operand_object *source_desc, /* We know that source_desc is a string by now */ - buffer = (u8 *) source_desc->string.pointer; + buffer = ACPI_CAST_PTR(u8, source_desc->string.pointer); length = source_desc->string.length; /* diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c index 562d0f822ab1..6eae35febccd 100644 --- a/drivers/acpi/parser/psargs.c +++ b/drivers/acpi/parser/psargs.c @@ -62,61 +62,51 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state * * PARAMETERS: parser_state - Current parser state object * - * RETURN: Decoded package length. On completion, the AML pointer points + * RETURN: Decoded package length. On completion, the AML pointer points * past the length byte or bytes. * - * DESCRIPTION: Decode and return a package length field + * DESCRIPTION: Decode and return a package length field. + * Note: Largest package length is 28 bits, from ACPI specification * ******************************************************************************/ static u32 acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) { - u32 encoded_length; - u32 length = 0; + u8 *aml = parser_state->aml; + u32 package_length = 0; + acpi_native_uint byte_count; + u8 byte_zero_mask = 0x3F; /* Default [0:5] */ ACPI_FUNCTION_TRACE("ps_get_next_package_length"); - encoded_length = (u32) ACPI_GET8(parser_state->aml); - parser_state->aml++; - - switch (encoded_length >> 6) { /* bits 6-7 contain encoding scheme */ - case 0: /* 1-byte encoding (bits 0-5) */ - - length = (encoded_length & 0x3F); - break; - - case 1: /* 2-byte encoding (next byte + bits 0-3) */ - - length = ((ACPI_GET8(parser_state->aml) << 04) | - (encoded_length & 0x0F)); - parser_state->aml++; - break; - - case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */ - - length = ((ACPI_GET8(parser_state->aml + 1) << 12) | - (ACPI_GET8(parser_state->aml) << 04) | - (encoded_length & 0x0F)); - parser_state->aml += 2; - break; - - case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */ + /* + * Byte 0 bits [6:7] contain the number of additional bytes + * used to encode the package length, either 0,1,2, or 3 + */ + byte_count = (aml[0] >> 6); + parser_state->aml += (byte_count + 1); - length = ((ACPI_GET8(parser_state->aml + 2) << 20) | - (ACPI_GET8(parser_state->aml + 1) << 12) | - (ACPI_GET8(parser_state->aml) << 04) | - (encoded_length & 0x0F)); - parser_state->aml += 3; - break; + /* Get bytes 3, 2, 1 as needed */ - default: + while (byte_count) { + /* + * Final bit positions for the package length bytes: + * Byte3->[20:27] + * Byte2->[12:19] + * Byte1->[04:11] + * Byte0->[00:03] + */ + package_length |= (aml[byte_count] << ((byte_count << 3) - 4)); - /* Can't get here, only 2 bits / 4 cases */ - break; + byte_zero_mask = 0x0F; /* Use bits [0:3] of byte 0 */ + byte_count--; } - return_UINT32(length); + /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */ + + package_length |= (aml[0] & byte_zero_mask); + return_UINT32(package_length); } /******************************************************************************* @@ -135,16 +125,15 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state) { u8 *start = parser_state->aml; - acpi_native_uint length; + u32 package_length; ACPI_FUNCTION_TRACE("ps_get_next_package_end"); - /* Function below changes parser_state->Aml */ + /* Function below updates parser_state->Aml */ - length = - (acpi_native_uint) acpi_ps_get_next_package_length(parser_state); + package_length = acpi_ps_get_next_package_length(parser_state); - return_PTR(start + length); /* end of package */ + return_PTR(start + package_length); /* end of package */ } /******************************************************************************* @@ -169,17 +158,15 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state) ACPI_FUNCTION_TRACE("ps_get_next_namestring"); - /* Handle multiple prefix characters */ - - while (acpi_ps_is_prefix_char(ACPI_GET8(end))) { - /* Include prefix '\\' or '^' */ + /* Point past any namestring prefix characters (backslash or carat) */ + while (acpi_ps_is_prefix_char(*end)) { end++; } - /* Decode the path */ + /* Decode the path prefix character */ - switch (ACPI_GET8(end)) { + switch (*end) { case 0: /* null_name */ @@ -199,9 +186,9 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state) case AML_MULTI_NAME_PREFIX_OP: - /* Multiple name segments, 4 chars each */ + /* Multiple name segments, 4 chars each, count in next byte */ - end += 2 + ((acpi_size) ACPI_GET8(end + 1) * ACPI_NAME_SIZE); + end += 2 + (*(end + 1) * ACPI_NAME_SIZE); break; default: @@ -212,7 +199,7 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state) break; } - parser_state->aml = (u8 *) end; + parser_state->aml = end; return_PTR((char *)start); } @@ -342,7 +329,6 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, ("search_node %p start_node %p return_node %p\n", scope_info.scope.node, parser_state->start_node, node); - } else { /* * We got a NOT_FOUND during table load or we encountered @@ -382,59 +368,63 @@ void acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state, u32 arg_type, union acpi_parse_object *arg) { + u32 length; + u16 opcode; + u8 *aml = parser_state->aml; ACPI_FUNCTION_TRACE_U32("ps_get_next_simple_arg", arg_type); switch (arg_type) { case ARGP_BYTEDATA: - acpi_ps_init_op(arg, AML_BYTE_OP); - arg->common.value.integer = (u32) ACPI_GET8(parser_state->aml); - parser_state->aml++; + /* Get 1 byte from the AML stream */ + + opcode = AML_BYTE_OP; + arg->common.value.integer = (acpi_integer) * aml; + length = 1; break; case ARGP_WORDDATA: - acpi_ps_init_op(arg, AML_WORD_OP); - /* Get 2 bytes from the AML stream */ - ACPI_MOVE_16_TO_32(&arg->common.value.integer, - parser_state->aml); - parser_state->aml += 2; + opcode = AML_WORD_OP; + ACPI_MOVE_16_TO_64(&arg->common.value.integer, aml); + length = 2; break; case ARGP_DWORDDATA: - acpi_ps_init_op(arg, AML_DWORD_OP); - /* Get 4 bytes from the AML stream */ - ACPI_MOVE_32_TO_32(&arg->common.value.integer, - parser_state->aml); - parser_state->aml += 4; + opcode = AML_DWORD_OP; + ACPI_MOVE_32_TO_64(&arg->common.value.integer, aml); + length = 4; break; case ARGP_QWORDDATA: - acpi_ps_init_op(arg, AML_QWORD_OP); - /* Get 8 bytes from the AML stream */ - ACPI_MOVE_64_TO_64(&arg->common.value.integer, - parser_state->aml); - parser_state->aml += 8; + opcode = AML_QWORD_OP; + ACPI_MOVE_64_TO_64(&arg->common.value.integer, aml); + length = 8; break; case ARGP_CHARLIST: - acpi_ps_init_op(arg, AML_STRING_OP); - arg->common.value.string = (char *)parser_state->aml; + /* Get a pointer to the string, point past the string */ + + opcode = AML_STRING_OP; + arg->common.value.string = ACPI_CAST_PTR(char, aml); - while (ACPI_GET8(parser_state->aml) != '\0') { - parser_state->aml++; + /* Find the null terminator */ + + length = 0; + while (aml[length]) { + length++; } - parser_state->aml++; + length++; break; case ARGP_NAME: @@ -443,14 +433,16 @@ acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state, acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); arg->common.value.name = acpi_ps_get_next_namestring(parser_state); - break; + return_VOID; default: ACPI_REPORT_ERROR(("Invalid arg_type %X\n", arg_type)); - break; + return_VOID; } + acpi_ps_init_op(arg, opcode); + parser_state->aml += length; return_VOID; } @@ -540,7 +532,7 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state * access_type is first operand, access_attribute is second */ field->common.value.integer = - (ACPI_GET8(parser_state->aml) << 8); + (((u32) ACPI_GET8(parser_state->aml) << 8)); parser_state->aml++; field->common.value.integer |= ACPI_GET8(parser_state->aml); parser_state->aml++; diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c index 76d4d640d83c..7cfa7eb0dfc7 100644 --- a/drivers/acpi/parser/psparse.c +++ b/drivers/acpi/parser/psparse.c @@ -503,22 +503,23 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) } else if (status == AE_CTRL_TERMINATE) { status = AE_OK; } else if ((status != AE_OK) && (walk_state->method_desc)) { - ACPI_REPORT_METHOD_ERROR("Method execution failed", - walk_state->method_node, NULL, - status); + /* Either the method parse or actual execution failed */ - /* Ensure proper cleanup */ - - walk_state->parse_flags |= ACPI_PARSE_EXECUTE; + ACPI_REPORT_METHOD_ERROR + ("Method parse/execution failed", + walk_state->method_node, NULL, status); /* Check for possible multi-thread reentrancy problem */ if ((status == AE_ALREADY_EXISTS) && (!walk_state->method_desc->method.semaphore)) { /* - * This method is marked not_serialized, but it tried to create + * Method tried to create an object twice. The probable cause is + * that the method cannot handle reentrancy. + * + * The method is marked not_serialized, but it tried to create * a named object, causing the second thread entrance to fail. - * We will workaround this by marking the method permanently + * Workaround this problem by marking the method permanently * as Serialized. */ walk_state->method_desc->method.method_flags |= @@ -536,15 +537,22 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) acpi_ds_scope_stack_clear(walk_state); /* - * If we just returned from the execution of a control method, - * there's lots of cleanup to do + * If we just returned from the execution of a control method or if we + * encountered an error during the method parse phase, there's lots of + * cleanup to do */ - if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == - ACPI_PARSE_EXECUTE) { + if (((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == + ACPI_PARSE_EXECUTE) || (ACPI_FAILURE(status))) { if (walk_state->method_desc) { /* Decrement the thread count on the method parse tree */ - walk_state->method_desc->method.thread_count--; + if (walk_state->method_desc->method. + thread_count) { + walk_state->method_desc->method. + thread_count--; + } else { + ACPI_REPORT_ERROR(("Invalid zero thread count in method\n")); + } } acpi_ds_terminate_control_method(walk_state); @@ -553,7 +561,6 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) /* Delete this walk state and all linked control states */ acpi_ps_cleanup_scope(&walk_state->parser_state); - previous_walk_state = walk_state; ACPI_DEBUG_PRINT((ACPI_DB_PARSE, diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c index 4c426f4c6af6..14d544d60867 100644 --- a/drivers/acpi/parser/psxface.c +++ b/drivers/acpi/parser/psxface.c @@ -87,7 +87,7 @@ acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags) /* TBDs: Validate name, allow full path or just nameseg */ - acpi_gbl_trace_method_name = *(u32 *) name; + acpi_gbl_trace_method_name = *ACPI_CAST_PTR(u32, name); acpi_gbl_trace_flags = flags; if (debug_level) { diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c index eca7439ee9da..c2c4d9079c6c 100644 --- a/drivers/acpi/resources/rscalc.c +++ b/drivers/acpi/resources/rscalc.c @@ -300,7 +300,7 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) /* Point to the next object */ resource = - ACPI_PTR_ADD(struct acpi_resource, resource, + ACPI_ADD_PTR(struct acpi_resource, resource, resource->length); } @@ -374,8 +374,7 @@ acpi_rs_get_list_length(u8 * aml_buffer, * Get the number of bits set in the 16-bit IRQ mask */ ACPI_MOVE_16_TO_16(&temp16, buffer); - extra_struct_bytes = - acpi_rs_count_set_bits(temp16) * sizeof(u32); + extra_struct_bytes = acpi_rs_count_set_bits(temp16); break; case ACPI_RESOURCE_NAME_DMA: @@ -383,8 +382,7 @@ acpi_rs_get_list_length(u8 * aml_buffer, * DMA Resource: * Get the number of bits set in the 8-bit DMA mask */ - extra_struct_bytes = - acpi_rs_count_set_bits(*buffer) * sizeof(u32); + extra_struct_bytes = acpi_rs_count_set_bits(*buffer); break; case ACPI_RESOURCE_NAME_VENDOR_SMALL: @@ -399,9 +397,9 @@ acpi_rs_get_list_length(u8 * aml_buffer, case ACPI_RESOURCE_NAME_END_TAG: /* - * End Tag: This is the normal exit + * End Tag: This is the normal exit, add size of end_tag */ - *size_needed = buffer_size; + *size_needed = buffer_size + ACPI_RS_SIZE_MIN; return_ACPI_STATUS(AE_OK); case ACPI_RESOURCE_NAME_VENDOR_LARGE: @@ -466,7 +464,7 @@ acpi_rs_get_list_length(u8 * aml_buffer, temp16 = (u16) (acpi_gbl_resource_struct_sizes[resource_index] + extra_struct_bytes); - buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16); + buffer_size += (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(temp16); /* * Point to the next resource within the stream diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c index f617ca80c5a6..cebd890d3db5 100644 --- a/drivers/acpi/resources/rsdump.c +++ b/drivers/acpi/resources/rsdump.c @@ -383,7 +383,7 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) while (count) { previous_target = target; - target = ((u8 *) resource) + table->offset; + target = ACPI_ADD_PTR(u8, resource, table->offset); name = table->name; switch (table->opcode) { @@ -410,22 +410,19 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) /* Data items, 8/16/32/64 bit */ case ACPI_RSD_UINT8: - acpi_rs_out_integer8(name, *ACPI_CAST_PTR(u8, target)); + acpi_rs_out_integer8(name, ACPI_GET8(target)); break; case ACPI_RSD_UINT16: - acpi_rs_out_integer16(name, - *ACPI_CAST_PTR(u16, target)); + acpi_rs_out_integer16(name, ACPI_GET16(target)); break; case ACPI_RSD_UINT32: - acpi_rs_out_integer32(name, - *ACPI_CAST_PTR(u32, target)); + acpi_rs_out_integer32(name, ACPI_GET32(target)); break; case ACPI_RSD_UINT64: - acpi_rs_out_integer64(name, - *ACPI_CAST_PTR(u64, target)); + acpi_rs_out_integer64(name, ACPI_GET64(target)); break; /* Flags: 1-bit and 2-bit flags supported */ @@ -462,8 +459,8 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) * Note: The list length is obtained from the previous table entry */ if (previous_target) { - acpi_rs_dump_byte_list(*ACPI_CAST_PTR - (u16, previous_target), + acpi_rs_dump_byte_list(ACPI_GET16 + (previous_target), target); } break; @@ -634,7 +631,7 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list) /* Point to the next resource structure */ resource_list = - ACPI_PTR_ADD(struct acpi_resource, resource_list, + ACPI_ADD_PTR(struct acpi_resource, resource_list, resource_list->length); /* Exit when END_TAG descriptor is reached */ @@ -675,9 +672,8 @@ void acpi_rs_dump_irq_list(u8 * route_table) count); acpi_rs_dump_descriptor(prt_element, acpi_rs_dump_prt); - prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table, - ((u8 *) prt_element) + - prt_element->length); + prt_element = ACPI_ADD_PTR(struct acpi_pci_routing_table, + prt_element, prt_element->length); } } diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c index b83996233c1d..573c06705641 100644 --- a/drivers/acpi/resources/rslist.c +++ b/drivers/acpi/resources/rslist.c @@ -112,7 +112,7 @@ acpi_rs_convert_aml_to_resources(u8 * aml, u32 aml_length, u8 * output_buffer) /* Point to the next structure in the output buffer */ resource = - ACPI_PTR_ADD(struct acpi_resource, resource, + ACPI_ADD_PTR(struct acpi_resource, resource, resource->length); } @@ -201,7 +201,7 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, /* Point to the next input resource descriptor */ resource = - ACPI_PTR_ADD(struct acpi_resource, resource, + ACPI_ADD_PTR(struct acpi_resource, resource, resource->length); } diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c index 16ad3bfbee2a..e1b5aa2af9a5 100644 --- a/drivers/acpi/resources/rsmisc.c +++ b/drivers/acpi/resources/rsmisc.c @@ -104,8 +104,9 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, * Source is the external AML byte stream buffer, * destination is the internal resource descriptor */ - source = ((u8 *) aml) + info->aml_offset; - destination = ((u8 *) resource) + info->resource_offset; + source = ACPI_ADD_PTR(void, aml, info->aml_offset); + destination = + ACPI_ADD_PTR(void, resource, info->resource_offset); switch (info->opcode) { case ACPI_RSC_INITGET: @@ -129,22 +130,22 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, /* * Mask and shift the flag bit */ - *((u8 *) destination) = (u8) - ((*((u8 *) source) >> info->value) & 0x01); + ACPI_SET8(destination) = (u8) + ((ACPI_GET8(source) >> info->value) & 0x01); break; case ACPI_RSC_2BITFLAG: /* * Mask and shift the flag bits */ - *((u8 *) destination) = (u8) - ((*((u8 *) source) >> info->value) & 0x03); + ACPI_SET8(destination) = (u8) + ((ACPI_GET8(source) >> info->value) & 0x03); break; case ACPI_RSC_COUNT: - item_count = *((u8 *) source); - *((u8 *) destination) = (u8) item_count; + item_count = ACPI_GET8(source); + ACPI_SET8(destination) = (u8) item_count; resource->length = resource->length + (info->value * (item_count - 1)); @@ -153,7 +154,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, case ACPI_RSC_COUNT16: item_count = aml_resource_length; - *((u16 *) destination) = item_count; + ACPI_SET16(destination) = item_count; resource->length = resource->length + (info->value * (item_count - 1)); @@ -186,9 +187,8 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, case ACPI_RSC_DATA8: - target = ((char *)resource) + info->value; - ACPI_MEMCPY(destination, source, - *(ACPI_CAST_PTR(u16, target))); + target = ACPI_ADD_PTR(char, resource, info->value); + ACPI_MEMCPY(destination, source, ACPI_GET16(target)); break; case ACPI_RSC_ADDRESS: @@ -217,8 +217,8 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, * complicated case used by the Interrupt() macro */ target = - ((char *)resource) + info->aml_offset + - (item_count * 4); + ACPI_ADD_PTR(char, resource, + info->aml_offset + (item_count * 4)); resource->length += acpi_rs_get_resource_source(aml_resource_length, @@ -230,15 +230,14 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, * 8-bit encoded bitmask (DMA macro) */ item_count = - acpi_rs_decode_bitmask(*((u8 *) source), + acpi_rs_decode_bitmask(ACPI_GET8(source), destination); if (item_count) { - resource->length += - resource->length + (item_count - 1); + resource->length += (item_count - 1); } - target = ((char *)resource) + info->value; - *((u8 *) target) = (u8) item_count; + target = ACPI_ADD_PTR(char, resource, info->value); + ACPI_SET8(target) = (u8) item_count; break; case ACPI_RSC_BITMASK16: @@ -250,12 +249,11 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, item_count = acpi_rs_decode_bitmask(temp16, destination); if (item_count) { - resource->length = - resource->length + (item_count - 1); + resource->length += (item_count - 1); } - target = ((char *)resource) + info->value; - *((u8 *) target) = (u8) item_count; + target = ACPI_ADD_PTR(char, resource, info->value); + ACPI_SET8(target) = (u8) item_count; break; case ACPI_RSC_EXIT_NE: @@ -270,7 +268,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, break; case ACPI_RSC_COMPARE_VALUE: - if (*((u8 *) source) != info->value) { + if (ACPI_GET8(source) != info->value) { goto exit; } break; @@ -349,8 +347,8 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, * Source is the internal resource descriptor, * destination is the external AML byte stream buffer */ - source = ((u8 *) resource) + info->resource_offset; - destination = ((u8 *) aml) + info->aml_offset; + source = ACPI_ADD_PTR(void, resource, info->resource_offset); + destination = ACPI_ADD_PTR(void, aml, info->aml_offset); switch (info->opcode) { case ACPI_RSC_INITSET: @@ -368,37 +366,38 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, /* * Clear the flag byte */ - *((u8 *) destination) = 0; + ACPI_SET8(destination) = 0; break; case ACPI_RSC_1BITFLAG: /* * Mask and shift the flag bit */ - *((u8 *) destination) |= (u8) - ((*((u8 *) source) & 0x01) << info->value); + ACPI_SET8(destination) |= (u8) + ((ACPI_GET8(source) & 0x01) << info->value); break; case ACPI_RSC_2BITFLAG: /* * Mask and shift the flag bits */ - *((u8 *) destination) |= (u8) - ((*((u8 *) source) & 0x03) << info->value); + ACPI_SET8(destination) |= (u8) + ((ACPI_GET8(source) & 0x03) << info->value); break; case ACPI_RSC_COUNT: - item_count = *((u8 *) source); - *((u8 *) destination) = (u8) item_count; + item_count = ACPI_GET8(source); + ACPI_SET8(destination) = (u8) item_count; - aml_length = (u16) (aml_length + - (info->value * (item_count - 1))); + aml_length = + (u16) (aml_length + + (info->value * (item_count - 1))); break; case ACPI_RSC_COUNT16: - item_count = *((u16 *) source); + item_count = ACPI_GET16(source); aml_length = (u16) (aml_length + item_count); acpi_rs_set_resource_length(aml_length, aml); break; @@ -453,20 +452,21 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, /* * 8-bit encoded bitmask (DMA macro) */ - *((u8 *) destination) = (u8) + ACPI_SET8(destination) = (u8) acpi_rs_encode_bitmask(source, - *(((u8 *) resource) + - info->value)); + *ACPI_ADD_PTR(u8, resource, + info->value)); break; case ACPI_RSC_BITMASK16: /* * 16-bit encoded bitmask (IRQ macro) */ - temp16 = - acpi_rs_encode_bitmask(source, - *(((u8 *) resource) + - info->value)); + temp16 = acpi_rs_encode_bitmask(source, + *ACPI_ADD_PTR(u8, + resource, + info-> + value)); ACPI_MOVE_16_TO_16(destination, &temp16); break; @@ -485,9 +485,9 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, */ switch (COMPARE_OPCODE(info)) { case ACPI_RSC_COMPARE_VALUE: - if (* - ((u8 *) (((u8 *) resource) + - COMPARE_TARGET(info))) != + + if (*ACPI_ADD_PTR(u8, resource, + COMPARE_TARGET(info)) != COMPARE_VALUE(info)) { goto exit; } diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c index a1eac0f1df54..2236a0c90daa 100644 --- a/drivers/acpi/resources/rsutils.c +++ b/drivers/acpi/resources/rsutils.c @@ -152,18 +152,18 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) * misaligned memory transfers */ case ACPI_RSC_MOVE16: - ACPI_MOVE_16_TO_16(&((u16 *) destination)[i], - &((u16 *) source)[i]); + ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i], + &ACPI_CAST_PTR(u16, source)[i]); break; case ACPI_RSC_MOVE32: - ACPI_MOVE_32_TO_32(&((u32 *) destination)[i], - &((u32 *) source)[i]); + ACPI_MOVE_32_TO_32(&ACPI_CAST_PTR(u32, destination)[i], + &ACPI_CAST_PTR(u32, source)[i]); break; case ACPI_RSC_MOVE64: - ACPI_MOVE_64_TO_64(&((u64 *) destination)[i], - &((u64 *) source)[i]); + ACPI_MOVE_64_TO_64(&ACPI_CAST_PTR(u64, destination)[i], + &ACPI_CAST_PTR(u64, source)[i]); break; default: @@ -318,7 +318,7 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length, total_length = resource_length + sizeof(struct aml_resource_large_header); - aml_resource_source = ((u8 *) aml) + minimum_length; + aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length); /* * resource_source is present if the length of the descriptor is longer than @@ -338,9 +338,9 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length, * String destination pointer is not specified; Set the String * pointer to the end of the current resource_source structure. */ - resource_source->string_ptr = (char *) - ((u8 *) resource_source) + - sizeof(struct acpi_resource_source); + resource_source->string_ptr = + ACPI_ADD_PTR(char, resource_source, + sizeof(struct acpi_resource_source)); } /* @@ -407,7 +407,7 @@ acpi_rs_set_resource_source(union aml_resource * aml, if (resource_source->string_length) { /* Point to the end of the AML descriptor */ - aml_resource_source = ((u8 *) aml) + minimum_length; + aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length); /* Copy the resource_source_index */ diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c index 09d250ab9872..50a956b705b0 100644 --- a/drivers/acpi/resources/rsxface.c +++ b/drivers/acpi/resources/rsxface.c @@ -64,6 +64,10 @@ ACPI_MODULE_NAME("rsxface") ACPI_COPY_FIELD(out, in, translation_offset); \ ACPI_COPY_FIELD(out, in, address_length); \ ACPI_COPY_FIELD(out, in, resource_source); +/* Local prototypes */ +static acpi_status +acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context); + /******************************************************************************* * * FUNCTION: acpi_get_irq_routing_table @@ -86,6 +90,7 @@ ACPI_MODULE_NAME("rsxface") * the object indicated by the passed device_handle. * ******************************************************************************/ + acpi_status acpi_get_irq_routing_table(acpi_handle device_handle, struct acpi_buffer *ret_buffer) @@ -222,12 +227,12 @@ EXPORT_SYMBOL(acpi_get_possible_resources); * * FUNCTION: acpi_walk_resources * - * PARAMETERS: device_handle - a handle to the device object for the + * PARAMETERS: device_handle - Handle to the device object for the * device we are querying - * Path - method name of the resources we want + * Name - Method name of the resources we want * (METHOD_NAME__CRS or METHOD_NAME__PRS) - * user_function - called for each resource - * Context - passed to user_function + * user_function - Called for each resource + * Context - Passed to user_function * * RETURN: Status * @@ -239,79 +244,74 @@ EXPORT_SYMBOL(acpi_get_possible_resources); acpi_status acpi_walk_resources(acpi_handle device_handle, - char *path, + char *name, ACPI_WALK_RESOURCE_CALLBACK user_function, void *context) { acpi_status status; - struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + struct acpi_buffer buffer; struct acpi_resource *resource; - struct acpi_resource *buffer_end; + struct acpi_resource *resource_end; ACPI_FUNCTION_TRACE("acpi_walk_resources"); - if (!device_handle || - (ACPI_STRNCMP(path, METHOD_NAME__CRS, sizeof(METHOD_NAME__CRS)) && - ACPI_STRNCMP(path, METHOD_NAME__PRS, sizeof(METHOD_NAME__PRS)))) { + /* Parameter validation */ + + if (!device_handle || !user_function || !name || + (ACPI_STRNCMP(name, METHOD_NAME__CRS, sizeof(METHOD_NAME__CRS)) && + ACPI_STRNCMP(name, METHOD_NAME__PRS, sizeof(METHOD_NAME__PRS)))) { return_ACPI_STATUS(AE_BAD_PARAMETER); } - status = acpi_rs_get_method_data(device_handle, path, &buffer); + /* Get the _CRS or _PRS resource list */ + + buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; + status = acpi_rs_get_method_data(device_handle, name, &buffer); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } - /* Setup pointers */ + /* Buffer now contains the resource list */ - resource = (struct acpi_resource *)buffer.pointer; - buffer_end = ACPI_CAST_PTR(struct acpi_resource, - ((u8 *) buffer.pointer + buffer.length)); + resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer); + resource_end = + ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length); - /* Walk the resource list */ + /* Walk the resource list until the end_tag is found (or buffer end) */ - for (;;) { - if (!resource || resource->type == ACPI_RESOURCE_TYPE_END_TAG) { + while (resource < resource_end) { + /* Sanity check the resource */ + + if (resource->type > ACPI_RESOURCE_TYPE_MAX) { + status = AE_AML_INVALID_RESOURCE_TYPE; break; } - status = user_function(resource, context); - - switch (status) { - case AE_OK: - case AE_CTRL_DEPTH: + /* Invoke the user function, abort on any error returned */ - /* Just keep going */ + status = user_function(resource, context); + if (ACPI_FAILURE(status)) { + if (status == AE_CTRL_TERMINATE) { + /* This is an OK termination by the user function */ - status = AE_OK; + status = AE_OK; + } break; + } - case AE_CTRL_TERMINATE: - - /* Exit now, with OK stats */ - - status = AE_OK; - goto cleanup; - - default: - - /* All others are valid exceptions */ + /* end_tag indicates end-of-list */ - goto cleanup; + if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) { + break; } /* Get the next resource descriptor */ - resource = ACPI_NEXT_RESOURCE(resource); - - /* Check for end-of-buffer */ - - if (resource >= buffer_end) { - goto cleanup; - } + resource = + ACPI_ADD_PTR(struct acpi_resource, resource, + resource->length); } - cleanup: - - acpi_os_free(buffer.pointer); + ACPI_MEM_FREE(buffer.pointer); return_ACPI_STATUS(status); } @@ -381,6 +381,12 @@ acpi_resource_to_address64(struct acpi_resource *resource, struct acpi_resource_address16 *address16; struct acpi_resource_address32 *address32; + if (!resource || !out) { + return (AE_BAD_PARAMETER); + } + + /* Convert 16 or 32 address descriptor to 64 */ + switch (resource->type) { case ACPI_RESOURCE_TYPE_ADDRESS16: @@ -410,3 +416,113 @@ acpi_resource_to_address64(struct acpi_resource *resource, } EXPORT_SYMBOL(acpi_resource_to_address64); + +/******************************************************************************* + * + * FUNCTION: acpi_get_vendor_resource + * + * PARAMETERS: device_handle - Handle for the parent device object + * Name - Method name for the parent resource + * (METHOD_NAME__CRS or METHOD_NAME__PRS) + * Uuid - Pointer to the UUID to be matched. + * includes both subtype and 16-byte UUID + * ret_buffer - Where the vendor resource is returned + * + * RETURN: Status + * + * DESCRIPTION: Walk a resource template for the specified evice to find a + * vendor-defined resource that matches the supplied UUID and + * UUID subtype. Returns a struct acpi_resource of type Vendor. + * + ******************************************************************************/ + +acpi_status +acpi_get_vendor_resource(acpi_handle device_handle, + char *name, + struct acpi_vendor_uuid * uuid, + struct acpi_buffer * ret_buffer) +{ + struct acpi_vendor_walk_info info; + acpi_status status; + + /* Other parameters are validated by acpi_walk_resources */ + + if (!uuid || !ret_buffer) { + return (AE_BAD_PARAMETER); + } + + info.uuid = uuid; + info.buffer = ret_buffer; + info.status = AE_NOT_EXIST; + + /* Walk the _CRS or _PRS resource list for this device */ + + status = + acpi_walk_resources(device_handle, name, + acpi_rs_match_vendor_resource, &info); + if (ACPI_FAILURE(status)) { + return (status); + } + + return (info.status); +} + +/******************************************************************************* + * + * FUNCTION: acpi_rs_match_vendor_resource + * + * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID + * + ******************************************************************************/ + +static acpi_status +acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context) +{ + struct acpi_vendor_walk_info *info = context; + struct acpi_resource_vendor_typed *vendor; + struct acpi_buffer *buffer; + acpi_status status; + + /* Ignore all descriptors except Vendor */ + + if (resource->type != ACPI_RESOURCE_TYPE_VENDOR) { + return (AE_OK); + } + + vendor = &resource->data.vendor_typed; + + /* + * For a valid match, these conditions must hold: + * + * 1) Length of descriptor data must be at least as long as a UUID struct + * 2) The UUID subtypes must match + * 3) The UUID data must match + */ + if ((vendor->byte_length < (ACPI_UUID_LENGTH + 1)) || + (vendor->uuid_subtype != info->uuid->subtype) || + (ACPI_MEMCMP(vendor->uuid, info->uuid->data, ACPI_UUID_LENGTH))) { + return (AE_OK); + } + + /* Validate/Allocate/Clear caller buffer */ + + buffer = info->buffer; + status = acpi_ut_initialize_buffer(buffer, resource->length); + if (ACPI_FAILURE(status)) { + return (status); + } + + /* Found the correct resource, copy and return it */ + + ACPI_MEMCPY(buffer->pointer, resource, resource->length); + buffer->length = resource->length; + + /* Found the desired descriptor, terminate resource walk */ + + info->status = AE_OK; + return (AE_CTRL_TERMINATE); +} diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 31218e1d2a18..e332306ae2b9 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -844,7 +844,7 @@ static void acpi_device_set_id(struct acpi_device *device, * ---- * Fix for the system root bus device -- the only root-level device. */ - if ((parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) { + if (((acpi_handle)parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) { hid = ACPI_BUS_HID; strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME); strcpy(device->pnp.device_class, ACPI_BUS_CLASS); diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c index a03939399fa9..cd33397d9231 100644 --- a/drivers/acpi/tables/tbconvrt.c +++ b/drivers/acpi/tables/tbconvrt.c @@ -554,7 +554,9 @@ acpi_status acpi_tb_convert_table_fadt(void) ACPI_DEBUG_PRINT((ACPI_DB_TABLES, "Hex dump of common internal FADT, size %d (%X)\n", acpi_gbl_FADT->length, acpi_gbl_FADT->length)); - ACPI_DUMP_BUFFER((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->length); + + ACPI_DUMP_BUFFER(ACPI_CAST_PTR(u8, acpi_gbl_FADT), + acpi_gbl_FADT->length); return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/tables/tbgetall.c b/drivers/acpi/tables/tbgetall.c index 8d72343537e7..33c9ed8a6f99 100644 --- a/drivers/acpi/tables/tbgetall.c +++ b/drivers/acpi/tables/tbgetall.c @@ -292,7 +292,9 @@ acpi_status acpi_tb_get_required_tables(void) "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n", acpi_gbl_DSDT->length, acpi_gbl_DSDT->length, acpi_gbl_integer_bit_width)); - ACPI_DUMP_BUFFER((u8 *) acpi_gbl_DSDT, acpi_gbl_DSDT->length); + + ACPI_DUMP_BUFFER(ACPI_CAST_PTR(u8, acpi_gbl_DSDT), + acpi_gbl_DSDT->length); /* Always delete the RSDP mapping, we are done with it */ diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c index e6dfe688b76b..9d0bf536d674 100644 --- a/drivers/acpi/tables/tbutils.c +++ b/drivers/acpi/tables/tbutils.c @@ -240,16 +240,16 @@ acpi_tb_verify_table_checksum(struct acpi_table_header * table_header) u8 acpi_tb_generate_checksum(void *buffer, u32 length) { - const u8 *limit; - const u8 *rover; + u8 *end_buffer; + u8 *rover; u8 sum = 0; if (buffer && length) { /* Buffer and Length are valid */ - limit = (u8 *) buffer + length; + end_buffer = ACPI_ADD_PTR(u8, buffer, length); - for (rover = buffer; rover < limit; rover++) { + for (rover = buffer; rover < end_buffer; rover++) { sum = (u8) (sum + *rover); } } diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c index 5442b32de611..568df9e42f89 100644 --- a/drivers/acpi/utilities/utcopy.c +++ b/drivers/acpi/utilities/utcopy.c @@ -398,14 +398,17 @@ acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object, * Build a simple object (no nested objects) */ status = acpi_ut_copy_isimple_to_esimple(internal_object, - (union acpi_object *) - ret_buffer->pointer, - ((u8 *) ret_buffer-> - pointer + - ACPI_ROUND_UP_TO_NATIVE_WORD - (sizeof - (union - acpi_object))), + ACPI_CAST_PTR(union + acpi_object, + ret_buffer-> + pointer), + ACPI_ADD_PTR(u8, + ret_buffer-> + pointer, + ACPI_ROUND_UP_TO_NATIVE_WORD + (sizeof + (union + acpi_object))), &ret_buffer->length); /* * build simple does not include the object size in the length diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index 413e1dd8ae36..d6813d88a104 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c @@ -638,7 +638,7 @@ char *acpi_ut_get_node_name(void *object) /* Name must be a valid ACPI name */ - if (!acpi_ut_valid_acpi_name(*(u32 *) node->name.ascii)) { + if (!acpi_ut_valid_acpi_name(node->name.integer)) { return ("????"); } @@ -831,6 +831,7 @@ void acpi_ut_init_globals(void) acpi_gbl_ps_find_count = 0; acpi_gbl_acpi_hardware_present = TRUE; acpi_gbl_owner_id_mask = 0; + acpi_gbl_last_owner_id = 0; acpi_gbl_trace_method_name = 0; acpi_gbl_trace_dbg_level = 0; acpi_gbl_trace_dbg_layer = 0; @@ -845,7 +846,6 @@ void acpi_ut_init_globals(void) /* Namespace */ acpi_gbl_root_node = NULL; - acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED; acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index 2a9110c06391..89efba7bf449 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -63,6 +63,7 @@ ACPI_MODULE_NAME("utmisc") acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) { acpi_native_uint i; + acpi_native_uint j; acpi_status status; ACPI_FUNCTION_TRACE("ut_allocate_owner_id"); @@ -82,29 +83,46 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) return_ACPI_STATUS(status); } - /* Find a free owner ID */ + /* + * Find a free owner ID, cycle through all possible IDs on repeated + * allocations. Note: Index for next possible ID is equal to the value + * of the last allocated ID. + */ + for (i = 0, j = acpi_gbl_last_owner_id; i < 32; i++, j++) { + if (j >= 32) { + j = 0; /* Wraparound to ID start */ + } + + if (!(acpi_gbl_owner_id_mask & (1 << j))) { + /* + * Found a free ID. The actual ID is the bit index plus one, + * making zero an invalid Owner ID. Save this as the last ID + * allocated and update the global ID mask. + */ + acpi_gbl_last_owner_id = (acpi_owner_id) (j + 1); + *owner_id = acpi_gbl_last_owner_id; - for (i = 0; i < 32; i++) { - if (!(acpi_gbl_owner_id_mask & (1 << i))) { ACPI_DEBUG_PRINT((ACPI_DB_VALUES, "Current owner_id mask: %8.8X New ID: %2.2X\n", acpi_gbl_owner_id_mask, - (unsigned int)(i + 1))); + (unsigned int) + acpi_gbl_last_owner_id)); - acpi_gbl_owner_id_mask |= (1 << i); - *owner_id = (acpi_owner_id) (i + 1); + acpi_gbl_owner_id_mask |= (1 << j); goto exit; } } /* - * If we are here, all owner_ids have been allocated. This probably should + * All owner_ids have been allocated. This typically should * not happen since the IDs are reused after deallocation. The IDs are * allocated upon table load (one per table) and method execution, and * they are released when a table is unloaded or a method completes * execution. + * + * If this error happens, there may be very deep nesting of invoked control + * methods, or there may be a bug where the IDs are not released. */ - *owner_id = 0; status = AE_OWNER_ID_LIMIT; ACPI_REPORT_ERROR(("Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n")); diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c index 07a314c710d8..6c0ce7b12194 100644 --- a/drivers/acpi/utilities/utresrc.c +++ b/drivers/acpi/utilities/utresrc.c @@ -157,7 +157,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index) /* * 1) Validate the resource_type field (Byte 0) */ - resource_type = *((u8 *) aml); + resource_type = ACPI_GET8(aml); /* * Byte 0 contains the descriptor name (Resource Type) @@ -266,14 +266,14 @@ u8 acpi_ut_get_resource_type(void *aml) * Byte 0 contains the descriptor name (Resource Type) * Examine the large/small bit in the resource header */ - if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { + if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) { /* Large Resource Type -- bits 6:0 contain the name */ - return (*((u8 *) aml)); + return (ACPI_GET8(aml)); } else { /* Small Resource Type -- bits 6:3 contain the name */ - return ((u8) (*((u8 *) aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); + return ((u8) (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); } } @@ -301,15 +301,15 @@ u16 acpi_ut_get_resource_length(void *aml) * Byte 0 contains the descriptor name (Resource Type) * Examine the large/small bit in the resource header */ - if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { + if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) { /* Large Resource type -- bytes 1-2 contain the 16-bit length */ - ACPI_MOVE_16_TO_16(&resource_length, &((u8 *) aml)[1]); + ACPI_MOVE_16_TO_16(&resource_length, ACPI_ADD_PTR(u8, aml, 1)); } else { /* Small Resource type -- bits 2:0 of byte 0 contain the length */ - resource_length = (u16) (*((u8 *) aml) & + resource_length = (u16) (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); } @@ -334,7 +334,7 @@ u8 acpi_ut_get_resource_header_length(void *aml) /* Examine the large/small bit in the resource header */ - if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { + if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) { return (sizeof(struct aml_resource_large_header)); } else { return (sizeof(struct aml_resource_small_header)); @@ -372,8 +372,9 @@ u32 acpi_ut_get_descriptor_length(void *aml) * FUNCTION: acpi_ut_get_resource_end_tag * * PARAMETERS: obj_desc - The resource template buffer object + * end_tag - Where the pointer to the end_tag is returned * - * RETURN: Pointer to the end tag + * RETURN: Status, pointer to the end tag * * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template * diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index d371ec6b9812..08eafece3eed 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -63,7 +63,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20051102 +#define ACPI_CA_VERSION 0x20051117 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, @@ -98,11 +98,6 @@ #define ACPI_CA_SUPPORT_LEVEL 3 -/* String size constants */ - -#define ACPI_MAX_STRING_LENGTH 512 -#define ACPI_PATHNAME_MAX 256 /* A full namespace pathname */ - /* Maximum count for a semaphore object */ #define ACPI_MAX_SEMAPHORE_COUNT 256 @@ -134,14 +129,11 @@ #define ACPI_METHOD_NUM_ARGS 7 #define ACPI_METHOD_MAX_ARG 6 -/* Maximum length of resulting string when converting from a buffer */ - -#define ACPI_MAX_STRING_CONVERSION 200 - -/* Length of _HID, _UID, and _CID values */ +/* Length of _HID, _UID, _CID, and UUID values */ #define ACPI_DEVICE_ID_LENGTH 0x09 #define ACPI_MAX_CID_LENGTH 48 +#define ACPI_UUID_LENGTH 16 /* * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG diff --git a/include/acpi/acglobal.h b/include/acpi/acglobal.h index cef51b1ddf94..bd344e51313b 100644 --- a/include/acpi/acglobal.h +++ b/include/acpi/acglobal.h @@ -223,6 +223,7 @@ ACPI_EXTERN u32 acpi_gbl_ps_find_count; ACPI_EXTERN u32 acpi_gbl_owner_id_mask; ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save; ACPI_EXTERN u16 acpi_gbl_global_lock_handle; +ACPI_EXTERN u8 acpi_gbl_last_owner_id; ACPI_EXTERN u8 acpi_gbl_debugger_configuration; ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; ACPI_EXTERN u8 acpi_gbl_step_to_next_call; diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h index dca0d40ea395..0cb61a72d971 100644 --- a/include/acpi/aclocal.h +++ b/include/acpi/aclocal.h @@ -573,6 +573,8 @@ struct acpi_parse_obj_named { /* The parse node is the fundamental element of the parse tree */ +#define ACPI_MAX_PARSEOP_NAME 20 + struct acpi_parse_obj_asl { ACPI_PARSE_COMMON union acpi_parse_object *child; union acpi_parse_object *parent_method; @@ -597,7 +599,7 @@ struct acpi_parse_obj_asl { u8 aml_opcode_length; u8 aml_pkg_len_bytes; u8 extra; - char parse_op_name[12]; + char parse_op_name[ACPI_MAX_PARSEOP_NAME]; }; union acpi_parse_object { diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h index e42222c3d34c..5b78ff4091b9 100644 --- a/include/acpi/acmacros.h +++ b/include/acpi/acmacros.h @@ -107,23 +107,29 @@ * Extract a byte of data using a pointer. Any more than a byte and we * get into potential aligment issues -- see the STORE macros below */ -#define ACPI_GET8(addr) (*(u8*)(addr)) +#define ACPI_GET8(ptr) *ACPI_CAST_PTR (u8, ptr) +#define ACPI_GET16(ptr) *ACPI_CAST_PTR (u16, ptr) +#define ACPI_GET32(ptr) *ACPI_CAST_PTR (u32, ptr) +#define ACPI_GET64(ptr) *ACPI_CAST_PTR (u64, ptr) +#define ACPI_SET8(ptr) *ACPI_CAST_PTR (u8, ptr) +#define ACPI_SET16(ptr) *ACPI_CAST_PTR (u16, ptr) +#define ACPI_SET32(ptr) *ACPI_CAST_PTR (u32, ptr) +#define ACPI_SET64(ptr) *ACPI_CAST_PTR (u64, ptr) -/* Pointer arithmetic */ +/* Pointer manipulation */ -#define ACPI_PTR_ADD(t,a,b) (t *) (void *)((char *)(a) + (acpi_native_uint)(b)) +#define ACPI_CAST_PTR(t, p) ((t *)(void *)(p)) +#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **)(void *)(p)) +#define ACPI_ADD_PTR(t,a,b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8, (a)) + (acpi_native_uint)(b))) #define ACPI_PTR_DIFF(a,b) (acpi_native_uint) ((char *)(a) - (char *)(b)) /* Pointer/Integer type conversions */ -#define ACPI_TO_POINTER(i) ACPI_PTR_ADD (void, (void *) NULL,(acpi_native_uint)i) +#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL,(acpi_native_uint)i) #define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,(void *) NULL) #define ACPI_OFFSET(d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL) #define ACPI_FADT_OFFSET(f) ACPI_OFFSET (FADT_DESCRIPTOR, f) -#define ACPI_CAST_PTR(t, p) ((t *)(void *)(p)) -#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **)(void *)(p)) - #if ACPI_MACHINE_WIDTH == 16 #define ACPI_STORE_POINTER(d,s) ACPI_MOVE_32_TO_32(d,s) #define ACPI_PHYSADDR_TO_PTR(i) (void *)(i) @@ -365,6 +371,13 @@ #define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask) #define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask) +/* Generate a UUID */ + +#define ACPI_INIT_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) (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) + /* * An struct acpi_namespace_node * can appear in some contexts, * where a pointer to an union acpi_operand_object can also diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index 02f00a8fee03..2a88429bc4ec 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -271,6 +271,12 @@ typedef acpi_status(*ACPI_WALK_RESOURCE_CALLBACK) (struct acpi_resource * resource, void *context); +acpi_status +acpi_get_vendor_resource(acpi_handle device_handle, + char *name, + struct acpi_vendor_uuid *uuid, + struct acpi_buffer *ret_buffer); + acpi_status acpi_get_current_resources(acpi_handle device_handle, struct acpi_buffer *ret_buffer); @@ -283,7 +289,7 @@ acpi_get_possible_resources(acpi_handle device_handle, acpi_status acpi_walk_resources(acpi_handle device_handle, - char *path, + char *name, ACPI_WALK_RESOURCE_CALLBACK user_function, void *context); acpi_status diff --git a/include/acpi/acresrc.h b/include/acpi/acresrc.h index 2bf53940f259..ba281f7740a0 100644 --- a/include/acpi/acresrc.h +++ b/include/acpi/acresrc.h @@ -137,9 +137,14 @@ extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[]; /* Resource tables indexed by raw AML resource descriptor type */ +extern const u8 acpi_gbl_resource_struct_sizes[]; extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[]; -extern const u8 acpi_gbl_resource_struct_sizes[]; +struct acpi_vendor_walk_info { + struct acpi_vendor_uuid *uuid; + struct acpi_buffer *buffer; + acpi_status status; +}; /* * rscreate diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 29b887017b18..11847592ed1b 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -326,7 +326,7 @@ typedef u64 acpi_integer; /* * Constants with special meanings */ -#define ACPI_ROOT_OBJECT (acpi_handle) ACPI_PTR_ADD (char, NULL, ACPI_MAX_PTR) +#define ACPI_ROOT_OBJECT ACPI_ADD_PTR (acpi_handle, NULL, ACPI_MAX_PTR) /* * Initialization sequence @@ -986,6 +986,17 @@ typedef u32 acpi_rsdesc_size; /* Max Resource Descriptor size is (length+3) = (6 #pragma pack(1) #endif +/* UUID data structures for use in vendor-defined resource descriptors */ + +struct acpi_uuid { + u8 data[ACPI_UUID_LENGTH]; +}; + +struct acpi_vendor_uuid { + u8 subtype; + u8 data[ACPI_UUID_LENGTH]; +}; + /* * Structures used to describe device resources */ @@ -1033,6 +1044,15 @@ struct acpi_resource_vendor { u8 byte_data[1]; }; +/* Vendor resource with UUID info (introduced in ACPI 3.0) */ + +struct acpi_resource_vendor_typed { + u16 byte_length; + u8 uuid_subtype; + u8 uuid[ACPI_UUID_LENGTH]; + u8 byte_data[1]; +}; + struct acpi_resource_end_tag { u8 checksum; }; @@ -1184,6 +1204,7 @@ union acpi_resource_data { struct acpi_resource_io io; struct acpi_resource_fixed_io fixed_io; struct acpi_resource_vendor vendor; + struct acpi_resource_vendor_typed vendor_typed; struct acpi_resource_end_tag end_tag; struct acpi_resource_memory24 memory24; struct acpi_resource_memory32 memory32; diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h index c93e6562f0e1..1b9cbf05b79e 100644 --- a/include/acpi/platform/aclinux.h +++ b/include/acpi/platform/aclinux.h @@ -71,6 +71,10 @@ #define acpi_cache_t kmem_cache_t #endif +/* Full namespace pathname length limit - arbitrary */ + +#define ACPI_PATHNAME_MAX 256 + #else /* !__KERNEL__ */ #include -- cgit v1.2.3 From 28f55ebce5bd2fceec8adc7c8860953d3e4532a8 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Fri, 2 Dec 2005 18:27:00 -0500 Subject: [ACPI] ACPICA 20051202 Modified the parsing of control methods to no longer create namespace objects during the first pass of the parse. Objects are now created only during the execute phase, at the moment the namespace creation operator is encountered in the AML (Name, OperationRegion, CreateByteField, etc.) This should eliminate ALREADY_EXISTS exceptions seen on some machines where reentrant control methods are protected by an AML mutex. The mutex will now correctly block multiple threads from attempting to create the same object more than once. Increased the number of available Owner Ids for namespace object tracking from 32 to 255. This should eliminate the OWNER_ID_LIMIT exceptions seen on some machines with a large number of ACPI tables (either static or dynamic). Enhanced the namespace dump routine to output the owner ID for each namespace object. Signed-off-by: Bob Moore Signed-off-by: Len Brown --- drivers/acpi/dispatcher/dsmethod.c | 337 ++++++++++++++++++++----------------- drivers/acpi/dispatcher/dswload.c | 132 +++++++++++---- drivers/acpi/namespace/nsdump.c | 4 +- drivers/acpi/utilities/utglobal.c | 9 +- drivers/acpi/utilities/utmisc.c | 79 ++++++--- include/acpi/acconfig.h | 6 +- include/acpi/acglobal.h | 5 +- include/acpi/acmacros.h | 4 + 8 files changed, 350 insertions(+), 226 deletions(-) (limited to 'include') diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index 36c1ca0b9adb..58ad00b31ee9 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c @@ -51,133 +51,6 @@ #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME("dsmethod") -/******************************************************************************* - * - * FUNCTION: acpi_ds_parse_method - * - * PARAMETERS: Node - Method node - * - * RETURN: Status - * - * DESCRIPTION: Parse the AML that is associated with the method. - * - * MUTEX: Assumes parser is locked - * - ******************************************************************************/ -acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node) -{ - acpi_status status; - union acpi_operand_object *obj_desc; - union acpi_parse_object *op; - struct acpi_walk_state *walk_state; - - ACPI_FUNCTION_TRACE_PTR("ds_parse_method", node); - - /* Parameter Validation */ - - if (!node) { - return_ACPI_STATUS(AE_NULL_ENTRY); - } - - ACPI_DEBUG_PRINT((ACPI_DB_PARSE, - "**** Parsing [%4.4s] **** named_obj=%p\n", - acpi_ut_get_node_name(node), node)); - - /* Extract the method object from the method Node */ - - obj_desc = acpi_ns_get_attached_object(node); - if (!obj_desc) { - return_ACPI_STATUS(AE_NULL_OBJECT); - } - - /* Create a mutex for the method if there is a concurrency limit */ - - if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) && - (!obj_desc->method.semaphore)) { - status = acpi_os_create_semaphore(obj_desc->method.concurrency, - obj_desc->method.concurrency, - &obj_desc->method.semaphore); - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); - } - } - - /* - * Allocate a new parser op to be the root of the parsed - * method tree - */ - op = acpi_ps_alloc_op(AML_METHOD_OP); - if (!op) { - return_ACPI_STATUS(AE_NO_MEMORY); - } - - /* Init new op with the method name and pointer back to the Node */ - - acpi_ps_set_name(op, node->name.integer); - op->common.node = node; - - /* - * Get a new owner_id for objects created by this method. Namespace - * objects (such as Operation Regions) can be created during the - * first pass parse. - */ - status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id); - if (ACPI_FAILURE(status)) { - goto cleanup; - } - - /* Create and initialize a new walk state */ - - walk_state = - acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL, - NULL); - if (!walk_state) { - status = AE_NO_MEMORY; - goto cleanup2; - } - - status = acpi_ds_init_aml_walk(walk_state, op, node, - obj_desc->method.aml_start, - obj_desc->method.aml_length, NULL, 1); - if (ACPI_FAILURE(status)) { - acpi_ds_delete_walk_state(walk_state); - goto cleanup2; - } - - /* - * Parse the method, first pass - * - * The first pass load is where newly declared named objects are added into - * the namespace. Actual evaluation of the named objects (what would be - * called a "second pass") happens during the actual execution of the - * method so that operands to the named objects can take on dynamic - * run-time values. - */ - status = acpi_ps_parse_aml(walk_state); - if (ACPI_FAILURE(status)) { - goto cleanup2; - } - - ACPI_DEBUG_PRINT((ACPI_DB_PARSE, - "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n", - acpi_ut_get_node_name(node), node, op)); - - /* - * Delete the parse tree. We simply re-parse the method for every - * execution since there isn't much overhead (compared to keeping lots - * of parse trees around) - */ - acpi_ns_delete_namespace_subtree(node); - acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id); - - cleanup2: - acpi_ut_release_owner_id(&obj_desc->method.owner_id); - - cleanup: - acpi_ps_delete_parse_tree(op); - return_ACPI_STATUS(status); -} - /******************************************************************************* * * FUNCTION: acpi_ds_begin_method_execution @@ -193,7 +66,6 @@ acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node) * for clearance to execute. * ******************************************************************************/ - acpi_status acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, union acpi_operand_object *obj_desc, @@ -545,16 +417,54 @@ void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) } } + /* + * There are no more threads executing this method. Perform + * additional cleanup. + * + * The method Node is stored in the walk state + */ + method_node = walk_state->method_node; + + /* Lock namespace for possible update */ + + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE(status)) { + goto exit; + } + + /* + * Delete any namespace entries created immediately underneath + * the method + */ + if (method_node->child) { + acpi_ns_delete_namespace_subtree(method_node); + } + + /* + * Delete any namespace entries created anywhere else within + * the namespace by the execution of this method + */ + acpi_ns_delete_namespace_by_owner(walk_state->method_desc->method. + owner_id); + status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); + + /* Are there any other threads currently executing this method? */ + if (walk_state->method_desc->method.thread_count) { + /* + * Additional threads. Do not release the owner_id in this case, + * we immediately reuse it for the next thread executing this method + */ ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, - "*** Not deleting method namespace, there are still %d threads\n", + "*** Completed execution of one thread, %d threads remaining\n", walk_state->method_desc->method. thread_count)); - } else { /* This is the last executing thread */ + } else { + /* This is the only executing thread for this method */ /* * Support to dynamically change a method from not_serialized to - * Serialized if it appears that the method is written foolishly and + * Serialized if it appears that the method is incorrectly written and * does not support multiple thread execution. The best example of this * is if such a method creates namespace objects and blocks. A second * thread will fail with an AE_ALREADY_EXISTS exception @@ -570,34 +480,8 @@ void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) semaphore); } - /* - * There are no more threads executing this method. Perform - * additional cleanup. - * - * The method Node is stored in the walk state - */ - method_node = walk_state->method_node; - - /* - * Delete any namespace entries created immediately underneath - * the method - */ - status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE(status)) { - goto exit; - } - - if (method_node->child) { - acpi_ns_delete_namespace_subtree(method_node); - } + /* No more threads, we can free the owner_id */ - /* - * Delete any namespace entries created anywhere else within - * the namespace - */ - acpi_ns_delete_namespace_by_owner(walk_state->method_desc-> - method.owner_id); - status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); acpi_ut_release_owner_id(&walk_state->method_desc->method. owner_id); } @@ -606,3 +490,140 @@ void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) (void)acpi_ut_release_mutex(ACPI_MTX_PARSER); return_VOID; } + +#ifdef ACPI_INIT_PARSE_METHODS + /* + * Note 11/2005: Removed this code to parse all methods during table + * load because it causes problems if there are any errors during the + * parse. Also, it seems like overkill and we probably don't want to + * abort a table load because of an issue with a single method. + */ + +/******************************************************************************* + * + * FUNCTION: acpi_ds_parse_method + * + * PARAMETERS: Node - Method node + * + * RETURN: Status + * + * DESCRIPTION: Parse the AML that is associated with the method. + * + * MUTEX: Assumes parser is locked + * + ******************************************************************************/ + +acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node) +{ + acpi_status status; + union acpi_operand_object *obj_desc; + union acpi_parse_object *op; + struct acpi_walk_state *walk_state; + + ACPI_FUNCTION_TRACE_PTR("ds_parse_method", node); + + /* Parameter Validation */ + + if (!node) { + return_ACPI_STATUS(AE_NULL_ENTRY); + } + + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "**** Parsing [%4.4s] **** named_obj=%p\n", + acpi_ut_get_node_name(node), node)); + + /* Extract the method object from the method Node */ + + obj_desc = acpi_ns_get_attached_object(node); + if (!obj_desc) { + return_ACPI_STATUS(AE_NULL_OBJECT); + } + + /* Create a mutex for the method if there is a concurrency limit */ + + if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) && + (!obj_desc->method.semaphore)) { + status = acpi_os_create_semaphore(obj_desc->method.concurrency, + obj_desc->method.concurrency, + &obj_desc->method.semaphore); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + } + + /* + * Allocate a new parser op to be the root of the parsed + * method tree + */ + op = acpi_ps_alloc_op(AML_METHOD_OP); + if (!op) { + return_ACPI_STATUS(AE_NO_MEMORY); + } + + /* Init new op with the method name and pointer back to the Node */ + + acpi_ps_set_name(op, node->name.integer); + op->common.node = node; + + /* + * Get a new owner_id for objects created by this method. Namespace + * objects (such as Operation Regions) can be created during the + * first pass parse. + */ + status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id); + if (ACPI_FAILURE(status)) { + goto cleanup; + } + + /* Create and initialize a new walk state */ + + walk_state = + acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL, + NULL); + if (!walk_state) { + status = AE_NO_MEMORY; + goto cleanup2; + } + + status = acpi_ds_init_aml_walk(walk_state, op, node, + obj_desc->method.aml_start, + obj_desc->method.aml_length, NULL, 1); + if (ACPI_FAILURE(status)) { + acpi_ds_delete_walk_state(walk_state); + goto cleanup2; + } + + /* + * Parse the method, first pass + * + * The first pass load is where newly declared named objects are added into + * the namespace. Actual evaluation of the named objects (what would be + * called a "second pass") happens during the actual execution of the + * method so that operands to the named objects can take on dynamic + * run-time values. + */ + status = acpi_ps_parse_aml(walk_state); + if (ACPI_FAILURE(status)) { + goto cleanup2; + } + + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "**** [%4.4s] Parsed **** named_obj=%p Op=%p\n", + acpi_ut_get_node_name(node), node, op)); + + /* + * Delete the parse tree. We simply re-parse the method for every + * execution since there isn't much overhead (compared to keeping lots + * of parse trees around) + */ + acpi_ns_delete_namespace_subtree(node); + acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id); + + cleanup2: + acpi_ut_release_owner_id(&obj_desc->method.owner_id); + + cleanup: + acpi_ps_delete_parse_tree(op); + return_ACPI_STATUS(status); +} +#endif diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c index 89d318cbc8a3..44d4f4bb2f92 100644 --- a/drivers/acpi/dispatcher/dswload.c +++ b/drivers/acpi/dispatcher/dswload.c @@ -127,7 +127,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, char *path; u32 flags; - ACPI_FUNCTION_NAME("ds_load1_begin_op"); + ACPI_FUNCTION_TRACE("ds_load1_begin_op"); op = walk_state->op; ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, @@ -138,14 +138,14 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, if (op) { if (!(walk_state->op_info->flags & AML_NAMED)) { *out_op = op; - return (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Check if this object has already been installed in the namespace */ if (op->common.node) { *out_op = op; - return (AE_OK); + return_ACPI_STATUS(AE_OK); } } @@ -188,7 +188,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, #endif if (ACPI_FAILURE(status)) { ACPI_REPORT_NSERROR(path, status); - return (status); + return_ACPI_STATUS(status); } /* @@ -235,7 +235,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n", acpi_ut_get_type_name(node->type), path)); - return (AE_AML_OPERAND_TYPE); + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } break; @@ -257,6 +257,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, * buffer_field, or Package), the name of the object is already * in the namespace. */ + if (walk_state->deferred_node) { /* This name is already in the namespace, get the node */ @@ -265,6 +266,16 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, break; } + /* + * If we are executing a method, do not create any namespace objects + * during the load phase, only during execution. + */ + if (walk_state->method_node) { + node = NULL; + status = AE_OK; + break; + } + flags = ACPI_NS_NO_UPSEARCH; if ((walk_state->opcode != AML_SCOPE_OP) && (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) { @@ -290,7 +301,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, &(node)); if (ACPI_FAILURE(status)) { ACPI_REPORT_NSERROR(path, status); - return (status); + return_ACPI_STATUS(status); } break; } @@ -302,28 +313,29 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, op = acpi_ps_alloc_op(walk_state->opcode); if (!op) { - return (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } } - /* Initialize */ - - op->named.name = node->name.integer; + /* Initialize the op */ #if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)) op->named.path = ACPI_CAST_PTR(u8, path); #endif - /* - * Put the Node in the "op" object that the parser uses, so we - * can get it again quickly when this scope is closed - */ - op->common.node = node; + if (node) { + /* + * Put the Node in the "op" object that the parser uses, so we + * can get it again quickly when this scope is closed + */ + op->common.node = node; + op->named.name = node->name.integer; + } + acpi_ps_append_arg(acpi_ps_get_parent_scope(&walk_state->parser_state), op); - *out_op = op; - return (status); + return_ACPI_STATUS(status); } /******************************************************************************* @@ -339,13 +351,13 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, * ******************************************************************************/ -acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state) +acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state) { union acpi_parse_object *op; acpi_object_type object_type; acpi_status status = AE_OK; - ACPI_FUNCTION_NAME("ds_load1_end_op"); + ACPI_FUNCTION_TRACE("ds_load1_end_op"); op = walk_state->op; ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, @@ -354,7 +366,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state) /* We are only interested in opcodes that have an associated name */ if (!(walk_state->op_info->flags & (AML_NAMED | AML_FIELD))) { - return (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Get the object type to determine if we should pop the scope */ @@ -363,21 +375,37 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state) #ifndef ACPI_NO_METHOD_EXECUTION if (walk_state->op_info->flags & AML_FIELD) { - if (walk_state->opcode == AML_FIELD_OP || - walk_state->opcode == AML_BANK_FIELD_OP || - walk_state->opcode == AML_INDEX_FIELD_OP) { - status = acpi_ds_init_field_objects(op, walk_state); + /* + * If we are executing a method, do not create any namespace objects + * during the load phase, only during execution. + */ + if (!walk_state->method_node) { + if (walk_state->opcode == AML_FIELD_OP || + walk_state->opcode == AML_BANK_FIELD_OP || + walk_state->opcode == AML_INDEX_FIELD_OP) { + status = + acpi_ds_init_field_objects(op, walk_state); + } } - return (status); + return_ACPI_STATUS(status); } - if (op->common.aml_opcode == AML_REGION_OP) { - status = acpi_ex_create_region(op->named.data, op->named.length, - (acpi_adr_space_type) - ((op->common.value.arg)->common. - value.integer), walk_state); - if (ACPI_FAILURE(status)) { - return (status); + /* + * If we are executing a method, do not create any namespace objects + * during the load phase, only during execution. + */ + if (!walk_state->method_node) { + if (op->common.aml_opcode == AML_REGION_OP) { + status = + acpi_ex_create_region(op->named.data, + op->named.length, + (acpi_adr_space_type) + ((op->common.value.arg)-> + common.value.integer), + walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } } } #endif @@ -391,7 +419,12 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state) common. aml_opcode))-> object_type; - op->common.node->type = (u8) object_type; + + /* Set node type if we have a namespace node */ + + if (op->common.node) { + op->common.node->type = (u8) object_type; + } } } @@ -424,7 +457,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state) walk_state->num_operands = 0; if (ACPI_FAILURE(status)) { - return (status); + return_ACPI_STATUS(status); } } } @@ -439,7 +472,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state) status = acpi_ds_scope_stack_pop(walk_state); } - return (status); + return_ACPI_STATUS(status); } /******************************************************************************* @@ -456,8 +489,8 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state) ******************************************************************************/ acpi_status -acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state, - union acpi_parse_object ** out_op) +acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, + union acpi_parse_object **out_op) { union acpi_parse_object *op; struct acpi_namespace_node *node; @@ -840,6 +873,13 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) case AML_TYPE_NAMED_FIELD: + /* + * If we are executing a method, initialize the field + */ + if (walk_state->method_node) { + status = acpi_ds_init_field_objects(op, walk_state); + } + switch (op->common.aml_opcode) { case AML_INDEX_FIELD_OP: @@ -929,6 +969,24 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) switch (op->common.aml_opcode) { #ifndef ACPI_NO_METHOD_EXECUTION case AML_REGION_OP: + + /* + * If we are executing a method, initialize the region + */ + if (walk_state->method_node) { + status = + acpi_ex_create_region(op->named.data, + op->named.length, + (acpi_adr_space_type) + ((op->common.value. + arg)->common.value. + integer), + walk_state); + if (ACPI_FAILURE(status)) { + return (status); + } + } + /* * The op_region is not fully parsed at this time. Only valid * argument is the space_id. (We must save the address of the diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c index 9faf1d5c86ed..864c642759fa 100644 --- a/drivers/acpi/namespace/nsdump.c +++ b/drivers/acpi/namespace/nsdump.c @@ -212,7 +212,9 @@ acpi_ns_dump_one_object(acpi_handle obj_handle, /* * Now we can print out the pertinent information */ - acpi_os_printf(" %-12s %p ", acpi_ut_get_type_name(type), this_node); + acpi_os_printf(" %-12s %p %2.2X ", + acpi_ut_get_type_name(type), this_node, + this_node->owner_id); dbg_level = acpi_dbg_level; acpi_dbg_level = 0; diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index d6813d88a104..6828c7aefa8a 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c @@ -793,6 +793,11 @@ void acpi_ut_init_globals(void) acpi_gbl_mutex_info[i].use_count = 0; } + for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) { + acpi_gbl_owner_id_mask[i] = 0; + } + acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; /* Last ID is never valid */ + /* GPE support */ acpi_gbl_gpe_xrupt_list_head = NULL; @@ -830,8 +835,8 @@ void acpi_ut_init_globals(void) acpi_gbl_ns_lookup_count = 0; acpi_gbl_ps_find_count = 0; acpi_gbl_acpi_hardware_present = TRUE; - acpi_gbl_owner_id_mask = 0; - acpi_gbl_last_owner_id = 0; + acpi_gbl_last_owner_id_index = 0; + acpi_gbl_next_owner_id_offset = 0; acpi_gbl_trace_method_name = 0; acpi_gbl_trace_dbg_level = 0; acpi_gbl_trace_dbg_layer = 0; diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index 89efba7bf449..64dd64b1aa18 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -64,6 +64,7 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) { acpi_native_uint i; acpi_native_uint j; + acpi_native_uint k; acpi_status status; ACPI_FUNCTION_TRACE("ut_allocate_owner_id"); @@ -85,32 +86,50 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) /* * Find a free owner ID, cycle through all possible IDs on repeated - * allocations. Note: Index for next possible ID is equal to the value - * of the last allocated ID. + * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have + * to be scanned twice. */ - for (i = 0, j = acpi_gbl_last_owner_id; i < 32; i++, j++) { - if (j >= 32) { - j = 0; /* Wraparound to ID start */ + for (i = 0, j = acpi_gbl_last_owner_id_index; + i < (ACPI_NUM_OWNERID_MASKS + 1); i++, j++) { + if (j >= ACPI_NUM_OWNERID_MASKS) { + j = 0; /* Wraparound to start of mask array */ } - if (!(acpi_gbl_owner_id_mask & (1 << j))) { - /* - * Found a free ID. The actual ID is the bit index plus one, - * making zero an invalid Owner ID. Save this as the last ID - * allocated and update the global ID mask. - */ - acpi_gbl_last_owner_id = (acpi_owner_id) (j + 1); - *owner_id = acpi_gbl_last_owner_id; + for (k = acpi_gbl_next_owner_id_offset; k < 32; k++) { + if (acpi_gbl_owner_id_mask[j] == ACPI_UINT32_MAX) { + /* There are no free IDs in this mask */ - ACPI_DEBUG_PRINT((ACPI_DB_VALUES, - "Current owner_id mask: %8.8X New ID: %2.2X\n", - acpi_gbl_owner_id_mask, - (unsigned int) - acpi_gbl_last_owner_id)); + break; + } - acpi_gbl_owner_id_mask |= (1 << j); - goto exit; + if (!(acpi_gbl_owner_id_mask[j] & (1 << k))) { + /* + * Found a free ID. The actual ID is the bit index plus one, + * making zero an invalid Owner ID. Save this as the last ID + * allocated and update the global ID mask. + */ + acpi_gbl_owner_id_mask[j] |= (1 << k); + + acpi_gbl_last_owner_id_index = (u8) j; + acpi_gbl_next_owner_id_offset = (u8) (k + 1); + + /* + * Construct encoded ID from the index and bit position + * + * Note: Last [j].k (bit 255) is never used and is marked + * permanently allocated (prevents +1 overflow) + */ + *owner_id = + (acpi_owner_id) ((k + 1) + ACPI_MUL_32(j)); + + ACPI_DEBUG_PRINT((ACPI_DB_VALUES, + "Allocated owner_id: %2.2X\n", + (unsigned int)*owner_id)); + goto exit; + } } + + acpi_gbl_next_owner_id_offset = 0; } /* @@ -124,7 +143,7 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) * methods, or there may be a bug where the IDs are not released. */ status = AE_OWNER_ID_LIMIT; - ACPI_REPORT_ERROR(("Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n")); + ACPI_REPORT_ERROR(("Could not allocate new owner_id (255 max), AE_OWNER_ID_LIMIT\n")); exit: (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); @@ -141,7 +160,7 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) * control method or unloading a table. Either way, we would * ignore any error anyway. * - * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 32 + * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255 * ******************************************************************************/ @@ -149,6 +168,8 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) { acpi_owner_id owner_id = *owner_id_ptr; acpi_status status; + acpi_native_uint index; + u32 bit; ACPI_FUNCTION_TRACE_U32("ut_release_owner_id", owner_id); @@ -158,7 +179,7 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) /* Zero is not a valid owner_iD */ - if ((owner_id == 0) || (owner_id > 32)) { + if ((owner_id == 0) || (owner_id > 255)) { ACPI_REPORT_ERROR(("Invalid owner_id: %2.2X\n", owner_id)); return_VOID; } @@ -174,10 +195,18 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) owner_id--; + /* Decode ID to index/offset pair */ + + index = ACPI_DIV_32(owner_id); + bit = 1 << ACPI_MOD_32(owner_id); + /* Free the owner ID only if it is valid */ - if (acpi_gbl_owner_id_mask & (1 << owner_id)) { - acpi_gbl_owner_id_mask ^= (1 << owner_id); + if (acpi_gbl_owner_id_mask[index] & bit) { + acpi_gbl_owner_id_mask[index] ^= bit; + } else { + ACPI_REPORT_ERROR(("Release of non-allocated owner_id: %2.2X\n", + owner_id + 1)); } (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index 08eafece3eed..f48b9ee9a876 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -63,7 +63,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20051117 +#define ACPI_CA_VERSION 0x20051202 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, @@ -110,6 +110,10 @@ #define ACPI_SYSMEM_REGION_WINDOW_SIZE 4096 +/* owner_id tracking. 8 entries allows for 255 owner_ids */ + +#define ACPI_NUM_OWNERID_MASKS 8 + /****************************************************************************** * * ACPI Specification constants (Do not change unless the specification changes) diff --git a/include/acpi/acglobal.h b/include/acpi/acglobal.h index bd344e51313b..3f37560c26ab 100644 --- a/include/acpi/acglobal.h +++ b/include/acpi/acglobal.h @@ -220,10 +220,11 @@ ACPI_EXTERN u32 acpi_gbl_original_mode; ACPI_EXTERN u32 acpi_gbl_rsdp_original_location; ACPI_EXTERN u32 acpi_gbl_ns_lookup_count; ACPI_EXTERN u32 acpi_gbl_ps_find_count; -ACPI_EXTERN u32 acpi_gbl_owner_id_mask; +ACPI_EXTERN u32 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS]; ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save; ACPI_EXTERN u16 acpi_gbl_global_lock_handle; -ACPI_EXTERN u8 acpi_gbl_last_owner_id; +ACPI_EXTERN u8 acpi_gbl_last_owner_id_index; +ACPI_EXTERN u8 acpi_gbl_next_owner_id_offset; ACPI_EXTERN u8 acpi_gbl_debugger_configuration; ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; ACPI_EXTERN u8 acpi_gbl_step_to_next_call; diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h index 5b78ff4091b9..65a1a5c1a689 100644 --- a/include/acpi/acmacros.h +++ b/include/acpi/acmacros.h @@ -332,6 +332,10 @@ #define ACPI_MUL_16(a) _ACPI_MUL(a,4) #define ACPI_MOD_16(a) _ACPI_MOD(a,16) +#define ACPI_DIV_32(a) _ACPI_DIV(a,5) +#define ACPI_MUL_32(a) _ACPI_MUL(a,5) +#define ACPI_MOD_32(a) _ACPI_MOD(a,32) + /* * Rounding macros (Power of two boundaries only) */ -- cgit v1.2.3 From 729b4d4ce1982c52040bbf22d6711cdf8db07ad8 Mon Sep 17 00:00:00 2001 From: Alexey Starikovskiy Date: Thu, 1 Dec 2005 04:29:00 -0500 Subject: [ACPI] fix reboot upon suspend-to-disk http://bugzilla.kernel.org/show_bug.cgi?id=4320 Signed-off-by: Alexey Starikovskiy Acked-by: Pavel Machek Signed-off-by: Len Brown --- drivers/acpi/sleep/poweroff.c | 15 +++++++++------ drivers/acpi/sleep/sleep.h | 2 +- drivers/acpi/sleep/wakeup.c | 6 +++--- include/linux/kernel.h | 1 + include/linux/reboot.h | 3 +-- kernel/power/disk.c | 9 +-------- kernel/sys.c | 25 ++++++++++--------------- 7 files changed, 26 insertions(+), 35 deletions(-) (limited to 'include') diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c index af7935a95bcc..47fb4b394eec 100644 --- a/drivers/acpi/sleep/poweroff.c +++ b/drivers/acpi/sleep/poweroff.c @@ -33,9 +33,7 @@ int acpi_sleep_prepare(u32 acpi_state) ACPI_FLUSH_CPU_CACHE(); acpi_enable_wakeup_device_prep(acpi_state); #endif - if (acpi_state == ACPI_STATE_S5) { - acpi_wakeup_gpe_poweroff_prepare(); - } + acpi_gpe_sleep_prepare(acpi_state); acpi_enter_sleep_state_prep(acpi_state); return 0; } @@ -53,11 +51,16 @@ void acpi_power_off(void) static int acpi_shutdown(struct sys_device *x) { - if (system_state == SYSTEM_POWER_OFF) { - /* Prepare if we are going to power off the system */ + switch (system_state) { + case SYSTEM_POWER_OFF: + /* Prepare to power off the system */ return acpi_sleep_prepare(ACPI_STATE_S5); + case SYSTEM_SUSPEND_DISK: + /* Prepare to suspend the system to disk */ + return acpi_sleep_prepare(ACPI_STATE_S4); + default: + return 0; } - return 0; } static struct sysdev_class acpi_sysclass = { diff --git a/drivers/acpi/sleep/sleep.h b/drivers/acpi/sleep/sleep.h index efd0001c6f05..f3e70397a7d6 100644 --- a/drivers/acpi/sleep/sleep.h +++ b/drivers/acpi/sleep/sleep.h @@ -5,4 +5,4 @@ extern int acpi_suspend (u32 state); extern void acpi_enable_wakeup_device_prep(u8 sleep_state); extern void acpi_enable_wakeup_device(u8 sleep_state); extern void acpi_disable_wakeup_device(u8 sleep_state); -extern void acpi_wakeup_gpe_poweroff_prepare(void); +extern void acpi_gpe_sleep_prepare(u32 sleep_state); diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/sleep/wakeup.c index 4134ed43d026..85df0ceda2a9 100644 --- a/drivers/acpi/sleep/wakeup.c +++ b/drivers/acpi/sleep/wakeup.c @@ -192,7 +192,7 @@ late_initcall(acpi_wakeup_device_init); * RUNTIME GPEs, we simply mark all GPES that * are not enabled for wakeup from S5 as RUNTIME. */ -void acpi_wakeup_gpe_poweroff_prepare(void) +void acpi_gpe_sleep_prepare(u32 sleep_state) { struct list_head *node, *next; @@ -201,8 +201,8 @@ void acpi_wakeup_gpe_poweroff_prepare(void) struct acpi_device, wakeup_list); - /* The GPE can wakeup system from S5, don't touch it */ - if ((u32) dev->wakeup.sleep_state == ACPI_STATE_S5) + /* The GPE can wakeup system from this state, don't touch it */ + if ((u32) dev->wakeup.sleep_state >= sleep_state) continue; /* acpi_set_gpe_type will automatically disable GPE */ acpi_set_gpe_type(dev->wakeup.gpe_device, diff --git a/include/linux/kernel.h b/include/linux/kernel.h index b1e407a4fbda..73aa55a73334 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -181,6 +181,7 @@ extern enum system_states { SYSTEM_HALT, SYSTEM_POWER_OFF, SYSTEM_RESTART, + SYSTEM_SUSPEND_DISK, } system_state; #define TAINT_PROPRIETARY_MODULE (1<<0) diff --git a/include/linux/reboot.h b/include/linux/reboot.h index 7ab2cdb83ef0..015297ff73fa 100644 --- a/include/linux/reboot.h +++ b/include/linux/reboot.h @@ -60,8 +60,7 @@ extern void machine_crash_shutdown(struct pt_regs *); */ extern void kernel_restart_prepare(char *cmd); -extern void kernel_halt_prepare(void); -extern void kernel_power_off_prepare(void); +extern void kernel_shutdown_prepare(enum system_states state); extern void kernel_restart(char *cmd); extern void kernel_halt(void); diff --git a/kernel/power/disk.c b/kernel/power/disk.c index 027322a564f4..f2cd279d07c7 100644 --- a/kernel/power/disk.c +++ b/kernel/power/disk.c @@ -52,7 +52,7 @@ static void power_down(suspend_disk_method_t mode) switch(mode) { case PM_DISK_PLATFORM: - kernel_power_off_prepare(); + kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK); error = pm_ops->enter(PM_SUSPEND_DISK); break; case PM_DISK_SHUTDOWN: @@ -119,13 +119,6 @@ static int prepare_processes(void) goto thaw; } - if (pm_disk_mode == PM_DISK_PLATFORM) { - if (pm_ops && pm_ops->prepare) { - if ((error = pm_ops->prepare(PM_SUSPEND_DISK))) - goto thaw; - } - } - /* Free memory before shutting down devices. */ free_some_memory(); return 0; diff --git a/kernel/sys.c b/kernel/sys.c index eecf84526afe..c3b1874661fa 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -427,23 +427,25 @@ void kernel_kexec(void) } EXPORT_SYMBOL_GPL(kernel_kexec); +void kernel_shutdown_prepare(enum system_states state) +{ + notifier_call_chain(&reboot_notifier_list, + (state == SYSTEM_HALT)?SYS_HALT:SYS_POWER_OFF, NULL); + system_state = state; + device_shutdown(); +} /** * kernel_halt - halt the system * * Shutdown everything and perform a clean system halt. */ -void kernel_halt_prepare(void) -{ - notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); - system_state = SYSTEM_HALT; - device_shutdown(); -} void kernel_halt(void) { - kernel_halt_prepare(); + kernel_shutdown_prepare(SYSTEM_HALT); printk(KERN_EMERG "System halted.\n"); machine_halt(); } + EXPORT_SYMBOL_GPL(kernel_halt); /** @@ -451,20 +453,13 @@ EXPORT_SYMBOL_GPL(kernel_halt); * * Shutdown everything and perform a clean system power_off. */ -void kernel_power_off_prepare(void) -{ - notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); - system_state = SYSTEM_POWER_OFF; - device_shutdown(); -} void kernel_power_off(void) { - kernel_power_off_prepare(); + kernel_shutdown_prepare(SYSTEM_POWER_OFF); printk(KERN_EMERG "Power down.\n"); machine_power_off(); } EXPORT_SYMBOL_GPL(kernel_power_off); - /* * Reboot system call: for obvious reasons only root may call it, * and even root needs to set up some magic numbers in the registers -- cgit v1.2.3 From defba1d8f233c0d5cf3e1ea6aeb898eca7231860 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Fri, 16 Dec 2005 17:05:00 -0500 Subject: [ACPI] ACPICA 20051216 Implemented optional support to allow unresolved names within ASL Package objects. A null object is inserted in the package when a named reference cannot be located in the current namespace. Enabled via the interpreter slack flag which Linux has enabled by default (acpi=strict to disable slack). This should eliminate AE_NOT_FOUND exceptions seen on machines that contain such code. Implemented an optimization to the initialization sequence that can improve boot time. During ACPI device initialization, the _STA method is now run if and only if the _INI method exists. The _STA method is used to determine if the device is present; An _INI can only be run if _STA returns present, but it is a waste of time to run the _STA method if the _INI does not exist. (Prototype and assistance from Dong Wei) Implemented use of the C99 uintptr_t for the pointer casting macros if it is available in the current compiler. Otherwise, the default (void *) cast is used as before. Fixed some possible memory leaks found within the execution path of the Break, Continue, If, and CreateField operators. (Valery Podrezov) Fixed a problem introduced in the 20051202 release where an exception is generated during method execution if a control method attempts to declare another method. Signed-off-by: Bob Moore Signed-off-by: Len Brown --- drivers/acpi/dispatcher/dsmethod.c | 65 +++++++- drivers/acpi/dispatcher/dsobject.c | 81 ++++++---- drivers/acpi/dispatcher/dswexec.c | 33 +--- drivers/acpi/dispatcher/dswload.c | 110 ++++++++++---- drivers/acpi/executer/exoparg3.c | 4 +- drivers/acpi/hardware/hwregs.c | 3 +- drivers/acpi/namespace/nsinit.c | 85 ++++++----- drivers/acpi/namespace/nssearch.c | 17 ++- drivers/acpi/namespace/nsxfeval.c | 4 +- drivers/acpi/parser/psargs.c | 198 +++++++++++++----------- drivers/acpi/parser/psloop.c | 9 ++ drivers/acpi/parser/psparse.c | 17 ++- drivers/acpi/resources/rsdump.c | 1 - drivers/acpi/utilities/utalloc.c | 4 +- drivers/acpi/utilities/uteval.c | 20 +-- drivers/acpi/utilities/utglobal.c | 9 +- drivers/acpi/utilities/utmisc.c | 2 +- drivers/acpi/utilities/utresrc.c | 109 +++++++++++++ include/acpi/acconfig.h | 2 +- include/acpi/acdisasm.h | 22 +-- include/acpi/acdispat.h | 3 + include/acpi/acglobal.h | 8 +- include/acpi/aclocal.h | 31 ++++ include/acpi/acmacros.h | 24 +-- include/acpi/actbl.h | 6 + include/acpi/actypes.h | 303 ++++++++++++++++++++----------------- include/acpi/acutils.h | 24 +++ 27 files changed, 775 insertions(+), 419 deletions(-) (limited to 'include') diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index 58ad00b31ee9..e7ce86b8d954 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c @@ -47,10 +47,68 @@ #include #include #include +#include #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME("dsmethod") +/******************************************************************************* + * + * FUNCTION: acpi_ds_method_error + * + * PARAMETERS: Status - Execution status + * walk_state - Current state + * + * RETURN: Status + * + * DESCRIPTION: Called on method error. Invoke the global exception handler if + * present, dump the method data if the disassembler is configured + * + * Note: Allows the exception handler to change the status code + * + ******************************************************************************/ +acpi_status +acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state) +{ + ACPI_FUNCTION_ENTRY(); + + /* Ignore AE_OK and control exception codes */ + + if (ACPI_SUCCESS(status) || (status & AE_CODE_CONTROL)) { + return (status); + } + + /* Invoke the global exception handler */ + + if (acpi_gbl_exception_handler) { + /* Exit the interpreter, allow handler to execute methods */ + + acpi_ex_exit_interpreter(); + + /* + * Handler can map the exception code to anything it wants, including + * AE_OK, in which case the executing method will not be aborted. + */ + status = acpi_gbl_exception_handler(status, + walk_state->method_node ? + walk_state->method_node-> + name.integer : 0, + walk_state->opcode, + walk_state->aml_offset, + NULL); + (void)acpi_ex_enter_interpreter(); + } +#ifdef ACPI_DISASSEMBLER + if (ACPI_FAILURE(status)) { + /* Display method locals/args if disassembler is present */ + + acpi_dm_dump_method_info(status, walk_state, walk_state->op); + } +#endif + + return (status); +} + /******************************************************************************* * * FUNCTION: acpi_ds_begin_method_execution @@ -66,10 +124,11 @@ ACPI_MODULE_NAME("dsmethod") * for clearance to execute. * ******************************************************************************/ + acpi_status -acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, - union acpi_operand_object *obj_desc, - struct acpi_namespace_node *calling_method_node) +acpi_ds_begin_method_execution(struct acpi_namespace_node * method_node, + union acpi_operand_object * obj_desc, + struct acpi_namespace_node * calling_method_node) { acpi_status status = AE_OK; diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c index 8ac0cd93adb5..905a84e4b145 100644 --- a/drivers/acpi/dispatcher/dsobject.c +++ b/drivers/acpi/dispatcher/dsobject.c @@ -51,6 +51,7 @@ #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME("dsobject") +/* Local prototypes */ static acpi_status acpi_ds_build_internal_object(struct acpi_walk_state *walk_state, union acpi_parse_object *op, @@ -85,7 +86,7 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state, *obj_desc_ptr = NULL; if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { /* - * This is an named object reference. If this name was + * This is a named object reference. If this name was * previously looked up in the namespace, it was stored in this op. * Otherwise, go ahead and look it up now */ @@ -96,18 +97,48 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, - (struct acpi_namespace_node **) - &(op->common.node)); - + ACPI_CAST_INDIRECT_PTR(struct + acpi_namespace_node, + &(op-> + common. + node))); if (ACPI_FAILURE(status)) { - ACPI_REPORT_NSERROR(op->common.value.string, - status); + /* Check if we are resolving a named reference within a package */ + + if ((status == AE_NOT_FOUND) + && (acpi_gbl_enable_interpreter_slack) + && + ((op->common.parent->common.aml_opcode == + AML_PACKAGE_OP) + || (op->common.parent->common.aml_opcode == + AML_VAR_PACKAGE_OP))) { + /* + * We didn't find the target and we are populating elements + * of a package - ignore if slack enabled. Some ASL code + * contains dangling invalid references in packages and + * expects that no exception will be issued. Leave the + * element as a null element. It cannot be used, but it + * can be overwritten by subsequent ASL code - this is + * typically the case. + */ + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Ignoring unresolved reference in package [%4.4s]\n", + walk_state-> + scope_info->scope. + node->name.ascii)); + + return_ACPI_STATUS(AE_OK); + } else { + ACPI_REPORT_NSERROR(op->common.value. + string, status); + } + return_ACPI_STATUS(status); } } } - /* Create and init the internal ACPI object */ + /* Create and init a new internal ACPI object */ obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info (op->common.aml_opcode))-> @@ -157,13 +188,13 @@ acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state, ACPI_FUNCTION_TRACE("ds_build_internal_buffer_obj"); + /* + * If we are evaluating a Named buffer object "Name (xxxx, Buffer)". + * The buffer object already exists (from the NS node), otherwise it must + * be created. + */ obj_desc = *obj_desc_ptr; - if (obj_desc) { - /* - * We are evaluating a Named buffer object "Name (xxxx, Buffer)". - * The buffer object already exists (from the NS node) - */ - } else { + if (!obj_desc) { /* Create a new buffer object */ obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER); @@ -259,7 +290,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, union acpi_operand_object *obj_desc = NULL; u32 package_list_length; acpi_status status = AE_OK; - u32 i; + acpi_native_uint i; ACPI_FUNCTION_TRACE("ds_build_internal_package_obj"); @@ -271,13 +302,12 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, parent = parent->common.parent; } + /* + * If we are evaluating a Named package object "Name (xxxx, Package)", + * the package object already exists, otherwise it must be created. + */ obj_desc = *obj_desc_ptr; - if (obj_desc) { - /* - * We are evaluating a Named package object "Name (xxxx, Package)". - * Get the existing package object from the NS node - */ - } else { + if (!obj_desc) { obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE); *obj_desc_ptr = obj_desc; if (!obj_desc) { @@ -291,11 +321,9 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, /* Count the number of items in the package list */ - package_list_length = 0; arg = op->common.value.arg; arg = arg->common.next; - while (arg) { - package_list_length++; + for (package_list_length = 0; arg; package_list_length++) { arg = arg->common.next; } @@ -322,12 +350,11 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, } /* - * Now init the elements of the package + * Initialize all elements of the package */ - i = 0; arg = op->common.value.arg; arg = arg->common.next; - while (arg) { + for (i = 0; arg; i++) { if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { /* Object (package or buffer) is already built */ @@ -340,8 +367,6 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, package. elements[i]); } - - i++; arg = arg->common.next; } diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c index e522763bb692..74f6996db2d7 100644 --- a/drivers/acpi/dispatcher/dswexec.c +++ b/drivers/acpi/dispatcher/dswexec.c @@ -314,12 +314,13 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state, case AML_CLASS_EXECUTE: case AML_CLASS_CREATE: - /* * Most operators with arguments. * Start a new result/operand state */ - status = acpi_ds_result_stack_push(walk_state); + if (walk_state->opcode != AML_CREATE_FIELD_OP) { + status = acpi_ds_result_stack_push(walk_state); + } break; default: @@ -723,20 +724,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) cleanup: - /* Invoke exception handler on error */ - - if (ACPI_FAILURE(status) && - acpi_gbl_exception_handler && !(status & AE_CODE_CONTROL)) { - acpi_ex_exit_interpreter(); - status = acpi_gbl_exception_handler(status, - walk_state->method_node-> - name.integer, - walk_state->opcode, - walk_state->aml_offset, - NULL); - (void)acpi_ex_enter_interpreter(); - } - if (walk_state->result_obj) { /* Break to debugger to display result */ @@ -758,18 +745,14 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) } #endif - /* Always clear the object stack */ - - walk_state->num_operands = 0; - -#ifdef ACPI_DISASSEMBLER - - /* On error, display method locals/args */ + /* Invoke exception handler on error */ if (ACPI_FAILURE(status)) { - acpi_dm_dump_method_info(status, walk_state, op); + status = acpi_ds_method_error(status, walk_state); } -#endif + /* Always clear the object stack */ + + walk_state->num_operands = 0; return_ACPI_STATUS(status); } diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c index 44d4f4bb2f92..441931cab08a 100644 --- a/drivers/acpi/dispatcher/dswload.c +++ b/drivers/acpi/dispatcher/dswload.c @@ -428,43 +428,54 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state) } } - if (op->common.aml_opcode == AML_METHOD_OP) { - /* - * method_op pkg_length name_string method_flags term_list - * - * Note: We must create the method node/object pair as soon as we - * see the method declaration. This allows later pass1 parsing - * of invocations of the method (need to know the number of - * arguments.) - */ - ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, - "LOADING-Method: State=%p Op=%p named_obj=%p\n", - walk_state, op, op->named.node)); + /* + * If we are executing a method, do not create any namespace objects + * during the load phase, only during execution. + */ + if (!walk_state->method_node) { + if (op->common.aml_opcode == AML_METHOD_OP) { + /* + * method_op pkg_length name_string method_flags term_list + * + * Note: We must create the method node/object pair as soon as we + * see the method declaration. This allows later pass1 parsing + * of invocations of the method (need to know the number of + * arguments.) + */ + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "LOADING-Method: State=%p Op=%p named_obj=%p\n", + walk_state, op, op->named.node)); - if (!acpi_ns_get_attached_object(op->named.node)) { - walk_state->operands[0] = (void *)op->named.node; - walk_state->num_operands = 1; + if (!acpi_ns_get_attached_object(op->named.node)) { + walk_state->operands[0] = + ACPI_CAST_PTR(void, op->named.node); + walk_state->num_operands = 1; - status = - acpi_ds_create_operands(walk_state, - op->common.value.arg); - if (ACPI_SUCCESS(status)) { - status = acpi_ex_create_method(op->named.data, - op->named.length, - walk_state); - } - walk_state->operands[0] = NULL; - walk_state->num_operands = 0; + status = + acpi_ds_create_operands(walk_state, + op->common.value. + arg); + if (ACPI_SUCCESS(status)) { + status = + acpi_ex_create_method(op->named. + data, + op->named. + length, + walk_state); + } + walk_state->operands[0] = NULL; + walk_state->num_operands = 0; - if (ACPI_FAILURE(status)) { - return_ACPI_STATUS(status); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } } } } - /* Pop the scope stack */ + /* Pop the scope stack (only if loading a table) */ - if (acpi_ns_opens_scope(object_type)) { + if (!walk_state->method_node && acpi_ns_opens_scope(object_type)) { ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n", acpi_ut_get_type_name(object_type), op)); @@ -1015,11 +1026,50 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) status = acpi_ds_create_node(walk_state, node, op); break; + + case AML_METHOD_OP: + /* + * method_op pkg_length name_string method_flags term_list + * + * Note: We must create the method node/object pair as soon as we + * see the method declaration. This allows later pass1 parsing + * of invocations of the method (need to know the number of + * arguments.) + */ + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "LOADING-Method: State=%p Op=%p named_obj=%p\n", + walk_state, op, op->named.node)); + + if (!acpi_ns_get_attached_object(op->named.node)) { + walk_state->operands[0] = + ACPI_CAST_PTR(void, op->named.node); + walk_state->num_operands = 1; + + status = + acpi_ds_create_operands(walk_state, + op->common.value. + arg); + if (ACPI_SUCCESS(status)) { + status = + acpi_ex_create_method(op->named. + data, + op->named. + length, + walk_state); + } + walk_state->operands[0] = NULL; + walk_state->num_operands = 0; + + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); + } + } + break; + #endif /* ACPI_NO_METHOD_EXECUTION */ default: /* All NAMED_COMPLEX opcodes must be handled above */ - /* Note: Method objects were already created in Pass 1 */ break; } break; diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/executer/exoparg3.c index 483365777670..2ea1c322970b 100644 --- a/drivers/acpi/executer/exoparg3.c +++ b/drivers/acpi/executer/exoparg3.c @@ -223,8 +223,8 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state) goto cleanup; } - if (length > 0) { - /* Copy the portion requested */ + if (buffer) { + /* We have a buffer, copy the portion requested */ ACPI_MEMCPY(buffer, operand[0]->string.pointer + index, length); diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c index 536a7aea80c9..b243f20708b7 100644 --- a/drivers/acpi/hardware/hwregs.c +++ b/drivers/acpi/hardware/hwregs.c @@ -144,7 +144,8 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b) info.parameters = NULL; info.return_object = NULL; - sleep_state_name = (char *)acpi_gbl_sleep_state_names[sleep_state]; + sleep_state_name = + ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]); status = acpi_ns_evaluate_by_name(sleep_state_name, &info); if (ACPI_FAILURE(status)) { diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c index 0a08d2f04a06..efa3f4233736 100644 --- a/drivers/acpi/namespace/nsinit.c +++ b/drivers/acpi/namespace/nsinit.c @@ -336,23 +336,22 @@ acpi_ns_init_one_device(acpi_handle obj_handle, struct acpi_parameter_info pinfo; u32 flags; acpi_status status; + struct acpi_namespace_node *ini_node; + struct acpi_namespace_node *device_node; ACPI_FUNCTION_TRACE("ns_init_one_device"); - pinfo.parameters = NULL; - pinfo.parameter_type = ACPI_PARAM_ARGS; - - pinfo.node = acpi_ns_map_handle_to_node(obj_handle); - if (!pinfo.node) { + device_node = acpi_ns_map_handle_to_node(obj_handle); + if (!device_node) { return_ACPI_STATUS(AE_BAD_PARAMETER); } /* * We will run _STA/_INI on Devices, Processors and thermal_zones only */ - if ((pinfo.node->type != ACPI_TYPE_DEVICE) && - (pinfo.node->type != ACPI_TYPE_PROCESSOR) && - (pinfo.node->type != ACPI_TYPE_THERMAL)) { + if ((device_node->type != ACPI_TYPE_DEVICE) && + (device_node->type != ACPI_TYPE_PROCESSOR) && + (device_node->type != ACPI_TYPE_THERMAL)) { return_ACPI_STATUS(AE_OK); } @@ -364,57 +363,69 @@ acpi_ns_init_one_device(acpi_handle obj_handle, info->device_count++; /* - * Run _STA to determine if we can run _INI on the device. + * Check if the _INI method exists for this device - + * if _INI does not exist, there is no need to run _STA + * No _INI means device requires no initialization + */ + status = acpi_ns_search_node(*ACPI_CAST_PTR(u32, METHOD_NAME__INI), + device_node, ACPI_TYPE_METHOD, &ini_node); + if (ACPI_FAILURE(status)) { + /* No _INI method found - move on to next device */ + + return_ACPI_STATUS(AE_OK); + } + + /* + * Run _STA to determine if we can run _INI on the device - + * the device must be present before _INI can be run. + * However, _STA is not required - assume device present if no _STA */ ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, - pinfo.node, + device_node, METHOD_NAME__STA)); - status = acpi_ut_execute_STA(pinfo.node, &flags); + pinfo.node = device_node; + pinfo.parameters = NULL; + pinfo.parameter_type = ACPI_PARAM_ARGS; + + status = acpi_ut_execute_STA(pinfo.node, &flags); if (ACPI_FAILURE(status)) { - if (pinfo.node->type == ACPI_TYPE_DEVICE) { - /* Ignore error and move on to next device */ + /* Ignore error and move on to next device */ - return_ACPI_STATUS(AE_OK); - } + return_ACPI_STATUS(AE_OK); + } - /* _STA is not required for Processor or thermal_zone objects */ - } else { + if (flags != ACPI_UINT32_MAX) { info->num_STA++; + } - if (!(flags & 0x01)) { - /* Don't look at children of a not present device */ + if (!(flags & ACPI_STA_DEVICE_PRESENT)) { + /* Don't look at children of a not present device */ - return_ACPI_STATUS(AE_CTRL_DEPTH); - } + return_ACPI_STATUS(AE_CTRL_DEPTH); } /* - * The device is present. Run _INI. + * The device is present and _INI exists. Run the _INI method. + * (We already have the _INI node from above) */ ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, pinfo.node, METHOD_NAME__INI)); - status = acpi_ns_evaluate_relative(METHOD_NAME__INI, &pinfo); - if (ACPI_FAILURE(status)) { - /* No _INI (AE_NOT_FOUND) means device requires no initialization */ - if (status != AE_NOT_FOUND) { - /* Ignore error and move on to next device */ + pinfo.node = ini_node; + status = acpi_ns_evaluate_by_handle(&pinfo); + if (ACPI_FAILURE(status)) { + /* Ignore error and move on to next device */ #ifdef ACPI_DEBUG_OUTPUT - char *scope_name = - acpi_ns_get_external_pathname(pinfo.node); + char *scope_name = acpi_ns_get_external_pathname(ini_node); - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "%s._INI failed: %s\n", - scope_name, - acpi_format_exception(status))); + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "%s._INI failed: %s\n", + scope_name, acpi_format_exception(status))); - ACPI_MEM_FREE(scope_name); + ACPI_MEM_FREE(scope_name); #endif - } - - status = AE_OK; } else { /* Delete any return object (especially if implicit_return is enabled) */ @@ -434,5 +445,5 @@ acpi_ns_init_one_device(acpi_handle obj_handle, acpi_gbl_init_handler(pinfo.node, ACPI_INIT_DEVICE_INI); } - return_ACPI_STATUS(status); + return_ACPI_STATUS(AE_OK); } diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c index 50a3ca5470ed..c1b1943d4670 100644 --- a/drivers/acpi/namespace/nssearch.c +++ b/drivers/acpi/namespace/nssearch.c @@ -99,8 +99,8 @@ acpi_ns_search_node(u32 target_name, if (scope_name) { ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Searching %s (%p) For [%4.4s] (%s)\n", - scope_name, node, - (char *)&target_name, + scope_name, node, ACPI_CAST_PTR(char, + &target_name), acpi_ut_get_type_name(type))); ACPI_MEM_FREE(scope_name); @@ -131,7 +131,7 @@ acpi_ns_search_node(u32 target_name, */ ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n", - (char *)&target_name, + ACPI_CAST_PTR(char, &target_name), acpi_ut_get_type_name(next_node-> type), next_node, @@ -160,7 +160,8 @@ acpi_ns_search_node(u32 target_name, ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Name [%4.4s] (%s) not found in search in scope [%4.4s] %p first child %p\n", - (char *)&target_name, acpi_ut_get_type_name(type), + ACPI_CAST_PTR(char, &target_name), + acpi_ut_get_type_name(type), acpi_ut_get_node_name(node), node, node->child)); return_ACPI_STATUS(AE_NOT_FOUND); @@ -210,14 +211,14 @@ acpi_ns_search_parent_tree(u32 target_name, */ if (!parent_node) { ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "[%4.4s] has no parent\n", - (char *)&target_name)); + ACPI_CAST_PTR(char, &target_name))); return_ACPI_STATUS(AE_NOT_FOUND); } if (acpi_ns_local(type)) { ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "[%4.4s] type [%s] must be local to this scope (no parent search)\n", - (char *)&target_name, + ACPI_CAST_PTR(char, &target_name), acpi_ut_get_type_name(type))); return_ACPI_STATUS(AE_NOT_FOUND); } @@ -227,7 +228,7 @@ acpi_ns_search_parent_tree(u32 target_name, ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Searching parent [%4.4s] for [%4.4s]\n", acpi_ut_get_node_name(parent_node), - (char *)&target_name)); + ACPI_CAST_PTR(char, &target_name))); /* * Search parents until target is found or we have backed up to the root @@ -360,7 +361,7 @@ acpi_ns_search_and_enter(u32 target_name, if (interpreter_mode == ACPI_IMODE_EXECUTE) { ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%4.4s Not found in %p [Not adding]\n", - (char *)&target_name, node)); + ACPI_CAST_PTR(char, &target_name), node)); return_ACPI_STATUS(AE_NOT_FOUND); } diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c index 8167af1fa57b..75b137a6a3c9 100644 --- a/drivers/acpi/namespace/nsxfeval.c +++ b/drivers/acpi/namespace/nsxfeval.c @@ -473,8 +473,8 @@ acpi_ns_get_device_callback(acpi_handle obj_handle, return (AE_CTRL_DEPTH); } - if (!(flags & 0x01)) { - /* Don't return at the device or children of the device if not there */ + if (!(flags & ACPI_STA_DEVICE_PRESENT)) { + /* Don't examine children of the device if not present */ return (AE_CTRL_DEPTH); } diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c index 6eae35febccd..e6d4cb9fd303 100644 --- a/drivers/acpi/parser/psargs.c +++ b/drivers/acpi/parser/psargs.c @@ -45,6 +45,7 @@ #include #include #include +#include #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME("psargs") @@ -211,7 +212,7 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state) * Arg - Where the namepath will be stored * arg_count - If the namepath points to a control method * the method's argument is returned here. - * method_call - Whether the namepath can possibly be the + * possible_method_call - Whether the namepath can possibly be the * start of a method call * * RETURN: Status @@ -227,11 +228,11 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state) acpi_status acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, struct acpi_parse_state *parser_state, - union acpi_parse_object *arg, u8 method_call) + union acpi_parse_object *arg, u8 possible_method_call) { char *path; union acpi_parse_object *name_op; - acpi_status status = AE_OK; + acpi_status status; union acpi_operand_object *method_desc; struct acpi_namespace_node *node; union acpi_generic_state scope_info; @@ -239,114 +240,127 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, ACPI_FUNCTION_TRACE("ps_get_next_namepath"); path = acpi_ps_get_next_namestring(parser_state); + acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); - /* Null path case is allowed */ + /* Null path case is allowed, just exit */ - if (path) { - /* - * Lookup the name in the internal namespace - */ - scope_info.scope.node = NULL; - node = parser_state->start_node; - if (node) { - scope_info.scope.node = node; - } + if (!path) { + arg->common.value.name = path; + return_ACPI_STATUS(AE_OK); + } - /* - * Lookup object. We don't want to add anything new to the namespace - * here, however. So we use MODE_EXECUTE. Allow searching of the - * parent tree, but don't open a new scope -- we just want to lookup the - * object (MUST BE mode EXECUTE to perform upsearch) - */ - status = acpi_ns_lookup(&scope_info, path, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT | - ACPI_NS_DONT_OPEN_SCOPE, NULL, &node); - if (ACPI_SUCCESS(status) && method_call) { - if (node->type == ACPI_TYPE_METHOD) { - /* This name is actually a control method invocation */ - - method_desc = acpi_ns_get_attached_object(node); - ACPI_DEBUG_PRINT((ACPI_DB_PARSE, - "Control Method - %p Desc %p Path=%p\n", - node, method_desc, path)); - - name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP); - if (!name_op) { - return_ACPI_STATUS(AE_NO_MEMORY); - } + /* Setup search scope info */ + + scope_info.scope.node = NULL; + node = parser_state->start_node; + if (node) { + scope_info.scope.node = node; + } - /* Change arg into a METHOD CALL and attach name to it */ + /* + * Lookup the name in the internal namespace. We don't want to add + * anything new to the namespace here, however, so we use MODE_EXECUTE. + * Allow searching of the parent tree, but don't open a new scope - + * we just want to lookup the object (must be mode EXECUTE to perform + * the upsearch) + */ + status = + acpi_ns_lookup(&scope_info, path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + NULL, &node); - acpi_ps_init_op(arg, AML_INT_METHODCALL_OP); - name_op->common.value.name = path; + /* + * If this name is a control method invocation, we must + * setup the method call + */ + if (ACPI_SUCCESS(status) && + possible_method_call && (node->type == ACPI_TYPE_METHOD)) { + /* This name is actually a control method invocation */ - /* Point METHODCALL/NAME to the METHOD Node */ + method_desc = acpi_ns_get_attached_object(node); + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "Control Method - %p Desc %p Path=%p\n", node, + method_desc, path)); - name_op->common.node = node; - acpi_ps_append_arg(arg, name_op); + name_op = acpi_ps_alloc_op(AML_INT_NAMEPATH_OP); + if (!name_op) { + return_ACPI_STATUS(AE_NO_MEMORY); + } - if (!method_desc) { - ACPI_REPORT_ERROR(("ps_get_next_namepath: Control Method %p has no attached object\n", node)); - return_ACPI_STATUS(AE_AML_INTERNAL); - } + /* Change Arg into a METHOD CALL and attach name to it */ - ACPI_DEBUG_PRINT((ACPI_DB_PARSE, - "Control Method - %p Args %X\n", - node, - method_desc->method. - param_count)); + acpi_ps_init_op(arg, AML_INT_METHODCALL_OP); + name_op->common.value.name = path; - /* Get the number of arguments to expect */ + /* Point METHODCALL/NAME to the METHOD Node */ - walk_state->arg_count = - method_desc->method.param_count; - return_ACPI_STATUS(AE_OK); - } + name_op->common.node = node; + acpi_ps_append_arg(arg, name_op); - /* - * Else this is normal named object reference. - * Just init the NAMEPATH object with the pathname. - * (See code below) - */ + if (!method_desc) { + ACPI_REPORT_ERROR(("ps_get_next_namepath: Control Method %p has no attached object\n", node)); + return_ACPI_STATUS(AE_AML_INTERNAL); } - if (ACPI_FAILURE(status)) { - /* - * 1) Any error other than NOT_FOUND is always severe - * 2) NOT_FOUND is only important if we are executing a method. - * 3) If executing a cond_ref_of opcode, NOT_FOUND is ok. - */ - if ((((walk_state-> - parse_flags & ACPI_PARSE_MODE_MASK) == - ACPI_PARSE_EXECUTE) && (status == AE_NOT_FOUND) - && (walk_state->op->common.aml_opcode != - AML_COND_REF_OF_OP)) - || (status != AE_NOT_FOUND)) { - ACPI_REPORT_NSERROR(path, status); - - acpi_os_printf - ("search_node %p start_node %p return_node %p\n", - scope_info.scope.node, - parser_state->start_node, node); - } else { - /* - * We got a NOT_FOUND during table load or we encountered - * a cond_ref_of(x) where the target does not exist. - * Either case is ok - */ - status = AE_OK; - } - } + ACPI_DEBUG_PRINT((ACPI_DB_PARSE, + "Control Method - %p Args %X\n", + node, method_desc->method.param_count)); + + /* Get the number of arguments to expect */ + + walk_state->arg_count = method_desc->method.param_count; + return_ACPI_STATUS(AE_OK); } /* - * Regardless of success/failure above, - * Just initialize the Op with the pathname. + * Special handling if the name was not found during the lookup - + * some not_found cases are allowed */ - acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); - arg->common.value.name = path; + if (status == AE_NOT_FOUND) { + /* 1) not_found is ok during load pass 1/2 (allow forward references) */ + + if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) != + ACPI_PARSE_EXECUTE) { + status = AE_OK; + } + + /* 2) not_found during a cond_ref_of(x) is ok by definition */ + + else if (walk_state->op->common.aml_opcode == + AML_COND_REF_OF_OP) { + status = AE_OK; + } + + /* + * 3) not_found while building a Package is ok at this point, we + * may flag as an error later if slack mode is not enabled. + * (Some ASL code depends on allowing this behavior) + */ + else if ((arg->common.parent) && + ((arg->common.parent->common.aml_opcode == + AML_PACKAGE_OP) + || (arg->common.parent->common.aml_opcode == + AML_VAR_PACKAGE_OP))) { + status = AE_OK; + } + } + + /* Final exception check (may have been changed from code above) */ + + if (ACPI_FAILURE(status)) { + ACPI_REPORT_NSERROR(path, status); + + if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == + ACPI_PARSE_EXECUTE) { + /* Report a control method execution error */ + status = acpi_ds_method_error(status, walk_state); + } + } + + /* Save the namepath */ + + arg->common.value.name = path; return_ACPI_STATUS(status); } diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c index 088d33999d90..e81e51b8b3ae 100644 --- a/drivers/acpi/parser/psloop.c +++ b/drivers/acpi/parser/psloop.c @@ -704,6 +704,15 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state) acpi_ps_pop_scope(parser_state, &op, &walk_state->arg_types, &walk_state->arg_count); + + if (op->common.aml_opcode != AML_WHILE_OP) { + status2 = + acpi_ds_result_stack_pop + (walk_state); + if (ACPI_FAILURE(status2)) { + return_ACPI_STATUS(status2); + } + } } /* Close this iteration of the While loop */ diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c index 7cfa7eb0dfc7..f0979b2956f2 100644 --- a/drivers/acpi/parser/psparse.c +++ b/drivers/acpi/parser/psparse.c @@ -333,7 +333,6 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state, switch (callback_status) { case AE_CTRL_TERMINATE: - /* * A control method was terminated via a RETURN statement. * The walk of this method is complete. @@ -346,13 +345,19 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state, parser_state->aml = walk_state->aml_last_while; walk_state->control_state->common.value = FALSE; - status = AE_CTRL_BREAK; + status = acpi_ds_result_stack_pop(walk_state); + if (ACPI_SUCCESS(status)) { + status = AE_CTRL_BREAK; + } break; case AE_CTRL_CONTINUE: parser_state->aml = walk_state->aml_last_while; - status = AE_CTRL_CONTINUE; + status = acpi_ds_result_stack_pop(walk_state); + if (ACPI_SUCCESS(status)) { + status = AE_CTRL_CONTINUE; + } break; case AE_CTRL_PENDING: @@ -369,16 +374,18 @@ acpi_ps_next_parse_state(struct acpi_walk_state *walk_state, #endif case AE_CTRL_TRUE: - /* * Predicate of an IF was true, and we are at the matching ELSE. * Just close out this package */ parser_state->aml = acpi_ps_get_next_package_end(parser_state); + status = acpi_ds_result_stack_pop(walk_state); + if (ACPI_SUCCESS(status)) { + status = AE_CTRL_PENDING; + } break; case AE_CTRL_FALSE: - /* * Either an IF/WHILE Predicate was false or we encountered a BREAK * opcode. In both cases, we do not execute the rest of the diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c index cebd890d3db5..c24e3eb658c3 100644 --- a/drivers/acpi/resources/rsdump.c +++ b/drivers/acpi/resources/rsdump.c @@ -43,7 +43,6 @@ #include #include -#include #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME("rsdump") diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c index e04b6119a4d7..b11b7ed788c6 100644 --- a/drivers/acpi/utilities/utalloc.c +++ b/drivers/acpi/utilities/utalloc.c @@ -47,7 +47,7 @@ ACPI_MODULE_NAME("utalloc") /* Local prototypes */ -#ifdef ACPI_DBG_TRACK_ALLOCATIONS +#ifdef ACPI_DBG_TRACK_ALLOCATIONS static struct acpi_debug_mem_block *acpi_ut_find_allocation(void *allocation); static acpi_status @@ -58,9 +58,7 @@ acpi_ut_track_allocation(struct acpi_debug_mem_block *address, static acpi_status acpi_ut_remove_allocation(struct acpi_debug_mem_block *address, u32 component, char *module, u32 line); -#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ -#ifdef ACPI_DBG_TRACK_ALLOCATIONS static acpi_status acpi_ut_create_list(char *list_name, u16 object_size, struct acpi_memory_list **return_cache); diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c index 7b81d5ef3c32..cd63a2d93fe3 100644 --- a/drivers/acpi/utilities/uteval.c +++ b/drivers/acpi/utilities/uteval.c @@ -95,7 +95,9 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++) { if (!ACPI_STRCMP(string_desc->string.pointer, - (char *)acpi_gbl_valid_osi_strings[i])) { + ACPI_CAST_PTR(char, + acpi_gbl_valid_osi_strings[i]))) + { /* This string is supported */ return_desc->integer.value = 0xFFFFFFFF; @@ -592,7 +594,7 @@ acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags) "_STA on %4.4s was not found, assuming device is present\n", acpi_ut_get_node_name(device_node))); - *flags = 0x0F; + *flags = ACPI_UINT32_MAX; status = AE_OK; } @@ -637,17 +639,17 @@ acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest) for (i = 0; i < 4; i++) { highest[i] = 0xFF; status = acpi_ut_evaluate_object(device_node, - (char *) - acpi_gbl_highest_dstate_names - [i], ACPI_BTYPE_INTEGER, - &obj_desc); + ACPI_CAST_PTR(char, + acpi_gbl_highest_dstate_names + [i]), + ACPI_BTYPE_INTEGER, &obj_desc); if (ACPI_FAILURE(status)) { if (status != AE_NOT_FOUND) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s on Device %4.4s, %s\n", - (char *) - acpi_gbl_highest_dstate_names - [i], + ACPI_CAST_PTR(char, + acpi_gbl_highest_dstate_names + [i]), acpi_ut_get_node_name (device_node), acpi_format_exception diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index 6828c7aefa8a..7c59c2b0d953 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c @@ -485,7 +485,7 @@ char *acpi_ut_get_region_name(u8 space_id) return ("invalid_space_id"); } - return ((char *)acpi_gbl_region_types[space_id]); + return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id])); } /******************************************************************************* @@ -690,11 +690,12 @@ char *acpi_ut_get_descriptor_name(void *object) } if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) { - return ((char *)acpi_gbl_bad_type); + return (ACPI_CAST_PTR(char, acpi_gbl_bad_type)); } - return ((char *) - acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE(object)]); + return (ACPI_CAST_PTR(char, + acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE + (object)])); } diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index 64dd64b1aa18..48d511d5c04b 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -179,7 +179,7 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) /* Zero is not a valid owner_iD */ - if ((owner_id == 0) || (owner_id > 255)) { + if (owner_id == 0) { ACPI_REPORT_ERROR(("Invalid owner_id: %2.2X\n", owner_id)); return_VOID; } diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c index 6c0ce7b12194..eaf0edec6efe 100644 --- a/drivers/acpi/utilities/utresrc.c +++ b/drivers/acpi/utilities/utresrc.c @@ -47,6 +47,115 @@ #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME("utmisc") +#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) +/* + * Strings used to decode resource descriptors. + * Used by both the disasssembler and the debugger resource dump routines + */ +const char *acpi_gbl_BMdecode[2] = { + "not_bus_master", + "bus_master" +}; + +const char *acpi_gbl_config_decode[4] = { + "0 - Good Configuration", + "1 - Acceptable Configuration", + "2 - Suboptimal Configuration", + "3 - ***Invalid Configuration***", +}; + +const char *acpi_gbl_consume_decode[2] = { + "resource_producer", + "resource_consumer" +}; + +const char *acpi_gbl_DECdecode[2] = { + "pos_decode", + "sub_decode" +}; + +const char *acpi_gbl_HEdecode[2] = { + "Level", + "Edge" +}; + +const char *acpi_gbl_io_decode[2] = { + "Decode10", + "Decode16" +}; + +const char *acpi_gbl_LLdecode[2] = { + "active_high", + "active_low" +}; + +const char *acpi_gbl_max_decode[2] = { + "max_not_fixed", + "max_fixed" +}; + +const char *acpi_gbl_MEMdecode[4] = { + "non_cacheable", + "Cacheable", + "write_combining", + "Prefetchable" +}; + +const char *acpi_gbl_min_decode[2] = { + "min_not_fixed", + "min_fixed" +}; + +const char *acpi_gbl_MTPdecode[4] = { + "address_range_memory", + "address_range_reserved", + "address_range_aCPI", + "address_range_nVS" +}; + +const char *acpi_gbl_RNGdecode[4] = { + "invalid_ranges", + "non_iSAonly_ranges", + "ISAonly_ranges", + "entire_range" +}; + +const char *acpi_gbl_RWdecode[2] = { + "read_only", + "read_write" +}; + +const char *acpi_gbl_SHRdecode[2] = { + "Exclusive", + "Shared" +}; + +const char *acpi_gbl_SIZdecode[4] = { + "Transfer8", + "Transfer8_16", + "Transfer16", + "invalid_size" +}; + +const char *acpi_gbl_TRSdecode[2] = { + "dense_translation", + "sparse_translation" +}; + +const char *acpi_gbl_TTPdecode[2] = { + "type_static", + "type_translation" +}; + +const char *acpi_gbl_TYPdecode[4] = { + "Compatibility", + "type_a", + "type_b", + "type_f" +}; + +#endif + /* * Base sizes of the raw AML resource descriptors, indexed by resource type. * Zero indicates a reserved (and therefore invalid) resource type. diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index f48b9ee9a876..1f2477eb95fe 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -63,7 +63,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20051202 +#define ACPI_CA_VERSION 0x20051216 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, diff --git a/include/acpi/acdisasm.h b/include/acpi/acdisasm.h index 99250ee1b9d1..0a8f49f5d2f1 100644 --- a/include/acpi/acdisasm.h +++ b/include/acpi/acdisasm.h @@ -57,27 +57,11 @@ struct acpi_external_list { }; extern struct acpi_external_list *acpi_gbl_external_list; -extern const char *acpi_gbl_io_decode[2]; + +/* Strings used for decoding flags to ASL keywords */ + extern const char *acpi_gbl_word_decode[4]; -extern const char *acpi_gbl_consume_decode[2]; -extern const char *acpi_gbl_config_decode[4]; -extern const char *acpi_gbl_min_decode[2]; -extern const char *acpi_gbl_max_decode[2]; -extern const char *acpi_gbl_DECdecode[2]; -extern const char *acpi_gbl_RNGdecode[4]; -extern const char *acpi_gbl_MEMdecode[4]; -extern const char *acpi_gbl_RWdecode[2]; extern const char *acpi_gbl_irq_decode[2]; -extern const char *acpi_gbl_HEdecode[2]; -extern const char *acpi_gbl_LLdecode[2]; -extern const char *acpi_gbl_SHRdecode[2]; -extern const char *acpi_gbl_TYPdecode[4]; -extern const char *acpi_gbl_BMdecode[2]; -extern const char *acpi_gbl_SIZdecode[4]; -extern const char *acpi_gbl_TTPdecode[2]; -extern const char *acpi_gbl_MTPdecode[4]; -extern const char *acpi_gbl_TRSdecode[2]; - extern const char *acpi_gbl_lock_rule[ACPI_NUM_LOCK_RULES]; extern const char *acpi_gbl_access_types[ACPI_NUM_ACCESS_TYPES]; extern const char *acpi_gbl_update_rules[ACPI_NUM_UPDATE_RULES]; diff --git a/include/acpi/acdispat.h b/include/acpi/acdispat.h index 065f24a77cfc..cc6407eef701 100644 --- a/include/acpi/acdispat.h +++ b/include/acpi/acdispat.h @@ -201,6 +201,9 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, union acpi_operand_object *obj_desc, struct acpi_namespace_node *calling_method_node); +acpi_status +acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state); + /* * dsinit */ diff --git a/include/acpi/acglobal.h b/include/acpi/acglobal.h index 3f37560c26ab..dfb3b2493ae5 100644 --- a/include/acpi/acglobal.h +++ b/include/acpi/acglobal.h @@ -98,11 +98,15 @@ ACPI_EXTERN u32 acpi_gbl_trace_flags; /* * Enable "slack" in the AML interpreter? Default is FALSE, and the * interpreter strictly follows the ACPI specification. Setting to TRUE - * allows the interpreter to forgive certain bad AML constructs. Currently: + * allows the interpreter to ignore certain errors and/or bad AML constructs. + * + * Currently, these features are enabled by this flag: + * * 1) Allow "implicit return" of last value in a control method - * 2) Allow access beyond end of operation region + * 2) Allow access beyond the end of an operation region * 3) Allow access to uninitialized locals/args (auto-init to integer 0) * 4) Allow ANY object type to be a source operand for the Store() operator + * 5) Allow unresolved references (invalid target name) in package objects */ ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_interpreter_slack, FALSE); diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h index 0cb61a72d971..da7f1cb96f5d 100644 --- a/include/acpi/aclocal.h +++ b/include/acpi/aclocal.h @@ -276,6 +276,37 @@ struct acpi_create_field_info { u8 field_type; }; +/* + * Bitmapped ACPI types. Used internally only + */ +#define ACPI_BTYPE_ANY 0x00000000 +#define ACPI_BTYPE_INTEGER 0x00000001 +#define ACPI_BTYPE_STRING 0x00000002 +#define ACPI_BTYPE_BUFFER 0x00000004 +#define ACPI_BTYPE_PACKAGE 0x00000008 +#define ACPI_BTYPE_FIELD_UNIT 0x00000010 +#define ACPI_BTYPE_DEVICE 0x00000020 +#define ACPI_BTYPE_EVENT 0x00000040 +#define ACPI_BTYPE_METHOD 0x00000080 +#define ACPI_BTYPE_MUTEX 0x00000100 +#define ACPI_BTYPE_REGION 0x00000200 +#define ACPI_BTYPE_POWER 0x00000400 +#define ACPI_BTYPE_PROCESSOR 0x00000800 +#define ACPI_BTYPE_THERMAL 0x00001000 +#define ACPI_BTYPE_BUFFER_FIELD 0x00002000 +#define ACPI_BTYPE_DDB_HANDLE 0x00004000 +#define ACPI_BTYPE_DEBUG_OBJECT 0x00008000 +#define ACPI_BTYPE_REFERENCE 0x00010000 +#define ACPI_BTYPE_RESOURCE 0x00020000 + +#define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER) + +#define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE) +#define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE) +#define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR) +#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ +#define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF + /***************************************************************************** * * Event typedefs and structs diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h index 65a1a5c1a689..0fa8f72dbace 100644 --- a/include/acpi/acmacros.h +++ b/include/acpi/acmacros.h @@ -60,7 +60,7 @@ /* * For 16-bit addresses, we have to assume that the upper 32 bits - * are zero. + * (out of 64) are zero. */ #define ACPI_LODWORD(l) ((u32)(l)) #define ACPI_HIDWORD(l) ((u32)(0)) @@ -104,8 +104,9 @@ #define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i),ACPI_LODWORD(i) /* - * Extract a byte of data using a pointer. Any more than a byte and we - * get into potential aligment issues -- see the STORE macros below + * Extract data using a pointer. Any more than a byte and we + * get into potential aligment issues -- see the STORE macros below. + * Use with care. */ #define ACPI_GET8(ptr) *ACPI_CAST_PTR (u8, ptr) #define ACPI_GET16(ptr) *ACPI_CAST_PTR (u16, ptr) @@ -116,16 +117,17 @@ #define ACPI_SET32(ptr) *ACPI_CAST_PTR (u32, ptr) #define ACPI_SET64(ptr) *ACPI_CAST_PTR (u64, ptr) -/* Pointer manipulation */ - -#define ACPI_CAST_PTR(t, p) ((t *)(void *)(p)) -#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **)(void *)(p)) -#define ACPI_ADD_PTR(t,a,b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8, (a)) + (acpi_native_uint)(b))) -#define ACPI_PTR_DIFF(a,b) (acpi_native_uint) ((char *)(a) - (char *)(b)) +/* + * Pointer manipulation + */ +#define ACPI_CAST_PTR(t, p) ((t *) (acpi_uintptr_t) (p)) +#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (acpi_uintptr_t) (p)) +#define ACPI_ADD_PTR(t,a,b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8,(a)) + (acpi_native_uint)(b))) +#define ACPI_PTR_DIFF(a,b) (acpi_native_uint) (ACPI_CAST_PTR (u8,(a)) - ACPI_CAST_PTR (u8,(b))) /* Pointer/Integer type conversions */ -#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL,(acpi_native_uint)i) +#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void,(void *) NULL,(acpi_native_uint) i) #define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,(void *) NULL) #define ACPI_OFFSET(d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL) #define ACPI_FADT_OFFSET(f) ACPI_OFFSET (FADT_DESCRIPTOR, f) @@ -133,7 +135,7 @@ #if ACPI_MACHINE_WIDTH == 16 #define ACPI_STORE_POINTER(d,s) ACPI_MOVE_32_TO_32(d,s) #define ACPI_PHYSADDR_TO_PTR(i) (void *)(i) -#define ACPI_PTR_TO_PHYSADDR(i) (u32) (char *)(i) +#define ACPI_PTR_TO_PHYSADDR(i) (u32) ACPI_CAST_PTR (u8,(i)) #else #define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) #define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h index a46f406e1c94..ef2ddcadfe61 100644 --- a/include/acpi/actbl.h +++ b/include/acpi/actbl.h @@ -44,6 +44,12 @@ #ifndef __ACTBL_H__ #define __ACTBL_H__ +/* + * Note about bitfields: The u8 type is used for bitfields in ACPI tables. + * This is the only type that is even remotely portable. Anything else is not + * portable, so do not use any other bitfield types. + */ + /* * Values for description table header signatures */ diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 11847592ed1b..18e1338c5c7f 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -44,7 +44,15 @@ #ifndef __ACTYPES_H__ #define __ACTYPES_H__ -/*! [Begin] no source code translation (keep the typedefs) */ +/* + * ACPI_MACHINE_WIDTH must be specified in an OS- or compiler-dependent header + * and must be either 16, 32, or 64 + */ +#ifndef ACPI_MACHINE_WIDTH +#error ACPI_MACHINE_WIDTH not defined +#endif + +/*! [Begin] no source code translation */ /* * Data type ranges @@ -58,154 +66,210 @@ #define ACPI_UINT64_MAX (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */ #define ACPI_ASCII_MAX 0x7F -#ifdef DEFINE_ALTERNATE_TYPES /* - * Types used only in translated source, defined here to enable - * cross-platform compilation only. + * Architecture-specific ACPICA Subsystem Data Types + * + * The goal of these types is to provide source code portability across + * 16-bit, 32-bit, and 64-bit targets. + * + * 1) The following types are of fixed size for all targets (16/32/64): + * + * BOOLEAN Logical boolean + * + * UINT8 8-bit (1 byte) unsigned value + * UINT16 16-bit (2 byte) unsigned value + * UINT32 32-bit (4 byte) unsigned value + * UINT64 64-bit (8 byte) unsigned value + * + * INT16 16-bit (2 byte) signed value + * INT32 32-bit (4 byte) signed value + * INT64 64-bit (8 byte) signed value + * + * COMPILER_DEPENDENT_UINT64/INT64 - These types are defined in the + * compiler-dependent header(s) and were introduced because there is no common + * 64-bit integer type across the various compilation models, as shown in + * the table below. + * + * Datatype LP64 ILP64 LLP64 ILP32 LP32 16bit + * char 8 8 8 8 8 8 + * short 16 16 16 16 16 16 + * _int32 32 + * int 32 64 32 32 16 16 + * long 64 64 32 32 32 32 + * long long 64 64 + * pointer 64 64 64 32 32 32 + * + * Note: ILP64 and LP32 are currently not supported. + * + * + * 2) These types represent the native word size of the target mode of the + * processor, and may be 16-bit, 32-bit, or 64-bit as required. They are + * usually used for memory allocation, efficient loop counters, and array + * indexes. The types are similar to the size_t type in the C library and are + * required because there is no C type that consistently represents the native + * data width. + * + * ACPI_SIZE 16/32/64-bit unsigned value + * ACPI_NATIVE_UINT 16/32/64-bit unsigned value + * ACPI_NATIVE_INT 16/32/64-bit signed value + * */ -typedef int s32; -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -typedef COMPILER_DEPENDENT_UINT64 u64; -#endif - -/* - * Data types - Fixed across all compilation models (16/32/64) +/******************************************************************************* * - * BOOLEAN Logical Boolean. - * INT8 8-bit (1 byte) signed value - * UINT8 8-bit (1 byte) unsigned value - * INT16 16-bit (2 byte) signed value - * UINT16 16-bit (2 byte) unsigned value - * INT32 32-bit (4 byte) signed value - * UINT32 32-bit (4 byte) unsigned value - * INT64 64-bit (8 byte) signed value - * UINT64 64-bit (8 byte) unsigned value - * ACPI_NATIVE_UINT 32-bit on IA-32, 64-bit on x86_64/IA-64 unsigned value - */ + * Common types for all compilers, all targets + * + ******************************************************************************/ + +typedef unsigned char BOOLEAN; +typedef unsigned char UINT8; +typedef unsigned short UINT16; +typedef COMPILER_DEPENDENT_UINT64 UINT64; +typedef COMPILER_DEPENDENT_INT64 INT64; -typedef unsigned long acpi_native_uint; +/*! [End] no source code translation !*/ -#ifndef ACPI_MACHINE_WIDTH -#error ACPI_MACHINE_WIDTH not defined -#endif +/******************************************************************************* + * + * Types specific to 64-bit targets + * + ******************************************************************************/ #if ACPI_MACHINE_WIDTH == 64 -/*! [Begin] no source code translation (keep the typedefs) */ +/*! [Begin] no source code translation (keep the typedefs as-is) */ -/* - * 64-bit type definitions - */ -typedef unsigned char UINT8; -typedef unsigned char BOOLEAN; -typedef unsigned short UINT16; -typedef int INT32; typedef unsigned int UINT32; -typedef COMPILER_DEPENDENT_INT64 INT64; -typedef COMPILER_DEPENDENT_UINT64 UINT64; +typedef int INT32; /*! [End] no source code translation !*/ +typedef u64 acpi_native_uint; +typedef s64 acpi_native_int; + typedef u64 acpi_table_ptr; typedef u64 acpi_io_address; typedef u64 acpi_physical_address; -typedef u64 acpi_size; -#define ALIGNED_ADDRESS_BOUNDARY 0x00000008 /* No hardware alignment support in IA64 */ -#define ACPI_USE_NATIVE_DIVIDE /* Native 64-bit integer support */ #define ACPI_MAX_PTR ACPI_UINT64_MAX #define ACPI_SIZE_MAX ACPI_UINT64_MAX +#define ALIGNED_ADDRESS_BOUNDARY 0x00000008 +#define ACPI_USE_NATIVE_DIVIDE /* Has native 64-bit integer support */ + /* * In the case of the Itanium Processor Family (IPF), the hardware does not * support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED flag * to indicate that special precautions must be taken to avoid alignment faults. * (IA64 or ia64 is currently used by existing compilers to indicate IPF.) * - * Note: Em64_t and other X86-64 processors do support misaligned transfers, + * Note: Em64_t and other X86-64 processors support misaligned transfers, * so there is no need to define this flag. */ #if defined (__IA64__) || defined (__ia64__) #define ACPI_MISALIGNMENT_NOT_SUPPORTED #endif +/******************************************************************************* + * + * Types specific to 32-bit targets + * + ******************************************************************************/ + +#elif ACPI_MACHINE_WIDTH == 32 + +/*! [Begin] no source code translation (keep the typedefs as-is) */ + +typedef unsigned int UINT32; +typedef int INT32; + +/*! [End] no source code translation !*/ + +typedef u32 acpi_native_uint; +typedef s32 acpi_native_int; + +typedef u64 acpi_table_ptr; +typedef u32 acpi_io_address; +typedef u64 acpi_physical_address; + +#define ACPI_MAX_PTR ACPI_UINT32_MAX +#define ACPI_SIZE_MAX ACPI_UINT32_MAX + +#define ALIGNED_ADDRESS_BOUNDARY 0x00000004 + +/******************************************************************************* + * + * Types specific to 16-bit targets + * + ******************************************************************************/ + #elif ACPI_MACHINE_WIDTH == 16 /*! [Begin] no source code translation (keep the typedefs as-is) */ -/* - * 16-bit type definitions - */ -typedef unsigned char UINT8; -typedef unsigned char BOOLEAN; -typedef unsigned int UINT16; -typedef long INT32; -typedef int INT16; typedef unsigned long UINT32; - -struct { - UINT32 Lo; - UINT32 Hi; -}; +typedef short INT16; +typedef long INT32; /*! [End] no source code translation !*/ +typedef u16 acpi_native_uint; +typedef s16 acpi_native_int; + typedef u32 acpi_table_ptr; typedef u32 acpi_io_address; typedef char *acpi_physical_address; -typedef u16 acpi_size; -#define ALIGNED_ADDRESS_BOUNDARY 0x00000002 -#define ACPI_USE_NATIVE_DIVIDE /* No 64-bit integers, ok to use native divide */ #define ACPI_MAX_PTR ACPI_UINT16_MAX #define ACPI_SIZE_MAX ACPI_UINT16_MAX -/* - * (16-bit only) internal integers must be 32-bits, so - * 64-bit integers cannot be supported - */ -#define ACPI_NO_INTEGER64_SUPPORT +#define ALIGNED_ADDRESS_BOUNDARY 0x00000002 +#define ACPI_USE_NATIVE_DIVIDE /* No 64-bit integers, ok to use native divide */ -#elif ACPI_MACHINE_WIDTH == 32 +/* 64-bit integers cannot be supported */ -/*! [Begin] no source code translation (keep the typedefs) */ +#define ACPI_NO_INTEGER64_SUPPORT -/* - * 32-bit type definitions (default) - */ -typedef unsigned char UINT8; -typedef unsigned char BOOLEAN; -typedef unsigned short UINT16; -typedef int INT32; -typedef unsigned int UINT32; -typedef COMPILER_DEPENDENT_INT64 INT64; -typedef COMPILER_DEPENDENT_UINT64 UINT64; +#else -/*! [End] no source code translation !*/ +/* ACPI_MACHINE_WIDTH must be either 64, 32, or 16 */ -typedef u64 acpi_table_ptr; -typedef u32 acpi_io_address; -typedef u64 acpi_physical_address; -typedef u32 acpi_size; +#error unknown ACPI_MACHINE_WIDTH +#endif -#define ALIGNED_ADDRESS_BOUNDARY 0x00000004 -#define ACPI_MAX_PTR ACPI_UINT32_MAX -#define ACPI_SIZE_MAX ACPI_UINT32_MAX +/******************************************************************************* + * + * OS- or compiler-dependent types + * + ******************************************************************************/ -#else -#error unknown ACPI_MACHINE_WIDTH +/* + * If acpi_uintptr_t was not defined in the OS- or compiler-dependent header, + * define it now (use C99 uintptr_t for pointer casting if available, + * "void *" otherwise) + */ +#ifndef acpi_uintptr_t +#define acpi_uintptr_t void * #endif /* - * This type is used for bitfields in ACPI tables. The only type that is - * even remotely portable is u8. Anything else is not portable, so - * do not add any more bitfield types. + * If acpi_cache_t was not defined in the OS-dependent header, + * define it now. This is typically the case where the local cache + * manager implementation is to be used (ACPI_USE_LOCAL_CACHE) */ -typedef u8 UINT8_BIT; -typedef acpi_native_uint ACPI_PTRDIFF; +#ifndef acpi_cache_t +#define acpi_cache_t struct acpi_memory_list +#endif + +/* Variable-width type, used instead of clib size_t */ + +typedef acpi_native_uint acpi_size; + +/******************************************************************************* + * + * Independent types + * + ******************************************************************************/ /* * Pointer overlays to avoid lots of typecasting for @@ -237,18 +301,8 @@ struct acpi_pointer { #define ACPI_LOGMODE_PHYSPTR ACPI_LOGICAL_ADDRESSING | ACPI_PHYSICAL_POINTER #define ACPI_LOGMODE_LOGPTR ACPI_LOGICAL_ADDRESSING | ACPI_LOGICAL_POINTER -/* - * If acpi_cache_t was not defined in the OS-dependent header, - * define it now. This is typically the case where the local cache - * manager implementation is to be used (ACPI_USE_LOCAL_CACHE) - */ -#ifndef acpi_cache_t -#define acpi_cache_t struct acpi_memory_list -#endif +/* Logical defines and NULL */ -/* - * Useful defines - */ #ifdef FALSE #undef FALSE #endif @@ -264,12 +318,12 @@ struct acpi_pointer { #endif /* - * Local datatypes + * Mescellaneous types */ typedef u32 acpi_status; /* All ACPI Exceptions */ typedef u32 acpi_name; /* 4-byte ACPI name */ typedef char *acpi_string; /* Null terminated ASCII string */ -typedef void *acpi_handle; /* Actually a ptr to an Node */ +typedef void *acpi_handle; /* Actually a ptr to a NS Node */ struct uint64_struct { u32 lo; @@ -472,37 +526,6 @@ typedef u32 acpi_object_type; #define ACPI_TYPE_INVALID 0x1E #define ACPI_TYPE_NOT_FOUND 0xFF -/* - * Bitmapped ACPI types. Used internally only - */ -#define ACPI_BTYPE_ANY 0x00000000 -#define ACPI_BTYPE_INTEGER 0x00000001 -#define ACPI_BTYPE_STRING 0x00000002 -#define ACPI_BTYPE_BUFFER 0x00000004 -#define ACPI_BTYPE_PACKAGE 0x00000008 -#define ACPI_BTYPE_FIELD_UNIT 0x00000010 -#define ACPI_BTYPE_DEVICE 0x00000020 -#define ACPI_BTYPE_EVENT 0x00000040 -#define ACPI_BTYPE_METHOD 0x00000080 -#define ACPI_BTYPE_MUTEX 0x00000100 -#define ACPI_BTYPE_REGION 0x00000200 -#define ACPI_BTYPE_POWER 0x00000400 -#define ACPI_BTYPE_PROCESSOR 0x00000800 -#define ACPI_BTYPE_THERMAL 0x00001000 -#define ACPI_BTYPE_BUFFER_FIELD 0x00002000 -#define ACPI_BTYPE_DDB_HANDLE 0x00004000 -#define ACPI_BTYPE_DEBUG_OBJECT 0x00008000 -#define ACPI_BTYPE_REFERENCE 0x00010000 -#define ACPI_BTYPE_RESOURCE 0x00020000 - -#define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER) - -#define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE) -#define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE) -#define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR) -#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ -#define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF - /* * All I/O */ @@ -856,6 +879,14 @@ struct acpi_compatible_id_list { #define ACPI_VALID_CID 0x0010 #define ACPI_VALID_SXDS 0x0020 +/* Flags for _STA method */ + +#define ACPI_STA_DEVICE_PRESENT 0x01 +#define ACPI_STA_DEVICE_ENABLED 0x02 +#define ACPI_STA_DEVICE_UI 0x04 +#define ACPI_STA_DEVICE_OK 0x08 +#define ACPI_STA_BATTERY_PRESENT 0x10 + #define ACPI_COMMON_OBJ_INFO \ acpi_object_type type; /* ACPI object type */ \ acpi_name name /* ACPI object Name */ @@ -921,7 +952,9 @@ typedef u32 acpi_rsdesc_size; /* Max Resource Descriptor size is (length+3) = (6 #define ACPI_ISA_ONLY_RANGES (u8) 0x02 #define ACPI_ENTIRE_RANGE (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES) -#define ACPI_SPARSE_TRANSLATION (u8) 0x03 +/* Type of translation - 1=Sparse, 0=Dense */ + +#define ACPI_SPARSE_TRANSLATION (u8) 0x01 /* * IO Port Descriptor Decode diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h index 4ff963323de3..5fa21e03a62f 100644 --- a/include/acpi/acutils.h +++ b/include/acpi/acutils.h @@ -46,6 +46,30 @@ extern const u8 acpi_gbl_resource_aml_sizes[]; +/* Strings used by the disassembler and debugger resource dump routines */ + +#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) + +extern const char *acpi_gbl_BMdecode[2]; +extern const char *acpi_gbl_config_decode[4]; +extern const char *acpi_gbl_consume_decode[2]; +extern const char *acpi_gbl_DECdecode[2]; +extern const char *acpi_gbl_HEdecode[2]; +extern const char *acpi_gbl_io_decode[2]; +extern const char *acpi_gbl_LLdecode[2]; +extern const char *acpi_gbl_max_decode[2]; +extern const char *acpi_gbl_MEMdecode[4]; +extern const char *acpi_gbl_min_decode[2]; +extern const char *acpi_gbl_MTPdecode[4]; +extern const char *acpi_gbl_RNGdecode[4]; +extern const char *acpi_gbl_RWdecode[2]; +extern const char *acpi_gbl_SHRdecode[2]; +extern const char *acpi_gbl_SIZdecode[4]; +extern const char *acpi_gbl_TRSdecode[2]; +extern const char *acpi_gbl_TTPdecode[2]; +extern const char *acpi_gbl_TYPdecode[4]; +#endif + /* Types for Resource descriptor entries */ #define ACPI_INVALID_RESOURCE 0 -- cgit v1.2.3 From 757b18661ea0a0d890e8ce7b1a391e5b7d417d78 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sat, 7 Jan 2006 13:19:00 -0500 Subject: [ACPI] make two processor functions static acpi_processor_write_throttling() acpi_processor_write_limit() Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Len Brown --- drivers/acpi/processor_thermal.c | 6 +++--- drivers/acpi/processor_throttling.c | 6 +++--- include/acpi/processor.h | 6 ------ 3 files changed, 6 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c index 22fc9e28a58d..f99ad05cd6a2 100644 --- a/drivers/acpi/processor_thermal.c +++ b/drivers/acpi/processor_thermal.c @@ -348,9 +348,9 @@ static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file) PDE(inode)->data); } -ssize_t acpi_processor_write_limit(struct file * file, - const char __user * buffer, - size_t count, loff_t * data) +static ssize_t acpi_processor_write_limit(struct file * file, + const char __user * buffer, + size_t count, loff_t * data) { int result = 0; struct seq_file *m = (struct seq_file *)file->private_data; diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 5cd056abfcfb..b966549ec000 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c @@ -306,9 +306,9 @@ static int acpi_processor_throttling_open_fs(struct inode *inode, PDE(inode)->data); } -ssize_t acpi_processor_write_throttling(struct file * file, - const char __user * buffer, - size_t count, loff_t * data) +static ssize_t acpi_processor_write_throttling(struct file * file, + const char __user * buffer, + size_t count, loff_t * data) { int result = 0; struct seq_file *m = (struct seq_file *)file->private_data; diff --git a/include/acpi/processor.h b/include/acpi/processor.h index 7a00d5089de9..edb5a8919cb6 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h @@ -235,9 +235,6 @@ static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr) /* in processor_throttling.c */ int acpi_processor_get_throttling_info(struct acpi_processor *pr); int acpi_processor_set_throttling(struct acpi_processor *pr, int state); -ssize_t acpi_processor_write_throttling(struct file *file, - const char __user * buffer, - size_t count, loff_t * data); extern struct file_operations acpi_processor_throttling_fops; /* in processor_idle.c */ @@ -249,9 +246,6 @@ int acpi_processor_power_exit(struct acpi_processor *pr, /* in processor_thermal.c */ int acpi_processor_get_limit_info(struct acpi_processor *pr); -ssize_t acpi_processor_write_limit(struct file *file, - const char __user * buffer, - size_t count, loff_t * data); extern struct file_operations acpi_processor_limit_fops; #ifdef CONFIG_CPU_FREQ -- cgit v1.2.3 From 168678233ca45af3f74fef60c4265fa5dd217e29 Mon Sep 17 00:00:00 2001 From: "akpm@osdl.org" Date: Fri, 13 Jan 2006 15:51:02 -0800 Subject: [AGPGART] Semaphore to Mutex conversion. Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Arjan van de Ven Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Dave Jones --- drivers/char/agp/frontend.c | 28 ++++++++++++++-------------- include/linux/agpgart.h | 3 ++- 2 files changed, 16 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c index 17f520c9d471..97eeb2345b18 100644 --- a/drivers/char/agp/frontend.c +++ b/drivers/char/agp/frontend.c @@ -592,7 +592,7 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma) struct agp_file_private *priv = file->private_data; struct agp_kern_info kerninfo; - down(&(agp_fe.agp_mutex)); + mutex_lock(&(agp_fe.agp_mutex)); if (agp_fe.backend_acquired != TRUE) goto out_eperm; @@ -627,7 +627,7 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma) size, vma->vm_page_prot)) { goto out_again; } - up(&(agp_fe.agp_mutex)); + mutex_unlock(&(agp_fe.agp_mutex)); return 0; } @@ -643,20 +643,20 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma) size, vma->vm_page_prot)) { goto out_again; } - up(&(agp_fe.agp_mutex)); + mutex_unlock(&(agp_fe.agp_mutex)); return 0; } out_eperm: - up(&(agp_fe.agp_mutex)); + mutex_unlock(&(agp_fe.agp_mutex)); return -EPERM; out_inval: - up(&(agp_fe.agp_mutex)); + mutex_unlock(&(agp_fe.agp_mutex)); return -EINVAL; out_again: - up(&(agp_fe.agp_mutex)); + mutex_unlock(&(agp_fe.agp_mutex)); return -EAGAIN; } @@ -664,7 +664,7 @@ static int agp_release(struct inode *inode, struct file *file) { struct agp_file_private *priv = file->private_data; - down(&(agp_fe.agp_mutex)); + mutex_lock(&(agp_fe.agp_mutex)); DBG("priv=%p", priv); @@ -687,7 +687,7 @@ static int agp_release(struct inode *inode, struct file *file) agp_remove_file_private(priv); kfree(priv); file->private_data = NULL; - up(&(agp_fe.agp_mutex)); + mutex_unlock(&(agp_fe.agp_mutex)); return 0; } @@ -698,7 +698,7 @@ static int agp_open(struct inode *inode, struct file *file) struct agp_client *client; int rc = -ENXIO; - down(&(agp_fe.agp_mutex)); + mutex_lock(&(agp_fe.agp_mutex)); if (minor != AGPGART_MINOR) goto err_out; @@ -723,13 +723,13 @@ static int agp_open(struct inode *inode, struct file *file) file->private_data = (void *) priv; agp_insert_file_private(priv); DBG("private=%p, client=%p", priv, client); - up(&(agp_fe.agp_mutex)); + mutex_unlock(&(agp_fe.agp_mutex)); return 0; err_out_nomem: rc = -ENOMEM; err_out: - up(&(agp_fe.agp_mutex)); + mutex_unlock(&(agp_fe.agp_mutex)); return rc; } @@ -985,7 +985,7 @@ static int agp_ioctl(struct inode *inode, struct file *file, int ret_val = -ENOTTY; DBG("priv=%p, cmd=%x", curr_priv, cmd); - down(&(agp_fe.agp_mutex)); + mutex_lock(&(agp_fe.agp_mutex)); if ((agp_fe.current_controller == NULL) && (cmd != AGPIOC_ACQUIRE)) { @@ -1055,7 +1055,7 @@ static int agp_ioctl(struct inode *inode, struct file *file, ioctl_out: DBG("ioctl returns %d\n", ret_val); - up(&(agp_fe.agp_mutex)); + mutex_unlock(&(agp_fe.agp_mutex)); return ret_val; } @@ -1081,7 +1081,7 @@ static struct miscdevice agp_miscdev = int agp_frontend_initialize(void) { memset(&agp_fe, 0, sizeof(struct agp_front_data)); - sema_init(&(agp_fe.agp_mutex), 1); + mutex_init(&(agp_fe.agp_mutex)); if (misc_register(&agp_miscdev)) { printk(KERN_ERR PFX "unable to get minor: %d\n", AGPGART_MINOR); diff --git a/include/linux/agpgart.h b/include/linux/agpgart.h index 17a17c55a17f..6d59c8efe3be 100644 --- a/include/linux/agpgart.h +++ b/include/linux/agpgart.h @@ -111,6 +111,7 @@ typedef struct _agp_unbind { } agp_unbind; #else /* __KERNEL__ */ +#include #define AGPGART_MINOR 175 @@ -201,7 +202,7 @@ struct agp_file_private { }; struct agp_front_data { - struct semaphore agp_mutex; + struct mutex agp_mutex; struct agp_controller *current_controller; struct agp_controller *controllers; struct agp_file_private *file_priv_list; -- cgit v1.2.3 From 83933af4720b282f6f6a0b6c05a2a47b4cf08819 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Sat, 14 Jan 2006 16:01:49 +0100 Subject: [CPUFREQ] convert remaining cpufreq semaphore to a mutex This one fell through the automation at first because it initializes the semaphore to locked, but that's easily remedied Signed-off-by: Arjan van de Ven Signed-off-by: Dave Jones drivers/cpufreq/cpufreq.c | 37 +++++++++++++++++++------------------ include/linux/cpufreq.h | 3 ++- 2 files changed, 21 insertions(+), 19 deletions(-) --- drivers/cpufreq/cpufreq.c | 37 +++++++++++++++++++------------------ include/linux/cpufreq.h | 3 ++- 2 files changed, 21 insertions(+), 19 deletions(-) (limited to 'include') diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index eb2f19d00e93..0675d9f02e34 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -601,7 +601,8 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) policy->cpu = cpu; policy->cpus = cpumask_of_cpu(cpu); - init_MUTEX_LOCKED(&policy->lock); + mutex_init(&policy->lock); + mutex_lock(&policy->lock); init_completion(&policy->kobj_unregister); INIT_WORK(&policy->update, handle_update, (void *)(long)cpu); @@ -642,7 +643,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) spin_unlock_irqrestore(&cpufreq_driver_lock, flags); policy->governor = NULL; /* to assure that the starting sequence is * run in cpufreq_set_policy */ - up(&policy->lock); + mutex_unlock(&policy->lock); /* set default policy */ @@ -763,10 +764,10 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) spin_unlock_irqrestore(&cpufreq_driver_lock, flags); #endif - down(&data->lock); + mutex_lock(&data->lock); if (cpufreq_driver->target) __cpufreq_governor(data, CPUFREQ_GOV_STOP); - up(&data->lock); + mutex_unlock(&data->lock); kobject_unregister(&data->kobj); @@ -835,9 +836,9 @@ unsigned int cpufreq_quick_get(unsigned int cpu) unsigned int ret = 0; if (policy) { - down(&policy->lock); + mutex_lock(&policy->lock); ret = policy->cur; - up(&policy->lock); + mutex_unlock(&policy->lock); cpufreq_cpu_put(policy); } @@ -863,7 +864,7 @@ unsigned int cpufreq_get(unsigned int cpu) if (!cpufreq_driver->get) goto out; - down(&policy->lock); + mutex_lock(&policy->lock); ret = cpufreq_driver->get(cpu); @@ -876,7 +877,7 @@ unsigned int cpufreq_get(unsigned int cpu) } } - up(&policy->lock); + mutex_unlock(&policy->lock); out: cpufreq_cpu_put(policy); @@ -1159,11 +1160,11 @@ int cpufreq_driver_target(struct cpufreq_policy *policy, if (!policy) return -EINVAL; - down(&policy->lock); + mutex_lock(&policy->lock); ret = __cpufreq_driver_target(policy, target_freq, relation); - up(&policy->lock); + mutex_unlock(&policy->lock); cpufreq_cpu_put(policy); @@ -1200,9 +1201,9 @@ int cpufreq_governor(unsigned int cpu, unsigned int event) if (!policy) return -EINVAL; - down(&policy->lock); + mutex_lock(&policy->lock); ret = __cpufreq_governor(policy, event); - up(&policy->lock); + mutex_unlock(&policy->lock); cpufreq_cpu_put(policy); @@ -1269,9 +1270,9 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu) if (!cpu_policy) return -EINVAL; - down(&cpu_policy->lock); + mutex_lock(&cpu_policy->lock); memcpy(policy, cpu_policy, sizeof(struct cpufreq_policy)); - up(&cpu_policy->lock); + mutex_unlock(&cpu_policy->lock); cpufreq_cpu_put(cpu_policy); @@ -1383,7 +1384,7 @@ int cpufreq_set_policy(struct cpufreq_policy *policy) return -EINVAL; /* lock this CPU */ - down(&data->lock); + mutex_lock(&data->lock); ret = __cpufreq_set_policy(data, policy); data->user_policy.min = data->min; @@ -1391,7 +1392,7 @@ int cpufreq_set_policy(struct cpufreq_policy *policy) data->user_policy.policy = data->policy; data->user_policy.governor = data->governor; - up(&data->lock); + mutex_unlock(&data->lock); cpufreq_cpu_put(data); return ret; @@ -1415,7 +1416,7 @@ int cpufreq_update_policy(unsigned int cpu) if (!data) return -ENODEV; - down(&data->lock); + mutex_lock(&data->lock); dprintk("updating policy for CPU %u\n", cpu); memcpy(&policy, @@ -1428,7 +1429,7 @@ int cpufreq_update_policy(unsigned int cpu) ret = __cpufreq_set_policy(data, &policy); - up(&data->lock); + mutex_unlock(&data->lock); cpufreq_cpu_put(data); return ret; diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index c31650df9241..17866d7e2b71 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -14,6 +14,7 @@ #ifndef _LINUX_CPUFREQ_H #define _LINUX_CPUFREQ_H +#include #include #include #include @@ -82,7 +83,7 @@ struct cpufreq_policy { unsigned int policy; /* see above */ struct cpufreq_governor *governor; /* see below */ - struct semaphore lock; /* CPU ->setpolicy or ->target may + struct mutex lock; /* CPU ->setpolicy or ->target may only be called once a time */ struct work_struct update; /* if update_policy() needs to be -- cgit v1.2.3 From 3b0e8eadc511eaceba6d6b8d0743359a34ee23c6 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Thu, 19 Jan 2006 14:08:40 +0000 Subject: [AGPGART] 945GM support for agpgart Here's a very small diff for 945GM support for agpgart. Patch against 2.6.15. From: Alan Hourihane Signed-off-by: Dave Jones --- drivers/char/agp/intel-agp.c | 15 +++++++++++++-- include/linux/pci_ids.h | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c index e7bed5047dcc..631531fd97a5 100644 --- a/drivers/char/agp/intel-agp.c +++ b/drivers/char/agp/intel-agp.c @@ -422,7 +422,8 @@ static void intel_i830_init_gtt_entries(void) /* Check it's really I915G */ if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB) + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB) gtt_entries = MB(48) - KB(size); else gtt_entries = 0; @@ -431,7 +432,8 @@ static void intel_i830_init_gtt_entries(void) /* Check it's really I915G */ if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB) + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB) gtt_entries = MB(64) - KB(size); else gtt_entries = 0; @@ -1681,6 +1683,14 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev, } name = "945G"; break; + case PCI_DEVICE_ID_INTEL_82945GM_HB: + if (find_i830(PCI_DEVICE_ID_INTEL_82945GM_IG)) { + bridge->driver = &intel_915_driver; + } else { + bridge->driver = &intel_845_driver; + } + name = "945GM"; + break; case PCI_DEVICE_ID_INTEL_7505_0: bridge->driver = &intel_7505_driver; name = "E7505"; @@ -1821,6 +1831,7 @@ static struct pci_device_id agp_intel_pci_table[] = { ID(PCI_DEVICE_ID_INTEL_82915G_HB), ID(PCI_DEVICE_ID_INTEL_82915GM_HB), ID(PCI_DEVICE_ID_INTEL_82945G_HB), + ID(PCI_DEVICE_ID_INTEL_82945GM_HB), { } }; diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 5403257ae3e7..2726140a6732 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -2084,6 +2084,8 @@ #define PCI_DEVICE_ID_INTEL_82915GM_IG 0x2592 #define PCI_DEVICE_ID_INTEL_82945G_HB 0x2770 #define PCI_DEVICE_ID_INTEL_82945G_IG 0x2772 +#define PCI_DEVICE_ID_INTEL_82945GM_HB 0x27A0 +#define PCI_DEVICE_ID_INTEL_82945GM_IG 0x27A2 #define PCI_DEVICE_ID_INTEL_ICH6_0 0x2640 #define PCI_DEVICE_ID_INTEL_ICH6_1 0x2641 #define PCI_DEVICE_ID_INTEL_ICH6_2 0x2642 -- cgit v1.2.3 From 4a90c7e86202f46fa9af011bdbcdf36e355d1721 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Fri, 13 Jan 2006 16:22:00 -0500 Subject: [ACPI] ACPICA 20060113 Added 2006 copyright. At SuSE's suggestion, enabled all error messages without enabling function tracing, ie with CONFIG_ACPI_DEBUG=n Replaced all instances of the ACPI_DEBUG_PRINT macro invoked at the ACPI_DB_ERROR and ACPI_DB_WARN debug levels with the ACPI_REPORT_ERROR and ACPI_REPORT_WARNING macros, respectively. This preserves all error and warning messages in the non-debug version of the ACPICA code (this has been referred to as the "debug lite" option.) Over 200 cases were converted to create a total of over 380 error/warning messages across the ACPICA code. This increases the code and data size of the default non-debug version by about 13K. Added ACPI_NO_ERROR_MESSAGES flag to enable deleting all messages. The size of the debug version remains about the same. Signed-off-by: Bob Moore Signed-off-by: Len Brown --- drivers/acpi/dispatcher/dsfield.c | 9 ++-- drivers/acpi/dispatcher/dsinit.c | 20 +++---- drivers/acpi/dispatcher/dsmethod.c | 2 +- drivers/acpi/dispatcher/dsmthdat.c | 28 ++++------ drivers/acpi/dispatcher/dsobject.c | 21 +++----- drivers/acpi/dispatcher/dsopcode.c | 41 ++++++-------- drivers/acpi/dispatcher/dsutils.c | 18 +++---- drivers/acpi/dispatcher/dswexec.c | 36 ++++--------- drivers/acpi/dispatcher/dswload.c | 2 +- drivers/acpi/dispatcher/dswscope.c | 6 +-- drivers/acpi/dispatcher/dswstate.c | 106 +++++++++++++------------------------ drivers/acpi/events/evevent.c | 4 +- drivers/acpi/events/evgpe.c | 20 ++++--- drivers/acpi/events/evgpeblk.c | 20 +++---- drivers/acpi/events/evmisc.c | 12 ++--- drivers/acpi/events/evregion.c | 45 +++++----------- drivers/acpi/events/evrgnini.c | 2 +- drivers/acpi/events/evsci.c | 2 +- drivers/acpi/events/evxface.c | 13 +++-- drivers/acpi/events/evxfevnt.c | 23 ++++---- drivers/acpi/events/evxfregn.c | 2 +- drivers/acpi/executer/exconfig.c | 6 +-- drivers/acpi/executer/exconvrt.c | 15 ++---- drivers/acpi/executer/excreate.c | 2 +- drivers/acpi/executer/exdump.c | 2 +- drivers/acpi/executer/exfield.c | 2 +- drivers/acpi/executer/exfldio.c | 60 ++++++--------------- drivers/acpi/executer/exmisc.c | 12 +++-- drivers/acpi/executer/exmutex.c | 2 +- drivers/acpi/executer/exnames.c | 16 +++--- drivers/acpi/executer/exoparg1.c | 59 ++++++++------------- drivers/acpi/executer/exoparg2.c | 28 +++++----- drivers/acpi/executer/exoparg3.c | 8 +-- drivers/acpi/executer/exoparg6.c | 13 ++--- drivers/acpi/executer/exprep.c | 11 ++-- drivers/acpi/executer/exregion.c | 12 ++--- drivers/acpi/executer/exresnte.c | 50 +++++++---------- drivers/acpi/executer/exresolv.c | 28 +++++----- drivers/acpi/executer/exresop.c | 89 +++++++++---------------------- drivers/acpi/executer/exstore.c | 19 +++---- drivers/acpi/executer/exstoren.c | 13 ++--- drivers/acpi/executer/exstorob.c | 2 +- drivers/acpi/executer/exsystem.c | 4 +- drivers/acpi/executer/exutils.c | 6 +-- drivers/acpi/hardware/hwacpi.c | 7 ++- drivers/acpi/hardware/hwgpe.c | 2 +- drivers/acpi/hardware/hwregs.c | 29 ++++------ drivers/acpi/hardware/hwsleep.c | 2 +- drivers/acpi/hardware/hwtimer.c | 2 +- drivers/acpi/namespace/nsaccess.c | 18 +++---- drivers/acpi/namespace/nsalloc.c | 7 ++- drivers/acpi/namespace/nsdump.c | 5 +- drivers/acpi/namespace/nsdumpdv.c | 2 +- drivers/acpi/namespace/nseval.c | 5 +- drivers/acpi/namespace/nsinit.c | 22 ++++---- drivers/acpi/namespace/nsload.c | 6 +-- drivers/acpi/namespace/nsnames.c | 10 ++-- drivers/acpi/namespace/nsobject.c | 10 ++-- drivers/acpi/namespace/nsparse.c | 2 +- drivers/acpi/namespace/nssearch.c | 11 ++-- drivers/acpi/namespace/nsutils.c | 29 ++++------ drivers/acpi/namespace/nswalk.c | 2 +- drivers/acpi/namespace/nsxfeval.c | 21 ++++---- drivers/acpi/namespace/nsxfname.c | 2 +- drivers/acpi/namespace/nsxfobj.c | 2 +- drivers/acpi/parser/psargs.c | 4 +- drivers/acpi/parser/psloop.c | 23 ++------ drivers/acpi/parser/psopcode.c | 4 +- drivers/acpi/parser/psparse.c | 8 +-- drivers/acpi/parser/psscope.c | 2 +- drivers/acpi/parser/pstree.c | 5 +- drivers/acpi/parser/psutils.c | 2 +- drivers/acpi/parser/pswalk.c | 2 +- drivers/acpi/parser/psxface.c | 2 +- drivers/acpi/resources/rsaddr.c | 2 +- drivers/acpi/resources/rscalc.c | 2 +- drivers/acpi/resources/rscreate.c | 42 +++------------ drivers/acpi/resources/rsdump.c | 2 +- drivers/acpi/resources/rsinfo.c | 2 +- drivers/acpi/resources/rsio.c | 2 +- drivers/acpi/resources/rsirq.c | 2 +- drivers/acpi/resources/rslist.c | 6 +-- drivers/acpi/resources/rsmemory.c | 2 +- drivers/acpi/resources/rsmisc.c | 9 ++-- drivers/acpi/resources/rsutils.c | 2 +- drivers/acpi/resources/rsxface.c | 2 +- drivers/acpi/tables/tbconvrt.c | 2 +- drivers/acpi/tables/tbget.c | 6 +-- drivers/acpi/tables/tbgetall.c | 2 +- drivers/acpi/tables/tbinstal.c | 2 +- drivers/acpi/tables/tbrsdt.c | 18 +++---- drivers/acpi/tables/tbutils.c | 22 +++----- drivers/acpi/tables/tbxface.c | 17 +++--- drivers/acpi/tables/tbxfroot.c | 22 +++----- drivers/acpi/utilities/utalloc.c | 32 ++++++----- drivers/acpi/utilities/utcache.c | 2 +- drivers/acpi/utilities/utcopy.c | 7 ++- drivers/acpi/utilities/utdebug.c | 2 +- drivers/acpi/utilities/utdelete.c | 9 ++-- drivers/acpi/utilities/uteval.c | 24 ++++----- drivers/acpi/utilities/utglobal.c | 21 ++++---- drivers/acpi/utilities/utinit.c | 7 ++- drivers/acpi/utilities/utmath.c | 10 ++-- drivers/acpi/utilities/utmisc.c | 18 +++---- drivers/acpi/utilities/utmutex.c | 37 +++---------- drivers/acpi/utilities/utobject.c | 28 +++++----- drivers/acpi/utilities/utresrc.c | 2 +- drivers/acpi/utilities/utstate.c | 2 +- drivers/acpi/utilities/utxface.c | 7 ++- include/acpi/acconfig.h | 4 +- include/acpi/acdebug.h | 2 +- include/acpi/acdisasm.h | 2 +- include/acpi/acdispat.h | 2 +- include/acpi/acevents.h | 2 +- include/acpi/acexcep.h | 2 +- include/acpi/acglobal.h | 2 +- include/acpi/achware.h | 2 +- include/acpi/acinterp.h | 2 +- include/acpi/aclocal.h | 2 +- include/acpi/acmacros.h | 83 ++++++++++++++++------------- include/acpi/acnames.h | 2 +- include/acpi/acnamesp.h | 4 +- include/acpi/acobject.h | 2 +- include/acpi/acopcode.h | 2 +- include/acpi/acoutput.h | 12 +++-- include/acpi/acparser.h | 2 +- include/acpi/acpi.h | 2 +- include/acpi/acpiosxf.h | 2 +- include/acpi/acpixf.h | 2 +- include/acpi/acresrc.h | 2 +- include/acpi/acstruct.h | 2 +- include/acpi/actables.h | 2 +- include/acpi/actbl.h | 2 +- include/acpi/actbl1.h | 2 +- include/acpi/actbl2.h | 2 +- include/acpi/actypes.h | 2 +- include/acpi/acutils.h | 9 ++-- include/acpi/amlcode.h | 2 +- include/acpi/amlresrc.h | 2 +- include/acpi/platform/acenv.h | 2 +- include/acpi/platform/acgcc.h | 2 +- include/acpi/platform/aclinux.h | 2 +- 142 files changed, 658 insertions(+), 1023 deletions(-) (limited to 'include') diff --git a/drivers/acpi/dispatcher/dsfield.c b/drivers/acpi/dispatcher/dsfield.c index 2022aeaecfbb..f3a008ff1eae 100644 --- a/drivers/acpi/dispatcher/dsfield.c +++ b/drivers/acpi/dispatcher/dsfield.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -293,7 +293,7 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info, + (acpi_integer) arg->common.value.size; if (position > ACPI_UINT32_MAX) { - ACPI_REPORT_ERROR(("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", (char *)&info->field_node->name)); + ACPI_REPORT_ERROR(("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", ACPI_CAST_PTR(char, &info->field_node->name))); return_ACPI_STATUS(AE_SUPPORT); } @@ -302,9 +302,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info, default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid opcode in field list: %X\n", - arg->common.aml_opcode)); + ACPI_REPORT_ERROR(("Invalid opcode in field list: %X\n", + arg->common.aml_opcode)); return_ACPI_STATUS(AE_AML_BAD_OPCODE); } diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c index 4fa80abfe6c0..258fbdfaa69c 100644 --- a/drivers/acpi/dispatcher/dsinit.c +++ b/drivers/acpi/dispatcher/dsinit.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,7 +84,7 @@ acpi_ds_init_one_object(acpi_handle obj_handle, acpi_object_type type; acpi_status status; - ACPI_FUNCTION_NAME("ds_init_one_object"); + ACPI_FUNCTION_ENTRY(); /* * We are only interested in NS nodes owned by the table that @@ -105,11 +105,7 @@ acpi_ds_init_one_object(acpi_handle obj_handle, status = acpi_ds_initialize_region(obj_handle); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Region %p [%4.4s] - Init failure, %s\n", - obj_handle, - acpi_ut_get_node_name(obj_handle), - acpi_format_exception(status))); + ACPI_REPORT_ERROR(("Region %p [%4.4s] - Init failure, %s\n", obj_handle, acpi_ut_get_node_name(obj_handle), acpi_format_exception(status))); } info->op_region_count++; @@ -148,11 +144,7 @@ acpi_ds_init_one_object(acpi_handle obj_handle, */ status = acpi_ds_parse_method(obj_handle); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "\n+Method %p [%4.4s] - parse failure, %s\n", - obj_handle, - acpi_ut_get_node_name(obj_handle), - acpi_format_exception(status))); + ACPI_REPORT_ERROR(("\n+Method %p [%4.4s] - parse failure, %s\n", obj_handle, acpi_ut_get_node_name(obj_handle), acpi_format_exception(status))); /* This parse failed, but we will continue parsing more methods */ } @@ -214,8 +206,8 @@ acpi_ds_initialize_objects(struct acpi_table_desc * table_desc, status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX, acpi_ds_init_one_object, &info, NULL); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed, %s\n", - acpi_format_exception(status))); + ACPI_REPORT_ERROR(("walk_namespace failed, %s\n", + acpi_format_exception(status))); } ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index e7ce86b8d954..d861add3fc1f 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c index 4095ce70982b..ce33c34f87c6 100644 --- a/drivers/acpi/dispatcher/dsmthdat.c +++ b/drivers/acpi/dispatcher/dsmthdat.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -260,9 +260,7 @@ acpi_ds_method_data_get_node(u16 opcode, case AML_LOCAL_OP: if (index > ACPI_METHOD_MAX_LOCAL) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Local index %d is invalid (max %d)\n", - index, ACPI_METHOD_MAX_LOCAL)); + ACPI_REPORT_ERROR(("Local index %d is invalid (max %d)\n", index, ACPI_METHOD_MAX_LOCAL)); return_ACPI_STATUS(AE_AML_INVALID_INDEX); } @@ -274,9 +272,8 @@ acpi_ds_method_data_get_node(u16 opcode, case AML_ARG_OP: if (index > ACPI_METHOD_MAX_ARG) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Arg index %d is invalid (max %d)\n", - index, ACPI_METHOD_MAX_ARG)); + ACPI_REPORT_ERROR(("Arg index %d is invalid (max %d)\n", + index, ACPI_METHOD_MAX_ARG)); return_ACPI_STATUS(AE_AML_INVALID_INDEX); } @@ -286,8 +283,7 @@ acpi_ds_method_data_get_node(u16 opcode, break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Opcode %d is invalid\n", - opcode)); + ACPI_REPORT_ERROR(("Opcode %d is invalid\n", opcode)); return_ACPI_STATUS(AE_AML_BAD_OPCODE); } @@ -378,8 +374,7 @@ acpi_ds_method_data_get_value(u16 opcode, /* Validate the object descriptor */ if (!dest_desc) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Null object descriptor pointer\n")); + ACPI_REPORT_ERROR(("Null object descriptor pointer\n")); return_ACPI_STATUS(AE_BAD_PARAMETER); } @@ -424,23 +419,18 @@ acpi_ds_method_data_get_value(u16 opcode, switch (opcode) { case AML_ARG_OP: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Uninitialized Arg[%d] at node %p\n", - index, node)); + ACPI_REPORT_ERROR(("Uninitialized Arg[%d] at node %p\n", index, node)); return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG); case AML_LOCAL_OP: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Uninitialized Local[%d] at node %p\n", - index, node)); + ACPI_REPORT_ERROR(("Uninitialized Local[%d] at node %p\n", index, node)); return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL); default: - ACPI_REPORT_ERROR(("Not Arg/Local opcode: %X\n", - opcode)); + ACPI_REPORT_ERROR(("Not a Arg/Local opcode: %X\n", opcode)); return_ACPI_STATUS(AE_AML_INTERNAL); } } diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c index 905a84e4b145..dc116d679a58 100644 --- a/drivers/acpi/dispatcher/dsobject.c +++ b/drivers/acpi/dispatcher/dsobject.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -214,10 +214,7 @@ acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state, byte_list = arg->named.next; if (byte_list) { if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Expecting bytelist, got AML opcode %X in op %p\n", - byte_list->common.aml_opcode, - byte_list)); + ACPI_REPORT_ERROR(("Expecting bytelist, got AML opcode %X in op %p\n", byte_list->common.aml_opcode, byte_list)); acpi_ut_remove_reference(obj_desc); return (AE_TYPE); @@ -543,9 +540,7 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unknown constant opcode %X\n", - opcode)); + ACPI_REPORT_ERROR(("Unknown constant opcode %X\n", opcode)); status = AE_AML_OPERAND_TYPE; break; } @@ -560,9 +555,8 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unknown Integer type %X\n", - op_info->type)); + ACPI_REPORT_ERROR(("Unknown Integer type %X\n", + op_info->type)); status = AE_AML_OPERAND_TYPE; break; } @@ -640,9 +634,8 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unimplemented data type: %X\n", - ACPI_GET_OBJECT_TYPE(obj_desc))); + ACPI_REPORT_ERROR(("Unimplemented data type: %X\n", + ACPI_GET_OBJECT_TYPE(obj_desc))); status = AE_AML_OPERAND_TYPE; break; diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c index 939d167bf87b..60414ee84b0a 100644 --- a/drivers/acpi/dispatcher/dsopcode.c +++ b/drivers/acpi/dispatcher/dsopcode.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -413,9 +413,7 @@ acpi_ds_init_buffer_field(u16 aml_opcode, /* Host object must be a Buffer */ if (ACPI_GET_OBJECT_TYPE(buffer_desc) != ACPI_TYPE_BUFFER) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Target of Create Field is not a Buffer object - %s\n", - acpi_ut_get_object_type_name(buffer_desc))); + ACPI_REPORT_ERROR(("Target of Create Field is not a Buffer object - %s\n", acpi_ut_get_object_type_name(buffer_desc))); status = AE_AML_OPERAND_TYPE; goto cleanup; @@ -427,10 +425,9 @@ acpi_ds_init_buffer_field(u16 aml_opcode, * after resolution in acpi_ex_resolve_operands(). */ if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "(%s) destination not a NS Node [%s]\n", - acpi_ps_get_opcode_name(aml_opcode), - acpi_ut_get_descriptor_name(result_desc))); + ACPI_REPORT_ERROR(("(%s) destination not a NS Node [%s]\n", + acpi_ps_get_opcode_name(aml_opcode), + acpi_ut_get_descriptor_name(result_desc))); status = AE_AML_OPERAND_TYPE; goto cleanup; @@ -453,8 +450,7 @@ acpi_ds_init_buffer_field(u16 aml_opcode, /* Must have a valid (>0) bit count */ if (bit_count == 0) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Attempt to create_field of length 0\n")); + ACPI_REPORT_ERROR(("Attempt to create_field of length 0\n")); status = AE_AML_OPERAND_VALUE; goto cleanup; } @@ -507,9 +503,8 @@ acpi_ds_init_buffer_field(u16 aml_opcode, default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unknown field creation opcode %02x\n", - aml_opcode)); + ACPI_REPORT_ERROR(("Unknown field creation opcode %02x\n", + aml_opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } @@ -517,13 +512,7 @@ acpi_ds_init_buffer_field(u16 aml_opcode, /* Entire field must fit within the current length of the buffer */ if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n", - acpi_ut_get_node_name(result_desc), - bit_offset + bit_count, - acpi_ut_get_node_name(buffer_desc->buffer. - node), - 8 * (u32) buffer_desc->buffer.length)); + ACPI_REPORT_ERROR(("Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n", acpi_ut_get_node_name(result_desc), bit_offset + bit_count, acpi_ut_get_node_name(buffer_desc->buffer.node), 8 * (u32) buffer_desc->buffer.length)); status = AE_AML_BUFFER_LIMIT; goto cleanup; } @@ -629,9 +618,10 @@ acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state, "after acpi_ex_resolve_operands"); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n", - acpi_ps_get_opcode_name(op->common. - aml_opcode), status)); + ACPI_REPORT_ERROR(("(%s) bad operand(s) (%X)\n", + acpi_ps_get_opcode_name(op->common. + aml_opcode), + status)); return_ACPI_STATUS(status); } @@ -1155,9 +1145,8 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state, default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unknown control opcode=%X Op=%p\n", - op->common.aml_opcode, op)); + ACPI_REPORT_ERROR(("Unknown control opcode=%X Op=%p\n", + op->common.aml_opcode, op)); status = AE_AML_BAD_OPCODE; break; diff --git a/drivers/acpi/dispatcher/dsutils.c b/drivers/acpi/dispatcher/dsutils.c index 2cc53da5c0bd..cd9aa7faa57b 100644 --- a/drivers/acpi/dispatcher/dsutils.c +++ b/drivers/acpi/dispatcher/dsutils.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -176,7 +176,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, /* Must have both an Op and a Result Object */ if (!op) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n")); + ACPI_REPORT_ERROR(("Null Op\n")); return_UINT8(TRUE); } @@ -216,8 +216,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, parent_info = acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode); if (parent_info->class == AML_CLASS_UNKNOWN) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unknown parent opcode. Op=%p\n", op)); + ACPI_REPORT_ERROR(("Unknown parent opcode Op=%p\n", op)); return_UINT8(FALSE); } @@ -344,7 +343,7 @@ acpi_ds_delete_result_if_not_used(union acpi_parse_object *op, ACPI_FUNCTION_TRACE_PTR("ds_delete_result_if_not_used", result_obj); if (!op) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null Op\n")); + ACPI_REPORT_ERROR(("Null Op\n")); return_VOID; } @@ -635,10 +634,7 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state, * Only error is underflow, and this indicates * a missing or null operand! */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Missing or null operand, %s\n", - acpi_format_exception - (status))); + ACPI_REPORT_ERROR(("Missing or null operand, %s\n", acpi_format_exception(status))); return_ACPI_STATUS(status); } } else { @@ -730,7 +726,7 @@ acpi_ds_create_operands(struct acpi_walk_state *walk_state, */ (void)acpi_ds_obj_stack_pop_and_delete(arg_count, walk_state); - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "While creating Arg %d - %s\n", - (arg_count + 1), acpi_format_exception(status))); + ACPI_REPORT_ERROR(("While creating Arg %d - %s\n", + (arg_count + 1), acpi_format_exception(status))); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c index 74f6996db2d7..5a9b91fe93d2 100644 --- a/drivers/acpi/dispatcher/dswexec.c +++ b/drivers/acpi/dispatcher/dswexec.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -100,9 +100,7 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state, if (result_obj) { status = acpi_ds_result_pop(&obj_desc, walk_state); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not get result from predicate evaluation, %s\n", - acpi_format_exception(status))); + ACPI_REPORT_ERROR(("Could not get result from predicate evaluation, %s\n", acpi_format_exception(status))); return_ACPI_STATUS(status); } @@ -123,9 +121,8 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state, } if (!obj_desc) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "No predicate obj_desc=%p State=%p\n", - obj_desc, walk_state)); + ACPI_REPORT_ERROR(("No predicate obj_desc=%p State=%p\n", + obj_desc, walk_state)); return_ACPI_STATUS(AE_AML_NO_OPERAND); } @@ -140,10 +137,7 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state, } if (ACPI_GET_OBJECT_TYPE(local_obj_desc) != ACPI_TYPE_INTEGER) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Bad predicate (not an integer) obj_desc=%p State=%p Type=%X\n", - obj_desc, walk_state, - ACPI_GET_OBJECT_TYPE(obj_desc))); + ACPI_REPORT_ERROR(("Bad predicate (not an integer) obj_desc=%p State=%p Type=%X\n", obj_desc, walk_state, ACPI_GET_OBJECT_TYPE(obj_desc))); status = AE_AML_OPERAND_TYPE; goto cleanup; @@ -362,8 +356,8 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) op_class = walk_state->op_info->class; if (op_class == AML_CLASS_UNKNOWN) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown opcode %X\n", - op->common.aml_opcode)); + ACPI_REPORT_ERROR(("Unknown opcode %X\n", + op->common.aml_opcode)); return_ACPI_STATUS(AE_NOT_IMPLEMENTED); } @@ -453,12 +447,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) walk_state->operands[1]->reference.offset)) { status = AE_OK; } else { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "[%s]: Could not resolve operands, %s\n", - acpi_ps_get_opcode_name - (walk_state->opcode), - acpi_format_exception - (status))); + ACPI_REPORT_ERROR(("[%s]: Could not resolve operands, %s\n", acpi_ps_get_opcode_name(walk_state->opcode), acpi_format_exception(status))); } } @@ -677,8 +666,8 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) case AML_TYPE_UNDEFINED: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Undefined opcode type Op=%p\n", op)); + ACPI_REPORT_ERROR(("Undefined opcode type Op=%p\n", + op)); return_ACPI_STATUS(AE_NOT_IMPLEMENTED); case AML_TYPE_BOGUS: @@ -690,10 +679,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n", - op_class, op_type, - op->common.aml_opcode, op)); + ACPI_REPORT_ERROR(("Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n", op_class, op_type, op->common.aml_opcode, op)); status = AE_NOT_IMPLEMENTED; break; diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c index 441931cab08a..4cad6afa82f7 100644 --- a/drivers/acpi/dispatcher/dswload.c +++ b/drivers/acpi/dispatcher/dswload.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/dispatcher/dswscope.c b/drivers/acpi/dispatcher/dswscope.c index defe956ef751..e7fc88ca47ba 100644 --- a/drivers/acpi/dispatcher/dswscope.c +++ b/drivers/acpi/dispatcher/dswscope.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -107,14 +107,14 @@ acpi_ds_scope_stack_push(struct acpi_namespace_node *node, if (!node) { /* Invalid scope */ - ACPI_REPORT_ERROR(("ds_scope_stack_push: null scope passed\n")); + ACPI_REPORT_ERROR(("Null scope parameter\n")); return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Make sure object type is valid */ if (!acpi_ut_valid_object_type(type)) { - ACPI_REPORT_WARNING(("ds_scope_stack_push: Invalid object type: 0x%X\n", type)); + ACPI_REPORT_WARNING(("Invalid object type: 0x%X\n", type)); } /* Allocate a new scope object */ diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c index 7d68a5aaf3c4..61aae2dcc5e2 100644 --- a/drivers/acpi/dispatcher/dswstate.c +++ b/drivers/acpi/dispatcher/dswstate.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -92,26 +92,23 @@ acpi_ds_result_remove(union acpi_operand_object **object, state = walk_state->results; if (!state) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "No result object pushed! State=%p\n", - walk_state)); + ACPI_REPORT_ERROR(("No result object pushed! State=%p\n", + walk_state)); return (AE_NOT_EXIST); } if (index >= ACPI_OBJ_MAX_OPERAND) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Index out of range: %X State=%p Num=%X\n", - index, walk_state, - state->results.num_results)); + ACPI_REPORT_ERROR(("Index out of range: %X State=%p Num=%X\n", + index, walk_state, + state->results.num_results)); } /* Check for a valid result object */ if (!state->results.obj_desc[index]) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Null operand! State=%p #Ops=%X, Index=%X\n", - walk_state, state->results.num_results, - index)); + ACPI_REPORT_ERROR(("Null operand! State=%p #Ops=%X, Index=%X\n", + walk_state, state->results.num_results, + index)); return (AE_AML_NO_RETURN_VALUE); } @@ -163,9 +160,8 @@ acpi_ds_result_pop(union acpi_operand_object ** object, } if (!state->results.num_results) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Result stack is empty! State=%p\n", - walk_state)); + ACPI_REPORT_ERROR(("Result stack is empty! State=%p\n", + walk_state)); return (AE_AML_NO_RETURN_VALUE); } @@ -192,8 +188,7 @@ acpi_ds_result_pop(union acpi_operand_object ** object, } } - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "No result objects! State=%p\n", walk_state)); + ACPI_REPORT_ERROR(("No result objects! State=%p\n", walk_state)); return (AE_AML_NO_RETURN_VALUE); } @@ -222,15 +217,14 @@ acpi_ds_result_pop_from_bottom(union acpi_operand_object ** object, state = walk_state->results; if (!state) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Warning: No result object pushed! State=%p\n", - walk_state)); + ACPI_REPORT_ERROR(("No result object pushed! State=%p\n", + walk_state)); return (AE_NOT_EXIST); } if (!state->results.num_results) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "No result objects! State=%p\n", walk_state)); + ACPI_REPORT_ERROR(("No result objects! State=%p\n", + walk_state)); return (AE_AML_NO_RETURN_VALUE); } @@ -250,10 +244,9 @@ acpi_ds_result_pop_from_bottom(union acpi_operand_object ** object, /* Check for a valid result object */ if (!*object) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Null operand! State=%p #Ops=%X Index=%X\n", - walk_state, state->results.num_results, - (u32) index)); + ACPI_REPORT_ERROR(("Null operand! State=%p #Ops=%X Index=%X\n", + walk_state, state->results.num_results, + (u32) index)); return (AE_AML_NO_RETURN_VALUE); } @@ -293,18 +286,14 @@ acpi_ds_result_push(union acpi_operand_object * object, } if (state->results.num_results == ACPI_OBJ_NUM_OPERANDS) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Result stack overflow: Obj=%p State=%p Num=%X\n", - object, walk_state, - state->results.num_results)); + ACPI_REPORT_ERROR(("Result stack overflow: Obj=%p State=%p Num=%X\n", object, walk_state, state->results.num_results)); return (AE_STACK_OVERFLOW); } if (!object) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Null Object! Obj=%p State=%p Num=%X\n", - object, walk_state, - state->results.num_results)); + ACPI_REPORT_ERROR(("Null Object! Obj=%p State=%p Num=%X\n", + object, walk_state, + state->results.num_results)); return (AE_BAD_PARAMETER); } @@ -413,10 +402,7 @@ acpi_ds_obj_stack_push(void *object, struct acpi_walk_state * walk_state) /* Check for stack overflow */ if (walk_state->num_operands >= ACPI_OBJ_NUM_OPERANDS) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "overflow! Obj=%p State=%p #Ops=%X\n", - object, walk_state, - walk_state->num_operands)); + ACPI_REPORT_ERROR(("Object stack overflow! Obj=%p State=%p #Ops=%X\n", object, walk_state, walk_state->num_operands)); return (AE_STACK_OVERFLOW); } @@ -460,10 +446,7 @@ acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state * walk_state) /* Check for stack underflow */ if (walk_state->num_operands == 0) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Underflow! Count=%X State=%p #Ops=%X\n", - pop_count, walk_state, - walk_state->num_operands)); + ACPI_REPORT_ERROR(("Object stack underflow! Count=%X State=%p #Ops=%X\n", pop_count, walk_state, walk_state->num_operands)); return (AE_STACK_UNDERFLOW); } @@ -506,10 +489,7 @@ acpi_ds_obj_stack_pop_and_delete(u32 pop_count, /* Check for stack underflow */ if (walk_state->num_operands == 0) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Underflow! Count=%X State=%p #Ops=%X\n", - pop_count, walk_state, - walk_state->num_operands)); + ACPI_REPORT_ERROR(("Object stack underflow! Count=%X State=%p #Ops=%X\n", pop_count, walk_state, walk_state->num_operands)); return (AE_STACK_UNDERFLOW); } @@ -826,16 +806,14 @@ void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state) } if (walk_state->data_type != ACPI_DESC_TYPE_WALK) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "%p is not a valid walk state\n", - walk_state)); + ACPI_REPORT_ERROR(("%p is not a valid walk state\n", + walk_state)); return; } if (walk_state->parser_state.scope) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "%p walk still has a scope list\n", - walk_state)); + ACPI_REPORT_ERROR(("%p walk still has a scope list\n", + walk_state)); } /* Always must free any linked control states */ @@ -894,25 +872,18 @@ acpi_ds_result_insert(void *object, state = walk_state->results; if (!state) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "No result object pushed! State=%p\n", - walk_state)); + ACPI_REPORT_ERROR(("No result object pushed! State=%p\n", + walk_state)); return (AE_NOT_EXIST); } if (index >= ACPI_OBJ_NUM_OPERANDS) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Index out of range: %X Obj=%p State=%p Num=%X\n", - index, object, walk_state, - state->results.num_results)); + ACPI_REPORT_ERROR(("Index out of range: %X Obj=%p State=%p Num=%X\n", index, object, walk_state, state->results.num_results)); return (AE_BAD_PARAMETER); } if (!object) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Null Object! Index=%X Obj=%p State=%p Num=%X\n", - index, object, walk_state, - state->results.num_results)); + ACPI_REPORT_ERROR(("Null Object! Index=%X Obj=%p State=%p Num=%X\n", index, object, walk_state, state->results.num_results)); return (AE_BAD_PARAMETER); } @@ -986,9 +957,7 @@ acpi_ds_obj_stack_pop_object(union acpi_operand_object **object, /* Check for stack underflow */ if (walk_state->num_operands == 0) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Missing operand/stack empty! State=%p #Ops=%X\n", - walk_state, walk_state->num_operands)); + ACPI_REPORT_ERROR(("Missing operand/stack empty! State=%p #Ops=%X\n", walk_state, walk_state->num_operands)); *object = NULL; return (AE_AML_NO_OPERAND); } @@ -1000,9 +969,8 @@ acpi_ds_obj_stack_pop_object(union acpi_operand_object **object, /* Check for a valid operand */ if (!walk_state->operands[walk_state->num_operands]) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Null operand! State=%p #Ops=%X\n", - walk_state, walk_state->num_operands)); + ACPI_REPORT_ERROR(("Null operand! State=%p #Ops=%X\n", + walk_state, walk_state->num_operands)); *object = NULL; return (AE_AML_NO_OPERAND); } diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/events/evevent.c index 9522c643b88b..b380ae1044b7 100644 --- a/drivers/acpi/events/evevent.c +++ b/drivers/acpi/events/evevent.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -73,7 +73,7 @@ acpi_status acpi_ev_initialize_events(void) /* Make sure we have ACPI tables */ if (!acpi_gbl_DSDT) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No ACPI tables present!\n")); + ACPI_REPORT_WARNING(("No ACPI tables present!\n")); return_ACPI_STATUS(AE_NO_ACPI_TABLES); } diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c index bdd86537738e..353b907edbfa 100644 --- a/drivers/acpi/events/evgpe.c +++ b/drivers/acpi/events/evgpe.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -599,7 +599,9 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) ACPI_GPE_EDGE_TRIGGERED) { status = acpi_hw_clear_gpe(gpe_event_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); + ACPI_REPORT_ERROR(("%s, Unable to clear GPE[%2X]\n", + acpi_format_exception(status), + gpe_number)); return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); } } @@ -637,7 +639,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) ACPI_GPE_LEVEL_TRIGGERED) { status = acpi_hw_clear_gpe(gpe_event_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); + ACPI_REPORT_ERROR(("%s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); } } @@ -651,7 +653,9 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) */ status = acpi_ev_disable_gpe(gpe_event_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number)); + ACPI_REPORT_ERROR(("%s, Unable to disable GPE[%2X]\n", + acpi_format_exception(status), + gpe_number)); return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); } @@ -663,7 +667,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) acpi_ev_asynch_execute_gpe_method, gpe_event_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n", acpi_format_exception(status), gpe_number)); + ACPI_REPORT_ERROR(("%s, Unable to queue handler for GPE[%2X] - event disabled\n", acpi_format_exception(status), gpe_number)); } break; @@ -671,7 +675,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) /* No handler or method to run! */ - ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n", gpe_number)); + ACPI_REPORT_ERROR(("No handler or method for GPE[%2X], disabling event\n", gpe_number)); /* * Disable the GPE. The GPE will remain disabled until the ACPI @@ -679,7 +683,9 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) */ status = acpi_ev_disable_gpe(gpe_event_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n", acpi_format_exception(status), gpe_number)); + ACPI_REPORT_ERROR(("%s, Unable to disable GPE[%2X]\n", + acpi_format_exception(status), + gpe_number)); return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); } break; diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c index 8efca2eac27e..3b9bbdda551d 100644 --- a/drivers/acpi/events/evgpeblk.c +++ b/drivers/acpi/events/evgpeblk.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -279,9 +279,7 @@ acpi_ev_save_method_info(acpi_handle obj_handle, default: /* Unknown method type, just ignore it! */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unknown GPE method type: %s (name not of form _Lxx or _Exx)\n", - name)); + ACPI_REPORT_ERROR(("Unknown GPE method type: %s (name not of form _Lxx or _Exx)\n", name)); return_ACPI_STATUS(AE_OK); } @@ -291,9 +289,7 @@ acpi_ev_save_method_info(acpi_handle obj_handle, if (gpe_number == ACPI_UINT32_MAX) { /* Conversion failed; invalid method, just ignore it */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)\n", - name)); + ACPI_REPORT_ERROR(("Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)\n", name)); return_ACPI_STATUS(AE_OK); } @@ -527,9 +523,7 @@ static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 acpi_ev_gpe_xrupt_handler, gpe_xrupt); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not install GPE interrupt handler at level 0x%X\n", - interrupt_number)); + ACPI_REPORT_ERROR(("Could not install GPE interrupt handler at level 0x%X\n", interrupt_number)); return_PTR(NULL); } } @@ -745,8 +739,7 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block) sizeof(struct acpi_gpe_register_info)); if (!gpe_register_info) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not allocate the gpe_register_info table\n")); + ACPI_REPORT_ERROR(("Could not allocate the gpe_register_info table\n")); return_ACPI_STATUS(AE_NO_MEMORY); } @@ -759,8 +752,7 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block) ACPI_GPE_REGISTER_WIDTH) * sizeof(struct acpi_gpe_event_info)); if (!gpe_event_info) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not allocate the gpe_event_info table\n")); + ACPI_REPORT_ERROR(("Could not allocate the gpe_event_info table\n")); status = AE_NO_MEMORY; goto error_exit; } diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c index 7e57b8470f55..78883239784a 100644 --- a/drivers/acpi/events/evmisc.c +++ b/drivers/acpi/events/evmisc.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -542,9 +542,7 @@ void acpi_ev_terminate(void) for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { status = acpi_disable_event((u32) i, 0); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not disable fixed event %d\n", - (u32) i)); + ACPI_REPORT_ERROR(("Could not disable fixed event %d\n", (u32) i)); } } @@ -556,8 +554,7 @@ void acpi_ev_terminate(void) status = acpi_ev_remove_sci_handler(); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not remove SCI handler\n")); + ACPI_REPORT_ERROR(("Could not remove SCI handler\n")); } } @@ -570,8 +567,7 @@ void acpi_ev_terminate(void) if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) { status = acpi_disable(); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "acpi_disable failed\n")); + ACPI_REPORT_WARNING(("acpi_disable failed\n")); } } return_VOID; diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c index 84fad082d80d..900e5b32e595 100644 --- a/drivers/acpi/events/evregion.c +++ b/drivers/acpi/events/evregion.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -295,12 +295,11 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, handler_desc = region_obj->region.handler; if (!handler_desc) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "No handler for Region [%4.4s] (%p) [%s]\n", - acpi_ut_get_node_name(region_obj->region. - node), region_obj, - acpi_ut_get_region_name(region_obj->region. - space_id))); + ACPI_REPORT_ERROR(("No handler for Region [%4.4s] (%p) [%s]\n", + acpi_ut_get_node_name(region_obj->region. + node), region_obj, + acpi_ut_get_region_name(region_obj->region. + space_id))); return_ACPI_STATUS(AE_NOT_EXIST); } @@ -317,12 +316,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, if (!region_setup) { /* No initialization routine, exit with error */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "No init routine for region(%p) [%s]\n", - region_obj, - acpi_ut_get_region_name(region_obj-> - region. - space_id))); + ACPI_REPORT_ERROR(("No init routine for region(%p) [%s]\n", region_obj, acpi_ut_get_region_name(region_obj->region.space_id))); return_ACPI_STATUS(AE_NOT_EXIST); } @@ -347,12 +341,11 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, /* Check for failure of the Region Setup */ if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Region Init: %s [%s]\n", - acpi_format_exception(status), - acpi_ut_get_region_name(region_obj-> - region. - space_id))); + ACPI_REPORT_ERROR(("Region Initialization: %s [%s]\n", + acpi_format_exception(status), + acpi_ut_get_region_name(region_obj-> + region. + space_id))); return_ACPI_STATUS(status); } @@ -501,12 +494,7 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj, status = acpi_ev_execute_reg_method(region_obj, 0); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "%s from region _REG, [%s]\n", - acpi_format_exception(status), - acpi_ut_get_region_name - (region_obj->region. - space_id))); + ACPI_REPORT_ERROR(("%s from region _REG, [%s]\n", acpi_format_exception(status), acpi_ut_get_region_name(region_obj->region.space_id))); } if (acpi_ns_is_locked) { @@ -528,12 +516,7 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj, /* Init routine may fail, Just ignore errors */ if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "%s from region init, [%s]\n", - acpi_format_exception(status), - acpi_ut_get_region_name - (region_obj->region. - space_id))); + ACPI_REPORT_ERROR(("%s from region init, [%s]\n", acpi_format_exception(status), acpi_ut_get_region_name(region_obj->region.space_id))); } region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE); diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c index a1bd2da27c45..de1a38e9ce22 100644 --- a/drivers/acpi/events/evrgnini.c +++ b/drivers/acpi/events/evrgnini.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/events/evsci.c b/drivers/acpi/events/evsci.c index e2c0b48a7e9f..9a622169008a 100644 --- a/drivers/acpi/events/evsci.c +++ b/drivers/acpi/events/evsci.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c index 57d73299298e..b2f69b1ac4b5 100644 --- a/drivers/acpi/events/evxface.c +++ b/drivers/acpi/events/evxface.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -143,8 +143,8 @@ acpi_install_fixed_event_handler(u32 event, if (ACPI_SUCCESS(status)) status = acpi_enable_event(event, 0); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Could not enable fixed event.\n")); + ACPI_REPORT_WARNING(("Could not enable fixed event %X\n", + event)); /* Remove the handler */ @@ -204,10 +204,9 @@ acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler) acpi_gbl_fixed_event_handlers[event].context = NULL; if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Could not write to fixed event enable register.\n")); + ACPI_REPORT_WARNING(("Could not write to fixed event enable register %X\n", event)); } else { - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X.\n", + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X\n", event)); } @@ -434,7 +433,7 @@ acpi_remove_notify_handler(acpi_handle device, if (device == ACPI_ROOT_OBJECT) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "Removing notify handler for ROOT object.\n")); + "Removing notify handler for namespace root object\n")); if (((handler_type & ACPI_SYSTEM_NOTIFY) && !acpi_gbl_system_notify.handler) || diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c index c1b898928256..90eb7939e986 100644 --- a/drivers/acpi/events/evxfevnt.c +++ b/drivers/acpi/events/evxfevnt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -70,8 +70,7 @@ acpi_status acpi_enable(void) /* Make sure we have the FADT */ if (!acpi_gbl_FADT) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "No FADT information present!\n")); + ACPI_REPORT_WARNING(("No FADT information present!\n")); return_ACPI_STATUS(AE_NO_ACPI_TABLES); } @@ -83,7 +82,7 @@ acpi_status acpi_enable(void) status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not transition to ACPI mode.\n")); + ACPI_REPORT_ERROR(("Could not transition to ACPI mode\n")); return_ACPI_STATUS(status); } @@ -113,8 +112,7 @@ acpi_status acpi_disable(void) ACPI_FUNCTION_TRACE("acpi_disable"); if (!acpi_gbl_FADT) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "No FADT information present!\n")); + ACPI_REPORT_WARNING(("No FADT information present!\n")); return_ACPI_STATUS(AE_NO_ACPI_TABLES); } @@ -127,8 +125,7 @@ acpi_status acpi_disable(void) status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not exit ACPI mode to legacy mode")); + ACPI_REPORT_ERROR(("Could not exit ACPI mode to legacy mode")); return_ACPI_STATUS(status); } @@ -185,9 +182,8 @@ acpi_status acpi_enable_event(u32 event, u32 flags) } if (value != 1) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not enable %s event\n", - acpi_ut_get_event_name(event))); + ACPI_REPORT_ERROR(("Could not enable %s event\n", + acpi_ut_get_event_name(event))); return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); } @@ -384,9 +380,8 @@ acpi_status acpi_disable_event(u32 event, u32 flags) } if (value != 0) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not disable %s events\n", - acpi_ut_get_event_name(event))); + ACPI_REPORT_ERROR(("Could not disable %s events\n", + acpi_ut_get_event_name(event))); return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); } diff --git a/drivers/acpi/events/evxfregn.c b/drivers/acpi/events/evxfregn.c index 6f28ea2db5ba..abf5caca9ae5 100644 --- a/drivers/acpi/events/evxfregn.c +++ b/drivers/acpi/events/evxfregn.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c index 1ce365d651d8..109d0255a5bb 100644 --- a/drivers/acpi/executer/exconfig.c +++ b/drivers/acpi/executer/exconfig.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -413,9 +413,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc, (!ACPI_STRNCMP(table_ptr->signature, acpi_gbl_table_data[ACPI_TABLE_SSDT].signature, acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Table has invalid signature [%4.4s], must be SSDT or PSDT\n", - table_ptr->signature)); + ACPI_REPORT_ERROR(("Table has invalid signature [%4.4s], must be SSDT or PSDT\n", table_ptr->signature)); status = AE_BAD_SIGNATURE; goto cleanup; } diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c index fa9e75d4ec65..e6f55cf8ad31 100644 --- a/drivers/acpi/executer/exconvrt.c +++ b/drivers/acpi/executer/exconvrt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -654,17 +654,8 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type, break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unknown Target type ID 0x%X Op %s dest_type %s\n", - GET_CURRENT_ARG_TYPE(walk_state->op_info-> - runtime_args), - walk_state->op_info->name, - acpi_ut_get_type_name(destination_type))); - - ACPI_REPORT_ERROR(("Bad Target Type (ARGI): %X\n", - GET_CURRENT_ARG_TYPE(walk_state->op_info-> - runtime_args))) - status = AE_AML_INTERNAL; + ACPI_REPORT_ERROR(("Unknown Target type ID 0x%X aml_opcode %X dest_type %s\n", GET_CURRENT_ARG_TYPE(walk_state->op_info->runtime_args), walk_state->opcode, acpi_ut_get_type_name(destination_type))); + status = AE_AML_INTERNAL; } /* diff --git a/drivers/acpi/executer/excreate.c b/drivers/acpi/executer/excreate.c index 91c49188fb07..da313dad576a 100644 --- a/drivers/acpi/executer/excreate.c +++ b/drivers/acpi/executer/excreate.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index 17c79cd91b31..a7cca8d4f855 100644 --- a/drivers/acpi/executer/exdump.c +++ b/drivers/acpi/executer/exdump.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/executer/exfield.c b/drivers/acpi/executer/exfield.c index ab1ba399aa28..78a76f91a1c9 100644 --- a/drivers/acpi/executer/exfield.c +++ b/drivers/acpi/executer/exfield.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/executer/exfldio.c b/drivers/acpi/executer/exfldio.c index ba6e08843c29..9fe27fd04a2f 100644 --- a/drivers/acpi/executer/exfldio.c +++ b/drivers/acpi/executer/exfldio.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -94,10 +94,9 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc, /* We must have a valid region */ if (ACPI_GET_OBJECT_TYPE(rgn_desc) != ACPI_TYPE_REGION) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Needed Region, found type %X (%s)\n", - ACPI_GET_OBJECT_TYPE(rgn_desc), - acpi_ut_get_object_type_name(rgn_desc))); + ACPI_REPORT_ERROR(("Needed Region, found type %X (%s)\n", + ACPI_GET_OBJECT_TYPE(rgn_desc), + acpi_ut_get_object_type_name(rgn_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -162,31 +161,14 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc, * than the region itself. For example, a region of length one * byte, and a field with Dword access specified. */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n", - acpi_ut_get_node_name(obj_desc-> - common_field. - node), - obj_desc->common_field. - access_byte_width, - acpi_ut_get_node_name(rgn_desc-> - region.node), - rgn_desc->region.length)); + ACPI_REPORT_ERROR(("Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n", acpi_ut_get_node_name(obj_desc->common_field.node), obj_desc->common_field.access_byte_width, acpi_ut_get_node_name(rgn_desc->region.node), rgn_desc->region.length)); } /* * Offset rounded up to next multiple of field width * exceeds region length, indicate an error */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)\n", - acpi_ut_get_node_name(obj_desc->common_field. - node), - obj_desc->common_field.base_byte_offset, - field_datum_byte_offset, - obj_desc->common_field.access_byte_width, - acpi_ut_get_node_name(rgn_desc->region.node), - rgn_desc->region.length)); + ACPI_REPORT_ERROR(("Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)\n", acpi_ut_get_node_name(obj_desc->common_field.node), obj_desc->common_field.base_byte_offset, field_datum_byte_offset, obj_desc->common_field.access_byte_width, acpi_ut_get_node_name(rgn_desc->region.node), rgn_desc->region.length)); return_ACPI_STATUS(AE_AML_REGION_LIMIT); } @@ -270,12 +252,11 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc, if (ACPI_FAILURE(status)) { if (status == AE_NOT_IMPLEMENTED) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Region %s(%X) not implemented\n", - acpi_ut_get_region_name(rgn_desc-> - region. - space_id), - rgn_desc->region.space_id)); + ACPI_REPORT_ERROR(("Region %s(%X) not implemented\n", + acpi_ut_get_region_name(rgn_desc-> + region. + space_id), + rgn_desc->region.space_id)); } else if (status == AE_NOT_EXIST) { ACPI_REPORT_ERROR(("Region %s(%X) has no handler\n", acpi_ut_get_region_name(rgn_desc-> @@ -618,11 +599,10 @@ acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc, default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "write_with_update_rule: Unknown update_rule setting: %X\n", - (obj_desc->common_field. - field_flags & - AML_FIELD_UPDATE_RULE_MASK))); + ACPI_REPORT_ERROR(("Unknown update_rule value: %X\n", + (obj_desc->common_field. + field_flags & + AML_FIELD_UPDATE_RULE_MASK))); return_ACPI_STATUS(AE_AML_OPERAND_VALUE); } } @@ -677,10 +657,7 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc, if (buffer_length < ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Field size %X (bits) is too large for buffer (%X)\n", - obj_desc->common_field.bit_length, - buffer_length)); + ACPI_REPORT_ERROR(("Field size %X (bits) is too large for buffer (%X)\n", obj_desc->common_field.bit_length, buffer_length)); return_ACPI_STATUS(AE_BUFFER_OVERFLOW); } @@ -792,10 +769,7 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc, if (buffer_length < ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Field size %X (bits) is too large for buffer (%X)\n", - obj_desc->common_field.bit_length, - buffer_length)); + ACPI_REPORT_ERROR(("Field size %X (bits) is too large for buffer (%X)\n", obj_desc->common_field.bit_length, buffer_length)); return_ACPI_STATUS(AE_BUFFER_OVERFLOW); } diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c index 0778bff632bf..5ad34566738c 100644 --- a/drivers/acpi/executer/exmisc.c +++ b/drivers/acpi/executer/exmisc.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -98,7 +98,8 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc, default: - ACPI_REPORT_ERROR(("Unknown Reference opcode in get_reference %X\n", obj_desc->reference.opcode)); + ACPI_REPORT_ERROR(("Unknown Reference opcode %X\n", + obj_desc->reference.opcode)); return_ACPI_STATUS(AE_AML_INTERNAL); } break; @@ -113,7 +114,8 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc, default: - ACPI_REPORT_ERROR(("Invalid descriptor type in get_reference: %X\n", ACPI_GET_DESCRIPTOR_TYPE(obj_desc))); + ACPI_REPORT_ERROR(("Invalid descriptor type %X\n", + ACPI_GET_DESCRIPTOR_TYPE(obj_desc))); return_ACPI_STATUS(AE_TYPE); } @@ -266,7 +268,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, break; default: - ACPI_REPORT_ERROR(("Concatanate - invalid object type: %X\n", + ACPI_REPORT_ERROR(("Invalid object type: %X\n", ACPI_GET_OBJECT_TYPE(operand0))); status = AE_AML_INTERNAL; } @@ -368,7 +370,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, /* Invalid object type, should not happen here */ - ACPI_REPORT_ERROR(("Concatenate - Invalid object type: %X\n", + ACPI_REPORT_ERROR(("Invalid object type: %X\n", ACPI_GET_OBJECT_TYPE(operand0))); status = AE_AML_INTERNAL; goto cleanup; diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c index ab47f6d8b5c0..89b8ab79410b 100644 --- a/drivers/acpi/executer/exmutex.c +++ b/drivers/acpi/executer/exmutex.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c index 7bb5e17b5680..de3216b6a4fc 100644 --- a/drivers/acpi/executer/exnames.c +++ b/drivers/acpi/executer/exnames.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -99,7 +99,8 @@ static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs) */ name_string = ACPI_MEM_ALLOCATE(size_needed); if (!name_string) { - ACPI_REPORT_ERROR(("ex_allocate_name_string: Could not allocate size %d\n", size_needed)); + ACPI_REPORT_ERROR(("Could not allocate size %d\n", + size_needed)); return_PTR(NULL); } @@ -167,8 +168,7 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string) char_buf[0] = *aml_address; if ('0' <= char_buf[0] && char_buf[0] <= '9') { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "leading digit: %c\n", - char_buf[0])); + ACPI_REPORT_ERROR(("Invalid leading digit: %c\n", char_buf[0])); return_ACPI_STATUS(AE_CTRL_PENDING); } @@ -211,9 +211,8 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string) * the required 4 */ status = AE_AML_BAD_NAME; - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Bad character %02x in name, at %p\n", - *aml_address, aml_address)); + ACPI_REPORT_ERROR(("Bad character %02x in name, at %p\n", + *aml_address, aml_address)); } *in_aml_address = ACPI_CAST_PTR(u8, aml_address); @@ -412,8 +411,7 @@ acpi_ex_get_name_string(acpi_object_type data_type, if (AE_CTRL_PENDING == status && has_prefix) { /* Ran out of segments after processing a prefix */ - ACPI_REPORT_ERROR(("ex_do_name: Malformed Name at %p\n", - name_string)); + ACPI_REPORT_ERROR(("Malformed Name at %p\n", name_string)); status = AE_AML_BAD_NAME; } diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c index 97e34542f5e4..bc8837ecb716 100644 --- a/drivers/acpi/executer/exoparg1.c +++ b/drivers/acpi/executer/exoparg1.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -111,7 +111,8 @@ acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state) default: /* Unknown opcode */ - ACPI_REPORT_ERROR(("acpi_ex_opcode_0A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); + ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; break; } @@ -188,7 +189,8 @@ acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state) default: /* Unknown opcode */ - ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); + ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; break; } @@ -227,7 +229,8 @@ acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state) default: /* Unknown opcode */ - ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_1T_0R: Unknown opcode %X\n", walk_state->opcode)); + ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } @@ -346,9 +349,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state) /* Check the range of the digit */ if (temp32 > 9) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "BCD digit too large (not decimal): 0x%X\n", - temp32)); + ACPI_REPORT_ERROR(("BCD digit too large (not decimal): 0x%X\n", temp32)); status = AE_AML_NUMERIC_OVERFLOW; goto cleanup; @@ -393,12 +394,7 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state) /* Overflow if there is any data left in Digit */ if (digit > 0) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Integer too large to convert to BCD: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64(operand - [0]-> - integer. - value))); + ACPI_REPORT_ERROR(("Integer too large to convert to BCD: %8.8X%8.8X\n", ACPI_FORMAT_UINT64(operand[0]->integer.value))); status = AE_AML_NUMERIC_OVERFLOW; goto cleanup; } @@ -525,15 +521,16 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state) /* These are two obsolete opcodes */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "%s is obsolete and not implemented\n", - acpi_ps_get_opcode_name(walk_state->opcode))); + ACPI_REPORT_ERROR(("%s is obsolete and not implemented\n", + acpi_ps_get_opcode_name(walk_state-> + opcode))); status = AE_SUPPORT; goto cleanup; default: /* Unknown opcode */ - ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_1T_1R: Unknown opcode %X\n", walk_state->opcode)); + ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } @@ -639,11 +636,10 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) acpi_ex_resolve_operands(AML_LNOT_OP, &temp_desc, walk_state); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "%s: bad operand(s) %s\n", - acpi_ps_get_opcode_name(walk_state-> - opcode), - acpi_format_exception(status))); + ACPI_REPORT_ERROR(("%s: bad operand(s) %s\n", + acpi_ps_get_opcode_name(walk_state-> + opcode), + acpi_format_exception(status))); goto cleanup; } @@ -742,9 +738,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "size_of - Operand is not Buf/Int/Str/Pkg - found type %s\n", - acpi_ut_get_type_name(type))); + ACPI_REPORT_ERROR(("Operand is not Buf/Int/Str/Pkg - found type %s\n", acpi_ut_get_type_name(type))); status = AE_AML_OPERAND_TYPE; goto cleanup; } @@ -941,11 +935,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unknown Index target_type %X in obj %p\n", - operand[0]->reference. - target_type, - operand[0])); + ACPI_REPORT_ERROR(("Unknown Index target_type %X in obj %p\n", operand[0]->reference.target_type, operand[0])); status = AE_AML_OPERAND_TYPE; goto cleanup; } @@ -971,11 +961,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unknown opcode in ref(%p) - %X\n", - operand[0], - operand[0]->reference. - opcode)); + ACPI_REPORT_ERROR(("Unknown opcode in ref(%p) - %X\n", operand[0], operand[0]->reference.opcode)); status = AE_TYPE; goto cleanup; @@ -985,7 +971,8 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("acpi_ex_opcode_1A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); + ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } diff --git a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/executer/exoparg2.c index d8472842c1fd..7c59dda40946 100644 --- a/drivers/acpi/executer/exoparg2.c +++ b/drivers/acpi/executer/exoparg2.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -111,9 +111,7 @@ acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state) /* Are notifies allowed on this object? */ if (!acpi_ev_is_notify_object(node)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unexpected notify object type [%s]\n", - acpi_ut_get_type_name(node->type))); + ACPI_REPORT_ERROR(("Unexpected notify object type [%s]\n", acpi_ut_get_type_name(node->type))); status = AE_AML_OPERAND_TYPE; break; @@ -157,7 +155,8 @@ acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); + ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; } @@ -221,7 +220,8 @@ acpi_status acpi_ex_opcode_2A_2T_1R(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_2T_1R: Unknown opcode %X\n", walk_state->opcode)); + ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } @@ -389,10 +389,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) /* Object to be indexed is a Package */ if (index >= operand[0]->package.count) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Index value (%X%8.8X) beyond package end (%X)\n", - ACPI_FORMAT_UINT64(index), - operand[0]->package.count)); + ACPI_REPORT_ERROR(("Index value (%X%8.8X) beyond package end (%X)\n", ACPI_FORMAT_UINT64(index), operand[0]->package.count)); status = AE_AML_PACKAGE_LIMIT; goto cleanup; } @@ -405,10 +402,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) /* Object to be indexed is a Buffer/String */ if (index >= operand[0]->buffer.length) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Index value (%X%8.8X) beyond end of buffer (%X)\n", - ACPI_FORMAT_UINT64(index), - operand[0]->buffer.length)); + ACPI_REPORT_ERROR(("Index value (%X%8.8X) beyond end of buffer (%X)\n", ACPI_FORMAT_UINT64(index), operand[0]->buffer.length)); status = AE_AML_BUFFER_LIMIT; goto cleanup; } @@ -440,7 +434,8 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_1T_1R: Unknown opcode %X\n", walk_state->opcode)); + ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; break; } @@ -544,7 +539,8 @@ acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("acpi_ex_opcode_2A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); + ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/executer/exoparg3.c index 2ea1c322970b..a979b338a491 100644 --- a/drivers/acpi/executer/exoparg3.c +++ b/drivers/acpi/executer/exoparg3.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -119,7 +119,8 @@ acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); + ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } @@ -242,7 +243,8 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n", walk_state->opcode)); + ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } diff --git a/drivers/acpi/executer/exoparg6.c b/drivers/acpi/executer/exoparg6.c index 5dee77139576..05e7f9b67f29 100644 --- a/drivers/acpi/executer/exoparg6.c +++ b/drivers/acpi/executer/exoparg6.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -234,8 +234,7 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state) if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) || (operand[3]->integer.value > MAX_MATCH_OPERATOR)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Match operator out of range\n")); + ACPI_REPORT_ERROR(("Match operator out of range\n")); status = AE_AML_OPERAND_VALUE; goto cleanup; } @@ -244,10 +243,7 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state) index = operand[5]->integer.value; if (index >= operand[0]->package.count) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Index (%X%8.8X) beyond package end (%X)\n", - ACPI_FORMAT_UINT64(index), - operand[0]->package.count)); + ACPI_REPORT_ERROR(("Index (%X%8.8X) beyond package end (%X)\n", ACPI_FORMAT_UINT64(index), operand[0]->package.count)); status = AE_AML_PACKAGE_LIMIT; goto cleanup; } @@ -316,7 +312,8 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state) default: - ACPI_REPORT_ERROR(("acpi_ex_opcode_6A_0T_1R: Unknown opcode %X\n", walk_state->opcode)); + ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } diff --git a/drivers/acpi/executer/exprep.c b/drivers/acpi/executer/exprep.c index 88ccbf3b29d0..3bde780c94cf 100644 --- a/drivers/acpi/executer/exprep.c +++ b/drivers/acpi/executer/exprep.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -274,8 +274,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc, default: /* Invalid field access type */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unknown field access type %X\n", access)); + ACPI_REPORT_ERROR(("Unknown field access type %X\n", access)); return_UINT32(0); } @@ -422,15 +421,13 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info) if (info->field_type != ACPI_TYPE_LOCAL_INDEX_FIELD) { if (!info->region_node) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null region_node\n")); + ACPI_REPORT_ERROR(("Null region_node\n")); return_ACPI_STATUS(AE_AML_NO_OPERAND); } type = acpi_ns_get_type(info->region_node); if (type != ACPI_TYPE_REGION) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Needed Region, found type %X (%s)\n", - type, acpi_ut_get_type_name(type))); + ACPI_REPORT_ERROR(("Needed Region, found type %X (%s)\n", type, acpi_ut_get_type_name(type))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c index 80118be3f544..82983575cca6 100644 --- a/drivers/acpi/executer/exregion.c +++ b/drivers/acpi/executer/exregion.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -103,9 +103,8 @@ acpi_ex_system_memory_space_handler(u32 function, break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid system_memory width %d\n", - bit_width)); + ACPI_REPORT_ERROR(("Invalid system_memory width %d\n", + bit_width)); return_ACPI_STATUS(AE_AML_OPERAND_VALUE); } @@ -159,10 +158,7 @@ acpi_ex_system_memory_space_handler(u32 function, (void **)&mem_info-> mapped_logical_address); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not map memory at %8.8X%8.8X, size %X\n", - ACPI_FORMAT_UINT64(address), - (u32) window_size)); + ACPI_REPORT_ERROR(("Could not map memory at %8.8X%8.8X, size %X\n", ACPI_FORMAT_UINT64(address), (u32) window_size)); mem_info->mapped_length = 0; return_ACPI_STATUS(status); } diff --git a/drivers/acpi/executer/exresnte.c b/drivers/acpi/executer/exresnte.c index ff5d8f97e8eb..a5cca7eda210 100644 --- a/drivers/acpi/executer/exresnte.c +++ b/drivers/acpi/executer/exresnte.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -122,8 +122,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, } if (!source_desc) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "No object attached to node %p\n", node)); + ACPI_REPORT_ERROR(("No object attached to node %p\n", node)); return_ACPI_STATUS(AE_AML_NO_OPERAND); } @@ -135,10 +134,9 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, case ACPI_TYPE_PACKAGE: if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_PACKAGE) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Object not a Package, type %s\n", - acpi_ut_get_object_type_name - (source_desc))); + ACPI_REPORT_ERROR(("Object not a Package, type %s\n", + acpi_ut_get_object_type_name + (source_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -154,10 +152,9 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, case ACPI_TYPE_BUFFER: if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Object not a Buffer, type %s\n", - acpi_ut_get_object_type_name - (source_desc))); + ACPI_REPORT_ERROR(("Object not a Buffer, type %s\n", + acpi_ut_get_object_type_name + (source_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -173,10 +170,9 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, case ACPI_TYPE_STRING: if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Object not a String, type %s\n", - acpi_ut_get_object_type_name - (source_desc))); + ACPI_REPORT_ERROR(("Object not a String, type %s\n", + acpi_ut_get_object_type_name + (source_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -189,10 +185,9 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, case ACPI_TYPE_INTEGER: if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Object not a Integer, type %s\n", - acpi_ut_get_object_type_name - (source_desc))); + ACPI_REPORT_ERROR(("Object not a Integer, type %s\n", + acpi_ut_get_object_type_name + (source_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -236,9 +231,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, case ACPI_TYPE_ANY: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Untyped entry %p, no attached object!\n", - node)); + ACPI_REPORT_ERROR(("Untyped entry %p, no attached object!\n", + node)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ @@ -257,12 +251,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, default: /* No named references are allowed here */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unsupported Reference opcode %X (%s)\n", - source_desc->reference.opcode, - acpi_ps_get_opcode_name(source_desc-> - reference. - opcode))); + ACPI_REPORT_ERROR(("Unsupported Reference opcode %X (%s)\n", source_desc->reference.opcode, acpi_ps_get_opcode_name(source_desc->reference.opcode))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -272,9 +261,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, /* Default case is for unknown types */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Node %p - Unknown object type %X\n", - node, entry_type)); + ACPI_REPORT_ERROR(("Node %p - Unknown object type %X\n", + node, entry_type)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); diff --git a/drivers/acpi/executer/exresolv.c b/drivers/acpi/executer/exresolv.c index 97eecbd3242d..ae2d2da00844 100644 --- a/drivers/acpi/executer/exresolv.c +++ b/drivers/acpi/executer/exresolv.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -81,7 +81,7 @@ acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr, ACPI_FUNCTION_TRACE_PTR("ex_resolve_to_value", stack_ptr); if (!stack_ptr || !*stack_ptr) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Internal - null pointer\n")); + ACPI_REPORT_ERROR(("Internal - null pointer\n")); return_ACPI_STATUS(AE_AML_NO_OPERAND); } @@ -97,8 +97,7 @@ acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr, } if (!*stack_ptr) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Internal - null pointer\n")); + ACPI_REPORT_ERROR(("Internal - null pointer\n")); return_ACPI_STATUS(AE_AML_NO_OPERAND); } } @@ -228,9 +227,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, * A NULL object descriptor means an unitialized element of * the package, can't dereference it */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Attempt to deref an Index to NULL pkg element Idx=%p\n", - stack_desc)); + ACPI_REPORT_ERROR(("Attempt to deref an Index to NULL pkg element Idx=%p\n", stack_desc)); status = AE_AML_UNINITIALIZED_ELEMENT; } break; @@ -239,7 +236,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, /* Invalid reference object */ - ACPI_REPORT_ERROR(("During resolve, Unknown target_type %X in Index/Reference obj %p\n", stack_desc->reference.target_type, stack_desc)); + ACPI_REPORT_ERROR(("Unknown target_type %X in Index/Reference obj %p\n", stack_desc->reference.target_type, stack_desc)); status = AE_AML_INTERNAL; break; } @@ -264,7 +261,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, default: - ACPI_REPORT_ERROR(("During resolve, Unknown Reference opcode %X (%s) in %p\n", opcode, acpi_ps_get_opcode_name(opcode), stack_desc)); + ACPI_REPORT_ERROR(("Unknown Reference opcode %X (%s) in %p\n", opcode, acpi_ps_get_opcode_name(opcode), stack_desc)); status = AE_AML_INTERNAL; break; } @@ -386,7 +383,10 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) { - ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", node, acpi_ut_get_descriptor_name(node))); + ACPI_REPORT_ERROR(("Not a NS node %p [%s]\n", + node, + acpi_ut_get_descriptor_name + (node))); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -442,7 +442,10 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) { - ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n", node, acpi_ut_get_descriptor_name(node))); + ACPI_REPORT_ERROR(("Not a NS node %p [%s]\n", + node, + acpi_ut_get_descriptor_name + (node))); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -511,7 +514,8 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, default: - ACPI_REPORT_ERROR(("acpi_ex_resolve_multiple: Unknown Reference subtype %X\n", obj_desc->reference.opcode)); + ACPI_REPORT_ERROR(("Unknown Reference subtype %X\n", + obj_desc->reference.opcode)); return_ACPI_STATUS(AE_AML_INTERNAL); } } diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c index b04e4a3707a1..804faebf825c 100644 --- a/drivers/acpi/executer/exresop.c +++ b/drivers/acpi/executer/exresop.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -73,7 +73,7 @@ static acpi_status acpi_ex_check_object_type(acpi_object_type type_needed, acpi_object_type this_type, void *object) { - ACPI_FUNCTION_NAME("ex_check_object_type"); + ACPI_FUNCTION_ENTRY(); if (type_needed == ACPI_TYPE_ANY) { /* All types OK, so we don't perform any typechecks */ @@ -95,10 +95,9 @@ acpi_ex_check_object_type(acpi_object_type type_needed, } if (type_needed != this_type) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Needed [%s], found [%s] %p\n", - acpi_ut_get_type_name(type_needed), - acpi_ut_get_type_name(this_type), object)); + ACPI_REPORT_ERROR(("Needed type [%s], found [%s] %p\n", + acpi_ut_get_type_name(type_needed), + acpi_ut_get_type_name(this_type), object)); return (AE_AML_OPERAND_TYPE); } @@ -151,7 +150,7 @@ acpi_ex_resolve_operands(u16 opcode, arg_types = op_info->runtime_args; if (arg_types == ARGI_INVALID_OPCODE) { - ACPI_REPORT_ERROR(("resolve_operands: %X is not a valid AML opcode\n", opcode)); + ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", opcode)); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -169,7 +168,8 @@ acpi_ex_resolve_operands(u16 opcode, */ while (GET_CURRENT_ARG_TYPE(arg_types)) { if (!stack_ptr || !*stack_ptr) { - ACPI_REPORT_ERROR(("resolve_operands: Null stack entry at %p\n", stack_ptr)); + ACPI_REPORT_ERROR(("Null stack entry at %p\n", + stack_ptr)); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -198,9 +198,7 @@ acpi_ex_resolve_operands(u16 opcode, /* Check for bad acpi_object_type */ if (!acpi_ut_valid_object_type(object_type)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Bad operand object type [%X]\n", - object_type)); + ACPI_REPORT_ERROR(("Bad operand object type [%X]\n", object_type)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -238,13 +236,7 @@ acpi_ex_resolve_operands(u16 opcode, break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Operand is a Reference, Unknown Reference Opcode %X [%s]\n", - obj_desc->reference. - opcode, - (acpi_ps_get_opcode_info - (obj_desc->reference. - opcode))->name)); + ACPI_REPORT_ERROR(("Operand is a Reference, Unknown Reference Opcode: %X\n", obj_desc->reference.opcode)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -255,11 +247,10 @@ acpi_ex_resolve_operands(u16 opcode, /* Invalid descriptor */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid descriptor %p [%s]\n", - obj_desc, - acpi_ut_get_descriptor_name - (obj_desc))); + ACPI_REPORT_ERROR(("Invalid descriptor %p [%s]\n", + obj_desc, + acpi_ut_get_descriptor_name + (obj_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -417,11 +408,7 @@ acpi_ex_resolve_operands(u16 opcode, acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16); if (ACPI_FAILURE(status)) { if (status == AE_TYPE) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Needed [Integer/String/Buffer], found [%s] %p\n", - acpi_ut_get_object_type_name - (obj_desc), - obj_desc)); + ACPI_REPORT_ERROR(("Needed [Integer/String/Buffer], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -444,11 +431,7 @@ acpi_ex_resolve_operands(u16 opcode, status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr); if (ACPI_FAILURE(status)) { if (status == AE_TYPE) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Needed [Integer/String/Buffer], found [%s] %p\n", - acpi_ut_get_object_type_name - (obj_desc), - obj_desc)); + ACPI_REPORT_ERROR(("Needed [Integer/String/Buffer], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -472,11 +455,7 @@ acpi_ex_resolve_operands(u16 opcode, ACPI_IMPLICIT_CONVERT_HEX); if (ACPI_FAILURE(status)) { if (status == AE_TYPE) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Needed [Integer/String/Buffer], found [%s] %p\n", - acpi_ut_get_object_type_name - (obj_desc), - obj_desc)); + ACPI_REPORT_ERROR(("Needed [Integer/String/Buffer], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -502,10 +481,7 @@ acpi_ex_resolve_operands(u16 opcode, break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Needed [Integer/String/Buffer], found [%s] %p\n", - acpi_ut_get_object_type_name - (obj_desc), obj_desc)); + ACPI_REPORT_ERROR(("Needed [Integer/String/Buffer], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -539,10 +515,7 @@ acpi_ex_resolve_operands(u16 opcode, break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Needed [Integer/String/Buffer], found [%s] %p\n", - acpi_ut_get_object_type_name - (obj_desc), obj_desc)); + ACPI_REPORT_ERROR(("Needed [Integer/String/Buffer], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -566,10 +539,7 @@ acpi_ex_resolve_operands(u16 opcode, break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Needed [Buffer/String/Package/Reference], found [%s] %p\n", - acpi_ut_get_object_type_name - (obj_desc), obj_desc)); + ACPI_REPORT_ERROR(("Needed [Buffer/String/Package/Reference], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -588,10 +558,7 @@ acpi_ex_resolve_operands(u16 opcode, break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Needed [Buffer/String/Package], found [%s] %p\n", - acpi_ut_get_object_type_name - (obj_desc), obj_desc)); + ACPI_REPORT_ERROR(("Needed [Buffer/String/Package], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -611,10 +578,7 @@ acpi_ex_resolve_operands(u16 opcode, break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Needed [Region/region_field], found [%s] %p\n", - acpi_ut_get_object_type_name - (obj_desc), obj_desc)); + ACPI_REPORT_ERROR(("Needed [Region/region_field], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -656,10 +620,7 @@ acpi_ex_resolve_operands(u16 opcode, break; } - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n", - acpi_ut_get_object_type_name - (obj_desc), obj_desc)); + ACPI_REPORT_ERROR(("Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -669,9 +630,7 @@ acpi_ex_resolve_operands(u16 opcode, /* Unknown type */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Internal - Unknown ARGI (required operand) type %X\n", - this_arg_type)); + ACPI_REPORT_ERROR(("Internal - Unknown ARGI (required operand) type %X\n", this_arg_type)); return_ACPI_STATUS(AE_BAD_PARAMETER); } diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c index a7d8eea305c2..202ebe1eb957 100644 --- a/drivers/acpi/executer/exstore.c +++ b/drivers/acpi/executer/exstore.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -250,7 +250,7 @@ acpi_ex_store(union acpi_operand_object *source_desc, /* Validate parameters */ if (!source_desc || !dest_desc) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null parameter\n")); + ACPI_REPORT_ERROR(("Null parameter\n")); return_ACPI_STATUS(AE_AML_NO_OPERAND); } @@ -290,10 +290,7 @@ acpi_ex_store(union acpi_operand_object *source_desc, /* Destination is not a Reference object */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Target is not a Reference or Constant object - %s [%p]\n", - acpi_ut_get_object_type_name(dest_desc), - dest_desc)); + ACPI_REPORT_ERROR(("Target is not a Reference or Constant object - %s [%p]\n", acpi_ut_get_object_type_name(dest_desc), dest_desc)); ACPI_DUMP_STACK_ENTRY(source_desc); ACPI_DUMP_STACK_ENTRY(dest_desc); @@ -360,7 +357,7 @@ acpi_ex_store(union acpi_operand_object *source_desc, default: - ACPI_REPORT_ERROR(("ex_store: Unknown Reference opcode %X\n", + ACPI_REPORT_ERROR(("Unknown Reference opcode %X\n", ref_desc->reference.opcode)); ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_ERROR); @@ -490,10 +487,7 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc, /* All other types are invalid */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Source must be Integer/Buffer/String type, not %s\n", - acpi_ut_get_object_type_name - (source_desc))); + ACPI_REPORT_ERROR(("Source must be Integer/Buffer/String type, not %s\n", acpi_ut_get_object_type_name(source_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -503,8 +497,7 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc, break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Target is not a Package or buffer_field\n")); + ACPI_REPORT_ERROR(("Target is not a Package or buffer_field\n")); status = AE_AML_OPERAND_TYPE; break; } diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/executer/exstoren.c index 382f63c14ea1..25bbc1d78547 100644 --- a/drivers/acpi/executer/exstoren.c +++ b/drivers/acpi/executer/exstoren.c @@ -7,7 +7,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -123,11 +123,7 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr, && (source_desc->reference.opcode == AML_LOAD_OP))) { /* Conversion successful but still not a valid type */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Cannot assign type %s to %s (must be type Int/Str/Buf)\n", - acpi_ut_get_object_type_name - (source_desc), - acpi_ut_get_type_name(target_type))); + ACPI_REPORT_ERROR(("Cannot assign type %s to %s (must be type Int/Str/Buf)\n", acpi_ut_get_object_type_name(source_desc), acpi_ut_get_type_name(target_type))); status = AE_AML_OPERAND_TYPE; } break; @@ -280,9 +276,8 @@ acpi_ex_store_object_to_object(union acpi_operand_object *source_desc, /* * All other types come here. */ - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "Store into type %s not implemented\n", - acpi_ut_get_object_type_name(dest_desc))); + ACPI_REPORT_WARNING(("Store into type %s not implemented\n", + acpi_ut_get_object_type_name(dest_desc))); status = AE_NOT_IMPLEMENTED; break; diff --git a/drivers/acpi/executer/exstorob.c b/drivers/acpi/executer/exstorob.c index 855db7130751..6ab707087750 100644 --- a/drivers/acpi/executer/exstorob.c +++ b/drivers/acpi/executer/exstorob.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/executer/exsystem.c index 8a88b841237d..9a3684d3cf87 100644 --- a/drivers/acpi/executer/exsystem.c +++ b/drivers/acpi/executer/exsystem.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -129,7 +129,7 @@ acpi_status acpi_ex_system_do_stall(u32 how_long) * (ACPI specifies 100 usec as max, but this gives some slack in * order to support existing BIOSs) */ - ACPI_REPORT_ERROR(("Stall: Time parameter is too large (%d)\n", + ACPI_REPORT_ERROR(("Time parameter is too large (%d)\n", how_long)); status = AE_AML_OPERAND_VALUE; } else { diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c index 9f4e547d7734..990c40e0c041 100644 --- a/drivers/acpi/executer/exutils.c +++ b/drivers/acpi/executer/exutils.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -200,9 +200,7 @@ u8 acpi_ex_acquire_global_lock(u32 field_flags) if (ACPI_SUCCESS(status)) { locked = TRUE; } else { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not acquire Global Lock, %s\n", - acpi_format_exception(status))); + ACPI_REPORT_ERROR(("Could not acquire Global Lock, %s\n", acpi_format_exception(status))); } } diff --git a/drivers/acpi/hardware/hwacpi.c b/drivers/acpi/hardware/hwacpi.c index 20a335cc9bea..5c068cc4f674 100644 --- a/drivers/acpi/hardware/hwacpi.c +++ b/drivers/acpi/hardware/hwacpi.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,8 +68,7 @@ acpi_status acpi_hw_initialize(void) /* We must have the ACPI tables by the time we get here */ if (!acpi_gbl_FADT) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No FADT is present\n")); - + ACPI_REPORT_ERROR(("No FADT is present\n")); return_ACPI_STATUS(AE_NO_ACPI_TABLES); } @@ -108,7 +107,7 @@ acpi_status acpi_hw_set_mode(u32 mode) * system does not support mode transition. */ if (!acpi_gbl_FADT->smi_cmd) { - ACPI_REPORT_ERROR(("No SMI_CMD in FADT, mode transition failed.\n")); + ACPI_REPORT_ERROR(("No SMI_CMD in FADT, mode transition failed\n")); return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); } diff --git a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/hardware/hwgpe.c index 5c8e5dfd024e..d84942d22dd5 100644 --- a/drivers/acpi/hardware/hwgpe.c +++ b/drivers/acpi/hardware/hwgpe.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c index b243f20708b7..b4b50a3d1705 100644 --- a/drivers/acpi/hardware/hwregs.c +++ b/drivers/acpi/hardware/hwregs.c @@ -7,7 +7,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -202,12 +202,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b) } if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "%s While evaluating sleep_state [%s], bad Sleep object %p type %s\n", - acpi_format_exception(status), - sleep_state_name, info.return_object, - acpi_ut_get_object_type_name(info. - return_object))); + ACPI_REPORT_ERROR(("%s While evaluating sleep_state [%s], bad Sleep object %p type %s\n", acpi_format_exception(status), sleep_state_name, info.return_object, acpi_ut_get_object_type_name(info.return_object))); } acpi_ut_remove_reference(info.return_object); @@ -230,12 +225,11 @@ EXPORT_SYMBOL(acpi_get_sleep_type_data); struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) { - ACPI_FUNCTION_NAME("hw_get_bit_register_info"); + ACPI_FUNCTION_ENTRY(); if (register_id > ACPI_BITREG_MAX) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid bit_register ID: %X\n", - register_id)); + ACPI_REPORT_ERROR(("Invalid bit_register ID: %X\n", + register_id)); return (NULL); } @@ -570,8 +564,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value) break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown Register ID: %X\n", - register_id)); + ACPI_REPORT_ERROR(("Unknown Register ID: %X\n", register_id)); status = AE_BAD_PARAMETER; break; } @@ -766,9 +759,8 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg) break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unsupported address space: %X\n", - reg->address_space_id)); + ACPI_REPORT_ERROR(("Unsupported address space: %X\n", + reg->address_space_id)); return (AE_BAD_PARAMETER); } @@ -837,9 +829,8 @@ acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg) break; default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unsupported address space: %X\n", - reg->address_space_id)); + ACPI_REPORT_ERROR(("Unsupported address space: %X\n", + reg->address_space_id)); return (AE_BAD_PARAMETER); } diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c index 34519069050c..992128d71117 100644 --- a/drivers/acpi/hardware/hwsleep.c +++ b/drivers/acpi/hardware/hwsleep.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/hardware/hwtimer.c b/drivers/acpi/hardware/hwtimer.c index aff6dc141784..fc10b7cb456f 100644 --- a/drivers/acpi/hardware/hwtimer.c +++ b/drivers/acpi/hardware/hwtimer.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c index 6923059ba3c7..c2db93e25b78 100644 --- a/drivers/acpi/namespace/nsaccess.c +++ b/drivers/acpi/namespace/nsaccess.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -110,10 +110,7 @@ acpi_status acpi_ns_root_initialize(void) ACPI_NS_NO_UPSEARCH, NULL, &new_node); if (ACPI_FAILURE(status) || (!new_node)) { /* Must be on same line for code converter */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not create predefined name %s, %s\n", - init_val->name, - acpi_format_exception(status))); + ACPI_REPORT_ERROR(("Could not create predefined name %s, %s\n", init_val->name, acpi_format_exception(status))); } /* @@ -124,9 +121,7 @@ acpi_status acpi_ns_root_initialize(void) if (init_val->val) { status = acpi_os_predefined_override(init_val, &val); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not override predefined %s\n", - init_val->name)); + ACPI_REPORT_ERROR(("Could not override predefined %s\n", init_val->name)); } if (!val) { @@ -339,7 +334,10 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, prefix_node = scope_info->scope.node; if (ACPI_GET_DESCRIPTOR_TYPE(prefix_node) != ACPI_DESC_TYPE_NAMED) { - ACPI_REPORT_ERROR(("ns_lookup: %p is not a namespace node [%s]\n", prefix_node, acpi_ut_get_descriptor_name(prefix_node))); + ACPI_REPORT_ERROR(("%p is not a namespace node [%s]\n", + prefix_node, + acpi_ut_get_descriptor_name + (prefix_node))); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -600,7 +598,7 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, (this_node->type != type_to_check_for)) { /* Complain about a type mismatch */ - ACPI_REPORT_WARNING(("ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)\n", (char *)&simple_name, acpi_ut_get_type_name(this_node->type), acpi_ut_get_type_name(type_to_check_for))); + ACPI_REPORT_WARNING(("ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)\n", ACPI_CAST_PTR(char, &simple_name), acpi_ut_get_type_name(this_node->type), acpi_ut_get_type_name(type_to_check_for))); } /* diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c index cc7a85f8cfe6..3db950f5d5a0 100644 --- a/drivers/acpi/namespace/nsalloc.c +++ b/drivers/acpi/namespace/nsalloc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -272,9 +272,8 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node) /* Grandchildren should have all been deleted already */ if (child_node->child) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Found a grandchild! P=%p C=%p\n", - parent_node, child_node)); + ACPI_REPORT_ERROR(("Found a grandchild! P=%p C=%p\n", + parent_node, child_node)); } /* Now we can free this child object */ diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c index 864c642759fa..2f0b70e3e881 100644 --- a/drivers/acpi/namespace/nsdump.c +++ b/drivers/acpi/namespace/nsdump.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -198,7 +198,8 @@ acpi_ns_dump_one_object(acpi_handle obj_handle, /* Check the node type and name */ if (type > ACPI_TYPE_LOCAL_MAX) { - ACPI_REPORT_WARNING(("Invalid ACPI Type %08X\n", type)); + ACPI_REPORT_WARNING(("Invalid ACPI Object Type %08X\n", + type)); } if (!acpi_ut_valid_acpi_name(this_node->name.integer)) { diff --git a/drivers/acpi/namespace/nsdumpdv.c b/drivers/acpi/namespace/nsdumpdv.c index 55de883943d6..aff899a935e3 100644 --- a/drivers/acpi/namespace/nsdumpdv.c +++ b/drivers/acpi/namespace/nsdumpdv.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c index 0191c7d92824..e3c667072e2f 100644 --- a/drivers/acpi/namespace/nseval.c +++ b/drivers/acpi/namespace/nseval.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -373,8 +373,7 @@ acpi_ns_execute_control_method(struct acpi_parameter_info *info) info->obj_desc = acpi_ns_get_attached_object(info->node); if (!info->obj_desc) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "No attached method object\n")); + ACPI_REPORT_ERROR(("No attached method object\n")); (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); return_ACPI_STATUS(AE_NULL_OBJECT); diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c index efa3f4233736..6c117893f301 100644 --- a/drivers/acpi/namespace/nsinit.c +++ b/drivers/acpi/namespace/nsinit.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -93,8 +93,8 @@ acpi_status acpi_ns_initialize_objects(void) ACPI_UINT32_MAX, acpi_ns_init_one_object, &info, NULL); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n", - acpi_format_exception(status))); + ACPI_REPORT_ERROR(("walk_namespace failed! %s\n", + acpi_format_exception(status))); } ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, @@ -159,8 +159,8 @@ acpi_status acpi_ns_initialize_devices(void) (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n", - acpi_format_exception(status))); + ACPI_REPORT_ERROR(("walk_namespace failed! %s\n", + acpi_format_exception(status))); } ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, @@ -289,12 +289,7 @@ acpi_ns_init_one_object(acpi_handle obj_handle, } if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR, "\n")); - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not execute arguments for [%4.4s] (%s), %s\n", - acpi_ut_get_node_name(node), - acpi_ut_get_type_name(type), - acpi_format_exception(status))); + ACPI_REPORT_ERROR(("\nCould not execute arguments for [%4.4s] (%s), %s\n", acpi_ut_get_node_name(node), acpi_ut_get_type_name(type), acpi_format_exception(status))); } /* @@ -421,8 +416,9 @@ acpi_ns_init_one_device(acpi_handle obj_handle, #ifdef ACPI_DEBUG_OUTPUT char *scope_name = acpi_ns_get_external_pathname(ini_node); - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "%s._INI failed: %s\n", - scope_name, acpi_format_exception(status))); + ACPI_REPORT_WARNING(("%s._INI failed: %s\n", + scope_name, + acpi_format_exception(status))); ACPI_MEM_FREE(scope_name); #endif diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c index c28849de465a..0b4a866ef5aa 100644 --- a/drivers/acpi/namespace/nsload.c +++ b/drivers/acpi/namespace/nsload.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -92,7 +92,7 @@ acpi_ns_load_table(struct acpi_table_desc *table_desc, /* Check validity of the AML start and length */ if (!table_desc->aml_start) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Null AML pointer\n")); + ACPI_REPORT_ERROR(("Null AML pointer\n")); return_ACPI_STATUS(AE_BAD_PARAMETER); } @@ -263,7 +263,7 @@ acpi_status acpi_ns_load_namespace(void) /* There must be at least a DSDT installed */ if (acpi_gbl_DSDT == NULL) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "DSDT is not in memory\n")); + ACPI_REPORT_ERROR(("DSDT is not in memory\n")); return_ACPI_STATUS(AE_NO_ACPI_TABLES); } diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c index 5400728eb791..411e1f8b11d0 100644 --- a/drivers/acpi/namespace/nsnames.c +++ b/drivers/acpi/namespace/nsnames.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -75,7 +75,7 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node, acpi_size index; struct acpi_namespace_node *parent_node; - ACPI_FUNCTION_NAME("ns_build_external_path"); + ACPI_FUNCTION_ENTRY(); /* Special case for root */ @@ -110,9 +110,7 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node, name_buffer[index] = AML_ROOT_PREFIX; if (index != 0) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not construct pathname; index=%X, size=%X, Path=%s\n", - (u32) index, (u32) size, &name_buffer[size])); + ACPI_REPORT_ERROR(("Could not construct pathname; index=%X, size=%X, Path=%s\n", (u32) index, (u32) size, &name_buffer[size])); } return; @@ -148,7 +146,7 @@ char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node) name_buffer = ACPI_MEM_CALLOCATE(size); if (!name_buffer) { - ACPI_REPORT_ERROR(("ns_get_table_pathname: allocation failure\n")); + ACPI_REPORT_ERROR(("Allocation failure\n")); return_PTR(NULL); } diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/namespace/nsobject.c index fc9be946ebed..86113093f7b7 100644 --- a/drivers/acpi/namespace/nsobject.c +++ b/drivers/acpi/namespace/nsobject.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,21 +84,21 @@ acpi_ns_attach_object(struct acpi_namespace_node *node, if (!node) { /* Invalid handle */ - ACPI_REPORT_ERROR(("ns_attach_object: Null named_obj handle\n")); + ACPI_REPORT_ERROR(("Null named_obj handle\n")); return_ACPI_STATUS(AE_BAD_PARAMETER); } if (!object && (ACPI_TYPE_ANY != type)) { /* Null object */ - ACPI_REPORT_ERROR(("ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n")); + ACPI_REPORT_ERROR(("Null object, but type not ACPI_TYPE_ANY\n")); return_ACPI_STATUS(AE_BAD_PARAMETER); } if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) { /* Not a name handle */ - ACPI_REPORT_ERROR(("ns_attach_object: Invalid handle %p [%s]\n", + ACPI_REPORT_ERROR(("Invalid handle %p [%s]\n", node, acpi_ut_get_descriptor_name(node))); return_ACPI_STATUS(AE_BAD_PARAMETER); } @@ -254,7 +254,7 @@ union acpi_operand_object *acpi_ns_get_attached_object(struct ACPI_FUNCTION_TRACE_PTR("ns_get_attached_object", node); if (!node) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Null Node ptr\n")); + ACPI_REPORT_WARNING(("Null Node ptr\n")); return_PTR(NULL); } diff --git a/drivers/acpi/namespace/nsparse.c b/drivers/acpi/namespace/nsparse.c index 433442a9ec74..232be4303653 100644 --- a/drivers/acpi/namespace/nsparse.c +++ b/drivers/acpi/namespace/nsparse.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c index c1b1943d4670..f094a2eb8512 100644 --- a/drivers/acpi/namespace/nssearch.c +++ b/drivers/acpi/namespace/nssearch.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -298,18 +298,15 @@ acpi_ns_search_and_enter(u32 target_name, /* Parameter validation */ if (!node || !target_name || !return_node) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Null param: Node %p Name %X return_node %p\n", - node, target_name, return_node)); - - ACPI_REPORT_ERROR(("ns_search_and_enter: Null parameter\n")); + ACPI_REPORT_ERROR(("Null param: Node %p Name %X return_node %p\n", node, target_name, return_node)); return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Name must consist of printable characters */ if (!acpi_ut_valid_acpi_name(target_name)) { - ACPI_REPORT_ERROR(("ns_search_and_enter: Bad character in ACPI Name: %X\n", target_name)); + ACPI_REPORT_ERROR(("Bad character in ACPI Name: %X\n", + target_name)); return_ACPI_STATUS(AE_BAD_CHARACTER); } diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c index 549075fb9f88..bc779fdd3caf 100644 --- a/drivers/acpi/namespace/nsutils.c +++ b/drivers/acpi/namespace/nsutils.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,7 +63,6 @@ acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search); * * PARAMETERS: module_name - Caller's module name (for error output) * line_number - Caller's line number (for error output) - * component_id - Caller's component ID (for error output) * internal_name - Name or path of the namespace node * lookup_status - Exception code from NS lookup * @@ -76,14 +75,12 @@ acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search); void acpi_ns_report_error(char *module_name, u32 line_number, - u32 component_id, char *internal_name, acpi_status lookup_status) { acpi_status status; char *name = NULL; - acpi_os_printf("%8s-%04d: *** Error: Looking up ", - module_name, line_number); + acpi_ut_report_error(module_name, line_number); if (lookup_status == AE_BAD_CHARACTER) { /* There is a non-ascii character in the name */ @@ -109,7 +106,7 @@ acpi_ns_report_error(char *module_name, } } - acpi_os_printf(" in namespace, %s\n", + acpi_os_printf("Namespace lookup failure, %s\n", acpi_format_exception(lookup_status)); } @@ -119,10 +116,9 @@ acpi_ns_report_error(char *module_name, * * PARAMETERS: module_name - Caller's module name (for error output) * line_number - Caller's line number (for error output) - * component_id - Caller's component ID (for error output) * Message - Error message to use on failure * prefix_node - Prefix relative to the path - * Path - Path to the node + * Path - Path to the node (optional) * method_status - Execution status * * RETURN: None @@ -134,7 +130,6 @@ acpi_ns_report_error(char *module_name, void acpi_ns_report_method_error(char *module_name, u32 line_number, - u32 component_id, char *message, struct acpi_namespace_node *prefix_node, char *path, acpi_status method_status) @@ -142,17 +137,16 @@ acpi_ns_report_method_error(char *module_name, acpi_status status; struct acpi_namespace_node *node = prefix_node; + acpi_ut_report_error(module_name, line_number); + if (path) { status = acpi_ns_get_node_by_path(path, prefix_node, ACPI_NS_NO_UPSEARCH, &node); if (ACPI_FAILURE(status)) { - acpi_os_printf - ("report_method_error: Could not get node\n"); - return; + acpi_os_printf("[Could not get node by pathname]"); } } - acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number); acpi_ns_print_node_pathname(node, message); acpi_os_printf(", %s\n", acpi_format_exception(method_status)); } @@ -248,7 +242,7 @@ acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node) ACPI_FUNCTION_TRACE("ns_get_type"); if (!node) { - ACPI_REPORT_WARNING(("ns_get_type: Null Node input pointer\n")); + ACPI_REPORT_WARNING(("Null Node parameter\n")); return_UINT32(ACPI_TYPE_ANY); } @@ -275,7 +269,7 @@ u32 acpi_ns_local(acpi_object_type type) if (!acpi_ut_valid_object_type(type)) { /* Type code out of range */ - ACPI_REPORT_WARNING(("ns_local: Invalid Object Type\n")); + ACPI_REPORT_WARNING(("Invalid Object Type %X\n", type)); return_UINT32(ACPI_NS_NORMAL); } @@ -627,7 +621,7 @@ acpi_ns_externalize_name(u32 internal_name_length, * with internal_name (invalid format). */ if (required_length > internal_name_length) { - ACPI_REPORT_ERROR(("ns_externalize_name: Invalid internal name\n")); + ACPI_REPORT_ERROR(("Invalid internal name\n")); return_ACPI_STATUS(AE_BAD_PATHNAME); } @@ -803,8 +797,7 @@ u32 acpi_ns_opens_scope(acpi_object_type type) if (!acpi_ut_valid_object_type(type)) { /* type code out of range */ - ACPI_REPORT_WARNING(("ns_opens_scope: Invalid Object Type %X\n", - type)); + ACPI_REPORT_WARNING(("Invalid Object Type %X\n", type)); return_UINT32(ACPI_NS_NORMAL); } diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/namespace/nswalk.c index 5f164c0df33b..fcab1e784b81 100644 --- a/drivers/acpi/namespace/nswalk.c +++ b/drivers/acpi/namespace/nswalk.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c index 75b137a6a3c9..de13add43efc 100644 --- a/drivers/acpi/namespace/nsxfeval.c +++ b/drivers/acpi/namespace/nsxfeval.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -112,8 +112,7 @@ acpi_evaluate_object_typed(acpi_handle handle, if (return_buffer->length == 0) { /* Error because caller specifically asked for a return value */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No return value\n")); - + ACPI_REPORT_ERROR(("No return value\n")); return_ACPI_STATUS(AE_NULL_OBJECT); } @@ -125,11 +124,11 @@ acpi_evaluate_object_typed(acpi_handle handle, /* Return object type does not match requested type */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Incorrect return type [%s] requested [%s]\n", - acpi_ut_get_type_name(((union acpi_object *) - return_buffer->pointer)->type), - acpi_ut_get_type_name(return_type))); + ACPI_REPORT_ERROR(("Incorrect return type [%s] requested [%s]\n", + acpi_ut_get_type_name(((union acpi_object *) + return_buffer->pointer)-> + type), + acpi_ut_get_type_name(return_type))); if (must_free) { /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ @@ -236,11 +235,9 @@ acpi_evaluate_object(acpi_handle handle, * qualified names above, this is an error */ if (!pathname) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Both Handle and Pathname are NULL\n")); + ACPI_REPORT_ERROR(("Both Handle and Pathname are NULL\n")); } else { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Handle is NULL and Pathname is relative\n")); + ACPI_REPORT_ERROR(("Handle is NULL and Pathname is relative\n")); } status = AE_BAD_PARAMETER; diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c index 6b5f8d4481d1..853e6d170c96 100644 --- a/drivers/acpi/namespace/nsxfname.c +++ b/drivers/acpi/namespace/nsxfname.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/namespace/nsxfobj.c index 0856d42e6909..a0332595677a 100644 --- a/drivers/acpi/namespace/nsxfobj.c +++ b/drivers/acpi/namespace/nsxfobj.c @@ -6,7 +6,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c index e6d4cb9fd303..3c37cd0ecd80 100644 --- a/drivers/acpi/parser/psargs.c +++ b/drivers/acpi/parser/psargs.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -298,7 +298,7 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, acpi_ps_append_arg(arg, name_op); if (!method_desc) { - ACPI_REPORT_ERROR(("ps_get_next_namepath: Control Method %p has no attached object\n", node)); + ACPI_REPORT_ERROR(("Control Method %p has no attached object\n", node)); return_ACPI_STATUS(AE_AML_INTERNAL); } diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c index e81e51b8b3ae..c66029b890b1 100644 --- a/drivers/acpi/parser/psloop.c +++ b/drivers/acpi/parser/psloop.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -123,16 +123,10 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state) && ((status & AE_CODE_MASK) != AE_CODE_CONTROL)) { if (status == AE_AML_NO_RETURN_VALUE) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invoked method did not return a value, %s\n", - acpi_format_exception - (status))); + ACPI_REPORT_ERROR(("Invoked method did not return a value, %s\n", acpi_format_exception(status))); } - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "get_predicate Failed, %s\n", - acpi_format_exception - (status))); + ACPI_REPORT_ERROR(("get_predicate Failed, %s\n", acpi_format_exception(status))); return_ACPI_STATUS(status); } @@ -190,11 +184,7 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state) /* The opcode is unrecognized. Just skip unknown opcodes */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Found unknown opcode %X at AML address %p offset %X, ignoring\n", - walk_state->opcode, - parser_state->aml, - walk_state->aml_offset)); + ACPI_REPORT_ERROR(("Found unknown opcode %X at AML address %p offset %X, ignoring\n", walk_state->opcode, parser_state->aml, walk_state->aml_offset)); ACPI_DUMP_BUFFER(parser_state->aml, 128); @@ -281,10 +271,7 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state) walk_state->descending_callback(walk_state, &op); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "During name lookup/catalog, %s\n", - acpi_format_exception - (status))); + ACPI_REPORT_ERROR(("During name lookup/catalog, %s\n", acpi_format_exception(status))); goto close_this_op; } diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c index 229ae86afe8b..11d6351ab8b2 100644 --- a/drivers/acpi/parser/psopcode.c +++ b/drivers/acpi/parser/psopcode.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -747,7 +747,7 @@ const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode) /* Unknown AML opcode */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Unknown AML opcode [%4.4X]\n", opcode)); return (&acpi_gbl_aml_op_info[_UNK]); diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c index f0979b2956f2..3b540fe17a0c 100644 --- a/drivers/acpi/parser/psparse.c +++ b/drivers/acpi/parser/psparse.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -512,9 +512,9 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) } else if ((status != AE_OK) && (walk_state->method_desc)) { /* Either the method parse or actual execution failed */ - ACPI_REPORT_METHOD_ERROR - ("Method parse/execution failed", - walk_state->method_node, NULL, status); + ACPI_REPORT_MTERROR("Method parse/execution failed", + walk_state->method_node, NULL, + status); /* Check for possible multi-thread reentrancy problem */ diff --git a/drivers/acpi/parser/psscope.c b/drivers/acpi/parser/psscope.c index 1c953b6f1af1..bc6047caccd9 100644 --- a/drivers/acpi/parser/psscope.c +++ b/drivers/acpi/parser/psscope.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/parser/pstree.c b/drivers/acpi/parser/pstree.c index f0e755884eea..d387e2b01dbb 100644 --- a/drivers/acpi/parser/pstree.c +++ b/drivers/acpi/parser/pstree.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -132,7 +132,8 @@ acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg) if (op_info->class == AML_CLASS_UNKNOWN) { /* Invalid opcode */ - ACPI_REPORT_ERROR(("ps_append_arg: Invalid AML Opcode: 0x%2.2X\n", op->common.aml_opcode)); + ACPI_REPORT_ERROR(("Invalid AML Opcode: 0x%2.2X\n", + op->common.aml_opcode)); return; } diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c index 2075efbb4324..3e07cb9cb748 100644 --- a/drivers/acpi/parser/psutils.c +++ b/drivers/acpi/parser/psutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/parser/pswalk.c b/drivers/acpi/parser/pswalk.c index 08f2321b6ded..06f05bfd7612 100644 --- a/drivers/acpi/parser/pswalk.c +++ b/drivers/acpi/parser/pswalk.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c index 14d544d60867..2dd48cbb7c02 100644 --- a/drivers/acpi/parser/psxface.c +++ b/drivers/acpi/parser/psxface.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c index 4ac942badbc0..8fa3213ce000 100644 --- a/drivers/acpi/resources/rsaddr.c +++ b/drivers/acpi/resources/rsaddr.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c index c2c4d9079c6c..1dfa6906d455 100644 --- a/drivers/acpi/resources/rscalc.c +++ b/drivers/acpi/resources/rscalc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c index 6c7c6c560635..7f46ca0bf33a 100644 --- a/drivers/acpi/resources/rscreate.c +++ b/drivers/acpi/resources/rscreate.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -207,21 +207,14 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, /* Each element of the top-level package must also be a package */ if (ACPI_GET_OBJECT_TYPE(*top_object_list) != ACPI_TYPE_PACKAGE) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "(PRT[%X]) Need sub-package, found %s\n", - index, - acpi_ut_get_object_type_name - (*top_object_list))); + ACPI_REPORT_ERROR(("(PRT[%X]) Need sub-package, found %s\n", index, acpi_ut_get_object_type_name(*top_object_list))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } /* Each sub-package must be of length 4 */ if ((*top_object_list)->package.count != 4) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "(PRT[%X]) Need package of length 4, found length %d\n", - index, - (*top_object_list)->package.count)); + ACPI_REPORT_ERROR(("(PRT[%X]) Need package of length 4, found length %d\n", index, (*top_object_list)->package.count)); return_ACPI_STATUS(AE_AML_PACKAGE_LIMIT); } @@ -238,11 +231,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { user_prt->address = obj_desc->integer.value; } else { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "(PRT[%X].Address) Need Integer, found %s\n", - index, - acpi_ut_get_object_type_name - (obj_desc))); + ACPI_REPORT_ERROR(("(PRT[%X].Address) Need Integer, found %s\n", index, acpi_ut_get_object_type_name(obj_desc))); return_ACPI_STATUS(AE_BAD_DATA); } @@ -252,11 +241,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { user_prt->pin = (u32) obj_desc->integer.value; } else { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "(PRT[%X].Pin) Need Integer, found %s\n", - index, - acpi_ut_get_object_type_name - (obj_desc))); + ACPI_REPORT_ERROR(("(PRT[%X].Pin) Need Integer, found %s\n", index, acpi_ut_get_object_type_name(obj_desc))); return_ACPI_STATUS(AE_BAD_DATA); } @@ -267,10 +252,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, case ACPI_TYPE_LOCAL_REFERENCE: if (obj_desc->reference.opcode != AML_INT_NAMEPATH_OP) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "(PRT[%X].Source) Need name, found reference op %X\n", - index, - obj_desc->reference.opcode)); + ACPI_REPORT_ERROR(("(PRT[%X].Source) Need name, found reference op %X\n", index, obj_desc->reference.opcode)); return_ACPI_STATUS(AE_BAD_DATA); } @@ -316,11 +298,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "(PRT[%X].Source) Need Ref/String/Integer, found %s\n", - index, - acpi_ut_get_object_type_name - (obj_desc))); + ACPI_REPORT_ERROR(("(PRT[%X].Source) Need Ref/String/Integer, found %s\n", index, acpi_ut_get_object_type_name(obj_desc))); return_ACPI_STATUS(AE_BAD_DATA); } @@ -335,11 +313,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { user_prt->source_index = (u32) obj_desc->integer.value; } else { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "(PRT[%X].source_index) Need Integer, found %s\n", - index, - acpi_ut_get_object_type_name - (obj_desc))); + ACPI_REPORT_ERROR(("(PRT[%X].source_index) Need Integer, found %s\n", index, acpi_ut_get_object_type_name(obj_desc))); return_ACPI_STATUS(AE_BAD_DATA); } diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c index c24e3eb658c3..98356e2482c5 100644 --- a/drivers/acpi/resources/rsdump.c +++ b/drivers/acpi/resources/rsdump.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/resources/rsinfo.c index 623b06689336..d9ae64b77bd9 100644 --- a/drivers/acpi/resources/rsinfo.c +++ b/drivers/acpi/resources/rsinfo.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c index ef24ba110c6e..ea567167c4f2 100644 --- a/drivers/acpi/resources/rsio.c +++ b/drivers/acpi/resources/rsio.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c index 79e71257b69a..1fa63bc2e36f 100644 --- a/drivers/acpi/resources/rsirq.c +++ b/drivers/acpi/resources/rsirq.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c index 573c06705641..e4778a51c17e 100644 --- a/drivers/acpi/resources/rslist.c +++ b/drivers/acpi/resources/rslist.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -156,9 +156,7 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, /* Validate the (internal) Resource Type */ if (resource->type > ACPI_RESOURCE_TYPE_MAX) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid descriptor type (%X) in resource list\n", - resource->type)); + ACPI_REPORT_ERROR(("Invalid descriptor type (%X) in resource list\n", resource->type)); return_ACPI_STATUS(AE_BAD_DATA); } diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c index 418a3fb64077..a5131936d690 100644 --- a/drivers/acpi/resources/rsmemory.c +++ b/drivers/acpi/resources/rsmemory.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c index 4a758bd4a5c8..83bfe0dd3eba 100644 --- a/drivers/acpi/resources/rsmisc.c +++ b/drivers/acpi/resources/rsmisc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -523,9 +523,7 @@ if (((aml->irq.flags & 0x09) == 0x00) || ((aml->irq.flags & 0x09) == 0x09)) { * polarity/trigger interrupts are allowed (ACPI spec, section * "IRQ Format"), so 0x00 and 0x09 are illegal. */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid interrupt polarity/trigger in resource list, %X\n", - aml->irq.flags)); + ACPI_REPORT_ERROR(("Invalid interrupt polarity/trigger in resource list, %X\n", aml->irq.flags)); return_ACPI_STATUS(AE_BAD_DATA); } @@ -537,8 +535,7 @@ if (temp8 < 1) { } if (resource->data.dma.transfer == 0x03) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid DMA.Transfer preference (3)\n")); + ACPI_REPORT_ERROR(("Invalid DMA.Transfer preference (3)\n")); return_ACPI_STATUS(AE_BAD_DATA); } #endif diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c index 2236a0c90daa..25b5aedd6612 100644 --- a/drivers/acpi/resources/rsutils.c +++ b/drivers/acpi/resources/rsutils.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c index 50a956b705b0..88b67077aeeb 100644 --- a/drivers/acpi/resources/rsxface.c +++ b/drivers/acpi/resources/rsxface.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c index cd33397d9231..48290b7e6ba5 100644 --- a/drivers/acpi/tables/tbconvrt.c +++ b/drivers/acpi/tables/tbconvrt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c index 6acd5aeb093e..0fedf4b27ea5 100644 --- a/drivers/acpi/tables/tbget.c +++ b/drivers/acpi/tables/tbget.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -362,8 +362,8 @@ acpi_tb_get_this_table(struct acpi_pointer *address, default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid address flags %X\n", - address->pointer_type)); + ACPI_REPORT_ERROR(("Invalid address flags %X\n", + address->pointer_type)); return_ACPI_STATUS(AE_BAD_PARAMETER); } diff --git a/drivers/acpi/tables/tbgetall.c b/drivers/acpi/tables/tbgetall.c index 33c9ed8a6f99..496f336b3e3a 100644 --- a/drivers/acpi/tables/tbgetall.c +++ b/drivers/acpi/tables/tbgetall.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c index 10db8484e462..e1c9faa3982e 100644 --- a/drivers/acpi/tables/tbinstal.c +++ b/drivers/acpi/tables/tbinstal.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c index 3cee0cee4cc2..178309026850 100644 --- a/drivers/acpi/tables/tbrsdt.c +++ b/drivers/acpi/tables/tbrsdt.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -176,7 +176,7 @@ acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr) { int no_match; - ACPI_FUNCTION_NAME("tb_validate_rsdt"); + ACPI_FUNCTION_ENTRY(); /* * Search for appropriate signature, RSDT or XSDT @@ -192,15 +192,11 @@ acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr) if (no_match) { /* Invalid RSDT or XSDT signature */ - ACPI_REPORT_ERROR(("Invalid signature where RSDP indicates RSDT/XSDT should be located\n")); + ACPI_REPORT_ERROR(("Invalid signature where RSDP indicates RSDT/XSDT should be located. RSDP:\n")); ACPI_DUMP_BUFFER(acpi_gbl_RSDP, 20); - ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR, - "RSDT/XSDT signature at %X (%p) is invalid\n", - acpi_gbl_RSDP->rsdt_physical_address, - (void *)(acpi_native_uint) acpi_gbl_RSDP-> - rsdt_physical_address)); + ACPI_REPORT_ERROR(("RSDT/XSDT signature at %X (%p) is invalid\n", acpi_gbl_RSDP->rsdt_physical_address, (void *)(acpi_native_uint) acpi_gbl_RSDP->rsdt_physical_address)); if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { ACPI_REPORT_ERROR(("Looking for RSDT\n")) @@ -209,7 +205,6 @@ acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr) } ACPI_DUMP_BUFFER((char *)table_ptr, 48); - return (AE_BAD_SIGNATURE); } @@ -243,9 +238,8 @@ acpi_status acpi_tb_get_table_rsdt(void) table_info.type = ACPI_TABLE_XSDT; status = acpi_tb_get_table(&address, &table_info); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not get the RSDT/XSDT, %s\n", - acpi_format_exception(status))); + ACPI_REPORT_ERROR(("Could not get the RSDT/XSDT, %s\n", + acpi_format_exception(status))); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c index 9d0bf536d674..38c6749e43d5 100644 --- a/drivers/acpi/tables/tbutils.c +++ b/drivers/acpi/tables/tbutils.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -144,14 +144,13 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header) { acpi_name signature; - ACPI_FUNCTION_NAME("tb_validate_table_header"); + ACPI_FUNCTION_ENTRY(); /* Verify that this is a valid address */ if (!acpi_os_readable(table_header, sizeof(struct acpi_table_header))) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Cannot read table header at %p\n", - table_header)); + ACPI_REPORT_ERROR(("Cannot read table header at %p\n", + table_header)); return (AE_BAD_ADDRESS); } @@ -160,12 +159,10 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header) ACPI_MOVE_32_TO_32(&signature, table_header->signature); if (!acpi_ut_valid_acpi_name(signature)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Table signature at %p [%p] has invalid characters\n", - table_header, &signature)); + ACPI_REPORT_ERROR(("Table signature at %p [%p] has invalid characters\n", table_header, &signature)); ACPI_REPORT_WARNING(("Invalid table signature found: [%4.4s]\n", - (char *)&signature)); + ACPI_CAST_PTR(char, &signature))); ACPI_DUMP_BUFFER(table_header, sizeof(struct acpi_table_header)); @@ -175,9 +172,7 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header) /* Validate the table length */ if (table_header->length < sizeof(struct acpi_table_header)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid length in table header %p name %4.4s\n", - table_header, (char *)&signature)); + ACPI_REPORT_ERROR(("Invalid length in table header %p name %4.4s\n", table_header, (char *)&signature)); ACPI_REPORT_WARNING(("Invalid table header length (0x%X) found\n", (u32) table_header->length)); @@ -291,8 +286,7 @@ acpi_tb_handle_to_object(u16 table_id, } } - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "table_id=%X does not exist\n", - table_id)); + ACPI_REPORT_ERROR(("table_id=%X does not exist\n", table_id)); return (AE_BAD_PARAMETER); } #endif diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c index 3f96a4909aad..83a9ca8cb98c 100644 --- a/drivers/acpi/tables/tbxface.c +++ b/drivers/acpi/tables/tbxface.c @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -75,7 +75,7 @@ acpi_status acpi_load_tables(void) status = acpi_os_get_root_pointer(ACPI_LOGICAL_ADDRESSING, &rsdp_address); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("acpi_load_tables: Could not get RSDP, %s\n", + ACPI_REPORT_ERROR(("Could not get RSDP, %s\n", acpi_format_exception(status))); goto error_exit; } @@ -86,7 +86,8 @@ acpi_status acpi_load_tables(void) status = acpi_tb_verify_rsdp(&rsdp_address); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("acpi_load_tables: RSDP Failed validation: %s\n", acpi_format_exception(status))); + ACPI_REPORT_ERROR(("RSDP Failed validation: %s\n", + acpi_format_exception(status))); goto error_exit; } @@ -94,7 +95,8 @@ acpi_status acpi_load_tables(void) status = acpi_tb_get_table_rsdt(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("acpi_load_tables: Could not load RSDT: %s\n", acpi_format_exception(status))); + ACPI_REPORT_ERROR(("Could not load RSDT: %s\n", + acpi_format_exception(status))); goto error_exit; } @@ -102,7 +104,7 @@ acpi_status acpi_load_tables(void) status = acpi_tb_get_required_tables(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n", acpi_format_exception(status))); + ACPI_REPORT_ERROR(("Could not get all required tables (DSDT/FADT/FACS): %s\n", acpi_format_exception(status))); goto error_exit; } @@ -112,14 +114,15 @@ acpi_status acpi_load_tables(void) status = acpi_ns_load_namespace(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("acpi_load_tables: Could not load namespace: %s\n", acpi_format_exception(status))); + ACPI_REPORT_ERROR(("Could not load namespace: %s\n", + acpi_format_exception(status))); goto error_exit; } return_ACPI_STATUS(AE_OK); error_exit: - ACPI_REPORT_ERROR(("acpi_load_tables: Could not load tables: %s\n", + ACPI_REPORT_ERROR(("Could not load tables: %s\n", acpi_format_exception(status))); return_ACPI_STATUS(status); diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c index b01a4b2ae7da..6538ed818f5b 100644 --- a/drivers/acpi/tables/tbxfroot.c +++ b/drivers/acpi/tables/tbxfroot.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -396,9 +396,8 @@ acpi_status acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address) status = acpi_tb_find_rsdp(&table_info, flags); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "RSDP structure not found, %s Flags=%X\n", - acpi_format_exception(status), flags)); + ACPI_REPORT_ERROR(("RSDP structure not found, %s Flags=%X\n", + acpi_format_exception(status), flags)); return_ACPI_STATUS(AE_NO_ACPI_TABLES); } @@ -503,10 +502,7 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags) ACPI_EBDA_PTR_LENGTH, (void *)&table_ptr); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not map memory at %8.8X for length %X\n", - ACPI_EBDA_PTR_LOCATION, - ACPI_EBDA_PTR_LENGTH)); + ACPI_REPORT_ERROR(("Could not map memory at %8.8X for length %X\n", ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); return_ACPI_STATUS(status); } @@ -530,10 +526,7 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags) ACPI_EBDA_WINDOW_SIZE, (void *)&table_ptr); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not map memory at %8.8X for length %X\n", - physical_address, - ACPI_EBDA_WINDOW_SIZE)); + ACPI_REPORT_ERROR(("Could not map memory at %8.8X for length %X\n", physical_address, ACPI_EBDA_WINDOW_SIZE)); return_ACPI_STATUS(status); } @@ -563,10 +556,7 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags) (void *)&table_ptr); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Could not map memory at %8.8X for length %X\n", - ACPI_HI_RSDP_WINDOW_BASE, - ACPI_HI_RSDP_WINDOW_SIZE)); + ACPI_REPORT_ERROR(("Could not map memory at %8.8X for length %X\n", ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c index b11b7ed788c6..0efcbdf7e620 100644 --- a/drivers/acpi/utilities/utalloc.c +++ b/drivers/acpi/utilities/utalloc.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -301,7 +301,7 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line) /* Check for an inadvertent size of zero bytes */ if (!size) { - _ACPI_REPORT_ERROR(module, line, component, + _ACPI_REPORT_ERROR(module, line, ("ut_allocate: Attempt to allocate zero bytes, allocating 1 byte\n")); size = 1; } @@ -310,7 +310,7 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line) if (!allocation) { /* Report allocation error */ - _ACPI_REPORT_ERROR(module, line, component, + _ACPI_REPORT_ERROR(module, line, ("ut_allocate: Could not allocate size %X\n", (u32) size)); @@ -344,7 +344,7 @@ void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line) /* Check for an inadvertent size of zero bytes */ if (!size) { - _ACPI_REPORT_ERROR(module, line, component, + _ACPI_REPORT_ERROR(module, line, ("ut_callocate: Attempt to allocate zero bytes, allocating 1 byte\n")); size = 1; } @@ -353,7 +353,7 @@ void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line) if (!allocation) { /* Report allocation error */ - _ACPI_REPORT_ERROR(module, line, component, + _ACPI_REPORT_ERROR(module, line, ("ut_callocate: Could not allocate size %X\n", (u32) size)); return_PTR(NULL); @@ -480,7 +480,7 @@ void *acpi_ut_callocate_and_track(acpi_size size, if (!allocation) { /* Report allocation error */ - _ACPI_REPORT_ERROR(module, line, component, + _ACPI_REPORT_ERROR(module, line, ("ut_callocate: Could not allocate size %X\n", (u32) size)); return (NULL); @@ -524,7 +524,7 @@ acpi_ut_free_and_track(void *allocation, u32 component, char *module, u32 line) ACPI_FUNCTION_TRACE_PTR("ut_free", allocation); if (NULL == allocation) { - _ACPI_REPORT_ERROR(module, line, component, + _ACPI_REPORT_ERROR(module, line, ("acpi_ut_free: Attempt to delete a NULL address\n")); return_VOID; @@ -540,8 +540,8 @@ acpi_ut_free_and_track(void *allocation, u32 component, char *module, u32 line) status = acpi_ut_remove_allocation(debug_block, component, module, line); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Could not free memory, %s\n", - acpi_format_exception(status))); + ACPI_REPORT_ERROR(("Could not free memory, %s\n", + acpi_format_exception(status))); } acpi_os_free(debug_block); @@ -626,8 +626,8 @@ acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation, if (element) { ACPI_REPORT_ERROR(("ut_track_allocation: Allocation already present in list! (%p)\n", allocation)); - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Element %p Address %p\n", - element, allocation)); + ACPI_REPORT_ERROR(("Element %p Address %p\n", + element, allocation)); goto unlock_and_exit; } @@ -687,7 +687,7 @@ acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation, if (NULL == mem_list->list_head) { /* No allocations! */ - _ACPI_REPORT_ERROR(module, line, component, + _ACPI_REPORT_ERROR(module, line, ("ut_remove_allocation: Empty allocation list, nothing to free!\n")); return_ACPI_STATUS(AE_OK); @@ -863,12 +863,10 @@ void acpi_ut_dump_allocations(u32 component, char *module) /* Print summary */ if (!num_outstanding) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "No outstanding allocations\n")); + ACPI_REPORT_INFO(("No outstanding allocations\n")); } else { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "%d(%X) Outstanding allocations\n", - num_outstanding, num_outstanding)); + ACPI_REPORT_ERROR(("%d(%X) Outstanding allocations\n", + num_outstanding, num_outstanding)); } return_VOID; diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c index 93d48681d276..2177cb1ef2c4 100644 --- a/drivers/acpi/utilities/utcache.c +++ b/drivers/acpi/utilities/utcache.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c index 568df9e42f89..1a4da006822a 100644 --- a/drivers/acpi/utilities/utcopy.c +++ b/drivers/acpi/utilities/utcopy.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -606,8 +606,7 @@ acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object, /* * Packages as external input to control methods are not supported, */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Packages as parameters not implemented!\n")); + ACPI_REPORT_ERROR(("Packages as parameters not implemented!\n")); return_ACPI_STATUS(AE_NOT_IMPLEMENTED); } @@ -870,7 +869,7 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj, count + 1) * sizeof(void *)); if (!dest_obj->package.elements) { - ACPI_REPORT_ERROR(("aml_build_copy_internal_package_object: Package allocation failure\n")); + ACPI_REPORT_ERROR(("Package allocation failure\n")); return_ACPI_STATUS(AE_NO_MEMORY); } diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c index d80e92639932..35f3d581e034 100644 --- a/drivers/acpi/utilities/utdebug.c +++ b/drivers/acpi/utilities/utdebug.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c index 2bc878f7a127..1079a1a1f195 100644 --- a/drivers/acpi/utilities/utdelete.c +++ b/drivers/acpi/utilities/utdelete.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -363,8 +363,7 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action) default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown action (%X)\n", - action)); + ACPI_REPORT_ERROR(("Unknown action (%X)\n", action)); break; } @@ -374,9 +373,7 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action) */ if (count > ACPI_MAX_REFERENCE_COUNT) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "**** Warning **** Large Reference Count (%X) in object %p\n\n", - count, object)); + ACPI_REPORT_WARNING(("Large Reference Count (%X) in object %p\n\n", count, object)); } return; diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c index cd63a2d93fe3..f4dc374a0eec 100644 --- a/drivers/acpi/utilities/uteval.c +++ b/drivers/acpi/utilities/uteval.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -154,8 +154,8 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, acpi_ut_get_node_name(prefix_node), path)); } else { - ACPI_REPORT_METHOD_ERROR("Method execution failed", - prefix_node, path, status); + ACPI_REPORT_MTERROR("Method execution failed", + prefix_node, path, status); } return_ACPI_STATUS(status); @@ -165,9 +165,8 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, if (!info.return_object) { if (expected_return_btypes) { - ACPI_REPORT_METHOD_ERROR("No object was returned from", - prefix_node, path, - AE_NOT_EXIST); + ACPI_REPORT_MTERROR("No object was returned from", + prefix_node, path, AE_NOT_EXIST); return_ACPI_STATUS(AE_NOT_EXIST); } @@ -212,15 +211,10 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, /* Is the return object one of the expected types? */ if (!(expected_return_btypes & return_btype)) { - ACPI_REPORT_METHOD_ERROR("Return object type is incorrect", - prefix_node, path, AE_TYPE); - - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Type returned from %s was incorrect: %s, expected Btypes: %X\n", - path, - acpi_ut_get_object_type_name(info. - return_object), - expected_return_btypes)); + ACPI_REPORT_MTERROR("Return object type is incorrect", + prefix_node, path, AE_TYPE); + + ACPI_REPORT_ERROR(("Type returned from %s was incorrect: %s, expected Btypes: %X\n", path, acpi_ut_get_object_type_name(info.return_object), expected_return_btypes)); /* On error exit, we must delete the return object */ diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index 7c59c2b0d953..87ca9a0a8b76 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -67,8 +67,11 @@ const char *acpi_format_exception(acpi_status status) acpi_status sub_status; const char *exception = NULL; - ACPI_FUNCTION_NAME("format_exception"); + ACPI_FUNCTION_ENTRY(); + /* + * Status is composed of two parts, a "type" and an actual code + */ sub_status = (status & ~AE_CODE_MASK); switch (status & AE_CODE_MASK) { @@ -118,13 +121,13 @@ const char *acpi_format_exception(acpi_status status) if (!exception) { /* Exception code was not recognized */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unknown exception code: 0x%8.8X\n", status)); + ACPI_REPORT_ERROR(("Unknown exception code: 0x%8.8X\n", + status)); - return ((const char *)"UNKNOWN_STATUS_CODE"); + exception = "UNKNOWN_STATUS_CODE"; } - return ((const char *)exception); + return (ACPI_CAST_PTR(const char, exception)); } /******************************************************************************* @@ -519,7 +522,7 @@ char *acpi_ut_get_event_name(u32 event_id) return ("invalid_event_iD"); } - return ((char *)acpi_gbl_event_types[event_id]); + return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id])); } /******************************************************************************* @@ -586,10 +589,10 @@ char *acpi_ut_get_type_name(acpi_object_type type) { if (type > ACPI_TYPE_INVALID) { - return ((char *)acpi_gbl_bad_type); + return (ACPI_CAST_PTR(char, acpi_gbl_bad_type)); } - return ((char *)acpi_gbl_ns_type_names[type]); + return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type])); } char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc) diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c index 9dde82b0beaf..7565ba6f90d5 100644 --- a/drivers/acpi/utilities/utinit.c +++ b/drivers/acpi/utilities/utinit.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -221,15 +221,14 @@ void acpi_ut_subsystem_shutdown(void) /* Just exit if subsystem is already shutdown */ if (acpi_gbl_shutdown) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "ACPI Subsystem is already terminated\n")); + ACPI_REPORT_ERROR(("ACPI Subsystem is already terminated\n")); return_VOID; } /* Subsystem appears active, go ahead and shut it down */ acpi_gbl_shutdown = TRUE; - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem...\n")); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n")); /* Close the acpi_event Handling */ diff --git a/drivers/acpi/utilities/utmath.c b/drivers/acpi/utilities/utmath.c index 68a0a6f94129..06214201329d 100644 --- a/drivers/acpi/utilities/utmath.c +++ b/drivers/acpi/utilities/utmath.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -82,7 +82,7 @@ acpi_ut_short_divide(acpi_integer dividend, /* Always check for a zero divisor */ if (divisor == 0) { - ACPI_REPORT_ERROR(("acpi_ut_short_divide: Divide by zero\n")); + ACPI_REPORT_ERROR(("Divide by zero\n")); return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } @@ -144,7 +144,7 @@ acpi_ut_divide(acpi_integer in_dividend, /* Always check for a zero divisor */ if (in_divisor == 0) { - ACPI_REPORT_ERROR(("acpi_ut_divide: Divide by zero\n")); + ACPI_REPORT_ERROR(("Divide by zero\n")); return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } @@ -266,7 +266,7 @@ acpi_ut_short_divide(acpi_integer in_dividend, /* Always check for a zero divisor */ if (divisor == 0) { - ACPI_REPORT_ERROR(("acpi_ut_short_divide: Divide by zero\n")); + ACPI_REPORT_ERROR(("Divide by zero\n")); return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } @@ -292,7 +292,7 @@ acpi_ut_divide(acpi_integer in_dividend, /* Always check for a zero divisor */ if (in_divisor == 0) { - ACPI_REPORT_ERROR(("acpi_ut_divide: Divide by zero\n")); + ACPI_REPORT_ERROR(("Divide by zero\n")); return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index 48d511d5c04b..a77ffcd5570f 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -841,7 +841,6 @@ u8 acpi_ut_generate_checksum(u8 * buffer, u32 length) * * PARAMETERS: module_name - Caller's module name (for error output) * line_number - Caller's line number (for error output) - * component_id - Caller's component ID (for error output) * * RETURN: None * @@ -849,10 +848,10 @@ u8 acpi_ut_generate_checksum(u8 * buffer, u32 length) * ******************************************************************************/ -void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id) +void acpi_ut_report_error(char *module_name, u32 line_number) { - acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number); + acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number); } /******************************************************************************* @@ -861,7 +860,6 @@ void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id) * * PARAMETERS: module_name - Caller's module name (for error output) * line_number - Caller's line number (for error output) - * component_id - Caller's component ID (for error output) * * RETURN: None * @@ -869,11 +867,10 @@ void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id) * ******************************************************************************/ -void -acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id) +void acpi_ut_report_warning(char *module_name, u32 line_number) { - acpi_os_printf("%8s-%04d: *** Warning: ", module_name, line_number); + acpi_os_printf("ACPI Warning (%s-%04d): ", module_name, line_number); } /******************************************************************************* @@ -882,7 +879,6 @@ acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id) * * PARAMETERS: module_name - Caller's module name (for error output) * line_number - Caller's line number (for error output) - * component_id - Caller's component ID (for error output) * * RETURN: None * @@ -890,8 +886,8 @@ acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id) * ******************************************************************************/ -void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id) +void acpi_ut_report_info(char *module_name, u32 line_number) { - acpi_os_printf("%8s-%04d: *** Info: ", module_name, line_number); + acpi_os_printf("ACPI (%s-%04d): ", module_name, line_number); } diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c index e158b1b6313b..ffaff55270b1 100644 --- a/drivers/acpi/utilities/utmutex.c +++ b/drivers/acpi/utilities/utmutex.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -216,21 +216,12 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id) for (i = mutex_id; i < MAX_MUTEX; i++) { if (acpi_gbl_mutex_info[i].thread_id == this_thread_id) { if (i == mutex_id) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Mutex [%s] already acquired by this thread [%X]\n", - acpi_ut_get_mutex_name - (mutex_id), - this_thread_id)); + ACPI_REPORT_ERROR(("Mutex [%s] already acquired by this thread [%X]\n", acpi_ut_get_mutex_name(mutex_id), this_thread_id)); return (AE_ALREADY_ACQUIRED); } - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", - this_thread_id, - acpi_ut_get_mutex_name(i), - acpi_ut_get_mutex_name - (mutex_id))); + ACPI_REPORT_ERROR(("Invalid acquire order: Thread %X owns [%s], wants [%s]\n", this_thread_id, acpi_ut_get_mutex_name(i), acpi_ut_get_mutex_name(mutex_id))); return (AE_ACQUIRE_DEADLOCK); } @@ -253,11 +244,7 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id) acpi_gbl_mutex_info[mutex_id].use_count++; acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id; } else { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Thread %X could not acquire Mutex [%s] %s\n", - this_thread_id, - acpi_ut_get_mutex_name(mutex_id), - acpi_format_exception(status))); + ACPI_REPORT_ERROR(("Thread %X could not acquire Mutex [%X] %s\n", this_thread_id, mutex_id, acpi_format_exception(status))); } return (status); @@ -295,9 +282,7 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) * Mutex must be acquired in order to release it! */ if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Mutex [%s] is not acquired, cannot release\n", - acpi_ut_get_mutex_name(mutex_id))); + ACPI_REPORT_ERROR(("Mutex [%X] is not acquired, cannot release\n", mutex_id)); return (AE_NOT_ACQUIRED); } @@ -318,11 +303,7 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) continue; } - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Invalid release order: owns [%s], releasing [%s]\n", - acpi_ut_get_mutex_name(i), - acpi_ut_get_mutex_name - (mutex_id))); + ACPI_REPORT_ERROR(("Invalid release order: owns [%s], releasing [%s]\n", acpi_ut_get_mutex_name(i), acpi_ut_get_mutex_name(mutex_id))); return (AE_RELEASE_DEADLOCK); } @@ -338,11 +319,7 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Thread %X could not release Mutex [%s] %s\n", - this_thread_id, - acpi_ut_get_mutex_name(mutex_id), - acpi_format_exception(status))); + ACPI_REPORT_ERROR(("Thread %X could not release Mutex [%X] %s\n", this_thread_id, mutex_id, acpi_format_exception(status))); } else { ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c index 3015e1540053..1b6b21577805 100644 --- a/drivers/acpi/utilities/utobject.c +++ b/drivers/acpi/utilities/utobject.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -177,7 +177,8 @@ union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size) buffer = ACPI_MEM_CALLOCATE(buffer_size); if (!buffer) { - ACPI_REPORT_ERROR(("create_buffer: could not allocate size %X\n", (u32) buffer_size)); + ACPI_REPORT_ERROR(("Could not allocate size %X\n", + (u32) buffer_size)); acpi_ut_remove_reference(buffer_desc); return_PTR(NULL); } @@ -228,7 +229,8 @@ union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size) */ string = ACPI_MEM_CALLOCATE(string_size + 1); if (!string) { - ACPI_REPORT_ERROR(("create_string: could not allocate size %X\n", (u32) string_size)); + ACPI_REPORT_ERROR(("Could not allocate size %X\n", + (u32) string_size)); acpi_ut_remove_reference(string_desc); return_PTR(NULL); } @@ -310,7 +312,7 @@ void *acpi_ut_allocate_object_desc_dbg(char *module_name, object = acpi_os_acquire_object(acpi_gbl_operand_cache); if (!object) { - _ACPI_REPORT_ERROR(module_name, line_number, component_id, + _ACPI_REPORT_ERROR(module_name, line_number, ("Could not allocate an object descriptor\n")); return_PTR(NULL); @@ -345,9 +347,9 @@ void acpi_ut_delete_object_desc(union acpi_operand_object *object) /* Object must be an union acpi_operand_object */ if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) { - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "%p is not an ACPI Operand object [%s]\n", - object, acpi_ut_get_descriptor_name(object))); + ACPI_REPORT_ERROR(("%p is not an ACPI Operand object [%s]\n", + object, + acpi_ut_get_descriptor_name(object))); return_VOID; } @@ -449,10 +451,7 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, * Notably, Locals and Args are not supported, but this may be * required eventually. */ - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unsupported Reference opcode=%X in object %p\n", - internal_object->reference.opcode, - internal_object)); + ACPI_REPORT_ERROR(("Unsupported Reference opcode=%X in object %p\n", internal_object->reference.opcode, internal_object)); status = AE_TYPE; break; } @@ -460,10 +459,9 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, default: - ACPI_DEBUG_PRINT((ACPI_DB_ERROR, - "Unsupported type=%X in object %p\n", - ACPI_GET_OBJECT_TYPE(internal_object), - internal_object)); + ACPI_REPORT_ERROR(("Unsupported type=%X in object %p\n", + ACPI_GET_OBJECT_TYPE(internal_object), + internal_object)); status = AE_TYPE; break; } diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c index eaf0edec6efe..36bf9e4bf529 100644 --- a/drivers/acpi/utilities/utresrc.c +++ b/drivers/acpi/utilities/utresrc.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/utilities/utstate.c index 6ff1d7073349..4b134a722907 100644 --- a/drivers/acpi/utilities/utstate.c +++ b/drivers/acpi/utilities/utstate.c @@ -5,7 +5,7 @@ ******************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c index 57adc5bc02f3..b4bc94883200 100644 --- a/drivers/acpi/utilities/utxface.c +++ b/drivers/acpi/utilities/utxface.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -75,7 +75,7 @@ acpi_status acpi_initialize_subsystem(void) status = acpi_os_initialize(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("OSD failed to initialize, %s\n", + ACPI_REPORT_ERROR(("OSL failed to initialize, %s\n", acpi_format_exception(status))); return_ACPI_STATUS(status); } @@ -154,8 +154,7 @@ acpi_status acpi_enable_subsystem(u32 flags) status = acpi_enable(); if (ACPI_FAILURE(status)) { - ACPI_DEBUG_PRINT((ACPI_DB_WARN, - "acpi_enable failed.\n")); + ACPI_REPORT_WARNING(("acpi_enable failed\n")); return_ACPI_STATUS(status); } } diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index 1f2477eb95fe..675a32f78329 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,7 +63,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20051216 +#define ACPI_CA_VERSION 0x20060113 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, diff --git a/include/acpi/acdebug.h b/include/acpi/acdebug.h index 70ce3b4d006e..d8167095caf3 100644 --- a/include/acpi/acdebug.h +++ b/include/acpi/acdebug.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acdisasm.h b/include/acpi/acdisasm.h index 0a8f49f5d2f1..11a8fe39cb04 100644 --- a/include/acpi/acdisasm.h +++ b/include/acpi/acdisasm.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acdispat.h b/include/acpi/acdispat.h index cc6407eef701..c41a926ff317 100644 --- a/include/acpi/acdispat.h +++ b/include/acpi/acdispat.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acevents.h b/include/acpi/acevents.h index b40062c3ba7a..f2717be4fe0d 100644 --- a/include/acpi/acevents.h +++ b/include/acpi/acevents.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h index 4f005eb65928..dc768aa580e4 100644 --- a/include/acpi/acexcep.h +++ b/include/acpi/acexcep.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acglobal.h b/include/acpi/acglobal.h index dfb3b2493ae5..734cc77bf2c7 100644 --- a/include/acpi/acglobal.h +++ b/include/acpi/acglobal.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/achware.h b/include/acpi/achware.h index 3644d7248e7e..29b60a8c0593 100644 --- a/include/acpi/achware.h +++ b/include/acpi/achware.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acinterp.h b/include/acpi/acinterp.h index 87e5e44572ca..9f22cfcb624b 100644 --- a/include/acpi/acinterp.h +++ b/include/acpi/acinterp.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h index da7f1cb96f5d..97f8e4185e4f 100644 --- a/include/acpi/aclocal.h +++ b/include/acpi/aclocal.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h index 0fa8f72dbace..49ba151766de 100644 --- a/include/acpi/acmacros.h +++ b/include/acpi/acmacros.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -443,56 +443,66 @@ #define INCREMENT_ARG_LIST(list) (list >>= ((u32) ARG_TYPE_WIDTH)) /* - * Reporting macros that are never compiled out + * Module name is include in both debug and non-debug versions primarily for + * error messages. The __FILE__ macro is not very useful for this, because it + * often includes the entire pathname to the module */ -#define ACPI_PARAM_LIST(pl) pl +#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES) + +#define ACPI_MODULE_NAME(name) static char ACPI_UNUSED_VAR *_acpi_module_name = name; +#else +#define ACPI_MODULE_NAME(name) +#endif /* - * Error reporting. These versions add callers module and line#. - * - * Since _acpi_module_name gets compiled out when ACPI_DEBUG_OUTPUT - * isn't defined, only use it in debug mode. + * Ascii error messages can be configured out */ -#ifdef ACPI_DEBUG_OUTPUT +#ifndef ACPI_NO_ERROR_MESSAGES + +#define ACPI_PARAM_LIST(pl) pl +#define ACPI_LOCATION_INFO _acpi_module_name, __LINE__ -#define ACPI_REPORT_INFO(fp) {acpi_ut_report_info(_acpi_module_name,__LINE__,_COMPONENT); \ - acpi_os_printf ACPI_PARAM_LIST(fp);} -#define ACPI_REPORT_ERROR(fp) {acpi_ut_report_error(_acpi_module_name,__LINE__,_COMPONENT); \ - acpi_os_printf ACPI_PARAM_LIST(fp);} -#define ACPI_REPORT_WARNING(fp) {acpi_ut_report_warning(_acpi_module_name,__LINE__,_COMPONENT); \ - acpi_os_printf ACPI_PARAM_LIST(fp);} -#define ACPI_REPORT_NSERROR(s,e) acpi_ns_report_error(_acpi_module_name,__LINE__,_COMPONENT, s, e); +/* + * Error reporting. Callers module and line number are inserted automatically + * These macros are used for both the debug and non-debug versions of the code + */ +#define ACPI_REPORT_INFO(fp) {acpi_ut_report_info (ACPI_LOCATION_INFO); \ + acpi_os_printf ACPI_PARAM_LIST (fp);} +#define ACPI_REPORT_ERROR(fp) {acpi_ut_report_error (ACPI_LOCATION_INFO); \ + acpi_os_printf ACPI_PARAM_LIST (fp);} +#define ACPI_REPORT_WARNING(fp) {acpi_ut_report_warning (ACPI_LOCATION_INFO); \ + acpi_os_printf ACPI_PARAM_LIST (fp);} +#define ACPI_REPORT_NSERROR(s,e) acpi_ns_report_error (ACPI_LOCATION_INFO, \ + s, e); +#define ACPI_REPORT_MTERROR(s,n,p,e) acpi_ns_report_method_error (ACPI_LOCATION_INFO, \ + s, n, p, e); -#define ACPI_REPORT_METHOD_ERROR(s,n,p,e) acpi_ns_report_method_error(_acpi_module_name,__LINE__,_COMPONENT, s, n, p, e); +/* Error reporting. These versions pass thru the module and lineno */ +#define _ACPI_REPORT_INFO(a,b,fp) {acpi_ut_report_info (a,b); \ + acpi_os_printf ACPI_PARAM_LIST (fp);} +#define _ACPI_REPORT_ERROR(a,b,fp) {acpi_ut_report_error (a,b); \ + acpi_os_printf ACPI_PARAM_LIST (fp);} +#define _ACPI_REPORT_WARNING(a,b,fp) {acpi_ut_report_warning (a,b); \ + acpi_os_printf ACPI_PARAM_LIST (fp);} #else -#define ACPI_REPORT_INFO(fp) {acpi_ut_report_info("ACPI",__LINE__,_COMPONENT); \ - acpi_os_printf ACPI_PARAM_LIST(fp);} -#define ACPI_REPORT_ERROR(fp) {acpi_ut_report_error("ACPI",__LINE__,_COMPONENT); \ - acpi_os_printf ACPI_PARAM_LIST(fp);} -#define ACPI_REPORT_WARNING(fp) {acpi_ut_report_warning("ACPI",__LINE__,_COMPONENT); \ - acpi_os_printf ACPI_PARAM_LIST(fp);} -#define ACPI_REPORT_NSERROR(s,e) acpi_ns_report_error("ACPI",__LINE__,_COMPONENT, s, e); - -#define ACPI_REPORT_METHOD_ERROR(s,n,p,e) acpi_ns_report_method_error("ACPI",__LINE__,_COMPONENT, s, n, p, e); +/* No error messages */ +#define ACPI_REPORT_INFO(fp) +#define ACPI_REPORT_ERROR(fp) +#define ACPI_REPORT_WARNING(fp) +#define ACPI_REPORT_NSERROR(s,e) +#define ACPI_REPORT_MTERROR(s,n,p,e) +#define _ACPI_REPORT_INFO(a,b,c,fp) +#define _ACPI_REPORT_ERROR(a,b,c,fp) +#define _ACPI_REPORT_WARNING(a,b,c,fp) #endif -/* Error reporting. These versions pass thru the module and line# */ - -#define _ACPI_REPORT_INFO(a,b,c,fp) {acpi_ut_report_info(a,b,c); \ - acpi_os_printf ACPI_PARAM_LIST(fp);} -#define _ACPI_REPORT_ERROR(a,b,c,fp) {acpi_ut_report_error(a,b,c); \ - acpi_os_printf ACPI_PARAM_LIST(fp);} -#define _ACPI_REPORT_WARNING(a,b,c,fp) {acpi_ut_report_warning(a,b,c); \ - acpi_os_printf ACPI_PARAM_LIST(fp);} - /* * Debug macros that are conditionally compiled */ #ifdef ACPI_DEBUG_OUTPUT -#define ACPI_MODULE_NAME(name) static char ACPI_UNUSED_VAR *_acpi_module_name = name; /* * Common parameters used for debug output functions: @@ -649,9 +659,6 @@ * This is the non-debug case -- make everything go away, * leaving no executable debug code! */ -#define ACPI_MODULE_NAME(name) -#define _acpi_module_name "" - #define ACPI_DEBUG_EXEC(a) #define ACPI_NORMAL_EXEC(a) a; diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h index 4f9063f3e951..b67da3636899 100644 --- a/include/acpi/acnames.h +++ b/include/acpi/acnames.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acnamesp.h b/include/acpi/acnamesp.h index dd3501f7e5d6..b667a804fc8a 100644 --- a/include/acpi/acnamesp.h +++ b/include/acpi/acnamesp.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -263,13 +263,11 @@ u32 acpi_ns_local(acpi_object_type type); void acpi_ns_report_error(char *module_name, u32 line_number, - u32 component_id, char *internal_name, acpi_status lookup_status); void acpi_ns_report_method_error(char *module_name, u32 line_number, - u32 component_id, char *message, struct acpi_namespace_node *node, char *path, acpi_status lookup_status); diff --git a/include/acpi/acobject.h b/include/acpi/acobject.h index 4a326ba6d482..1bd411962c77 100644 --- a/include/acpi/acobject.h +++ b/include/acpi/acobject.h @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acopcode.h b/include/acpi/acopcode.h index 64da42992199..e6d78bd9e90a 100644 --- a/include/acpi/acopcode.h +++ b/include/acpi/acopcode.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h index 68d7edf0f697..7785d481dc3e 100644 --- a/include/acpi/acoutput.h +++ b/include/acpi/acoutput.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -137,13 +137,19 @@ /* Exception level -- used in the global "debug_level" */ -#define ACPI_DB_ERROR ACPI_DEBUG_LEVEL (ACPI_LV_ERROR) -#define ACPI_DB_WARN ACPI_DEBUG_LEVEL (ACPI_LV_WARN) #define ACPI_DB_INIT ACPI_DEBUG_LEVEL (ACPI_LV_INIT) #define ACPI_DB_DEBUG_OBJECT ACPI_DEBUG_LEVEL (ACPI_LV_DEBUG_OBJECT) #define ACPI_DB_INFO ACPI_DEBUG_LEVEL (ACPI_LV_INFO) #define ACPI_DB_ALL_EXCEPTIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS) +/* + * These two levels are essentially obsolete, all instances in the + * ACPICA core code have been replaced by REPORT_ERROR and REPORT_WARNING + * (Kept here because some drivers may still use them) + */ +#define ACPI_DB_ERROR ACPI_DEBUG_LEVEL (ACPI_LV_ERROR) +#define ACPI_DB_WARN ACPI_DEBUG_LEVEL (ACPI_LV_WARN) + /* Trace level -- also used in the global "debug_level" */ #define ACPI_DB_INIT_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_INIT_NAMES) diff --git a/include/acpi/acparser.h b/include/acpi/acparser.h index d352d40de1f3..5a1ff484af33 100644 --- a/include/acpi/acparser.h +++ b/include/acpi/acparser.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acpi.h b/include/acpi/acpi.h index ccf34f9dac64..b9a39d1009bd 100644 --- a/include/acpi/acpi.h +++ b/include/acpi/acpi.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h index 58473f60755f..768f63f391cd 100644 --- a/include/acpi/acpiosxf.h +++ b/include/acpi/acpiosxf.h @@ -8,7 +8,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index 2a88429bc4ec..66cf2ecef57a 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acresrc.h b/include/acpi/acresrc.h index ba281f7740a0..fa02e8083381 100644 --- a/include/acpi/acresrc.h +++ b/include/acpi/acresrc.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acstruct.h b/include/acpi/acstruct.h index 99d235339801..d8c1c2cdac0c 100644 --- a/include/acpi/acstruct.h +++ b/include/acpi/acstruct.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/actables.h b/include/acpi/actables.h index f92c1858b808..30a47542e1c8 100644 --- a/include/acpi/actables.h +++ b/include/acpi/actables.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h index ef2ddcadfe61..ed53f842dad4 100644 --- a/include/acpi/actbl.h +++ b/include/acpi/actbl.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h index 67312c3a915a..cd428d57add0 100644 --- a/include/acpi/actbl1.h +++ b/include/acpi/actbl1.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h index 50305ce2681a..dfc7ac1094bb 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 18e1338c5c7f..74819e9b4699 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h index 5fa21e03a62f..10f6625f6390 100644 --- a/include/acpi/acutils.h +++ b/include/acpi/acutils.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -275,12 +275,11 @@ acpi_ut_ptr_exit(u32 line_number, const char *function_name, char *module_name, u32 component_id, u8 * ptr); -void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id); +void acpi_ut_report_error(char *module_name, u32 line_number); -void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id); +void acpi_ut_report_info(char *module_name, u32 line_number); -void -acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id); +void acpi_ut_report_warning(char *module_name, u32 line_number); void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id); diff --git a/include/acpi/amlcode.h b/include/acpi/amlcode.h index 7fdf5299f501..37964a59aef8 100644 --- a/include/acpi/amlcode.h +++ b/include/acpi/amlcode.h @@ -7,7 +7,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/amlresrc.h b/include/acpi/amlresrc.h index 2e3382c1e5e3..fb4735315ad3 100644 --- a/include/acpi/amlresrc.h +++ b/include/acpi/amlresrc.h @@ -6,7 +6,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h index 53aa997f05fc..31b0f18342f6 100644 --- a/include/acpi/platform/acenv.h +++ b/include/acpi/platform/acenv.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/platform/acgcc.h b/include/acpi/platform/acgcc.h index 4c0e0ba09ba0..ea2a6322f64d 100644 --- a/include/acpi/platform/acgcc.h +++ b/include/acpi/platform/acgcc.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h index 1b9cbf05b79e..c21c27fe7e1e 100644 --- a/include/acpi/platform/aclinux.h +++ b/include/acpi/platform/aclinux.h @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without -- cgit v1.2.3 From 6fbfc9688448aac064edbaccb5d30ecd565a9105 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 20 Jan 2006 11:57:07 -0800 Subject: [NETFILTER]: Unbreak x-tables on x86. x86 defines __alignof__(long long) as 8 yet it gives 4 for a struct containing a long long, ho hum... so my simplified form doesn't work everywhere. So use Harald Welte's original patch, which should work on all platforms. Signed-off-by: David S. Miller --- include/linux/netfilter/x_tables.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index 59ff6c430cf6..6500d4e59d46 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h @@ -19,7 +19,21 @@ struct xt_get_revision /* For standard target */ #define XT_RETURN (-NF_REPEAT - 1) -#define XT_ALIGN(s) (((s) + (__alignof__(u_int64_t)-1)) & ~(__alignof__(u_int64_t)-1)) +/* this is a dummy structure to find out the alignment requirement for a struct + * containing all the fundamental data types that are used in ipt_entry, + * ip6t_entry and arpt_entry. This sucks, and it is a hack. It will be my + * personal pleasure to remove it -HW + */ +struct _xt_align +{ + u_int8_t u8; + u_int16_t u16; + u_int32_t u32; + u_int64_t u64; +}; + +#define XT_ALIGN(s) (((s) + (__alignof__(struct _xt_align)-1)) \ + & ~(__alignof__(struct _xt_align)-1)) /* Standard return verdict, or do jump. */ #define XT_STANDARD_TARGET "" -- cgit v1.2.3 From ca740803856f23dbc5b1872039291231bc131ecb Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 21 Jan 2006 20:06:14 +0000 Subject: [SERIAL] Remove UPF_AUTOPROBE and UPF_BOOT_ONLYMCA The functionality UPF_BOOT_ONLYMCA provided has been replaced by the 8250_mca module, which only registers MCA ports if MCA is present. UPF_AUTOPROBE has no functional effect - in fact, it's never tested. Only ibmasm set the flag. Signed-off-by: Russell King --- drivers/misc/ibmasm/uart.c | 2 +- drivers/serial/8250.c | 7 ------- include/linux/serial_core.h | 2 -- 3 files changed, 1 insertion(+), 10 deletions(-) (limited to 'include') diff --git a/drivers/misc/ibmasm/uart.c b/drivers/misc/ibmasm/uart.c index 7e98434cfa37..9783caf49696 100644 --- a/drivers/misc/ibmasm/uart.c +++ b/drivers/misc/ibmasm/uart.c @@ -50,7 +50,7 @@ void ibmasm_register_uart(struct service_processor *sp) memset(&uport, 0, sizeof(struct uart_port)); uport.irq = sp->irq; uport.uartclk = 3686400; - uport.flags = UPF_AUTOPROBE | UPF_SHARE_IRQ; + uport.flags = UPF_SHARE_IRQ; uport.iotype = UPIO_MEM; uport.membase = iomem_base; diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index ff2f931c6715..179c1f065e60 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -2026,12 +2025,6 @@ static void serial8250_config_port(struct uart_port *port, int flags) int probeflags = PROBE_ANY; int ret; - /* - * Don't probe for MCA ports on non-MCA machines. - */ - if (up->port.flags & UPF_BOOT_ONLYMCA && !MCA_bus) - return; - /* * Find the region that we can probe for. This in turn * tells us whether we can probe for the type of port. diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index ec351005bf9d..f3af47713a4e 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -245,9 +245,7 @@ struct uart_port { #define UPF_HARDPPS_CD (1 << 11) #define UPF_LOW_LATENCY (1 << 13) #define UPF_BUGGY_UART (1 << 14) -#define UPF_AUTOPROBE (1 << 15) #define UPF_MAGIC_MULTIPLIER (1 << 16) -#define UPF_BOOT_ONLYMCA (1 << 22) #define UPF_CONS_FLOW (1 << 23) #define UPF_SHARE_IRQ (1 << 24) #define UPF_BOOT_AUTOCONF (1 << 28) -- cgit v1.2.3 From ba899dbc036d24ab6b45faf64e3648a268721cc9 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 21 Jan 2006 22:45:50 +0000 Subject: [SERIAL] Make port->ops constant No one should write to the port->ops structure, so make it constant. Signed-off-by: Russell King --- drivers/serial/serial_core.c | 4 ++-- include/linux/serial_core.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index 943770470b9d..74142b731527 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c @@ -1870,7 +1870,7 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *port) mutex_lock(&state->mutex); if (state->info && state->info->flags & UIF_INITIALIZED) { - struct uart_ops *ops = port->ops; + const struct uart_ops *ops = port->ops; spin_lock_irq(&port->lock); ops->stop_tx(port); @@ -1932,7 +1932,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *port) } if (state->info && state->info->flags & UIF_INITIALIZED) { - struct uart_ops *ops = port->ops; + const struct uart_ops *ops = port->ops; int ret; ops->set_mctrl(port, 0); diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index f3af47713a4e..b74ff34469b9 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -257,7 +257,7 @@ struct uart_port { unsigned int mctrl; /* current modem ctrl settings */ unsigned int timeout; /* character-based timeout */ unsigned int type; /* port type */ - struct uart_ops *ops; + const struct uart_ops *ops; unsigned int custom_divisor; unsigned int line; /* port index */ unsigned long mapbase; /* for ioremap */ -- cgit v1.2.3 From 747c8a55946ed037bf7d62454c3c599c02af2262 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 21 Jan 2006 22:50:36 +0000 Subject: [SERIAL] Make uart_info flags a bitwise type The potential for confusing the flags is fairly high. Make uart_info's flags a bitwise type so sparse can check that the right flag definitions are used with the right structure. Signed-off-by: Russell King --- include/linux/serial_core.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index b74ff34469b9..90f681789a64 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -287,6 +287,9 @@ struct uart_state { }; #define UART_XMIT_SIZE PAGE_SIZE + +typedef unsigned int __bitwise__ uif_t; + /* * This is the state information which is only valid when the port * is open; it may be freed by the core driver once the device has @@ -296,17 +299,16 @@ struct uart_state { struct uart_info { struct tty_struct *tty; struct circ_buf xmit; - unsigned int flags; + uif_t flags; /* - * These are the flags that specific to info->flags, and reflect our - * internal state. They can not be accessed via port->flags. Low - * level drivers must not change these, but may query them instead. + * Definitions for info->flags. These are _private_ to serial_core, and + * are specific to this structure. They may be queried by low level drivers. */ -#define UIF_CHECK_CD (1 << 25) -#define UIF_CTS_FLOW (1 << 26) -#define UIF_NORMAL_ACTIVE (1 << 29) -#define UIF_INITIALIZED (1 << 31) +#define UIF_CHECK_CD ((__force uif_t) (1 << 25)) +#define UIF_CTS_FLOW ((__force uif_t) (1 << 26)) +#define UIF_NORMAL_ACTIVE ((__force uif_t) (1 << 29)) +#define UIF_INITIALIZED ((__force uif_t) (1 << 31)) int blocked_open; -- cgit v1.2.3 From 27ae7a7435634820e7f7e2b922d8119f79cfc6e4 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 21 Jan 2006 22:54:06 +0000 Subject: [SERIAL] Fix UPF_ flag usage with uart_info->flags The previous change found a bug in the serial SAK handling - because we were looking for UPF_SAK set in uart_info->flags, we would never raise a SAK condition. UPF_SAK is in uart_port->flags. Signed-off-by: Russell King --- include/linux/serial_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 90f681789a64..1a8cd0169c9a 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -430,7 +430,7 @@ static inline int uart_handle_break(struct uart_port *port) port->sysrq = 0; } #endif - if (info->flags & UPF_SAK) + if (port->flags & UPF_SAK) do_SAK(info->tty); return 0; } -- cgit v1.2.3 From 0077d45e46fe2af3aaee5813c99268afcd0e7c0e Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 21 Jan 2006 23:03:28 +0000 Subject: [SERIAL] Make uart_port flags a bitwise type Same reasoning as commit 747c8a55946ed037bf7d62454c3c599c02af2262 but this time we're making uart_port flags a bitwise type - not all of these flags correspond with the old ASYNC_ flags, so there is the possibility for bugs if the wrong ASYNC_* constants are used. Always use UPF_* constants for uart_port->flags. Signed-off-by: Russell King --- drivers/serial/serial_core.c | 12 ++++++----- include/linux/serial_8250.h | 2 +- include/linux/serial_core.h | 48 +++++++++++++++++++++++--------------------- 3 files changed, 33 insertions(+), 29 deletions(-) (limited to 'include') diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index 74142b731527..0717abfdae06 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c @@ -332,7 +332,7 @@ uart_get_baud_rate(struct uart_port *port, struct termios *termios, struct termios *old, unsigned int min, unsigned int max) { unsigned int try, baud, altbaud = 38400; - unsigned int flags = port->flags & UPF_SPD_MASK; + upf_t flags = port->flags & UPF_SPD_MASK; if (flags == UPF_SPD_HI) altbaud = 57600; @@ -615,8 +615,9 @@ static int uart_set_info(struct uart_state *state, struct serial_struct new_serial; struct uart_port *port = state->port; unsigned long new_port; - unsigned int change_irq, change_port, old_flags, closing_wait; + unsigned int change_irq, change_port, closing_wait; unsigned int old_custom_divisor, close_delay; + upf_t old_flags, new_flags; int retval = 0; if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) @@ -655,6 +656,7 @@ static int uart_set_info(struct uart_state *state, new_serial.type != port->type; old_flags = port->flags; + new_flags = new_serial.flags; old_custom_divisor = port->custom_divisor; if (!capable(CAP_SYS_ADMIN)) { @@ -664,10 +666,10 @@ static int uart_set_info(struct uart_state *state, (close_delay != state->close_delay) || (closing_wait != state->closing_wait) || (new_serial.xmit_fifo_size != port->fifosize) || - (((new_serial.flags ^ old_flags) & ~UPF_USR_MASK) != 0)) + (((new_flags ^ old_flags) & ~UPF_USR_MASK) != 0)) goto exit; port->flags = ((port->flags & ~UPF_USR_MASK) | - (new_serial.flags & UPF_USR_MASK)); + (new_flags & UPF_USR_MASK)); port->custom_divisor = new_serial.custom_divisor; goto check_and_exit; } @@ -764,7 +766,7 @@ static int uart_set_info(struct uart_state *state, port->irq = new_serial.irq; port->uartclk = new_serial.baud_base * 16; port->flags = (port->flags & ~UPF_CHANGE_MASK) | - (new_serial.flags & UPF_CHANGE_MASK); + (new_flags & UPF_CHANGE_MASK); port->custom_divisor = new_serial.custom_divisor; state->close_delay = close_delay; state->closing_wait = closing_wait; diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index cee302aefdb7..73b464f0926a 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h @@ -26,7 +26,7 @@ struct plat_serial8250_port { unsigned char regshift; /* register shift */ unsigned char iotype; /* UPIO_* */ unsigned char hub6; - unsigned int flags; /* UPF_* flags */ + upf_t flags; /* UPF_* flags */ }; /* diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 1a8cd0169c9a..4041122dabfc 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -203,6 +203,8 @@ struct uart_icount { __u32 buf_overrun; }; +typedef unsigned int __bitwise__ upf_t; + struct uart_port { spinlock_t lock; /* port lock */ unsigned int iobase; /* in/out[bwl] */ @@ -230,29 +232,29 @@ struct uart_port { unsigned long sysrq; /* sysrq timeout */ #endif - unsigned int flags; - -#define UPF_FOURPORT (1 << 1) -#define UPF_SAK (1 << 2) -#define UPF_SPD_MASK (0x1030) -#define UPF_SPD_HI (0x0010) -#define UPF_SPD_VHI (0x0020) -#define UPF_SPD_CUST (0x0030) -#define UPF_SPD_SHI (0x1000) -#define UPF_SPD_WARP (0x1010) -#define UPF_SKIP_TEST (1 << 6) -#define UPF_AUTO_IRQ (1 << 7) -#define UPF_HARDPPS_CD (1 << 11) -#define UPF_LOW_LATENCY (1 << 13) -#define UPF_BUGGY_UART (1 << 14) -#define UPF_MAGIC_MULTIPLIER (1 << 16) -#define UPF_CONS_FLOW (1 << 23) -#define UPF_SHARE_IRQ (1 << 24) -#define UPF_BOOT_AUTOCONF (1 << 28) -#define UPF_IOREMAP (1 << 31) - -#define UPF_CHANGE_MASK (0x17fff) -#define UPF_USR_MASK (UPF_SPD_MASK|UPF_LOW_LATENCY) + upf_t flags; + +#define UPF_FOURPORT ((__force upf_t) (1 << 1)) +#define UPF_SAK ((__force upf_t) (1 << 2)) +#define UPF_SPD_MASK ((__force upf_t) (0x1030)) +#define UPF_SPD_HI ((__force upf_t) (0x0010)) +#define UPF_SPD_VHI ((__force upf_t) (0x0020)) +#define UPF_SPD_CUST ((__force upf_t) (0x0030)) +#define UPF_SPD_SHI ((__force upf_t) (0x1000)) +#define UPF_SPD_WARP ((__force upf_t) (0x1010)) +#define UPF_SKIP_TEST ((__force upf_t) (1 << 6)) +#define UPF_AUTO_IRQ ((__force upf_t) (1 << 7)) +#define UPF_HARDPPS_CD ((__force upf_t) (1 << 11)) +#define UPF_LOW_LATENCY ((__force upf_t) (1 << 13)) +#define UPF_BUGGY_UART ((__force upf_t) (1 << 14)) +#define UPF_MAGIC_MULTIPLIER ((__force upf_t) (1 << 16)) +#define UPF_CONS_FLOW ((__force upf_t) (1 << 23)) +#define UPF_SHARE_IRQ ((__force upf_t) (1 << 24)) +#define UPF_BOOT_AUTOCONF ((__force upf_t) (1 << 28)) +#define UPF_IOREMAP ((__force upf_t) (1 << 31)) + +#define UPF_CHANGE_MASK ((__force upf_t) (0x17fff)) +#define UPF_USR_MASK ((__force upf_t) (UPF_SPD_MASK|UPF_LOW_LATENCY)) unsigned int mctrl; /* current modem ctrl settings */ unsigned int timeout; /* character-based timeout */ -- cgit v1.2.3 From cb6fc18e9ca615f03d18e60c49855b434ca2e51e Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Tue, 17 Jan 2006 12:40:40 -0700 Subject: [PARISC] Use kzalloc and other janitor-style cleanups Helge, o Convert a bunch of kmalloc/memset uses to kzalloc. o pci.c: Add some __read_mostly annotations. o pci.c: Move constant pci_post_reset_delay to asm/pci.h o grfioctl.h: Add A4450A to comment of CRT_ID_VISUALIZE_EG. o Add some consts to perf.c/perf_images.h Matthew, o sticore.c: Add some consts to suppress compile warnings. Signed-off-by: Helge Deller Signed-off-by: Matthew Wilcox Signed-off-by: Kyle McMartin --- arch/parisc/kernel/drivers.c | 3 +-- arch/parisc/kernel/pci.c | 11 +++++----- arch/parisc/kernel/perf.c | 35 ++++++++++++++++--------------- arch/parisc/kernel/perf_images.h | 4 ++-- arch/parisc/kernel/traps.c | 3 +-- drivers/parisc/ccio-dma.c | 7 +++---- drivers/parisc/dino.c | 4 +--- drivers/parisc/hppb.c | 3 +-- drivers/parisc/iosapic.c | 8 ++----- drivers/parisc/lasi.c | 2 +- drivers/parisc/lba_pci.c | 6 ++---- drivers/parisc/sba_iommu.c | 3 +-- drivers/parisc/wax.c | 2 +- drivers/parport/parport_gsc.c | 2 +- drivers/video/console/sticore.c | 45 +++++++++++++++++----------------------- include/asm-parisc/grfioctl.h | 2 +- include/asm-parisc/pci.h | 15 ++++++++++++-- 17 files changed, 73 insertions(+), 82 deletions(-) (limited to 'include') diff --git a/arch/parisc/kernel/drivers.c b/arch/parisc/kernel/drivers.c index 2d804e2d16d1..3d569a485a1a 100644 --- a/arch/parisc/kernel/drivers.c +++ b/arch/parisc/kernel/drivers.c @@ -408,11 +408,10 @@ static void setup_bus_id(struct parisc_device *padev) struct parisc_device * create_tree_node(char id, struct device *parent) { - struct parisc_device *dev = kmalloc(sizeof(*dev), GFP_KERNEL); + struct parisc_device *dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return NULL; - memset(dev, 0, sizeof(*dev)); dev->hw_path = id; dev->id.hw_type = HPHW_FAULTY; diff --git a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c index 88cba49c5301..3a7dda860336 100644 --- a/arch/parisc/kernel/pci.c +++ b/arch/parisc/kernel/pci.c @@ -47,18 +47,17 @@ * this makes the boot time much longer than necessary. * 20ms seems to work for all the HP PCI implementations to date. * - * XXX: turn into a #defined constant in ? + * #define pci_post_reset_delay 50 */ -int pci_post_reset_delay = 50; -struct pci_port_ops *pci_port; -struct pci_bios_ops *pci_bios; +struct pci_port_ops *pci_port __read_mostly; +struct pci_bios_ops *pci_bios __read_mostly; -int pci_hba_count = 0; +static int pci_hba_count __read_mostly; /* parisc_pci_hba used by pci_port->in/out() ops to lookup bus data. */ #define PCI_HBA_MAX 32 -struct pci_hba_data *parisc_pci_hba[PCI_HBA_MAX]; +struct pci_hba_data *parisc_pci_hba[PCI_HBA_MAX] __read_mostly; /******************************************************************** diff --git a/arch/parisc/kernel/perf.c b/arch/parisc/kernel/perf.c index 11d406cd0b3e..11178ccbb89a 100644 --- a/arch/parisc/kernel/perf.c +++ b/arch/parisc/kernel/perf.c @@ -68,20 +68,20 @@ struct rdr_tbl_ent { }; static int perf_processor_interface __read_mostly = UNKNOWN_INTF; -static int perf_enabled __read_mostly = 0; +static int perf_enabled __read_mostly; static spinlock_t perf_lock; -struct parisc_device *cpu_device __read_mostly = NULL; +struct parisc_device *cpu_device __read_mostly; /* RDRs to write for PCX-W */ -static int perf_rdrs_W[] = +static const int perf_rdrs_W[] = { 0, 1, 4, 5, 6, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, -1 }; /* RDRs to write for PCX-U */ -static int perf_rdrs_U[] = +static const int perf_rdrs_U[] = { 0, 1, 4, 5, 6, 7, 16, 17, 18, 20, 21, 22, 23, 24, 25, -1 }; /* RDR register descriptions for PCX-W */ -static struct rdr_tbl_ent perf_rdr_tbl_W[] = { +static const struct rdr_tbl_ent perf_rdr_tbl_W[] = { { 19, 1, 8 }, /* RDR 0 */ { 16, 1, 16 }, /* RDR 1 */ { 72, 2, 0 }, /* RDR 2 */ @@ -117,7 +117,7 @@ static struct rdr_tbl_ent perf_rdr_tbl_W[] = { }; /* RDR register descriptions for PCX-U */ -static struct rdr_tbl_ent perf_rdr_tbl_U[] = { +static const struct rdr_tbl_ent perf_rdr_tbl_U[] = { { 19, 1, 8 }, /* RDR 0 */ { 32, 1, 16 }, /* RDR 1 */ { 20, 1, 0 }, /* RDR 2 */ @@ -156,7 +156,7 @@ static struct rdr_tbl_ent perf_rdr_tbl_U[] = { * A non-zero write_control in the above tables is a byte offset into * this array. */ -static uint64_t perf_bitmasks[] = { +static const uint64_t perf_bitmasks[] = { 0x0000000000000000ul, /* first dbl word must be zero */ 0xfdffe00000000000ul, /* RDR0 bitmask */ 0x003f000000000000ul, /* RDR1 bitmask */ @@ -173,7 +173,7 @@ static uint64_t perf_bitmasks[] = { * Write control bitmasks for Pa-8700 processor given * somethings have changed slightly. */ -static uint64_t perf_bitmasks_piranha[] = { +static const uint64_t perf_bitmasks_piranha[] = { 0x0000000000000000ul, /* first dbl word must be zero */ 0xfdffe00000000000ul, /* RDR0 bitmask */ 0x003f000000000000ul, /* RDR1 bitmask */ @@ -186,7 +186,7 @@ static uint64_t perf_bitmasks_piranha[] = { 0xfffc000000000000ul }; -static uint64_t *bitmask_array; /* array of bitmasks to use */ +static const uint64_t *bitmask_array; /* array of bitmasks to use */ /****************************************************************************** * Function Prototypes @@ -200,7 +200,7 @@ static ssize_t perf_write(struct file *file, const char __user *buf, size_t coun static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg); static void perf_start_counters(void); static int perf_stop_counters(uint32_t *raddr); -static struct rdr_tbl_ent * perf_rdr_get_entry(uint32_t rdr_num); +static const struct rdr_tbl_ent * perf_rdr_get_entry(uint32_t rdr_num); static int perf_rdr_read_ubuf(uint32_t rdr_num, uint64_t *buffer); static int perf_rdr_clear(uint32_t rdr_num); static int perf_write_image(uint64_t *memaddr); @@ -655,7 +655,7 @@ static int perf_stop_counters(uint32_t *raddr) * Retrieve a pointer to the description of what this * RDR contains. */ -static struct rdr_tbl_ent * perf_rdr_get_entry(uint32_t rdr_num) +static const struct rdr_tbl_ent * perf_rdr_get_entry(uint32_t rdr_num) { if (perf_processor_interface == ONYX_INTF) { return &perf_rdr_tbl_U[rdr_num]; @@ -673,7 +673,7 @@ static int perf_rdr_read_ubuf(uint32_t rdr_num, uint64_t *buffer) { uint64_t data, data_mask = 0; uint32_t width, xbits, i; - struct rdr_tbl_ent *tentry; + const struct rdr_tbl_ent *tentry; tentry = perf_rdr_get_entry(rdr_num); if ((width = tentry->width) == 0) @@ -721,7 +721,7 @@ static int perf_rdr_read_ubuf(uint32_t rdr_num, uint64_t *buffer) */ static int perf_rdr_clear(uint32_t rdr_num) { - struct rdr_tbl_ent *tentry; + const struct rdr_tbl_ent *tentry; int32_t i; tentry = perf_rdr_get_entry(rdr_num); @@ -753,10 +753,11 @@ static int perf_write_image(uint64_t *memaddr) uint64_t buffer[MAX_RDR_WORDS]; uint64_t *bptr; uint32_t dwords; - uint32_t *intrigue_rdr; - uint64_t *intrigue_bitmask, tmp64; + const uint32_t *intrigue_rdr; + const uint64_t *intrigue_bitmask; + uint64_t tmp64; void __iomem *runway; - struct rdr_tbl_ent *tentry; + const struct rdr_tbl_ent *tentry; int i; /* Clear out counters */ @@ -830,7 +831,7 @@ static int perf_write_image(uint64_t *memaddr) */ static void perf_rdr_write(uint32_t rdr_num, uint64_t *buffer) { - struct rdr_tbl_ent *tentry; + const struct rdr_tbl_ent *tentry; int32_t i; printk("perf_rdr_write\n"); diff --git a/arch/parisc/kernel/perf_images.h b/arch/parisc/kernel/perf_images.h index d9562fe3f75c..7fef9644df47 100644 --- a/arch/parisc/kernel/perf_images.h +++ b/arch/parisc/kernel/perf_images.h @@ -25,7 +25,7 @@ #define PCXU_IMAGE_SIZE 584 -static uint32_t onyx_images[][PCXU_IMAGE_SIZE/sizeof(uint32_t)] = { +static uint32_t onyx_images[][PCXU_IMAGE_SIZE/sizeof(uint32_t)] __read_mostly = { /* * CPI: * @@ -2093,7 +2093,7 @@ static uint32_t onyx_images[][PCXU_IMAGE_SIZE/sizeof(uint32_t)] = { }; #define PCXW_IMAGE_SIZE 576 -static uint32_t cuda_images[][PCXW_IMAGE_SIZE/sizeof(uint32_t)] = { +static uint32_t cuda_images[][PCXW_IMAGE_SIZE/sizeof(uint32_t)] __read_mostly = { /* * CPI: FROM CPI.IDF (Image 0) * diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c index 15914f0235a0..ff200608c851 100644 --- a/arch/parisc/kernel/traps.c +++ b/arch/parisc/kernel/traps.c @@ -193,10 +193,9 @@ void show_stack(struct task_struct *task, unsigned long *s) HERE: asm volatile ("copy %%r30, %0" : "=r"(sp)); - r = (struct pt_regs *)kmalloc(sizeof(struct pt_regs), GFP_KERNEL); + r = kzalloc(sizeof(struct pt_regs), GFP_KERNEL); if (!r) return; - memset(r, 0, sizeof(struct pt_regs)); r->iaoq[0] = (unsigned long)&&HERE; r->gr[2] = (unsigned long)__builtin_return_address(0); r->gr[30] = sp; diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c index 9e0229f7e25f..f46e8438e0d2 100644 --- a/drivers/parisc/ccio-dma.c +++ b/drivers/parisc/ccio-dma.c @@ -1423,7 +1423,7 @@ static void __init ccio_init_resources(struct ioc *ioc) struct resource *res = ioc->mmio_region; char *name = kmalloc(14, GFP_KERNEL); - sprintf(name, "GSC Bus [%d/]", ioc->hw_path); + snprintf(name, 14, "GSC Bus [%d/]", ioc->hw_path); ccio_init_resource(res, name, &ioc->ioc_regs->io_io_low); ccio_init_resource(res + 1, name, &ioc->ioc_regs->io_io_low_hv); @@ -1557,12 +1557,11 @@ static int ccio_probe(struct parisc_device *dev) int i; struct ioc *ioc, **ioc_p = &ioc_list; - ioc = kmalloc(sizeof(struct ioc), GFP_KERNEL); + ioc = kzalloc(sizeof(struct ioc), GFP_KERNEL); if (ioc == NULL) { printk(KERN_ERR MODULE_NAME ": memory allocation failure\n"); return 1; } - memset(ioc, 0, sizeof(struct ioc)); ioc->name = dev->id.hversion == U2_IOA_RUNWAY ? "U2" : "UTurn"; @@ -1578,7 +1577,7 @@ static int ccio_probe(struct parisc_device *dev) ccio_ioc_init(ioc); ccio_init_resources(ioc); hppa_dma_ops = &ccio_ops; - dev->dev.platform_data = kmalloc(sizeof(struct pci_hba_data), GFP_KERNEL); + dev->dev.platform_data = kzalloc(sizeof(struct pci_hba_data), GFP_KERNEL); /* if this fails, no I/O cards will work, so may as well bug */ BUG_ON(dev->dev.platform_data == NULL); diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c index 216d1d859326..3d1a7f98c676 100644 --- a/drivers/parisc/dino.c +++ b/drivers/parisc/dino.c @@ -989,14 +989,12 @@ static int __init dino_probe(struct parisc_device *dev) */ } - dino_dev = kmalloc(sizeof(struct dino_device), GFP_KERNEL); + dino_dev = kzalloc(sizeof(struct dino_device), GFP_KERNEL); if (!dino_dev) { printk("dino_init_chip - couldn't alloc dino_device\n"); return 1; } - memset(dino_dev, 0, sizeof(struct dino_device)); - dino_dev->hba.dev = dev; dino_dev->hba.base_addr = ioremap(hpa, 4096); dino_dev->hba.lmmio_space_offset = 0; /* CPU addrs == bus addrs */ diff --git a/drivers/parisc/hppb.c b/drivers/parisc/hppb.c index 5edf93f80757..07dc2b6d4e93 100644 --- a/drivers/parisc/hppb.c +++ b/drivers/parisc/hppb.c @@ -60,12 +60,11 @@ static int hppb_probe(struct parisc_device *dev) } if(card->hpa) { - card->next = kmalloc(sizeof(struct hppb_card), GFP_KERNEL); + card->next = kzalloc(sizeof(struct hppb_card), GFP_KERNEL); if(!card->next) { printk(KERN_ERR "HP-PB: Unable to allocate memory.\n"); return 1; } - memset(card->next, '\0', sizeof(struct hppb_card)); card = card->next; } printk(KERN_INFO "Found GeckoBoa at 0x%lx\n", dev->hpa.start); diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c index 19657efa8dc3..8d7a36392eb8 100644 --- a/drivers/parisc/iosapic.c +++ b/drivers/parisc/iosapic.c @@ -873,28 +873,24 @@ void *iosapic_register(unsigned long hpa) return NULL; } - isi = (struct iosapic_info *)kmalloc(sizeof(struct iosapic_info), GFP_KERNEL); + isi = (struct iosapic_info *)kzalloc(sizeof(struct iosapic_info), GFP_KERNEL); if (!isi) { BUG(); return NULL; } - memset(isi, 0, sizeof(struct iosapic_info)); - isi->addr = ioremap(hpa, 4096); isi->isi_hpa = hpa; isi->isi_version = iosapic_rd_version(isi); isi->isi_num_vectors = IOSAPIC_IRDT_MAX_ENTRY(isi->isi_version) + 1; vip = isi->isi_vector = (struct vector_info *) - kmalloc(sizeof(struct vector_info) * isi->isi_num_vectors, GFP_KERNEL); + kzalloc(sizeof(struct vector_info) * isi->isi_num_vectors, GFP_KERNEL); if (vip == NULL) { kfree(isi); return NULL; } - memset(vip, 0, sizeof(struct vector_info) * isi->isi_num_vectors); - for (cnt=0; cnt < isi->isi_num_vectors; cnt++, vip++) { vip->irqline = (unsigned char) cnt; vip->iosapic = isi; diff --git a/drivers/parisc/lasi.c b/drivers/parisc/lasi.c index 2b3ba1dcf332..d043a8a33511 100644 --- a/drivers/parisc/lasi.c +++ b/drivers/parisc/lasi.c @@ -170,7 +170,7 @@ lasi_init_chip(struct parisc_device *dev) struct gsc_irq gsc_irq; int ret; - lasi = kmalloc(sizeof(*lasi), GFP_KERNEL); + lasi = kzalloc(sizeof(*lasi), GFP_KERNEL); if (!lasi) return -ENOMEM; diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c index cbae8c8963fa..e8a2a4a852f5 100644 --- a/drivers/parisc/lba_pci.c +++ b/drivers/parisc/lba_pci.c @@ -1565,7 +1565,7 @@ lba_driver_probe(struct parisc_device *dev) } else if (IS_MERCURY(dev) || IS_QUICKSILVER(dev)) { func_class &= 0xff; version = kmalloc(6, GFP_KERNEL); - sprintf(version,"TR%d.%d",(func_class >> 4),(func_class & 0xf)); + snprintf(version, 6, "TR%d.%d",(func_class >> 4),(func_class & 0xf)); /* We could use one printk for both Elroy and Mercury, * but for the mask for func_class. */ @@ -1586,14 +1586,12 @@ lba_driver_probe(struct parisc_device *dev) ** have an IRT entry will get NULL back from iosapic code. */ - lba_dev = kmalloc(sizeof(struct lba_device), GFP_KERNEL); + lba_dev = kzalloc(sizeof(struct lba_device), GFP_KERNEL); if (!lba_dev) { printk(KERN_ERR "lba_init_chip - couldn't alloc lba_device\n"); return(1); } - memset(lba_dev, 0, sizeof(struct lba_device)); - /* ---------- First : initialize data we already have --------- */ diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c index c85653f315aa..52f265e97729 100644 --- a/drivers/parisc/sba_iommu.c +++ b/drivers/parisc/sba_iommu.c @@ -2064,14 +2064,13 @@ sba_driver_callback(struct parisc_device *dev) printk(KERN_INFO "%s found %s at 0x%lx\n", MODULE_NAME, version, dev->hpa.start); - sba_dev = kmalloc(sizeof(struct sba_device), GFP_KERNEL); + sba_dev = kzalloc(sizeof(struct sba_device), GFP_KERNEL); if (!sba_dev) { printk(KERN_ERR MODULE_NAME " - couldn't alloc sba_device\n"); return -ENOMEM; } parisc_set_drvdata(dev, sba_dev); - memset(sba_dev, 0, sizeof(struct sba_device)); for(i=0; iioc[i].res_lock)); diff --git a/drivers/parisc/wax.c b/drivers/parisc/wax.c index 17dce2adf7fe..813c2c24ab1e 100644 --- a/drivers/parisc/wax.c +++ b/drivers/parisc/wax.c @@ -76,7 +76,7 @@ wax_init_chip(struct parisc_device *dev) struct gsc_irq gsc_irq; int ret; - wax = kmalloc(sizeof(*wax), GFP_KERNEL); + wax = kzalloc(sizeof(*wax), GFP_KERNEL); if (!wax) return -ENOMEM; diff --git a/drivers/parport/parport_gsc.c b/drivers/parport/parport_gsc.c index fde29a75f888..1de52d9febf9 100644 --- a/drivers/parport/parport_gsc.c +++ b/drivers/parport/parport_gsc.c @@ -249,7 +249,7 @@ struct parport *__devinit parport_gsc_probe_port (unsigned long base, struct parport tmp; struct parport *p = &tmp; - priv = kmalloc (sizeof (struct parport_gsc_private), GFP_KERNEL); + priv = kzalloc (sizeof (struct parport_gsc_private), GFP_KERNEL); if (!priv) { printk (KERN_DEBUG "parport (0x%lx): no memory!\n", base); return NULL; diff --git a/drivers/video/console/sticore.c b/drivers/video/console/sticore.c index a7bcd17112c0..0339f5640a78 100644 --- a/drivers/video/console/sticore.c +++ b/drivers/video/console/sticore.c @@ -30,10 +30,11 @@ #define STI_DRIVERVERSION "Version 0.9a" -struct sti_struct *default_sti; +struct sti_struct *default_sti __read_mostly; -static int num_sti_roms; /* # of STI ROMS found */ -static struct sti_struct *sti_roms[MAX_STI_ROMS]; /* ptr to each sti_struct */ +/* number of STI ROMS found and their ptrs to each struct */ +static int num_sti_roms __read_mostly; +static struct sti_struct *sti_roms[MAX_STI_ROMS] __read_mostly; /* The colour indices used by STI are @@ -266,7 +267,7 @@ sti_rom_copy(unsigned long base, unsigned long count, void *dest) -static char default_sti_path[21]; +static char default_sti_path[21] __read_mostly; #ifndef MODULE static int __init sti_setup(char *str) @@ -414,10 +415,10 @@ sti_init_glob_cfg(struct sti_struct *sti, if (!sti->sti_mem_request) sti->sti_mem_request = 256; /* STI default */ - glob_cfg = kmalloc(sizeof(*sti->glob_cfg), GFP_KERNEL); - glob_cfg_ext = kmalloc(sizeof(*glob_cfg_ext), GFP_KERNEL); - save_addr = kmalloc(save_addr_size, GFP_KERNEL); - sti_mem_addr = kmalloc(sti->sti_mem_request, GFP_KERNEL); + glob_cfg = kzalloc(sizeof(*sti->glob_cfg), GFP_KERNEL); + glob_cfg_ext = kzalloc(sizeof(*glob_cfg_ext), GFP_KERNEL); + save_addr = kzalloc(save_addr_size, GFP_KERNEL); + sti_mem_addr = kzalloc(sti->sti_mem_request, GFP_KERNEL); if (!(glob_cfg && glob_cfg_ext && save_addr && sti_mem_addr)) { kfree(glob_cfg); @@ -427,11 +428,6 @@ sti_init_glob_cfg(struct sti_struct *sti, return -ENOMEM; } - memset(glob_cfg, 0, sizeof(*glob_cfg)); - memset(glob_cfg_ext, 0, sizeof(*glob_cfg_ext)); - memset(save_addr, 0, save_addr_size); - memset(sti_mem_addr, 0, sti->sti_mem_request); - glob_cfg->ext_ptr = STI_PTR(glob_cfg_ext); glob_cfg->save_addr = STI_PTR(save_addr); for (i=0; i<8; i++) { @@ -502,9 +498,9 @@ sti_init_glob_cfg(struct sti_struct *sti, #ifdef CONFIG_FB struct sti_cooked_font * __init -sti_select_fbfont( struct sti_cooked_rom *cooked_rom, char *fbfont_name ) +sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name) { - struct font_desc *fbfont; + const struct font_desc *fbfont; unsigned int size, bpc; void *dest; struct sti_rom_font *nf; @@ -525,10 +521,9 @@ sti_select_fbfont( struct sti_cooked_rom *cooked_rom, char *fbfont_name ) size = bpc * 256; size += sizeof(struct sti_rom_font); - nf = kmalloc(size, GFP_KERNEL); + nf = kzalloc(size, GFP_KERNEL); if (!nf) return NULL; - memset(nf, 0, size); nf->first_char = 0; nf->last_char = 255; @@ -544,7 +539,7 @@ sti_select_fbfont( struct sti_cooked_rom *cooked_rom, char *fbfont_name ) dest += sizeof(struct sti_rom_font); memcpy(dest, fbfont->data, bpc*256); - cooked_font = kmalloc(sizeof(*cooked_font), GFP_KERNEL); + cooked_font = kzalloc(sizeof(*cooked_font), GFP_KERNEL); if (!cooked_font) { kfree(nf); return NULL; @@ -559,7 +554,7 @@ sti_select_fbfont( struct sti_cooked_rom *cooked_rom, char *fbfont_name ) } #else struct sti_cooked_font * __init -sti_select_fbfont(struct sti_cooked_rom *cooked_rom, char *fbfont_name) +sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name) { return NULL; } @@ -617,7 +612,7 @@ sti_cook_fonts(struct sti_cooked_rom *cooked_rom, struct sti_rom_font *raw_font, *font_start; struct sti_cooked_font *cooked_font; - cooked_font = kmalloc(sizeof(*cooked_font), GFP_KERNEL); + cooked_font = kzalloc(sizeof(*cooked_font), GFP_KERNEL); if (!cooked_font) return 0; @@ -631,7 +626,7 @@ sti_cook_fonts(struct sti_cooked_rom *cooked_rom, while (raw_font->next_font) { raw_font = ((void *)font_start) + (raw_font->next_font); - cooked_font->next_font = kmalloc(sizeof(*cooked_font), GFP_KERNEL); + cooked_font->next_font = kzalloc(sizeof(*cooked_font), GFP_KERNEL); if (!cooked_font->next_font) return 1; @@ -668,10 +663,9 @@ sti_bmode_font_raw(struct sti_cooked_font *f) unsigned char *n, *p, *q; int size = f->raw->bytes_per_char*256+sizeof(struct sti_rom_font); - n = kmalloc (4*size, GFP_KERNEL); + n = kzalloc (4*size, GFP_KERNEL); if (!n) return NULL; - memset (n, 0, 4*size); p = n + 3; q = (unsigned char *)f->raw; while (size--) { @@ -816,13 +810,12 @@ sti_try_rom_generic(unsigned long address, unsigned long hpa, struct pci_dev *pd return NULL; } - sti = kmalloc(sizeof(*sti), GFP_KERNEL); + sti = kzalloc(sizeof(*sti), GFP_KERNEL); if (!sti) { printk(KERN_ERR "Not enough memory !\n"); return NULL; } - memset(sti, 0, sizeof(*sti)); spin_lock_init(&sti->lock); test_rom: @@ -1035,7 +1028,7 @@ static struct parisc_driver pa_sti_driver = { * sti_init_roms() - detects all STI ROMs and stores them in sti_roms[] */ -static int sticore_initialized; +static int sticore_initialized __read_mostly; static void __init sti_init_roms(void) { diff --git a/include/asm-parisc/grfioctl.h b/include/asm-parisc/grfioctl.h index 6a910311b56b..671e06042b40 100644 --- a/include/asm-parisc/grfioctl.h +++ b/include/asm-parisc/grfioctl.h @@ -58,7 +58,7 @@ #define CRT_ID_ELK_1024DB 0x27849CA5 /* Elk 1024x768 double buffer */ #define CRT_ID_ELK_GS S9000_ID_A1924A /* Elk 1280x1024 GreyScale */ #define CRT_ID_CRX24 S9000_ID_A1439A /* Piranha */ -#define CRT_ID_VISUALIZE_EG 0x2D08C0A7 /* Graffiti (built-in B132+/B160L) */ +#define CRT_ID_VISUALIZE_EG 0x2D08C0A7 /* Graffiti, A4450A (built-in B132+/B160L) */ #define CRT_ID_THUNDER 0x2F23E5FC /* Thunder 1 VISUALIZE 48*/ #define CRT_ID_THUNDER2 0x2F8D570E /* Thunder 2 VISUALIZE 48 XP*/ #define CRT_ID_HCRX S9000_ID_HCRX /* Hyperdrive HCRX */ diff --git a/include/asm-parisc/pci.h b/include/asm-parisc/pci.h index f277254159b7..4c5e15ea3a02 100644 --- a/include/asm-parisc/pci.h +++ b/include/asm-parisc/pci.h @@ -18,6 +18,18 @@ */ #define PCI_MAX_BUSSES 256 + +/* To be used as: mdelay(pci_post_reset_delay); + * + * post_reset is the time the kernel should stall to prevent anyone from + * accessing the PCI bus once #RESET is de-asserted. + * PCI spec somewhere says 1 second but with multi-PCI bus systems, + * this makes the boot time much longer than necessary. + * 20ms seems to work for all the HP PCI implementations to date. + */ +#define pci_post_reset_delay 50 + + /* ** pci_hba_data (aka H2P_OBJECT in HP/UX) ** @@ -83,7 +95,7 @@ static __inline__ int pci_is_lmmio(struct pci_hba_data *hba, unsigned long a) /* ** Convert between PCI (IO_VIEW) addresses and processor (PA_VIEW) addresses. -** See pcibios.c for more conversions used by Generic PCI code. +** See pci.c for more conversions used by Generic PCI code. ** ** Platform characteristics/firmware guarantee that ** (1) PA_VIEW - IO_VIEW = lmmio_offset for both LMMIO and ELMMIO @@ -191,7 +203,6 @@ struct pci_bios_ops { */ extern struct pci_port_ops *pci_port; extern struct pci_bios_ops *pci_bios; -extern int pci_post_reset_delay; /* delay after de-asserting #RESET */ extern int pci_hba_count; extern struct pci_hba_data *parisc_pci_hba[]; -- cgit v1.2.3 From 2c9aadabf454fb07b8f7533096e22bf005dd08df Mon Sep 17 00:00:00 2001 From: Grant Grundler Date: Thu, 19 Jan 2006 23:38:03 -0700 Subject: [PARISC] Remove unnecessary extern declarations from asm/pci.h Remove two unnecessary extern declarations from asm/pci.h. They collide with what gcc4.0 assumed was static (and should be static). Found by Joel Soete. Signed-off-by: Grant Grundler Signed-off-by: Kyle McMartin --- arch/parisc/kernel/pci.c | 2 +- include/asm-parisc/pci.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'include') diff --git a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c index 3a7dda860336..d66d7cb1c0d9 100644 --- a/arch/parisc/kernel/pci.c +++ b/arch/parisc/kernel/pci.c @@ -57,7 +57,7 @@ static int pci_hba_count __read_mostly; /* parisc_pci_hba used by pci_port->in/out() ops to lookup bus data. */ #define PCI_HBA_MAX 32 -struct pci_hba_data *parisc_pci_hba[PCI_HBA_MAX] __read_mostly; +static struct pci_hba_data *parisc_pci_hba[PCI_HBA_MAX] __read_mostly; /******************************************************************** diff --git a/include/asm-parisc/pci.h b/include/asm-parisc/pci.h index 4c5e15ea3a02..fe7f6a2f5aa7 100644 --- a/include/asm-parisc/pci.h +++ b/include/asm-parisc/pci.h @@ -203,8 +203,6 @@ struct pci_bios_ops { */ extern struct pci_port_ops *pci_port; extern struct pci_bios_ops *pci_bios; -extern int pci_hba_count; -extern struct pci_hba_data *parisc_pci_hba[]; #ifdef CONFIG_PCI extern void pcibios_register_hba(struct pci_hba_data *); -- cgit v1.2.3 From c475eea2929a7f0dac21d20e10562a491fcf7c45 Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Sun, 15 Jan 2006 12:11:50 -0700 Subject: [PARISC] Drop unused do_check_pgt_cache() Drop the unused do_check_pgt_cache routine from mm/init.c and its prototype in asm/pgalloc.h Signed-off-by: Helge Deller Signed-off-by: Kyle McMartin --- arch/parisc/mm/init.c | 5 ----- include/asm-parisc/pgalloc.h | 1 - 2 files changed, 6 deletions(-) (limited to 'include') diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c index e54268004f53..9999eb045238 100644 --- a/arch/parisc/mm/init.c +++ b/arch/parisc/mm/init.c @@ -477,11 +477,6 @@ void __init mem_init(void) } -int do_check_pgt_cache(int low, int high) -{ - return 0; -} - unsigned long *empty_zero_page __read_mostly; void show_mem(void) diff --git a/include/asm-parisc/pgalloc.h b/include/asm-parisc/pgalloc.h index 6291d6692e5d..3122fad38a1b 100644 --- a/include/asm-parisc/pgalloc.h +++ b/include/asm-parisc/pgalloc.h @@ -137,7 +137,6 @@ static inline void pte_free_kernel(pte_t *pte) #define pte_free(page) pte_free_kernel(page_address(page)) -extern int do_check_pgt_cache(int, int); #define check_pgt_cache() do { } while (0) #endif -- cgit v1.2.3 From 2e13b31e5b0ff0b1f1e3359ebf8ca46c356e9391 Mon Sep 17 00:00:00 2001 From: Kyle McMartin Date: Tue, 17 Jan 2006 08:33:01 -0700 Subject: [PARISC] atomic64 support Implement atomic64_t so atomic_long_t works on parisc. Also clean up some of the coding style in atomic.h, and make sure ATOMIC_INIT is cast properly. Signed-off-by: Kyle McMartin --- include/asm-parisc/atomic.h | 84 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/asm-parisc/atomic.h b/include/asm-parisc/atomic.h index 2ca56d34aaad..4dc7253ff5d0 100644 --- a/include/asm-parisc/atomic.h +++ b/include/asm-parisc/atomic.h @@ -1,9 +1,13 @@ +/* Copyright (C) 2000 Philipp Rumpf + * Copyright (C) 2006 Kyle McMartin + */ + #ifndef _ASM_PARISC_ATOMIC_H_ #define _ASM_PARISC_ATOMIC_H_ #include +#include #include -/* Copyright (C) 2000 Philipp Rumpf . */ /* * Atomic operations that C can't guarantee us. Useful for @@ -46,15 +50,6 @@ extern raw_spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned; # define _atomic_spin_unlock_irqrestore(l,f) do { local_irq_restore(f); } while (0) #endif -/* Note that we need not lock read accesses - aligned word writes/reads - * are atomic, so a reader never sees unconsistent values. - * - * Cache-line alignment would conflict with, for example, linux/module.h - */ - -typedef struct { volatile int counter; } atomic_t; - - /* This should get optimized out since it's never called. ** Or get a link error if xchg is used "wrong". */ @@ -69,10 +64,9 @@ extern unsigned long __xchg64(unsigned long, unsigned long *); #endif /* optimizer better get rid of switch since size is a constant */ -static __inline__ unsigned long __xchg(unsigned long x, __volatile__ void * ptr, - int size) +static __inline__ unsigned long +__xchg(unsigned long x, __volatile__ void * ptr, int size) { - switch(size) { #ifdef __LP64__ case 8: return __xchg64(x,(unsigned long *) ptr); @@ -129,7 +123,13 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size) (unsigned long)_n_, sizeof(*(ptr))); \ }) +/* Note that we need not lock read accesses - aligned word writes/reads + * are atomic, so a reader never sees unconsistent values. + * + * Cache-line alignment would conflict with, for example, linux/module.h + */ +typedef struct { volatile int counter; } atomic_t; /* It's possible to reduce all atomic operations to either * __atomic_add_return, atomic_set and atomic_read (the latter @@ -210,12 +210,66 @@ static __inline__ int atomic_read(const atomic_t *v) #define atomic_dec_and_test(v) (atomic_dec_return(v) == 0) -#define ATOMIC_INIT(i) { (i) } +#define ATOMIC_INIT(i) ((atomic_t) { (i) }) #define smp_mb__before_atomic_dec() smp_mb() #define smp_mb__after_atomic_dec() smp_mb() #define smp_mb__before_atomic_inc() smp_mb() #define smp_mb__after_atomic_inc() smp_mb() +#ifdef __LP64__ + +typedef struct { volatile s64 counter; } atomic64_t; + +#define ATOMIC64_INIT(i) ((atomic64_t) { (i) }) + +static __inline__ int +__atomic64_add_return(s64 i, atomic64_t *v) +{ + int ret; + unsigned long flags; + _atomic_spin_lock_irqsave(v, flags); + + ret = (v->counter += i); + + _atomic_spin_unlock_irqrestore(v, flags); + return ret; +} + +static __inline__ void +atomic64_set(atomic64_t *v, s64 i) +{ + unsigned long flags; + _atomic_spin_lock_irqsave(v, flags); + + v->counter = i; + + _atomic_spin_unlock_irqrestore(v, flags); +} + +static __inline__ s64 +atomic64_read(const atomic64_t *v) +{ + return v->counter; +} + +#define atomic64_add(i,v) ((void)(__atomic64_add_return( ((s64)i),(v)))) +#define atomic64_sub(i,v) ((void)(__atomic64_add_return(-((s64)i),(v)))) +#define atomic64_inc(v) ((void)(__atomic64_add_return( 1,(v)))) +#define atomic64_dec(v) ((void)(__atomic64_add_return( -1,(v)))) + +#define atomic64_add_return(i,v) (__atomic64_add_return( ((s64)i),(v))) +#define atomic64_sub_return(i,v) (__atomic64_add_return(-((s64)i),(v))) +#define atomic64_inc_return(v) (__atomic64_add_return( 1,(v))) +#define atomic64_dec_return(v) (__atomic64_add_return( -1,(v))) + +#define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0) + +#define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0) +#define atomic64_dec_and_test(v) (atomic64_dec_return(v) == 0) + +#endif /* __LP64__ */ + #include -#endif + +#endif /* _ASM_PARISC_ATOMIC_H_ */ -- cgit v1.2.3 From 1bcdd8548286743e1d6b3d53c96a90c6da975620 Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Fri, 13 Jan 2006 13:21:06 -0700 Subject: [PARISC] Add CONFIG_DEBUG_RODATA to protect read-only data Add the parisc version of the "mark rodata section read only" patches. Based on code from and Signed-off-by Arjan van de Ven , Ingo Molnar , Andi Kleen , Andrew Morton , Linus Torvalds . Signed-off-by: Helge Deller Signed-off-by: Kyle McMartin --- arch/parisc/Kconfig.debug | 10 ++++++++++ arch/parisc/hpux/entry_hpux.S | 3 +-- arch/parisc/kernel/syscall.S | 2 ++ arch/parisc/mm/init.c | 15 ++++++++++++++- include/asm-parisc/cacheflush.h | 6 ++++++ include/asm-parisc/pgtable.h | 2 +- 6 files changed, 34 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/arch/parisc/Kconfig.debug b/arch/parisc/Kconfig.debug index 8caaed187a1f..9166bd117267 100644 --- a/arch/parisc/Kconfig.debug +++ b/arch/parisc/Kconfig.debug @@ -11,4 +11,14 @@ config DEBUG_RWLOCK too many attempts. If you suspect a rwlock problem or a kernel hacker asks for this option then say Y. Otherwise say N. +config DEBUG_RODATA + bool "Write protect kernel read-only data structures" + depends on DEBUG_KERNEL + help + Mark the kernel read-only data as write-protected in the pagetables, + in order to catch accidental (and incorrect) writes to such const + data. This option may have a slight performance impact because a + portion of the kernel code won't be covered by a TLB anymore. + If in doubt, say "N". + endmenu diff --git a/arch/parisc/hpux/entry_hpux.S b/arch/parisc/hpux/entry_hpux.S index fa9bf38787e7..31c8cccfba31 100644 --- a/arch/parisc/hpux/entry_hpux.S +++ b/arch/parisc/hpux/entry_hpux.S @@ -22,10 +22,9 @@ #include #include - .text - #define ENTRY_NAME(_name_) .word _name_ + .section .rodata,"a" .align 4 .export hpux_call_table .import hpux_unimplemented_wrapper diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S index d66163492890..af88afef41bd 100644 --- a/arch/parisc/kernel/syscall.S +++ b/arch/parisc/kernel/syscall.S @@ -650,6 +650,8 @@ end_linux_gateway_page: #define LWS_ENTRY(_name_) .word (lws_##_name_ - linux_gateway_page) #endif + .section .rodata,"a" + .align 4096 /* Light-weight-syscall table */ /* Start of lws table. */ diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c index 9999eb045238..6f36d0b17d9e 100644 --- a/arch/parisc/mm/init.c +++ b/arch/parisc/mm/init.c @@ -417,6 +417,19 @@ void free_initmem(void) #endif } + +#ifdef CONFIG_DEBUG_RODATA +void mark_rodata_ro(void) +{ + extern char __start_rodata, __end_rodata; + /* rodata memory was already mapped with KERNEL_RO access rights by + pagetable_init() and map_pages(). No need to do additional stuff here */ + printk (KERN_INFO "Write protecting the kernel read-only data: %luk\n", + (unsigned long)(&__end_rodata - &__start_rodata) >> 10); +} +#endif + + /* * Just an arbitrary offset to serve as a "hole" between mapping areas * (between top of physical memory and a potential pcxl dma mapping @@ -685,7 +698,7 @@ static void __init pagetable_init(void) #ifdef CONFIG_BLK_DEV_INITRD if (initrd_end && initrd_end > mem_limit) { - printk("initrd: mapping %08lx-%08lx\n", initrd_start, initrd_end); + printk(KERN_INFO "initrd: mapping %08lx-%08lx\n", initrd_start, initrd_end); map_pages(initrd_start, __pa(initrd_start), initrd_end - initrd_start, PAGE_KERNEL); } diff --git a/include/asm-parisc/cacheflush.h b/include/asm-parisc/cacheflush.h index 1bc3c83ee74b..c53af9ff41b5 100644 --- a/include/asm-parisc/cacheflush.h +++ b/include/asm-parisc/cacheflush.h @@ -183,4 +183,10 @@ flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long __flush_cache_page(vma, vmaddr); } + +#ifdef CONFIG_DEBUG_RODATA +void mark_rodata_ro(void); #endif + +#endif /* _PARISC_CACHEFLUSH_H */ + diff --git a/include/asm-parisc/pgtable.h b/include/asm-parisc/pgtable.h index b4554711c3e7..4e34c6b44059 100644 --- a/include/asm-parisc/pgtable.h +++ b/include/asm-parisc/pgtable.h @@ -213,7 +213,7 @@ extern void *vmalloc_start; #define PAGE_COPY PAGE_EXECREAD #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED) #define PAGE_KERNEL __pgprot(_PAGE_KERNEL) -#define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_EXEC | _PAGE_READ | _PAGE_DIRTY | _PAGE_ACCESSED) +#define PAGE_KERNEL_RO __pgprot(_PAGE_KERNEL & ~_PAGE_WRITE) #define PAGE_KERNEL_UNC __pgprot(_PAGE_KERNEL | _PAGE_NO_CACHE) #define PAGE_GATEWAY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_GATEWAY| _PAGE_READ) #define PAGE_FLUSH __pgprot(_PAGE_FLUSH) -- cgit v1.2.3 From f671c45df23005692daa200aba768c642fb14ef2 Mon Sep 17 00:00:00 2001 From: Kyle McMartin Date: Sun, 15 Jan 2006 14:10:29 -0500 Subject: [PARISC] Arch-specific compat signals Add enough arch-specific compat signals code to enable parisc64 to compile and boot out of the mainline tree. There are likely still many dragons here, but this is a start to squashing the last big difference between the mainline tree and the parisc-linux tree. The remaining bugs can be squashed as they come up. Signed-off-by: Kyle McMartin --- arch/parisc/kernel/ptrace.c | 8 +-- arch/parisc/kernel/signal.c | 2 +- arch/parisc/kernel/signal32.c | 102 +++++++++++++++++++++++++++- arch/parisc/kernel/signal32.h | 127 ++++++++++++++++++++++++++++++++++- include/asm-parisc/compat_ucontext.h | 3 +- include/asm-parisc/rt_sigframe.h | 4 -- 6 files changed, 232 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/arch/parisc/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c index 27160e8bf15b..413292f1a4a3 100644 --- a/arch/parisc/kernel/ptrace.c +++ b/arch/parisc/kernel/ptrace.c @@ -91,7 +91,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) int copied; #ifdef __LP64__ - if (is_compat_task(child)) { + if (personality(child->personality) == PER_LINUX32) { unsigned int tmp; addr &= 0xffffffffL; @@ -123,7 +123,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) case PTRACE_POKEDATA: ret = 0; #ifdef __LP64__ - if (is_compat_task(child)) { + if (personality(child->personality) == PER_LINUX32) { unsigned int tmp = (unsigned int)data; DBG("sys_ptrace(POKE%s, %d, %lx, %lx)\n", request == PTRACE_POKETEXT ? "TEXT" : "DATA", @@ -146,7 +146,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) case PTRACE_PEEKUSR: { ret = -EIO; #ifdef __LP64__ - if (is_compat_task(child)) { + if (personality(child->personality) == PER_LINUX32) { unsigned int tmp; if (addr & (sizeof(int)-1)) @@ -205,7 +205,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) goto out_tsk; } #ifdef __LP64__ - if (is_compat_task(child)) { + if (personality(child->personality) == PER_LINUX32) { if (addr & (sizeof(int)-1)) goto out_tsk; if ((addr = translate_usr_offset(addr)) < 0) diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c index 3a25a7bd673e..05767e83cf2d 100644 --- a/arch/parisc/kernel/signal.c +++ b/arch/parisc/kernel/signal.c @@ -317,7 +317,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, if(personality(current->personality) == PER_LINUX32) { DBG(1,"setup_rt_frame: frame->info = 0x%p\n", &compat_frame->info); - err |= compat_copy_siginfo_to_user(&compat_frame->info, info); + err |= copy_siginfo_to_user32(&compat_frame->info, info); DBG(1,"SETUP_RT_FRAME: 1\n"); compat_val = (compat_int_t)current->sas_ss_sp; err |= __put_user(compat_val, &compat_frame->uc.uc_stack.ss_sp); diff --git a/arch/parisc/kernel/signal32.c b/arch/parisc/kernel/signal32.c index 0792e20efef3..a6b4231cafa1 100644 --- a/arch/parisc/kernel/signal32.c +++ b/arch/parisc/kernel/signal32.c @@ -31,7 +31,6 @@ #include #include -#include #include #include "signal32.h" @@ -398,3 +397,104 @@ setup_sigcontext32(struct compat_sigcontext __user *sc, struct compat_regfile __ return err; } + +int +copy_siginfo_from_user32 (siginfo_t *to, compat_siginfo_t __user *from) +{ + unsigned long tmp; + int err; + + if (!access_ok(VERIFY_READ, from, sizeof(compat_siginfo_t))) + return -EFAULT; + + err = __get_user(to->si_signo, &from->si_signo); + err |= __get_user(to->si_errno, &from->si_errno); + err |= __get_user(to->si_code, &from->si_code); + + if (to->si_code < 0) + err |= __copy_from_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE); + else { + switch (to->si_code >> 16) { + case __SI_CHLD >> 16: + err |= __get_user(to->si_utime, &from->si_utime); + err |= __get_user(to->si_stime, &from->si_stime); + err |= __get_user(to->si_status, &from->si_status); + default: + err |= __get_user(to->si_pid, &from->si_pid); + err |= __get_user(to->si_uid, &from->si_uid); + break; + case __SI_FAULT >> 16: + err |= __get_user(tmp, &from->si_addr); + to->si_addr = (void __user *) tmp; + break; + case __SI_POLL >> 16: + err |= __get_user(to->si_band, &from->si_band); + err |= __get_user(to->si_fd, &from->si_fd); + break; + case __SI_RT >> 16: /* This is not generated by the kernel as of now. */ + case __SI_MESGQ >> 16: + err |= __get_user(to->si_pid, &from->si_pid); + err |= __get_user(to->si_uid, &from->si_uid); + err |= __get_user(to->si_int, &from->si_int); + break; + } + } + return err; +} + +int +copy_siginfo_to_user32 (compat_siginfo_t __user *to, siginfo_t *from) +{ + unsigned int addr; + int err; + + if (!access_ok(VERIFY_WRITE, to, sizeof(compat_siginfo_t))) + return -EFAULT; + + /* If you change siginfo_t structure, please be sure + this code is fixed accordingly. + It should never copy any pad contained in the structure + to avoid security leaks, but must copy the generic + 3 ints plus the relevant union member. + This routine must convert siginfo from 64bit to 32bit as well + at the same time. */ + err = __put_user(from->si_signo, &to->si_signo); + err |= __put_user(from->si_errno, &to->si_errno); + err |= __put_user((short)from->si_code, &to->si_code); + if (from->si_code < 0) + err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE); + else { + switch (from->si_code >> 16) { + case __SI_CHLD >> 16: + err |= __put_user(from->si_utime, &to->si_utime); + err |= __put_user(from->si_stime, &to->si_stime); + err |= __put_user(from->si_status, &to->si_status); + default: + err |= __put_user(from->si_pid, &to->si_pid); + err |= __put_user(from->si_uid, &to->si_uid); + break; + case __SI_FAULT >> 16: + /* avoid type-checking warnings by copying _pad[0] in lieu of si_addr... */ + err |= __put_user(from->_sifields._pad[0], &to->si_addr); + break; + case __SI_POLL >> 16: + err |= __put_user(from->si_band, &to->si_band); + err |= __put_user(from->si_fd, &to->si_fd); + break; + case __SI_TIMER >> 16: + err |= __put_user(from->si_tid, &to->si_tid); + err |= __put_user(from->si_overrun, &to->si_overrun); + addr = (unsigned long) from->si_ptr; + err |= __put_user(addr, &to->si_ptr); + break; + case __SI_RT >> 16: /* Not generated by the kernel as of now. */ + case __SI_MESGQ >> 16: + err |= __put_user(from->si_uid, &to->si_uid); + err |= __put_user(from->si_pid, &to->si_pid); + addr = (unsigned long) from->si_ptr; + err |= __put_user(addr, &to->si_ptr); + break; + } + } + return err; +} diff --git a/arch/parisc/kernel/signal32.h b/arch/parisc/kernel/signal32.h index 4d1569e717cc..e39b38a67a87 100644 --- a/arch/parisc/kernel/signal32.h +++ b/arch/parisc/kernel/signal32.h @@ -20,8 +20,34 @@ #define _PARISC64_KERNEL_SIGNAL32_H #include -#include -#include + +typedef compat_uptr_t compat_sighandler_t; + +typedef struct compat_sigaltstack { + compat_uptr_t ss_sp; + compat_int_t ss_flags; + compat_size_t ss_size; +} compat_stack_t; + +/* Most things should be clean enough to redefine this at will, if care + is taken to make libc match. */ + +struct compat_sigaction { + compat_sighandler_t sa_handler; + compat_uint_t sa_flags; + compat_sigset_t sa_mask; /* mask last for extensibility */ +}; + +/* 32-bit ucontext as seen from an 64-bit kernel */ +struct compat_ucontext { + compat_uint_t uc_flags; + compat_uptr_t uc_link; + compat_stack_t uc_stack; /* struct compat_sigaltstack (12 bytes)*/ + /* FIXME: Pad out to get uc_mcontext to start at an 8-byte aligned boundary */ + compat_uint_t pad[1]; + struct compat_sigcontext uc_mcontext; + compat_sigset_t uc_sigmask; /* mask last for extensibility */ +}; /* ELF32 signal handling */ @@ -29,6 +55,103 @@ struct k_sigaction32 { struct compat_sigaction sa; }; +typedef struct compat_siginfo { + int si_signo; + int si_errno; + int si_code; + + union { + int _pad[((128/sizeof(int)) - 3)]; + + /* kill() */ + struct { + unsigned int _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + } _kill; + + /* POSIX.1b timers */ + struct { + compat_timer_t _tid; /* timer id */ + int _overrun; /* overrun count */ + char _pad[sizeof(unsigned int) - sizeof(int)]; + compat_sigval_t _sigval; /* same as below */ + int _sys_private; /* not to be passed to user */ + } _timer; + + /* POSIX.1b signals */ + struct { + unsigned int _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + compat_sigval_t _sigval; + } _rt; + + /* SIGCHLD */ + struct { + unsigned int _pid; /* which child */ + unsigned int _uid; /* sender's uid */ + int _status; /* exit code */ + compat_clock_t _utime; + compat_clock_t _stime; + } _sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ + struct { + unsigned int _addr; /* faulting insn/memory ref. */ + } _sigfault; + + /* SIGPOLL */ + struct { + int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ + int _fd; + } _sigpoll; + } _sifields; +} compat_siginfo_t; + +int copy_siginfo_to_user32 (compat_siginfo_t __user *to, siginfo_t *from); +int copy_siginfo_from_user32 (siginfo_t *to, compat_siginfo_t __user *from); + +/* In a deft move of uber-hackery, we decide to carry the top half of all + * 64-bit registers in a non-portable, non-ABI, hidden structure. + * Userspace can read the hidden structure if it *wants* but is never + * guaranteed to be in the same place. Infact the uc_sigmask from the + * ucontext_t structure may push the hidden register file downards + */ +struct compat_regfile { + /* Upper half of all the 64-bit registers that were truncated + on a copy to a 32-bit userspace */ + compat_int_t rf_gr[32]; + compat_int_t rf_iasq[2]; + compat_int_t rf_iaoq[2]; + compat_int_t rf_sar; +}; + +#define COMPAT_SIGRETURN_TRAMP 4 +#define COMPAT_SIGRESTARTBLOCK_TRAMP 5 +#define COMPAT_TRAMP_SIZE (COMPAT_SIGRETURN_TRAMP + \ + COMPAT_SIGRESTARTBLOCK_TRAMP) + +struct compat_rt_sigframe { + /* XXX: Must match trampoline size in arch/parisc/kernel/signal.c + Secondary to that it must protect the ERESTART_RESTARTBLOCK + trampoline we left on the stack (we were bad and didn't + change sp so we could run really fast.) */ + compat_uint_t tramp[COMPAT_TRAMP_SIZE]; + compat_siginfo_t info; + struct compat_ucontext uc; + /* Hidden location of truncated registers, *must* be last. */ + struct compat_regfile regs; +}; + +/* + * The 32-bit ABI wants at least 48 bytes for a function call frame: + * 16 bytes for arg0-arg3, and 32 bytes for magic (the only part of + * which Linux/parisc uses is sp-20 for the saved return pointer...) + * Then, the stack pointer must be rounded to a cache line (64 bytes). + */ +#define SIGFRAME32 64 +#define FUNCTIONCALLFRAME32 48 +#define PARISC_RT_SIGFRAME_SIZE32 (((sizeof(struct compat_rt_sigframe) + FUNCTIONCALLFRAME32) + SIGFRAME32) & -SIGFRAME32) + void sigset_32to64(sigset_t *s64, compat_sigset_t *s32); void sigset_64to32(compat_sigset_t *s32, sigset_t *s64); int do_sigaltstack32 (const compat_stack_t __user *uss32, diff --git a/include/asm-parisc/compat_ucontext.h b/include/asm-parisc/compat_ucontext.h index a1228a3d2071..2f7292afde3c 100644 --- a/include/asm-parisc/compat_ucontext.h +++ b/include/asm-parisc/compat_ucontext.h @@ -1,8 +1,7 @@ #ifndef _ASM_PARISC_COMPAT_UCONTEXT_H #define _ASM_PARISC_COMPAT_UCONTEXT_H -#include -#include +#include /* 32-bit ucontext as seen from an 64-bit kernel */ struct compat_ucontext { diff --git a/include/asm-parisc/rt_sigframe.h b/include/asm-parisc/rt_sigframe.h index 5623c032b64c..f0dd3b30f6c4 100644 --- a/include/asm-parisc/rt_sigframe.h +++ b/include/asm-parisc/rt_sigframe.h @@ -1,10 +1,6 @@ #ifndef _ASM_PARISC_RT_SIGFRAME_H #define _ASM_PARISC_RT_SIGFRAME_H -#ifdef CONFIG_COMPAT -#include -#endif - #define SIGRETURN_TRAMP 4 #define SIGRESTARTBLOCK_TRAMP 5 #define TRAMP_SIZE (SIGRETURN_TRAMP + SIGRESTARTBLOCK_TRAMP) -- cgit v1.2.3 From d3ed309a718bc6f79dc485a6d18731990daeee5e Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Mon, 23 Jan 2006 21:03:56 -0800 Subject: [SPARC64]: Implement __raw_read_trylock() generic__raw_read_trylock() just does a raw_read_lock() so that isn't very useful. Signed-off-by: David S. Miller --- include/asm-sparc64/spinlock.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/asm-sparc64/spinlock.h b/include/asm-sparc64/spinlock.h index ec85d12d73b9..508c416e9d6a 100644 --- a/include/asm-sparc64/spinlock.h +++ b/include/asm-sparc64/spinlock.h @@ -131,6 +131,28 @@ static void inline __read_lock(raw_rwlock_t *lock) : "memory"); } +static int inline __read_trylock(raw_rwlock_t *lock) +{ + int tmp1, tmp2; + + __asm__ __volatile__ ( +"1: ldsw [%2], %0\n" +" brlz,a,pn %0, 2f\n" +" mov 0, %0\n" +" add %0, 1, %1\n" +" cas [%2], %0, %1\n" +" cmp %0, %1\n" +" membar #StoreLoad | #StoreStore\n" +" bne,pn %%icc, 1b\n" +" mov 1, %0\n" +"2:" + : "=&r" (tmp1), "=&r" (tmp2) + : "r" (lock) + : "memory"); + + return tmp1; +} + static void inline __read_unlock(raw_rwlock_t *lock) { unsigned long tmp1, tmp2; @@ -211,12 +233,12 @@ static int inline __write_trylock(raw_rwlock_t *lock) } #define __raw_read_lock(p) __read_lock(p) +#define __raw_read_trylock(p) __read_trylock(p) #define __raw_read_unlock(p) __read_unlock(p) #define __raw_write_lock(p) __write_lock(p) #define __raw_write_unlock(p) __write_unlock(p) #define __raw_write_trylock(p) __write_trylock(p) -#define __raw_read_trylock(lock) generic__raw_read_trylock(lock) #define __raw_read_can_lock(rw) (!((rw)->lock & 0x80000000UL)) #define __raw_write_can_lock(rw) (!(rw)->lock) -- cgit v1.2.3 From 2cb2e147a6d20bffd1d6b7a79be7301560f751c3 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 17 Jan 2006 09:04:32 +0100 Subject: [BLOCK] ll_rw_blk: make max_sectors and max_hw_sectors unsigned ints IDE lba48 can support full 64k request size, which overflows the max_hw_sectors variable. Signed-off-by: Jens Axboe --- block/ll_rw_blk.c | 2 +- include/linux/blkdev.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 8e27d0ab0d7c..5c62507a510d 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c @@ -662,7 +662,7 @@ EXPORT_SYMBOL(blk_queue_bounce_limit); * Enables a low level driver to set an upper limit on the size of * received requests. **/ -void blk_queue_max_sectors(request_queue_t *q, unsigned short max_sectors) +void blk_queue_max_sectors(request_queue_t *q, unsigned int max_sectors) { if ((max_sectors << 9) < PAGE_CACHE_SIZE) { max_sectors = 1 << (PAGE_CACHE_SHIFT - 9); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 02a585faa62c..860e7a485a5f 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -392,8 +392,8 @@ struct request_queue unsigned int nr_congestion_off; unsigned int nr_batching; - unsigned short max_sectors; - unsigned short max_hw_sectors; + unsigned int max_sectors; + unsigned int max_hw_sectors; unsigned short max_phys_segments; unsigned short max_hw_segments; unsigned short hardsect_size; @@ -697,7 +697,7 @@ extern request_queue_t *blk_init_queue(request_fn_proc *, spinlock_t *); extern void blk_cleanup_queue(request_queue_t *); extern void blk_queue_make_request(request_queue_t *, make_request_fn *); extern void blk_queue_bounce_limit(request_queue_t *, u64); -extern void blk_queue_max_sectors(request_queue_t *, unsigned short); +extern void blk_queue_max_sectors(request_queue_t *, unsigned int); extern void blk_queue_max_phys_segments(request_queue_t *, unsigned short); extern void blk_queue_max_hw_segments(request_queue_t *, unsigned short); extern void blk_queue_max_segment_size(request_queue_t *, unsigned int); -- cgit v1.2.3 From fd8b206d1621ad526e7b00dc26322f546b2a57fb Mon Sep 17 00:00:00 2001 From: Dean Roe Date: Tue, 24 Jan 2006 14:49:43 -0800 Subject: [IA64-SGI] add sn_feature_sets bit SGI's prom has added a new feature which avoids an Altix-specific MCA that can occur with excessive use of ia64_pal_cache_flush. This patch adds the #define to the sn_feature_sets.h to reflect that bit is taken. Signed-off-by: Dean Roe Signed-off-by: Tony Luck --- include/asm-ia64/sn/sn_feature_sets.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/asm-ia64/sn/sn_feature_sets.h b/include/asm-ia64/sn/sn_feature_sets.h index e68a80853d5d..f63f144e8170 100644 --- a/include/asm-ia64/sn/sn_feature_sets.h +++ b/include/asm-ia64/sn/sn_feature_sets.h @@ -8,7 +8,7 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (c) 2005 Silicon Graphics, Inc. All rights reserved. + * Copyright (c) 2005-2006 Silicon Graphics, Inc. All rights reserved. */ @@ -27,14 +27,11 @@ extern int sn_prom_feature_available(int id); * "false" for new features. * * Use: - * if (sn_prom_feature_available(PRF_FEATURE_XXX)) + * if (sn_prom_feature_available(PRF_XXX)) * ... */ -/* - * Example: feature XXX - */ -#define PRF_FEATURE_XXX 0 +#define PRF_PAL_CACHE_FLUSH_SAFE 0 -- cgit v1.2.3 From dfcd77d16b5745fbfea7d5636f15fc80cc05fef8 Mon Sep 17 00:00:00 2001 From: Tetsuo Takata Date: Wed, 25 Jan 2006 11:12:40 +0100 Subject: [SCSI] Remove host template ordered_flush variable After the recent overhaul of the block layer the variable "ordered_flush" is no longer used. Signed-off-by: Tetsuo Takata Signed-off-by: Jens Axboe --- include/scsi/scsi_host.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 467274a764d1..827992949c4b 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -554,7 +554,6 @@ struct Scsi_Host { /* * ordered write support */ - unsigned ordered_flush:1; unsigned ordered_tag:1; /* -- cgit v1.2.3 From 0367a8d37af6028b64127ac70922717575b81113 Mon Sep 17 00:00:00 2001 From: Lucas Correia Villa Real Date: Thu, 26 Jan 2006 15:20:50 +0000 Subject: [ARM] 3266/1: S3C2400 - adds macro S3C24XX Patch from Lucas Correia Villa Real This patch defines S3C2400 memory map and adds a S3C24XX macro for common resources between S3C2400, S3C2410 and S3C2440 cpus. Signed-off-by: Lucas Correia Villa Real Signed-off-by: Ben Dooks Signed-off-by: Russell King --- arch/arm/mach-s3c2410/cpu.h | 3 +- arch/arm/mach-s3c2410/devs.c | 57 +++++++++++++++--------------- arch/arm/mach-s3c2410/dma.c | 2 +- arch/arm/mach-s3c2410/sleep.S | 6 ++-- drivers/serial/s3c2410.c | 2 +- include/asm-arm/arch-s3c2410/debug-macro.S | 6 ++-- include/asm-arm/arch-s3c2410/map.h | 38 ++++++++++++++++++++ include/asm-arm/arch-s3c2410/regs-serial.h | 6 ++-- include/asm-arm/arch-s3c2410/uncompress.h | 6 ++-- 9 files changed, 83 insertions(+), 43 deletions(-) (limited to 'include') diff --git a/arch/arm/mach-s3c2410/cpu.h b/arch/arm/mach-s3c2410/cpu.h index 9cbe5eef492b..fc1067783f6d 100644 --- a/arch/arm/mach-s3c2410/cpu.h +++ b/arch/arm/mach-s3c2410/cpu.h @@ -17,11 +17,12 @@ * 14-Jan-2005 BJD Added s3c24xx_init_clocks() call * 10-Mar-2005 LCVR Changed S3C2410_{VA,SZ} to S3C24XX_{VA,SZ} & IODESC_ENT * 14-Mar-2005 BJD Updated for __iomem + * 15-Jan-2006 LCVR Updated S3C2410_PA_##x to new S3C24XX_PA_##x macro */ /* todo - fix when rmk changes iodescs to use `void __iomem *` */ -#define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C2410_PA_##x), S3C24XX_SZ_##x, MT_DEVICE } +#define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C24XX_PA_##x), S3C24XX_SZ_##x, MT_DEVICE } #ifndef MHZ #define MHZ (1000*1000) diff --git a/arch/arm/mach-s3c2410/devs.c b/arch/arm/mach-s3c2410/devs.c index f58406e6ef5a..b8d994a24d1c 100644 --- a/arch/arm/mach-s3c2410/devs.c +++ b/arch/arm/mach-s3c2410/devs.c @@ -10,6 +10,7 @@ * published by the Free Software Foundation. * * Modifications: + * 15-Jan-2006 LCVR Using S3C24XX_PA_##x macro for common S3C24XX devices * 10-Mar-2005 LCVR Changed S3C2410_{VA,SZ} to S3C24XX_{VA,SZ} * 10-Feb-2005 BJD Added camera from guillaume.gourat@nexvision.tv * 29-Aug-2004 BJD Added timers 0 through 3 @@ -46,8 +47,8 @@ struct platform_device *s3c24xx_uart_devs[3]; static struct resource s3c_usb_resource[] = { [0] = { - .start = S3C2410_PA_USBHOST, - .end = S3C2410_PA_USBHOST + S3C24XX_SZ_USBHOST - 1, + .start = S3C24XX_PA_USBHOST, + .end = S3C24XX_PA_USBHOST + S3C24XX_SZ_USBHOST - 1, .flags = IORESOURCE_MEM, }, [1] = { @@ -76,8 +77,8 @@ EXPORT_SYMBOL(s3c_device_usb); static struct resource s3c_lcd_resource[] = { [0] = { - .start = S3C2410_PA_LCD, - .end = S3C2410_PA_LCD + S3C24XX_SZ_LCD - 1, + .start = S3C24XX_PA_LCD, + .end = S3C24XX_PA_LCD + S3C24XX_SZ_LCD - 1, .flags = IORESOURCE_MEM, }, [1] = { @@ -139,8 +140,8 @@ EXPORT_SYMBOL(s3c_device_nand); static struct resource s3c_usbgadget_resource[] = { [0] = { - .start = S3C2410_PA_USBDEV, - .end = S3C2410_PA_USBDEV + S3C24XX_SZ_USBDEV - 1, + .start = S3C24XX_PA_USBDEV, + .end = S3C24XX_PA_USBDEV + S3C24XX_SZ_USBDEV - 1, .flags = IORESOURCE_MEM, }, [1] = { @@ -164,8 +165,8 @@ EXPORT_SYMBOL(s3c_device_usbgadget); static struct resource s3c_wdt_resource[] = { [0] = { - .start = S3C2410_PA_WATCHDOG, - .end = S3C2410_PA_WATCHDOG + S3C24XX_SZ_WATCHDOG - 1, + .start = S3C24XX_PA_WATCHDOG, + .end = S3C24XX_PA_WATCHDOG + S3C24XX_SZ_WATCHDOG - 1, .flags = IORESOURCE_MEM, }, [1] = { @@ -189,8 +190,8 @@ EXPORT_SYMBOL(s3c_device_wdt); static struct resource s3c_i2c_resource[] = { [0] = { - .start = S3C2410_PA_IIC, - .end = S3C2410_PA_IIC + S3C24XX_SZ_IIC - 1, + .start = S3C24XX_PA_IIC, + .end = S3C24XX_PA_IIC + S3C24XX_SZ_IIC - 1, .flags = IORESOURCE_MEM, }, [1] = { @@ -214,8 +215,8 @@ EXPORT_SYMBOL(s3c_device_i2c); static struct resource s3c_iis_resource[] = { [0] = { - .start = S3C2410_PA_IIS, - .end = S3C2410_PA_IIS + S3C24XX_SZ_IIS -1, + .start = S3C24XX_PA_IIS, + .end = S3C24XX_PA_IIS + S3C24XX_SZ_IIS -1, .flags = IORESOURCE_MEM, } }; @@ -239,8 +240,8 @@ EXPORT_SYMBOL(s3c_device_iis); static struct resource s3c_rtc_resource[] = { [0] = { - .start = S3C2410_PA_RTC, - .end = S3C2410_PA_RTC + 0xff, + .start = S3C24XX_PA_RTC, + .end = S3C24XX_PA_RTC + 0xff, .flags = IORESOURCE_MEM, }, [1] = { @@ -268,8 +269,8 @@ EXPORT_SYMBOL(s3c_device_rtc); static struct resource s3c_adc_resource[] = { [0] = { - .start = S3C2410_PA_ADC, - .end = S3C2410_PA_ADC + S3C24XX_SZ_ADC - 1, + .start = S3C24XX_PA_ADC, + .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1, .flags = IORESOURCE_MEM, }, [1] = { @@ -316,8 +317,8 @@ EXPORT_SYMBOL(s3c_device_sdi); static struct resource s3c_spi0_resource[] = { [0] = { - .start = S3C2410_PA_SPI, - .end = S3C2410_PA_SPI + 0x1f, + .start = S3C24XX_PA_SPI, + .end = S3C24XX_PA_SPI + 0x1f, .flags = IORESOURCE_MEM, }, [1] = { @@ -341,8 +342,8 @@ EXPORT_SYMBOL(s3c_device_spi0); static struct resource s3c_spi1_resource[] = { [0] = { - .start = S3C2410_PA_SPI + 0x20, - .end = S3C2410_PA_SPI + 0x20 + 0x1f, + .start = S3C24XX_PA_SPI + 0x20, + .end = S3C24XX_PA_SPI + 0x20 + 0x1f, .flags = IORESOURCE_MEM, }, [1] = { @@ -366,8 +367,8 @@ EXPORT_SYMBOL(s3c_device_spi1); static struct resource s3c_timer0_resource[] = { [0] = { - .start = S3C2410_PA_TIMER + 0x0C, - .end = S3C2410_PA_TIMER + 0x0C + 0xB, + .start = S3C24XX_PA_TIMER + 0x0C, + .end = S3C24XX_PA_TIMER + 0x0C + 0xB, .flags = IORESOURCE_MEM, }, [1] = { @@ -391,8 +392,8 @@ EXPORT_SYMBOL(s3c_device_timer0); static struct resource s3c_timer1_resource[] = { [0] = { - .start = S3C2410_PA_TIMER + 0x18, - .end = S3C2410_PA_TIMER + 0x23, + .start = S3C24XX_PA_TIMER + 0x18, + .end = S3C24XX_PA_TIMER + 0x23, .flags = IORESOURCE_MEM, }, [1] = { @@ -416,8 +417,8 @@ EXPORT_SYMBOL(s3c_device_timer1); static struct resource s3c_timer2_resource[] = { [0] = { - .start = S3C2410_PA_TIMER + 0x24, - .end = S3C2410_PA_TIMER + 0x2F, + .start = S3C24XX_PA_TIMER + 0x24, + .end = S3C24XX_PA_TIMER + 0x2F, .flags = IORESOURCE_MEM, }, [1] = { @@ -441,8 +442,8 @@ EXPORT_SYMBOL(s3c_device_timer2); static struct resource s3c_timer3_resource[] = { [0] = { - .start = S3C2410_PA_TIMER + 0x30, - .end = S3C2410_PA_TIMER + 0x3B, + .start = S3C24XX_PA_TIMER + 0x30, + .end = S3C24XX_PA_TIMER + 0x3B, .flags = IORESOURCE_MEM, }, [1] = { diff --git a/arch/arm/mach-s3c2410/dma.c b/arch/arm/mach-s3c2410/dma.c index 65feaf20d23e..4dbd8e758ea6 100644 --- a/arch/arm/mach-s3c2410/dma.c +++ b/arch/arm/mach-s3c2410/dma.c @@ -1152,7 +1152,7 @@ static int __init s3c2410_init_dma(void) printk("S3C2410 DMA Driver, (c) 2003-2004 Simtec Electronics\n"); - dma_base = ioremap(S3C2410_PA_DMA, 0x200); + dma_base = ioremap(S3C24XX_PA_DMA, 0x200); if (dma_base == NULL) { printk(KERN_ERR "dma failed to remap register block\n"); return -ENOMEM; diff --git a/arch/arm/mach-s3c2410/sleep.S b/arch/arm/mach-s3c2410/sleep.S index 61768dac7fee..e9a055b779b7 100644 --- a/arch/arm/mach-s3c2410/sleep.S +++ b/arch/arm/mach-s3c2410/sleep.S @@ -133,12 +133,12 @@ ENTRY(s3c2410_cpu_resume) @@ load UART to allow us to print the two characters for @@ resume debug - mov r2, #S3C2410_PA_UART & 0xff000000 - orr r2, r2, #S3C2410_PA_UART & 0xff000 + mov r2, #S3C24XX_PA_UART & 0xff000000 + orr r2, r2, #S3C24XX_PA_UART & 0xff000 #if 0 /* SMDK2440 LED set */ - mov r14, #S3C2410_PA_GPIO + mov r14, #S3C24XX_PA_GPIO ldr r12, [ r14, #0x54 ] bic r12, r12, #3<<4 orr r12, r12, #1<<7 diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c index eb4883efb7c6..0a2dd6c5b95f 100644 --- a/drivers/serial/s3c2410.c +++ b/drivers/serial/s3c2410.c @@ -1060,7 +1060,7 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, dbg("resource %p (%lx..%lx)\n", res, res->start, res->end); port->mapbase = res->start; - port->membase = S3C24XX_VA_UART + (res->start - S3C2410_PA_UART); + port->membase = S3C24XX_VA_UART + (res->start - S3C24XX_PA_UART); port->irq = platform_get_irq(platdev, 0); ourport->clk = clk_get(&platdev->dev, "uart"); diff --git a/include/asm-arm/arch-s3c2410/debug-macro.S b/include/asm-arm/arch-s3c2410/debug-macro.S index abfbe45cd17c..5f8223e700d3 100644 --- a/include/asm-arm/arch-s3c2410/debug-macro.S +++ b/include/asm-arm/arch-s3c2410/debug-macro.S @@ -25,7 +25,7 @@ .macro addruart, rx mrc p15, 0, \rx, c1, c0 tst \rx, #1 - ldreq \rx, = S3C2410_PA_UART + ldreq \rx, = S3C24XX_PA_UART ldrne \rx, = S3C24XX_VA_UART #if CONFIG_DEBUG_S3C2410_UART != 0 add \rx, \rx, #(S3C2410_UART1_OFF * CONFIG_DEBUG_S3C2410_UART) @@ -44,7 +44,7 @@ 1003: mrc p15, 0, \rd, c1, c0 tst \rd, #1 - addeq \rd, \rx, #(S3C2410_PA_GPIO - S3C2410_PA_UART) + addeq \rd, \rx, #(S3C24XX_PA_GPIO - S3C24XX_PA_UART) addne \rd, \rx, #(S3C24XX_VA_GPIO - S3C24XX_VA_UART) bic \rd, \rd, #0xff000 ldr \rd, [ \rd, # S3C2410_GSTATUS1 - S3C2410_GPIOREG(0) ] @@ -75,7 +75,7 @@ 1003: mrc p15, 0, \rd, c1, c0 tst \rd, #1 - addeq \rd, \rx, #(S3C2410_PA_GPIO - S3C2410_PA_UART) + addeq \rd, \rx, #(S3C24XX_PA_GPIO - S3C24XX_PA_UART) addne \rd, \rx, #(S3C24XX_VA_GPIO - S3C24XX_VA_UART) bic \rd, \rd, #0xff000 ldr \rd, [ \rd, # S3C2410_GSTATUS1 - S3C2410_GPIOREG(0) ] diff --git a/include/asm-arm/arch-s3c2410/map.h b/include/asm-arm/arch-s3c2410/map.h index 1833ea5c4220..c380d264a847 100644 --- a/include/asm-arm/arch-s3c2410/map.h +++ b/include/asm-arm/arch-s3c2410/map.h @@ -14,6 +14,7 @@ * 06-Jan-2003 BJD Linux 2.6.0 version, moved bast specifics out * 10-Feb-2005 BJD Added CAMIF definition from guillaume.gourat@nexvision.tv * 10-Mar-2005 LCVR Added support to S3C2400, changed {VA,SZ} names + * 15-Jan-2006 LCVR Added S3C24XX_PA macros for common S3C24XX resources */ #ifndef __ASM_ARCH_MAP_H @@ -188,5 +189,42 @@ #define S3C2400_SDRAM_PA (S3C2400_CS6) +/* Use a single interface for common resources between S3C24XX cpus */ + +#ifdef CONFIG_CPU_S3C2400 +#define S3C24XX_PA_IRQ S3C2400_PA_IRQ +#define S3C24XX_PA_MEMCTRL S3C2400_PA_MEMCTRL +#define S3C24XX_PA_USBHOST S3C2400_PA_USBHOST +#define S3C24XX_PA_DMA S3C2400_PA_DMA +#define S3C24XX_PA_CLKPWR S3C2400_PA_CLKPWR +#define S3C24XX_PA_LCD S3C2400_PA_LCD +#define S3C24XX_PA_UART S3C2400_PA_UART +#define S3C24XX_PA_TIMER S3C2400_PA_TIMER +#define S3C24XX_PA_USBDEV S3C2400_PA_USBDEV +#define S3C24XX_PA_WATCHDOG S3C2400_PA_WATCHDOG +#define S3C24XX_PA_IIC S3C2400_PA_IIC +#define S3C24XX_PA_IIS S3C2400_PA_IIS +#define S3C24XX_PA_GPIO S3C2400_PA_GPIO +#define S3C24XX_PA_RTC S3C2400_PA_RTC +#define S3C24XX_PA_ADC S3C2400_PA_ADC +#define S3C24XX_PA_SPI S3C2400_PA_SPI +#else +#define S3C24XX_PA_IRQ S3C2410_PA_IRQ +#define S3C24XX_PA_MEMCTRL S3C2410_PA_MEMCTRL +#define S3C24XX_PA_USBHOST S3C2410_PA_USBHOST +#define S3C24XX_PA_DMA S3C2410_PA_DMA +#define S3C24XX_PA_CLKPWR S3C2410_PA_CLKPWR +#define S3C24XX_PA_LCD S3C2410_PA_LCD +#define S3C24XX_PA_UART S3C2410_PA_UART +#define S3C24XX_PA_TIMER S3C2410_PA_TIMER +#define S3C24XX_PA_USBDEV S3C2410_PA_USBDEV +#define S3C24XX_PA_WATCHDOG S3C2410_PA_WATCHDOG +#define S3C24XX_PA_IIC S3C2410_PA_IIC +#define S3C24XX_PA_IIS S3C2410_PA_IIS +#define S3C24XX_PA_GPIO S3C2410_PA_GPIO +#define S3C24XX_PA_RTC S3C2410_PA_RTC +#define S3C24XX_PA_ADC S3C2410_PA_ADC +#define S3C24XX_PA_SPI S3C2410_PA_SPI +#endif #endif /* __ASM_ARCH_MAP_H */ diff --git a/include/asm-arm/arch-s3c2410/regs-serial.h b/include/asm-arm/arch-s3c2410/regs-serial.h index ce1bbbaad6d3..83b01254c4ac 100644 --- a/include/asm-arm/arch-s3c2410/regs-serial.h +++ b/include/asm-arm/arch-s3c2410/regs-serial.h @@ -39,9 +39,9 @@ #define S3C24XX_VA_UART1 (S3C24XX_VA_UART + 0x4000 ) #define S3C24XX_VA_UART2 (S3C24XX_VA_UART + 0x8000 ) -#define S3C2410_PA_UART0 (S3C2410_PA_UART) -#define S3C2410_PA_UART1 (S3C2410_PA_UART + 0x4000 ) -#define S3C2410_PA_UART2 (S3C2410_PA_UART + 0x8000 ) +#define S3C2410_PA_UART0 (S3C24XX_PA_UART) +#define S3C2410_PA_UART1 (S3C24XX_PA_UART + 0x4000 ) +#define S3C2410_PA_UART2 (S3C24XX_PA_UART + 0x8000 ) #define S3C2410_URXH (0x24) #define S3C2410_UTXH (0x20) diff --git a/include/asm-arm/arch-s3c2410/uncompress.h b/include/asm-arm/arch-s3c2410/uncompress.h index ddd1578a7ee0..4367ec054b51 100644 --- a/include/asm-arm/arch-s3c2410/uncompress.h +++ b/include/asm-arm/arch-s3c2410/uncompress.h @@ -35,13 +35,13 @@ #undef S3C2410_GPIOREG #undef S3C2410_WDOGREG -#define S3C2410_GPIOREG(x) ((S3C2410_PA_GPIO + (x))) -#define S3C2410_WDOGREG(x) ((S3C2410_PA_WATCHDOG + (x))) +#define S3C2410_GPIOREG(x) ((S3C24XX_PA_GPIO + (x))) +#define S3C2410_WDOGREG(x) ((S3C24XX_PA_WATCHDOG + (x))) /* how many bytes we allow into the FIFO at a time in FIFO mode */ #define FIFO_MAX (14) -#define uart_base S3C2410_PA_UART + (0x4000*CONFIG_S3C2410_LOWLEVEL_UART_PORT) +#define uart_base S3C24XX_PA_UART + (0x4000*CONFIG_S3C2410_LOWLEVEL_UART_PORT) static __inline__ void uart_wr(unsigned int reg, unsigned int val) -- cgit v1.2.3 From 7efb83002bc20c5c72151d51468593834b510d71 Mon Sep 17 00:00:00 2001 From: "George G. Davis" Date: Thu, 26 Jan 2006 15:21:28 +0000 Subject: [ARM] 3269/1: Add ARMv6 MT_NONSHARED_DEVICE mem_types[] index Patch from George G. Davis This Freescale Semiconductor, Inc. contributed patch adds mem_types[] support for ARMv6 non-shared device memory region attributes. This implementation provides support for only first level section mapped non-shared devices. Second level non-shared device mappings are not yet supported. Signed-off-by: George G. Davis Signed-off-by: Russell King --- arch/arm/mm/mm-armv.c | 6 ++++++ include/asm-arm/mach/map.h | 1 + include/asm-arm/pgtable.h | 1 + 3 files changed, 8 insertions(+) (limited to 'include') diff --git a/arch/arm/mm/mm-armv.c b/arch/arm/mm/mm-armv.c index d0245a31d4dd..ef8d30a185a9 100644 --- a/arch/arm/mm/mm-armv.c +++ b/arch/arm/mm/mm-armv.c @@ -343,6 +343,12 @@ static struct mem_types mem_types[] __initdata = { PMD_SECT_AP_WRITE | PMD_SECT_BUFFERABLE | PMD_SECT_TEX(1), .domain = DOMAIN_IO, + }, + [MT_NONSHARED_DEVICE] = { + .prot_l1 = PMD_TYPE_TABLE, + .prot_sect = PMD_TYPE_SECT | PMD_SECT_NONSHARED_DEV | + PMD_SECT_AP_WRITE, + .domain = DOMAIN_IO, } }; diff --git a/include/asm-arm/mach/map.h b/include/asm-arm/mach/map.h index 3351b77fab36..e8ea67c97c73 100644 --- a/include/asm-arm/mach/map.h +++ b/include/asm-arm/mach/map.h @@ -26,6 +26,7 @@ struct meminfo; #define MT_MEMORY 5 #define MT_ROM 6 #define MT_IXP2000_DEVICE 7 +#define MT_NONSHARED_DEVICE 8 extern void create_memmap_holes(struct meminfo *); extern void memtable_init(struct meminfo *); diff --git a/include/asm-arm/pgtable.h b/include/asm-arm/pgtable.h index 5a0d19b466b0..70e00d08345e 100644 --- a/include/asm-arm/pgtable.h +++ b/include/asm-arm/pgtable.h @@ -168,6 +168,7 @@ extern void __pgd_error(const char *file, int line, unsigned long val); #define PMD_SECT_WB (PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE) #define PMD_SECT_MINICACHE (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE) #define PMD_SECT_WBWA (PMD_SECT_TEX(1) | PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE) +#define PMD_SECT_NONSHARED_DEV (PMD_SECT_TEX(2)) /* * - coarse table (not used) -- cgit v1.2.3 From bb1d1073a10fdc8547e3eb821ee2488260094b39 Mon Sep 17 00:00:00 2001 From: "brking@us.ibm.com" Date: Mon, 23 Jan 2006 15:03:22 -0600 Subject: [SCSI] Prevent scsi_execute_async from guessing cdb length When the scsi_execute_async interface was added it ended up reducing the flexibility of userspace to send arbitrary scsi commands through sg using SG_IO. The SG_IO interface allows userspace to specify the CDB length. This is now ignored in scsi_execute_async and it is guessed using the COMMAND_SIZE macro, which is not always correct, particularly for vendor specific commands. This patch adds a cmd_len parameter to the scsi_execute_async interface to allow the caller to specify the length of the CDB. Signed-off-by: Brian King Signed-off-by: James Bottomley --- drivers/scsi/scsi_error.c | 2 +- drivers/scsi/scsi_lib.c | 5 +++-- drivers/scsi/sg.c | 2 +- drivers/scsi/st.c | 2 +- include/scsi/scsi_device.h | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index a2333d2c7af0..5cc97b721661 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1350,7 +1350,7 @@ static void scsi_eh_lock_door(struct scsi_device *sdev) cmnd[4] = SCSI_REMOVAL_PREVENT; cmnd[5] = 0; - scsi_execute_async(sdev, cmnd, DMA_NONE, NULL, 0, 0, 10 * HZ, + scsi_execute_async(sdev, cmnd, 6, DMA_NONE, NULL, 0, 0, 10 * HZ, 5, NULL, NULL, GFP_KERNEL); } diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 3574ba935af8..4a602853a98e 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -436,6 +436,7 @@ free_bios: * scsi_execute_async - insert request * @sdev: scsi device * @cmd: scsi command + * @cmd_len: length of scsi cdb * @data_direction: data direction * @buffer: data buffer (this can be a kernel buffer or scatterlist) * @bufflen: len of buffer @@ -445,7 +446,7 @@ free_bios: * @flags: or into request flags **/ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd, - int data_direction, void *buffer, unsigned bufflen, + int cmd_len, int data_direction, void *buffer, unsigned bufflen, int use_sg, int timeout, int retries, void *privdata, void (*done)(void *, char *, int, int), gfp_t gfp) { @@ -472,7 +473,7 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd, if (err) goto free_req; - req->cmd_len = COMMAND_SIZE(cmd[0]); + req->cmd_len = cmd_len; memcpy(req->cmd, cmd, req->cmd_len); req->sense = sioc->sense; req->sense_len = 0; diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 78aad9582bcf..7d0700091f3d 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -741,7 +741,7 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp, hp->duration = jiffies_to_msecs(jiffies); /* Now send everything of to mid-level. The next time we hear about this packet is when sg_cmd_done() is called (i.e. a callback). */ - if (scsi_execute_async(sdp->device, cmnd, data_dir, srp->data.buffer, + if (scsi_execute_async(sdp->device, cmnd, hp->cmd_len, data_dir, srp->data.buffer, hp->dxfer_len, srp->data.k_use_sg, timeout, SG_DEFAULT_RETRIES, srp, sg_cmd_done, GFP_ATOMIC)) { diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 13b1d3aac265..7f96f33c1bb1 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -508,7 +508,7 @@ st_do_scsi(struct st_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd STp->buffer->cmdstat.have_sense = 0; STp->buffer->syscall_result = 0; - if (scsi_execute_async(STp->device, cmd, direction, + if (scsi_execute_async(STp->device, cmd, COMMAND_SIZE(cmd[0]), direction, &((STp->buffer)->sg[0]), bytes, (STp->buffer)->sg_segs, timeout, retries, SRpnt, st_sleep_done, GFP_KERNEL)) { /* could not allocate the buffer or request was too large */ diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index e94ca4d36035..290e3b4d2aec 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -275,7 +275,7 @@ extern int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, int data_direction, void *buffer, unsigned bufflen, struct scsi_sense_hdr *, int timeout, int retries); extern int scsi_execute_async(struct scsi_device *sdev, - const unsigned char *cmd, int data_direction, + const unsigned char *cmd, int cmd_len, int data_direction, void *buffer, unsigned bufflen, int use_sg, int timeout, int retries, void *privdata, void (*done)(void *, char *, int, int), -- cgit v1.2.3 From 61d67f2e07d96d20d86135792ca591c491939c27 Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Wed, 25 Jan 2006 18:51:14 -0500 Subject: [IA64-SGI] Add PROM feature set for device flush list Introduce PRF_DEVICE_FLUSH_LIST flag for older PROMs. Signed-off-by: Prarit Bhargava Signed-off-by: Tony Luck --- arch/ia64/sn/kernel/io_init.c | 36 +++++++++++++++++------------------ include/asm-ia64/sn/sn_feature_sets.h | 7 ++++--- 2 files changed, 22 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c index 00700f7e6837..a4c78152b336 100644 --- a/arch/ia64/sn/kernel/io_init.c +++ b/arch/ia64/sn/kernel/io_init.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -173,8 +174,8 @@ sn_pcidev_info_get(struct pci_dev *dev) */ static u8 war_implemented = 0; -static void sn_device_fixup_war(u64 nasid, u64 widget, int device, - struct sn_flush_device_common *common) +static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device, + struct sn_flush_device_common *common) { struct sn_flush_device_war *war_list; struct sn_flush_device_war *dev_entry; @@ -198,8 +199,9 @@ static void sn_device_fixup_war(u64 nasid, u64 widget, int device, dev_entry = war_list + device; memcpy(common,dev_entry, sizeof(*common)); - kfree(war_list); + + return isrv.status; } /* @@ -279,23 +281,21 @@ static void sn_fixup_ionodes(void) memset(dev_entry->common, 0x0, sizeof(struct sn_flush_device_common)); - status = sal_get_device_dmaflush_list(nasid, - widget, - device, + if (sn_prom_feature_available( + PRF_DEVICE_FLUSH_LIST)) + status = sal_get_device_dmaflush_list( + nasid, + widget, + device, (u64)(dev_entry->common)); - if (status) { - if (sn_sal_rev() < 0x0450) { - /* shortlived WAR for older - * PROM images - */ - sn_device_fixup_war(nasid, - widget, - device, + else + status = sn_device_fixup_war(nasid, + widget, + device, dev_entry->common); - } - else - BUG(); - } + if (status != SALRET_OK) + panic("SAL call failed: %s\n", + ia64_sal_strerror(status)); spin_lock_init(&dev_entry->sfdl_flush_lock); } diff --git a/include/asm-ia64/sn/sn_feature_sets.h b/include/asm-ia64/sn/sn_feature_sets.h index f63f144e8170..9ca642cad338 100644 --- a/include/asm-ia64/sn/sn_feature_sets.h +++ b/include/asm-ia64/sn/sn_feature_sets.h @@ -31,7 +31,8 @@ extern int sn_prom_feature_available(int id); * ... */ -#define PRF_PAL_CACHE_FLUSH_SAFE 0 +#define PRF_PAL_CACHE_FLUSH_SAFE 0 +#define PRF_DEVICE_FLUSH_LIST 1 @@ -48,7 +49,7 @@ extern int sn_prom_feature_available(int id); * * By default, features are disabled unless explicitly enabled. */ -#define OSF_MCA_SLV_TO_OS_INIT_SLV 0 -#define OSF_FEAT_LOG_SBES 1 +#define OSF_MCA_SLV_TO_OS_INIT_SLV 0 +#define OSF_FEAT_LOG_SBES 1 #endif /* _ASM_IA64_SN_FEATURE_SETS_H */ -- cgit v1.2.3 From 4a99ac3a9ee7e1b90ebc3ddbb44db75eef5c41e6 Mon Sep 17 00:00:00 2001 From: Zhu Yi Date: Thu, 19 Jan 2006 16:21:19 +0800 Subject: [PATCH] ieee80211: Fix A band min and max channel definitions Signed-off-by: Hong Liu Signed-off-by: Zhu Yi Signed-off-by: John W. Linville --- include/net/ieee80211.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h index df05f468fa5c..9a92aef8b0b2 100644 --- a/include/net/ieee80211.h +++ b/include/net/ieee80211.h @@ -803,9 +803,9 @@ enum ieee80211_state { #define IEEE80211_24GHZ_MAX_CHANNEL 14 #define IEEE80211_24GHZ_CHANNELS 14 -#define IEEE80211_52GHZ_MIN_CHANNEL 36 +#define IEEE80211_52GHZ_MIN_CHANNEL 34 #define IEEE80211_52GHZ_MAX_CHANNEL 165 -#define IEEE80211_52GHZ_CHANNELS 32 +#define IEEE80211_52GHZ_CHANNELS 131 enum { IEEE80211_CH_PASSIVE_ONLY = (1 << 0), -- cgit v1.2.3 From 68ee3eb8295c9c164071fcbd367c419121bd55f8 Mon Sep 17 00:00:00 2001 From: Kyle McMartin Date: Sun, 29 Jan 2006 20:25:49 -0700 Subject: [PARISC] New syscalls (inotify, *at, pselect6/ppoll, migrate_pages) Wire up some new syscalls that have been merged upstream, o inotify o openat et al o pselect6/ppoll o migrate_pages Signed-off-by: Kyle McMartin --- arch/parisc/kernel/syscall_table.S | 19 +++++++++++++++++++ include/asm-parisc/unistd.h | 21 ++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S index 32cbc0489324..51d2480627d1 100644 --- a/arch/parisc/kernel/syscall_table.S +++ b/arch/parisc/kernel/syscall_table.S @@ -374,5 +374,24 @@ ENTRY_SAME(keyctl) ENTRY_SAME(ioprio_set) ENTRY_SAME(ioprio_get) + ENTRY_SAME(inotify_init) + ENTRY_SAME(inotify_add_watch) /* 270 */ + ENTRY_SAME(inotify_rm_watch) + ENTRY_COMP(pselect6) + ENTRY_COMP(ppoll) + ENTRY_SAME(migrate_pages) + ENTRY_COMP(openat) /* 275 */ + ENTRY_SAME(mkdirat) + ENTRY_SAME(mknodat) + ENTRY_SAME(fchownat) + ENTRY_COMP(futimesat) + ENTRY_COMP(newfstatat) /* 280 */ + ENTRY_SAME(unlinkat) + ENTRY_SAME(renameat) + ENTRY_SAME(linkat) + ENTRY_SAME(symlinkat) + ENTRY_SAME(readlinkat) /* 285 */ + ENTRY_SAME(fchmodat) + ENTRY_SAME(faccessat) /* Nothing yet */ diff --git a/include/asm-parisc/unistd.h b/include/asm-parisc/unistd.h index 80b7b98c70a1..c56fccbf34ad 100644 --- a/include/asm-parisc/unistd.h +++ b/include/asm-parisc/unistd.h @@ -761,8 +761,27 @@ #define __NR_keyctl (__NR_Linux + 266) #define __NR_ioprio_set (__NR_Linux + 267) #define __NR_ioprio_get (__NR_Linux + 268) +#define __NR_inotify_init (__NR_Linux + 269) +#define __NR_inotify_add_watch (__NR_Linux + 270) +#define __NR_inotify_rm_watch (__NR_Linux + 271) +#define __NR_migrate_pages (__NR_Linux + 272) +#define __NR_pselect6 (__NR_Linux + 273) +#define __NR_ppoll (__NR_Linux + 274) +#define __NR_openat (__NR_Linux + 275) +#define __NR_mkdirat (__NR_Linux + 276) +#define __NR_mknodat (__NR_Linux + 277) +#define __NR_fchownat (__NR_Linux + 278) +#define __NR_futimesat (__NR_Linux + 279) +#define __NR_newfstatat (__NR_Linux + 280) +#define __NR_unlinkat (__NR_Linux + 281) +#define __NR_renameat (__NR_Linux + 282) +#define __NR_linkat (__NR_Linux + 283) +#define __NR_symlinkat (__NR_Linux + 284) +#define __NR_readlinkat (__NR_Linux + 285) +#define __NR_fchmodat (__NR_Linux + 286) +#define __NR_faccessat (__NR_Linux + 287) -#define __NR_Linux_syscalls 269 +#define __NR_Linux_syscalls 288 #define HPUX_GATEWAY_ADDR 0xC0000004 #define LINUX_GATEWAY_ADDR 0x100 -- cgit v1.2.3 From b8e4d89357fc434618a59c1047cac72641191805 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Fri, 27 Jan 2006 16:43:00 -0500 Subject: [ACPI] ACPICA 20060127 Implemented support in the Resource Manager to allow unresolved namestring references within resource package objects for the _PRT method. This support is in addition to the previously implemented unresolved reference support within the AML parser. If the interpreter slack mode is enabled (true on Linux unless acpi=strict), these unresolved references will be passed through to the caller as a NULL package entry. http://bugzilla.kernel.org/show_bug.cgi?id=5741 Implemented and deployed new macros and functions for error and warning messages across the subsystem. These macros are simpler and generate less code than their predecessors. The new macros ACPI_ERROR, ACPI_EXCEPTION, ACPI_WARNING, and ACPI_INFO replace the ACPI_REPORT_* macros. Implemented the acpi_cpu_flags type to simplify host OS integration of the Acquire/Release Lock OSL interfaces. Suggested by Steven Rostedt and Andrew Morton. Fixed a problem where Alias ASL operators are sometimes not correctly resolved. causing AE_AML_INTERNAL http://bugzilla.kernel.org/show_bug.cgi?id=5189 http://bugzilla.kernel.org/show_bug.cgi?id=5674 Fixed several problems with the implementation of the ConcatenateResTemplate ASL operator. As per the ACPI specification, zero length buffers are now treated as a single EndTag. One-length buffers always cause a fatal exception. Non-zero length buffers that do not end with a full 2-byte EndTag cause a fatal exception. Fixed a possible structure overwrite in the AcpiGetObjectInfo external interface. (With assistance from Thomas Renninger) Signed-off-by: Bob Moore Signed-off-by: Len Brown --- drivers/acpi/dispatcher/dsfield.c | 34 +++++---- drivers/acpi/dispatcher/dsinit.c | 14 ++-- drivers/acpi/dispatcher/dsmethod.c | 6 +- drivers/acpi/dispatcher/dsmthdat.c | 25 ++++--- drivers/acpi/dispatcher/dsobject.c | 20 +++--- drivers/acpi/dispatcher/dsopcode.c | 45 +++++++----- drivers/acpi/dispatcher/dsutils.c | 15 ++-- drivers/acpi/dispatcher/dswexec.c | 31 +++++--- drivers/acpi/dispatcher/dswload.c | 26 ++++--- drivers/acpi/dispatcher/dswscope.c | 4 +- drivers/acpi/dispatcher/dswstate.c | 94 ++++++++++++++---------- drivers/acpi/events/evevent.c | 19 +++-- drivers/acpi/events/evgpe.c | 42 +++++++---- drivers/acpi/events/evgpeblk.c | 50 ++++++++----- drivers/acpi/events/evmisc.c | 20 ++++-- drivers/acpi/events/evregion.c | 44 +++++++----- drivers/acpi/events/evrgnini.c | 6 +- drivers/acpi/events/evxface.c | 12 ++-- drivers/acpi/events/evxfevnt.c | 20 +++--- drivers/acpi/executer/exconfig.c | 4 +- drivers/acpi/executer/exconvrt.c | 11 ++- drivers/acpi/executer/excreate.c | 4 +- drivers/acpi/executer/exfield.c | 9 ++- drivers/acpi/executer/exfldio.c | 65 +++++++++++------ drivers/acpi/executer/exmisc.c | 43 ++++++----- drivers/acpi/executer/exmutex.c | 26 +++++-- drivers/acpi/executer/exnames.c | 13 ++-- drivers/acpi/executer/exoparg1.c | 57 +++++++++------ drivers/acpi/executer/exoparg2.c | 30 +++++--- drivers/acpi/executer/exoparg3.c | 8 +-- drivers/acpi/executer/exoparg6.c | 11 +-- drivers/acpi/executer/exprep.c | 25 +++++-- drivers/acpi/executer/exregion.c | 9 ++- drivers/acpi/executer/exresnte.c | 37 +++++----- drivers/acpi/executer/exresolv.c | 37 ++++++---- drivers/acpi/executer/exresop.c | 96 +++++++++++++++++++------ drivers/acpi/executer/exstore.c | 18 +++-- drivers/acpi/executer/exstoren.c | 17 +++-- drivers/acpi/executer/exsystem.c | 4 +- drivers/acpi/executer/exutils.c | 10 +-- drivers/acpi/hardware/hwacpi.c | 14 ++-- drivers/acpi/hardware/hwregs.c | 43 +++++++---- drivers/acpi/hardware/hwsleep.c | 21 +++--- drivers/acpi/namespace/nsaccess.c | 29 +++++--- drivers/acpi/namespace/nsalloc.c | 8 ++- drivers/acpi/namespace/nsdump.c | 8 +-- drivers/acpi/namespace/nseval.c | 2 +- drivers/acpi/namespace/nsinit.c | 18 ++--- drivers/acpi/namespace/nsload.c | 8 +-- drivers/acpi/namespace/nsnames.c | 6 +- drivers/acpi/namespace/nsobject.c | 11 +-- drivers/acpi/namespace/nssearch.c | 8 ++- drivers/acpi/namespace/nsutils.c | 12 ++-- drivers/acpi/namespace/nsxfeval.c | 18 ++--- drivers/acpi/namespace/nsxfname.c | 3 +- drivers/acpi/osl.c | 8 +-- drivers/acpi/parser/psargs.c | 10 +-- drivers/acpi/parser/psloop.c | 15 ++-- drivers/acpi/parser/psparse.c | 9 +-- drivers/acpi/parser/pstree.c | 4 +- drivers/acpi/resources/rscalc.c | 14 ++-- drivers/acpi/resources/rscreate.c | 144 ++++++++++++++++++++++--------------- drivers/acpi/resources/rsdump.c | 6 +- drivers/acpi/resources/rslist.c | 12 +++- drivers/acpi/resources/rsmisc.c | 28 +++++--- drivers/acpi/tables/tbconvrt.c | 17 +++-- drivers/acpi/tables/tbget.c | 37 +++++----- drivers/acpi/tables/tbgetall.c | 21 ++++-- drivers/acpi/tables/tbinstal.c | 10 +-- drivers/acpi/tables/tbrsdt.c | 18 +++-- drivers/acpi/tables/tbutils.c | 27 ++++--- drivers/acpi/tables/tbxface.c | 19 ++--- drivers/acpi/tables/tbxfroot.c | 21 ++++-- drivers/acpi/utilities/utalloc.c | 51 +++++++------ drivers/acpi/utilities/utcopy.c | 5 +- drivers/acpi/utilities/utdelete.c | 10 +-- drivers/acpi/utilities/uteval.c | 20 +++--- drivers/acpi/utilities/utglobal.c | 4 +- drivers/acpi/utilities/utinit.c | 8 +-- drivers/acpi/utilities/utmath.c | 8 +-- drivers/acpi/utilities/utmisc.c | 90 ++++++++++++++++------- drivers/acpi/utilities/utmutex.c | 29 ++++++-- drivers/acpi/utilities/utobject.c | 29 ++++---- drivers/acpi/utilities/utresrc.c | 16 +++++ drivers/acpi/utilities/utxface.c | 14 ++-- include/acpi/acconfig.h | 4 +- include/acpi/aclocal.h | 9 ++- include/acpi/acmacros.h | 87 +++++++++------------- include/acpi/acobject.h | 2 +- include/acpi/acpiosxf.h | 4 +- include/acpi/actypes.h | 41 +++++++++-- include/acpi/acutils.h | 25 ++++++- include/acpi/platform/acenv.h | 10 +-- include/acpi/platform/acgcc.h | 8 ++- include/acpi/platform/aclinux.h | 2 + 95 files changed, 1345 insertions(+), 821 deletions(-) (limited to 'include') diff --git a/drivers/acpi/dispatcher/dsfield.c b/drivers/acpi/dispatcher/dsfield.c index f3a008ff1eae..76bc0463f6de 100644 --- a/drivers/acpi/dispatcher/dsfield.c +++ b/drivers/acpi/dispatcher/dsfield.c @@ -128,7 +128,7 @@ acpi_ds_create_buffer_field(union acpi_parse_object *op, ACPI_IMODE_LOAD_PASS1, flags, walk_state, &(node)); if (ACPI_FAILURE(status)) { - ACPI_REPORT_NSERROR(arg->common.value.string, status); + ACPI_ERROR_NAMESPACE(arg->common.value.string, status); return_ACPI_STATUS(status); } } @@ -232,7 +232,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info, + (acpi_integer) arg->common.value.size; if (position > ACPI_UINT32_MAX) { - ACPI_REPORT_ERROR(("Bit offset within field too large (> 0xFFFFFFFF)\n")); + ACPI_ERROR((AE_INFO, + "Bit offset within field too large (> 0xFFFFFFFF)")); return_ACPI_STATUS(AE_SUPPORT); } @@ -268,8 +269,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info, ACPI_NS_DONT_OPEN_SCOPE, walk_state, &info->field_node); if (ACPI_FAILURE(status)) { - ACPI_REPORT_NSERROR((char *)&arg->named.name, - status); + ACPI_ERROR_NAMESPACE((char *)&arg->named.name, + status); if (status != AE_ALREADY_EXISTS) { return_ACPI_STATUS(status); } @@ -293,7 +294,11 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info, + (acpi_integer) arg->common.value.size; if (position > ACPI_UINT32_MAX) { - ACPI_REPORT_ERROR(("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", ACPI_CAST_PTR(char, &info->field_node->name))); + ACPI_ERROR((AE_INFO, + "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)", + ACPI_CAST_PTR(char, + &info->field_node-> + name))); return_ACPI_STATUS(AE_SUPPORT); } @@ -302,8 +307,9 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info, default: - ACPI_REPORT_ERROR(("Invalid opcode in field list: %X\n", - arg->common.aml_opcode)); + ACPI_ERROR((AE_INFO, + "Invalid opcode in field list: %X", + arg->common.aml_opcode)); return_ACPI_STATUS(AE_AML_BAD_OPCODE); } @@ -348,7 +354,7 @@ acpi_ds_create_field(union acpi_parse_object *op, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, ®ion_node); if (ACPI_FAILURE(status)) { - ACPI_REPORT_NSERROR(arg->common.value.name, status); + ACPI_ERROR_NAMESPACE(arg->common.value.name, status); return_ACPI_STATUS(status); } } @@ -430,8 +436,8 @@ acpi_ds_init_field_objects(union acpi_parse_object *op, ACPI_NS_ERROR_IF_FOUND, walk_state, &node); if (ACPI_FAILURE(status)) { - ACPI_REPORT_NSERROR((char *)&arg->named.name, - status); + ACPI_ERROR_NAMESPACE((char *)&arg->named.name, + status); if (status != AE_ALREADY_EXISTS) { return_ACPI_STATUS(status); } @@ -487,7 +493,7 @@ acpi_ds_create_bank_field(union acpi_parse_object *op, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, ®ion_node); if (ACPI_FAILURE(status)) { - ACPI_REPORT_NSERROR(arg->common.value.name, status); + ACPI_ERROR_NAMESPACE(arg->common.value.name, status); return_ACPI_STATUS(status); } } @@ -501,7 +507,7 @@ acpi_ds_create_bank_field(union acpi_parse_object *op, ACPI_NS_SEARCH_PARENT, walk_state, &info.register_node); if (ACPI_FAILURE(status)) { - ACPI_REPORT_NSERROR(arg->common.value.string, status); + ACPI_ERROR_NAMESPACE(arg->common.value.string, status); return_ACPI_STATUS(status); } @@ -559,7 +565,7 @@ acpi_ds_create_index_field(union acpi_parse_object *op, ACPI_NS_SEARCH_PARENT, walk_state, &info.register_node); if (ACPI_FAILURE(status)) { - ACPI_REPORT_NSERROR(arg->common.value.string, status); + ACPI_ERROR_NAMESPACE(arg->common.value.string, status); return_ACPI_STATUS(status); } @@ -572,7 +578,7 @@ acpi_ds_create_index_field(union acpi_parse_object *op, ACPI_NS_SEARCH_PARENT, walk_state, &info.data_register_node); if (ACPI_FAILURE(status)) { - ACPI_REPORT_NSERROR(arg->common.value.string, status); + ACPI_ERROR_NAMESPACE(arg->common.value.string, status); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c index 258fbdfaa69c..e65a07ad2422 100644 --- a/drivers/acpi/dispatcher/dsinit.c +++ b/drivers/acpi/dispatcher/dsinit.c @@ -105,7 +105,10 @@ acpi_ds_init_one_object(acpi_handle obj_handle, status = acpi_ds_initialize_region(obj_handle); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Region %p [%4.4s] - Init failure, %s\n", obj_handle, acpi_ut_get_node_name(obj_handle), acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "During Region initialization %p [%4.4s]", + obj_handle, + acpi_ut_get_node_name(obj_handle))); } info->op_region_count++; @@ -144,7 +147,11 @@ acpi_ds_init_one_object(acpi_handle obj_handle, */ status = acpi_ds_parse_method(obj_handle); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("\n+Method %p [%4.4s] - parse failure, %s\n", obj_handle, acpi_ut_get_node_name(obj_handle), acpi_format_exception(status))); + ACPI_ERROR((AE_INFO, + "Method %p [%4.4s] - parse failure, %s", + obj_handle, + acpi_ut_get_node_name(obj_handle), + acpi_format_exception(status))); /* This parse failed, but we will continue parsing more methods */ } @@ -206,8 +213,7 @@ acpi_ds_initialize_objects(struct acpi_table_desc * table_desc, status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX, acpi_ds_init_one_object, &info, NULL); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("walk_namespace failed, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "During walk_namespace")); } ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index d861add3fc1f..c475546535b6 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c @@ -141,7 +141,8 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node * method_node, /* Prevent wraparound of thread count */ if (obj_desc->method.thread_count == ACPI_UINT8_MAX) { - ACPI_REPORT_ERROR(("Method reached maximum reentrancy limit (255)\n")); + ACPI_ERROR((AE_INFO, + "Method reached maximum reentrancy limit (255)")); return_ACPI_STATUS(AE_AML_METHOD_LIMIT); } @@ -470,7 +471,8 @@ void acpi_ds_terminate_control_method(struct acpi_walk_state *walk_state) acpi_os_signal_semaphore(walk_state->method_desc->method. semaphore, 1); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not signal method semaphore\n")); + ACPI_ERROR((AE_INFO, + "Could not signal method semaphore")); /* Ignore error and continue cleanup */ } diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c index ce33c34f87c6..c025674f938b 100644 --- a/drivers/acpi/dispatcher/dsmthdat.c +++ b/drivers/acpi/dispatcher/dsmthdat.c @@ -260,7 +260,9 @@ acpi_ds_method_data_get_node(u16 opcode, case AML_LOCAL_OP: if (index > ACPI_METHOD_MAX_LOCAL) { - ACPI_REPORT_ERROR(("Local index %d is invalid (max %d)\n", index, ACPI_METHOD_MAX_LOCAL)); + ACPI_ERROR((AE_INFO, + "Local index %d is invalid (max %d)", + index, ACPI_METHOD_MAX_LOCAL)); return_ACPI_STATUS(AE_AML_INVALID_INDEX); } @@ -272,8 +274,9 @@ acpi_ds_method_data_get_node(u16 opcode, case AML_ARG_OP: if (index > ACPI_METHOD_MAX_ARG) { - ACPI_REPORT_ERROR(("Arg index %d is invalid (max %d)\n", - index, ACPI_METHOD_MAX_ARG)); + ACPI_ERROR((AE_INFO, + "Arg index %d is invalid (max %d)", + index, ACPI_METHOD_MAX_ARG)); return_ACPI_STATUS(AE_AML_INVALID_INDEX); } @@ -283,7 +286,7 @@ acpi_ds_method_data_get_node(u16 opcode, break; default: - ACPI_REPORT_ERROR(("Opcode %d is invalid\n", opcode)); + ACPI_ERROR((AE_INFO, "Opcode %d is invalid", opcode)); return_ACPI_STATUS(AE_AML_BAD_OPCODE); } @@ -374,7 +377,7 @@ acpi_ds_method_data_get_value(u16 opcode, /* Validate the object descriptor */ if (!dest_desc) { - ACPI_REPORT_ERROR(("Null object descriptor pointer\n")); + ACPI_ERROR((AE_INFO, "Null object descriptor pointer")); return_ACPI_STATUS(AE_BAD_PARAMETER); } @@ -419,18 +422,24 @@ acpi_ds_method_data_get_value(u16 opcode, switch (opcode) { case AML_ARG_OP: - ACPI_REPORT_ERROR(("Uninitialized Arg[%d] at node %p\n", index, node)); + ACPI_ERROR((AE_INFO, + "Uninitialized Arg[%d] at node %p", + index, node)); return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG); case AML_LOCAL_OP: - ACPI_REPORT_ERROR(("Uninitialized Local[%d] at node %p\n", index, node)); + ACPI_ERROR((AE_INFO, + "Uninitialized Local[%d] at node %p", + index, node)); return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL); default: - ACPI_REPORT_ERROR(("Not a Arg/Local opcode: %X\n", opcode)); + ACPI_ERROR((AE_INFO, + "Not a Arg/Local opcode: %X", + opcode)); return_ACPI_STATUS(AE_AML_INTERNAL); } } diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c index dc116d679a58..8b21f0f9e517 100644 --- a/drivers/acpi/dispatcher/dsobject.c +++ b/drivers/acpi/dispatcher/dsobject.c @@ -129,8 +129,8 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state, return_ACPI_STATUS(AE_OK); } else { - ACPI_REPORT_NSERROR(op->common.value. - string, status); + ACPI_ERROR_NAMESPACE(op->common.value. + string, status); } return_ACPI_STATUS(status); @@ -214,7 +214,9 @@ acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state, byte_list = arg->named.next; if (byte_list) { if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) { - ACPI_REPORT_ERROR(("Expecting bytelist, got AML opcode %X in op %p\n", byte_list->common.aml_opcode, byte_list)); + ACPI_ERROR((AE_INFO, + "Expecting bytelist, got AML opcode %X in op %p", + byte_list->common.aml_opcode, byte_list)); acpi_ut_remove_reference(obj_desc); return (AE_TYPE); @@ -540,7 +542,9 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, default: - ACPI_REPORT_ERROR(("Unknown constant opcode %X\n", opcode)); + ACPI_ERROR((AE_INFO, + "Unknown constant opcode %X", + opcode)); status = AE_AML_OPERAND_TYPE; break; } @@ -555,8 +559,8 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, break; default: - ACPI_REPORT_ERROR(("Unknown Integer type %X\n", - op_info->type)); + ACPI_ERROR((AE_INFO, "Unknown Integer type %X", + op_info->type)); status = AE_AML_OPERAND_TYPE; break; } @@ -634,8 +638,8 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, default: - ACPI_REPORT_ERROR(("Unimplemented data type: %X\n", - ACPI_GET_OBJECT_TYPE(obj_desc))); + ACPI_ERROR((AE_INFO, "Unimplemented data type: %X", + ACPI_GET_OBJECT_TYPE(obj_desc))); status = AE_AML_OPERAND_TYPE; break; diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c index 60414ee84b0a..6229c10674e1 100644 --- a/drivers/acpi/dispatcher/dsopcode.c +++ b/drivers/acpi/dispatcher/dsopcode.c @@ -245,7 +245,9 @@ acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc) node = obj_desc->buffer.node; if (!node) { - ACPI_REPORT_ERROR(("No pointer back to NS node in buffer obj %p\n", obj_desc)); + ACPI_ERROR((AE_INFO, + "No pointer back to NS node in buffer obj %p", + obj_desc)); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -287,8 +289,9 @@ acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc) node = obj_desc->package.node; if (!node) { - ACPI_REPORT_ERROR(("No pointer back to NS node in package %p\n", - obj_desc)); + ACPI_ERROR((AE_INFO, + "No pointer back to NS node in package %p", + obj_desc)); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -413,7 +416,9 @@ acpi_ds_init_buffer_field(u16 aml_opcode, /* Host object must be a Buffer */ if (ACPI_GET_OBJECT_TYPE(buffer_desc) != ACPI_TYPE_BUFFER) { - ACPI_REPORT_ERROR(("Target of Create Field is not a Buffer object - %s\n", acpi_ut_get_object_type_name(buffer_desc))); + ACPI_ERROR((AE_INFO, + "Target of Create Field is not a Buffer object - %s", + acpi_ut_get_object_type_name(buffer_desc))); status = AE_AML_OPERAND_TYPE; goto cleanup; @@ -425,9 +430,10 @@ acpi_ds_init_buffer_field(u16 aml_opcode, * after resolution in acpi_ex_resolve_operands(). */ if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) { - ACPI_REPORT_ERROR(("(%s) destination not a NS Node [%s]\n", - acpi_ps_get_opcode_name(aml_opcode), - acpi_ut_get_descriptor_name(result_desc))); + ACPI_ERROR((AE_INFO, + "(%s) destination not a NS Node [%s]", + acpi_ps_get_opcode_name(aml_opcode), + acpi_ut_get_descriptor_name(result_desc))); status = AE_AML_OPERAND_TYPE; goto cleanup; @@ -450,7 +456,8 @@ acpi_ds_init_buffer_field(u16 aml_opcode, /* Must have a valid (>0) bit count */ if (bit_count == 0) { - ACPI_REPORT_ERROR(("Attempt to create_field of length 0\n")); + ACPI_ERROR((AE_INFO, + "Attempt to create_field of length zero")); status = AE_AML_OPERAND_VALUE; goto cleanup; } @@ -503,8 +510,8 @@ acpi_ds_init_buffer_field(u16 aml_opcode, default: - ACPI_REPORT_ERROR(("Unknown field creation opcode %02x\n", - aml_opcode)); + ACPI_ERROR((AE_INFO, + "Unknown field creation opcode %02x", aml_opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } @@ -512,7 +519,12 @@ acpi_ds_init_buffer_field(u16 aml_opcode, /* Entire field must fit within the current length of the buffer */ if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) { - ACPI_REPORT_ERROR(("Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n", acpi_ut_get_node_name(result_desc), bit_offset + bit_count, acpi_ut_get_node_name(buffer_desc->buffer.node), 8 * (u32) buffer_desc->buffer.length)); + ACPI_ERROR((AE_INFO, + "Field [%4.4s] at %d exceeds Buffer [%4.4s] size %d (bits)", + acpi_ut_get_node_name(result_desc), + bit_offset + bit_count, + acpi_ut_get_node_name(buffer_desc->buffer.node), + 8 * (u32) buffer_desc->buffer.length)); status = AE_AML_BUFFER_LIMIT; goto cleanup; } @@ -618,10 +630,9 @@ acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state, "after acpi_ex_resolve_operands"); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("(%s) bad operand(s) (%X)\n", - acpi_ps_get_opcode_name(op->common. - aml_opcode), - status)); + ACPI_ERROR((AE_INFO, "(%s) bad operand(s) (%X)", + acpi_ps_get_opcode_name(op->common.aml_opcode), + status)); return_ACPI_STATUS(status); } @@ -1145,8 +1156,8 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state, default: - ACPI_REPORT_ERROR(("Unknown control opcode=%X Op=%p\n", - op->common.aml_opcode, op)); + ACPI_ERROR((AE_INFO, "Unknown control opcode=%X Op=%p", + op->common.aml_opcode, op)); status = AE_AML_BAD_OPCODE; break; diff --git a/drivers/acpi/dispatcher/dsutils.c b/drivers/acpi/dispatcher/dsutils.c index cd9aa7faa57b..53356a591ac1 100644 --- a/drivers/acpi/dispatcher/dsutils.c +++ b/drivers/acpi/dispatcher/dsutils.c @@ -176,7 +176,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, /* Must have both an Op and a Result Object */ if (!op) { - ACPI_REPORT_ERROR(("Null Op\n")); + ACPI_ERROR((AE_INFO, "Null Op")); return_UINT8(TRUE); } @@ -216,7 +216,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, parent_info = acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode); if (parent_info->class == AML_CLASS_UNKNOWN) { - ACPI_REPORT_ERROR(("Unknown parent opcode Op=%p\n", op)); + ACPI_ERROR((AE_INFO, "Unknown parent opcode Op=%p", op)); return_UINT8(FALSE); } @@ -343,7 +343,7 @@ acpi_ds_delete_result_if_not_used(union acpi_parse_object *op, ACPI_FUNCTION_TRACE_PTR("ds_delete_result_if_not_used", result_obj); if (!op) { - ACPI_REPORT_ERROR(("Null Op\n")); + ACPI_ERROR((AE_INFO, "Null Op")); return_VOID; } @@ -566,7 +566,7 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state, } if (ACPI_FAILURE(status)) { - ACPI_REPORT_NSERROR(name_string, status); + ACPI_ERROR_NAMESPACE(name_string, status); } } @@ -634,7 +634,8 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state, * Only error is underflow, and this indicates * a missing or null operand! */ - ACPI_REPORT_ERROR(("Missing or null operand, %s\n", acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Missing or null operand")); return_ACPI_STATUS(status); } } else { @@ -726,7 +727,7 @@ acpi_ds_create_operands(struct acpi_walk_state *walk_state, */ (void)acpi_ds_obj_stack_pop_and_delete(arg_count, walk_state); - ACPI_REPORT_ERROR(("While creating Arg %d - %s\n", - (arg_count + 1), acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "While creating Arg %d", + (arg_count + 1))); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c index 5a9b91fe93d2..f1af655ff113 100644 --- a/drivers/acpi/dispatcher/dswexec.c +++ b/drivers/acpi/dispatcher/dswexec.c @@ -100,7 +100,8 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state, if (result_obj) { status = acpi_ds_result_pop(&obj_desc, walk_state); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not get result from predicate evaluation, %s\n", acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not get result from predicate evaluation")); return_ACPI_STATUS(status); } @@ -121,8 +122,9 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state, } if (!obj_desc) { - ACPI_REPORT_ERROR(("No predicate obj_desc=%p State=%p\n", - obj_desc, walk_state)); + ACPI_ERROR((AE_INFO, + "No predicate obj_desc=%p State=%p", + obj_desc, walk_state)); return_ACPI_STATUS(AE_AML_NO_OPERAND); } @@ -137,7 +139,10 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state, } if (ACPI_GET_OBJECT_TYPE(local_obj_desc) != ACPI_TYPE_INTEGER) { - ACPI_REPORT_ERROR(("Bad predicate (not an integer) obj_desc=%p State=%p Type=%X\n", obj_desc, walk_state, ACPI_GET_OBJECT_TYPE(obj_desc))); + ACPI_ERROR((AE_INFO, + "Bad predicate (not an integer) obj_desc=%p State=%p Type=%X", + obj_desc, walk_state, + ACPI_GET_OBJECT_TYPE(obj_desc))); status = AE_AML_OPERAND_TYPE; goto cleanup; @@ -356,8 +361,8 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) op_class = walk_state->op_info->class; if (op_class == AML_CLASS_UNKNOWN) { - ACPI_REPORT_ERROR(("Unknown opcode %X\n", - op->common.aml_opcode)); + ACPI_ERROR((AE_INFO, "Unknown opcode %X", + op->common.aml_opcode)); return_ACPI_STATUS(AE_NOT_IMPLEMENTED); } @@ -447,7 +452,10 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) walk_state->operands[1]->reference.offset)) { status = AE_OK; } else { - ACPI_REPORT_ERROR(("[%s]: Could not resolve operands, %s\n", acpi_ps_get_opcode_name(walk_state->opcode), acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "While resolving operands for [%s]", + acpi_ps_get_opcode_name + (walk_state->opcode))); } } @@ -666,8 +674,8 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) case AML_TYPE_UNDEFINED: - ACPI_REPORT_ERROR(("Undefined opcode type Op=%p\n", - op)); + ACPI_ERROR((AE_INFO, + "Undefined opcode type Op=%p", op)); return_ACPI_STATUS(AE_NOT_IMPLEMENTED); case AML_TYPE_BOGUS: @@ -679,7 +687,10 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n", op_class, op_type, op->common.aml_opcode, op)); + ACPI_ERROR((AE_INFO, + "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p", + op_class, op_type, op->common.aml_opcode, + op)); status = AE_NOT_IMPLEMENTED; break; diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c index 4cad6afa82f7..d3d24da31c81 100644 --- a/drivers/acpi/dispatcher/dswload.c +++ b/drivers/acpi/dispatcher/dswload.c @@ -187,7 +187,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, } #endif if (ACPI_FAILURE(status)) { - ACPI_REPORT_NSERROR(path, status); + ACPI_ERROR_NAMESPACE(path, status); return_ACPI_STATUS(status); } @@ -233,7 +233,9 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, /* All other types are an error */ - ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n", acpi_ut_get_type_name(node->type), path)); + ACPI_ERROR((AE_INFO, + "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)", + acpi_ut_get_type_name(node->type), path)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -300,7 +302,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, ACPI_IMODE_LOAD_PASS1, flags, walk_state, &(node)); if (ACPI_FAILURE(status)) { - ACPI_REPORT_NSERROR(path, status); + ACPI_ERROR_NAMESPACE(path, status); return_ACPI_STATUS(status); } break; @@ -618,10 +620,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, if (status == AE_NOT_FOUND) { status = AE_OK; } else { - ACPI_REPORT_NSERROR(buffer_ptr, status); + ACPI_ERROR_NAMESPACE(buffer_ptr, status); } #else - ACPI_REPORT_NSERROR(buffer_ptr, status); + ACPI_ERROR_NAMESPACE(buffer_ptr, status); #endif return_ACPI_STATUS(status); } @@ -651,7 +653,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, * Scope (DEB) { ... } */ - ACPI_REPORT_WARNING(("Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", buffer_ptr, acpi_ut_get_type_name(node->type))); + ACPI_WARNING((AE_INFO, + "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)", + buffer_ptr, + acpi_ut_get_type_name(node->type))); node->type = ACPI_TYPE_ANY; walk_state->scope_info->common.value = ACPI_TYPE_ANY; @@ -661,7 +666,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, /* All other types are an error */ - ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s]\n", acpi_ut_get_type_name(node->type), buffer_ptr)); + ACPI_ERROR((AE_INFO, + "Invalid type (%s) for target of Scope operator [%4.4s]", + acpi_ut_get_type_name(node->type), + buffer_ptr)); return (AE_AML_OPERAND_TYPE); } @@ -714,7 +722,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state, } if (ACPI_FAILURE(status)) { - ACPI_REPORT_NSERROR(buffer_ptr, status); + ACPI_ERROR_NAMESPACE(buffer_ptr, status); return_ACPI_STATUS(status); } @@ -1112,7 +1120,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) */ op->common.node = new_node; } else { - ACPI_REPORT_NSERROR(arg->common.value.string, status); + ACPI_ERROR_NAMESPACE(arg->common.value.string, status); } break; diff --git a/drivers/acpi/dispatcher/dswscope.c b/drivers/acpi/dispatcher/dswscope.c index e7fc88ca47ba..ada21ef4a174 100644 --- a/drivers/acpi/dispatcher/dswscope.c +++ b/drivers/acpi/dispatcher/dswscope.c @@ -107,14 +107,14 @@ acpi_ds_scope_stack_push(struct acpi_namespace_node *node, if (!node) { /* Invalid scope */ - ACPI_REPORT_ERROR(("Null scope parameter\n")); + ACPI_ERROR((AE_INFO, "Null scope parameter")); return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Make sure object type is valid */ if (!acpi_ut_valid_object_type(type)) { - ACPI_REPORT_WARNING(("Invalid object type: 0x%X\n", type)); + ACPI_WARNING((AE_INFO, "Invalid object type: 0x%X", type)); } /* Allocate a new scope object */ diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c index 61aae2dcc5e2..fa78cb74ee36 100644 --- a/drivers/acpi/dispatcher/dswstate.c +++ b/drivers/acpi/dispatcher/dswstate.c @@ -92,23 +92,23 @@ acpi_ds_result_remove(union acpi_operand_object **object, state = walk_state->results; if (!state) { - ACPI_REPORT_ERROR(("No result object pushed! State=%p\n", - walk_state)); + ACPI_ERROR((AE_INFO, "No result object pushed! State=%p", + walk_state)); return (AE_NOT_EXIST); } if (index >= ACPI_OBJ_MAX_OPERAND) { - ACPI_REPORT_ERROR(("Index out of range: %X State=%p Num=%X\n", - index, walk_state, - state->results.num_results)); + ACPI_ERROR((AE_INFO, + "Index out of range: %X State=%p Num=%X", + index, walk_state, state->results.num_results)); } /* Check for a valid result object */ if (!state->results.obj_desc[index]) { - ACPI_REPORT_ERROR(("Null operand! State=%p #Ops=%X, Index=%X\n", - walk_state, state->results.num_results, - index)); + ACPI_ERROR((AE_INFO, + "Null operand! State=%p #Ops=%X, Index=%X", + walk_state, state->results.num_results, index)); return (AE_AML_NO_RETURN_VALUE); } @@ -160,8 +160,8 @@ acpi_ds_result_pop(union acpi_operand_object ** object, } if (!state->results.num_results) { - ACPI_REPORT_ERROR(("Result stack is empty! State=%p\n", - walk_state)); + ACPI_ERROR((AE_INFO, "Result stack is empty! State=%p", + walk_state)); return (AE_AML_NO_RETURN_VALUE); } @@ -188,7 +188,7 @@ acpi_ds_result_pop(union acpi_operand_object ** object, } } - ACPI_REPORT_ERROR(("No result objects! State=%p\n", walk_state)); + ACPI_ERROR((AE_INFO, "No result objects! State=%p", walk_state)); return (AE_AML_NO_RETURN_VALUE); } @@ -217,14 +217,14 @@ acpi_ds_result_pop_from_bottom(union acpi_operand_object ** object, state = walk_state->results; if (!state) { - ACPI_REPORT_ERROR(("No result object pushed! State=%p\n", - walk_state)); + ACPI_ERROR((AE_INFO, + "No result object pushed! State=%p", walk_state)); return (AE_NOT_EXIST); } if (!state->results.num_results) { - ACPI_REPORT_ERROR(("No result objects! State=%p\n", - walk_state)); + ACPI_ERROR((AE_INFO, "No result objects! State=%p", + walk_state)); return (AE_AML_NO_RETURN_VALUE); } @@ -244,9 +244,10 @@ acpi_ds_result_pop_from_bottom(union acpi_operand_object ** object, /* Check for a valid result object */ if (!*object) { - ACPI_REPORT_ERROR(("Null operand! State=%p #Ops=%X Index=%X\n", - walk_state, state->results.num_results, - (u32) index)); + ACPI_ERROR((AE_INFO, + "Null operand! State=%p #Ops=%X Index=%X", + walk_state, state->results.num_results, + (u32) index)); return (AE_AML_NO_RETURN_VALUE); } @@ -281,19 +282,21 @@ acpi_ds_result_push(union acpi_operand_object * object, state = walk_state->results; if (!state) { - ACPI_REPORT_ERROR(("No result stack frame during push\n")); + ACPI_ERROR((AE_INFO, "No result stack frame during push")); return (AE_AML_INTERNAL); } if (state->results.num_results == ACPI_OBJ_NUM_OPERANDS) { - ACPI_REPORT_ERROR(("Result stack overflow: Obj=%p State=%p Num=%X\n", object, walk_state, state->results.num_results)); + ACPI_ERROR((AE_INFO, + "Result stack overflow: Obj=%p State=%p Num=%X", + object, walk_state, state->results.num_results)); return (AE_STACK_OVERFLOW); } if (!object) { - ACPI_REPORT_ERROR(("Null Object! Obj=%p State=%p Num=%X\n", - object, walk_state, - state->results.num_results)); + ACPI_ERROR((AE_INFO, + "Null Object! Obj=%p State=%p Num=%X", + object, walk_state, state->results.num_results)); return (AE_BAD_PARAMETER); } @@ -402,7 +405,9 @@ acpi_ds_obj_stack_push(void *object, struct acpi_walk_state * walk_state) /* Check for stack overflow */ if (walk_state->num_operands >= ACPI_OBJ_NUM_OPERANDS) { - ACPI_REPORT_ERROR(("Object stack overflow! Obj=%p State=%p #Ops=%X\n", object, walk_state, walk_state->num_operands)); + ACPI_ERROR((AE_INFO, + "Object stack overflow! Obj=%p State=%p #Ops=%X", + object, walk_state, walk_state->num_operands)); return (AE_STACK_OVERFLOW); } @@ -446,7 +451,10 @@ acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state * walk_state) /* Check for stack underflow */ if (walk_state->num_operands == 0) { - ACPI_REPORT_ERROR(("Object stack underflow! Count=%X State=%p #Ops=%X\n", pop_count, walk_state, walk_state->num_operands)); + ACPI_ERROR((AE_INFO, + "Object stack underflow! Count=%X State=%p #Ops=%X", + pop_count, walk_state, + walk_state->num_operands)); return (AE_STACK_UNDERFLOW); } @@ -489,7 +497,10 @@ acpi_ds_obj_stack_pop_and_delete(u32 pop_count, /* Check for stack underflow */ if (walk_state->num_operands == 0) { - ACPI_REPORT_ERROR(("Object stack underflow! Count=%X State=%p #Ops=%X\n", pop_count, walk_state, walk_state->num_operands)); + ACPI_ERROR((AE_INFO, + "Object stack underflow! Count=%X State=%p #Ops=%X", + pop_count, walk_state, + walk_state->num_operands)); return (AE_STACK_UNDERFLOW); } @@ -806,14 +817,14 @@ void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state) } if (walk_state->data_type != ACPI_DESC_TYPE_WALK) { - ACPI_REPORT_ERROR(("%p is not a valid walk state\n", - walk_state)); + ACPI_ERROR((AE_INFO, "%p is not a valid walk state", + walk_state)); return; } if (walk_state->parser_state.scope) { - ACPI_REPORT_ERROR(("%p walk still has a scope list\n", - walk_state)); + ACPI_ERROR((AE_INFO, "%p walk still has a scope list", + walk_state)); } /* Always must free any linked control states */ @@ -872,18 +883,24 @@ acpi_ds_result_insert(void *object, state = walk_state->results; if (!state) { - ACPI_REPORT_ERROR(("No result object pushed! State=%p\n", - walk_state)); + ACPI_ERROR((AE_INFO, "No result object pushed! State=%p", + walk_state)); return (AE_NOT_EXIST); } if (index >= ACPI_OBJ_NUM_OPERANDS) { - ACPI_REPORT_ERROR(("Index out of range: %X Obj=%p State=%p Num=%X\n", index, object, walk_state, state->results.num_results)); + ACPI_ERROR((AE_INFO, + "Index out of range: %X Obj=%p State=%p Num=%X", + index, object, walk_state, + state->results.num_results)); return (AE_BAD_PARAMETER); } if (!object) { - ACPI_REPORT_ERROR(("Null Object! Index=%X Obj=%p State=%p Num=%X\n", index, object, walk_state, state->results.num_results)); + ACPI_ERROR((AE_INFO, + "Null Object! Index=%X Obj=%p State=%p Num=%X", + index, object, walk_state, + state->results.num_results)); return (AE_BAD_PARAMETER); } @@ -957,7 +974,9 @@ acpi_ds_obj_stack_pop_object(union acpi_operand_object **object, /* Check for stack underflow */ if (walk_state->num_operands == 0) { - ACPI_REPORT_ERROR(("Missing operand/stack empty! State=%p #Ops=%X\n", walk_state, walk_state->num_operands)); + ACPI_ERROR((AE_INFO, + "Missing operand/stack empty! State=%p #Ops=%X", + walk_state, walk_state->num_operands)); *object = NULL; return (AE_AML_NO_OPERAND); } @@ -969,8 +988,9 @@ acpi_ds_obj_stack_pop_object(union acpi_operand_object **object, /* Check for a valid operand */ if (!walk_state->operands[walk_state->num_operands]) { - ACPI_REPORT_ERROR(("Null operand! State=%p #Ops=%X\n", - walk_state, walk_state->num_operands)); + ACPI_ERROR((AE_INFO, + "Null operand! State=%p #Ops=%X", + walk_state, walk_state->num_operands)); *object = NULL; return (AE_AML_NO_OPERAND); } diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/events/evevent.c index b380ae1044b7..c9ac05c4685f 100644 --- a/drivers/acpi/events/evevent.c +++ b/drivers/acpi/events/evevent.c @@ -73,7 +73,7 @@ acpi_status acpi_ev_initialize_events(void) /* Make sure we have ACPI tables */ if (!acpi_gbl_DSDT) { - ACPI_REPORT_WARNING(("No ACPI tables present!\n")); + ACPI_WARNING((AE_INFO, "No ACPI tables present!")); return_ACPI_STATUS(AE_NO_ACPI_TABLES); } @@ -84,14 +84,15 @@ acpi_status acpi_ev_initialize_events(void) */ status = acpi_ev_fixed_event_initialize(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Unable to initialize fixed events, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Unable to initialize fixed events")); return_ACPI_STATUS(status); } status = acpi_ev_gpe_initialize(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Unable to initialize general purpose events, %s\n", acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Unable to initialize general purpose events")); return_ACPI_STATUS(status); } @@ -162,7 +163,8 @@ acpi_status acpi_ev_install_xrupt_handlers(void) status = acpi_ev_install_sci_handler(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Unable to install System Control Interrupt Handler, %s\n", acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Unable to install System Control Interrupt handler")); return_ACPI_STATUS(status); } @@ -170,7 +172,8 @@ acpi_status acpi_ev_install_xrupt_handlers(void) status = acpi_ev_init_global_lock_handler(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Unable to initialize Global Lock handler, %s\n", acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Unable to initialize Global Lock handler")); return_ACPI_STATUS(status); } @@ -304,7 +307,9 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event) enable_register_id, 0, ACPI_MTX_DO_NOT_LOCK); - ACPI_REPORT_ERROR(("No installed handler for fixed event [%08X]\n", event)); + ACPI_ERROR((AE_INFO, + "No installed handler for fixed event [%08X]", + event)); return (ACPI_INTERRUPT_NOT_HANDLED); } diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c index 353b907edbfa..f64f977dd3d5 100644 --- a/drivers/acpi/events/evgpe.c +++ b/drivers/acpi/events/evgpe.c @@ -379,7 +379,7 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) u8 enabled_status_byte; u32 status_reg; u32 enable_reg; - acpi_native_uint flags; + acpi_cpu_flags flags; acpi_native_uint i; acpi_native_uint j; @@ -546,7 +546,11 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context) status = acpi_ns_evaluate_by_handle(&info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("%s while evaluating method [%4.4s] for GPE[%2X]\n", acpi_format_exception(status), acpi_ut_get_node_name(local_gpe_event_info.dispatch.method_node), gpe_number)); + ACPI_EXCEPTION((AE_INFO, status, + "While evaluating method [%4.4s] for GPE[%2X]", + acpi_ut_get_node_name + (local_gpe_event_info.dispatch. + method_node), gpe_number)); } } @@ -599,9 +603,9 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) ACPI_GPE_EDGE_TRIGGERED) { status = acpi_hw_clear_gpe(gpe_event_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("%s, Unable to clear GPE[%2X]\n", - acpi_format_exception(status), - gpe_number)); + ACPI_EXCEPTION((AE_INFO, status, + "Unable to clear GPE[%2X]", + gpe_number)); return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); } } @@ -639,7 +643,9 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) ACPI_GPE_LEVEL_TRIGGERED) { status = acpi_hw_clear_gpe(gpe_event_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("%s, Unable to clear GPE[%2X]\n", acpi_format_exception(status), gpe_number)); + ACPI_EXCEPTION((AE_INFO, status, + "Unable to clear GPE[%2X]", + gpe_number)); return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); } } @@ -653,9 +659,9 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) */ status = acpi_ev_disable_gpe(gpe_event_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("%s, Unable to disable GPE[%2X]\n", - acpi_format_exception(status), - gpe_number)); + ACPI_EXCEPTION((AE_INFO, status, + "Unable to disable GPE[%2X]", + gpe_number)); return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); } @@ -667,7 +673,9 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) acpi_ev_asynch_execute_gpe_method, gpe_event_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("%s, Unable to queue handler for GPE[%2X] - event disabled\n", acpi_format_exception(status), gpe_number)); + ACPI_EXCEPTION((AE_INFO, status, + "Unable to queue handler for GPE[%2X] - event disabled", + gpe_number)); } break; @@ -675,7 +683,9 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) /* No handler or method to run! */ - ACPI_REPORT_ERROR(("No handler or method for GPE[%2X], disabling event\n", gpe_number)); + ACPI_ERROR((AE_INFO, + "No handler or method for GPE[%2X], disabling event", + gpe_number)); /* * Disable the GPE. The GPE will remain disabled until the ACPI @@ -683,9 +693,9 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) */ status = acpi_ev_disable_gpe(gpe_event_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("%s, Unable to disable GPE[%2X]\n", - acpi_format_exception(status), - gpe_number)); + ACPI_EXCEPTION((AE_INFO, status, + "Unable to disable GPE[%2X]", + gpe_number)); return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); } break; @@ -728,7 +738,9 @@ acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info) acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE); - ACPI_REPORT_INFO(("GPE %p was updated from wake/run to wake-only\n", gpe_event_info)); + ACPI_INFO((AE_INFO, + "GPE %p was updated from wake/run to wake-only", + gpe_event_info)); /* This was a wake-only GPE */ diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c index 3b9bbdda551d..0fd00b5ad650 100644 --- a/drivers/acpi/events/evgpeblk.c +++ b/drivers/acpi/events/evgpeblk.c @@ -136,7 +136,7 @@ acpi_status acpi_ev_walk_gpe_list(ACPI_GPE_CALLBACK gpe_walk_callback) struct acpi_gpe_block_info *gpe_block; struct acpi_gpe_xrupt_info *gpe_xrupt_info; acpi_status status = AE_OK; - acpi_native_uint flags; + acpi_cpu_flags flags; ACPI_FUNCTION_TRACE("ev_walk_gpe_list"); @@ -279,7 +279,9 @@ acpi_ev_save_method_info(acpi_handle obj_handle, default: /* Unknown method type, just ignore it! */ - ACPI_REPORT_ERROR(("Unknown GPE method type: %s (name not of form _Lxx or _Exx)\n", name)); + ACPI_ERROR((AE_INFO, + "Unknown GPE method type: %s (name not of form _Lxx or _Exx)", + name)); return_ACPI_STATUS(AE_OK); } @@ -289,7 +291,9 @@ acpi_ev_save_method_info(acpi_handle obj_handle, if (gpe_number == ACPI_UINT32_MAX) { /* Conversion failed; invalid method, just ignore it */ - ACPI_REPORT_ERROR(("Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)\n", name)); + ACPI_ERROR((AE_INFO, + "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)", + name)); return_ACPI_STATUS(AE_OK); } @@ -476,7 +480,7 @@ static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 struct acpi_gpe_xrupt_info *next_gpe_xrupt; struct acpi_gpe_xrupt_info *gpe_xrupt; acpi_status status; - acpi_native_uint flags; + acpi_cpu_flags flags; ACPI_FUNCTION_TRACE("ev_get_gpe_xrupt_block"); @@ -523,7 +527,9 @@ static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 acpi_ev_gpe_xrupt_handler, gpe_xrupt); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not install GPE interrupt handler at level 0x%X\n", interrupt_number)); + ACPI_ERROR((AE_INFO, + "Could not install GPE interrupt handler at level 0x%X", + interrupt_number)); return_PTR(NULL); } } @@ -548,7 +554,7 @@ static acpi_status acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt) { acpi_status status; - acpi_native_uint flags; + acpi_cpu_flags flags; ACPI_FUNCTION_TRACE("ev_delete_gpe_xrupt"); @@ -606,7 +612,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, struct acpi_gpe_block_info *next_gpe_block; struct acpi_gpe_xrupt_info *gpe_xrupt_block; acpi_status status; - acpi_native_uint flags; + acpi_cpu_flags flags; ACPI_FUNCTION_TRACE("ev_install_gpe_block"); @@ -659,7 +665,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block) { acpi_status status; - acpi_native_uint flags; + acpi_cpu_flags flags; ACPI_FUNCTION_TRACE("ev_install_gpe_block"); @@ -739,7 +745,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block) sizeof(struct acpi_gpe_register_info)); if (!gpe_register_info) { - ACPI_REPORT_ERROR(("Could not allocate the gpe_register_info table\n")); + ACPI_ERROR((AE_INFO, + "Could not allocate the gpe_register_info table")); return_ACPI_STATUS(AE_NO_MEMORY); } @@ -752,7 +759,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block) ACPI_GPE_REGISTER_WIDTH) * sizeof(struct acpi_gpe_event_info)); if (!gpe_event_info) { - ACPI_REPORT_ERROR(("Could not allocate the gpe_event_info table\n")); + ACPI_ERROR((AE_INFO, + "Could not allocate the gpe_event_info table")); status = AE_NO_MEMORY; goto error_exit; } @@ -1032,8 +1040,8 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not enable GPEs in gpe_block %p\n", - gpe_block)); + ACPI_ERROR((AE_INFO, "Could not enable GPEs in gpe_block %p", + gpe_block)); } return_ACPI_STATUS(status); @@ -1107,8 +1115,8 @@ acpi_status acpi_ev_gpe_initialize(void) &acpi_gbl_gpe_fadt_blocks[0]); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not create GPE Block 0, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not create GPE Block 0")); } } @@ -1121,7 +1129,12 @@ acpi_status acpi_ev_gpe_initialize(void) if ((register_count0) && (gpe_number_max >= acpi_gbl_FADT->gpe1_base)) { - ACPI_REPORT_ERROR(("GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1\n", gpe_number_max, acpi_gbl_FADT->gpe1_base, acpi_gbl_FADT->gpe1_base + ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1))); + ACPI_ERROR((AE_INFO, + "GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1", + gpe_number_max, acpi_gbl_FADT->gpe1_base, + acpi_gbl_FADT->gpe1_base + + ((register_count1 * + ACPI_GPE_REGISTER_WIDTH) - 1))); /* Ignore GPE1 block by setting the register count to zero */ @@ -1139,7 +1152,8 @@ acpi_status acpi_ev_gpe_initialize(void) [1]); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not create GPE Block 1, %s\n", acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not create GPE Block 1")); } /* @@ -1165,7 +1179,9 @@ acpi_status acpi_ev_gpe_initialize(void) /* Check for Max GPE number out-of-range */ if (gpe_number_max > ACPI_GPE_MAX) { - ACPI_REPORT_ERROR(("Maximum GPE number from FADT is too large: 0x%X\n", gpe_number_max)); + ACPI_ERROR((AE_INFO, + "Maximum GPE number from FADT is too large: 0x%X", + gpe_number_max)); status = AE_BAD_VALUE; goto cleanup; } diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c index 78883239784a..0909ba69577e 100644 --- a/drivers/acpi/events/evmisc.c +++ b/drivers/acpi/events/evmisc.c @@ -303,7 +303,8 @@ static void ACPI_SYSTEM_XFACE acpi_ev_global_lock_thread(void *context) acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore, acpi_gbl_global_lock_thread_count); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not signal Global Lock semaphore\n")); + ACPI_ERROR((AE_INFO, + "Could not signal Global Lock semaphore")); } } } @@ -344,7 +345,8 @@ static u32 acpi_ev_global_lock_handler(void *context) acpi_ev_global_lock_thread, context); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not queue Global Lock thread, %s\n", acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not queue Global Lock thread")); return (ACPI_INTERRUPT_NOT_HANDLED); } @@ -384,7 +386,8 @@ acpi_status acpi_ev_init_global_lock_handler(void) * with an error. */ if (status == AE_NO_HARDWARE_RESPONSE) { - ACPI_REPORT_ERROR(("No response from Global Lock hardware, disabling lock\n")); + ACPI_ERROR((AE_INFO, + "No response from Global Lock hardware, disabling lock")); acpi_gbl_global_lock_present = FALSE; status = AE_OK; @@ -480,7 +483,8 @@ acpi_status acpi_ev_release_global_lock(void) ACPI_FUNCTION_TRACE("ev_release_global_lock"); if (!acpi_gbl_global_lock_thread_count) { - ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n")); + ACPI_WARNING((AE_INFO, + "Cannot release HW Global Lock, it has not been acquired")); return_ACPI_STATUS(AE_NOT_ACQUIRED); } @@ -542,7 +546,9 @@ void acpi_ev_terminate(void) for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { status = acpi_disable_event((u32) i, 0); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not disable fixed event %d\n", (u32) i)); + ACPI_ERROR((AE_INFO, + "Could not disable fixed event %d", + (u32) i)); } } @@ -554,7 +560,7 @@ void acpi_ev_terminate(void) status = acpi_ev_remove_sci_handler(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not remove SCI handler\n")); + ACPI_ERROR((AE_INFO, "Could not remove SCI handler")); } } @@ -567,7 +573,7 @@ void acpi_ev_terminate(void) if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) { status = acpi_disable(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_WARNING(("acpi_disable failed\n")); + ACPI_WARNING((AE_INFO, "acpi_disable failed")); } } return_VOID; diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c index 900e5b32e595..6da58e776413 100644 --- a/drivers/acpi/events/evregion.c +++ b/drivers/acpi/events/evregion.c @@ -295,11 +295,12 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, handler_desc = region_obj->region.handler; if (!handler_desc) { - ACPI_REPORT_ERROR(("No handler for Region [%4.4s] (%p) [%s]\n", - acpi_ut_get_node_name(region_obj->region. - node), region_obj, - acpi_ut_get_region_name(region_obj->region. - space_id))); + ACPI_ERROR((AE_INFO, + "No handler for Region [%4.4s] (%p) [%s]", + acpi_ut_get_node_name(region_obj->region.node), + region_obj, + acpi_ut_get_region_name(region_obj->region. + space_id))); return_ACPI_STATUS(AE_NOT_EXIST); } @@ -316,7 +317,11 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, if (!region_setup) { /* No initialization routine, exit with error */ - ACPI_REPORT_ERROR(("No init routine for region(%p) [%s]\n", region_obj, acpi_ut_get_region_name(region_obj->region.space_id))); + ACPI_ERROR((AE_INFO, + "No init routine for region(%p) [%s]", + region_obj, + acpi_ut_get_region_name(region_obj->region. + space_id))); return_ACPI_STATUS(AE_NOT_EXIST); } @@ -341,11 +346,11 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, /* Check for failure of the Region Setup */ if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Region Initialization: %s [%s]\n", - acpi_format_exception(status), - acpi_ut_get_region_name(region_obj-> - region. - space_id))); + ACPI_EXCEPTION((AE_INFO, status, + "During region initialization: [%s]", + acpi_ut_get_region_name(region_obj-> + region. + space_id))); return_ACPI_STATUS(status); } @@ -399,10 +404,9 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, region_obj2->extra.region_context); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Handler for [%s] returned %s\n", - acpi_ut_get_region_name(region_obj->region. - space_id), - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "Returned by Handler for [%s]", + acpi_ut_get_region_name(region_obj->region. + space_id))); } if (! @@ -494,7 +498,10 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj, status = acpi_ev_execute_reg_method(region_obj, 0); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("%s from region _REG, [%s]\n", acpi_format_exception(status), acpi_ut_get_region_name(region_obj->region.space_id))); + ACPI_EXCEPTION((AE_INFO, status, + "from region _REG, [%s]", + acpi_ut_get_region_name + (region_obj->region.space_id))); } if (acpi_ns_is_locked) { @@ -516,7 +523,10 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj, /* Init routine may fail, Just ignore errors */ if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("%s from region init, [%s]\n", acpi_format_exception(status), acpi_ut_get_region_name(region_obj->region.space_id))); + ACPI_EXCEPTION((AE_INFO, status, + "from region init, [%s]", + acpi_ut_get_region_name + (region_obj->region.space_id))); } region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE); diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c index de1a38e9ce22..baed8c1a1b9f 100644 --- a/drivers/acpi/events/evrgnini.c +++ b/drivers/acpi/events/evrgnini.c @@ -233,7 +233,11 @@ acpi_ev_pci_config_region_setup(acpi_handle handle, */ status = AE_OK; } else { - ACPI_REPORT_ERROR(("Could not install pci_config handler for Root Bridge %4.4s, %s\n", acpi_ut_get_node_name(pci_root_node), acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, + status, + "Could not install pci_config handler for Root Bridge %4.4s", + acpi_ut_get_node_name + (pci_root_node))); } } break; diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c index b2f69b1ac4b5..b38b39dde543 100644 --- a/drivers/acpi/events/evxface.c +++ b/drivers/acpi/events/evxface.c @@ -143,8 +143,8 @@ acpi_install_fixed_event_handler(u32 event, if (ACPI_SUCCESS(status)) status = acpi_enable_event(event, 0); if (ACPI_FAILURE(status)) { - ACPI_REPORT_WARNING(("Could not enable fixed event %X\n", - event)); + ACPI_WARNING((AE_INFO, "Could not enable fixed event %X", + event)); /* Remove the handler */ @@ -204,7 +204,9 @@ acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler) acpi_gbl_fixed_event_handlers[event].context = NULL; if (ACPI_FAILURE(status)) { - ACPI_REPORT_WARNING(("Could not write to fixed event enable register %X\n", event)); + ACPI_WARNING((AE_INFO, + "Could not write to fixed event enable register %X", + event)); } else { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X\n", event)); @@ -561,7 +563,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device, struct acpi_gpe_event_info *gpe_event_info; struct acpi_handler_info *handler; acpi_status status; - acpi_native_uint flags; + acpi_cpu_flags flags; ACPI_FUNCTION_TRACE("acpi_install_gpe_handler"); @@ -652,7 +654,7 @@ acpi_remove_gpe_handler(acpi_handle gpe_device, struct acpi_gpe_event_info *gpe_event_info; struct acpi_handler_info *handler; acpi_status status; - acpi_native_uint flags; + acpi_cpu_flags flags; ACPI_FUNCTION_TRACE("acpi_remove_gpe_handler"); diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c index 90eb7939e986..ec9ce8429f15 100644 --- a/drivers/acpi/events/evxfevnt.c +++ b/drivers/acpi/events/evxfevnt.c @@ -70,7 +70,7 @@ acpi_status acpi_enable(void) /* Make sure we have the FADT */ if (!acpi_gbl_FADT) { - ACPI_REPORT_WARNING(("No FADT information present!\n")); + ACPI_WARNING((AE_INFO, "No FADT information present!")); return_ACPI_STATUS(AE_NO_ACPI_TABLES); } @@ -82,7 +82,8 @@ acpi_status acpi_enable(void) status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not transition to ACPI mode\n")); + ACPI_ERROR((AE_INFO, + "Could not transition to ACPI mode")); return_ACPI_STATUS(status); } @@ -112,7 +113,7 @@ acpi_status acpi_disable(void) ACPI_FUNCTION_TRACE("acpi_disable"); if (!acpi_gbl_FADT) { - ACPI_REPORT_WARNING(("No FADT information present!\n")); + ACPI_WARNING((AE_INFO, "No FADT information present!")); return_ACPI_STATUS(AE_NO_ACPI_TABLES); } @@ -125,7 +126,8 @@ acpi_status acpi_disable(void) status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not exit ACPI mode to legacy mode")); + ACPI_ERROR((AE_INFO, + "Could not exit ACPI mode to legacy mode")); return_ACPI_STATUS(status); } @@ -182,8 +184,9 @@ acpi_status acpi_enable_event(u32 event, u32 flags) } if (value != 1) { - ACPI_REPORT_ERROR(("Could not enable %s event\n", - acpi_ut_get_event_name(event))); + ACPI_ERROR((AE_INFO, + "Could not enable %s event", + acpi_ut_get_event_name(event))); return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); } @@ -380,8 +383,9 @@ acpi_status acpi_disable_event(u32 event, u32 flags) } if (value != 0) { - ACPI_REPORT_ERROR(("Could not disable %s events\n", - acpi_ut_get_event_name(event))); + ACPI_ERROR((AE_INFO, + "Could not disable %s events", + acpi_ut_get_event_name(event))); return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); } diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c index 109d0255a5bb..a29782fe3ecf 100644 --- a/drivers/acpi/executer/exconfig.c +++ b/drivers/acpi/executer/exconfig.c @@ -413,7 +413,9 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc, (!ACPI_STRNCMP(table_ptr->signature, acpi_gbl_table_data[ACPI_TABLE_SSDT].signature, acpi_gbl_table_data[ACPI_TABLE_SSDT].sig_length))) { - ACPI_REPORT_ERROR(("Table has invalid signature [%4.4s], must be SSDT or PSDT\n", table_ptr->signature)); + ACPI_ERROR((AE_INFO, + "Table has invalid signature [%4.4s], must be SSDT or PSDT", + table_ptr->signature)); status = AE_BAD_SIGNATURE; goto cleanup; } diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c index e6f55cf8ad31..e6d52e12d77a 100644 --- a/drivers/acpi/executer/exconvrt.c +++ b/drivers/acpi/executer/exconvrt.c @@ -641,7 +641,9 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type, break; default: - ACPI_REPORT_ERROR(("Bad destination type during conversion: %X\n", destination_type)); + ACPI_ERROR((AE_INFO, + "Bad destination type during conversion: %X", + destination_type)); status = AE_AML_INTERNAL; break; } @@ -654,7 +656,12 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type, break; default: - ACPI_REPORT_ERROR(("Unknown Target type ID 0x%X aml_opcode %X dest_type %s\n", GET_CURRENT_ARG_TYPE(walk_state->op_info->runtime_args), walk_state->opcode, acpi_ut_get_type_name(destination_type))); + ACPI_ERROR((AE_INFO, + "Unknown Target type ID 0x%X aml_opcode %X dest_type %s", + GET_CURRENT_ARG_TYPE(walk_state->op_info-> + runtime_args), + walk_state->opcode, + acpi_ut_get_type_name(destination_type))); status = AE_AML_INTERNAL; } diff --git a/drivers/acpi/executer/excreate.c b/drivers/acpi/executer/excreate.c index da313dad576a..680575402835 100644 --- a/drivers/acpi/executer/excreate.c +++ b/drivers/acpi/executer/excreate.c @@ -300,8 +300,8 @@ acpi_ex_create_region(u8 * aml_start, */ if ((region_space >= ACPI_NUM_PREDEFINED_REGIONS) && (region_space < ACPI_USER_REGION_BEGIN)) { - ACPI_REPORT_ERROR(("Invalid address_space type %X\n", - region_space)); + ACPI_ERROR((AE_INFO, "Invalid address_space type %X", + region_space)); return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID); } diff --git a/drivers/acpi/executer/exfield.c b/drivers/acpi/executer/exfield.c index 78a76f91a1c9..e259201ce9a0 100644 --- a/drivers/acpi/executer/exfield.c +++ b/drivers/acpi/executer/exfield.c @@ -249,13 +249,18 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE). */ if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) { - ACPI_REPORT_ERROR(("SMBus write requires Buffer, found type %s\n", acpi_ut_get_object_type_name(source_desc))); + ACPI_ERROR((AE_INFO, + "SMBus write requires Buffer, found type %s", + acpi_ut_get_object_type_name(source_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) { - ACPI_REPORT_ERROR(("SMBus write requires Buffer of length %X, found length %X\n", ACPI_SMBUS_BUFFER_SIZE, source_desc->buffer.length)); + ACPI_ERROR((AE_INFO, + "SMBus write requires Buffer of length %X, found length %X", + ACPI_SMBUS_BUFFER_SIZE, + source_desc->buffer.length)); return_ACPI_STATUS(AE_AML_BUFFER_LIMIT); } diff --git a/drivers/acpi/executer/exfldio.c b/drivers/acpi/executer/exfldio.c index 9fe27fd04a2f..bd1af35f7fcf 100644 --- a/drivers/acpi/executer/exfldio.c +++ b/drivers/acpi/executer/exfldio.c @@ -94,9 +94,9 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc, /* We must have a valid region */ if (ACPI_GET_OBJECT_TYPE(rgn_desc) != ACPI_TYPE_REGION) { - ACPI_REPORT_ERROR(("Needed Region, found type %X (%s)\n", - ACPI_GET_OBJECT_TYPE(rgn_desc), - acpi_ut_get_object_type_name(rgn_desc))); + ACPI_ERROR((AE_INFO, "Needed Region, found type %X (%s)", + ACPI_GET_OBJECT_TYPE(rgn_desc), + acpi_ut_get_object_type_name(rgn_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -161,14 +161,28 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc, * than the region itself. For example, a region of length one * byte, and a field with Dword access specified. */ - ACPI_REPORT_ERROR(("Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n", acpi_ut_get_node_name(obj_desc->common_field.node), obj_desc->common_field.access_byte_width, acpi_ut_get_node_name(rgn_desc->region.node), rgn_desc->region.length)); + ACPI_ERROR((AE_INFO, + "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)", + acpi_ut_get_node_name(obj_desc-> + common_field.node), + obj_desc->common_field.access_byte_width, + acpi_ut_get_node_name(rgn_desc->region. + node), + rgn_desc->region.length)); } /* * Offset rounded up to next multiple of field width * exceeds region length, indicate an error */ - ACPI_REPORT_ERROR(("Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)\n", acpi_ut_get_node_name(obj_desc->common_field.node), obj_desc->common_field.base_byte_offset, field_datum_byte_offset, obj_desc->common_field.access_byte_width, acpi_ut_get_node_name(rgn_desc->region.node), rgn_desc->region.length)); + ACPI_ERROR((AE_INFO, + "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)", + acpi_ut_get_node_name(obj_desc->common_field.node), + obj_desc->common_field.base_byte_offset, + field_datum_byte_offset, + obj_desc->common_field.access_byte_width, + acpi_ut_get_node_name(rgn_desc->region.node), + rgn_desc->region.length)); return_ACPI_STATUS(AE_AML_REGION_LIMIT); } @@ -252,17 +266,17 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc, if (ACPI_FAILURE(status)) { if (status == AE_NOT_IMPLEMENTED) { - ACPI_REPORT_ERROR(("Region %s(%X) not implemented\n", - acpi_ut_get_region_name(rgn_desc-> - region. - space_id), - rgn_desc->region.space_id)); + ACPI_ERROR((AE_INFO, + "Region %s(%X) not implemented", + acpi_ut_get_region_name(rgn_desc->region. + space_id), + rgn_desc->region.space_id)); } else if (status == AE_NOT_EXIST) { - ACPI_REPORT_ERROR(("Region %s(%X) has no handler\n", - acpi_ut_get_region_name(rgn_desc-> - region. - space_id), - rgn_desc->region.space_id)); + ACPI_ERROR((AE_INFO, + "Region %s(%X) has no handler", + acpi_ut_get_region_name(rgn_desc->region. + space_id), + rgn_desc->region.space_id)); } } @@ -495,8 +509,8 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc, default: - ACPI_REPORT_ERROR(("Wrong object type in field I/O %X\n", - ACPI_GET_OBJECT_TYPE(obj_desc))); + ACPI_ERROR((AE_INFO, "Wrong object type in field I/O %X", + ACPI_GET_OBJECT_TYPE(obj_desc))); status = AE_AML_INTERNAL; break; } @@ -599,10 +613,11 @@ acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc, default: - ACPI_REPORT_ERROR(("Unknown update_rule value: %X\n", - (obj_desc->common_field. - field_flags & - AML_FIELD_UPDATE_RULE_MASK))); + ACPI_ERROR((AE_INFO, + "Unknown update_rule value: %X", + (obj_desc->common_field. + field_flags & + AML_FIELD_UPDATE_RULE_MASK))); return_ACPI_STATUS(AE_AML_OPERAND_VALUE); } } @@ -657,7 +672,9 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc, if (buffer_length < ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) { - ACPI_REPORT_ERROR(("Field size %X (bits) is too large for buffer (%X)\n", obj_desc->common_field.bit_length, buffer_length)); + ACPI_ERROR((AE_INFO, + "Field size %X (bits) is too large for buffer (%X)", + obj_desc->common_field.bit_length, buffer_length)); return_ACPI_STATUS(AE_BUFFER_OVERFLOW); } @@ -769,7 +786,9 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc, if (buffer_length < ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) { - ACPI_REPORT_ERROR(("Field size %X (bits) is too large for buffer (%X)\n", obj_desc->common_field.bit_length, buffer_length)); + ACPI_ERROR((AE_INFO, + "Field size %X (bits) is too large for buffer (%X)", + obj_desc->common_field.bit_length, buffer_length)); return_ACPI_STATUS(AE_BUFFER_OVERFLOW); } diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c index 5ad34566738c..48c18d29222a 100644 --- a/drivers/acpi/executer/exmisc.c +++ b/drivers/acpi/executer/exmisc.c @@ -98,8 +98,8 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc, default: - ACPI_REPORT_ERROR(("Unknown Reference opcode %X\n", - obj_desc->reference.opcode)); + ACPI_ERROR((AE_INFO, "Unknown Reference opcode %X", + obj_desc->reference.opcode)); return_ACPI_STATUS(AE_AML_INTERNAL); } break; @@ -114,8 +114,8 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc, default: - ACPI_REPORT_ERROR(("Invalid descriptor type %X\n", - ACPI_GET_DESCRIPTOR_TYPE(obj_desc))); + ACPI_ERROR((AE_INFO, "Invalid descriptor type %X", + ACPI_GET_DESCRIPTOR_TYPE(obj_desc))); return_ACPI_STATUS(AE_TYPE); } @@ -166,15 +166,18 @@ acpi_ex_concat_template(union acpi_operand_object *operand0, u8 *end_tag; acpi_size length0; acpi_size length1; + acpi_size new_length; ACPI_FUNCTION_TRACE("ex_concat_template"); /* * Find the end_tag descriptor in each resource template. - * Note: returned pointers point TO the end_tag, not past it. - * - * Compute the length of each resource template + * Note1: returned pointers point TO the end_tag, not past it. + * Note2: zero-length buffers are allowed; treated like one end_tag */ + + /* Get the length of the first resource template */ + status = acpi_ut_get_resource_end_tag(operand0, &end_tag); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); @@ -182,19 +185,22 @@ acpi_ex_concat_template(union acpi_operand_object *operand0, length0 = ACPI_PTR_DIFF(end_tag, operand0->buffer.pointer); + /* Get the length of the second resource template */ + status = acpi_ut_get_resource_end_tag(operand1, &end_tag); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } - /* Include the end_tag in the second template length */ + length1 = ACPI_PTR_DIFF(end_tag, operand1->buffer.pointer); + + /* Combine both lengths, minimum size will be 2 for end_tag */ - length1 = ACPI_PTR_DIFF(end_tag, operand1->buffer.pointer) + - sizeof(struct aml_resource_end_tag); + new_length = length0 + length1 + sizeof(struct aml_resource_end_tag); - /* Create a new buffer object for the result */ + /* Create a new buffer object for the result (with one end_tag) */ - return_desc = acpi_ut_create_buffer_object(length0 + length1); + return_desc = acpi_ut_create_buffer_object(new_length); if (!return_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } @@ -207,9 +213,10 @@ acpi_ex_concat_template(union acpi_operand_object *operand0, ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length0); ACPI_MEMCPY(new_buf + length0, operand1->buffer.pointer, length1); - /* Set the end_tag checksum to zero, means "ignore checksum" */ + /* Insert end_tag and set the checksum to zero, means "ignore checksum" */ - new_buf[return_desc->buffer.length - 1] = 0; + new_buf[new_length - 1] = 0; + new_buf[new_length - 2] = ACPI_RESOURCE_NAME_END_TAG | 1; /* Return the completed resource template */ @@ -268,8 +275,8 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, break; default: - ACPI_REPORT_ERROR(("Invalid object type: %X\n", - ACPI_GET_OBJECT_TYPE(operand0))); + ACPI_ERROR((AE_INFO, "Invalid object type: %X", + ACPI_GET_OBJECT_TYPE(operand0))); status = AE_AML_INTERNAL; } @@ -370,8 +377,8 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, /* Invalid object type, should not happen here */ - ACPI_REPORT_ERROR(("Invalid object type: %X\n", - ACPI_GET_OBJECT_TYPE(operand0))); + ACPI_ERROR((AE_INFO, "Invalid object type: %X", + ACPI_GET_OBJECT_TYPE(operand0))); status = AE_AML_INTERNAL; goto cleanup; } diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c index 89b8ab79410b..f843b22e20b9 100644 --- a/drivers/acpi/executer/exmutex.c +++ b/drivers/acpi/executer/exmutex.c @@ -153,7 +153,9 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc, /* Sanity check -- we must have a valid thread ID */ if (!walk_state->thread) { - ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node))); + ACPI_ERROR((AE_INFO, + "Cannot acquire Mutex [%4.4s], null thread info", + acpi_ut_get_node_name(obj_desc->mutex.node))); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -162,7 +164,9 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc, * mutex. This mechanism provides some deadlock prevention */ if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) { - ACPI_REPORT_ERROR(("Cannot acquire Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node))); + ACPI_ERROR((AE_INFO, + "Cannot acquire Mutex [%4.4s], incorrect sync_level", + acpi_ut_get_node_name(obj_desc->mutex.node))); return_ACPI_STATUS(AE_AML_MUTEX_ORDER); } @@ -237,14 +241,18 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, /* The mutex must have been previously acquired in order to release it */ if (!obj_desc->mutex.owner_thread) { - ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], not acquired\n", acpi_ut_get_node_name(obj_desc->mutex.node))); + ACPI_ERROR((AE_INFO, + "Cannot release Mutex [%4.4s], not acquired", + acpi_ut_get_node_name(obj_desc->mutex.node))); return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED); } /* Sanity check -- we must have a valid thread ID */ if (!walk_state->thread) { - ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], null thread info\n", acpi_ut_get_node_name(obj_desc->mutex.node))); + ACPI_ERROR((AE_INFO, + "Cannot release Mutex [%4.4s], null thread info", + acpi_ut_get_node_name(obj_desc->mutex.node))); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -255,7 +263,11 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, if ((obj_desc->mutex.owner_thread->thread_id != walk_state->thread->thread_id) && (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) { - ACPI_REPORT_ERROR(("Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", walk_state->thread->thread_id, acpi_ut_get_node_name(obj_desc->mutex.node), obj_desc->mutex.owner_thread->thread_id)); + ACPI_ERROR((AE_INFO, + "Thread %X cannot release Mutex [%4.4s] acquired by thread %X", + walk_state->thread->thread_id, + acpi_ut_get_node_name(obj_desc->mutex.node), + obj_desc->mutex.owner_thread->thread_id)); return_ACPI_STATUS(AE_AML_NOT_OWNER); } @@ -264,7 +276,9 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, * equal to the current sync level */ if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) { - ACPI_REPORT_ERROR(("Cannot release Mutex [%4.4s], incorrect sync_level\n", acpi_ut_get_node_name(obj_desc->mutex.node))); + ACPI_ERROR((AE_INFO, + "Cannot release Mutex [%4.4s], incorrect sync_level", + acpi_ut_get_node_name(obj_desc->mutex.node))); return_ACPI_STATUS(AE_AML_MUTEX_ORDER); } diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c index de3216b6a4fc..054fe5e1a314 100644 --- a/drivers/acpi/executer/exnames.c +++ b/drivers/acpi/executer/exnames.c @@ -99,8 +99,8 @@ static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs) */ name_string = ACPI_MEM_ALLOCATE(size_needed); if (!name_string) { - ACPI_REPORT_ERROR(("Could not allocate size %d\n", - size_needed)); + ACPI_ERROR((AE_INFO, + "Could not allocate size %d", size_needed)); return_PTR(NULL); } @@ -168,7 +168,7 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string) char_buf[0] = *aml_address; if ('0' <= char_buf[0] && char_buf[0] <= '9') { - ACPI_REPORT_ERROR(("Invalid leading digit: %c\n", char_buf[0])); + ACPI_ERROR((AE_INFO, "Invalid leading digit: %c", char_buf[0])); return_ACPI_STATUS(AE_CTRL_PENDING); } @@ -211,8 +211,9 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string) * the required 4 */ status = AE_AML_BAD_NAME; - ACPI_REPORT_ERROR(("Bad character %02x in name, at %p\n", - *aml_address, aml_address)); + ACPI_ERROR((AE_INFO, + "Bad character %02x in name, at %p", + *aml_address, aml_address)); } *in_aml_address = ACPI_CAST_PTR(u8, aml_address); @@ -411,7 +412,7 @@ acpi_ex_get_name_string(acpi_object_type data_type, if (AE_CTRL_PENDING == status && has_prefix) { /* Ran out of segments after processing a prefix */ - ACPI_REPORT_ERROR(("Malformed Name at %p\n", name_string)); + ACPI_ERROR((AE_INFO, "Malformed Name at %p", name_string)); status = AE_AML_BAD_NAME; } diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c index bc8837ecb716..23d0823bcd5e 100644 --- a/drivers/acpi/executer/exoparg1.c +++ b/drivers/acpi/executer/exoparg1.c @@ -111,8 +111,8 @@ acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state) default: /* Unknown opcode */ - ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", - walk_state->opcode)); + ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; break; } @@ -189,8 +189,8 @@ acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state) default: /* Unknown opcode */ - ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", - walk_state->opcode)); + ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; break; } @@ -229,8 +229,8 @@ acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state) default: /* Unknown opcode */ - ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", - walk_state->opcode)); + ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } @@ -349,7 +349,9 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state) /* Check the range of the digit */ if (temp32 > 9) { - ACPI_REPORT_ERROR(("BCD digit too large (not decimal): 0x%X\n", temp32)); + ACPI_ERROR((AE_INFO, + "BCD digit too large (not decimal): 0x%X", + temp32)); status = AE_AML_NUMERIC_OVERFLOW; goto cleanup; @@ -394,7 +396,10 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state) /* Overflow if there is any data left in Digit */ if (digit > 0) { - ACPI_REPORT_ERROR(("Integer too large to convert to BCD: %8.8X%8.8X\n", ACPI_FORMAT_UINT64(operand[0]->integer.value))); + ACPI_ERROR((AE_INFO, + "Integer too large to convert to BCD: %8.8X%8.8X", + ACPI_FORMAT_UINT64(operand[0]-> + integer.value))); status = AE_AML_NUMERIC_OVERFLOW; goto cleanup; } @@ -521,16 +526,16 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state) /* These are two obsolete opcodes */ - ACPI_REPORT_ERROR(("%s is obsolete and not implemented\n", - acpi_ps_get_opcode_name(walk_state-> - opcode))); + ACPI_ERROR((AE_INFO, + "%s is obsolete and not implemented", + acpi_ps_get_opcode_name(walk_state->opcode))); status = AE_SUPPORT; goto cleanup; default: /* Unknown opcode */ - ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", - walk_state->opcode)); + ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } @@ -636,10 +641,10 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) acpi_ex_resolve_operands(AML_LNOT_OP, &temp_desc, walk_state); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("%s: bad operand(s) %s\n", - acpi_ps_get_opcode_name(walk_state-> - opcode), - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "While resolving operands for [%s]", + acpi_ps_get_opcode_name(walk_state-> + opcode))); goto cleanup; } @@ -738,7 +743,9 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) break; default: - ACPI_REPORT_ERROR(("Operand is not Buf/Int/Str/Pkg - found type %s\n", acpi_ut_get_type_name(type))); + ACPI_ERROR((AE_INFO, + "Operand is not Buf/Int/Str/Pkg - found type %s", + acpi_ut_get_type_name(type))); status = AE_AML_OPERAND_TYPE; goto cleanup; } @@ -935,7 +942,10 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("Unknown Index target_type %X in obj %p\n", operand[0]->reference.target_type, operand[0])); + ACPI_ERROR((AE_INFO, + "Unknown Index target_type %X in obj %p", + operand[0]->reference. + target_type, operand[0])); status = AE_AML_OPERAND_TYPE; goto cleanup; } @@ -961,7 +971,10 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) break; default: - ACPI_REPORT_ERROR(("Unknown opcode in ref(%p) - %X\n", operand[0], operand[0]->reference.opcode)); + ACPI_ERROR((AE_INFO, + "Unknown opcode in ref(%p) - %X", + operand[0], + operand[0]->reference.opcode)); status = AE_TYPE; goto cleanup; @@ -971,8 +984,8 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", - walk_state->opcode)); + ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } diff --git a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/executer/exoparg2.c index 7c59dda40946..e263a5ddd405 100644 --- a/drivers/acpi/executer/exoparg2.c +++ b/drivers/acpi/executer/exoparg2.c @@ -111,7 +111,9 @@ acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state) /* Are notifies allowed on this object? */ if (!acpi_ev_is_notify_object(node)) { - ACPI_REPORT_ERROR(("Unexpected notify object type [%s]\n", acpi_ut_get_type_name(node->type))); + ACPI_ERROR((AE_INFO, + "Unexpected notify object type [%s]", + acpi_ut_get_type_name(node->type))); status = AE_AML_OPERAND_TYPE; break; @@ -155,8 +157,8 @@ acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", - walk_state->opcode)); + ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; } @@ -220,8 +222,8 @@ acpi_status acpi_ex_opcode_2A_2T_1R(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", - walk_state->opcode)); + ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } @@ -389,7 +391,10 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) /* Object to be indexed is a Package */ if (index >= operand[0]->package.count) { - ACPI_REPORT_ERROR(("Index value (%X%8.8X) beyond package end (%X)\n", ACPI_FORMAT_UINT64(index), operand[0]->package.count)); + ACPI_ERROR((AE_INFO, + "Index value (%X%8.8X) beyond package end (%X)", + ACPI_FORMAT_UINT64(index), + operand[0]->package.count)); status = AE_AML_PACKAGE_LIMIT; goto cleanup; } @@ -402,7 +407,10 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) /* Object to be indexed is a Buffer/String */ if (index >= operand[0]->buffer.length) { - ACPI_REPORT_ERROR(("Index value (%X%8.8X) beyond end of buffer (%X)\n", ACPI_FORMAT_UINT64(index), operand[0]->buffer.length)); + ACPI_ERROR((AE_INFO, + "Index value (%X%8.8X) beyond end of buffer (%X)", + ACPI_FORMAT_UINT64(index), + operand[0]->buffer.length)); status = AE_AML_BUFFER_LIMIT; goto cleanup; } @@ -434,8 +442,8 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", - walk_state->opcode)); + ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; break; } @@ -539,8 +547,8 @@ acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", - walk_state->opcode)); + ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/executer/exoparg3.c index a979b338a491..6a3a883cb8a3 100644 --- a/drivers/acpi/executer/exoparg3.c +++ b/drivers/acpi/executer/exoparg3.c @@ -119,8 +119,8 @@ acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", - walk_state->opcode)); + ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } @@ -243,8 +243,8 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state) default: - ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", - walk_state->opcode)); + ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } diff --git a/drivers/acpi/executer/exoparg6.c b/drivers/acpi/executer/exoparg6.c index 05e7f9b67f29..e043d924444f 100644 --- a/drivers/acpi/executer/exoparg6.c +++ b/drivers/acpi/executer/exoparg6.c @@ -234,7 +234,7 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state) if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) || (operand[3]->integer.value > MAX_MATCH_OPERATOR)) { - ACPI_REPORT_ERROR(("Match operator out of range\n")); + ACPI_ERROR((AE_INFO, "Match operator out of range")); status = AE_AML_OPERAND_VALUE; goto cleanup; } @@ -243,7 +243,10 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state) index = operand[5]->integer.value; if (index >= operand[0]->package.count) { - ACPI_REPORT_ERROR(("Index (%X%8.8X) beyond package end (%X)\n", ACPI_FORMAT_UINT64(index), operand[0]->package.count)); + ACPI_ERROR((AE_INFO, + "Index (%X%8.8X) beyond package end (%X)", + ACPI_FORMAT_UINT64(index), + operand[0]->package.count)); status = AE_AML_PACKAGE_LIMIT; goto cleanup; } @@ -312,8 +315,8 @@ acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state) default: - ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", - walk_state->opcode)); + ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", + walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } diff --git a/drivers/acpi/executer/exprep.c b/drivers/acpi/executer/exprep.c index 3bde780c94cf..7719ae5d4f16 100644 --- a/drivers/acpi/executer/exprep.c +++ b/drivers/acpi/executer/exprep.c @@ -274,7 +274,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc, default: /* Invalid field access type */ - ACPI_REPORT_ERROR(("Unknown field access type %X\n", access)); + ACPI_ERROR((AE_INFO, "Unknown field access type %X", access)); return_UINT32(0); } @@ -421,13 +421,15 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info) if (info->field_type != ACPI_TYPE_LOCAL_INDEX_FIELD) { if (!info->region_node) { - ACPI_REPORT_ERROR(("Null region_node\n")); + ACPI_ERROR((AE_INFO, "Null region_node")); return_ACPI_STATUS(AE_AML_NO_OPERAND); } type = acpi_ns_get_type(info->region_node); if (type != ACPI_TYPE_REGION) { - ACPI_REPORT_ERROR(("Needed Region, found type %X (%s)\n", type, acpi_ut_get_type_name(type))); + ACPI_ERROR((AE_INFO, + "Needed Region, found type %X (%s)", + type, acpi_ut_get_type_name(type))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -496,17 +498,17 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info) case ACPI_TYPE_LOCAL_INDEX_FIELD: + /* Get the Index and Data registers */ + obj_desc->index_field.index_obj = acpi_ns_get_attached_object(info->register_node); obj_desc->index_field.data_obj = acpi_ns_get_attached_object(info->data_register_node); - obj_desc->index_field.value = (u32) - (info->field_bit_position / - ACPI_MUL_8(obj_desc->field.access_byte_width)); if (!obj_desc->index_field.data_obj || !obj_desc->index_field.index_obj) { - ACPI_REPORT_ERROR(("Null Index Object during field prep\n")); + ACPI_ERROR((AE_INFO, + "Null Index Object during field prep")); acpi_ut_delete_object_desc(obj_desc); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -516,6 +518,15 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info) acpi_ut_add_reference(obj_desc->index_field.data_obj); acpi_ut_add_reference(obj_desc->index_field.index_obj); + /* + * The value written to the Index register is the byte offset of the + * target field + * Note: may change code to: ACPI_DIV_8 (Info->field_bit_position) + */ + obj_desc->index_field.value = (u32) + (info->field_bit_position / + ACPI_MUL_8(obj_desc->field.access_byte_width)); + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "index_field: bit_off %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n", obj_desc->index_field.start_field_bit_offset, diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c index 82983575cca6..6a4cfdff606d 100644 --- a/drivers/acpi/executer/exregion.c +++ b/drivers/acpi/executer/exregion.c @@ -103,8 +103,8 @@ acpi_ex_system_memory_space_handler(u32 function, break; default: - ACPI_REPORT_ERROR(("Invalid system_memory width %d\n", - bit_width)); + ACPI_ERROR((AE_INFO, "Invalid system_memory width %d", + bit_width)); return_ACPI_STATUS(AE_AML_OPERAND_VALUE); } @@ -158,7 +158,10 @@ acpi_ex_system_memory_space_handler(u32 function, (void **)&mem_info-> mapped_logical_address); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not map memory at %8.8X%8.8X, size %X\n", ACPI_FORMAT_UINT64(address), (u32) window_size)); + ACPI_ERROR((AE_INFO, + "Could not map memory at %8.8X%8.8X, size %X", + ACPI_FORMAT_UINT64(address), + (u32) window_size)); mem_info->mapped_length = 0; return_ACPI_STATUS(status); } diff --git a/drivers/acpi/executer/exresnte.c b/drivers/acpi/executer/exresnte.c index a5cca7eda210..01b26c80d22b 100644 --- a/drivers/acpi/executer/exresnte.c +++ b/drivers/acpi/executer/exresnte.c @@ -122,7 +122,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, } if (!source_desc) { - ACPI_REPORT_ERROR(("No object attached to node %p\n", node)); + ACPI_ERROR((AE_INFO, "No object attached to node %p", node)); return_ACPI_STATUS(AE_AML_NO_OPERAND); } @@ -134,9 +134,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, case ACPI_TYPE_PACKAGE: if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_PACKAGE) { - ACPI_REPORT_ERROR(("Object not a Package, type %s\n", - acpi_ut_get_object_type_name - (source_desc))); + ACPI_ERROR((AE_INFO, "Object not a Package, type %s", + acpi_ut_get_object_type_name(source_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -152,9 +151,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, case ACPI_TYPE_BUFFER: if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_BUFFER) { - ACPI_REPORT_ERROR(("Object not a Buffer, type %s\n", - acpi_ut_get_object_type_name - (source_desc))); + ACPI_ERROR((AE_INFO, "Object not a Buffer, type %s", + acpi_ut_get_object_type_name(source_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -170,9 +168,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, case ACPI_TYPE_STRING: if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) { - ACPI_REPORT_ERROR(("Object not a String, type %s\n", - acpi_ut_get_object_type_name - (source_desc))); + ACPI_ERROR((AE_INFO, "Object not a String, type %s", + acpi_ut_get_object_type_name(source_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -185,9 +182,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, case ACPI_TYPE_INTEGER: if (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_INTEGER) { - ACPI_REPORT_ERROR(("Object not a Integer, type %s\n", - acpi_ut_get_object_type_name - (source_desc))); + ACPI_ERROR((AE_INFO, "Object not a Integer, type %s", + acpi_ut_get_object_type_name(source_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -231,8 +227,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, case ACPI_TYPE_ANY: - ACPI_REPORT_ERROR(("Untyped entry %p, no attached object!\n", - node)); + ACPI_ERROR((AE_INFO, + "Untyped entry %p, no attached object!", node)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ @@ -251,7 +247,11 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, default: /* No named references are allowed here */ - ACPI_REPORT_ERROR(("Unsupported Reference opcode %X (%s)\n", source_desc->reference.opcode, acpi_ps_get_opcode_name(source_desc->reference.opcode))); + ACPI_ERROR((AE_INFO, + "Unsupported Reference opcode %X (%s)", + source_desc->reference.opcode, + acpi_ps_get_opcode_name(source_desc-> + reference.opcode))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -261,8 +261,9 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, /* Default case is for unknown types */ - ACPI_REPORT_ERROR(("Node %p - Unknown object type %X\n", - node, entry_type)); + ACPI_ERROR((AE_INFO, + "Node %p - Unknown object type %X", + node, entry_type)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); diff --git a/drivers/acpi/executer/exresolv.c b/drivers/acpi/executer/exresolv.c index ae2d2da00844..1deed492fe88 100644 --- a/drivers/acpi/executer/exresolv.c +++ b/drivers/acpi/executer/exresolv.c @@ -81,7 +81,7 @@ acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr, ACPI_FUNCTION_TRACE_PTR("ex_resolve_to_value", stack_ptr); if (!stack_ptr || !*stack_ptr) { - ACPI_REPORT_ERROR(("Internal - null pointer\n")); + ACPI_ERROR((AE_INFO, "Internal - null pointer")); return_ACPI_STATUS(AE_AML_NO_OPERAND); } @@ -97,7 +97,7 @@ acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr, } if (!*stack_ptr) { - ACPI_REPORT_ERROR(("Internal - null pointer\n")); + ACPI_ERROR((AE_INFO, "Internal - null pointer")); return_ACPI_STATUS(AE_AML_NO_OPERAND); } } @@ -227,7 +227,9 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, * A NULL object descriptor means an unitialized element of * the package, can't dereference it */ - ACPI_REPORT_ERROR(("Attempt to deref an Index to NULL pkg element Idx=%p\n", stack_desc)); + ACPI_ERROR((AE_INFO, + "Attempt to deref an Index to NULL pkg element Idx=%p", + stack_desc)); status = AE_AML_UNINITIALIZED_ELEMENT; } break; @@ -236,7 +238,10 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, /* Invalid reference object */ - ACPI_REPORT_ERROR(("Unknown target_type %X in Index/Reference obj %p\n", stack_desc->reference.target_type, stack_desc)); + ACPI_ERROR((AE_INFO, + "Unknown target_type %X in Index/Reference obj %p", + stack_desc->reference.target_type, + stack_desc)); status = AE_AML_INTERNAL; break; } @@ -261,7 +266,10 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, default: - ACPI_REPORT_ERROR(("Unknown Reference opcode %X (%s) in %p\n", opcode, acpi_ps_get_opcode_name(opcode), stack_desc)); + ACPI_ERROR((AE_INFO, + "Unknown Reference opcode %X (%s) in %p", + opcode, acpi_ps_get_opcode_name(opcode), + stack_desc)); status = AE_AML_INTERNAL; break; } @@ -383,10 +391,9 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) { - ACPI_REPORT_ERROR(("Not a NS node %p [%s]\n", - node, - acpi_ut_get_descriptor_name - (node))); + ACPI_ERROR((AE_INFO, "Not a NS node %p [%s]", + node, + acpi_ut_get_descriptor_name(node))); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -442,10 +449,9 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) { - ACPI_REPORT_ERROR(("Not a NS node %p [%s]\n", - node, - acpi_ut_get_descriptor_name - (node))); + ACPI_ERROR((AE_INFO, "Not a NS node %p [%s]", + node, + acpi_ut_get_descriptor_name(node))); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -514,8 +520,9 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, default: - ACPI_REPORT_ERROR(("Unknown Reference subtype %X\n", - obj_desc->reference.opcode)); + ACPI_ERROR((AE_INFO, + "Unknown Reference subtype %X", + obj_desc->reference.opcode)); return_ACPI_STATUS(AE_AML_INTERNAL); } } diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c index 804faebf825c..a1c000f5a415 100644 --- a/drivers/acpi/executer/exresop.c +++ b/drivers/acpi/executer/exresop.c @@ -46,6 +46,7 @@ #include #include #include +#include #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME("exresop") @@ -95,9 +96,10 @@ acpi_ex_check_object_type(acpi_object_type type_needed, } if (type_needed != this_type) { - ACPI_REPORT_ERROR(("Needed type [%s], found [%s] %p\n", - acpi_ut_get_type_name(type_needed), - acpi_ut_get_type_name(this_type), object)); + ACPI_ERROR((AE_INFO, + "Needed type [%s], found [%s] %p", + acpi_ut_get_type_name(type_needed), + acpi_ut_get_type_name(this_type), object)); return (AE_AML_OPERAND_TYPE); } @@ -150,7 +152,7 @@ acpi_ex_resolve_operands(u16 opcode, arg_types = op_info->runtime_args; if (arg_types == ARGI_INVALID_OPCODE) { - ACPI_REPORT_ERROR(("Unknown AML opcode %X\n", opcode)); + ACPI_ERROR((AE_INFO, "Unknown AML opcode %X", opcode)); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -168,8 +170,8 @@ acpi_ex_resolve_operands(u16 opcode, */ while (GET_CURRENT_ARG_TYPE(arg_types)) { if (!stack_ptr || !*stack_ptr) { - ACPI_REPORT_ERROR(("Null stack entry at %p\n", - stack_ptr)); + ACPI_ERROR((AE_INFO, "Null stack entry at %p", + stack_ptr)); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -187,6 +189,22 @@ acpi_ex_resolve_operands(u16 opcode, object_type = ((struct acpi_namespace_node *)obj_desc)->type; + + /* + * Resolve an alias object. The construction of these objects + * guarantees that there is only one level of alias indirection; + * thus, the attached object is always the aliased namespace node + */ + if (object_type == ACPI_TYPE_LOCAL_ALIAS) { + obj_desc = + acpi_ns_get_attached_object((struct + acpi_namespace_node + *)obj_desc); + *stack_ptr = obj_desc; + object_type = + ((struct acpi_namespace_node *)obj_desc)-> + type; + } break; case ACPI_DESC_TYPE_OPERAND: @@ -198,7 +216,9 @@ acpi_ex_resolve_operands(u16 opcode, /* Check for bad acpi_object_type */ if (!acpi_ut_valid_object_type(object_type)) { - ACPI_REPORT_ERROR(("Bad operand object type [%X]\n", object_type)); + ACPI_ERROR((AE_INFO, + "Bad operand object type [%X]", + object_type)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -236,7 +256,10 @@ acpi_ex_resolve_operands(u16 opcode, break; default: - ACPI_REPORT_ERROR(("Operand is a Reference, Unknown Reference Opcode: %X\n", obj_desc->reference.opcode)); + ACPI_ERROR((AE_INFO, + "Operand is a Reference, Unknown Reference Opcode: %X", + obj_desc->reference. + opcode)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -247,10 +270,10 @@ acpi_ex_resolve_operands(u16 opcode, /* Invalid descriptor */ - ACPI_REPORT_ERROR(("Invalid descriptor %p [%s]\n", - obj_desc, - acpi_ut_get_descriptor_name - (obj_desc))); + ACPI_ERROR((AE_INFO, + "Invalid descriptor %p [%s]", + obj_desc, + acpi_ut_get_descriptor_name(obj_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -408,7 +431,10 @@ acpi_ex_resolve_operands(u16 opcode, acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16); if (ACPI_FAILURE(status)) { if (status == AE_TYPE) { - ACPI_REPORT_ERROR(("Needed [Integer/String/Buffer], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); + ACPI_ERROR((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + acpi_ut_get_object_type_name + (obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -431,7 +457,10 @@ acpi_ex_resolve_operands(u16 opcode, status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr); if (ACPI_FAILURE(status)) { if (status == AE_TYPE) { - ACPI_REPORT_ERROR(("Needed [Integer/String/Buffer], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); + ACPI_ERROR((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + acpi_ut_get_object_type_name + (obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -455,7 +484,10 @@ acpi_ex_resolve_operands(u16 opcode, ACPI_IMPLICIT_CONVERT_HEX); if (ACPI_FAILURE(status)) { if (status == AE_TYPE) { - ACPI_REPORT_ERROR(("Needed [Integer/String/Buffer], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); + ACPI_ERROR((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + acpi_ut_get_object_type_name + (obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -481,7 +513,10 @@ acpi_ex_resolve_operands(u16 opcode, break; default: - ACPI_REPORT_ERROR(("Needed [Integer/String/Buffer], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); + ACPI_ERROR((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + acpi_ut_get_object_type_name + (obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -515,7 +550,10 @@ acpi_ex_resolve_operands(u16 opcode, break; default: - ACPI_REPORT_ERROR(("Needed [Integer/String/Buffer], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); + ACPI_ERROR((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + acpi_ut_get_object_type_name + (obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -539,7 +577,10 @@ acpi_ex_resolve_operands(u16 opcode, break; default: - ACPI_REPORT_ERROR(("Needed [Buffer/String/Package/Reference], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); + ACPI_ERROR((AE_INFO, + "Needed [Buffer/String/Package/Reference], found [%s] %p", + acpi_ut_get_object_type_name + (obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -558,7 +599,10 @@ acpi_ex_resolve_operands(u16 opcode, break; default: - ACPI_REPORT_ERROR(("Needed [Buffer/String/Package], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); + ACPI_ERROR((AE_INFO, + "Needed [Buffer/String/Package], found [%s] %p", + acpi_ut_get_object_type_name + (obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -578,7 +622,10 @@ acpi_ex_resolve_operands(u16 opcode, break; default: - ACPI_REPORT_ERROR(("Needed [Region/region_field], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); + ACPI_ERROR((AE_INFO, + "Needed [Region/region_field], found [%s] %p", + acpi_ut_get_object_type_name + (obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -620,7 +667,10 @@ acpi_ex_resolve_operands(u16 opcode, break; } - ACPI_REPORT_ERROR(("Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n", acpi_ut_get_object_type_name(obj_desc), obj_desc)); + ACPI_ERROR((AE_INFO, + "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p", + acpi_ut_get_object_type_name + (obj_desc), obj_desc)); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -630,7 +680,9 @@ acpi_ex_resolve_operands(u16 opcode, /* Unknown type */ - ACPI_REPORT_ERROR(("Internal - Unknown ARGI (required operand) type %X\n", this_arg_type)); + ACPI_ERROR((AE_INFO, + "Internal - Unknown ARGI (required operand) type %X", + this_arg_type)); return_ACPI_STATUS(AE_BAD_PARAMETER); } diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c index 202ebe1eb957..3f020c0e2b95 100644 --- a/drivers/acpi/executer/exstore.c +++ b/drivers/acpi/executer/exstore.c @@ -250,7 +250,7 @@ acpi_ex_store(union acpi_operand_object *source_desc, /* Validate parameters */ if (!source_desc || !dest_desc) { - ACPI_REPORT_ERROR(("Null parameter\n")); + ACPI_ERROR((AE_INFO, "Null parameter")); return_ACPI_STATUS(AE_AML_NO_OPERAND); } @@ -290,7 +290,10 @@ acpi_ex_store(union acpi_operand_object *source_desc, /* Destination is not a Reference object */ - ACPI_REPORT_ERROR(("Target is not a Reference or Constant object - %s [%p]\n", acpi_ut_get_object_type_name(dest_desc), dest_desc)); + ACPI_ERROR((AE_INFO, + "Target is not a Reference or Constant object - %s [%p]", + acpi_ut_get_object_type_name(dest_desc), + dest_desc)); ACPI_DUMP_STACK_ENTRY(source_desc); ACPI_DUMP_STACK_ENTRY(dest_desc); @@ -357,8 +360,8 @@ acpi_ex_store(union acpi_operand_object *source_desc, default: - ACPI_REPORT_ERROR(("Unknown Reference opcode %X\n", - ref_desc->reference.opcode)); + ACPI_ERROR((AE_INFO, "Unknown Reference opcode %X", + ref_desc->reference.opcode)); ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_ERROR); status = AE_AML_INTERNAL; @@ -487,7 +490,9 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc, /* All other types are invalid */ - ACPI_REPORT_ERROR(("Source must be Integer/Buffer/String type, not %s\n", acpi_ut_get_object_type_name(source_desc))); + ACPI_ERROR((AE_INFO, + "Source must be Integer/Buffer/String type, not %s", + acpi_ut_get_object_type_name(source_desc))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } @@ -497,7 +502,8 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc, break; default: - ACPI_REPORT_ERROR(("Target is not a Package or buffer_field\n")); + ACPI_ERROR((AE_INFO, + "Target is not a Package or buffer_field")); status = AE_AML_OPERAND_TYPE; break; } diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/executer/exstoren.c index 25bbc1d78547..42967baf760d 100644 --- a/drivers/acpi/executer/exstoren.c +++ b/drivers/acpi/executer/exstoren.c @@ -123,7 +123,10 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr, && (source_desc->reference.opcode == AML_LOAD_OP))) { /* Conversion successful but still not a valid type */ - ACPI_REPORT_ERROR(("Cannot assign type %s to %s (must be type Int/Str/Buf)\n", acpi_ut_get_object_type_name(source_desc), acpi_ut_get_type_name(target_type))); + ACPI_ERROR((AE_INFO, + "Cannot assign type %s to %s (must be type Int/Str/Buf)", + acpi_ut_get_object_type_name(source_desc), + acpi_ut_get_type_name(target_type))); status = AE_AML_OPERAND_TYPE; } break; @@ -131,9 +134,11 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr, case ACPI_TYPE_LOCAL_ALIAS: case ACPI_TYPE_LOCAL_METHOD_ALIAS: - /* Aliases are resolved by acpi_ex_prep_operands */ - - ACPI_REPORT_ERROR(("Store into Alias - should never happen\n")); + /* + * All aliases should have been resolved earlier, during the + * operand resolution phase. + */ + ACPI_ERROR((AE_INFO, "Store into an unresolved Alias object")); status = AE_AML_INTERNAL; break; @@ -276,8 +281,8 @@ acpi_ex_store_object_to_object(union acpi_operand_object *source_desc, /* * All other types come here. */ - ACPI_REPORT_WARNING(("Store into type %s not implemented\n", - acpi_ut_get_object_type_name(dest_desc))); + ACPI_WARNING((AE_INFO, "Store into type %s not implemented", + acpi_ut_get_object_type_name(dest_desc))); status = AE_NOT_IMPLEMENTED; break; diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/executer/exsystem.c index 9a3684d3cf87..ea9144f42e1f 100644 --- a/drivers/acpi/executer/exsystem.c +++ b/drivers/acpi/executer/exsystem.c @@ -129,8 +129,8 @@ acpi_status acpi_ex_system_do_stall(u32 how_long) * (ACPI specifies 100 usec as max, but this gives some slack in * order to support existing BIOSs) */ - ACPI_REPORT_ERROR(("Time parameter is too large (%d)\n", - how_long)); + ACPI_ERROR((AE_INFO, "Time parameter is too large (%d)", + how_long)); status = AE_AML_OPERAND_VALUE; } else { acpi_os_stall(how_long); diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c index 990c40e0c041..f73a61aeb7ec 100644 --- a/drivers/acpi/executer/exutils.c +++ b/drivers/acpi/executer/exutils.c @@ -91,7 +91,7 @@ acpi_status acpi_ex_enter_interpreter(void) status = acpi_ut_acquire_mutex(ACPI_MTX_EXECUTE); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not acquire interpreter mutex\n")); + ACPI_ERROR((AE_INFO, "Could not acquire interpreter mutex")); } return_ACPI_STATUS(status); @@ -127,7 +127,7 @@ void acpi_ex_exit_interpreter(void) status = acpi_ut_release_mutex(ACPI_MTX_EXECUTE); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not release interpreter mutex\n")); + ACPI_ERROR((AE_INFO, "Could not release interpreter mutex")); } return_VOID; @@ -200,7 +200,8 @@ u8 acpi_ex_acquire_global_lock(u32 field_flags) if (ACPI_SUCCESS(status)) { locked = TRUE; } else { - ACPI_REPORT_ERROR(("Could not acquire Global Lock, %s\n", acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not acquire Global Lock")); } } @@ -235,7 +236,8 @@ void acpi_ex_release_global_lock(u8 locked_by_me) if (ACPI_FAILURE(status)) { /* Report the error, but there isn't much else we can do */ - ACPI_REPORT_ERROR(("Could not release ACPI Global Lock, %s\n", acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not release ACPI Global Lock")); } } diff --git a/drivers/acpi/hardware/hwacpi.c b/drivers/acpi/hardware/hwacpi.c index 5c068cc4f674..ea2f13271ff1 100644 --- a/drivers/acpi/hardware/hwacpi.c +++ b/drivers/acpi/hardware/hwacpi.c @@ -68,7 +68,7 @@ acpi_status acpi_hw_initialize(void) /* We must have the ACPI tables by the time we get here */ if (!acpi_gbl_FADT) { - ACPI_REPORT_ERROR(("No FADT is present\n")); + ACPI_ERROR((AE_INFO, "No FADT is present")); return_ACPI_STATUS(AE_NO_ACPI_TABLES); } @@ -107,7 +107,8 @@ acpi_status acpi_hw_set_mode(u32 mode) * system does not support mode transition. */ if (!acpi_gbl_FADT->smi_cmd) { - ACPI_REPORT_ERROR(("No SMI_CMD in FADT, mode transition failed\n")); + ACPI_ERROR((AE_INFO, + "No SMI_CMD in FADT, mode transition failed")); return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); } @@ -119,7 +120,8 @@ acpi_status acpi_hw_set_mode(u32 mode) * transitions are not supported. */ if (!acpi_gbl_FADT->acpi_enable && !acpi_gbl_FADT->acpi_disable) { - ACPI_REPORT_ERROR(("No ACPI mode transition supported in this system (enable/disable both zero)\n")); + ACPI_ERROR((AE_INFO, + "No ACPI mode transition supported in this system (enable/disable both zero)")); return_ACPI_STATUS(AE_OK); } @@ -153,8 +155,8 @@ acpi_status acpi_hw_set_mode(u32 mode) } if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not write mode change, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not write ACPI mode change")); return_ACPI_STATUS(status); } @@ -174,7 +176,7 @@ acpi_status acpi_hw_set_mode(u32 mode) retry--; } - ACPI_REPORT_ERROR(("Hardware never changed modes\n")); + ACPI_ERROR((AE_INFO, "Hardware did not change modes")); return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); } diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c index b4b50a3d1705..e1fe75498415 100644 --- a/drivers/acpi/hardware/hwregs.c +++ b/drivers/acpi/hardware/hwregs.c @@ -160,15 +160,16 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b) /* Must have a return object */ if (!info.return_object) { - ACPI_REPORT_ERROR(("No Sleep State object returned from [%s]\n", - sleep_state_name)); + ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]", + sleep_state_name)); status = AE_NOT_EXIST; } /* It must be of type Package */ else if (ACPI_GET_OBJECT_TYPE(info.return_object) != ACPI_TYPE_PACKAGE) { - ACPI_REPORT_ERROR(("Sleep State return object is not a Package\n")); + ACPI_ERROR((AE_INFO, + "Sleep State return object is not a Package")); status = AE_AML_OPERAND_TYPE; } @@ -180,7 +181,8 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b) * one per sleep type (A/B). */ else if (info.return_object->package.count < 2) { - ACPI_REPORT_ERROR(("Sleep State return package does not have at least two elements\n")); + ACPI_ERROR((AE_INFO, + "Sleep State return package does not have at least two elements")); status = AE_AML_NO_OPERAND; } @@ -190,7 +192,12 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b) != ACPI_TYPE_INTEGER) || (ACPI_GET_OBJECT_TYPE(info.return_object->package.elements[1]) != ACPI_TYPE_INTEGER)) { - ACPI_REPORT_ERROR(("Sleep State return package elements are not both Integers (%s, %s)\n", acpi_ut_get_object_type_name(info.return_object->package.elements[0]), acpi_ut_get_object_type_name(info.return_object->package.elements[1]))); + ACPI_ERROR((AE_INFO, + "Sleep State return package elements are not both Integers (%s, %s)", + acpi_ut_get_object_type_name(info.return_object-> + package.elements[0]), + acpi_ut_get_object_type_name(info.return_object-> + package.elements[1]))); status = AE_AML_OPERAND_TYPE; } else { /* Valid _Sx_ package size, type, and value */ @@ -202,7 +209,11 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b) } if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("%s While evaluating sleep_state [%s], bad Sleep object %p type %s\n", acpi_format_exception(status), sleep_state_name, info.return_object, acpi_ut_get_object_type_name(info.return_object))); + ACPI_EXCEPTION((AE_INFO, status, + "While evaluating sleep_state [%s], bad Sleep object %p type %s", + sleep_state_name, info.return_object, + acpi_ut_get_object_type_name(info. + return_object))); } acpi_ut_remove_reference(info.return_object); @@ -228,8 +239,8 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) ACPI_FUNCTION_ENTRY(); if (register_id > ACPI_BITREG_MAX) { - ACPI_REPORT_ERROR(("Invalid bit_register ID: %X\n", - register_id)); + ACPI_ERROR((AE_INFO, "Invalid bit_register ID: %X", + register_id)); return (NULL); } @@ -329,8 +340,8 @@ acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags) bit_reg_info = acpi_hw_get_bit_register_info(register_id); if (!bit_reg_info) { - ACPI_REPORT_ERROR(("Bad ACPI HW register_id: %X\n", - register_id)); + ACPI_ERROR((AE_INFO, "Bad ACPI HW register_id: %X", + register_id)); return_ACPI_STATUS(AE_BAD_PARAMETER); } @@ -564,7 +575,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value) break; default: - ACPI_REPORT_ERROR(("Unknown Register ID: %X\n", register_id)); + ACPI_ERROR((AE_INFO, "Unknown Register ID: %X", register_id)); status = AE_BAD_PARAMETER; break; } @@ -759,8 +770,9 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg) break; default: - ACPI_REPORT_ERROR(("Unsupported address space: %X\n", - reg->address_space_id)); + ACPI_ERROR((AE_INFO, + "Unsupported address space: %X", + reg->address_space_id)); return (AE_BAD_PARAMETER); } @@ -829,8 +841,9 @@ acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg) break; default: - ACPI_REPORT_ERROR(("Unsupported address space: %X\n", - reg->address_space_id)); + ACPI_ERROR((AE_INFO, + "Unsupported address space: %X", + reg->address_space_id)); return (AE_BAD_PARAMETER); } diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c index 992128d71117..89269272fd62 100644 --- a/drivers/acpi/hardware/hwsleep.c +++ b/drivers/acpi/hardware/hwsleep.c @@ -199,8 +199,8 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state) status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR(("Method _SST failed, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "While executing method _SST")); } return_ACPI_STATUS(AE_OK); @@ -232,9 +232,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) || (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) { - ACPI_REPORT_ERROR(("Sleep values out of range: A=%X B=%X\n", - acpi_gbl_sleep_type_a, - acpi_gbl_sleep_type_b)); + ACPI_ERROR((AE_INFO, "Sleep values out of range: A=%X B=%X", + acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b)); return_ACPI_STATUS(AE_AML_OPERAND_VALUE); } @@ -533,21 +532,18 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state) arg.integer.value = ACPI_SST_WAKING; status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR(("Method _SST failed, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "During Method _SST")); } arg.integer.value = sleep_state; status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL); if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR(("Method _BFS failed, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS")); } status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL); if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR(("Method _WAK failed, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK")); } /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ @@ -582,8 +578,7 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state) arg.integer.value = ACPI_SST_WORKING; status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR(("Method _SST failed, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "During Method _SST")); } return_ACPI_STATUS(status); diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c index c2db93e25b78..1149bc18fb35 100644 --- a/drivers/acpi/namespace/nsaccess.c +++ b/drivers/acpi/namespace/nsaccess.c @@ -110,7 +110,9 @@ acpi_status acpi_ns_root_initialize(void) ACPI_NS_NO_UPSEARCH, NULL, &new_node); if (ACPI_FAILURE(status) || (!new_node)) { /* Must be on same line for code converter */ - ACPI_REPORT_ERROR(("Could not create predefined name %s, %s\n", init_val->name, acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not create predefined name %s", + init_val->name)); } /* @@ -121,7 +123,9 @@ acpi_status acpi_ns_root_initialize(void) if (init_val->val) { status = acpi_os_predefined_override(init_val, &val); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not override predefined %s\n", init_val->name)); + ACPI_ERROR((AE_INFO, + "Could not override predefined %s", + init_val->name)); } if (!val) { @@ -228,7 +232,9 @@ acpi_status acpi_ns_root_initialize(void) default: - ACPI_REPORT_ERROR(("Unsupported initial type value %X\n", init_val->type)); + ACPI_ERROR((AE_INFO, + "Unsupported initial type value %X", + init_val->type)); acpi_ut_remove_reference(obj_desc); obj_desc = NULL; continue; @@ -334,10 +340,9 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, prefix_node = scope_info->scope.node; if (ACPI_GET_DESCRIPTOR_TYPE(prefix_node) != ACPI_DESC_TYPE_NAMED) { - ACPI_REPORT_ERROR(("%p is not a namespace node [%s]\n", - prefix_node, - acpi_ut_get_descriptor_name - (prefix_node))); + ACPI_ERROR((AE_INFO, "%p is not a namespace node [%s]", + prefix_node, + acpi_ut_get_descriptor_name(prefix_node))); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -427,7 +432,8 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, if (!this_node) { /* Current scope has no parent scope */ - ACPI_REPORT_ERROR(("ACPI path has too many parent prefixes (^) - reached beyond root node\n")); + ACPI_ERROR((AE_INFO, + "ACPI path has too many parent prefixes (^) - reached beyond root node")); return_ACPI_STATUS(AE_NOT_FOUND); } } @@ -598,7 +604,12 @@ acpi_ns_lookup(union acpi_generic_state *scope_info, (this_node->type != type_to_check_for)) { /* Complain about a type mismatch */ - ACPI_REPORT_WARNING(("ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)\n", ACPI_CAST_PTR(char, &simple_name), acpi_ut_get_type_name(this_node->type), acpi_ut_get_type_name(type_to_check_for))); + ACPI_WARNING((AE_INFO, + "ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)", + ACPI_CAST_PTR(char, &simple_name), + acpi_ut_get_type_name(this_node->type), + acpi_ut_get_type_name + (type_to_check_for))); } /* diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c index 3db950f5d5a0..9b871f38b61b 100644 --- a/drivers/acpi/namespace/nsalloc.c +++ b/drivers/acpi/namespace/nsalloc.c @@ -272,8 +272,8 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node) /* Grandchildren should have all been deleted already */ if (child_node->child) { - ACPI_REPORT_ERROR(("Found a grandchild! P=%p C=%p\n", - parent_node, child_node)); + ACPI_ERROR((AE_INFO, "Found a grandchild! P=%p C=%p", + parent_node, child_node)); } /* Now we can free this child object */ @@ -301,7 +301,9 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node) /* There should be only one reference remaining on this node */ if (child_node->reference_count != 1) { - ACPI_REPORT_WARNING(("Existing references (%d) on node being deleted (%p)\n", child_node->reference_count, child_node)); + ACPI_WARNING((AE_INFO, + "Existing references (%d) on node being deleted (%p)", + child_node->reference_count, child_node)); } /* Now we can delete the node */ diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c index 2f0b70e3e881..a2807317a84b 100644 --- a/drivers/acpi/namespace/nsdump.c +++ b/drivers/acpi/namespace/nsdump.c @@ -198,13 +198,13 @@ acpi_ns_dump_one_object(acpi_handle obj_handle, /* Check the node type and name */ if (type > ACPI_TYPE_LOCAL_MAX) { - ACPI_REPORT_WARNING(("Invalid ACPI Object Type %08X\n", - type)); + ACPI_WARNING((AE_INFO, "Invalid ACPI Object Type %08X", + type)); } if (!acpi_ut_valid_acpi_name(this_node->name.integer)) { - ACPI_REPORT_WARNING(("Invalid ACPI Name %08X\n", - this_node->name.integer)); + ACPI_WARNING((AE_INFO, "Invalid ACPI Name %08X", + this_node->name.integer)); } acpi_os_printf("%4.4s", acpi_ut_get_node_name(this_node)); diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c index e3c667072e2f..19d7b94d40c3 100644 --- a/drivers/acpi/namespace/nseval.c +++ b/drivers/acpi/namespace/nseval.c @@ -373,7 +373,7 @@ acpi_ns_execute_control_method(struct acpi_parameter_info *info) info->obj_desc = acpi_ns_get_attached_object(info->node); if (!info->obj_desc) { - ACPI_REPORT_ERROR(("No attached method object\n")); + ACPI_ERROR((AE_INFO, "No attached method object")); (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); return_ACPI_STATUS(AE_NULL_OBJECT); diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c index 6c117893f301..9f929e479fd8 100644 --- a/drivers/acpi/namespace/nsinit.c +++ b/drivers/acpi/namespace/nsinit.c @@ -93,8 +93,7 @@ acpi_status acpi_ns_initialize_objects(void) ACPI_UINT32_MAX, acpi_ns_init_one_object, &info, NULL); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("walk_namespace failed! %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "During walk_namespace")); } ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, @@ -159,12 +158,11 @@ acpi_status acpi_ns_initialize_devices(void) (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("walk_namespace failed! %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "During walk_namespace")); } ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, - "\n%hd Devices found containing: %hd _STA, %hd _INI methods\n", + "\n%hd Devices found - executed %hd _STA, %hd _INI methods\n", info.device_count, info.num_STA, info.num_INI)); return_ACPI_STATUS(status); @@ -289,7 +287,10 @@ acpi_ns_init_one_object(acpi_handle obj_handle, } if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("\nCould not execute arguments for [%4.4s] (%s), %s\n", acpi_ut_get_node_name(node), acpi_ut_get_type_name(type), acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not execute arguments for [%4.4s] (%s)", + acpi_ut_get_node_name(node), + acpi_ut_get_type_name(type))); } /* @@ -416,9 +417,8 @@ acpi_ns_init_one_device(acpi_handle obj_handle, #ifdef ACPI_DEBUG_OUTPUT char *scope_name = acpi_ns_get_external_pathname(ini_node); - ACPI_REPORT_WARNING(("%s._INI failed: %s\n", - scope_name, - acpi_format_exception(status))); + ACPI_WARNING((AE_INFO, "%s._INI failed: %s", + scope_name, acpi_format_exception(status))); ACPI_MEM_FREE(scope_name); #endif diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c index 0b4a866ef5aa..4e0b0524c188 100644 --- a/drivers/acpi/namespace/nsload.c +++ b/drivers/acpi/namespace/nsload.c @@ -92,7 +92,7 @@ acpi_ns_load_table(struct acpi_table_desc *table_desc, /* Check validity of the AML start and length */ if (!table_desc->aml_start) { - ACPI_REPORT_ERROR(("Null AML pointer\n")); + ACPI_ERROR((AE_INFO, "Null AML pointer")); return_ACPI_STATUS(AE_BAD_PARAMETER); } @@ -102,8 +102,8 @@ acpi_ns_load_table(struct acpi_table_desc *table_desc, /* Ignore table if there is no AML contained within */ if (!table_desc->aml_length) { - ACPI_REPORT_WARNING(("Zero-length AML block in table [%4.4s]\n", - table_desc->pointer->signature)); + ACPI_WARNING((AE_INFO, "Zero-length AML block in table [%4.4s]", + table_desc->pointer->signature)); return_ACPI_STATUS(AE_OK); } @@ -263,7 +263,7 @@ acpi_status acpi_ns_load_namespace(void) /* There must be at least a DSDT installed */ if (acpi_gbl_DSDT == NULL) { - ACPI_REPORT_ERROR(("DSDT is not in memory\n")); + ACPI_ERROR((AE_INFO, "DSDT is not in memory")); return_ACPI_STATUS(AE_NO_ACPI_TABLES); } diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c index 411e1f8b11d0..639f653b4b6b 100644 --- a/drivers/acpi/namespace/nsnames.c +++ b/drivers/acpi/namespace/nsnames.c @@ -110,7 +110,9 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node, name_buffer[index] = AML_ROOT_PREFIX; if (index != 0) { - ACPI_REPORT_ERROR(("Could not construct pathname; index=%X, size=%X, Path=%s\n", (u32) index, (u32) size, &name_buffer[size])); + ACPI_ERROR((AE_INFO, + "Could not construct pathname; index=%X, size=%X, Path=%s", + (u32) index, (u32) size, &name_buffer[size])); } return; @@ -146,7 +148,7 @@ char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node) name_buffer = ACPI_MEM_CALLOCATE(size); if (!name_buffer) { - ACPI_REPORT_ERROR(("Allocation failure\n")); + ACPI_ERROR((AE_INFO, "Allocation failure")); return_PTR(NULL); } diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/namespace/nsobject.c index 86113093f7b7..10ae6292bca4 100644 --- a/drivers/acpi/namespace/nsobject.c +++ b/drivers/acpi/namespace/nsobject.c @@ -84,22 +84,23 @@ acpi_ns_attach_object(struct acpi_namespace_node *node, if (!node) { /* Invalid handle */ - ACPI_REPORT_ERROR(("Null named_obj handle\n")); + ACPI_ERROR((AE_INFO, "Null named_obj handle")); return_ACPI_STATUS(AE_BAD_PARAMETER); } if (!object && (ACPI_TYPE_ANY != type)) { /* Null object */ - ACPI_REPORT_ERROR(("Null object, but type not ACPI_TYPE_ANY\n")); + ACPI_ERROR((AE_INFO, + "Null object, but type not ACPI_TYPE_ANY")); return_ACPI_STATUS(AE_BAD_PARAMETER); } if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) { /* Not a name handle */ - ACPI_REPORT_ERROR(("Invalid handle %p [%s]\n", - node, acpi_ut_get_descriptor_name(node))); + ACPI_ERROR((AE_INFO, "Invalid handle %p [%s]", + node, acpi_ut_get_descriptor_name(node))); return_ACPI_STATUS(AE_BAD_PARAMETER); } @@ -254,7 +255,7 @@ union acpi_operand_object *acpi_ns_get_attached_object(struct ACPI_FUNCTION_TRACE_PTR("ns_get_attached_object", node); if (!node) { - ACPI_REPORT_WARNING(("Null Node ptr\n")); + ACPI_WARNING((AE_INFO, "Null Node ptr")); return_PTR(NULL); } diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c index f094a2eb8512..d64b78952f24 100644 --- a/drivers/acpi/namespace/nssearch.c +++ b/drivers/acpi/namespace/nssearch.c @@ -298,15 +298,17 @@ acpi_ns_search_and_enter(u32 target_name, /* Parameter validation */ if (!node || !target_name || !return_node) { - ACPI_REPORT_ERROR(("Null param: Node %p Name %X return_node %p\n", node, target_name, return_node)); + ACPI_ERROR((AE_INFO, + "Null param: Node %p Name %X return_node %p", + node, target_name, return_node)); return_ACPI_STATUS(AE_BAD_PARAMETER); } /* Name must consist of printable characters */ if (!acpi_ut_valid_acpi_name(target_name)) { - ACPI_REPORT_ERROR(("Bad character in ACPI Name: %X\n", - target_name)); + ACPI_ERROR((AE_INFO, "Bad character in ACPI Name: %X", + target_name)); return_ACPI_STATUS(AE_BAD_CHARACTER); } diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c index bc779fdd3caf..3e7cad549a38 100644 --- a/drivers/acpi/namespace/nsutils.c +++ b/drivers/acpi/namespace/nsutils.c @@ -85,7 +85,7 @@ acpi_ns_report_error(char *module_name, if (lookup_status == AE_BAD_CHARACTER) { /* There is a non-ascii character in the name */ - acpi_os_printf("[0x%4.4X] (NON-ASCII)\n", + acpi_os_printf("[0x%4.4X] (NON-ASCII)", *(ACPI_CAST_PTR(u32, internal_name))); } else { /* Convert path to external format */ @@ -106,7 +106,7 @@ acpi_ns_report_error(char *module_name, } } - acpi_os_printf("Namespace lookup failure, %s\n", + acpi_os_printf(" Namespace lookup failure, %s\n", acpi_format_exception(lookup_status)); } @@ -242,7 +242,7 @@ acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node) ACPI_FUNCTION_TRACE("ns_get_type"); if (!node) { - ACPI_REPORT_WARNING(("Null Node parameter\n")); + ACPI_WARNING((AE_INFO, "Null Node parameter")); return_UINT32(ACPI_TYPE_ANY); } @@ -269,7 +269,7 @@ u32 acpi_ns_local(acpi_object_type type) if (!acpi_ut_valid_object_type(type)) { /* Type code out of range */ - ACPI_REPORT_WARNING(("Invalid Object Type %X\n", type)); + ACPI_WARNING((AE_INFO, "Invalid Object Type %X", type)); return_UINT32(ACPI_NS_NORMAL); } @@ -621,7 +621,7 @@ acpi_ns_externalize_name(u32 internal_name_length, * with internal_name (invalid format). */ if (required_length > internal_name_length) { - ACPI_REPORT_ERROR(("Invalid internal name\n")); + ACPI_ERROR((AE_INFO, "Invalid internal name")); return_ACPI_STATUS(AE_BAD_PATHNAME); } @@ -797,7 +797,7 @@ u32 acpi_ns_opens_scope(acpi_object_type type) if (!acpi_ut_valid_object_type(type)) { /* type code out of range */ - ACPI_REPORT_WARNING(("Invalid Object Type %X\n", type)); + ACPI_WARNING((AE_INFO, "Invalid Object Type %X", type)); return_UINT32(ACPI_NS_NORMAL); } diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c index de13add43efc..a95f636dc35d 100644 --- a/drivers/acpi/namespace/nsxfeval.c +++ b/drivers/acpi/namespace/nsxfeval.c @@ -112,7 +112,7 @@ acpi_evaluate_object_typed(acpi_handle handle, if (return_buffer->length == 0) { /* Error because caller specifically asked for a return value */ - ACPI_REPORT_ERROR(("No return value\n")); + ACPI_ERROR((AE_INFO, "No return value")); return_ACPI_STATUS(AE_NULL_OBJECT); } @@ -124,11 +124,11 @@ acpi_evaluate_object_typed(acpi_handle handle, /* Return object type does not match requested type */ - ACPI_REPORT_ERROR(("Incorrect return type [%s] requested [%s]\n", - acpi_ut_get_type_name(((union acpi_object *) - return_buffer->pointer)-> - type), - acpi_ut_get_type_name(return_type))); + ACPI_ERROR((AE_INFO, + "Incorrect return type [%s] requested [%s]", + acpi_ut_get_type_name(((union acpi_object *)return_buffer-> + pointer)->type), + acpi_ut_get_type_name(return_type))); if (must_free) { /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ @@ -235,9 +235,11 @@ acpi_evaluate_object(acpi_handle handle, * qualified names above, this is an error */ if (!pathname) { - ACPI_REPORT_ERROR(("Both Handle and Pathname are NULL\n")); + ACPI_ERROR((AE_INFO, + "Both Handle and Pathname are NULL")); } else { - ACPI_REPORT_ERROR(("Handle is NULL and Pathname is relative\n")); + ACPI_ERROR((AE_INFO, + "Handle is NULL and Pathname is relative")); } status = AE_BAD_PARAMETER; diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c index 853e6d170c96..8cd8675a47c0 100644 --- a/drivers/acpi/namespace/nsxfname.c +++ b/drivers/acpi/namespace/nsxfname.c @@ -300,8 +300,7 @@ acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer) status = acpi_ut_execute_CID(node, &cid_list); if (ACPI_SUCCESS(status)) { - size += ((acpi_size) cid_list->count - 1) * - sizeof(struct acpi_compatible_id); + size += cid_list->size; info->valid |= ACPI_VALID_CID; } diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index cc4a4903842a..ac5bbaedac1b 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -1062,9 +1062,9 @@ EXPORT_SYMBOL(max_cstate); * handle is a pointer to the spinlock_t. */ -acpi_native_uint acpi_os_acquire_lock(acpi_handle handle) +acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle) { - unsigned long flags; + acpi_cpu_flags flags; spin_lock_irqsave((spinlock_t *) handle, flags); return flags; } @@ -1073,9 +1073,9 @@ acpi_native_uint acpi_os_acquire_lock(acpi_handle handle) * Release a spinlock. See above. */ -void acpi_os_release_lock(acpi_handle handle, acpi_native_uint flags) +void acpi_os_release_lock(acpi_handle handle, acpi_cpu_flags flags) { - spin_unlock_irqrestore((spinlock_t *) handle, (unsigned long) flags); + spin_unlock_irqrestore((spinlock_t *) handle, flags); } #ifndef ACPI_USE_LOCAL_CACHE diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c index 3c37cd0ecd80..de573be52718 100644 --- a/drivers/acpi/parser/psargs.c +++ b/drivers/acpi/parser/psargs.c @@ -298,7 +298,9 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, acpi_ps_append_arg(arg, name_op); if (!method_desc) { - ACPI_REPORT_ERROR(("Control Method %p has no attached object\n", node)); + ACPI_ERROR((AE_INFO, + "Control Method %p has no attached object", + node)); return_ACPI_STATUS(AE_AML_INTERNAL); } @@ -348,7 +350,7 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state, /* Final exception check (may have been changed from code above) */ if (ACPI_FAILURE(status)) { - ACPI_REPORT_NSERROR(path, status); + ACPI_ERROR_NAMESPACE(path, status); if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) { @@ -451,7 +453,7 @@ acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state, default: - ACPI_REPORT_ERROR(("Invalid arg_type %X\n", arg_type)); + ACPI_ERROR((AE_INFO, "Invalid arg_type %X", arg_type)); return_VOID; } @@ -709,7 +711,7 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state, default: - ACPI_REPORT_ERROR(("Invalid arg_type: %X\n", arg_type)); + ACPI_ERROR((AE_INFO, "Invalid arg_type: %X", arg_type)); status = AE_AML_OPERAND_TYPE; break; } diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c index c66029b890b1..00b072e15d19 100644 --- a/drivers/acpi/parser/psloop.c +++ b/drivers/acpi/parser/psloop.c @@ -123,10 +123,12 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state) && ((status & AE_CODE_MASK) != AE_CODE_CONTROL)) { if (status == AE_AML_NO_RETURN_VALUE) { - ACPI_REPORT_ERROR(("Invoked method did not return a value, %s\n", acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Invoked method did not return a value")); } - ACPI_REPORT_ERROR(("get_predicate Failed, %s\n", acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "get_predicate Failed")); return_ACPI_STATUS(status); } @@ -184,7 +186,11 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state) /* The opcode is unrecognized. Just skip unknown opcodes */ - ACPI_REPORT_ERROR(("Found unknown opcode %X at AML address %p offset %X, ignoring\n", walk_state->opcode, parser_state->aml, walk_state->aml_offset)); + ACPI_ERROR((AE_INFO, + "Found unknown opcode %X at AML address %p offset %X, ignoring", + walk_state->opcode, + parser_state->aml, + walk_state->aml_offset)); ACPI_DUMP_BUFFER(parser_state->aml, 128); @@ -271,7 +277,8 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state) walk_state->descending_callback(walk_state, &op); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("During name lookup/catalog, %s\n", acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "During name lookup/catalog")); goto close_this_op; } diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c index 3b540fe17a0c..a9f3229f4106 100644 --- a/drivers/acpi/parser/psparse.c +++ b/drivers/acpi/parser/psparse.c @@ -512,9 +512,9 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) } else if ((status != AE_OK) && (walk_state->method_desc)) { /* Either the method parse or actual execution failed */ - ACPI_REPORT_MTERROR("Method parse/execution failed", - walk_state->method_node, NULL, - status); + ACPI_ERROR_METHOD("Method parse/execution failed", + walk_state->method_node, NULL, + status); /* Check for possible multi-thread reentrancy problem */ @@ -558,7 +558,8 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state) walk_state->method_desc->method. thread_count--; } else { - ACPI_REPORT_ERROR(("Invalid zero thread count in method\n")); + ACPI_ERROR((AE_INFO, + "Invalid zero thread count in method")); } } diff --git a/drivers/acpi/parser/pstree.c b/drivers/acpi/parser/pstree.c index d387e2b01dbb..dd6f16726fc4 100644 --- a/drivers/acpi/parser/pstree.c +++ b/drivers/acpi/parser/pstree.c @@ -132,8 +132,8 @@ acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg) if (op_info->class == AML_CLASS_UNKNOWN) { /* Invalid opcode */ - ACPI_REPORT_ERROR(("Invalid AML Opcode: 0x%2.2X\n", - op->common.aml_opcode)); + ACPI_ERROR((AE_INFO, "Invalid AML Opcode: 0x%2.2X", + op->common.aml_opcode)); return; } diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c index 1dfa6906d455..7d6481d9fbec 100644 --- a/drivers/acpi/resources/rscalc.c +++ b/drivers/acpi/resources/rscalc.c @@ -541,13 +541,13 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, for (table_index = 0; table_index < 4 && !name_found; table_index++) { - if ((ACPI_TYPE_STRING == - ACPI_GET_OBJECT_TYPE(*sub_object_list)) - || - ((ACPI_TYPE_LOCAL_REFERENCE == - ACPI_GET_OBJECT_TYPE(*sub_object_list)) - && ((*sub_object_list)->reference.opcode == - AML_INT_NAMEPATH_OP))) { + if (*sub_object_list && /* Null object allowed */ + ((ACPI_TYPE_STRING == + ACPI_GET_OBJECT_TYPE(*sub_object_list)) || + ((ACPI_TYPE_LOCAL_REFERENCE == + ACPI_GET_OBJECT_TYPE(*sub_object_list)) && + ((*sub_object_list)->reference.opcode == + AML_INT_NAMEPATH_OP)))) { name_found = TRUE; } else { /* Look at the next element */ diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c index 7f46ca0bf33a..8c128dea3252 100644 --- a/drivers/acpi/resources/rscreate.c +++ b/drivers/acpi/resources/rscreate.c @@ -207,14 +207,20 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, /* Each element of the top-level package must also be a package */ if (ACPI_GET_OBJECT_TYPE(*top_object_list) != ACPI_TYPE_PACKAGE) { - ACPI_REPORT_ERROR(("(PRT[%X]) Need sub-package, found %s\n", index, acpi_ut_get_object_type_name(*top_object_list))); + ACPI_ERROR((AE_INFO, + "(PRT[%X]) Need sub-package, found %s", + index, + acpi_ut_get_object_type_name + (*top_object_list))); return_ACPI_STATUS(AE_AML_OPERAND_TYPE); } /* Each sub-package must be of length 4 */ if ((*top_object_list)->package.count != 4) { - ACPI_REPORT_ERROR(("(PRT[%X]) Need package of length 4, found length %d\n", index, (*top_object_list)->package.count)); + ACPI_ERROR((AE_INFO, + "(PRT[%X]) Need package of length 4, found length %d", + index, (*top_object_list)->package.count)); return_ACPI_STATUS(AE_AML_PACKAGE_LIMIT); } @@ -231,7 +237,10 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { user_prt->address = obj_desc->integer.value; } else { - ACPI_REPORT_ERROR(("(PRT[%X].Address) Need Integer, found %s\n", index, acpi_ut_get_object_type_name(obj_desc))); + ACPI_ERROR((AE_INFO, + "(PRT[%X].Address) Need Integer, found %s", + index, + acpi_ut_get_object_type_name(obj_desc))); return_ACPI_STATUS(AE_BAD_DATA); } @@ -241,65 +250,83 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { user_prt->pin = (u32) obj_desc->integer.value; } else { - ACPI_REPORT_ERROR(("(PRT[%X].Pin) Need Integer, found %s\n", index, acpi_ut_get_object_type_name(obj_desc))); + ACPI_ERROR((AE_INFO, + "(PRT[%X].Pin) Need Integer, found %s", + index, + acpi_ut_get_object_type_name(obj_desc))); return_ACPI_STATUS(AE_BAD_DATA); } - /* 3) Third subobject: Dereference the PRT.source_name */ - + /* + * 3) Third subobject: Dereference the PRT.source_name + * The name may be unresolved (slack mode), so allow a null object + */ obj_desc = sub_object_list[2]; - switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { - case ACPI_TYPE_LOCAL_REFERENCE: - - if (obj_desc->reference.opcode != AML_INT_NAMEPATH_OP) { - ACPI_REPORT_ERROR(("(PRT[%X].Source) Need name, found reference op %X\n", index, obj_desc->reference.opcode)); + if (obj_desc) { + switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { + case ACPI_TYPE_LOCAL_REFERENCE: + + if (obj_desc->reference.opcode != + AML_INT_NAMEPATH_OP) { + ACPI_ERROR((AE_INFO, + "(PRT[%X].Source) Need name, found reference op %X", + index, + obj_desc->reference. + opcode)); + return_ACPI_STATUS(AE_BAD_DATA); + } + + node = obj_desc->reference.node; + + /* Use *remaining* length of the buffer as max for pathname */ + + path_buffer.length = output_buffer->length - + (u32) ((u8 *) user_prt->source - + (u8 *) output_buffer->pointer); + path_buffer.pointer = user_prt->source; + + status = + acpi_ns_handle_to_pathname((acpi_handle) + node, + &path_buffer); + + /* +1 to include null terminator */ + + user_prt->length += + (u32) ACPI_STRLEN(user_prt->source) + 1; + break; + + case ACPI_TYPE_STRING: + + ACPI_STRCPY(user_prt->source, + obj_desc->string.pointer); + + /* + * Add to the Length field the length of the string + * (add 1 for terminator) + */ + user_prt->length += obj_desc->string.length + 1; + break; + + case ACPI_TYPE_INTEGER: + /* + * If this is a number, then the Source Name is NULL, since the + * entire buffer was zeroed out, we can leave this alone. + * + * Add to the Length field the length of the u32 NULL + */ + user_prt->length += sizeof(u32); + break; + + default: + + ACPI_ERROR((AE_INFO, + "(PRT[%X].Source) Need Ref/String/Integer, found %s", + index, + acpi_ut_get_object_type_name + (obj_desc))); return_ACPI_STATUS(AE_BAD_DATA); } - - node = obj_desc->reference.node; - - /* Use *remaining* length of the buffer as max for pathname */ - - path_buffer.length = output_buffer->length - - (u32) ((u8 *) user_prt->source - - (u8 *) output_buffer->pointer); - path_buffer.pointer = user_prt->source; - - status = - acpi_ns_handle_to_pathname((acpi_handle) node, - &path_buffer); - - /* +1 to include null terminator */ - - user_prt->length += - (u32) ACPI_STRLEN(user_prt->source) + 1; - break; - - case ACPI_TYPE_STRING: - - ACPI_STRCPY(user_prt->source, obj_desc->string.pointer); - - /* - * Add to the Length field the length of the string - * (add 1 for terminator) - */ - user_prt->length += obj_desc->string.length + 1; - break; - - case ACPI_TYPE_INTEGER: - /* - * If this is a number, then the Source Name is NULL, since the - * entire buffer was zeroed out, we can leave this alone. - * - * Add to the Length field the length of the u32 NULL - */ - user_prt->length += sizeof(u32); - break; - - default: - - ACPI_REPORT_ERROR(("(PRT[%X].Source) Need Ref/String/Integer, found %s\n", index, acpi_ut_get_object_type_name(obj_desc))); - return_ACPI_STATUS(AE_BAD_DATA); } /* Now align the current length */ @@ -313,7 +340,10 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { user_prt->source_index = (u32) obj_desc->integer.value; } else { - ACPI_REPORT_ERROR(("(PRT[%X].source_index) Need Integer, found %s\n", index, acpi_ut_get_object_type_name(obj_desc))); + ACPI_ERROR((AE_INFO, + "(PRT[%X].source_index) Need Integer, found %s", + index, + acpi_ut_get_object_type_name(obj_desc))); return_ACPI_STATUS(AE_BAD_DATA); } diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c index 98356e2482c5..e7de061cf883 100644 --- a/drivers/acpi/resources/rsdump.c +++ b/drivers/acpi/resources/rsdump.c @@ -692,7 +692,11 @@ void acpi_rs_dump_irq_list(u8 * route_table) static void acpi_rs_out_string(char *title, char *value) { - acpi_os_printf("%27s : %s\n", title, value); + acpi_os_printf("%27s : %s", title, value); + if (!*value) { + acpi_os_printf("[NULL NAMESTRING]"); + } + acpi_os_printf("\n"); } static void acpi_rs_out_integer8(char *title, u8 value) diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c index e4778a51c17e..1434e786477e 100644 --- a/drivers/acpi/resources/rslist.c +++ b/drivers/acpi/resources/rslist.c @@ -94,7 +94,9 @@ acpi_rs_convert_aml_to_resources(u8 * aml, u32 aml_length, u8 * output_buffer) acpi_gbl_get_resource_dispatch [resource_index]); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not convert AML resource (Type %X) to resource, %s\n", *aml, acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not convert AML resource (Type %X)", + *aml)); return_ACPI_STATUS(status); } @@ -156,7 +158,9 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, /* Validate the (internal) Resource Type */ if (resource->type > ACPI_RESOURCE_TYPE_MAX) { - ACPI_REPORT_ERROR(("Invalid descriptor type (%X) in resource list\n", resource->type)); + ACPI_ERROR((AE_INFO, + "Invalid descriptor type (%X) in resource list", + resource->type)); return_ACPI_STATUS(AE_BAD_DATA); } @@ -169,7 +173,9 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, acpi_gbl_set_resource_dispatch [resource->type]); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not convert resource (type %X) to AML, %s\n", resource->type, acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not convert resource (type %X) to AML", + resource->type)); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c index 83bfe0dd3eba..ed866cf1c6d2 100644 --- a/drivers/acpi/resources/rsmisc.c +++ b/drivers/acpi/resources/rsmisc.c @@ -84,9 +84,11 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, ACPI_FUNCTION_TRACE("rs_get_resource"); if (((acpi_native_uint) resource) & 0x3) { - acpi_os_printf - ("**** GET: Misaligned resource pointer: %p Type %2.2X Len %X\n", - resource, resource->type, resource->length); + /* Each internal resource struct is expected to be 32-bit aligned */ + + ACPI_WARNING((AE_INFO, + "Misaligned resource pointer (get): %p Type %2.2X Len %X", + resource, resource->type, resource->length)); } /* Extract the resource Length field (does not include header length) */ @@ -274,15 +276,16 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, break; default: - acpi_os_printf - ("*** Invalid conversion sub-opcode\n"); + + ACPI_ERROR((AE_INFO, + "Invalid conversion sub-opcode")); return_ACPI_STATUS(AE_BAD_PARAMETER); } break; default: - acpi_os_printf("*** Invalid conversion opcode\n"); + ACPI_ERROR((AE_INFO, "Invalid conversion opcode")); return_ACPI_STATUS(AE_BAD_PARAMETER); } @@ -486,15 +489,16 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, break; default: - acpi_os_printf - ("*** Invalid conversion sub-opcode\n"); + + ACPI_ERROR((AE_INFO, + "Invalid conversion sub-opcode")); return_ACPI_STATUS(AE_BAD_PARAMETER); } break; default: - acpi_os_printf("*** Invalid conversion opcode\n"); + ACPI_ERROR((AE_INFO, "Invalid conversion opcode")); return_ACPI_STATUS(AE_BAD_PARAMETER); } @@ -523,7 +527,9 @@ if (((aml->irq.flags & 0x09) == 0x00) || ((aml->irq.flags & 0x09) == 0x09)) { * polarity/trigger interrupts are allowed (ACPI spec, section * "IRQ Format"), so 0x00 and 0x09 are illegal. */ - ACPI_REPORT_ERROR(("Invalid interrupt polarity/trigger in resource list, %X\n", aml->irq.flags)); + ACPI_ERROR((AE_INFO, + "Invalid interrupt polarity/trigger in resource list, %X", + aml->irq.flags)); return_ACPI_STATUS(AE_BAD_DATA); } @@ -535,7 +541,7 @@ if (temp8 < 1) { } if (resource->data.dma.transfer == 0x03) { - ACPI_REPORT_ERROR(("Invalid DMA.Transfer preference (3)\n")); + ACPI_ERROR((AE_INFO, "Invalid DMA.Transfer preference (3)")); return_ACPI_STATUS(AE_BAD_DATA); } #endif diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c index 48290b7e6ba5..03b37d2223bc 100644 --- a/drivers/acpi/tables/tbconvrt.c +++ b/drivers/acpi/tables/tbconvrt.c @@ -501,8 +501,8 @@ acpi_status acpi_tb_convert_table_fadt(void) * at least as long as the version 1.0 FADT */ if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev1)) { - ACPI_REPORT_ERROR(("FADT is invalid, too short: 0x%X\n", - acpi_gbl_FADT->length)); + ACPI_ERROR((AE_INFO, "FADT is invalid, too short: 0x%X", + acpi_gbl_FADT->length)); return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); } @@ -517,7 +517,10 @@ acpi_status acpi_tb_convert_table_fadt(void) if (acpi_gbl_FADT->length < sizeof(struct fadt_descriptor_rev2)) { /* Length is too short to be a V2.0 table */ - ACPI_REPORT_WARNING(("Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n", acpi_gbl_FADT->length, acpi_gbl_FADT->revision)); + ACPI_WARNING((AE_INFO, + "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table", + acpi_gbl_FADT->length, + acpi_gbl_FADT->revision)); acpi_tb_convert_fadt1(local_fadt, (void *)acpi_gbl_FADT); @@ -582,13 +585,15 @@ acpi_status acpi_tb_build_common_facs(struct acpi_table_desc *table_info) /* Absolute minimum length is 24, but the ACPI spec says 64 */ if (acpi_gbl_FACS->length < 24) { - ACPI_REPORT_ERROR(("Invalid FACS table length: 0x%X\n", - acpi_gbl_FACS->length)); + ACPI_ERROR((AE_INFO, "Invalid FACS table length: 0x%X", + acpi_gbl_FACS->length)); return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); } if (acpi_gbl_FACS->length < 64) { - ACPI_REPORT_WARNING(("FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n", acpi_gbl_FACS->length)); + ACPI_WARNING((AE_INFO, + "FACS is shorter than the ACPI specification allows: 0x%X, using anyway", + acpi_gbl_FACS->length)); } /* Copy fields to the new FACS */ diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c index 0fedf4b27ea5..09b4ee6dfd60 100644 --- a/drivers/acpi/tables/tbget.c +++ b/drivers/acpi/tables/tbget.c @@ -91,9 +91,9 @@ acpi_tb_get_table(struct acpi_pointer *address, status = acpi_tb_get_table_body(address, &header, table_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not get ACPI table (size %X), %s\n", - header.length, - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not get ACPI table (size %X)", + header.length)); return_ACPI_STATUS(status); } @@ -148,7 +148,6 @@ acpi_tb_get_table_header(struct acpi_pointer *address, sizeof(struct acpi_table_header), (void *)&header); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not map memory at %8.8X%8.8X for length %X\n", ACPI_FORMAT_UINT64(address->pointer.physical), sizeof(struct acpi_table_header))); return_ACPI_STATUS(status); } @@ -161,8 +160,8 @@ acpi_tb_get_table_header(struct acpi_pointer *address, default: - ACPI_REPORT_ERROR(("Invalid address flags %X\n", - address->pointer_type)); + ACPI_ERROR((AE_INFO, "Invalid address flags %X", + address->pointer_type)); return_ACPI_STATUS(AE_BAD_PARAMETER); } @@ -253,8 +252,8 @@ acpi_tb_table_override(struct acpi_table_header *header, if (ACPI_FAILURE(status)) { /* Some severe error from the OSL, but we basically ignore it */ - ACPI_REPORT_ERROR(("Could not override ACPI table, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not override ACPI table")); return_ACPI_STATUS(status); } @@ -273,15 +272,14 @@ acpi_tb_table_override(struct acpi_table_header *header, status = acpi_tb_get_this_table(&address, new_table, table_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not copy override ACPI table, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "Could not copy ACPI table")); return_ACPI_STATUS(status); } /* Copy the table info */ - ACPI_REPORT_INFO(("Table [%4.4s] replaced by host OS\n", - table_info->pointer->signature)); + ACPI_INFO((AE_INFO, "Table [%4.4s] replaced by host OS", + table_info->pointer->signature)); return_ACPI_STATUS(AE_OK); } @@ -327,7 +325,9 @@ acpi_tb_get_this_table(struct acpi_pointer *address, full_table = ACPI_MEM_ALLOCATE(header->length); if (!full_table) { - ACPI_REPORT_ERROR(("Could not allocate table memory for [%4.4s] length %X\n", header->signature, header->length)); + ACPI_ERROR((AE_INFO, + "Could not allocate table memory for [%4.4s] length %X", + header->signature, header->length)); return_ACPI_STATUS(AE_NO_MEMORY); } @@ -351,7 +351,12 @@ acpi_tb_get_this_table(struct acpi_pointer *address, (acpi_size) header->length, (void *)&full_table); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n", header->signature, ACPI_FORMAT_UINT64(address->pointer.physical), header->length)); + ACPI_ERROR((AE_INFO, + "Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X", + header->signature, + ACPI_FORMAT_UINT64(address->pointer. + physical), + header->length)); return (status); } @@ -362,8 +367,8 @@ acpi_tb_get_this_table(struct acpi_pointer *address, default: - ACPI_REPORT_ERROR(("Invalid address flags %X\n", - address->pointer_type)); + ACPI_ERROR((AE_INFO, "Invalid address flags %X", + address->pointer_type)); return_ACPI_STATUS(AE_BAD_PARAMETER); } diff --git a/drivers/acpi/tables/tbgetall.c b/drivers/acpi/tables/tbgetall.c index 496f336b3e3a..134e5dce0bc1 100644 --- a/drivers/acpi/tables/tbgetall.c +++ b/drivers/acpi/tables/tbgetall.c @@ -152,7 +152,9 @@ acpi_tb_get_secondary_table(struct acpi_pointer *address, /* Signature must match request */ if (ACPI_STRNCMP(header.signature, signature, ACPI_NAME_SIZE)) { - ACPI_REPORT_ERROR(("Incorrect table signature - wanted [%s] found [%4.4s]\n", signature, header.signature)); + ACPI_ERROR((AE_INFO, + "Incorrect table signature - wanted [%s] found [%4.4s]", + signature, header.signature)); return_ACPI_STATUS(AE_BAD_SIGNATURE); } @@ -231,14 +233,18 @@ acpi_status acpi_tb_get_required_tables(void) */ status = acpi_tb_get_primary_table(&address, &table_info); if ((status != AE_OK) && (status != AE_TABLE_NOT_SUPPORTED)) { - ACPI_REPORT_WARNING(("%s, while getting table at %8.8X%8.8X\n", acpi_format_exception(status), ACPI_FORMAT_UINT64(address.pointer.value))); + ACPI_WARNING((AE_INFO, + "%s, while getting table at %8.8X%8.8X", + acpi_format_exception(status), + ACPI_FORMAT_UINT64(address.pointer. + value))); } } /* We must have a FADT to continue */ if (!acpi_gbl_FADT) { - ACPI_REPORT_ERROR(("No FADT present in RSDT/XSDT\n")); + ACPI_ERROR((AE_INFO, "No FADT present in RSDT/XSDT")); return_ACPI_STATUS(AE_NO_ACPI_TABLES); } @@ -248,7 +254,8 @@ acpi_status acpi_tb_get_required_tables(void) */ status = acpi_tb_convert_table_fadt(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not convert FADT to internal common format\n")); + ACPI_ERROR((AE_INFO, + "Could not convert FADT to internal common format")); return_ACPI_STATUS(status); } @@ -258,8 +265,8 @@ acpi_status acpi_tb_get_required_tables(void) status = acpi_tb_get_secondary_table(&address, FACS_SIG, &table_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not get/install the FACS, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not get/install the FACS")); return_ACPI_STATUS(status); } @@ -278,7 +285,7 @@ acpi_status acpi_tb_get_required_tables(void) status = acpi_tb_get_secondary_table(&address, DSDT_SIG, &table_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not get/install the DSDT\n")); + ACPI_ERROR((AE_INFO, "Could not get/install the DSDT")); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c index e1c9faa3982e..7ffd0fddb4e5 100644 --- a/drivers/acpi/tables/tbinstal.c +++ b/drivers/acpi/tables/tbinstal.c @@ -128,8 +128,8 @@ acpi_status acpi_tb_install_table(struct acpi_table_desc *table_info) status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not acquire table mutex, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not acquire table mutex")); return_ACPI_STATUS(status); } @@ -146,9 +146,9 @@ acpi_status acpi_tb_install_table(struct acpi_table_desc *table_info) status = acpi_tb_init_table_descriptor(table_info->type, table_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not install table [%4.4s], %s\n", - table_info->pointer->signature, - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not install table [%4.4s]", + table_info->pointer->signature)); } ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s located at %p\n", diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c index 178309026850..4d308220225d 100644 --- a/drivers/acpi/tables/tbrsdt.c +++ b/drivers/acpi/tables/tbrsdt.c @@ -192,16 +192,21 @@ acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr) if (no_match) { /* Invalid RSDT or XSDT signature */ - ACPI_REPORT_ERROR(("Invalid signature where RSDP indicates RSDT/XSDT should be located. RSDP:\n")); + ACPI_ERROR((AE_INFO, + "Invalid signature where RSDP indicates RSDT/XSDT should be located. RSDP:")); ACPI_DUMP_BUFFER(acpi_gbl_RSDP, 20); - ACPI_REPORT_ERROR(("RSDT/XSDT signature at %X (%p) is invalid\n", acpi_gbl_RSDP->rsdt_physical_address, (void *)(acpi_native_uint) acpi_gbl_RSDP->rsdt_physical_address)); + ACPI_ERROR((AE_INFO, + "RSDT/XSDT signature at %X (%p) is invalid", + acpi_gbl_RSDP->rsdt_physical_address, + (void *)(acpi_native_uint) acpi_gbl_RSDP-> + rsdt_physical_address)); if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) { - ACPI_REPORT_ERROR(("Looking for RSDT\n")) + ACPI_ERROR((AE_INFO, "Looking for RSDT")); } else { - ACPI_REPORT_ERROR(("Looking for XSDT\n")) + ACPI_ERROR((AE_INFO, "Looking for XSDT")); } ACPI_DUMP_BUFFER((char *)table_ptr, 48); @@ -238,9 +243,8 @@ acpi_status acpi_tb_get_table_rsdt(void) table_info.type = ACPI_TABLE_XSDT; status = acpi_tb_get_table(&address, &table_info); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not get the RSDT/XSDT, %s\n", - acpi_format_exception(status))); - + ACPI_EXCEPTION((AE_INFO, status, + "Could not get the RSDT/XSDT")); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c index 38c6749e43d5..bc571592f087 100644 --- a/drivers/acpi/tables/tbutils.c +++ b/drivers/acpi/tables/tbutils.c @@ -149,8 +149,8 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header) /* Verify that this is a valid address */ if (!acpi_os_readable(table_header, sizeof(struct acpi_table_header))) { - ACPI_REPORT_ERROR(("Cannot read table header at %p\n", - table_header)); + ACPI_ERROR((AE_INFO, + "Cannot read table header at %p", table_header)); return (AE_BAD_ADDRESS); } @@ -159,10 +159,12 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header) ACPI_MOVE_32_TO_32(&signature, table_header->signature); if (!acpi_ut_valid_acpi_name(signature)) { - ACPI_REPORT_ERROR(("Table signature at %p [%p] has invalid characters\n", table_header, &signature)); + ACPI_ERROR((AE_INFO, + "Table signature at %p [%p] has invalid characters", + table_header, &signature)); - ACPI_REPORT_WARNING(("Invalid table signature found: [%4.4s]\n", - ACPI_CAST_PTR(char, &signature))); + ACPI_WARNING((AE_INFO, "Invalid table signature found: [%4.4s]", + ACPI_CAST_PTR(char, &signature))); ACPI_DUMP_BUFFER(table_header, sizeof(struct acpi_table_header)); @@ -172,9 +174,13 @@ acpi_tb_validate_table_header(struct acpi_table_header *table_header) /* Validate the table length */ if (table_header->length < sizeof(struct acpi_table_header)) { - ACPI_REPORT_ERROR(("Invalid length in table header %p name %4.4s\n", table_header, (char *)&signature)); + ACPI_ERROR((AE_INFO, + "Invalid length in table header %p name %4.4s", + table_header, (char *)&signature)); - ACPI_REPORT_WARNING(("Invalid table header length (0x%X) found\n", (u32) table_header->length)); + ACPI_WARNING((AE_INFO, + "Invalid table header length (0x%X) found", + (u32) table_header->length)); ACPI_DUMP_BUFFER(table_header, sizeof(struct acpi_table_header)); @@ -213,7 +219,10 @@ acpi_tb_verify_table_checksum(struct acpi_table_header * table_header) /* Return the appropriate exception */ if (checksum) { - ACPI_REPORT_WARNING(("Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n", table_header->signature, (u32) table_header->checksum, (u32) checksum)); + ACPI_WARNING((AE_INFO, + "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)", + table_header->signature, + (u32) table_header->checksum, (u32) checksum)); status = AE_BAD_CHECKSUM; } @@ -286,7 +295,7 @@ acpi_tb_handle_to_object(u16 table_id, } } - ACPI_REPORT_ERROR(("table_id=%X does not exist\n", table_id)); + ACPI_ERROR((AE_INFO, "table_id=%X does not exist", table_id)); return (AE_BAD_PARAMETER); } #endif diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c index 83a9ca8cb98c..9fe53c9d5b9a 100644 --- a/drivers/acpi/tables/tbxface.c +++ b/drivers/acpi/tables/tbxface.c @@ -75,8 +75,7 @@ acpi_status acpi_load_tables(void) status = acpi_os_get_root_pointer(ACPI_LOGICAL_ADDRESSING, &rsdp_address); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not get RSDP, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "Could not get the RSDP")); goto error_exit; } @@ -86,8 +85,7 @@ acpi_status acpi_load_tables(void) status = acpi_tb_verify_rsdp(&rsdp_address); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("RSDP Failed validation: %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "During RSDP validation")); goto error_exit; } @@ -95,8 +93,7 @@ acpi_status acpi_load_tables(void) status = acpi_tb_get_table_rsdt(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not load RSDT: %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "Could not load RSDT")); goto error_exit; } @@ -104,7 +101,8 @@ acpi_status acpi_load_tables(void) status = acpi_tb_get_required_tables(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not get all required tables (DSDT/FADT/FACS): %s\n", acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not get all required tables (DSDT/FADT/FACS)")); goto error_exit; } @@ -114,17 +112,14 @@ acpi_status acpi_load_tables(void) status = acpi_ns_load_namespace(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not load namespace: %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "Could not load namespace")); goto error_exit; } return_ACPI_STATUS(AE_OK); error_exit: - ACPI_REPORT_ERROR(("Could not load tables: %s\n", - acpi_format_exception(status))); - + ACPI_EXCEPTION((AE_INFO, status, "Could not load tables")); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c index 6538ed818f5b..a62db6af83c9 100644 --- a/drivers/acpi/tables/tbxfroot.c +++ b/drivers/acpi/tables/tbxfroot.c @@ -396,8 +396,8 @@ acpi_status acpi_find_root_pointer(u32 flags, struct acpi_pointer *rsdp_address) status = acpi_tb_find_rsdp(&table_info, flags); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("RSDP structure not found, %s Flags=%X\n", - acpi_format_exception(status), flags)); + ACPI_EXCEPTION((AE_INFO, status, + "RSDP structure not found - Flags=%X", flags)); return_ACPI_STATUS(AE_NO_ACPI_TABLES); } @@ -502,7 +502,10 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags) ACPI_EBDA_PTR_LENGTH, (void *)&table_ptr); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not map memory at %8.8X for length %X\n", ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); + ACPI_ERROR((AE_INFO, + "Could not map memory at %8.8X for length %X", + ACPI_EBDA_PTR_LOCATION, + ACPI_EBDA_PTR_LENGTH)); return_ACPI_STATUS(status); } @@ -526,7 +529,10 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags) ACPI_EBDA_WINDOW_SIZE, (void *)&table_ptr); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not map memory at %8.8X for length %X\n", physical_address, ACPI_EBDA_WINDOW_SIZE)); + ACPI_ERROR((AE_INFO, + "Could not map memory at %8.8X for length %X", + physical_address, + ACPI_EBDA_WINDOW_SIZE)); return_ACPI_STATUS(status); } @@ -556,7 +562,10 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags) (void *)&table_ptr); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not map memory at %8.8X for length %X\n", ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); + ACPI_ERROR((AE_INFO, + "Could not map memory at %8.8X for length %X", + ACPI_HI_RSDP_WINDOW_BASE, + ACPI_HI_RSDP_WINDOW_SIZE)); return_ACPI_STATUS(status); } @@ -625,7 +634,7 @@ acpi_tb_find_rsdp(struct acpi_table_desc *table_info, u32 flags) /* A valid RSDP was not found */ - ACPI_REPORT_ERROR(("No valid RSDP was found\n")); + ACPI_ERROR((AE_INFO, "No valid RSDP was found")); return_ACPI_STATUS(AE_NOT_FOUND); } diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c index 0efcbdf7e620..03b0044974c2 100644 --- a/drivers/acpi/utilities/utalloc.c +++ b/drivers/acpi/utilities/utalloc.c @@ -301,8 +301,8 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line) /* Check for an inadvertent size of zero bytes */ if (!size) { - _ACPI_REPORT_ERROR(module, line, - ("ut_allocate: Attempt to allocate zero bytes, allocating 1 byte\n")); + ACPI_ERROR((module, line, + "ut_allocate: Attempt to allocate zero bytes, allocating 1 byte")); size = 1; } @@ -310,9 +310,9 @@ void *acpi_ut_allocate(acpi_size size, u32 component, char *module, u32 line) if (!allocation) { /* Report allocation error */ - _ACPI_REPORT_ERROR(module, line, - ("ut_allocate: Could not allocate size %X\n", - (u32) size)); + ACPI_ERROR((module, line, + "ut_allocate: Could not allocate size %X", + (u32) size)); return_PTR(NULL); } @@ -344,8 +344,8 @@ void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line) /* Check for an inadvertent size of zero bytes */ if (!size) { - _ACPI_REPORT_ERROR(module, line, - ("ut_callocate: Attempt to allocate zero bytes, allocating 1 byte\n")); + ACPI_ERROR((module, line, + "Attempt to allocate zero bytes, allocating 1 byte")); size = 1; } @@ -353,9 +353,8 @@ void *acpi_ut_callocate(acpi_size size, u32 component, char *module, u32 line) if (!allocation) { /* Report allocation error */ - _ACPI_REPORT_ERROR(module, line, - ("ut_callocate: Could not allocate size %X\n", - (u32) size)); + ACPI_ERROR((module, line, + "Could not allocate size %X", (u32) size)); return_PTR(NULL); } @@ -480,9 +479,8 @@ void *acpi_ut_callocate_and_track(acpi_size size, if (!allocation) { /* Report allocation error */ - _ACPI_REPORT_ERROR(module, line, - ("ut_callocate: Could not allocate size %X\n", - (u32) size)); + ACPI_ERROR((module, line, + "Could not allocate size %X", (u32) size)); return (NULL); } @@ -524,8 +522,7 @@ acpi_ut_free_and_track(void *allocation, u32 component, char *module, u32 line) ACPI_FUNCTION_TRACE_PTR("ut_free", allocation); if (NULL == allocation) { - _ACPI_REPORT_ERROR(module, line, - ("acpi_ut_free: Attempt to delete a NULL address\n")); + ACPI_ERROR((module, line, "Attempt to delete a NULL address")); return_VOID; } @@ -540,14 +537,11 @@ acpi_ut_free_and_track(void *allocation, u32 component, char *module, u32 line) status = acpi_ut_remove_allocation(debug_block, component, module, line); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Could not free memory, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "Could not free memory")); } acpi_os_free(debug_block); - ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation)); - return_VOID; } @@ -624,10 +618,12 @@ acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation, */ element = acpi_ut_find_allocation(allocation); if (element) { - ACPI_REPORT_ERROR(("ut_track_allocation: Allocation already present in list! (%p)\n", allocation)); + ACPI_ERROR((AE_INFO, + "ut_track_allocation: Allocation already present in list! (%p)", + allocation)); - ACPI_REPORT_ERROR(("Element %p Address %p\n", - element, allocation)); + ACPI_ERROR((AE_INFO, "Element %p Address %p", + element, allocation)); goto unlock_and_exit; } @@ -687,8 +683,8 @@ acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation, if (NULL == mem_list->list_head) { /* No allocations! */ - _ACPI_REPORT_ERROR(module, line, - ("ut_remove_allocation: Empty allocation list, nothing to free!\n")); + ACPI_ERROR((module, line, + "Empty allocation list, nothing to free!")); return_ACPI_STATUS(AE_OK); } @@ -863,10 +859,11 @@ void acpi_ut_dump_allocations(u32 component, char *module) /* Print summary */ if (!num_outstanding) { - ACPI_REPORT_INFO(("No outstanding allocations\n")); + ACPI_INFO((AE_INFO, "No outstanding allocations")); } else { - ACPI_REPORT_ERROR(("%d(%X) Outstanding allocations\n", - num_outstanding, num_outstanding)); + ACPI_ERROR((AE_INFO, + "%d(%X) Outstanding allocations", + num_outstanding, num_outstanding)); } return_VOID; diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c index 1a4da006822a..df2d32096b72 100644 --- a/drivers/acpi/utilities/utcopy.c +++ b/drivers/acpi/utilities/utcopy.c @@ -606,7 +606,8 @@ acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object, /* * Packages as external input to control methods are not supported, */ - ACPI_REPORT_ERROR(("Packages as parameters not implemented!\n")); + ACPI_ERROR((AE_INFO, + "Packages as parameters not implemented!")); return_ACPI_STATUS(AE_NOT_IMPLEMENTED); } @@ -869,7 +870,7 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj, count + 1) * sizeof(void *)); if (!dest_obj->package.elements) { - ACPI_REPORT_ERROR(("Package allocation failure\n")); + ACPI_ERROR((AE_INFO, "Package allocation failure")); return_ACPI_STATUS(AE_NO_MEMORY); } diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c index 1079a1a1f195..1db9695b0029 100644 --- a/drivers/acpi/utilities/utdelete.c +++ b/drivers/acpi/utilities/utdelete.c @@ -363,7 +363,7 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action) default: - ACPI_REPORT_ERROR(("Unknown action (%X)\n", action)); + ACPI_ERROR((AE_INFO, "Unknown action (%X)", action)); break; } @@ -373,7 +373,9 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action) */ if (count > ACPI_MAX_REFERENCE_COUNT) { - ACPI_REPORT_WARNING(("Large Reference Count (%X) in object %p\n\n", count, object)); + ACPI_WARNING((AE_INFO, + "Large Reference Count (%X) in object %p", + count, object)); } return; @@ -532,8 +534,8 @@ acpi_ut_update_object_reference(union acpi_operand_object * object, u16 action) error_exit: - ACPI_REPORT_ERROR(("Could not update object reference count, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Could not update object reference count")); return_ACPI_STATUS(status); } diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c index f4dc374a0eec..106cc97cb4af 100644 --- a/drivers/acpi/utilities/uteval.c +++ b/drivers/acpi/utilities/uteval.c @@ -154,8 +154,8 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, acpi_ut_get_node_name(prefix_node), path)); } else { - ACPI_REPORT_MTERROR("Method execution failed", - prefix_node, path, status); + ACPI_ERROR_METHOD("Method execution failed", + prefix_node, path, status); } return_ACPI_STATUS(status); @@ -165,8 +165,8 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, if (!info.return_object) { if (expected_return_btypes) { - ACPI_REPORT_MTERROR("No object was returned from", - prefix_node, path, AE_NOT_EXIST); + ACPI_ERROR_METHOD("No object was returned from", + prefix_node, path, AE_NOT_EXIST); return_ACPI_STATUS(AE_NOT_EXIST); } @@ -211,10 +211,14 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, /* Is the return object one of the expected types? */ if (!(expected_return_btypes & return_btype)) { - ACPI_REPORT_MTERROR("Return object type is incorrect", - prefix_node, path, AE_TYPE); - - ACPI_REPORT_ERROR(("Type returned from %s was incorrect: %s, expected Btypes: %X\n", path, acpi_ut_get_object_type_name(info.return_object), expected_return_btypes)); + ACPI_ERROR_METHOD("Return object type is incorrect", + prefix_node, path, AE_TYPE); + + ACPI_ERROR((AE_INFO, + "Type returned from %s was incorrect: %s, expected Btypes: %X", + path, + acpi_ut_get_object_type_name(info.return_object), + expected_return_btypes)); /* On error exit, we must delete the return object */ diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c index 87ca9a0a8b76..ffd13383a325 100644 --- a/drivers/acpi/utilities/utglobal.c +++ b/drivers/acpi/utilities/utglobal.c @@ -121,8 +121,8 @@ const char *acpi_format_exception(acpi_status status) if (!exception) { /* Exception code was not recognized */ - ACPI_REPORT_ERROR(("Unknown exception code: 0x%8.8X\n", - status)); + ACPI_ERROR((AE_INFO, + "Unknown exception code: 0x%8.8X", status)); exception = "UNKNOWN_STATUS_CODE"; } diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c index 7565ba6f90d5..ba771b4f39bc 100644 --- a/drivers/acpi/utilities/utinit.c +++ b/drivers/acpi/utilities/utinit.c @@ -72,9 +72,9 @@ static void acpi_ut_fadt_register_error(char *register_name, u32 value, acpi_size offset) { - ACPI_REPORT_WARNING(("Invalid FADT value %s=%X at offset %X FADT=%p\n", - register_name, value, (u32) offset, - acpi_gbl_FADT)); + ACPI_WARNING((AE_INFO, + "Invalid FADT value %s=%X at offset %X FADT=%p", + register_name, value, (u32) offset, acpi_gbl_FADT)); } /****************************************************************************** @@ -221,7 +221,7 @@ void acpi_ut_subsystem_shutdown(void) /* Just exit if subsystem is already shutdown */ if (acpi_gbl_shutdown) { - ACPI_REPORT_ERROR(("ACPI Subsystem is already terminated\n")); + ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated")); return_VOID; } diff --git a/drivers/acpi/utilities/utmath.c b/drivers/acpi/utilities/utmath.c index 06214201329d..4a3360484e72 100644 --- a/drivers/acpi/utilities/utmath.c +++ b/drivers/acpi/utilities/utmath.c @@ -82,7 +82,7 @@ acpi_ut_short_divide(acpi_integer dividend, /* Always check for a zero divisor */ if (divisor == 0) { - ACPI_REPORT_ERROR(("Divide by zero\n")); + ACPI_ERROR((AE_INFO, "Divide by zero")); return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } @@ -144,7 +144,7 @@ acpi_ut_divide(acpi_integer in_dividend, /* Always check for a zero divisor */ if (in_divisor == 0) { - ACPI_REPORT_ERROR(("Divide by zero\n")); + ACPI_ERROR((AE_INFO, "Divide by zero")); return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } @@ -266,7 +266,7 @@ acpi_ut_short_divide(acpi_integer in_dividend, /* Always check for a zero divisor */ if (divisor == 0) { - ACPI_REPORT_ERROR(("Divide by zero\n")); + ACPI_ERROR((AE_INFO, "Divide by zero")); return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } @@ -292,7 +292,7 @@ acpi_ut_divide(acpi_integer in_dividend, /* Always check for a zero divisor */ if (in_divisor == 0) { - ACPI_REPORT_ERROR(("Divide by zero\n")); + ACPI_ERROR((AE_INFO, "Divide by zero")); return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO); } diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index a77ffcd5570f..7364f5f8c9cd 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c @@ -72,8 +72,8 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) /* Guard against multiple allocations of ID to the same location */ if (*owner_id) { - ACPI_REPORT_ERROR(("Owner ID [%2.2X] already exists\n", - *owner_id)); + ACPI_ERROR((AE_INFO, "Owner ID [%2.2X] already exists", + *owner_id)); return_ACPI_STATUS(AE_ALREADY_EXISTS); } @@ -143,7 +143,8 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) * methods, or there may be a bug where the IDs are not released. */ status = AE_OWNER_ID_LIMIT; - ACPI_REPORT_ERROR(("Could not allocate new owner_id (255 max), AE_OWNER_ID_LIMIT\n")); + ACPI_ERROR((AE_INFO, + "Could not allocate new owner_id (255 max), AE_OWNER_ID_LIMIT")); exit: (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); @@ -180,7 +181,7 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) /* Zero is not a valid owner_iD */ if (owner_id == 0) { - ACPI_REPORT_ERROR(("Invalid owner_id: %2.2X\n", owner_id)); + ACPI_ERROR((AE_INFO, "Invalid owner_id: %2.2X", owner_id)); return_VOID; } @@ -205,8 +206,9 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) if (acpi_gbl_owner_id_mask[index] & bit) { acpi_gbl_owner_id_mask[index] ^= bit; } else { - ACPI_REPORT_ERROR(("Release of non-allocated owner_id: %2.2X\n", - owner_id + 1)); + ACPI_ERROR((AE_INFO, + "Release of non-allocated owner_id: %2.2X", + owner_id + 1)); } (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); @@ -837,55 +839,95 @@ u8 acpi_ut_generate_checksum(u8 * buffer, u32 length) /******************************************************************************* * - * FUNCTION: acpi_ut_report_error + * FUNCTION: acpi_ut_error, acpi_ut_warning, acpi_ut_info * * PARAMETERS: module_name - Caller's module name (for error output) * line_number - Caller's line number (for error output) + * Format - Printf format string + additional args * * RETURN: None * - * DESCRIPTION: Print error message + * DESCRIPTION: Print message with module/line/version info * ******************************************************************************/ -void acpi_ut_report_error(char *module_name, u32 line_number) +void ACPI_INTERNAL_VAR_XFACE +acpi_ut_error(char *module_name, u32 line_number, char *format, ...) { + va_list args; acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number); + + va_start(args, format); + acpi_os_vprintf(format, args); + acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); } -/******************************************************************************* - * - * FUNCTION: acpi_ut_report_warning - * - * PARAMETERS: module_name - Caller's module name (for error output) - * line_number - Caller's line number (for error output) - * - * RETURN: None - * - * DESCRIPTION: Print warning message - * - ******************************************************************************/ +void ACPI_INTERNAL_VAR_XFACE +acpi_ut_exception(char *module_name, + u32 line_number, acpi_status status, char *format, ...) +{ + va_list args; -void acpi_ut_report_warning(char *module_name, u32 line_number) + acpi_os_printf("ACPI Exception (%s-%04d): %s, ", module_name, + line_number, acpi_format_exception(status)); + + va_start(args, format); + acpi_os_vprintf(format, args); + acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); +} + +void ACPI_INTERNAL_VAR_XFACE +acpi_ut_warning(char *module_name, u32 line_number, char *format, ...) { + va_list args; acpi_os_printf("ACPI Warning (%s-%04d): ", module_name, line_number); + + va_start(args, format); + acpi_os_vprintf(format, args); + acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); +} + +void ACPI_INTERNAL_VAR_XFACE +acpi_ut_info(char *module_name, u32 line_number, char *format, ...) +{ + va_list args; + + acpi_os_printf("ACPI (%s-%04d): ", module_name, line_number); + + va_start(args, format); + acpi_os_vprintf(format, args); + acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); } /******************************************************************************* * - * FUNCTION: acpi_ut_report_info + * FUNCTION: acpi_ut_report_error, Warning, Info * * PARAMETERS: module_name - Caller's module name (for error output) * line_number - Caller's line number (for error output) * * RETURN: None * - * DESCRIPTION: Print information message + * DESCRIPTION: Print error message + * + * Note: Legacy only, should be removed when no longer used by drivers. * ******************************************************************************/ +void acpi_ut_report_error(char *module_name, u32 line_number) +{ + + acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number); +} + +void acpi_ut_report_warning(char *module_name, u32 line_number) +{ + + acpi_os_printf("ACPI Warning (%s-%04d): ", module_name, line_number); +} + void acpi_ut_report_info(char *module_name, u32 line_number) { diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c index ffaff55270b1..45a7244df924 100644 --- a/drivers/acpi/utilities/utmutex.c +++ b/drivers/acpi/utilities/utmutex.c @@ -216,12 +216,20 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id) for (i = mutex_id; i < MAX_MUTEX; i++) { if (acpi_gbl_mutex_info[i].thread_id == this_thread_id) { if (i == mutex_id) { - ACPI_REPORT_ERROR(("Mutex [%s] already acquired by this thread [%X]\n", acpi_ut_get_mutex_name(mutex_id), this_thread_id)); + ACPI_ERROR((AE_INFO, + "Mutex [%s] already acquired by this thread [%X]", + acpi_ut_get_mutex_name + (mutex_id), + this_thread_id)); return (AE_ALREADY_ACQUIRED); } - ACPI_REPORT_ERROR(("Invalid acquire order: Thread %X owns [%s], wants [%s]\n", this_thread_id, acpi_ut_get_mutex_name(i), acpi_ut_get_mutex_name(mutex_id))); + ACPI_ERROR((AE_INFO, + "Invalid acquire order: Thread %X owns [%s], wants [%s]", + this_thread_id, + acpi_ut_get_mutex_name(i), + acpi_ut_get_mutex_name(mutex_id))); return (AE_ACQUIRE_DEADLOCK); } @@ -244,7 +252,9 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id) acpi_gbl_mutex_info[mutex_id].use_count++; acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id; } else { - ACPI_REPORT_ERROR(("Thread %X could not acquire Mutex [%X] %s\n", this_thread_id, mutex_id, acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Thread %X could not acquire Mutex [%X]", + this_thread_id, mutex_id)); } return (status); @@ -282,7 +292,9 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) * Mutex must be acquired in order to release it! */ if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) { - ACPI_REPORT_ERROR(("Mutex [%X] is not acquired, cannot release\n", mutex_id)); + ACPI_ERROR((AE_INFO, + "Mutex [%X] is not acquired, cannot release", + mutex_id)); return (AE_NOT_ACQUIRED); } @@ -303,7 +315,10 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) continue; } - ACPI_REPORT_ERROR(("Invalid release order: owns [%s], releasing [%s]\n", acpi_ut_get_mutex_name(i), acpi_ut_get_mutex_name(mutex_id))); + ACPI_ERROR((AE_INFO, + "Invalid release order: owns [%s], releasing [%s]", + acpi_ut_get_mutex_name(i), + acpi_ut_get_mutex_name(mutex_id))); return (AE_RELEASE_DEADLOCK); } @@ -319,7 +334,9 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Thread %X could not release Mutex [%X] %s\n", this_thread_id, mutex_id, acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "Thread %X could not release Mutex [%X]", + this_thread_id, mutex_id)); } else { ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c index 1b6b21577805..7ee2d1d98071 100644 --- a/drivers/acpi/utilities/utobject.c +++ b/drivers/acpi/utilities/utobject.c @@ -177,8 +177,8 @@ union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size) buffer = ACPI_MEM_CALLOCATE(buffer_size); if (!buffer) { - ACPI_REPORT_ERROR(("Could not allocate size %X\n", - (u32) buffer_size)); + ACPI_ERROR((AE_INFO, "Could not allocate size %X", + (u32) buffer_size)); acpi_ut_remove_reference(buffer_desc); return_PTR(NULL); } @@ -229,8 +229,8 @@ union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size) */ string = ACPI_MEM_CALLOCATE(string_size + 1); if (!string) { - ACPI_REPORT_ERROR(("Could not allocate size %X\n", - (u32) string_size)); + ACPI_ERROR((AE_INFO, "Could not allocate size %X", + (u32) string_size)); acpi_ut_remove_reference(string_desc); return_PTR(NULL); } @@ -312,8 +312,8 @@ void *acpi_ut_allocate_object_desc_dbg(char *module_name, object = acpi_os_acquire_object(acpi_gbl_operand_cache); if (!object) { - _ACPI_REPORT_ERROR(module_name, line_number, - ("Could not allocate an object descriptor\n")); + ACPI_ERROR((module_name, line_number, + "Could not allocate an object descriptor")); return_PTR(NULL); } @@ -347,9 +347,9 @@ void acpi_ut_delete_object_desc(union acpi_operand_object *object) /* Object must be an union acpi_operand_object */ if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) { - ACPI_REPORT_ERROR(("%p is not an ACPI Operand object [%s]\n", - object, - acpi_ut_get_descriptor_name(object))); + ACPI_ERROR((AE_INFO, + "%p is not an ACPI Operand object [%s]", object, + acpi_ut_get_descriptor_name(object))); return_VOID; } @@ -451,7 +451,10 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, * Notably, Locals and Args are not supported, but this may be * required eventually. */ - ACPI_REPORT_ERROR(("Unsupported Reference opcode=%X in object %p\n", internal_object->reference.opcode, internal_object)); + ACPI_ERROR((AE_INFO, + "Unsupported Reference opcode=%X in object %p", + internal_object->reference.opcode, + internal_object)); status = AE_TYPE; break; } @@ -459,9 +462,9 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, default: - ACPI_REPORT_ERROR(("Unsupported type=%X in object %p\n", - ACPI_GET_OBJECT_TYPE(internal_object), - internal_object)); + ACPI_ERROR((AE_INFO, "Unsupported type=%X in object %p", + ACPI_GET_OBJECT_TYPE(internal_object), + internal_object)); status = AE_TYPE; break; } diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c index 36bf9e4bf529..16461317113f 100644 --- a/drivers/acpi/utilities/utresrc.c +++ b/drivers/acpi/utilities/utresrc.c @@ -486,6 +486,7 @@ u32 acpi_ut_get_descriptor_length(void *aml) * RETURN: Status, pointer to the end tag * * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template + * Note: allows a buffer length of zero. * ******************************************************************************/ @@ -504,6 +505,13 @@ acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc, aml = obj_desc->buffer.pointer; end_aml = aml + obj_desc->buffer.length; + /* Allow a buffer length of zero */ + + if (!obj_desc->buffer.length) { + *end_tag = aml; + return_ACPI_STATUS(AE_OK); + } + /* Walk the resource template, one descriptor per iteration */ while (aml < end_aml) { @@ -518,6 +526,14 @@ acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc, if (acpi_ut_get_resource_type(aml) == ACPI_RESOURCE_NAME_END_TAG) { + /* + * There must be at least one more byte in the buffer for + * the 2nd byte of the end_tag + */ + if ((aml + 1) >= end_aml) { + return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); + } + /* Return the pointer to the end_tag */ *end_tag = aml; diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c index b4bc94883200..308a960871be 100644 --- a/drivers/acpi/utilities/utxface.c +++ b/drivers/acpi/utilities/utxface.c @@ -75,8 +75,7 @@ acpi_status acpi_initialize_subsystem(void) status = acpi_os_initialize(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("OSL failed to initialize, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization")); return_ACPI_STATUS(status); } @@ -88,8 +87,8 @@ acpi_status acpi_initialize_subsystem(void) status = acpi_ut_mutex_initialize(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Global mutex creation failure, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "During Global Mutex creation")); return_ACPI_STATUS(status); } @@ -99,15 +98,14 @@ acpi_status acpi_initialize_subsystem(void) */ status = acpi_ns_root_initialize(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_ERROR(("Namespace initialization failure, %s\n", - acpi_format_exception(status))); + ACPI_EXCEPTION((AE_INFO, status, + "During Namespace initialization")); return_ACPI_STATUS(status); } /* If configured, initialize the AML debugger */ ACPI_DEBUGGER_EXEC(status = acpi_db_initialize()); - return_ACPI_STATUS(status); } @@ -154,7 +152,7 @@ acpi_status acpi_enable_subsystem(u32 flags) status = acpi_enable(); if (ACPI_FAILURE(status)) { - ACPI_REPORT_WARNING(("acpi_enable failed\n")); + ACPI_WARNING((AE_INFO, "acpi_enable failed")); return_ACPI_STATUS(status); } } diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index 675a32f78329..e27dc8f29972 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h @@ -63,7 +63,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20060113 +#define ACPI_CA_VERSION 0x20060127 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, @@ -83,7 +83,7 @@ #define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */ /* - * Should the subystem abort the loading of an ACPI table if the + * Should the subsystem abort the loading of an ACPI table if the * table checksum is incorrect? */ #define ACPI_CHECKSUM_ABORT FALSE diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h index 97f8e4185e4f..8361820d2970 100644 --- a/include/acpi/aclocal.h +++ b/include/acpi/aclocal.h @@ -416,13 +416,13 @@ struct acpi_field_info { #define ACPI_CONTROL_PREDICATE_FALSE 0xC3 #define ACPI_CONTROL_PREDICATE_TRUE 0xC4 -#define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ - u8 data_type; /* To differentiate various internal objs */\ +#define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ + u8 data_type; /* To differentiate various internal objs */\ u8 flags; \ u16 value; \ u16 state; \ u16 reserved; \ - void *next; \ + void *next; struct acpi_common_state { ACPI_STATE_COMMON}; @@ -575,8 +575,7 @@ union acpi_parse_value { char aml_op_name[16]) /* Op name (debug only) */\ /* NON-DEBUG members below: */\ struct acpi_namespace_node *node; /* For use by interpreter */\ - union acpi_parse_value value; /* Value or args associated with the opcode */\ - + union acpi_parse_value value; /* Value or args associated with the opcode */ #define ACPI_DASM_BUFFER 0x00 #define ACPI_DASM_RESOURCE 0x01 diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h index 49ba151766de..f2be2a881730 100644 --- a/include/acpi/acmacros.h +++ b/include/acpi/acmacros.h @@ -341,8 +341,12 @@ /* * Rounding macros (Power of two boundaries only) */ -#define ACPI_ROUND_DOWN(value,boundary) (((acpi_native_uint)(value)) & (~(((acpi_native_uint) boundary)-1))) -#define ACPI_ROUND_UP(value,boundary) ((((acpi_native_uint)(value)) + (((acpi_native_uint) boundary)-1)) & (~(((acpi_native_uint) boundary)-1))) +#define ACPI_ROUND_DOWN(value,boundary) (((acpi_native_uint)(value)) & \ + (~(((acpi_native_uint) boundary)-1))) + +#define ACPI_ROUND_UP(value,boundary) ((((acpi_native_uint)(value)) + \ + (((acpi_native_uint) boundary)-1)) & \ + (~(((acpi_native_uint) boundary)-1))) #define ACPI_ROUND_DOWN_TO_32_BITS(a) ACPI_ROUND_DOWN(a,4) #define ACPI_ROUND_DOWN_TO_64_BITS(a) ACPI_ROUND_DOWN(a,8) @@ -379,10 +383,11 @@ /* Generate a UUID */ -#define ACPI_INIT_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) (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) +#define ACPI_INIT_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ + (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) /* * An struct acpi_namespace_node * can appear in some contexts, @@ -442,13 +447,12 @@ #define GET_CURRENT_ARG_TYPE(list) (list & ((u32) 0x1F)) #define INCREMENT_ARG_LIST(list) (list >>= ((u32) ARG_TYPE_WIDTH)) +#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES) /* * Module name is include in both debug and non-debug versions primarily for * error messages. The __FILE__ macro is not very useful for this, because it * often includes the entire pathname to the module */ -#if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES) - #define ACPI_MODULE_NAME(name) static char ACPI_UNUSED_VAR *_acpi_module_name = name; #else #define ACPI_MODULE_NAME(name) @@ -458,45 +462,31 @@ * Ascii error messages can be configured out */ #ifndef ACPI_NO_ERROR_MESSAGES - -#define ACPI_PARAM_LIST(pl) pl -#define ACPI_LOCATION_INFO _acpi_module_name, __LINE__ +#define AE_INFO _acpi_module_name, __LINE__ /* - * Error reporting. Callers module and line number are inserted automatically - * These macros are used for both the debug and non-debug versions of the code + * Error reporting. Callers module and line number are inserted by AE_INFO, + * the plist contains a set of parens to allow variable-length lists. + * These macros are used for both the debug and non-debug versions of the code. */ -#define ACPI_REPORT_INFO(fp) {acpi_ut_report_info (ACPI_LOCATION_INFO); \ - acpi_os_printf ACPI_PARAM_LIST (fp);} -#define ACPI_REPORT_ERROR(fp) {acpi_ut_report_error (ACPI_LOCATION_INFO); \ - acpi_os_printf ACPI_PARAM_LIST (fp);} -#define ACPI_REPORT_WARNING(fp) {acpi_ut_report_warning (ACPI_LOCATION_INFO); \ - acpi_os_printf ACPI_PARAM_LIST (fp);} -#define ACPI_REPORT_NSERROR(s,e) acpi_ns_report_error (ACPI_LOCATION_INFO, \ - s, e); -#define ACPI_REPORT_MTERROR(s,n,p,e) acpi_ns_report_method_error (ACPI_LOCATION_INFO, \ - s, n, p, e); - -/* Error reporting. These versions pass thru the module and lineno */ +#define ACPI_INFO(plist) acpi_ut_info plist +#define ACPI_WARNING(plist) acpi_ut_warning plist +#define ACPI_EXCEPTION(plist) acpi_ut_exception plist +#define ACPI_ERROR(plist) acpi_ut_error plist +#define ACPI_ERROR_NAMESPACE(s,e) acpi_ns_report_error (AE_INFO, s, e); +#define ACPI_ERROR_METHOD(s,n,p,e) acpi_ns_report_method_error (AE_INFO, s, n, p, e); -#define _ACPI_REPORT_INFO(a,b,fp) {acpi_ut_report_info (a,b); \ - acpi_os_printf ACPI_PARAM_LIST (fp);} -#define _ACPI_REPORT_ERROR(a,b,fp) {acpi_ut_report_error (a,b); \ - acpi_os_printf ACPI_PARAM_LIST (fp);} -#define _ACPI_REPORT_WARNING(a,b,fp) {acpi_ut_report_warning (a,b); \ - acpi_os_printf ACPI_PARAM_LIST (fp);} #else /* No error messages */ -#define ACPI_REPORT_INFO(fp) -#define ACPI_REPORT_ERROR(fp) -#define ACPI_REPORT_WARNING(fp) -#define ACPI_REPORT_NSERROR(s,e) -#define ACPI_REPORT_MTERROR(s,n,p,e) -#define _ACPI_REPORT_INFO(a,b,c,fp) -#define _ACPI_REPORT_ERROR(a,b,c,fp) -#define _ACPI_REPORT_WARNING(a,b,c,fp) +#define ACPI_INFO(plist) +#define ACPI_WARNING(plist) +#define ACPI_EXCEPTION(plist) +#define ACPI_ERROR(plist) +#define ACPI_ERROR_NAMESPACE(s,e) +#define ACPI_ERROR_METHOD(s,n,p,e) + #endif /* @@ -538,7 +528,7 @@ #endif #define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ - acpi_ut_trace(ACPI_DEBUG_PARAMETERS) + acpi_ut_trace(ACPI_DEBUG_PARAMETERS) #define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \ acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS,(void *)b) #define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \ @@ -632,18 +622,6 @@ #define ACPI_DUMP_PATHNAME(a,b,c,d) acpi_ns_dump_pathname(a,b,c,d) #define ACPI_DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a) #define ACPI_DUMP_BUFFER(a,b) acpi_ut_dump_buffer((u8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT) -#define ACPI_BREAK_MSG(a) acpi_os_signal (ACPI_SIGNAL_BREAKPOINT,(a)) - -/* - * Generate INT3 on ACPI_ERROR (Debug only!) - */ -#define ACPI_ERROR_BREAK -#ifdef ACPI_ERROR_BREAK -#define ACPI_BREAK_ON_ERROR(lvl) if ((lvl)&ACPI_ERROR) \ - acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,"Fatal error encountered\n") -#else -#define ACPI_BREAK_ON_ERROR(lvl) -#endif /* * Master debug print macros @@ -651,8 +629,8 @@ * 1) Debug print for the current component is enabled * 2) Debug error level or trace level for the print statement is enabled */ -#define ACPI_DEBUG_PRINT(pl) acpi_ut_debug_print ACPI_PARAM_LIST(pl) -#define ACPI_DEBUG_PRINT_RAW(pl) acpi_ut_debug_print_raw ACPI_PARAM_LIST(pl) +#define ACPI_DEBUG_PRINT(plist) acpi_ut_debug_print plist +#define ACPI_DEBUG_PRINT_RAW(plist) acpi_ut_debug_print_raw plist #else /* @@ -681,7 +659,6 @@ #define ACPI_DUMP_BUFFER(a,b) #define ACPI_DEBUG_PRINT(pl) #define ACPI_DEBUG_PRINT_RAW(pl) -#define ACPI_BREAK_MSG(a) #define return_VOID return #define return_ACPI_STATUS(s) return(s) diff --git a/include/acpi/acobject.h b/include/acpi/acobject.h index 1bd411962c77..d130cfed8d55 100644 --- a/include/acpi/acobject.h +++ b/include/acpi/acobject.h @@ -69,7 +69,7 @@ u8 type; /* acpi_object_type */\ u16 reference_count; /* For object deletion management */\ union acpi_operand_object *next_object; /* Objects linked to parent NS node */\ - u8 flags; \ + u8 flags; /* Values for flag byte above */ diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h index 768f63f391cd..970e9a6372c3 100644 --- a/include/acpi/acpiosxf.h +++ b/include/acpi/acpiosxf.h @@ -108,9 +108,9 @@ acpi_status acpi_os_create_lock(acpi_handle * out_handle); void acpi_os_delete_lock(acpi_handle handle); -acpi_native_uint acpi_os_acquire_lock(acpi_handle handle); +acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle); -void acpi_os_release_lock(acpi_handle handle, acpi_native_uint flags); +void acpi_os_release_lock(acpi_handle handle, acpi_cpu_flags flags); /* * Memory allocation and mapping diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 74819e9b4699..7ca89cde706e 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -237,17 +237,22 @@ typedef char *acpi_physical_address; #error unknown ACPI_MACHINE_WIDTH #endif +/* Variable-width type, used instead of clib size_t */ + +typedef acpi_native_uint acpi_size; + /******************************************************************************* * * OS- or compiler-dependent types * + * If the defaults below are not appropriate for the host system, they can + * be defined in the compiler-specific or OS-specific header, and this will + * take precedence. + * ******************************************************************************/ -/* - * If acpi_uintptr_t was not defined in the OS- or compiler-dependent header, - * define it now (use C99 uintptr_t for pointer casting if available, - * "void *" otherwise) - */ +/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */ + #ifndef acpi_uintptr_t #define acpi_uintptr_t void * #endif @@ -261,9 +266,31 @@ typedef char *acpi_physical_address; #define acpi_cache_t struct acpi_memory_list #endif -/* Variable-width type, used instead of clib size_t */ +/* + * Allow the CPU flags word to be defined per-OS to simplify the use of the + * lock and unlock OSL interfaces. + */ +#ifndef acpi_cpu_flags +#define acpi_cpu_flags acpi_native_uint +#endif -typedef acpi_native_uint acpi_size; +/* + * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because + * some compilers can catch printf format string problems + */ +#ifndef ACPI_PRINTF_LIKE +#define ACPI_PRINTF_LIKE(c) +#endif + +/* + * Some compilers complain about unused variables. Sometimes we don't want to + * use all the variables (for example, _acpi_module_name). This allows us + * to to tell the compiler in a per-variable manner that a variable + * is unused + */ +#ifndef ACPI_UNUSED_VAR +#define ACPI_UNUSED_VAR +#endif /******************************************************************************* * diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h index 10f6625f6390..0927765df6aa 100644 --- a/include/acpi/acutils.h +++ b/include/acpi/acutils.h @@ -275,20 +275,22 @@ acpi_ut_ptr_exit(u32 line_number, const char *function_name, char *module_name, u32 component_id, u8 * ptr); +void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id); + void acpi_ut_report_error(char *module_name, u32 line_number); void acpi_ut_report_info(char *module_name, u32 line_number); void acpi_ut_report_warning(char *module_name, u32 line_number); -void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id); +/* Error and message reporting interfaces */ void ACPI_INTERNAL_VAR_XFACE acpi_ut_debug_print(u32 requested_debug_level, u32 line_number, const char *function_name, char *module_name, - u32 component_id, char *format, ...) ACPI_PRINTF_LIKE_FUNC; + u32 component_id, char *format, ...) ACPI_PRINTF_LIKE(6); void ACPI_INTERNAL_VAR_XFACE acpi_ut_debug_print_raw(u32 requested_debug_level, @@ -296,7 +298,24 @@ acpi_ut_debug_print_raw(u32 requested_debug_level, const char *function_name, char *module_name, u32 component_id, - char *format, ...) ACPI_PRINTF_LIKE_FUNC; + char *format, ...) ACPI_PRINTF_LIKE(6); + +void ACPI_INTERNAL_VAR_XFACE +acpi_ut_error(char *module_name, + u32 line_number, char *format, ...) ACPI_PRINTF_LIKE(3); + +void ACPI_INTERNAL_VAR_XFACE +acpi_ut_exception(char *module_name, + u32 line_number, + acpi_status status, char *format, ...) ACPI_PRINTF_LIKE(4); + +void ACPI_INTERNAL_VAR_XFACE +acpi_ut_warning(char *module_name, + u32 line_number, char *format, ...) ACPI_PRINTF_LIKE(3); + +void ACPI_INTERNAL_VAR_XFACE +acpi_ut_info(char *module_name, + u32 line_number, char *format, ...) ACPI_PRINTF_LIKE(3); /* * utdelete - Object deletion and reference counts diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h index 31b0f18342f6..223ec6467108 100644 --- a/include/acpi/platform/acenv.h +++ b/include/acpi/platform/acenv.h @@ -149,6 +149,9 @@ #elif defined(NETWARE) #include "acnetware.h" +#elif defined(__sun) +#include "acsolaris.h" + #else /* All other environments */ @@ -158,13 +161,6 @@ #define COMPILER_DEPENDENT_INT64 long long #define COMPILER_DEPENDENT_UINT64 unsigned long long -/* - * This macro is used to tag functions as "printf-like" because - * some compilers can catch printf format string problems. MSVC - * doesn't, so this is proprocessed away. - */ -#define ACPI_PRINTF_LIKE_FUNC - #endif /* diff --git a/include/acpi/platform/acgcc.h b/include/acpi/platform/acgcc.h index ea2a6322f64d..da80933963db 100644 --- a/include/acpi/platform/acgcc.h +++ b/include/acpi/platform/acgcc.h @@ -48,12 +48,14 @@ #define ACPI_GET_FUNCTION_NAME __FUNCTION__ -/* This macro is used to tag functions as "printf-like" because +/* + * This macro is used to tag functions as "printf-like" because * some compilers (like GCC) can catch printf format string problems. */ -#define ACPI_PRINTF_LIKE_FUNC __attribute__ ((__format__ (__printf__, 6, 7))) +#define ACPI_PRINTF_LIKE(c) __attribute__ ((__format__ (__printf__, c, c+1))) -/* Some compilers complain about unused variables. Sometimes we don't want to +/* + * Some compilers complain about unused variables. Sometimes we don't want to * use all the variables (for example, _acpi_module_name). This allows us * to to tell the compiler warning in a per-variable manner that a variable * is unused. diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h index c21c27fe7e1e..2e6d54569ee8 100644 --- a/include/acpi/platform/aclinux.h +++ b/include/acpi/platform/aclinux.h @@ -102,4 +102,6 @@ #include "acgcc.h" +#define acpi_cpu_flags unsigned long + #endif /* __ACLINUX_H__ */ -- cgit v1.2.3 From 7ce08c93e388922e25a96a7d9895784182e4c72c Mon Sep 17 00:00:00 2001 From: Luca Risolia Date: Wed, 11 Jan 2006 02:06:59 +0000 Subject: [PATCH] USB: Add ET61X[12]51 Video4Linux2 driver This patch adds a Video4Linux2 driver giving support to ET61X151 and ET61X251 PC Camera Controllers made by Etoms Electronics. Signed-off-by: Luca Risolia Signed-off-by: Greg Kroah-Hartman --- Documentation/usb/et61x251.txt | 306 ++++ MAINTAINERS | 10 + drivers/usb/Makefile | 1 + drivers/usb/media/Kconfig | 17 +- drivers/usb/media/Makefile | 2 + drivers/usb/media/et61x251.h | 220 +++ drivers/usb/media/et61x251_core.c | 2605 +++++++++++++++++++++++++++++++ drivers/usb/media/et61x251_sensor.h | 115 ++ drivers/usb/media/et61x251_tas5130d1b.c | 137 ++ include/linux/videodev2.h | 1 + 10 files changed, 3412 insertions(+), 2 deletions(-) create mode 100644 Documentation/usb/et61x251.txt create mode 100644 drivers/usb/media/et61x251.h create mode 100644 drivers/usb/media/et61x251_core.c create mode 100644 drivers/usb/media/et61x251_sensor.h create mode 100644 drivers/usb/media/et61x251_tas5130d1b.c (limited to 'include') diff --git a/Documentation/usb/et61x251.txt b/Documentation/usb/et61x251.txt new file mode 100644 index 000000000000..b44dda407ce2 --- /dev/null +++ b/Documentation/usb/et61x251.txt @@ -0,0 +1,306 @@ + + ET61X[12]51 PC Camera Controllers + Driver for Linux + ================================= + + - Documentation - + + +Index +===== +1. Copyright +2. Disclaimer +3. License +4. Overview and features +5. Module dependencies +6. Module loading +7. Module parameters +8. Optional device control through "sysfs" +9. Supported devices +10. Notes for V4L2 application developers +11. Contact information + + +1. Copyright +============ +Copyright (C) 2006 by Luca Risolia + + +2. Disclaimer +============= +Etoms is a trademark of Etoms Electronics Corp. +This software is not developed or sponsored by Etoms Electronics. + + +3. License +========== +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + +4. Overview and features +======================== +This driver supports the video interface of the devices mounting the ET61X151 +or ET61X251 PC Camera Controllers. + +It's worth to note that Etoms Electronics has never collaborated with the +author during the development of this project; despite several requests, +Etoms Electronics also refused to release enough detailed specifications of +the video compression engine. + +The driver relies on the Video4Linux2 and USB core modules. It has been +designed to run properly on SMP systems as well. + +The latest version of the ET61X[12]51 driver can be found at the following URL: +http://www.linux-projects.org/ + +Some of the features of the driver are: + +- full compliance with the Video4Linux2 API (see also "Notes for V4L2 + application developers" paragraph); +- available mmap or read/poll methods for video streaming through isochronous + data transfers; +- automatic detection of image sensor; +- support for any window resolutions and optional panning within the maximum + pixel area of image sensor; +- image downscaling with arbitrary scaling factors from 1 and 2 in both + directions (see "Notes for V4L2 application developers" paragraph); +- two different video formats for uncompressed or compressed data in low or + high compression quality (see also "Notes for V4L2 application developers" + paragraph); +- full support for the capabilities of every possible image sensors that can + be connected to the ET61X[12]51 bridges, including, for istance, red, green, + blue and global gain adjustments and exposure control (see "Supported + devices" paragraph for details); +- use of default color settings for sunlight conditions; +- dynamic I/O interface for both ET61X[12]51 and image sensor control (see + "Optional device control through 'sysfs'" paragraph); +- dynamic driver control thanks to various module parameters (see "Module + parameters" paragraph); +- up to 64 cameras can be handled at the same time; they can be connected and + disconnected from the host many times without turning off the computer, if + the system supports hotplugging; +- no known bugs. + + +5. Module dependencies +====================== +For it to work properly, the driver needs kernel support for Video4Linux and +USB. + +The following options of the kernel configuration file must be enabled and +corresponding modules must be compiled: + + # Multimedia devices + # + CONFIG_VIDEO_DEV=m + +To enable advanced debugging functionality on the device through /sysfs: + + # Multimedia devices + # + CONFIG_VIDEO_ADV_DEBUG=y + + # USB support + # + CONFIG_USB=m + +In addition, depending on the hardware being used, the modules below are +necessary: + + # USB Host Controller Drivers + # + CONFIG_USB_EHCI_HCD=m + CONFIG_USB_UHCI_HCD=m + CONFIG_USB_OHCI_HCD=m + +And finally: + + # USB Multimedia devices + # + CONFIG_USB_ET61X251=m + + +6. Module loading +================= +To use the driver, it is necessary to load the "et61x251" module into memory +after every other module required: "videodev", "usbcore" and, depending on +the USB host controller you have, "ehci-hcd", "uhci-hcd" or "ohci-hcd". + +Loading can be done as shown below: + + [root@localhost home]# modprobe et61x251 + +At this point the devices should be recognized. You can invoke "dmesg" to +analyze kernel messages and verify that the loading process has gone well: + + [user@localhost home]$ dmesg + + +7. Module parameters +==================== +Module parameters are listed below: +------------------------------------------------------------------------------- +Name: video_nr +Type: short array (min = 0, max = 64) +Syntax: <-1|n[,...]> +Description: Specify V4L2 minor mode number: + -1 = use next available + n = use minor number n + You can specify up to 64 cameras this way. + For example: + video_nr=-1,2,-1 would assign minor number 2 to the second + registered camera and use auto for the first one and for every + other camera. +Default: -1 +------------------------------------------------------------------------------- +Name: force_munmap +Type: bool array (min = 0, max = 64) +Syntax: <0|1[,...]> +Description: Force the application to unmap previously mapped buffer memory + before calling any VIDIOC_S_CROP or VIDIOC_S_FMT ioctl's. Not + all the applications support this feature. This parameter is + specific for each detected camera. + 0 = do not force memory unmapping + 1 = force memory unmapping (save memory) +Default: 0 +------------------------------------------------------------------------------- +Name: debug +Type: ushort +Syntax: +Description: Debugging information level, from 0 to 3: + 0 = none (use carefully) + 1 = critical errors + 2 = significant informations + 3 = more verbose messages + Level 3 is useful for testing only, when only one device + is used at the same time. It also shows some more informations + about the hardware being detected. This module parameter can be + changed at runtime thanks to the /sys filesystem interface. +Default: 2 +------------------------------------------------------------------------------- + + +8. Optional device control through "sysfs" +========================================== +If the kernel has been compiled with the CONFIG_VIDEO_ADV_DEBUG option enabled, +it is possible to read and write both the ET61X[12]51 and the image sensor +registers by using the "sysfs" filesystem interface. + +There are four files in the /sys/class/video4linux/videoX directory for each +registered camera: "reg", "val", "i2c_reg" and "i2c_val". The first two files +control the ET61X[12]51 bridge, while the other two control the sensor chip. +"reg" and "i2c_reg" hold the values of the current register index where the +following reading/writing operations are addressed at through "val" and +"i2c_val". Their use is not intended for end-users, unless you know what you +are doing. Remember that you must be logged in as root before writing to them. + +As an example, suppose we were to want to read the value contained in the +register number 1 of the sensor register table - which is usually the product +identifier - of the camera registered as "/dev/video0": + + [root@localhost #] cd /sys/class/video4linux/video0 + [root@localhost #] echo 1 > i2c_reg + [root@localhost #] cat i2c_val + +Note that if the sensor registers can not be read, "cat" will fail. +To avoid race conditions, all the I/O accesses to the files are serialized. + + +9. Supported devices +==================== +None of the names of the companies as well as their products will be mentioned +here. They have never collaborated with the author, so no advertising. + +From the point of view of a driver, what unambiguously identify a device are +its vendor and product USB identifiers. Below is a list of known identifiers of +devices mounting the ET61X[12]51 PC camera controllers: + +Vendor ID Product ID +--------- ---------- +0x102c 0x6151 +0x102c 0x6251 +0x102c 0x6253 +0x102c 0x6254 +0x102c 0x6255 +0x102c 0x6256 +0x102c 0x6257 +0x102c 0x6258 +0x102c 0x6259 +0x102c 0x625a +0x102c 0x625b +0x102c 0x625c +0x102c 0x625d +0x102c 0x625e +0x102c 0x625f +0x102c 0x6260 +0x102c 0x6261 +0x102c 0x6262 +0x102c 0x6263 +0x102c 0x6264 +0x102c 0x6265 +0x102c 0x6266 +0x102c 0x6267 +0x102c 0x6268 +0x102c 0x6269 + +The following image sensors are supported: + +Model Manufacturer +----- ------------ +TAS5130D1B Taiwan Advanced Sensor Corporation + +All the available control settings of each image sensor are supported through +the V4L2 interface. + + +10. Notes for V4L2 application developers +======================================== +This driver follows the V4L2 API specifications. In particular, it enforces two +rules: + +- exactly one I/O method, either "mmap" or "read", is associated with each +file descriptor. Once it is selected, the application must close and reopen the +device to switch to the other I/O method; + +- although it is not mandatory, previously mapped buffer memory should always +be unmapped before calling any "VIDIOC_S_CROP" or "VIDIOC_S_FMT" ioctl's. +The same number of buffers as before will be allocated again to match the size +of the new video frames, so you have to map the buffers again before any I/O +attempts on them. + +Consistently with the hardware limits, this driver also supports image +downscaling with arbitrary scaling factors from 1 and 2 in both directions. +However, the V4L2 API specifications don't correctly define how the scaling +factor can be chosen arbitrarily by the "negotiation" of the "source" and +"target" rectangles. To work around this flaw, we have added the convention +that, during the negotiation, whenever the "VIDIOC_S_CROP" ioctl is issued, the +scaling factor is restored to 1. + +This driver supports two different video formats: the first one is the "8-bit +Sequential Bayer" format and can be used to obtain uncompressed video data +from the device through the current I/O method, while the second one provides +"raw" compressed video data (without frame headers not related to the +compressed data). The current compression quality may vary from 0 to 1 and can +be selected or queried thanks to the VIDIOC_S_JPEGCOMP and VIDIOC_G_JPEGCOMP +V4L2 ioctl's. + + +11. Contact information +======================= +The author may be contacted by e-mail at . + +GPG/PGP encrypted e-mail's are accepted. The GPG key ID of the author is +'FCE635A4'; the public 1024-bit key should be available at any keyserver; +the fingerprint is: '88E8 F32F 7244 68BA 3958 5D40 99DA 5D2A FCE6 35A4'. diff --git a/MAINTAINERS b/MAINTAINERS index a37a2b38a557..42955fe1ffa0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2673,6 +2673,14 @@ M: dbrownell@users.sourceforge.net L: linux-usb-devel@lists.sourceforge.net S: Maintained +USB ET61X[12]51 DRIVER +P: Luca Risolia +M: luca.risolia@studio.unibo.it +L: linux-usb-devel@lists.sourceforge.net +L: video4linux-list@redhat.com +W: http://www.linux-projects.org +S: Maintained + USB HID/HIDBP DRIVERS P: Vojtech Pavlik M: vojtech@suse.cz @@ -2836,6 +2844,7 @@ USB SN9C10x DRIVER P: Luca Risolia M: luca.risolia@studio.unibo.it L: linux-usb-devel@lists.sourceforge.net +L: video4linux-list@redhat.com W: http://www.linux-projects.org S: Maintained @@ -2865,6 +2874,7 @@ USB W996[87]CF DRIVER P: Luca Risolia M: luca.risolia@studio.unibo.it L: linux-usb-devel@lists.sourceforge.net +L: video4linux-list@redhat.com W: http://www.linux-projects.org S: Maintained diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile index 3639c3f8d357..36e476dd9123 100644 --- a/drivers/usb/Makefile +++ b/drivers/usb/Makefile @@ -38,6 +38,7 @@ obj-$(CONFIG_USB_XPAD) += input/ obj-$(CONFIG_USB_DABUSB) += media/ obj-$(CONFIG_USB_DSBR) += media/ +obj-$(CONFIG_USB_ET61X251) += media/ obj-$(CONFIG_USB_IBMCAM) += media/ obj-$(CONFIG_USB_KONICAWC) += media/ obj-$(CONFIG_USB_OV511) += media/ diff --git a/drivers/usb/media/Kconfig b/drivers/usb/media/Kconfig index 21232ee2974c..0d3d2cc5d7be 100644 --- a/drivers/usb/media/Kconfig +++ b/drivers/usb/media/Kconfig @@ -53,6 +53,21 @@ config USB_DSBR To compile this driver as a module, choose M here: the module will be called dsbr100. +config USB_ET61X251 + tristate "USB ET61X[12]51 PC Camera Controller support" + depends on USB && VIDEO_DEV + ---help--- + Say Y here if you want support for cameras based on Etoms ET61X151 + or ET61X251 PC Camera Controllers. + + See for more informations. + + This driver uses the Video For Linux API. You must say Y or M to + "Video For Linux" to use this driver. + + To compile this driver as a module, choose M here: the + module will be called et61x251. + config USB_IBMCAM tristate "USB IBM (Xirlink) C-it Camera support" depends on USB && VIDEO_DEV @@ -209,5 +224,3 @@ config USB_PWC To compile this driver as a module, choose M here: the module will be called pwc. - - diff --git a/drivers/usb/media/Makefile b/drivers/usb/media/Makefile index d83adffa925f..3957aa1be0f2 100644 --- a/drivers/usb/media/Makefile +++ b/drivers/usb/media/Makefile @@ -3,9 +3,11 @@ # sn9c102-objs := sn9c102_core.o sn9c102_hv7131d.o sn9c102_mi0343.o sn9c102_ov7630.o sn9c102_pas106b.o sn9c102_pas202bcb.o sn9c102_tas5110c1b.o sn9c102_tas5130d1b.o +et61x251-objs := et61x251_core.o et61x251_tas5130d1b.o obj-$(CONFIG_USB_DABUSB) += dabusb.o obj-$(CONFIG_USB_DSBR) += dsbr100.o +obj-$(CONFIG_USB_ET61X251) += et61x251.o obj-$(CONFIG_USB_IBMCAM) += ibmcam.o usbvideo.o ultracam.o obj-$(CONFIG_USB_KONICAWC) += konicawc.o usbvideo.o obj-$(CONFIG_USB_OV511) += ov511.o diff --git a/drivers/usb/media/et61x251.h b/drivers/usb/media/et61x251.h new file mode 100644 index 000000000000..652238f329f3 --- /dev/null +++ b/drivers/usb/media/et61x251.h @@ -0,0 +1,220 @@ +/*************************************************************************** + * V4L2 driver for ET61X[12]51 PC Camera Controllers * + * * + * Copyright (C) 2006 by Luca Risolia * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * + ***************************************************************************/ + +#ifndef _ET61X251_H_ +#define _ET61X251_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "et61x251_sensor.h" + +/*****************************************************************************/ + +#define ET61X251_DEBUG +#define ET61X251_DEBUG_LEVEL 2 +#define ET61X251_MAX_DEVICES 64 +#define ET61X251_PRESERVE_IMGSCALE 0 +#define ET61X251_FORCE_MUNMAP 0 +#define ET61X251_MAX_FRAMES 32 +#define ET61X251_COMPRESSION_QUALITY 0 +#define ET61X251_URBS 2 +#define ET61X251_ISO_PACKETS 7 +#define ET61X251_ALTERNATE_SETTING 13 +#define ET61X251_URB_TIMEOUT msecs_to_jiffies(2 * ET61X251_ISO_PACKETS) +#define ET61X251_CTRL_TIMEOUT 100 + +/*****************************************************************************/ + +static const struct usb_device_id et61x251_id_table[] = { + { USB_DEVICE(0x102c, 0x6151), }, + { USB_DEVICE(0x102c, 0x6251), }, + { USB_DEVICE(0x102c, 0x6253), }, + { USB_DEVICE(0x102c, 0x6254), }, + { USB_DEVICE(0x102c, 0x6255), }, + { USB_DEVICE(0x102c, 0x6256), }, + { USB_DEVICE(0x102c, 0x6257), }, + { USB_DEVICE(0x102c, 0x6258), }, + { USB_DEVICE(0x102c, 0x6259), }, + { USB_DEVICE(0x102c, 0x625a), }, + { USB_DEVICE(0x102c, 0x625b), }, + { USB_DEVICE(0x102c, 0x625c), }, + { USB_DEVICE(0x102c, 0x625d), }, + { USB_DEVICE(0x102c, 0x625e), }, + { USB_DEVICE(0x102c, 0x625f), }, + { USB_DEVICE(0x102c, 0x6260), }, + { USB_DEVICE(0x102c, 0x6261), }, + { USB_DEVICE(0x102c, 0x6262), }, + { USB_DEVICE(0x102c, 0x6263), }, + { USB_DEVICE(0x102c, 0x6264), }, + { USB_DEVICE(0x102c, 0x6265), }, + { USB_DEVICE(0x102c, 0x6266), }, + { USB_DEVICE(0x102c, 0x6267), }, + { USB_DEVICE(0x102c, 0x6268), }, + { USB_DEVICE(0x102c, 0x6269), }, + { } +}; + +ET61X251_SENSOR_TABLE + +/*****************************************************************************/ + +enum et61x251_frame_state { + F_UNUSED, + F_QUEUED, + F_GRABBING, + F_DONE, + F_ERROR, +}; + +struct et61x251_frame_t { + void* bufmem; + struct v4l2_buffer buf; + enum et61x251_frame_state state; + struct list_head frame; + unsigned long vma_use_count; +}; + +enum et61x251_dev_state { + DEV_INITIALIZED = 0x01, + DEV_DISCONNECTED = 0x02, + DEV_MISCONFIGURED = 0x04, +}; + +enum et61x251_io_method { + IO_NONE, + IO_READ, + IO_MMAP, +}; + +enum et61x251_stream_state { + STREAM_OFF, + STREAM_INTERRUPT, + STREAM_ON, +}; + +struct et61x251_sysfs_attr { + u8 reg, i2c_reg; +}; + +struct et61x251_module_param { + u8 force_munmap; +}; + +static DECLARE_MUTEX(et61x251_sysfs_lock); +static DECLARE_RWSEM(et61x251_disconnect); + +struct et61x251_device { + struct video_device* v4ldev; + + struct et61x251_sensor* sensor; + + struct usb_device* usbdev; + struct urb* urb[ET61X251_URBS]; + void* transfer_buffer[ET61X251_URBS]; + u8* control_buffer; + + struct et61x251_frame_t *frame_current, frame[ET61X251_MAX_FRAMES]; + struct list_head inqueue, outqueue; + u32 frame_count, nbuffers, nreadbuffers; + + enum et61x251_io_method io; + enum et61x251_stream_state stream; + + struct v4l2_jpegcompression compression; + + struct et61x251_sysfs_attr sysfs; + struct et61x251_module_param module_param; + + enum et61x251_dev_state state; + u8 users; + + struct semaphore dev_sem, fileop_sem; + spinlock_t queue_lock; + wait_queue_head_t open, wait_frame, wait_stream; +}; + +/*****************************************************************************/ + +void +et61x251_attach_sensor(struct et61x251_device* cam, + struct et61x251_sensor* sensor) +{ + cam->sensor = sensor; + cam->sensor->usbdev = cam->usbdev; +} + +/*****************************************************************************/ + +#undef DBG +#undef KDBG +#ifdef ET61X251_DEBUG +# define DBG(level, fmt, args...) \ +do { \ + if (debug >= (level)) { \ + if ((level) == 1) \ + dev_err(&cam->usbdev->dev, fmt "\n", ## args); \ + else if ((level) == 2) \ + dev_info(&cam->usbdev->dev, fmt "\n", ## args); \ + else if ((level) >= 3) \ + dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ + __FUNCTION__, __LINE__ , ## args); \ + } \ +} while (0) +# define KDBG(level, fmt, args...) \ +do { \ + if (debug >= (level)) { \ + if ((level) == 1 || (level) == 2) \ + pr_info("et61x251: " fmt "\n", ## args); \ + else if ((level) == 3) \ + pr_debug("et61x251: [%s:%d] " fmt "\n", __FUNCTION__, \ + __LINE__ , ## args); \ + } \ +} while (0) +# define V4LDBG(level, name, cmd) \ +do { \ + if (debug >= (level)) \ + v4l_print_ioctl(name, cmd); \ +} while (0) +#else +# define DBG(level, fmt, args...) do {;} while(0) +# define KDBG(level, fmt, args...) do {;} while(0) +# define V4LDBG(level, name, cmd) do {;} while(0) +#endif + +#undef PDBG +#define PDBG(fmt, args...) \ +dev_info(&cam->dev, "[%s:%d] " fmt "\n", __FUNCTION__, __LINE__ , ## args) + +#undef PDBGG +#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */ + +#endif /* _ET61X251_H_ */ diff --git a/drivers/usb/media/et61x251_core.c b/drivers/usb/media/et61x251_core.c new file mode 100644 index 000000000000..2c0171a5ad62 --- /dev/null +++ b/drivers/usb/media/et61x251_core.c @@ -0,0 +1,2605 @@ +/*************************************************************************** + * V4L2 driver for ET61X[12]51 PC Camera Controllers * + * * + * Copyright (C) 2006 by Luca Risolia * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "et61x251.h" + +/*****************************************************************************/ + +#define ET61X251_MODULE_NAME "V4L2 driver for ET61X[12]51 " \ + "PC Camera Controllers" +#define ET61X251_MODULE_AUTHOR "(C) 2006 Luca Risolia" +#define ET61X251_AUTHOR_EMAIL "" +#define ET61X251_MODULE_LICENSE "GPL" +#define ET61X251_MODULE_VERSION "1:1.01" +#define ET61X251_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 1) + +/*****************************************************************************/ + +MODULE_DEVICE_TABLE(usb, et61x251_id_table); + +MODULE_AUTHOR(ET61X251_MODULE_AUTHOR " " ET61X251_AUTHOR_EMAIL); +MODULE_DESCRIPTION(ET61X251_MODULE_NAME); +MODULE_VERSION(ET61X251_MODULE_VERSION); +MODULE_LICENSE(ET61X251_MODULE_LICENSE); + +static short video_nr[] = {[0 ... ET61X251_MAX_DEVICES-1] = -1}; +module_param_array(video_nr, short, NULL, 0444); +MODULE_PARM_DESC(video_nr, + "\n<-1|n[,...]> Specify V4L2 minor mode number." + "\n -1 = use next available (default)" + "\n n = use minor number n (integer >= 0)" + "\nYou can specify up to " + __MODULE_STRING(ET61X251_MAX_DEVICES) " cameras this way." + "\nFor example:" + "\nvideo_nr=-1,2,-1 would assign minor number 2 to" + "\nthe second registered camera and use auto for the first" + "\none and for every other camera." + "\n"); + +static short force_munmap[] = {[0 ... ET61X251_MAX_DEVICES-1] = + ET61X251_FORCE_MUNMAP}; +module_param_array(force_munmap, bool, NULL, 0444); +MODULE_PARM_DESC(force_munmap, + "\n<0|1[,...]> Force the application to unmap previously" + "\nmapped buffer memory before calling any VIDIOC_S_CROP or" + "\nVIDIOC_S_FMT ioctl's. Not all the applications support" + "\nthis feature. This parameter is specific for each" + "\ndetected camera." + "\n 0 = do not force memory unmapping" + "\n 1 = force memory unmapping (save memory)" + "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"." + "\n"); + +#ifdef ET61X251_DEBUG +static unsigned short debug = ET61X251_DEBUG_LEVEL; +module_param(debug, ushort, 0644); +MODULE_PARM_DESC(debug, + "\n Debugging information level, from 0 to 3:" + "\n0 = none (use carefully)" + "\n1 = critical errors" + "\n2 = significant informations" + "\n3 = more verbose messages" + "\nLevel 3 is useful for testing only, when only " + "one device is used." + "\nDefault value is "__MODULE_STRING(ET61X251_DEBUG_LEVEL)"." + "\n"); +#endif + +/*****************************************************************************/ + +static u32 +et61x251_request_buffers(struct et61x251_device* cam, u32 count, + enum et61x251_io_method io) +{ + struct v4l2_pix_format* p = &(cam->sensor->pix_format); + struct v4l2_rect* r = &(cam->sensor->cropcap.bounds); + const size_t imagesize = cam->module_param.force_munmap || + io == IO_READ ? + (p->width * p->height * p->priv) / 8 : + (r->width * r->height * p->priv) / 8; + void* buff = NULL; + u32 i; + + if (count > ET61X251_MAX_FRAMES) + count = ET61X251_MAX_FRAMES; + + cam->nbuffers = count; + while (cam->nbuffers > 0) { + if ((buff = vmalloc_32(cam->nbuffers * PAGE_ALIGN(imagesize)))) + break; + cam->nbuffers--; + } + + for (i = 0; i < cam->nbuffers; i++) { + cam->frame[i].bufmem = buff + i*PAGE_ALIGN(imagesize); + cam->frame[i].buf.index = i; + cam->frame[i].buf.m.offset = i*PAGE_ALIGN(imagesize); + cam->frame[i].buf.length = imagesize; + cam->frame[i].buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + cam->frame[i].buf.sequence = 0; + cam->frame[i].buf.field = V4L2_FIELD_NONE; + cam->frame[i].buf.memory = V4L2_MEMORY_MMAP; + cam->frame[i].buf.flags = 0; + } + + return cam->nbuffers; +} + + +static void et61x251_release_buffers(struct et61x251_device* cam) +{ + if (cam->nbuffers) { + vfree(cam->frame[0].bufmem); + cam->nbuffers = 0; + } + cam->frame_current = NULL; +} + + +static void et61x251_empty_framequeues(struct et61x251_device* cam) +{ + u32 i; + + INIT_LIST_HEAD(&cam->inqueue); + INIT_LIST_HEAD(&cam->outqueue); + + for (i = 0; i < ET61X251_MAX_FRAMES; i++) { + cam->frame[i].state = F_UNUSED; + cam->frame[i].buf.bytesused = 0; + } +} + + +static void et61x251_requeue_outqueue(struct et61x251_device* cam) +{ + struct et61x251_frame_t *i; + + list_for_each_entry(i, &cam->outqueue, frame) { + i->state = F_QUEUED; + list_add(&i->frame, &cam->inqueue); + } + + INIT_LIST_HEAD(&cam->outqueue); +} + + +static void et61x251_queue_unusedframes(struct et61x251_device* cam) +{ + unsigned long lock_flags; + u32 i; + + for (i = 0; i < cam->nbuffers; i++) + if (cam->frame[i].state == F_UNUSED) { + cam->frame[i].state = F_QUEUED; + spin_lock_irqsave(&cam->queue_lock, lock_flags); + list_add_tail(&cam->frame[i].frame, &cam->inqueue); + spin_unlock_irqrestore(&cam->queue_lock, lock_flags); + } +} + +/*****************************************************************************/ + +int et61x251_write_reg(struct et61x251_device* cam, u8 value, u16 index) +{ + struct usb_device* udev = cam->usbdev; + u8* buff = cam->control_buffer; + int res; + + *buff = value; + + res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, + 0, index, buff, 1, ET61X251_CTRL_TIMEOUT); + if (res < 0) { + DBG(3, "Failed to write a register (value 0x%02X, index " + "0x%02X, error %d)", value, index, res); + return -1; + } + + return 0; +} + + +int et61x251_read_reg(struct et61x251_device* cam, u16 index) +{ + struct usb_device* udev = cam->usbdev; + u8* buff = cam->control_buffer; + int res; + + res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1, + 0, index, buff, 1, ET61X251_CTRL_TIMEOUT); + if (res < 0) + DBG(3, "Failed to read a register (index 0x%02X, error %d)", + index, res); + + return (res >= 0) ? (int)(*buff) : -1; +} + + +static int +et61x251_i2c_wait(struct et61x251_device* cam, struct et61x251_sensor* sensor) +{ + int i, r; + + for (i = 1; i <= 8; i++) { + if (sensor->interface == ET61X251_I2C_3WIRES) { + r = et61x251_read_reg(cam, 0x8e); + if (!(r & 0x02) && (r >= 0)) + return 0; + } else { + r = et61x251_read_reg(cam, 0x8b); + if (!(r & 0x01) && (r >= 0)) + return 0; + } + if (r < 0) + return -EIO; + udelay(8*8); /* minimum for sensors at 400kHz */ + } + + return -EBUSY; +} + + +int +et61x251_i2c_try_read(struct et61x251_device* cam, + struct et61x251_sensor* sensor, u8 address) +{ + struct usb_device* udev = cam->usbdev; + u8* data = cam->control_buffer; + int err = 0, res; + + data[0] = address; + data[1] = cam->sensor->i2c_slave_id; + data[2] = cam->sensor->rsta | 0x10; + data[3] = !(et61x251_read_reg(cam, 0x8b) & 0x02); + res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, + 0, 0x88, data, 4, ET61X251_CTRL_TIMEOUT); + if (res < 0) + err += res; + + err += et61x251_i2c_wait(cam, sensor); + + res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1, + 0, 0x80, data, 8, ET61X251_CTRL_TIMEOUT); + if (res < 0) + err += res; + + if (err) + DBG(3, "I2C read failed for %s image sensor", sensor->name); + + PDBGG("I2C read: address 0x%02X, value: 0x%02X", address, data[0]); + + return err ? -1 : (int)data[0]; +} + + +int +et61x251_i2c_try_write(struct et61x251_device* cam, + struct et61x251_sensor* sensor, u8 address, u8 value) +{ + struct usb_device* udev = cam->usbdev; + u8* data = cam->control_buffer; + int err = 0, res; + + data[0] = address; + data[1] = cam->sensor->i2c_slave_id; + data[2] = cam->sensor->rsta | 0x12; + res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, + 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT); + if (res < 0) + err += res; + + data[0] = value; + res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, + 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT); + if (res < 0) + err += res; + + err += et61x251_i2c_wait(cam, sensor); + + if (err) + DBG(3, "I2C write failed for %s image sensor", sensor->name); + + PDBGG("I2C write: address 0x%02X, value: 0x%02X", address, value); + + return err ? -1 : 0; +} + + +int +et61x251_i2c_raw_write(struct et61x251_device* cam, u8 n, u8 data1, u8 data2, + u8 data3, u8 data4, u8 data5, u8 data6, u8 data7, + u8 data8, u8 address) +{ + struct usb_device* udev = cam->usbdev; + u8* data = cam->control_buffer; + int err = 0, res; + + if (!cam->sensor) + return -1; + + data[0] = data2; + data[1] = data3; + data[2] = data4; + data[3] = data5; + data[4] = data6; + data[5] = data7; + data[6] = data8; + res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, + 0, 0x81, data, n-1, ET61X251_CTRL_TIMEOUT); + if (res < 0) + err += res; + + data[0] = address; + data[1] = cam->sensor->i2c_slave_id; + data[2] = cam->sensor->rsta | 0x02 | (n << 4); + res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, + 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT); + if (res < 0) + err += res; + + /* Start writing through the serial interface */ + data[0] = data1; + res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41, + 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT); + if (res < 0) + err += res; + + err += et61x251_i2c_wait(cam, cam->sensor); + + if (err) + DBG(3, "I2C raw write failed for %s image sensor", + cam->sensor->name); + + PDBGG("I2C raw write: %u bytes, address = 0x%02X, data1 = 0x%02X, " + "data2 = 0x%02X, data3 = 0x%02X, data4 = 0x%02X, data5 = 0x%02X," + " data6 = 0x%02X, data7 = 0x%02X, data8 = 0x%02X", n, address, + data1, data2, data3, data4, data5, data6, data7, data8); + + return err ? -1 : 0; + +} + + +int et61x251_i2c_read(struct et61x251_device* cam, u8 address) +{ + if (!cam->sensor) + return -1; + + return et61x251_i2c_try_read(cam, cam->sensor, address); +} + + +int et61x251_i2c_write(struct et61x251_device* cam, u8 address, u8 value) +{ + if (!cam->sensor) + return -1; + + return et61x251_i2c_try_write(cam, cam->sensor, address, value); +} + +/*****************************************************************************/ + +static void et61x251_urb_complete(struct urb *urb, struct pt_regs* regs) +{ + struct et61x251_device* cam = urb->context; + struct et61x251_frame_t** f; + size_t imagesize; + u8 i; + int err = 0; + + if (urb->status == -ENOENT) + return; + + f = &cam->frame_current; + + if (cam->stream == STREAM_INTERRUPT) { + cam->stream = STREAM_OFF; + if ((*f)) + (*f)->state = F_QUEUED; + DBG(3, "Stream interrupted"); + wake_up_interruptible(&cam->wait_stream); + } + + if (cam->state & DEV_DISCONNECTED) + return; + + if (cam->state & DEV_MISCONFIGURED) { + wake_up_interruptible(&cam->wait_frame); + return; + } + + if (cam->stream == STREAM_OFF || list_empty(&cam->inqueue)) + goto resubmit_urb; + + if (!(*f)) + (*f) = list_entry(cam->inqueue.next, struct et61x251_frame_t, + frame); + + imagesize = (cam->sensor->pix_format.width * + cam->sensor->pix_format.height * + cam->sensor->pix_format.priv) / 8; + + for (i = 0; i < urb->number_of_packets; i++) { + unsigned int len, status; + void *pos; + u8* b1, * b2, sof; + const u8 VOID_BYTES = 6; + size_t imglen; + + len = urb->iso_frame_desc[i].actual_length; + status = urb->iso_frame_desc[i].status; + pos = urb->iso_frame_desc[i].offset + urb->transfer_buffer; + + if (status) { + DBG(3, "Error in isochronous frame"); + (*f)->state = F_ERROR; + continue; + } + + b1 = pos++; + b2 = pos++; + sof = ((*b1 & 0x3f) == 63); + imglen = ((*b1 & 0xc0) << 2) | *b2; + + PDBGG("Isochrnous frame: length %u, #%u i, image length %zu", + len, i, imglen); + + if ((*f)->state == F_QUEUED || (*f)->state == F_ERROR) +start_of_frame: + if (sof) { + (*f)->state = F_GRABBING; + (*f)->buf.bytesused = 0; + do_gettimeofday(&(*f)->buf.timestamp); + pos += 22; + DBG(3, "SOF detected: new video frame"); + } + + if ((*f)->state == F_GRABBING) { + if (sof && (*f)->buf.bytesused) { + if (cam->sensor->pix_format.pixelformat == + V4L2_PIX_FMT_ET61X251) + goto end_of_frame; + else { + DBG(3, "Not expected SOF detected " + "after %lu bytes", + (unsigned long)(*f)->buf.bytesused); + (*f)->state = F_ERROR; + continue; + } + } + + if ((*f)->buf.bytesused + imglen > imagesize) { + DBG(3, "Video frame size exceeded"); + (*f)->state = F_ERROR; + continue; + } + + pos += VOID_BYTES; + + memcpy((*f)->bufmem+(*f)->buf.bytesused, pos, imglen); + (*f)->buf.bytesused += imglen; + + if ((*f)->buf.bytesused == imagesize) { + u32 b; +end_of_frame: + b = (*f)->buf.bytesused; + (*f)->state = F_DONE; + (*f)->buf.sequence= ++cam->frame_count; + spin_lock(&cam->queue_lock); + list_move_tail(&(*f)->frame, &cam->outqueue); + if (!list_empty(&cam->inqueue)) + (*f) = list_entry(cam->inqueue.next, + struct et61x251_frame_t, + frame); + else + (*f) = NULL; + spin_unlock(&cam->queue_lock); + DBG(3, "Video frame captured: : %lu bytes", + (unsigned long)(b)); + + if (!(*f)) + goto resubmit_urb; + + if (sof && + cam->sensor->pix_format.pixelformat == + V4L2_PIX_FMT_ET61X251) + goto start_of_frame; + } + } + } + +resubmit_urb: + urb->dev = cam->usbdev; + err = usb_submit_urb(urb, GFP_ATOMIC); + if (err < 0 && err != -EPERM) { + cam->state |= DEV_MISCONFIGURED; + DBG(1, "usb_submit_urb() failed"); + } + + wake_up_interruptible(&cam->wait_frame); +} + + +static int et61x251_start_transfer(struct et61x251_device* cam) +{ + struct usb_device *udev = cam->usbdev; + struct urb* urb; + const unsigned int wMaxPacketSize[] = {0, 256, 384, 512, 640, 768, 832, + 864, 896, 920, 956, 980, 1000, + 1022}; + const unsigned int psz = wMaxPacketSize[ET61X251_ALTERNATE_SETTING]; + s8 i, j; + int err = 0; + + for (i = 0; i < ET61X251_URBS; i++) { + cam->transfer_buffer[i] = kzalloc(ET61X251_ISO_PACKETS * psz, + GFP_KERNEL); + if (!cam->transfer_buffer[i]) { + err = -ENOMEM; + DBG(1, "Not enough memory"); + goto free_buffers; + } + } + + for (i = 0; i < ET61X251_URBS; i++) { + urb = usb_alloc_urb(ET61X251_ISO_PACKETS, GFP_KERNEL); + cam->urb[i] = urb; + if (!urb) { + err = -ENOMEM; + DBG(1, "usb_alloc_urb() failed"); + goto free_urbs; + } + urb->dev = udev; + urb->context = cam; + urb->pipe = usb_rcvisocpipe(udev, 1); + urb->transfer_flags = URB_ISO_ASAP; + urb->number_of_packets = ET61X251_ISO_PACKETS; + urb->complete = et61x251_urb_complete; + urb->transfer_buffer = cam->transfer_buffer[i]; + urb->transfer_buffer_length = psz * ET61X251_ISO_PACKETS; + urb->interval = 1; + for (j = 0; j < ET61X251_ISO_PACKETS; j++) { + urb->iso_frame_desc[j].offset = psz * j; + urb->iso_frame_desc[j].length = psz; + } + } + + err = et61x251_write_reg(cam, 0x01, 0x03); + err = et61x251_write_reg(cam, 0x00, 0x03); + err = et61x251_write_reg(cam, 0x08, 0x03); + if (err) { + err = -EIO; + DBG(1, "I/O hardware error"); + goto free_urbs; + } + + err = usb_set_interface(udev, 0, ET61X251_ALTERNATE_SETTING); + if (err) { + DBG(1, "usb_set_interface() failed"); + goto free_urbs; + } + + cam->frame_current = NULL; + + for (i = 0; i < ET61X251_URBS; i++) { + err = usb_submit_urb(cam->urb[i], GFP_KERNEL); + if (err) { + for (j = i-1; j >= 0; j--) + usb_kill_urb(cam->urb[j]); + DBG(1, "usb_submit_urb() failed, error %d", err); + goto free_urbs; + } + } + + return 0; + +free_urbs: + for (i = 0; (i < ET61X251_URBS) && cam->urb[i]; i++) + usb_free_urb(cam->urb[i]); + +free_buffers: + for (i = 0; (i < ET61X251_URBS) && cam->transfer_buffer[i]; i++) + kfree(cam->transfer_buffer[i]); + + return err; +} + + +static int et61x251_stop_transfer(struct et61x251_device* cam) +{ + struct usb_device *udev = cam->usbdev; + s8 i; + int err = 0; + + if (cam->state & DEV_DISCONNECTED) + return 0; + + for (i = ET61X251_URBS-1; i >= 0; i--) { + usb_kill_urb(cam->urb[i]); + usb_free_urb(cam->urb[i]); + kfree(cam->transfer_buffer[i]); + } + + err = usb_set_interface(udev, 0, 0); /* 0 Mb/s */ + if (err) + DBG(3, "usb_set_interface() failed"); + + return err; +} + + +static int et61x251_stream_interrupt(struct et61x251_device* cam) +{ + int err = 0; + + cam->stream = STREAM_INTERRUPT; + err = wait_event_timeout(cam->wait_stream, + (cam->stream == STREAM_OFF) || + (cam->state & DEV_DISCONNECTED), + ET61X251_URB_TIMEOUT); + if (cam->state & DEV_DISCONNECTED) + return -ENODEV; + else if (err) { + cam->state |= DEV_MISCONFIGURED; + DBG(1, "URB timeout reached. The camera is misconfigured. To " + "use it, close and open /dev/video%d again.", + cam->v4ldev->minor); + return err; + } + + return 0; +} + +/*****************************************************************************/ + +#ifdef CONFIG_VIDEO_ADV_DEBUG +static u8 et61x251_strtou8(const char* buff, size_t len, ssize_t* count) +{ + char str[5]; + char* endp; + unsigned long val; + + if (len < 4) { + strncpy(str, buff, len); + str[len+1] = '\0'; + } else { + strncpy(str, buff, 4); + str[4] = '\0'; + } + + val = simple_strtoul(str, &endp, 0); + + *count = 0; + if (val <= 0xff) + *count = (ssize_t)(endp - str); + if ((*count) && (len == *count+1) && (buff[*count] == '\n')) + *count += 1; + + return (u8)val; +} + +/* + NOTE 1: being inside one of the following methods implies that the v4l + device exists for sure (see kobjects and reference counters) + NOTE 2: buffers are PAGE_SIZE long +*/ + +static ssize_t et61x251_show_reg(struct class_device* cd, char* buf) +{ + struct et61x251_device* cam; + ssize_t count; + + if (down_interruptible(&et61x251_sysfs_lock)) + return -ERESTARTSYS; + + cam = video_get_drvdata(to_video_device(cd)); + if (!cam) { + up(&et61x251_sysfs_lock); + return -ENODEV; + } + + count = sprintf(buf, "%u\n", cam->sysfs.reg); + + up(&et61x251_sysfs_lock); + + return count; +} + + +static ssize_t +et61x251_store_reg(struct class_device* cd, const char* buf, size_t len) +{ + struct et61x251_device* cam; + u8 index; + ssize_t count; + + if (down_interruptible(&et61x251_sysfs_lock)) + return -ERESTARTSYS; + + cam = video_get_drvdata(to_video_device(cd)); + if (!cam) { + up(&et61x251_sysfs_lock); + return -ENODEV; + } + + index = et61x251_strtou8(buf, len, &count); + if (index > 0x8e || !count) { + up(&et61x251_sysfs_lock); + return -EINVAL; + } + + cam->sysfs.reg = index; + + DBG(2, "Moved ET61X[12]51 register index to 0x%02X", cam->sysfs.reg); + DBG(3, "Written bytes: %zd", count); + + up(&et61x251_sysfs_lock); + + return count; +} + + +static ssize_t et61x251_show_val(struct class_device* cd, char* buf) +{ + struct et61x251_device* cam; + ssize_t count; + int val; + + if (down_interruptible(&et61x251_sysfs_lock)) + return -ERESTARTSYS; + + cam = video_get_drvdata(to_video_device(cd)); + if (!cam) { + up(&et61x251_sysfs_lock); + return -ENODEV; + } + + if ((val = et61x251_read_reg(cam, cam->sysfs.reg)) < 0) { + up(&et61x251_sysfs_lock); + return -EIO; + } + + count = sprintf(buf, "%d\n", val); + + DBG(3, "Read bytes: %zd", count); + + up(&et61x251_sysfs_lock); + + return count; +} + + +static ssize_t +et61x251_store_val(struct class_device* cd, const char* buf, size_t len) +{ + struct et61x251_device* cam; + u8 value; + ssize_t count; + int err; + + if (down_interruptible(&et61x251_sysfs_lock)) + return -ERESTARTSYS; + + cam = video_get_drvdata(to_video_device(cd)); + if (!cam) { + up(&et61x251_sysfs_lock); + return -ENODEV; + } + + value = et61x251_strtou8(buf, len, &count); + if (!count) { + up(&et61x251_sysfs_lock); + return -EINVAL; + } + + err = et61x251_write_reg(cam, value, cam->sysfs.reg); + if (err) { + up(&et61x251_sysfs_lock); + return -EIO; + } + + DBG(2, "Written ET61X[12]51 reg. 0x%02X, val. 0x%02X", + cam->sysfs.reg, value); + DBG(3, "Written bytes: %zd", count); + + up(&et61x251_sysfs_lock); + + return count; +} + + +static ssize_t et61x251_show_i2c_reg(struct class_device* cd, char* buf) +{ + struct et61x251_device* cam; + ssize_t count; + + if (down_interruptible(&et61x251_sysfs_lock)) + return -ERESTARTSYS; + + cam = video_get_drvdata(to_video_device(cd)); + if (!cam) { + up(&et61x251_sysfs_lock); + return -ENODEV; + } + + count = sprintf(buf, "%u\n", cam->sysfs.i2c_reg); + + DBG(3, "Read bytes: %zd", count); + + up(&et61x251_sysfs_lock); + + return count; +} + + +static ssize_t +et61x251_store_i2c_reg(struct class_device* cd, const char* buf, size_t len) +{ + struct et61x251_device* cam; + u8 index; + ssize_t count; + + if (down_interruptible(&et61x251_sysfs_lock)) + return -ERESTARTSYS; + + cam = video_get_drvdata(to_video_device(cd)); + if (!cam) { + up(&et61x251_sysfs_lock); + return -ENODEV; + } + + index = et61x251_strtou8(buf, len, &count); + if (!count) { + up(&et61x251_sysfs_lock); + return -EINVAL; + } + + cam->sysfs.i2c_reg = index; + + DBG(2, "Moved sensor register index to 0x%02X", cam->sysfs.i2c_reg); + DBG(3, "Written bytes: %zd", count); + + up(&et61x251_sysfs_lock); + + return count; +} + + +static ssize_t et61x251_show_i2c_val(struct class_device* cd, char* buf) +{ + struct et61x251_device* cam; + ssize_t count; + int val; + + if (down_interruptible(&et61x251_sysfs_lock)) + return -ERESTARTSYS; + + cam = video_get_drvdata(to_video_device(cd)); + if (!cam) { + up(&et61x251_sysfs_lock); + return -ENODEV; + } + + if (!(cam->sensor->sysfs_ops & ET61X251_I2C_READ)) { + up(&et61x251_sysfs_lock); + return -ENOSYS; + } + + if ((val = et61x251_i2c_read(cam, cam->sysfs.i2c_reg)) < 0) { + up(&et61x251_sysfs_lock); + return -EIO; + } + + count = sprintf(buf, "%d\n", val); + + DBG(3, "Read bytes: %zd", count); + + up(&et61x251_sysfs_lock); + + return count; +} + + +static ssize_t +et61x251_store_i2c_val(struct class_device* cd, const char* buf, size_t len) +{ + struct et61x251_device* cam; + u8 value; + ssize_t count; + int err; + + if (down_interruptible(&et61x251_sysfs_lock)) + return -ERESTARTSYS; + + cam = video_get_drvdata(to_video_device(cd)); + if (!cam) { + up(&et61x251_sysfs_lock); + return -ENODEV; + } + + if (!(cam->sensor->sysfs_ops & ET61X251_I2C_READ)) { + up(&et61x251_sysfs_lock); + return -ENOSYS; + } + + value = et61x251_strtou8(buf, len, &count); + if (!count) { + up(&et61x251_sysfs_lock); + return -EINVAL; + } + + err = et61x251_i2c_write(cam, cam->sysfs.i2c_reg, value); + if (err) { + up(&et61x251_sysfs_lock); + return -EIO; + } + + DBG(2, "Written sensor reg. 0x%02X, val. 0x%02X", + cam->sysfs.i2c_reg, value); + DBG(3, "Written bytes: %zd", count); + + up(&et61x251_sysfs_lock); + + return count; +} + + +static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR, + et61x251_show_reg, et61x251_store_reg); +static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR, + et61x251_show_val, et61x251_store_val); +static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR, + et61x251_show_i2c_reg, et61x251_store_i2c_reg); +static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR, + et61x251_show_i2c_val, et61x251_store_i2c_val); + + +static void et61x251_create_sysfs(struct et61x251_device* cam) +{ + struct video_device *v4ldev = cam->v4ldev; + + video_device_create_file(v4ldev, &class_device_attr_reg); + video_device_create_file(v4ldev, &class_device_attr_val); + if (cam->sensor && cam->sensor->sysfs_ops) { + video_device_create_file(v4ldev, &class_device_attr_i2c_reg); + video_device_create_file(v4ldev, &class_device_attr_i2c_val); + } +} +#endif /* CONFIG_VIDEO_ADV_DEBUG */ + +/*****************************************************************************/ + +static int +et61x251_set_pix_format(struct et61x251_device* cam, + struct v4l2_pix_format* pix) +{ + int r, err = 0; + + if ((r = et61x251_read_reg(cam, 0x12)) < 0) + err += r; + if (pix->pixelformat == V4L2_PIX_FMT_ET61X251) + err += et61x251_write_reg(cam, r & 0xfd, 0x12); + else + err += et61x251_write_reg(cam, r | 0x02, 0x12); + + return err ? -EIO : 0; +} + + +static int +et61x251_set_compression(struct et61x251_device* cam, + struct v4l2_jpegcompression* compression) +{ + int r, err = 0; + + if ((r = et61x251_read_reg(cam, 0x12)) < 0) + err += r; + if (compression->quality == 0) + err += et61x251_write_reg(cam, r & 0xfb, 0x12); + else + err += et61x251_write_reg(cam, r | 0x04, 0x12); + + return err ? -EIO : 0; +} + + +static int et61x251_set_scale(struct et61x251_device* cam, u8 scale) +{ + int r = 0, err = 0; + + r = et61x251_read_reg(cam, 0x12); + if (r < 0) + err += r; + + if (scale == 1) + err += et61x251_write_reg(cam, r & ~0x01, 0x12); + else if (scale == 2) + err += et61x251_write_reg(cam, r | 0x01, 0x12); + + if (err) + return -EIO; + + PDBGG("Scaling factor: %u", scale); + + return 0; +} + + +static int +et61x251_set_crop(struct et61x251_device* cam, struct v4l2_rect* rect) +{ + struct et61x251_sensor* s = cam->sensor; + u16 fmw_sx = (u16)(rect->left - s->cropcap.bounds.left + + s->active_pixel.left), + fmw_sy = (u16)(rect->top - s->cropcap.bounds.top + + s->active_pixel.top), + fmw_length = (u16)(rect->width), + fmw_height = (u16)(rect->height); + int err = 0; + + err += et61x251_write_reg(cam, fmw_sx & 0xff, 0x69); + err += et61x251_write_reg(cam, fmw_sy & 0xff, 0x6a); + err += et61x251_write_reg(cam, fmw_length & 0xff, 0x6b); + err += et61x251_write_reg(cam, fmw_height & 0xff, 0x6c); + err += et61x251_write_reg(cam, (fmw_sx >> 8) | ((fmw_sy & 0x300) >> 6) + | ((fmw_length & 0x300) >> 4) + | ((fmw_height & 0x300) >> 2), 0x6d); + if (err) + return -EIO; + + PDBGG("fmw_sx, fmw_sy, fmw_length, fmw_height: %u %u %u %u", + fmw_sx, fmw_sy, fmw_length, fmw_height); + + return 0; +} + + +static int et61x251_init(struct et61x251_device* cam) +{ + struct et61x251_sensor* s = cam->sensor; + struct v4l2_control ctrl; + struct v4l2_queryctrl *qctrl; + struct v4l2_rect* rect; + u8 i = 0; + int err = 0; + + if (!(cam->state & DEV_INITIALIZED)) { + init_waitqueue_head(&cam->open); + qctrl = s->qctrl; + rect = &(s->cropcap.defrect); + cam->compression.quality = ET61X251_COMPRESSION_QUALITY; + } else { /* use current values */ + qctrl = s->_qctrl; + rect = &(s->_rect); + } + + err += et61x251_set_scale(cam, rect->width / s->pix_format.width); + err += et61x251_set_crop(cam, rect); + if (err) + return err; + + if (s->init) { + err = s->init(cam); + if (err) { + DBG(3, "Sensor initialization failed"); + return err; + } + } + + err += et61x251_set_compression(cam, &cam->compression); + err += et61x251_set_pix_format(cam, &s->pix_format); + if (s->set_pix_format) + err += s->set_pix_format(cam, &s->pix_format); + if (err) + return err; + + if (s->pix_format.pixelformat == V4L2_PIX_FMT_ET61X251) + DBG(3, "Compressed video format is active, quality %d", + cam->compression.quality); + else + DBG(3, "Uncompressed video format is active"); + + if (s->set_crop) + if ((err = s->set_crop(cam, rect))) { + DBG(3, "set_crop() failed"); + return err; + } + + if (s->set_ctrl) { + for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) + if (s->qctrl[i].id != 0 && + !(s->qctrl[i].flags & V4L2_CTRL_FLAG_DISABLED)) { + ctrl.id = s->qctrl[i].id; + ctrl.value = qctrl[i].default_value; + err = s->set_ctrl(cam, &ctrl); + if (err) { + DBG(3, "Set %s control failed", + s->qctrl[i].name); + return err; + } + DBG(3, "Image sensor supports '%s' control", + s->qctrl[i].name); + } + } + + if (!(cam->state & DEV_INITIALIZED)) { + init_MUTEX(&cam->fileop_sem); + spin_lock_init(&cam->queue_lock); + init_waitqueue_head(&cam->wait_frame); + init_waitqueue_head(&cam->wait_stream); + cam->nreadbuffers = 2; + memcpy(s->_qctrl, s->qctrl, sizeof(s->qctrl)); + memcpy(&(s->_rect), &(s->cropcap.defrect), + sizeof(struct v4l2_rect)); + cam->state |= DEV_INITIALIZED; + } + + DBG(2, "Initialization succeeded"); + return 0; +} + + +static void et61x251_release_resources(struct et61x251_device* cam) +{ + down(&et61x251_sysfs_lock); + + DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->minor); + video_set_drvdata(cam->v4ldev, NULL); + video_unregister_device(cam->v4ldev); + + up(&et61x251_sysfs_lock); + + kfree(cam->control_buffer); +} + +/*****************************************************************************/ + +static int et61x251_open(struct inode* inode, struct file* filp) +{ + struct et61x251_device* cam; + int err = 0; + + /* + This is the only safe way to prevent race conditions with + disconnect + */ + if (!down_read_trylock(&et61x251_disconnect)) + return -ERESTARTSYS; + + cam = video_get_drvdata(video_devdata(filp)); + + if (down_interruptible(&cam->dev_sem)) { + up_read(&et61x251_disconnect); + return -ERESTARTSYS; + } + + if (cam->users) { + DBG(2, "Device /dev/video%d is busy...", cam->v4ldev->minor); + if ((filp->f_flags & O_NONBLOCK) || + (filp->f_flags & O_NDELAY)) { + err = -EWOULDBLOCK; + goto out; + } + up(&cam->dev_sem); + err = wait_event_interruptible_exclusive(cam->open, + cam->state & DEV_DISCONNECTED + || !cam->users); + if (err) { + up_read(&et61x251_disconnect); + return err; + } + if (cam->state & DEV_DISCONNECTED) { + up_read(&et61x251_disconnect); + return -ENODEV; + } + down(&cam->dev_sem); + } + + + if (cam->state & DEV_MISCONFIGURED) { + err = et61x251_init(cam); + if (err) { + DBG(1, "Initialization failed again. " + "I will retry on next open()."); + goto out; + } + cam->state &= ~DEV_MISCONFIGURED; + } + + if ((err = et61x251_start_transfer(cam))) + goto out; + + filp->private_data = cam; + cam->users++; + cam->io = IO_NONE; + cam->stream = STREAM_OFF; + cam->nbuffers = 0; + cam->frame_count = 0; + et61x251_empty_framequeues(cam); + + DBG(3, "Video device /dev/video%d is open", cam->v4ldev->minor); + +out: + up(&cam->dev_sem); + up_read(&et61x251_disconnect); + return err; +} + + +static int et61x251_release(struct inode* inode, struct file* filp) +{ + struct et61x251_device* cam = video_get_drvdata(video_devdata(filp)); + + down(&cam->dev_sem); /* prevent disconnect() to be called */ + + et61x251_stop_transfer(cam); + + et61x251_release_buffers(cam); + + if (cam->state & DEV_DISCONNECTED) { + et61x251_release_resources(cam); + up(&cam->dev_sem); + kfree(cam); + return 0; + } + + cam->users--; + wake_up_interruptible_nr(&cam->open, 1); + + DBG(3, "Video device /dev/video%d closed", cam->v4ldev->minor); + + up(&cam->dev_sem); + + return 0; +} + + +static ssize_t +et61x251_read(struct file* filp, char __user * buf, + size_t count, loff_t* f_pos) +{ + struct et61x251_device* cam = video_get_drvdata(video_devdata(filp)); + struct et61x251_frame_t* f, * i; + unsigned long lock_flags; + int err = 0; + + if (down_interruptible(&cam->fileop_sem)) + return -ERESTARTSYS; + + if (cam->state & DEV_DISCONNECTED) { + DBG(1, "Device not present"); + up(&cam->fileop_sem); + return -ENODEV; + } + + if (cam->state & DEV_MISCONFIGURED) { + DBG(1, "The camera is misconfigured. Close and open it " + "again."); + up(&cam->fileop_sem); + return -EIO; + } + + if (cam->io == IO_MMAP) { + DBG(3, "Close and open the device again to choose the read " + "method"); + up(&cam->fileop_sem); + return -EINVAL; + } + + if (cam->io == IO_NONE) { + if (!et61x251_request_buffers(cam, cam->nreadbuffers, + IO_READ)) { + DBG(1, "read() failed, not enough memory"); + up(&cam->fileop_sem); + return -ENOMEM; + } + cam->io = IO_READ; + cam->stream = STREAM_ON; + } + + if (list_empty(&cam->inqueue)) { + if (!list_empty(&cam->outqueue)) + et61x251_empty_framequeues(cam); + et61x251_queue_unusedframes(cam); + } + + if (!count) { + up(&cam->fileop_sem); + return 0; + } + + if (list_empty(&cam->outqueue)) { + if (filp->f_flags & O_NONBLOCK) { + up(&cam->fileop_sem); + return -EAGAIN; + } + err = wait_event_interruptible + ( cam->wait_frame, + (!list_empty(&cam->outqueue)) || + (cam->state & DEV_DISCONNECTED) || + (cam->state & DEV_MISCONFIGURED) ); + if (err) { + up(&cam->fileop_sem); + return err; + } + if (cam->state & DEV_DISCONNECTED) { + up(&cam->fileop_sem); + return -ENODEV; + } + if (cam->state & DEV_MISCONFIGURED) { + up(&cam->fileop_sem); + return -EIO; + } + } + + f = list_entry(cam->outqueue.prev, struct et61x251_frame_t, frame); + + if (count > f->buf.bytesused) + count = f->buf.bytesused; + + if (copy_to_user(buf, f->bufmem, count)) { + err = -EFAULT; + goto exit; + } + *f_pos += count; + +exit: + spin_lock_irqsave(&cam->queue_lock, lock_flags); + list_for_each_entry(i, &cam->outqueue, frame) + i->state = F_UNUSED; + INIT_LIST_HEAD(&cam->outqueue); + spin_unlock_irqrestore(&cam->queue_lock, lock_flags); + + et61x251_queue_unusedframes(cam); + + PDBGG("Frame #%lu, bytes read: %zu", + (unsigned long)f->buf.index, count); + + up(&cam->fileop_sem); + + return err ? err : count; +} + + +static unsigned int et61x251_poll(struct file *filp, poll_table *wait) +{ + struct et61x251_device* cam = video_get_drvdata(video_devdata(filp)); + struct et61x251_frame_t* f; + unsigned long lock_flags; + unsigned int mask = 0; + + if (down_interruptible(&cam->fileop_sem)) + return POLLERR; + + if (cam->state & DEV_DISCONNECTED) { + DBG(1, "Device not present"); + goto error; + } + + if (cam->state & DEV_MISCONFIGURED) { + DBG(1, "The camera is misconfigured. Close and open it " + "again."); + goto error; + } + + if (cam->io == IO_NONE) { + if (!et61x251_request_buffers(cam, cam->nreadbuffers, + IO_READ)) { + DBG(1, "poll() failed, not enough memory"); + goto error; + } + cam->io = IO_READ; + cam->stream = STREAM_ON; + } + + if (cam->io == IO_READ) { + spin_lock_irqsave(&cam->queue_lock, lock_flags); + list_for_each_entry(f, &cam->outqueue, frame) + f->state = F_UNUSED; + INIT_LIST_HEAD(&cam->outqueue); + spin_unlock_irqrestore(&cam->queue_lock, lock_flags); + et61x251_queue_unusedframes(cam); + } + + poll_wait(filp, &cam->wait_frame, wait); + + if (!list_empty(&cam->outqueue)) + mask |= POLLIN | POLLRDNORM; + + up(&cam->fileop_sem); + + return mask; + +error: + up(&cam->fileop_sem); + return POLLERR; +} + + +static void et61x251_vm_open(struct vm_area_struct* vma) +{ + struct et61x251_frame_t* f = vma->vm_private_data; + f->vma_use_count++; +} + + +static void et61x251_vm_close(struct vm_area_struct* vma) +{ + /* NOTE: buffers are not freed here */ + struct et61x251_frame_t* f = vma->vm_private_data; + f->vma_use_count--; +} + + +static struct vm_operations_struct et61x251_vm_ops = { + .open = et61x251_vm_open, + .close = et61x251_vm_close, +}; + + +static int et61x251_mmap(struct file* filp, struct vm_area_struct *vma) +{ + struct et61x251_device* cam = video_get_drvdata(video_devdata(filp)); + unsigned long size = vma->vm_end - vma->vm_start, + start = vma->vm_start; + void *pos; + u32 i; + + if (down_interruptible(&cam->fileop_sem)) + return -ERESTARTSYS; + + if (cam->state & DEV_DISCONNECTED) { + DBG(1, "Device not present"); + up(&cam->fileop_sem); + return -ENODEV; + } + + if (cam->state & DEV_MISCONFIGURED) { + DBG(1, "The camera is misconfigured. Close and open it " + "again."); + up(&cam->fileop_sem); + return -EIO; + } + + if (cam->io != IO_MMAP || !(vma->vm_flags & VM_WRITE) || + size != PAGE_ALIGN(cam->frame[0].buf.length)) { + up(&cam->fileop_sem); + return -EINVAL; + } + + for (i = 0; i < cam->nbuffers; i++) { + if ((cam->frame[i].buf.m.offset>>PAGE_SHIFT) == vma->vm_pgoff) + break; + } + if (i == cam->nbuffers) { + up(&cam->fileop_sem); + return -EINVAL; + } + + vma->vm_flags |= VM_IO; + vma->vm_flags |= VM_RESERVED; + + pos = cam->frame[i].bufmem; + while (size > 0) { /* size is page-aligned */ + if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { + up(&cam->fileop_sem); + return -EAGAIN; + } + start += PAGE_SIZE; + pos += PAGE_SIZE; + size -= PAGE_SIZE; + } + + vma->vm_ops = &et61x251_vm_ops; + vma->vm_private_data = &cam->frame[i]; + + et61x251_vm_open(vma); + + up(&cam->fileop_sem); + + return 0; +} + +/*****************************************************************************/ + +static int +et61x251_vidioc_querycap(struct et61x251_device* cam, void __user * arg) +{ + struct v4l2_capability cap = { + .driver = "et61x251", + .version = ET61X251_MODULE_VERSION_CODE, + .capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | + V4L2_CAP_STREAMING, + }; + + strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card)); + if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0) + strlcpy(cap.bus_info, cam->usbdev->dev.bus_id, + sizeof(cap.bus_info)); + + if (copy_to_user(arg, &cap, sizeof(cap))) + return -EFAULT; + + return 0; +} + + +static int +et61x251_vidioc_enuminput(struct et61x251_device* cam, void __user * arg) +{ + struct v4l2_input i; + + if (copy_from_user(&i, arg, sizeof(i))) + return -EFAULT; + + if (i.index) + return -EINVAL; + + memset(&i, 0, sizeof(i)); + strcpy(i.name, "Camera"); + + if (copy_to_user(arg, &i, sizeof(i))) + return -EFAULT; + + return 0; +} + + +static int +et61x251_vidioc_gs_input(struct et61x251_device* cam, void __user * arg) +{ + int index; + + if (copy_from_user(&index, arg, sizeof(index))) + return -EFAULT; + + if (index != 0) + return -EINVAL; + + return 0; +} + + +static int +et61x251_vidioc_query_ctrl(struct et61x251_device* cam, void __user * arg) +{ + struct et61x251_sensor* s = cam->sensor; + struct v4l2_queryctrl qc; + u8 i; + + if (copy_from_user(&qc, arg, sizeof(qc))) + return -EFAULT; + + for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) + if (qc.id && qc.id == s->qctrl[i].id) { + memcpy(&qc, &(s->qctrl[i]), sizeof(qc)); + if (copy_to_user(arg, &qc, sizeof(qc))) + return -EFAULT; + return 0; + } + + return -EINVAL; +} + + +static int +et61x251_vidioc_g_ctrl(struct et61x251_device* cam, void __user * arg) +{ + struct et61x251_sensor* s = cam->sensor; + struct v4l2_control ctrl; + int err = 0; + u8 i; + + if (!s->get_ctrl && !s->set_ctrl) + return -EINVAL; + + if (copy_from_user(&ctrl, arg, sizeof(ctrl))) + return -EFAULT; + + if (!s->get_ctrl) { + for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) + if (ctrl.id == s->qctrl[i].id) { + ctrl.value = s->_qctrl[i].default_value; + goto exit; + } + return -EINVAL; + } else + err = s->get_ctrl(cam, &ctrl); + +exit: + if (copy_to_user(arg, &ctrl, sizeof(ctrl))) + return -EFAULT; + + return err; +} + + +static int +et61x251_vidioc_s_ctrl(struct et61x251_device* cam, void __user * arg) +{ + struct et61x251_sensor* s = cam->sensor; + struct v4l2_control ctrl; + u8 i; + int err = 0; + + if (!s->set_ctrl) + return -EINVAL; + + if (copy_from_user(&ctrl, arg, sizeof(ctrl))) + return -EFAULT; + + for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) + if (ctrl.id == s->qctrl[i].id) { + if (ctrl.value < s->qctrl[i].minimum || + ctrl.value > s->qctrl[i].maximum) + return -ERANGE; + ctrl.value -= ctrl.value % s->qctrl[i].step; + break; + } + + if ((err = s->set_ctrl(cam, &ctrl))) + return err; + + s->_qctrl[i].default_value = ctrl.value; + + return 0; +} + + +static int +et61x251_vidioc_cropcap(struct et61x251_device* cam, void __user * arg) +{ + struct v4l2_cropcap* cc = &(cam->sensor->cropcap); + + cc->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + cc->pixelaspect.numerator = 1; + cc->pixelaspect.denominator = 1; + + if (copy_to_user(arg, cc, sizeof(*cc))) + return -EFAULT; + + return 0; +} + + +static int +et61x251_vidioc_g_crop(struct et61x251_device* cam, void __user * arg) +{ + struct et61x251_sensor* s = cam->sensor; + struct v4l2_crop crop = { + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, + }; + + memcpy(&(crop.c), &(s->_rect), sizeof(struct v4l2_rect)); + + if (copy_to_user(arg, &crop, sizeof(crop))) + return -EFAULT; + + return 0; +} + + +static int +et61x251_vidioc_s_crop(struct et61x251_device* cam, void __user * arg) +{ + struct et61x251_sensor* s = cam->sensor; + struct v4l2_crop crop; + struct v4l2_rect* rect; + struct v4l2_rect* bounds = &(s->cropcap.bounds); + struct v4l2_pix_format* pix_format = &(s->pix_format); + u8 scale; + const enum et61x251_stream_state stream = cam->stream; + const u32 nbuffers = cam->nbuffers; + u32 i; + int err = 0; + + if (copy_from_user(&crop, arg, sizeof(crop))) + return -EFAULT; + + rect = &(crop.c); + + if (crop.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + + if (cam->module_param.force_munmap) + for (i = 0; i < cam->nbuffers; i++) + if (cam->frame[i].vma_use_count) { + DBG(3, "VIDIOC_S_CROP failed. " + "Unmap the buffers first."); + return -EINVAL; + } + + /* Preserve R,G or B origin */ + rect->left = (s->_rect.left & 1L) ? rect->left | 1L : rect->left & ~1L; + rect->top = (s->_rect.top & 1L) ? rect->top | 1L : rect->top & ~1L; + + if (rect->width < 4) + rect->width = 4; + if (rect->height < 4) + rect->height = 4; + if (rect->width > bounds->width) + rect->width = bounds->width; + if (rect->height > bounds->height) + rect->height = bounds->height; + if (rect->left < bounds->left) + rect->left = bounds->left; + if (rect->top < bounds->top) + rect->top = bounds->top; + if (rect->left + rect->width > bounds->left + bounds->width) + rect->left = bounds->left+bounds->width - rect->width; + if (rect->top + rect->height > bounds->top + bounds->height) + rect->top = bounds->top+bounds->height - rect->height; + + rect->width &= ~3L; + rect->height &= ~3L; + + if (ET61X251_PRESERVE_IMGSCALE) { + /* Calculate the actual scaling factor */ + u32 a, b; + a = rect->width * rect->height; + b = pix_format->width * pix_format->height; + scale = b ? (u8)((a / b) < 4 ? 1 : 2) : 1; + } else + scale = 1; + + if (cam->stream == STREAM_ON) + if ((err = et61x251_stream_interrupt(cam))) + return err; + + if (copy_to_user(arg, &crop, sizeof(crop))) { + cam->stream = stream; + return -EFAULT; + } + + if (cam->module_param.force_munmap || cam->io == IO_READ) + et61x251_release_buffers(cam); + + err = et61x251_set_crop(cam, rect); + if (s->set_crop) + err += s->set_crop(cam, rect); + err += et61x251_set_scale(cam, scale); + + if (err) { /* atomic, no rollback in ioctl() */ + cam->state |= DEV_MISCONFIGURED; + DBG(1, "VIDIOC_S_CROP failed because of hardware problems. To " + "use the camera, close and open /dev/video%d again.", + cam->v4ldev->minor); + return -EIO; + } + + s->pix_format.width = rect->width/scale; + s->pix_format.height = rect->height/scale; + memcpy(&(s->_rect), rect, sizeof(*rect)); + + if ((cam->module_param.force_munmap || cam->io == IO_READ) && + nbuffers != et61x251_request_buffers(cam, nbuffers, cam->io)) { + cam->state |= DEV_MISCONFIGURED; + DBG(1, "VIDIOC_S_CROP failed because of not enough memory. To " + "use the camera, close and open /dev/video%d again.", + cam->v4ldev->minor); + return -ENOMEM; + } + + if (cam->io == IO_READ) + et61x251_empty_framequeues(cam); + else if (cam->module_param.force_munmap) + et61x251_requeue_outqueue(cam); + + cam->stream = stream; + + return 0; +} + + +static int +et61x251_vidioc_enum_fmt(struct et61x251_device* cam, void __user * arg) +{ + struct v4l2_fmtdesc fmtd; + + if (copy_from_user(&fmtd, arg, sizeof(fmtd))) + return -EFAULT; + + if (fmtd.index == 0) { + strcpy(fmtd.description, "bayer rgb"); + fmtd.pixelformat = V4L2_PIX_FMT_SBGGR8; + } else if (fmtd.index == 1) { + strcpy(fmtd.description, "compressed"); + fmtd.pixelformat = V4L2_PIX_FMT_ET61X251; + fmtd.flags = V4L2_FMT_FLAG_COMPRESSED; + } else + return -EINVAL; + + fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + memset(&fmtd.reserved, 0, sizeof(fmtd.reserved)); + + if (copy_to_user(arg, &fmtd, sizeof(fmtd))) + return -EFAULT; + + return 0; +} + + +static int +et61x251_vidioc_g_fmt(struct et61x251_device* cam, void __user * arg) +{ + struct v4l2_format format; + struct v4l2_pix_format* pfmt = &(cam->sensor->pix_format); + + if (copy_from_user(&format, arg, sizeof(format))) + return -EFAULT; + + if (format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + + pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_ET61X251) + ? 0 : (pfmt->width * pfmt->priv) / 8; + pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8); + pfmt->field = V4L2_FIELD_NONE; + memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt)); + + if (copy_to_user(arg, &format, sizeof(format))) + return -EFAULT; + + return 0; +} + + +static int +et61x251_vidioc_try_s_fmt(struct et61x251_device* cam, unsigned int cmd, + void __user * arg) +{ + struct et61x251_sensor* s = cam->sensor; + struct v4l2_format format; + struct v4l2_pix_format* pix; + struct v4l2_pix_format* pfmt = &(s->pix_format); + struct v4l2_rect* bounds = &(s->cropcap.bounds); + struct v4l2_rect rect; + u8 scale; + const enum et61x251_stream_state stream = cam->stream; + const u32 nbuffers = cam->nbuffers; + u32 i; + int err = 0; + + if (copy_from_user(&format, arg, sizeof(format))) + return -EFAULT; + + pix = &(format.fmt.pix); + + if (format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + + memcpy(&rect, &(s->_rect), sizeof(rect)); + + { /* calculate the actual scaling factor */ + u32 a, b; + a = rect.width * rect.height; + b = pix->width * pix->height; + scale = b ? (u8)((a / b) < 4 ? 1 : 2) : 1; + } + + rect.width = scale * pix->width; + rect.height = scale * pix->height; + + if (rect.width < 4) + rect.width = 4; + if (rect.height < 4) + rect.height = 4; + if (rect.width > bounds->left + bounds->width - rect.left) + rect.width = bounds->left + bounds->width - rect.left; + if (rect.height > bounds->top + bounds->height - rect.top) + rect.height = bounds->top + bounds->height - rect.top; + + rect.width &= ~3L; + rect.height &= ~3L; + + { /* adjust the scaling factor */ + u32 a, b; + a = rect.width * rect.height; + b = pix->width * pix->height; + scale = b ? (u8)((a / b) < 4 ? 1 : 2) : 1; + } + + pix->width = rect.width / scale; + pix->height = rect.height / scale; + + if (pix->pixelformat != V4L2_PIX_FMT_ET61X251 && + pix->pixelformat != V4L2_PIX_FMT_SBGGR8) + pix->pixelformat = pfmt->pixelformat; + pix->priv = pfmt->priv; /* bpp */ + pix->colorspace = pfmt->colorspace; + pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_ET61X251) + ? 0 : (pix->width * pix->priv) / 8; + pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8); + pix->field = V4L2_FIELD_NONE; + + if (cmd == VIDIOC_TRY_FMT) { + if (copy_to_user(arg, &format, sizeof(format))) + return -EFAULT; + return 0; + } + + if (cam->module_param.force_munmap) + for (i = 0; i < cam->nbuffers; i++) + if (cam->frame[i].vma_use_count) { + DBG(3, "VIDIOC_S_FMT failed. " + "Unmap the buffers first."); + return -EINVAL; + } + + if (cam->stream == STREAM_ON) + if ((err = et61x251_stream_interrupt(cam))) + return err; + + if (copy_to_user(arg, &format, sizeof(format))) { + cam->stream = stream; + return -EFAULT; + } + + if (cam->module_param.force_munmap || cam->io == IO_READ) + et61x251_release_buffers(cam); + + err += et61x251_set_pix_format(cam, pix); + err += et61x251_set_crop(cam, &rect); + if (s->set_pix_format) + err += s->set_pix_format(cam, pix); + if (s->set_crop) + err += s->set_crop(cam, &rect); + err += et61x251_set_scale(cam, scale); + + if (err) { /* atomic, no rollback in ioctl() */ + cam->state |= DEV_MISCONFIGURED; + DBG(1, "VIDIOC_S_FMT failed because of hardware problems. To " + "use the camera, close and open /dev/video%d again.", + cam->v4ldev->minor); + return -EIO; + } + + memcpy(pfmt, pix, sizeof(*pix)); + memcpy(&(s->_rect), &rect, sizeof(rect)); + + if ((cam->module_param.force_munmap || cam->io == IO_READ) && + nbuffers != et61x251_request_buffers(cam, nbuffers, cam->io)) { + cam->state |= DEV_MISCONFIGURED; + DBG(1, "VIDIOC_S_FMT failed because of not enough memory. To " + "use the camera, close and open /dev/video%d again.", + cam->v4ldev->minor); + return -ENOMEM; + } + + if (cam->io == IO_READ) + et61x251_empty_framequeues(cam); + else if (cam->module_param.force_munmap) + et61x251_requeue_outqueue(cam); + + cam->stream = stream; + + return 0; +} + + +static int +et61x251_vidioc_g_jpegcomp(struct et61x251_device* cam, void __user * arg) +{ + if (copy_to_user(arg, &cam->compression, + sizeof(cam->compression))) + return -EFAULT; + + return 0; +} + + +static int +et61x251_vidioc_s_jpegcomp(struct et61x251_device* cam, void __user * arg) +{ + struct v4l2_jpegcompression jc; + const enum et61x251_stream_state stream = cam->stream; + int err = 0; + + if (copy_from_user(&jc, arg, sizeof(jc))) + return -EFAULT; + + if (jc.quality != 0 && jc.quality != 1) + return -EINVAL; + + if (cam->stream == STREAM_ON) + if ((err = et61x251_stream_interrupt(cam))) + return err; + + err += et61x251_set_compression(cam, &jc); + if (err) { /* atomic, no rollback in ioctl() */ + cam->state |= DEV_MISCONFIGURED; + DBG(1, "VIDIOC_S_JPEGCOMP failed because of hardware " + "problems. To use the camera, close and open " + "/dev/video%d again.", cam->v4ldev->minor); + return -EIO; + } + + cam->compression.quality = jc.quality; + + cam->stream = stream; + + return 0; +} + + +static int +et61x251_vidioc_reqbufs(struct et61x251_device* cam, void __user * arg) +{ + struct v4l2_requestbuffers rb; + u32 i; + int err; + + if (copy_from_user(&rb, arg, sizeof(rb))) + return -EFAULT; + + if (rb.type != V4L2_BUF_TYPE_VIDEO_CAPTURE || + rb.memory != V4L2_MEMORY_MMAP) + return -EINVAL; + + if (cam->io == IO_READ) { + DBG(3, "Close and open the device again to choose the mmap " + "I/O method"); + return -EINVAL; + } + + for (i = 0; i < cam->nbuffers; i++) + if (cam->frame[i].vma_use_count) { + DBG(3, "VIDIOC_REQBUFS failed. " + "Previous buffers are still mapped."); + return -EINVAL; + } + + if (cam->stream == STREAM_ON) + if ((err = et61x251_stream_interrupt(cam))) + return err; + + et61x251_empty_framequeues(cam); + + et61x251_release_buffers(cam); + if (rb.count) + rb.count = et61x251_request_buffers(cam, rb.count, IO_MMAP); + + if (copy_to_user(arg, &rb, sizeof(rb))) { + et61x251_release_buffers(cam); + cam->io = IO_NONE; + return -EFAULT; + } + + cam->io = rb.count ? IO_MMAP : IO_NONE; + + return 0; +} + + +static int +et61x251_vidioc_querybuf(struct et61x251_device* cam, void __user * arg) +{ + struct v4l2_buffer b; + + if (copy_from_user(&b, arg, sizeof(b))) + return -EFAULT; + + if (b.type != V4L2_BUF_TYPE_VIDEO_CAPTURE || + b.index >= cam->nbuffers || cam->io != IO_MMAP) + return -EINVAL; + + memcpy(&b, &cam->frame[b.index].buf, sizeof(b)); + + if (cam->frame[b.index].vma_use_count) + b.flags |= V4L2_BUF_FLAG_MAPPED; + + if (cam->frame[b.index].state == F_DONE) + b.flags |= V4L2_BUF_FLAG_DONE; + else if (cam->frame[b.index].state != F_UNUSED) + b.flags |= V4L2_BUF_FLAG_QUEUED; + + if (copy_to_user(arg, &b, sizeof(b))) + return -EFAULT; + + return 0; +} + + +static int +et61x251_vidioc_qbuf(struct et61x251_device* cam, void __user * arg) +{ + struct v4l2_buffer b; + unsigned long lock_flags; + + if (copy_from_user(&b, arg, sizeof(b))) + return -EFAULT; + + if (b.type != V4L2_BUF_TYPE_VIDEO_CAPTURE || + b.index >= cam->nbuffers || cam->io != IO_MMAP) + return -EINVAL; + + if (cam->frame[b.index].state != F_UNUSED) + return -EINVAL; + + cam->frame[b.index].state = F_QUEUED; + + spin_lock_irqsave(&cam->queue_lock, lock_flags); + list_add_tail(&cam->frame[b.index].frame, &cam->inqueue); + spin_unlock_irqrestore(&cam->queue_lock, lock_flags); + + PDBGG("Frame #%lu queued", (unsigned long)b.index); + + return 0; +} + + +static int +et61x251_vidioc_dqbuf(struct et61x251_device* cam, struct file* filp, + void __user * arg) +{ + struct v4l2_buffer b; + struct et61x251_frame_t *f; + unsigned long lock_flags; + int err = 0; + + if (copy_from_user(&b, arg, sizeof(b))) + return -EFAULT; + + if (b.type != V4L2_BUF_TYPE_VIDEO_CAPTURE || cam->io!= IO_MMAP) + return -EINVAL; + + if (list_empty(&cam->outqueue)) { + if (cam->stream == STREAM_OFF) + return -EINVAL; + if (filp->f_flags & O_NONBLOCK) + return -EAGAIN; + err = wait_event_interruptible + ( cam->wait_frame, + (!list_empty(&cam->outqueue)) || + (cam->state & DEV_DISCONNECTED) || + (cam->state & DEV_MISCONFIGURED) ); + if (err) + return err; + if (cam->state & DEV_DISCONNECTED) + return -ENODEV; + if (cam->state & DEV_MISCONFIGURED) + return -EIO; + } + + spin_lock_irqsave(&cam->queue_lock, lock_flags); + f = list_entry(cam->outqueue.next, struct et61x251_frame_t, frame); + list_del(cam->outqueue.next); + spin_unlock_irqrestore(&cam->queue_lock, lock_flags); + + f->state = F_UNUSED; + + memcpy(&b, &f->buf, sizeof(b)); + if (f->vma_use_count) + b.flags |= V4L2_BUF_FLAG_MAPPED; + + if (copy_to_user(arg, &b, sizeof(b))) + return -EFAULT; + + PDBGG("Frame #%lu dequeued", (unsigned long)f->buf.index); + + return 0; +} + + +static int +et61x251_vidioc_streamon(struct et61x251_device* cam, void __user * arg) +{ + int type; + + if (copy_from_user(&type, arg, sizeof(type))) + return -EFAULT; + + if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE || cam->io != IO_MMAP) + return -EINVAL; + + if (list_empty(&cam->inqueue)) + return -EINVAL; + + cam->stream = STREAM_ON; + + DBG(3, "Stream on"); + + return 0; +} + + +static int +et61x251_vidioc_streamoff(struct et61x251_device* cam, void __user * arg) +{ + int type, err; + + if (copy_from_user(&type, arg, sizeof(type))) + return -EFAULT; + + if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE || cam->io != IO_MMAP) + return -EINVAL; + + if (cam->stream == STREAM_ON) + if ((err = et61x251_stream_interrupt(cam))) + return err; + + et61x251_empty_framequeues(cam); + + DBG(3, "Stream off"); + + return 0; +} + + +static int +et61x251_vidioc_g_parm(struct et61x251_device* cam, void __user * arg) +{ + struct v4l2_streamparm sp; + + if (copy_from_user(&sp, arg, sizeof(sp))) + return -EFAULT; + + if (sp.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + + sp.parm.capture.extendedmode = 0; + sp.parm.capture.readbuffers = cam->nreadbuffers; + + if (copy_to_user(arg, &sp, sizeof(sp))) + return -EFAULT; + + return 0; +} + + +static int +et61x251_vidioc_s_parm(struct et61x251_device* cam, void __user * arg) +{ + struct v4l2_streamparm sp; + + if (copy_from_user(&sp, arg, sizeof(sp))) + return -EFAULT; + + if (sp.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + + sp.parm.capture.extendedmode = 0; + + if (sp.parm.capture.readbuffers == 0) + sp.parm.capture.readbuffers = cam->nreadbuffers; + + if (sp.parm.capture.readbuffers > ET61X251_MAX_FRAMES) + sp.parm.capture.readbuffers = ET61X251_MAX_FRAMES; + + if (copy_to_user(arg, &sp, sizeof(sp))) + return -EFAULT; + + cam->nreadbuffers = sp.parm.capture.readbuffers; + + return 0; +} + + +static int et61x251_ioctl_v4l2(struct inode* inode, struct file* filp, + unsigned int cmd, void __user * arg) +{ + struct et61x251_device* cam = video_get_drvdata(video_devdata(filp)); + + switch (cmd) { + + case VIDIOC_QUERYCAP: + return et61x251_vidioc_querycap(cam, arg); + + case VIDIOC_ENUMINPUT: + return et61x251_vidioc_enuminput(cam, arg); + + case VIDIOC_G_INPUT: + case VIDIOC_S_INPUT: + return et61x251_vidioc_gs_input(cam, arg); + + case VIDIOC_QUERYCTRL: + return et61x251_vidioc_query_ctrl(cam, arg); + + case VIDIOC_G_CTRL: + return et61x251_vidioc_g_ctrl(cam, arg); + + case VIDIOC_S_CTRL_OLD: + case VIDIOC_S_CTRL: + return et61x251_vidioc_s_ctrl(cam, arg); + + case VIDIOC_CROPCAP_OLD: + case VIDIOC_CROPCAP: + return et61x251_vidioc_cropcap(cam, arg); + + case VIDIOC_G_CROP: + return et61x251_vidioc_g_crop(cam, arg); + + case VIDIOC_S_CROP: + return et61x251_vidioc_s_crop(cam, arg); + + case VIDIOC_ENUM_FMT: + return et61x251_vidioc_enum_fmt(cam, arg); + + case VIDIOC_G_FMT: + return et61x251_vidioc_g_fmt(cam, arg); + + case VIDIOC_TRY_FMT: + case VIDIOC_S_FMT: + return et61x251_vidioc_try_s_fmt(cam, cmd, arg); + + case VIDIOC_G_JPEGCOMP: + return et61x251_vidioc_g_jpegcomp(cam, arg); + + case VIDIOC_S_JPEGCOMP: + return et61x251_vidioc_s_jpegcomp(cam, arg); + + case VIDIOC_REQBUFS: + return et61x251_vidioc_reqbufs(cam, arg); + + case VIDIOC_QUERYBUF: + return et61x251_vidioc_querybuf(cam, arg); + + case VIDIOC_QBUF: + return et61x251_vidioc_qbuf(cam, arg); + + case VIDIOC_DQBUF: + return et61x251_vidioc_dqbuf(cam, filp, arg); + + case VIDIOC_STREAMON: + return et61x251_vidioc_streamon(cam, arg); + + case VIDIOC_STREAMOFF: + return et61x251_vidioc_streamoff(cam, arg); + + case VIDIOC_G_PARM: + return et61x251_vidioc_g_parm(cam, arg); + + case VIDIOC_S_PARM_OLD: + case VIDIOC_S_PARM: + return et61x251_vidioc_s_parm(cam, arg); + + case VIDIOC_G_STD: + case VIDIOC_S_STD: + case VIDIOC_QUERYSTD: + case VIDIOC_ENUMSTD: + case VIDIOC_QUERYMENU: + return -EINVAL; + + default: + return -EINVAL; + + } +} + + +static int et61x251_ioctl(struct inode* inode, struct file* filp, + unsigned int cmd, unsigned long arg) +{ + struct et61x251_device* cam = video_get_drvdata(video_devdata(filp)); + int err = 0; + + if (down_interruptible(&cam->fileop_sem)) + return -ERESTARTSYS; + + if (cam->state & DEV_DISCONNECTED) { + DBG(1, "Device not present"); + up(&cam->fileop_sem); + return -ENODEV; + } + + if (cam->state & DEV_MISCONFIGURED) { + DBG(1, "The camera is misconfigured. Close and open it " + "again."); + up(&cam->fileop_sem); + return -EIO; + } + + V4LDBG(3, "et61x251", cmd); + + err = et61x251_ioctl_v4l2(inode, filp, cmd, (void __user *)arg); + + up(&cam->fileop_sem); + + return err; +} + + +static struct file_operations et61x251_fops = { + .owner = THIS_MODULE, + .open = et61x251_open, + .release = et61x251_release, + .ioctl = et61x251_ioctl, + .read = et61x251_read, + .poll = et61x251_poll, + .mmap = et61x251_mmap, + .llseek = no_llseek, +}; + +/*****************************************************************************/ + +/* It exists a single interface only. We do not need to validate anything. */ +static int +et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) +{ + struct usb_device *udev = interface_to_usbdev(intf); + struct et61x251_device* cam; + static unsigned int dev_nr = 0; + unsigned int i; + int err = 0; + + if (!(cam = kzalloc(sizeof(struct et61x251_device), GFP_KERNEL))) + return -ENOMEM; + + cam->usbdev = udev; + + if (!(cam->control_buffer = kzalloc(8, GFP_KERNEL))) { + DBG(1, "kmalloc() failed"); + err = -ENOMEM; + goto fail; + } + + if (!(cam->v4ldev = video_device_alloc())) { + DBG(1, "video_device_alloc() failed"); + err = -ENOMEM; + goto fail; + } + + init_MUTEX(&cam->dev_sem); + + DBG(2, "ET61X[12]51 PC Camera Controller detected " + "(vid/pid 0x%04X/0x%04X)",id->idVendor, id->idProduct); + + for (i = 0; et61x251_sensor_table[i]; i++) { + err = et61x251_sensor_table[i](cam); + if (!err) + break; + } + + if (!err && cam->sensor) + DBG(2, "%s image sensor detected", cam->sensor->name); + else { + DBG(1, "No supported image sensor detected"); + err = -ENODEV; + goto fail; + } + + if (et61x251_init(cam)) { + DBG(1, "Initialization failed. I will retry on open()."); + cam->state |= DEV_MISCONFIGURED; + } + + strcpy(cam->v4ldev->name, "ET61X[12]51 PC Camera"); + cam->v4ldev->owner = THIS_MODULE; + cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES; + cam->v4ldev->hardware = 0; + cam->v4ldev->fops = &et61x251_fops; + cam->v4ldev->minor = video_nr[dev_nr]; + cam->v4ldev->release = video_device_release; + video_set_drvdata(cam->v4ldev, cam); + + down(&cam->dev_sem); + + err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, + video_nr[dev_nr]); + if (err) { + DBG(1, "V4L2 device registration failed"); + if (err == -ENFILE && video_nr[dev_nr] == -1) + DBG(1, "Free /dev/videoX node not found"); + video_nr[dev_nr] = -1; + dev_nr = (dev_nr < ET61X251_MAX_DEVICES-1) ? dev_nr+1 : 0; + up(&cam->dev_sem); + goto fail; + } + + DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor); + + cam->module_param.force_munmap = force_munmap[dev_nr]; + + dev_nr = (dev_nr < ET61X251_MAX_DEVICES-1) ? dev_nr+1 : 0; + +#ifdef CONFIG_VIDEO_ADV_DEBUG + et61x251_create_sysfs(cam); + DBG(2, "Optional device control through 'sysfs' interface ready"); +#endif + + usb_set_intfdata(intf, cam); + + up(&cam->dev_sem); + + return 0; + +fail: + if (cam) { + kfree(cam->control_buffer); + if (cam->v4ldev) + video_device_release(cam->v4ldev); + kfree(cam); + } + return err; +} + + +static void et61x251_usb_disconnect(struct usb_interface* intf) +{ + struct et61x251_device* cam = usb_get_intfdata(intf); + + if (!cam) + return; + + down_write(&et61x251_disconnect); + + down(&cam->dev_sem); + + DBG(2, "Disconnecting %s...", cam->v4ldev->name); + + wake_up_interruptible_all(&cam->open); + + if (cam->users) { + DBG(2, "Device /dev/video%d is open! Deregistration and " + "memory deallocation are deferred on close.", + cam->v4ldev->minor); + cam->state |= DEV_MISCONFIGURED; + et61x251_stop_transfer(cam); + cam->state |= DEV_DISCONNECTED; + wake_up_interruptible(&cam->wait_frame); + wake_up_interruptible(&cam->wait_stream); + } else { + cam->state |= DEV_DISCONNECTED; + et61x251_release_resources(cam); + } + + up(&cam->dev_sem); + + if (!cam->users) + kfree(cam); + + up_write(&et61x251_disconnect); +} + + +static struct usb_driver et61x251_usb_driver = { + .name = "et61x251", + .id_table = et61x251_id_table, + .probe = et61x251_usb_probe, + .disconnect = et61x251_usb_disconnect, +}; + +/*****************************************************************************/ + +static int __init et61x251_module_init(void) +{ + int err = 0; + + KDBG(2, ET61X251_MODULE_NAME " v" ET61X251_MODULE_VERSION); + KDBG(3, ET61X251_MODULE_AUTHOR); + + if ((err = usb_register(&et61x251_usb_driver))) + KDBG(1, "usb_register() failed"); + + return err; +} + + +static void __exit et61x251_module_exit(void) +{ + usb_deregister(&et61x251_usb_driver); +} + + +module_init(et61x251_module_init); +module_exit(et61x251_module_exit); diff --git a/drivers/usb/media/et61x251_sensor.h b/drivers/usb/media/et61x251_sensor.h new file mode 100644 index 000000000000..b9df91062fc0 --- /dev/null +++ b/drivers/usb/media/et61x251_sensor.h @@ -0,0 +1,115 @@ +/*************************************************************************** + * API for image sensors connected to ET61X[12]51 PC Camera Controllers * + * * + * Copyright (C) 2006 by Luca Risolia * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * + ***************************************************************************/ + +#ifndef _ET61X251_SENSOR_H_ +#define _ET61X251_SENSOR_H_ + +#include +#include +#include +#include +#include +#include + +struct et61x251_device; +struct et61x251_sensor; + +/*****************************************************************************/ + +extern int et61x251_probe_tas5130d1b(struct et61x251_device* cam); + +#define ET61X251_SENSOR_TABLE \ +/* Weak detections must go at the end of the list */ \ +static int (*et61x251_sensor_table[])(struct et61x251_device*) = { \ + &et61x251_probe_tas5130d1b, \ + NULL, \ +}; + +extern void +et61x251_attach_sensor(struct et61x251_device* cam, + struct et61x251_sensor* sensor); + +/*****************************************************************************/ + +extern int et61x251_write_reg(struct et61x251_device*, u8 value, u16 index); +extern int et61x251_read_reg(struct et61x251_device*, u16 index); +extern int et61x251_i2c_write(struct et61x251_device*, u8 address, u8 value); +extern int et61x251_i2c_read(struct et61x251_device*, u8 address); +extern int et61x251_i2c_try_write(struct et61x251_device*, + struct et61x251_sensor*, u8 address, + u8 value); +extern int et61x251_i2c_try_read(struct et61x251_device*, + struct et61x251_sensor*, u8 address); +extern int et61x251_i2c_raw_write(struct et61x251_device*, u8 n, u8 data1, + u8 data2, u8 data3, u8 data4, u8 data5, + u8 data6, u8 data7, u8 data8, u8 address); + +/*****************************************************************************/ + +enum et61x251_i2c_sysfs_ops { + ET61X251_I2C_READ = 0x01, + ET61X251_I2C_WRITE = 0x02, +}; + +enum et61x251_i2c_interface { + ET61X251_I2C_2WIRES, + ET61X251_I2C_3WIRES, +}; + +/* Repeat start condition when RSTA is high */ +enum et61x251_i2c_rsta { + ET61X251_I2C_RSTA_STOP = 0x00, /* stop then start */ + ET61X251_I2C_RSTA_REPEAT = 0x01, /* repeat start */ +}; + +#define ET61X251_MAX_CTRLS V4L2_CID_LASTP1-V4L2_CID_BASE+10 + +struct et61x251_sensor { + char name[32]; + + enum et61x251_i2c_sysfs_ops sysfs_ops; + + enum et61x251_i2c_interface interface; + u8 i2c_slave_id; + enum et61x251_i2c_rsta rsta; + struct v4l2_rect active_pixel; /* left and top define FVSX and FVSY */ + + struct v4l2_queryctrl qctrl[ET61X251_MAX_CTRLS]; + struct v4l2_cropcap cropcap; + struct v4l2_pix_format pix_format; + + int (*init)(struct et61x251_device* cam); + int (*get_ctrl)(struct et61x251_device* cam, + struct v4l2_control* ctrl); + int (*set_ctrl)(struct et61x251_device* cam, + const struct v4l2_control* ctrl); + int (*set_crop)(struct et61x251_device* cam, + const struct v4l2_rect* rect); + int (*set_pix_format)(struct et61x251_device* cam, + const struct v4l2_pix_format* pix); + + const struct usb_device* usbdev; + + /* Private */ + struct v4l2_queryctrl _qctrl[ET61X251_MAX_CTRLS]; + struct v4l2_rect _rect; +}; + +#endif /* _ET61X251_SENSOR_H_ */ diff --git a/drivers/usb/media/et61x251_tas5130d1b.c b/drivers/usb/media/et61x251_tas5130d1b.c new file mode 100644 index 000000000000..65f1ae9cf2b3 --- /dev/null +++ b/drivers/usb/media/et61x251_tas5130d1b.c @@ -0,0 +1,137 @@ +/*************************************************************************** + * Plug-in for TAS5130D1B image sensor connected to the ET61X[12]51 * + * PC Camera Controllers * + * * + * Copyright (C) 2006 by Luca Risolia * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * + ***************************************************************************/ + +#include "et61x251_sensor.h" + + +static int tas5130d1b_init(struct et61x251_device* cam) +{ + int err = 0; + + err += et61x251_write_reg(cam, 0x14, 0x01); + err += et61x251_write_reg(cam, 0x1b, 0x02); + err += et61x251_write_reg(cam, 0x02, 0x12); + err += et61x251_write_reg(cam, 0x0e, 0x60); + err += et61x251_write_reg(cam, 0x80, 0x61); + err += et61x251_write_reg(cam, 0xf0, 0x62); + err += et61x251_write_reg(cam, 0x03, 0x63); + err += et61x251_write_reg(cam, 0x14, 0x64); + err += et61x251_write_reg(cam, 0xf4, 0x65); + err += et61x251_write_reg(cam, 0x01, 0x66); + err += et61x251_write_reg(cam, 0x05, 0x67); + err += et61x251_write_reg(cam, 0x8f, 0x68); + err += et61x251_write_reg(cam, 0x0f, 0x8d); + err += et61x251_write_reg(cam, 0x08, 0x8e); + + return err; +} + + +static int tas5130d1b_set_ctrl(struct et61x251_device* cam, + const struct v4l2_control* ctrl) +{ + int err = 0; + + switch (ctrl->id) { + case V4L2_CID_GAIN: + err += et61x251_i2c_raw_write(cam, 2, 0x20, + 0xf6-ctrl->value, 0, 0, 0, + 0, 0, 0, 0); + break; + case V4L2_CID_EXPOSURE: + err += et61x251_i2c_raw_write(cam, 2, 0x40, + 0x47-ctrl->value, 0, 0, 0, + 0, 0, 0, 0); + break; + default: + return -EINVAL; + } + + return err ? -EIO : 0; +} + + +static struct et61x251_sensor tas5130d1b = { + .name = "TAS5130D1B", + .interface = ET61X251_I2C_3WIRES, + .rsta = ET61X251_I2C_RSTA_STOP, + .active_pixel = { + .left = 106, + .top = 13, + }, + .init = &tas5130d1b_init, + .qctrl = { + { + .id = V4L2_CID_GAIN, + .type = V4L2_CTRL_TYPE_INTEGER, + .name = "global gain", + .minimum = 0x00, + .maximum = 0xf6, + .step = 0x02, + .default_value = 0x0d, + .flags = 0, + }, + { + .id = V4L2_CID_EXPOSURE, + .type = V4L2_CTRL_TYPE_INTEGER, + .name = "exposure", + .minimum = 0x00, + .maximum = 0x47, + .step = 0x01, + .default_value = 0x23, + .flags = 0, + }, + }, + .set_ctrl = &tas5130d1b_set_ctrl, + .cropcap = { + .bounds = { + .left = 0, + .top = 0, + .width = 640, + .height = 480, + }, + .defrect = { + .left = 0, + .top = 0, + .width = 640, + .height = 480, + }, + }, + .pix_format = { + .width = 640, + .height = 480, + .pixelformat = V4L2_PIX_FMT_SBGGR8, + .priv = 8, + }, +}; + + +int et61x251_probe_tas5130d1b(struct et61x251_device* cam) +{ + /* This sensor has no identifiers, so let's attach it anyway */ + et61x251_attach_sensor(cam, &tas5130d1b); + + /* Sensor detection is based on USB pid/vid */ + if (le16_to_cpu(tas5130d1b.usbdev->descriptor.idProduct) != 0x6251) + return -ENODEV; + + return 0; +} diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index ce40675324bd..6f6c69777648 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -315,6 +315,7 @@ struct v4l2_pix_format #define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S','9','1','0') /* SN9C10x compression */ #define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P','W','C','1') /* pwc older webcam */ #define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P','W','C','2') /* pwc newer webcam */ +#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E','6','2','5') /* ET61X251 compression */ /* * F O R M A T E N U M E R A T I O N -- cgit v1.2.3 From c02c4bb2058587d3c012ec08268fd93fdc654ae7 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Fri, 20 Jan 2006 14:44:12 -0800 Subject: [PATCH] USB: USB authentication states Another hook needed for wireless USB: there are states associated with the device authentication protocol. Wireless devices must authenticate using the host system's keystore. Note that wired connections could also use this authentication protocol, if for no other reason than to support the most secure "simple" key exchange protocols for wireless devices. Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- include/linux/usb_ch9.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/usb_ch9.h b/include/linux/usb_ch9.h index ee21e6bf3867..a2aacfc7af2f 100644 --- a/include/linux/usb_ch9.h +++ b/include/linux/usb_ch9.h @@ -535,9 +535,11 @@ enum usb_device_state { */ USB_STATE_NOTATTACHED = 0, - /* the chapter 9 device states */ + /* chapter 9 and authentication (wireless) device states */ USB_STATE_ATTACHED, - USB_STATE_POWERED, + USB_STATE_POWERED, /* wired */ + USB_STATE_UNAUTHENTICATED, /* auth */ + USB_STATE_RECONNECTING, /* auth */ USB_STATE_DEFAULT, /* limited function */ USB_STATE_ADDRESS, USB_STATE_CONFIGURED, /* most functions */ -- cgit v1.2.3 From 5d39a795bfa217b5f7637028c83ab5cb291f37bf Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Tue, 31 Jan 2006 17:35:35 -0800 Subject: [IPV4]: Always set fl.proto in ip_route_newports ip_route_newports uses the struct flowi from the struct rtable returned by ip_route_connect for the new route lookup and just replaces the port numbers if they have changed. If an IPsec policy exists which doesn't match port 0 the struct flowi won't have the proto field set and no xfrm lookup is done for the changed ports. Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- include/net/route.h | 5 +++-- net/dccp/ipv4.c | 3 ++- net/ipv4/tcp_ipv4.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/net/route.h b/include/net/route.h index e3e5436f8017..9c04f15090d2 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -170,8 +170,8 @@ static inline int ip_route_connect(struct rtable **rp, u32 dst, return ip_route_output_flow(rp, &fl, sk, 0); } -static inline int ip_route_newports(struct rtable **rp, u16 sport, u16 dport, - struct sock *sk) +static inline int ip_route_newports(struct rtable **rp, u8 protocol, + u16 sport, u16 dport, struct sock *sk) { if (sport != (*rp)->fl.fl_ip_sport || dport != (*rp)->fl.fl_ip_dport) { @@ -180,6 +180,7 @@ static inline int ip_route_newports(struct rtable **rp, u16 sport, u16 dport, memcpy(&fl, &(*rp)->fl, sizeof(fl)); fl.fl_ip_sport = sport; fl.fl_ip_dport = dport; + fl.proto = protocol; ip_rt_put(*rp); *rp = NULL; return ip_route_output_flow(rp, &fl, sk, 0); diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 00f983226672..dc0487b5bace 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -119,7 +119,8 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) if (err != 0) goto failure; - err = ip_route_newports(&rt, inet->sport, inet->dport, sk); + err = ip_route_newports(&rt, IPPROTO_DCCP, inet->sport, inet->dport, + sk); if (err != 0) goto failure; diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 6ea353907af5..1ac35a65b2e5 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -236,7 +236,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) if (err) goto failure; - err = ip_route_newports(&rt, inet->sport, inet->dport, sk); + err = ip_route_newports(&rt, IPPROTO_TCP, inet->sport, inet->dport, sk); if (err) goto failure; -- cgit v1.2.3 From b6ebb2659065b6e03605e7f0c69449bda382261a Mon Sep 17 00:00:00 2001 From: Jason Gaston Date: Mon, 9 Jan 2006 10:53:45 -0800 Subject: [PATCH] PCI: irq and pci_ids: patch for Intel ICH8 This patch adds the Intel ICH8 DID's to the irq.c and pci_ids.h files. Signed-off-by: Jason Gaston Signed-off-by: Greg Kroah-Hartman --- arch/i386/pci/irq.c | 5 +++++ include/linux/pci_ids.h | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'include') diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c index e715aa930036..3ca59cad05f3 100644 --- a/arch/i386/pci/irq.c +++ b/arch/i386/pci/irq.c @@ -539,6 +539,11 @@ static __init int intel_router_probe(struct irq_router *r, struct pci_dev *route case PCI_DEVICE_ID_INTEL_ICH7_30: case PCI_DEVICE_ID_INTEL_ICH7_31: case PCI_DEVICE_ID_INTEL_ESB2_0: + case PCI_DEVICE_ID_INTEL_ICH8_0: + case PCI_DEVICE_ID_INTEL_ICH8_1: + case PCI_DEVICE_ID_INTEL_ICH8_2: + case PCI_DEVICE_ID_INTEL_ICH8_3: + case PCI_DEVICE_ID_INTEL_ICH8_4: r->name = "PIIX/ICH"; r->get = pirq_piix_get; r->set = pirq_piix_set; diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 4401a7e06057..9eb1983b8787 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -2106,6 +2106,13 @@ #define PCI_DEVICE_ID_INTEL_ICH7_19 0x27dd #define PCI_DEVICE_ID_INTEL_ICH7_20 0x27de #define PCI_DEVICE_ID_INTEL_ICH7_21 0x27df +#define PCI_DEVICE_ID_INTEL_ICH8_0 0x2810 +#define PCI_DEVICE_ID_INTEL_ICH8_1 0x2811 +#define PCI_DEVICE_ID_INTEL_ICH8_2 0x2812 +#define PCI_DEVICE_ID_INTEL_ICH8_3 0x2814 +#define PCI_DEVICE_ID_INTEL_ICH8_4 0x2815 +#define PCI_DEVICE_ID_INTEL_ICH8_5 0x283e +#define PCI_DEVICE_ID_INTEL_ICH8_6 0x2850 #define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340 #define PCI_DEVICE_ID_INTEL_82830_HB 0x3575 #define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577 -- cgit v1.2.3 From f8d65713332cf6306889a3036142a17e01e3447e Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 6 Jan 2006 03:25:37 +0100 Subject: [PATCH] PCI: drivers/pci/pci.c: #if 0 pci_find_ext_capability() This patch #if 0's the unused global function pci_find_ext_capability(). Signed-off-by: Adrian Bunk Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pci.c | 2 ++ include/linux/pci.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index d2a633efa10a..d2d187916643 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -163,6 +163,7 @@ int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap) return __pci_bus_find_cap(bus, devfn, hdr_type & 0x7f, cap); } +#if 0 /** * pci_find_ext_capability - Find an extended capability * @dev: PCI device to query @@ -210,6 +211,7 @@ int pci_find_ext_capability(struct pci_dev *dev, int cap) return 0; } +#endif /* 0 */ /** * pci_find_parent_resource - return resource region of parent bus of given region diff --git a/include/linux/pci.h b/include/linux/pci.h index 0a44072383ec..fe1a2b02fc55 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -406,7 +406,6 @@ struct pci_dev *pci_find_device_reverse (unsigned int vendor, unsigned int devic struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn); int pci_find_capability (struct pci_dev *dev, int cap); int pci_find_next_capability (struct pci_dev *dev, u8 pos, int cap); -int pci_find_ext_capability (struct pci_dev *dev, int cap); struct pci_bus * pci_find_next_bus(const struct pci_bus *from); struct pci_dev *pci_get_device (unsigned int vendor, unsigned int device, struct pci_dev *from); @@ -626,7 +625,6 @@ static inline int pci_register_driver(struct pci_driver *drv) { return 0;} static inline void pci_unregister_driver(struct pci_driver *drv) { } static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; } static inline int pci_find_next_capability (struct pci_dev *dev, u8 post, int cap) { return 0; } -static inline int pci_find_ext_capability (struct pci_dev *dev, int cap) {return 0; } static inline const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev) { return NULL; } /* Power management related routines */ -- cgit v1.2.3 From 8cea8e9303d45556cb606cc8d9e41f889ff600c0 Mon Sep 17 00:00:00 2001 From: Mark Rustad Date: Thu, 5 Jan 2006 22:47:29 -0800 Subject: [PATCH] PCI: restore 2 missing pci ids Somewhere between 2.6.14 and 2.6.15-rc3, some PCI ids were apparently removed. The ecc.c module, which is not a part of the kernel.org tree, but included in some distributions, fails to compile. Signed-off-by: Mark Rustad Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- include/linux/pci_ids.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 9eb1983b8787..7868a8ed1906 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -2065,6 +2065,7 @@ #define PCI_DEVICE_ID_INTEL_82801EB_5 0x24d5 #define PCI_DEVICE_ID_INTEL_82801EB_6 0x24d6 #define PCI_DEVICE_ID_INTEL_82801EB_11 0x24db +#define PCI_DEVICE_ID_INTEL_82801EB_13 0x24dd #define PCI_DEVICE_ID_INTEL_ESB_1 0x25a1 #define PCI_DEVICE_ID_INTEL_ESB_2 0x25a2 #define PCI_DEVICE_ID_INTEL_ESB_4 0x25a4 @@ -2156,6 +2157,7 @@ #define PCI_DEVICE_ID_INTEL_82443GX_2 0x71a2 #define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601 #define PCI_DEVICE_ID_INTEL_82454GX 0x84c4 +#define PCI_DEVICE_ID_INTEL_82450GX 0x84c5 #define PCI_DEVICE_ID_INTEL_82451NX 0x84ca #define PCI_DEVICE_ID_INTEL_82454NX 0x84cb #define PCI_DEVICE_ID_INTEL_84460GX 0x84ea -- cgit v1.2.3 From 2181c971952ec2af56cd9cc68453f7ad5a0a38d6 Mon Sep 17 00:00:00 2001 From: Grant Coady Date: Sun, 15 Jan 2006 16:21:27 +1100 Subject: [PATCH] PCI: pci_ids: remove duplicates gathered during merge period pci_ids.h: remove duplicates. Compile tested allmodconfig. Signed-off-by: Grant Coady Signed-off-by: Greg Kroah-Hartman --- include/linux/pci_ids.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'include') diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 7868a8ed1906..b0b908f583c5 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -394,14 +394,9 @@ #define PCI_DEVICE_ID_NS_SC1100_SMI 0x0511 #define PCI_DEVICE_ID_NS_SC1100_XBUS 0x0515 #define PCI_DEVICE_ID_NS_87410 0xd001 -#define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d #define PCI_DEVICE_ID_NS_CS5535_HOST_BRIDGE 0x0028 #define PCI_DEVICE_ID_NS_CS5535_ISA_BRIDGE 0x002b -#define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d -#define PCI_DEVICE_ID_NS_CS5535_AUDIO 0x002e -#define PCI_DEVICE_ID_NS_CS5535_USB 0x002f -#define PCI_DEVICE_ID_NS_CS5535_VIDEO 0x0030 #define PCI_VENDOR_ID_TSENG 0x100c #define PCI_DEVICE_ID_TSENG_W32P_2 0x3202 @@ -511,8 +506,6 @@ #define PCI_DEVICE_ID_AMD_CS5536_UOC 0x2097 #define PCI_DEVICE_ID_AMD_CS5536_IDE 0x209A -#define PCI_DEVICE_ID_AMD_CS5536_IDE 0x209A - #define PCI_DEVICE_ID_AMD_LX_VIDEO 0x2081 #define PCI_DEVICE_ID_AMD_LX_AES 0x2082 -- cgit v1.2.3 From bd3f8f2b12bcf4ea25c89b84adeaafad232662c8 Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Tue, 31 Jan 2006 19:10:23 -0800 Subject: [PATCH] Make sure to always check upper bits of tv_nsec in timespec_valid. Signed-off-by: Chris Wright Signed-off-by: Linus Torvalds --- include/linux/time.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/time.h b/include/linux/time.h index 614dd8465839..7b4dc36532bb 100644 --- a/include/linux/time.h +++ b/include/linux/time.h @@ -48,7 +48,7 @@ extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec); * Returns true if the timespec is norm, false if denorm: */ #define timespec_valid(ts) \ - (((ts)->tv_sec >= 0) && (((unsigned) (ts)->tv_nsec) < NSEC_PER_SEC)) + (((ts)->tv_sec >= 0) && (((unsigned long) (ts)->tv_nsec) < NSEC_PER_SEC)) /* * 64-bit nanosec type. Large enough to span 292+ years in nanosecond -- cgit v1.2.3 From 3a2ca64496cc1c9aeab1076e06d092b3ec74a43d Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 1 Feb 2006 03:04:33 -0800 Subject: [PATCH] prototypes for *at functions & typo fix Here's the follow-up patch which introduces the prototypes for the new syscalls. There was also a typo in one of the new symbols. Signed-off-by: Ulrich Drepper Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-x86_64/ia32_unistd.h | 2 +- include/linux/syscalls.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/asm-x86_64/ia32_unistd.h b/include/asm-x86_64/ia32_unistd.h index e87cd83a0e86..9afc0c7d3661 100644 --- a/include/asm-x86_64/ia32_unistd.h +++ b/include/asm-x86_64/ia32_unistd.h @@ -300,7 +300,7 @@ #define __NR_ia32_inotify_add_watch 292 #define __NR_ia32_inotify_rm_watch 293 #define __NR_ia32_migrate_pages 294 -#define __NR_ia32_opanat 295 +#define __NR_ia32_openat 295 #define __NR_ia32_mkdirat 296 #define __NR_ia32_mknodat 297 #define __NR_ia32_fchownat 298 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index e666d6070569..fdbd436b24cc 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -50,6 +50,8 @@ struct timezone; struct tms; struct utimbuf; struct mq_attr; +struct compat_stat; +struct compat_timeval; #include #include @@ -534,4 +536,35 @@ asmlinkage long sys_spu_run(int fd, __u32 __user *unpc, asmlinkage long sys_spu_create(const char __user *name, unsigned int flags, mode_t mode); +asmlinkage long sys_mknodat(int dfd, const char __user * filename, int mode, + unsigned dev); +asmlinkage long sys_mkdirat(int dfd, const char __user * pathname, int mode); +asmlinkage long sys_unlinkat(int dfd, const char __user * pathname, int flag); +asmlinkage long sys_symlinkat(const char __user * oldname, + int newdfd, const char __user * newname); +asmlinkage long sys_linkat(int olddfd, const char __user *oldname, + int newdfd, const char __user *newname); +asmlinkage long sys_renameat(int olddfd, const char __user * oldname, + int newdfd, const char __user * newname); +asmlinkage long sys_futimesat(int dfd, char __user *filename, + struct timeval __user *utimes); +asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode); +asmlinkage long sys_fchmodat(int dfd, const char __user * filename, + mode_t mode); +asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user, + gid_t group, int flag); +asmlinkage long sys_openat(int dfd, const char __user *filename, int flags, + int mode); +asmlinkage long sys_newfstatat(int dfd, char __user *filename, + struct stat __user *statbuf, int flag); +asmlinkage long sys_readlinkat(int dfd, const char __user *path, char __user *buf, + int bufsiz); +asmlinkage long compat_sys_futimesat(int dfd, char __user *filename, + struct compat_timeval __user *t); +asmlinkage long compat_sys_newfstatat(int dfd, char __user * filename, + struct compat_stat __user *statbuf, + int flag); +asmlinkage long compat_sys_openat(int dfd, const char __user *filename, + int flags, int mode); + #endif -- cgit v1.2.3 From 9cd684551124e71630ab96d238747051463f5b56 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Wed, 1 Feb 2006 03:04:40 -0800 Subject: [PATCH] fuse: fix async read for legacy filesystems While asynchronous reads mean a performance improvement in most cases, if the filesystem assumed that reads are synchronous, then async reads may degrade performance (filesystem may receive reads out of order, which can confuse it's own readahead logic). With sshfs a 1.5 to 4 times slowdown can be measured. There's also a need for userspace filesystems to know whether asynchronous reads are supported by the kernel or not. To achive these, negotiate in the INIT request whether async reads will be used and the maximum readahead value. Update interface version to 7.6 If userspace uses a version earlier than 7.6, then disable async reads, and set maximum readahead value to the maximum read size, as done in previous versions. Signed-off-by: Miklos Szeredi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/fuse/file.c | 9 +++++++-- fs/fuse/fuse_i.h | 3 +++ fs/fuse/inode.c | 14 ++++++++++++-- include/linux/fuse.h | 16 ++++++++++++++-- 4 files changed, 36 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/fs/fuse/file.c b/fs/fuse/file.c index a7ef5e716f3c..296351615b00 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -335,9 +335,14 @@ static void fuse_send_readpages(struct fuse_req *req, struct file *file, loff_t pos = page_offset(req->pages[0]); size_t count = req->num_pages << PAGE_CACHE_SHIFT; req->out.page_zeroing = 1; - req->end = fuse_readpages_end; fuse_read_fill(req, file, inode, pos, count, FUSE_READ); - request_send_background(fc, req); + if (fc->async_read) { + req->end = fuse_readpages_end; + request_send_background(fc, req); + } else { + request_send(fc, req); + fuse_readpages_end(fc, req); + } } struct fuse_readpages_data { diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 46cf933aa3bf..4a83adfec968 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -272,6 +272,9 @@ struct fuse_conn { reply, before any other request, and never cleared */ unsigned conn_error : 1; + /** Do readpages asynchronously? Only set in INIT */ + unsigned async_read : 1; + /* * The following bitfields are only for optimization purposes * and hence races in setting them will not cause malfunction diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index c755a0440a66..879e6fba9480 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -473,6 +473,16 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) if (req->out.h.error || arg->major != FUSE_KERNEL_VERSION) fc->conn_error = 1; else { + unsigned long ra_pages; + + if (arg->minor >= 6) { + ra_pages = arg->max_readahead / PAGE_CACHE_SIZE; + if (arg->flags & FUSE_ASYNC_READ) + fc->async_read = 1; + } else + ra_pages = fc->max_read / PAGE_CACHE_SIZE; + + fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages); fc->minor = arg->minor; fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; } @@ -496,6 +506,8 @@ static void fuse_send_init(struct fuse_conn *fc) arg->major = FUSE_KERNEL_VERSION; arg->minor = FUSE_KERNEL_MINOR_VERSION; + arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE; + arg->flags |= FUSE_ASYNC_READ; req->in.h.opcode = FUSE_INIT; req->in.numargs = 1; req->in.args[0].size = sizeof(*arg); @@ -552,8 +564,6 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) fc->user_id = d.user_id; fc->group_id = d.group_id; fc->max_read = d.max_read; - if (fc->max_read / PAGE_CACHE_SIZE < fc->bdi.ra_pages) - fc->bdi.ra_pages = fc->max_read / PAGE_CACHE_SIZE; /* Used by get_root_inode() */ sb->s_fs_info = fc; diff --git a/include/linux/fuse.h b/include/linux/fuse.h index 528959c52f1b..5425b60021e3 100644 --- a/include/linux/fuse.h +++ b/include/linux/fuse.h @@ -14,7 +14,7 @@ #define FUSE_KERNEL_VERSION 7 /** Minor version number of this interface */ -#define FUSE_KERNEL_MINOR_VERSION 5 +#define FUSE_KERNEL_MINOR_VERSION 6 /** The node ID of the root inode */ #define FUSE_ROOT_ID 1 @@ -58,6 +58,9 @@ struct fuse_kstatfs { __u32 spare[6]; }; +/** + * Bitmasks for fuse_setattr_in.valid + */ #define FATTR_MODE (1 << 0) #define FATTR_UID (1 << 1) #define FATTR_GID (1 << 2) @@ -75,6 +78,11 @@ struct fuse_kstatfs { #define FOPEN_DIRECT_IO (1 << 0) #define FOPEN_KEEP_CACHE (1 << 1) +/** + * INIT request/reply flags + */ +#define FUSE_ASYNC_READ (1 << 0) + enum fuse_opcode { FUSE_LOOKUP = 1, FUSE_FORGET = 2, /* no reply */ @@ -247,12 +255,16 @@ struct fuse_access_in { struct fuse_init_in { __u32 major; __u32 minor; + __u32 max_readahead; + __u32 flags; }; struct fuse_init_out { __u32 major; __u32 minor; - __u32 unused[3]; + __u32 max_readahead; + __u32 flags; + __u32 unused; __u32 max_write; }; -- cgit v1.2.3 From cc0fa84a01d328a1ad70076b90f08281c4c79f92 Mon Sep 17 00:00:00 2001 From: Ben Collins Date: Wed, 1 Feb 2006 03:04:47 -0800 Subject: [PATCH] powerpc: enable irq's for platform functions. Make the platform function interrupt functions actually work. Calls irq_enable() for the first in the list, and irq_disable() for the last. Added *func to struct irq_client so the the user can pass just that to pmf_unregister_irq_client(). Signed-off-by: Ben Collins Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/powerpc/platforms/powermac/pfunc_core.c | 13 ++++++++++--- include/asm-powerpc/pmac_pfunc.h | 5 ++--- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/arch/powerpc/platforms/powermac/pfunc_core.c b/arch/powerpc/platforms/powermac/pfunc_core.c index c32c623001dc..356a739e52b2 100644 --- a/arch/powerpc/platforms/powermac/pfunc_core.c +++ b/arch/powerpc/platforms/powermac/pfunc_core.c @@ -862,21 +862,28 @@ int pmf_register_irq_client(struct device_node *target, spin_unlock_irqrestore(&pmf_lock, flags); return -ENODEV; } + if (list_empty(&func->irq_clients)) + func->dev->handlers->irq_enable(func); list_add(&client->link, &func->irq_clients); + client->func = func; spin_unlock_irqrestore(&pmf_lock, flags); return 0; } EXPORT_SYMBOL_GPL(pmf_register_irq_client); -void pmf_unregister_irq_client(struct device_node *np, - const char *name, - struct pmf_irq_client *client) +void pmf_unregister_irq_client(struct pmf_irq_client *client) { + struct pmf_function *func = client->func; unsigned long flags; + BUG_ON(func == NULL); + spin_lock_irqsave(&pmf_lock, flags); + client->func = NULL; list_del(&client->link); + if (list_empty(&func->irq_clients)) + func->dev->handlers->irq_disable(func); spin_unlock_irqrestore(&pmf_lock, flags); } EXPORT_SYMBOL_GPL(pmf_unregister_irq_client); diff --git a/include/asm-powerpc/pmac_pfunc.h b/include/asm-powerpc/pmac_pfunc.h index d9728c80f86d..cef61304ffc2 100644 --- a/include/asm-powerpc/pmac_pfunc.h +++ b/include/asm-powerpc/pmac_pfunc.h @@ -167,6 +167,7 @@ struct pmf_irq_client { void *data; struct module *owner; struct list_head link; + struct pmf_function *func; }; @@ -187,9 +188,7 @@ extern int pmf_register_irq_client(struct device_node *np, const char *name, struct pmf_irq_client *client); -extern void pmf_unregister_irq_client(struct device_node *np, - const char *name, - struct pmf_irq_client *client); +extern void pmf_unregister_irq_client(struct pmf_irq_client *client); /* * Called by the handlers when an irq happens -- cgit v1.2.3 From 3ee247ebce93a526f482d6bc714ce796fa85a81a Mon Sep 17 00:00:00 2001 From: Alasdair G Kergon Date: Wed, 1 Feb 2006 03:04:55 -0800 Subject: [PATCH] dm: dm-table warning fix drivers/md/dm-table.c:500: warning: comparison of distinct pointer types lacks a cast Signed-off-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/dm-table.c | 2 +- include/linux/device-mapper.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index a6f2dc66c3db..9b1e2f5ca630 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -508,7 +508,7 @@ int dm_get_device(struct dm_target *ti, const char *path, sector_t start, if (q->merge_bvec_fn) rs->max_sectors = min_not_zero(rs->max_sectors, - (unsigned short)(PAGE_SIZE >> 9)); + (unsigned int) (PAGE_SIZE >> 9)); rs->max_phys_segments = min_not_zero(rs->max_phys_segments, diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 83c7d207b80e..51e0e95a421a 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -91,7 +91,7 @@ struct target_type { }; struct io_restrictions { - unsigned short max_sectors; + unsigned int max_sectors; unsigned short max_phys_segments; unsigned short max_hw_segments; unsigned short hardsect_size; -- cgit v1.2.3 From ce5f8d70ba6e3d7ffcaff86b2cf91a42c27f77af Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Wed, 1 Feb 2006 03:04:56 -0800 Subject: [PATCH] alpha: dma-mapping.h: add "struct scatterlist;" On alpha-jensen: CC drivers/base/platform.o In file included from include/linux/dma-mapping.h:24, from drivers/base/platform.c:16: include/asm/dma-mapping.h:36: warning: "struct scatterlist" declared inside parameter list include/asm/dma-mapping.h:36: warning: its scope is only this definition or declaration, which is probably not what you want Signed-off-by: Alexey Dobriyan Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-alpha/dma-mapping.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/asm-alpha/dma-mapping.h b/include/asm-alpha/dma-mapping.h index 9dc7256cf979..62d0d6681aa9 100644 --- a/include/asm-alpha/dma-mapping.h +++ b/include/asm-alpha/dma-mapping.h @@ -30,6 +30,7 @@ #else /* no PCI - no IOMMU. */ +struct scatterlist; void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp); int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, -- cgit v1.2.3 From ed5a92700d3ce2646cb7763792a5f7ad1bade7e8 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Wed, 1 Feb 2006 03:05:00 -0800 Subject: [PATCH] tpm_bios: needs more securityfs_ functions tpm_bios.c needs securityfs_xyz() functions. Does include/linux/security.h need stubs for these, or should char/tpm/Makefile just be modified to say: ifdef CONFIG_ACPI ifdef CONFIG_SECURITY obj-$(CONFIG_TCG_TPM) += tpm_bios.o endif endif drivers/char/tpm/tpm_bios.c:494: warning: implicit declaration of function 'securityfs_create_dir' drivers/char/tpm/tpm_bios.c:494: warning: assignment makes pointer from integer without a cast drivers/char/tpm/tpm_bios.c:499: warning: implicit declaration of function 'securityfs_create_file' drivers/char/tpm/tpm_bios.c:501: warning: assignment makes pointer from integer without a cast drivers/char/tpm/tpm_bios.c:508: warning: assignment makes pointer from integer without a cast drivers/char/tpm/tpm_bios.c:523: warning: implicit declaration of function 'securityfs_remove' *** Warning: "securityfs_create_file" [drivers/char/tpm/tpm_bios.ko] undefined! *** Warning: "securityfs_create_dir" [drivers/char/tpm/tpm_bios.ko] undefined! *** Warning: "securityfs_remove" [drivers/char/tpm/tpm_bios.ko] undefined! There are also some gcc and sparse warnings that could be fixed. (see http://www.xenotime.net/linux/doc/build-tpm.out) Signed-off-by: Randy Dunlap Cc: Serge Hallyn Cc: Greg KH Cc: Kylene Jo Hall Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/security.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include') diff --git a/include/linux/security.h b/include/linux/security.h index ef753654daa5..bb1da86747c7 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -2617,6 +2617,25 @@ static inline int security_netlink_recv (struct sk_buff *skb) return cap_netlink_recv (skb); } +static inline struct dentry *securityfs_create_dir(const char *name, + struct dentry *parent) +{ + return ERR_PTR(-ENODEV); +} + +static inline struct dentry *securityfs_create_file(const char *name, + mode_t mode, + struct dentry *parent, + void *data, + struct file_operations *fops) +{ + return ERR_PTR(-ENODEV); +} + +static inline void securityfs_remove(struct dentry *dentry) +{ +} + #endif /* CONFIG_SECURITY */ #ifdef CONFIG_SECURITY_NETWORK -- cgit v1.2.3 From ff60a5dc4fa584d47022d2533bc5c53b80096fb5 Mon Sep 17 00:00:00 2001 From: "akpm@osdl.org" Date: Wed, 1 Feb 2006 03:05:10 -0800 Subject: [PATCH] hrtimers: fix posix-timer requeue race From: Steven Rostedtrostedt@goodmis.org CPU0 expires a posix-timer and runs the callback function. The signal is queued. After releasing the posix-timer lock and before returning to hrtimer_run_queue CPU0 gets interrupted. CPU1 delivers the queued signal and rearms the timer. CPU0 comes back to hrtimer_run_queue and sets the timer state to expired. The next modification of the timer can result in an oops, because the state information is wrong. Keep track of state = RUNNING and check if the state has been in the return path of hrtimer_run_queue. In case the state has been changed, ignore a restart request and do not touch the state variable. Signed-off-by: Steven Rostedt Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/hrtimer.h | 1 + kernel/hrtimer.c | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'include') diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 089bfb1fa01a..c657f3d4924a 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -40,6 +40,7 @@ enum hrtimer_restart { enum hrtimer_state { HRTIMER_INACTIVE, /* Timer is inactive */ HRTIMER_EXPIRED, /* Timer is expired */ + HRTIMER_RUNNING, /* Timer is running the callback function */ HRTIMER_PENDING, /* Timer is pending */ }; diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index f1c4155b49ac..f580dd9db286 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -550,6 +550,7 @@ static inline void run_hrtimer_queue(struct hrtimer_base *base) fn = timer->function; data = timer->data; set_curr_timer(base, timer); + timer->state = HRTIMER_RUNNING; __remove_hrtimer(timer, base); spin_unlock_irq(&base->lock); @@ -565,6 +566,10 @@ static inline void run_hrtimer_queue(struct hrtimer_base *base) spin_lock_irq(&base->lock); + /* Another CPU has added back the timer */ + if (timer->state != HRTIMER_RUNNING) + continue; + if (restart == HRTIMER_RESTART) enqueue_hrtimer(timer, base); else -- cgit v1.2.3 From 7978672c4d9a1e6a6081de3a9d9ba5e5b24904a0 Mon Sep 17 00:00:00 2001 From: George Anzinger Date: Wed, 1 Feb 2006 03:05:11 -0800 Subject: [PATCH] hrtimers: cleanups and simplifications Clean up the interface to hrtimers by changing the init code to pass the mode as well as the clock. This allow the init code to select the correct base and eliminates extra timer re-init code in posix-timers. We also simplify the restart interface nanosleep use. Signed-off-by: George Anzinger Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/hrtimer.h | 5 ++--- kernel/fork.c | 2 +- kernel/hrtimer.c | 59 ++++++++++++++++++++----------------------------- kernel/posix-timers.c | 37 ++++++++----------------------- 4 files changed, 36 insertions(+), 67 deletions(-) (limited to 'include') diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index c657f3d4924a..6361544bb6ae 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -101,9 +101,8 @@ struct hrtimer_base { /* Exported timer functions: */ /* Initialize timers: */ -extern void hrtimer_init(struct hrtimer *timer, const clockid_t which_clock); -extern void hrtimer_rebase(struct hrtimer *timer, const clockid_t which_clock); - +extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock, + enum hrtimer_mode mode); /* Basic timer operations: */ extern int hrtimer_start(struct hrtimer *timer, ktime_t tim, diff --git a/kernel/fork.c b/kernel/fork.c index 4ae8cfc1c89c..7f0ab5ee948c 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -802,7 +802,7 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts init_sigpending(&sig->shared_pending); INIT_LIST_HEAD(&sig->posix_timers); - hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC); + hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_REL); sig->it_real_incr.tv64 = 0; sig->real_timer.function = it_real_fn; sig->real_timer.data = tsk; diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index f580dd9db286..efff9496b2fa 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -66,6 +66,12 @@ EXPORT_SYMBOL_GPL(ktime_get_real); /* * The timer bases: + * + * Note: If we want to add new timer bases, we have to skip the two + * clock ids captured by the cpu-timers. We do this by holding empty + * entries rather than doing math adjustment of the clock ids. + * This ensures that we capture erroneous accesses to these clock ids + * rather than moving them into the range of valid clock id's. */ #define MAX_HRTIMER_BASES 2 @@ -483,29 +489,25 @@ ktime_t hrtimer_get_remaining(const struct hrtimer *timer) } /** - * hrtimer_rebase - rebase an initialized hrtimer to a different base + * hrtimer_init - initialize a timer to the given clock * - * @timer: the timer to be rebased + * @timer: the timer to be initialized * @clock_id: the clock to be used + * @mode: timer mode abs/rel */ -void hrtimer_rebase(struct hrtimer *timer, const clockid_t clock_id) +void hrtimer_init(struct hrtimer *timer, clockid_t clock_id, + enum hrtimer_mode mode) { struct hrtimer_base *bases; + memset(timer, 0, sizeof(struct hrtimer)); + bases = per_cpu(hrtimer_bases, raw_smp_processor_id()); - timer->base = &bases[clock_id]; -} -/** - * hrtimer_init - initialize a timer to the given clock - * - * @timer: the timer to be initialized - * @clock_id: the clock to be used - */ -void hrtimer_init(struct hrtimer *timer, const clockid_t clock_id) -{ - memset(timer, 0, sizeof(struct hrtimer)); - hrtimer_rebase(timer, clock_id); + if (clock_id == CLOCK_REALTIME && mode != HRTIMER_ABS) + clock_id = CLOCK_MONOTONIC; + + timer->base = &bases[clock_id]; } /** @@ -643,8 +645,7 @@ schedule_hrtimer_interruptible(struct hrtimer *timer, return schedule_hrtimer(timer, mode); } -static long __sched -nanosleep_restart(struct restart_block *restart, clockid_t clockid) +static long __sched nanosleep_restart(struct restart_block *restart) { struct timespec __user *rmtp; struct timespec tu; @@ -654,7 +655,7 @@ nanosleep_restart(struct restart_block *restart, clockid_t clockid) restart->fn = do_no_restart_syscall; - hrtimer_init(&timer, clockid); + hrtimer_init(&timer, (clockid_t) restart->arg3, HRTIMER_ABS); timer.expires.tv64 = ((u64)restart->arg1 << 32) | (u64) restart->arg0; @@ -674,16 +675,6 @@ nanosleep_restart(struct restart_block *restart, clockid_t clockid) return -ERESTART_RESTARTBLOCK; } -static long __sched nanosleep_restart_mono(struct restart_block *restart) -{ - return nanosleep_restart(restart, CLOCK_MONOTONIC); -} - -static long __sched nanosleep_restart_real(struct restart_block *restart) -{ - return nanosleep_restart(restart, CLOCK_REALTIME); -} - long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp, const enum hrtimer_mode mode, const clockid_t clockid) { @@ -692,7 +683,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp, struct timespec tu; ktime_t rem; - hrtimer_init(&timer, clockid); + hrtimer_init(&timer, clockid, mode); timer.expires = timespec_to_ktime(*rqtp); @@ -700,7 +691,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp, if (rem.tv64 <= 0) return 0; - /* Absolute timers do not update the rmtp value: */ + /* Absolute timers do not update the rmtp value and restart: */ if (mode == HRTIMER_ABS) return -ERESTARTNOHAND; @@ -710,11 +701,11 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp, return -EFAULT; restart = ¤t_thread_info()->restart_block; - restart->fn = (clockid == CLOCK_MONOTONIC) ? - nanosleep_restart_mono : nanosleep_restart_real; + restart->fn = nanosleep_restart; restart->arg0 = timer.expires.tv64 & 0xFFFFFFFF; restart->arg1 = timer.expires.tv64 >> 32; restart->arg2 = (unsigned long) rmtp; + restart->arg3 = (unsigned long) timer.base->index; return -ERESTART_RESTARTBLOCK; } @@ -741,10 +732,8 @@ static void __devinit init_hrtimers_cpu(int cpu) struct hrtimer_base *base = per_cpu(hrtimer_bases, cpu); int i; - for (i = 0; i < MAX_HRTIMER_BASES; i++) { + for (i = 0; i < MAX_HRTIMER_BASES; i++, base++) spin_lock_init(&base->lock); - base++; - } } #ifdef CONFIG_HOTPLUG_CPU diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index 3b606d361b52..28e72fd0029f 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c @@ -194,9 +194,7 @@ static inline int common_clock_set(const clockid_t which_clock, static int common_timer_create(struct k_itimer *new_timer) { - hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock); - new_timer->it.real.timer.data = new_timer; - new_timer->it.real.timer.function = posix_timer_fn; + hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0); return 0; } @@ -693,6 +691,7 @@ common_timer_set(struct k_itimer *timr, int flags, struct itimerspec *new_setting, struct itimerspec *old_setting) { struct hrtimer *timer = &timr->it.real.timer; + enum hrtimer_mode mode; if (old_setting) common_timer_get(timr, old_setting); @@ -714,14 +713,10 @@ common_timer_set(struct k_itimer *timr, int flags, if (!new_setting->it_value.tv_sec && !new_setting->it_value.tv_nsec) return 0; - /* Posix madness. Only absolute CLOCK_REALTIME timers - * are affected by clock sets. So we must reiniatilize - * the timer. - */ - if (timr->it_clock == CLOCK_REALTIME && (flags & TIMER_ABSTIME)) - hrtimer_rebase(timer, CLOCK_REALTIME); - else - hrtimer_rebase(timer, CLOCK_MONOTONIC); + mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL; + hrtimer_init(&timr->it.real.timer, timr->it_clock, mode); + timr->it.real.timer.data = timr; + timr->it.real.timer.function = posix_timer_fn; timer->expires = timespec_to_ktime(new_setting->it_value); @@ -732,8 +727,7 @@ common_timer_set(struct k_itimer *timr, int flags, if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) return 0; - hrtimer_start(timer, timer->expires, (flags & TIMER_ABSTIME) ? - HRTIMER_ABS : HRTIMER_REL); + hrtimer_start(timer, timer->expires, mode); return 0; } @@ -948,21 +942,8 @@ sys_clock_getres(const clockid_t which_clock, struct timespec __user *tp) static int common_nsleep(const clockid_t which_clock, int flags, struct timespec *tsave, struct timespec __user *rmtp) { - int mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL; - int clockid = which_clock; - - switch (which_clock) { - case CLOCK_REALTIME: - /* Posix madness. Only absolute timers on clock realtime - are affected by clock set. */ - if (mode != HRTIMER_ABS) - clockid = CLOCK_MONOTONIC; - case CLOCK_MONOTONIC: - break; - default: - return -EINVAL; - } - return hrtimer_nanosleep(tsave, rmtp, mode, clockid); + return hrtimer_nanosleep(tsave, rmtp, flags & TIMER_ABSTIME ? + HRTIMER_ABS : HRTIMER_REL, which_clock); } asmlinkage long -- cgit v1.2.3 From 66188fae3bf7f8dd951e2291d2a81888ed1b65de Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Wed, 1 Feb 2006 03:05:13 -0800 Subject: [PATCH] hrtimers: add back lost credit lines At some point we added credits to people who actively helped to bring k/hr-timers along. This was lost in the big code revamp. Add it back. Signed-off-by: Thomas Gleixner Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/ktime.h | 6 ++++++ kernel/hrtimer.c | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'include') diff --git a/include/linux/ktime.h b/include/linux/ktime.h index 1bd6552cc341..6aca67a569a2 100644 --- a/include/linux/ktime.h +++ b/include/linux/ktime.h @@ -10,6 +10,12 @@ * * Started by: Thomas Gleixner and Ingo Molnar * + * Credits: + * + * Roman Zippel provided the ideas and primary code snippets of + * the ktime_t union and further simplifications of the original + * code. + * * For licencing details see kernel-base/COPYING */ #ifndef _LINUX_KTIME_H diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index efff9496b2fa..2b6e1757aedd 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -21,6 +21,12 @@ * Credits: * based on kernel/timer.c * + * Help, testing, suggestions, bugfixes, improvements were + * provided by: + * + * George Anzinger, Andrew Morton, Steven Rostedt, Roman Zippel + * et. al. + * * For licencing details see kernel-base/COPYING */ -- cgit v1.2.3 From 493f01d1d0699ddafc30067d33fcc18d0b95b624 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 1 Feb 2006 03:05:14 -0800 Subject: [PATCH] kernel/posix-timers.c: remove do_posix_clock_notimer_create() This function is neither used nor has any real contents. Signed-off-by: Adrian Bunk Acked-by: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/posix-timers.h | 1 - kernel/posix-timers.c | 6 ------ 2 files changed, 7 deletions(-) (limited to 'include') diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index 54faf5236da0..95572c434bc9 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -84,7 +84,6 @@ struct k_clock { void register_posix_clock(const clockid_t clock_id, struct k_clock *new_clock); /* error handlers for timer_create, nanosleep and settime */ -int do_posix_clock_notimer_create(struct k_itimer *timer); int do_posix_clock_nonanosleep(const clockid_t, int flags, struct timespec *, struct timespec __user *); int do_posix_clock_nosettime(const clockid_t, struct timespec *tp); diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index aad6f138d5c9..216f574b5ffb 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c @@ -875,12 +875,6 @@ int do_posix_clock_nosettime(const clockid_t clockid, struct timespec *tp) } EXPORT_SYMBOL_GPL(do_posix_clock_nosettime); -int do_posix_clock_notimer_create(struct k_itimer *timer) -{ - return -EINVAL; -} -EXPORT_SYMBOL_GPL(do_posix_clock_notimer_create); - int do_posix_clock_nonanosleep(const clockid_t clock, int flags, struct timespec *t, struct timespec __user *r) { -- cgit v1.2.3 From f7589f28d7dd4586b4e90ac3b2a180409669053a Mon Sep 17 00:00:00 2001 From: Bryan O'Sullivan Date: Wed, 1 Feb 2006 03:05:15 -0800 Subject: [PATCH] Define BITS_PER_BYTE This can make the intent behind some arithmetic expressions clearer. Signed-off-by: Bryan O'Sullivan Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/types.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/types.h b/include/linux/types.h index 21b9ce803644..54ae2d59e71b 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -8,6 +8,8 @@ (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG) #define DECLARE_BITMAP(name,bits) \ unsigned long name[BITS_TO_LONGS(bits)] + +#define BITS_PER_BYTE 8 #endif #include -- cgit v1.2.3 From c27a0d75b33c030965cc97d3d7f571107a673fb4 Mon Sep 17 00:00:00 2001 From: Bryan O'Sullivan Date: Wed, 1 Feb 2006 03:05:16 -0800 Subject: [PATCH] Introduce __iowrite32_copy This arch-independent routine copies data to a memory-mapped I/O region, using 32-bit accesses. The naming is double-underscored to make it clear that it does not guarantee write ordering, nor does it perform a memory barrier afterwards; the kernel doc also explicitly states this. This style of access is required by some devices. This change also introduces include/linux/io.h, at Andrew's suggestion. It only has one occupant at the moment, but is a logical destination for oft-replicated contents of include/asm-*/{io,iomap}.h to migrate to. Signed-off-by: Bryan O'Sullivan Cc: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/io.h | 25 +++++++++++++++++++++++++ lib/Makefile | 2 +- lib/iomap_copy.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 include/linux/io.h create mode 100644 lib/iomap_copy.c (limited to 'include') diff --git a/include/linux/io.h b/include/linux/io.h new file mode 100644 index 000000000000..85533ec5aaa1 --- /dev/null +++ b/include/linux/io.h @@ -0,0 +1,25 @@ +/* + * Copyright 2006 PathScale, Inc. All Rights Reserved. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _LINUX_IO_H +#define _LINUX_IO_H + +#include + +void __iowrite32_copy(void __iomem *to, const void *from, size_t count); + +#endif /* _LINUX_IO_H */ diff --git a/lib/Makefile b/lib/Makefile index 8535f4d7d1c3..648b2c1242fd 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -9,7 +9,7 @@ lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \ lib-y += kobject.o kref.o kobject_uevent.o klist.o -obj-y += sort.o parser.o halfmd4.o +obj-y += sort.o parser.o halfmd4.o iomap_copy.o ifeq ($(CONFIG_DEBUG_KOBJECT),y) CFLAGS_kobject.o += -DDEBUG diff --git a/lib/iomap_copy.c b/lib/iomap_copy.c new file mode 100644 index 000000000000..a6b1e271d53c --- /dev/null +++ b/lib/iomap_copy.c @@ -0,0 +1,42 @@ +/* + * Copyright 2006 PathScale, Inc. All Rights Reserved. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include + +/** + * __iowrite32_copy - copy data to MMIO space, in 32-bit units + * @to: destination, in MMIO space (must be 32-bit aligned) + * @from: source (must be 32-bit aligned) + * @count: number of 32-bit quantities to copy + * + * Copy data from kernel space to MMIO space, in units of 32 bits at a + * time. Order of access is not guaranteed, nor is a memory barrier + * performed afterwards. + */ +void __attribute__((weak)) __iowrite32_copy(void __iomem *to, + const void *from, + size_t count) +{ + u32 __iomem *dst = to; + const u32 *src = from; + const u32 *end = src + count; + + while (src < end) + __raw_writel(*src++, dst++); +} +EXPORT_SYMBOL_GPL(__iowrite32_copy); -- cgit v1.2.3 From 79046ae07ae21245520ca0aab985ee6678a879f8 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Wed, 1 Feb 2006 03:05:26 -0800 Subject: [PATCH] GFP_ZONETYPES: add commentry on how to calculate GFP_ZONETYPES define using GFP_ZONEMASK and add commentry Add commentry explaining the optimisation that we can apply to GFP_ZONETYPES when the leftmost bit is a 'loaner', it can only be set in isolation. Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/mmzone.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 93a849f742db..88c30f844abf 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -91,6 +91,14 @@ struct per_cpu_pageset { * be 8 (2 ** 3) zonelists. GFP_ZONETYPES defines the number of possible * combinations of zone modifiers in "zone modifier space". * + * As an optimisation any zone modifier bits which are only valid when + * no other zone modifier bits are set (loners) should be placed in + * the highest order bits of this field. This allows us to reduce the + * extent of the zonelists thus saving space. For example in the case + * of three zone modifier bits, we could require up to eight zonelists. + * If the left most zone modifier is a "loner" then the highest valid + * zonelist would be four allowing us to allocate only five zonelists. + * * NOTE! Make sure this matches the zones in */ #define GFP_ZONEMASK 0x07 -- cgit v1.2.3 From ce2ea89ba101d976907128441ba3aca72a8804b9 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Wed, 1 Feb 2006 03:05:27 -0800 Subject: [PATCH] GFP_ZONETYPES: calculate from GFP_ZONEMASK GFP_ZONETYPES calculate from GFP_ZONEMASK GFP_ZONETYPES's value is directly related to the value of GFP_ZONEMASK. It takes one of two forms depending whether the top bit of GFP_ZONEMASK is a 'loner'. Supply both forms, enabling the loner. Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/mmzone.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 88c30f844abf..ebfc238cc243 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -98,11 +98,14 @@ struct per_cpu_pageset { * of three zone modifier bits, we could require up to eight zonelists. * If the left most zone modifier is a "loner" then the highest valid * zonelist would be four allowing us to allocate only five zonelists. + * Use the first form for GFP_ZONETYPES when the left most bit is not + * a "loner", otherwise use the second. * * NOTE! Make sure this matches the zones in */ #define GFP_ZONEMASK 0x07 -#define GFP_ZONETYPES 5 +/* #define GFP_ZONETYPES (GFP_ZONEMASK + 1) */ /* Non-loner */ +#define GFP_ZONETYPES ((GFP_ZONEMASK + 1) / 2 + 1) /* Loner */ /* * On machines where it is needed (eg PCs) we divide physical memory -- cgit v1.2.3 From 2a11ff06d7d12be5d1bbcf592fff649b45ac2388 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Wed, 1 Feb 2006 03:05:33 -0800 Subject: [PATCH] zone_reclaim: configurable off node allocation period. Currently the zone_reclaim code has a fixed window of 30 seconds of off node allocations should a local zone have no unused pagecache pages left. Reclaim will be attempted again after this timeout period to avoid repeated useless scans for memory. This is also useful to established sufficiently large off node allocation chunks to relieve the local node. It may be beneficial to adjust that time period for some special situations. For example if memory use was exceeding node capacity one may want to give up for longer periods of time. If memory spikes intermittendly then one may want to shorten the time period to reduce the number of off node allocations. This patch allows just that.... Signed-off-by: Christoph Lameter Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/sysctl/vm.txt | 12 ++++++++++++ include/linux/swap.h | 1 + include/linux/sysctl.h | 3 ++- kernel/sysctl.c | 9 +++++++++ mm/vmscan.c | 4 ++-- 5 files changed, 26 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/Documentation/sysctl/vm.txt b/Documentation/sysctl/vm.txt index 391dd64363e7..44518c023949 100644 --- a/Documentation/sysctl/vm.txt +++ b/Documentation/sysctl/vm.txt @@ -28,6 +28,7 @@ Currently, these files are in /proc/sys/vm: - block_dump - drop-caches - zone_reclaim_mode +- zone_reclaim_interval ============================================================== @@ -137,4 +138,15 @@ of memory should be used for caching files from disk. It may be beneficial to switch this on if one wants to do zone reclaim regardless of the numa distances in the system. +================================================================ + +zone_reclaim_interval: + +The time allowed for off node allocations after zone reclaim +has failed to reclaim enough pages to allow a local allocation. + +Time is set in seconds and set by default to 30 seconds. + +Reduce the interval if undesired off node allocations occur. However, too +frequent scans will have a negative impact onoff node allocation performance. diff --git a/include/linux/swap.h b/include/linux/swap.h index 4a99e4a7fbf3..e53fef7051e6 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -178,6 +178,7 @@ extern int vm_swappiness; #ifdef CONFIG_NUMA extern int zone_reclaim_mode; +extern int zone_reclaim_interval; extern int zone_reclaim(struct zone *, gfp_t, unsigned int); #else #define zone_reclaim_mode 0 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 8352a7ce5895..32a4139c4ad8 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -182,7 +182,8 @@ enum VM_SWAP_TOKEN_TIMEOUT=28, /* default time for token time out */ VM_DROP_PAGECACHE=29, /* int: nuke lots of pagecache */ VM_PERCPU_PAGELIST_FRACTION=30,/* int: fraction of pages in each percpu_pagelist */ - VM_ZONE_RECLAIM_MODE=31,/* reclaim local zone memory before going off node */ + VM_ZONE_RECLAIM_MODE=31, /* reclaim local zone memory before going off node */ + VM_ZONE_RECLAIM_INTERVAL=32, /* time period to wait after reclaim failure */ }; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index c74f03bc0144..71dd6f62efec 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -881,6 +881,15 @@ static ctl_table vm_table[] = { .strategy = &sysctl_intvec, .extra1 = &zero, }, + { + .ctl_name = VM_ZONE_RECLAIM_INTERVAL, + .procname = "zone_reclaim_interval", + .data = &zone_reclaim_interval, + .maxlen = sizeof(zone_reclaim_interval), + .mode = 0644, + .proc_handler = &proc_dointvec_jiffies, + .strategy = &sysctl_jiffies, + }, #endif { .ctl_name = 0 } }; diff --git a/mm/vmscan.c b/mm/vmscan.c index f8b94ea6f722..8760a4abfa1f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1595,7 +1595,7 @@ int zone_reclaim_mode __read_mostly; /* * Mininum time between zone reclaim scans */ -#define ZONE_RECLAIM_INTERVAL 30*HZ +int zone_reclaim_interval __read_mostly = 30*HZ; /* * Priority for ZONE_RECLAIM. This determines the fraction of pages @@ -1617,7 +1617,7 @@ int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) int node_id; if (time_before(jiffies, - zone->last_unsuccessful_zone_reclaim + ZONE_RECLAIM_INTERVAL)) + zone->last_unsuccessful_zone_reclaim + zone_reclaim_interval)) return 0; if (!(gfp_mask & __GFP_WAIT) || -- cgit v1.2.3 From a48d07afdf18212de22b959715b16793c5a6e57a Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Wed, 1 Feb 2006 03:05:38 -0800 Subject: [PATCH] Direct Migration V9: migrate_pages() extension Add direct migration support with fall back to swap. Direct migration support on top of the swap based page migration facility. This allows the direct migration of anonymous pages and the migration of file backed pages by dropping the associated buffers (requires writeout). Fall back to swap out if necessary. The patch is based on lots of patches from the hotplug project but the code was restructured, documented and simplified as much as possible. Note that an additional patch that defines the migrate_page() method for filesystems is necessary in order to avoid writeback for anonymous and file backed pages. Signed-off-by: KAMEZAWA Hiroyuki Signed-off-by: Mike Kravetz Signed-off-by: Christoph Lameter Signed-off-by: Alexey Dobriyan Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/vm/page_migration | 129 +++++++++++++++++++++++ include/linux/rmap.h | 4 +- include/linux/swap.h | 2 + mm/rmap.c | 21 ++-- mm/vmscan.c | 226 ++++++++++++++++++++++++++++++++++++++-- 5 files changed, 360 insertions(+), 22 deletions(-) create mode 100644 Documentation/vm/page_migration (limited to 'include') diff --git a/Documentation/vm/page_migration b/Documentation/vm/page_migration new file mode 100644 index 000000000000..c52820fcf500 --- /dev/null +++ b/Documentation/vm/page_migration @@ -0,0 +1,129 @@ +Page migration +-------------- + +Page migration allows the moving of the physical location of pages between +nodes in a numa system while the process is running. This means that the +virtual addresses that the process sees do not change. However, the +system rearranges the physical location of those pages. + +The main intend of page migration is to reduce the latency of memory access +by moving pages near to the processor where the process accessing that memory +is running. + +Page migration allows a process to manually relocate the node on which its +pages are located through the MF_MOVE and MF_MOVE_ALL options while setting +a new memory policy. The pages of process can also be relocated +from another process using the sys_migrate_pages() function call. The +migrate_pages function call takes two sets of nodes and moves pages of a +process that are located on the from nodes to the destination nodes. + +Manual migration is very useful if for example the scheduler has relocated +a process to a processor on a distant node. A batch scheduler or an +administrator may detect the situation and move the pages of the process +nearer to the new processor. At some point in the future we may have +some mechanism in the scheduler that will automatically move the pages. + +Larger installations usually partition the system using cpusets into +sections of nodes. Paul Jackson has equipped cpusets with the ability to +move pages when a task is moved to another cpuset. This allows automatic +control over locality of a process. If a task is moved to a new cpuset +then also all its pages are moved with it so that the performance of the +process does not sink dramatically (as is the case today). + +Page migration allows the preservation of the relative location of pages +within a group of nodes for all migration techniques which will preserve a +particular memory allocation pattern generated even after migrating a +process. This is necessary in order to preserve the memory latencies. +Processes will run with similar performance after migration. + +Page migration occurs in several steps. First a high level +description for those trying to use migrate_pages() and then +a low level description of how the low level details work. + +A. Use of migrate_pages() +------------------------- + +1. Remove pages from the LRU. + + Lists of pages to be migrated are generated by scanning over + pages and moving them into lists. This is done by + calling isolate_lru_page() or __isolate_lru_page(). + Calling isolate_lru_page increases the references to the page + so that it cannot vanish under us. + +2. Generate a list of newly allocates page to move the contents + of the first list to. + +3. The migrate_pages() function is called which attempts + to do the migration. It returns the moved pages in the + list specified as the third parameter and the failed + migrations in the fourth parameter. The first parameter + will contain the pages that could still be retried. + +4. The leftover pages of various types are returned + to the LRU using putback_to_lru_pages() or otherwise + disposed of. The pages will still have the refcount as + increased by isolate_lru_pages()! + +B. Operation of migrate_pages() +-------------------------------- + +migrate_pages does several passes over its list of pages. A page is moved +if all references to a page are removable at the time. + +Steps: + +1. Lock the page to be migrated + +2. Insure that writeback is complete. + +3. Make sure that the page has assigned swap cache entry if + it is an anonyous page. The swap cache reference is necessary + to preserve the information contain in the page table maps. + +4. Prep the new page that we want to move to. It is locked + and set to not being uptodate so that all accesses to the new + page immediately lock while we are moving references. + +5. All the page table references to the page are either dropped (file backed) + or converted to swap references (anonymous pages). This should decrease the + reference count. + +6. The radix tree lock is taken + +7. The refcount of the page is examined and we back out if references remain + otherwise we know that we are the only one referencing this page. + +8. The radix tree is checked and if it does not contain the pointer to this + page then we back out. + +9. The mapping is checked. If the mapping is gone then a truncate action may + be in progress and we back out. + +10. The new page is prepped with some settings from the old page so that accesses + to the new page will be discovered to have the correct settings. + +11. The radix tree is changed to point to the new page. + +12. The reference count of the old page is dropped because the reference has now + been removed. + +13. The radix tree lock is dropped. + +14. The page contents are copied to the new page. + +15. The remaining page flags are copied to the new page. + +16. The old page flags are cleared to indicate that the page does + not use any information anymore. + +17. Queued up writeback on the new page is triggered. + +18. If swap pte's were generated for the page then remove them again. + +19. The locks are dropped from the old and new page. + +20. The new page is moved to the LRU. + +Christoph Lameter, December 19, 2005. + diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 9d6fbeef2104..0f1ea2d6ed86 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -91,7 +91,7 @@ static inline void page_dup_rmap(struct page *page) * Called from mm/vmscan.c to handle paging out */ int page_referenced(struct page *, int is_locked); -int try_to_unmap(struct page *); +int try_to_unmap(struct page *, int ignore_refs); /* * Called from mm/filemap_xip.c to unmap empty zero page @@ -111,7 +111,7 @@ unsigned long page_address_in_vma(struct page *, struct vm_area_struct *); #define anon_vma_link(vma) do {} while (0) #define page_referenced(page,l) TestClearPageReferenced(page) -#define try_to_unmap(page) SWAP_FAIL +#define try_to_unmap(page, refs) SWAP_FAIL #endif /* CONFIG_MMU */ diff --git a/include/linux/swap.h b/include/linux/swap.h index e53fef7051e6..d359fc022433 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -191,6 +191,8 @@ static inline int zone_reclaim(struct zone *z, gfp_t mask, unsigned int order) #ifdef CONFIG_MIGRATION extern int isolate_lru_page(struct page *p); extern int putback_lru_pages(struct list_head *l); +extern int migrate_page(struct page *, struct page *); +extern void migrate_page_copy(struct page *, struct page *); extern int migrate_pages(struct list_head *l, struct list_head *t, struct list_head *moved, struct list_head *failed); #else diff --git a/mm/rmap.c b/mm/rmap.c index d85a99d28c03..13fad5fcdf79 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -52,6 +52,7 @@ #include #include #include +#include #include @@ -541,7 +542,8 @@ void page_remove_rmap(struct page *page) * Subfunctions of try_to_unmap: try_to_unmap_one called * repeatedly from either try_to_unmap_anon or try_to_unmap_file. */ -static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma) +static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, + int ignore_refs) { struct mm_struct *mm = vma->vm_mm; unsigned long address; @@ -564,7 +566,8 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma) * skipped over this mm) then we should reactivate it. */ if ((vma->vm_flags & VM_LOCKED) || - ptep_clear_flush_young(vma, address, pte)) { + (ptep_clear_flush_young(vma, address, pte) + && !ignore_refs)) { ret = SWAP_FAIL; goto out_unmap; } @@ -698,7 +701,7 @@ static void try_to_unmap_cluster(unsigned long cursor, pte_unmap_unlock(pte - 1, ptl); } -static int try_to_unmap_anon(struct page *page) +static int try_to_unmap_anon(struct page *page, int ignore_refs) { struct anon_vma *anon_vma; struct vm_area_struct *vma; @@ -709,7 +712,7 @@ static int try_to_unmap_anon(struct page *page) return ret; list_for_each_entry(vma, &anon_vma->head, anon_vma_node) { - ret = try_to_unmap_one(page, vma); + ret = try_to_unmap_one(page, vma, ignore_refs); if (ret == SWAP_FAIL || !page_mapped(page)) break; } @@ -726,7 +729,7 @@ static int try_to_unmap_anon(struct page *page) * * This function is only called from try_to_unmap for object-based pages. */ -static int try_to_unmap_file(struct page *page) +static int try_to_unmap_file(struct page *page, int ignore_refs) { struct address_space *mapping = page->mapping; pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); @@ -740,7 +743,7 @@ static int try_to_unmap_file(struct page *page) spin_lock(&mapping->i_mmap_lock); vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) { - ret = try_to_unmap_one(page, vma); + ret = try_to_unmap_one(page, vma, ignore_refs); if (ret == SWAP_FAIL || !page_mapped(page)) goto out; } @@ -825,16 +828,16 @@ out: * SWAP_AGAIN - we missed a mapping, try again later * SWAP_FAIL - the page is unswappable */ -int try_to_unmap(struct page *page) +int try_to_unmap(struct page *page, int ignore_refs) { int ret; BUG_ON(!PageLocked(page)); if (PageAnon(page)) - ret = try_to_unmap_anon(page); + ret = try_to_unmap_anon(page, ignore_refs); else - ret = try_to_unmap_file(page); + ret = try_to_unmap_file(page, ignore_refs); if (!page_mapped(page)) ret = SWAP_SUCCESS; diff --git a/mm/vmscan.c b/mm/vmscan.c index aa4b80dbe3ad..8f326ce2b690 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -483,7 +483,7 @@ static int shrink_list(struct list_head *page_list, struct scan_control *sc) if (!sc->may_swap) goto keep_locked; - switch (try_to_unmap(page)) { + switch (try_to_unmap(page, 0)) { case SWAP_FAIL: goto activate_locked; case SWAP_AGAIN: @@ -623,7 +623,7 @@ static int swap_page(struct page *page) struct address_space *mapping = page_mapping(page); if (page_mapped(page) && mapping) - if (try_to_unmap(page) != SWAP_SUCCESS) + if (try_to_unmap(page, 0) != SWAP_SUCCESS) goto unlock_retry; if (PageDirty(page)) { @@ -659,6 +659,154 @@ unlock_retry: retry: return -EAGAIN; } + +/* + * Page migration was first developed in the context of the memory hotplug + * project. The main authors of the migration code are: + * + * IWAMOTO Toshihiro + * Hirokazu Takahashi + * Dave Hansen + * Christoph Lameter + */ + +/* + * Remove references for a page and establish the new page with the correct + * basic settings to be able to stop accesses to the page. + */ +static int migrate_page_remove_references(struct page *newpage, + struct page *page, int nr_refs) +{ + struct address_space *mapping = page_mapping(page); + struct page **radix_pointer; + + /* + * Avoid doing any of the following work if the page count + * indicates that the page is in use or truncate has removed + * the page. + */ + if (!mapping || page_mapcount(page) + nr_refs != page_count(page)) + return 1; + + /* + * Establish swap ptes for anonymous pages or destroy pte + * maps for files. + * + * In order to reestablish file backed mappings the fault handlers + * will take the radix tree_lock which may then be used to stop + * processses from accessing this page until the new page is ready. + * + * A process accessing via a swap pte (an anonymous page) will take a + * page_lock on the old page which will block the process until the + * migration attempt is complete. At that time the PageSwapCache bit + * will be examined. If the page was migrated then the PageSwapCache + * bit will be clear and the operation to retrieve the page will be + * retried which will find the new page in the radix tree. Then a new + * direct mapping may be generated based on the radix tree contents. + * + * If the page was not migrated then the PageSwapCache bit + * is still set and the operation may continue. + */ + try_to_unmap(page, 1); + + /* + * Give up if we were unable to remove all mappings. + */ + if (page_mapcount(page)) + return 1; + + write_lock_irq(&mapping->tree_lock); + + radix_pointer = (struct page **)radix_tree_lookup_slot( + &mapping->page_tree, + page_index(page)); + + if (!page_mapping(page) || page_count(page) != nr_refs || + *radix_pointer != page) { + write_unlock_irq(&mapping->tree_lock); + return 1; + } + + /* + * Now we know that no one else is looking at the page. + * + * Certain minimal information about a page must be available + * in order for other subsystems to properly handle the page if they + * find it through the radix tree update before we are finished + * copying the page. + */ + get_page(newpage); + newpage->index = page->index; + newpage->mapping = page->mapping; + if (PageSwapCache(page)) { + SetPageSwapCache(newpage); + set_page_private(newpage, page_private(page)); + } + + *radix_pointer = newpage; + __put_page(page); + write_unlock_irq(&mapping->tree_lock); + + return 0; +} + +/* + * Copy the page to its new location + */ +void migrate_page_copy(struct page *newpage, struct page *page) +{ + copy_highpage(newpage, page); + + if (PageError(page)) + SetPageError(newpage); + if (PageReferenced(page)) + SetPageReferenced(newpage); + if (PageUptodate(page)) + SetPageUptodate(newpage); + if (PageActive(page)) + SetPageActive(newpage); + if (PageChecked(page)) + SetPageChecked(newpage); + if (PageMappedToDisk(page)) + SetPageMappedToDisk(newpage); + + if (PageDirty(page)) { + clear_page_dirty_for_io(page); + set_page_dirty(newpage); + } + + ClearPageSwapCache(page); + ClearPageActive(page); + ClearPagePrivate(page); + set_page_private(page, 0); + page->mapping = NULL; + + /* + * If any waiters have accumulated on the new page then + * wake them up. + */ + if (PageWriteback(newpage)) + end_page_writeback(newpage); +} + +/* + * Common logic to directly migrate a single page suitable for + * pages that do not use PagePrivate. + * + * Pages are locked upon entry and exit. + */ +int migrate_page(struct page *newpage, struct page *page) +{ + BUG_ON(PageWriteback(page)); /* Writeback must be complete */ + + if (migrate_page_remove_references(newpage, page, 2)) + return -EAGAIN; + + migrate_page_copy(newpage, page); + + return 0; +} + /* * migrate_pages * @@ -672,11 +820,6 @@ retry: * are movable anymore because t has become empty * or no retryable pages exist anymore. * - * SIMPLIFIED VERSION: This implementation of migrate_pages - * is only swapping out pages and never touches the second - * list. The direct migration patchset - * extends this function to avoid the use of swap. - * * Return: Number of pages not migrated when "to" ran empty. */ int migrate_pages(struct list_head *from, struct list_head *to, @@ -697,6 +840,9 @@ redo: retry = 0; list_for_each_entry_safe(page, page2, from, lru) { + struct page *newpage = NULL; + struct address_space *mapping; + cond_resched(); rc = 0; @@ -704,6 +850,9 @@ redo: /* page was freed from under us. So we are done. */ goto next; + if (to && list_empty(to)) + break; + /* * Skip locked pages during the first two passes to give the * functions holding the lock time to release the page. Later we @@ -740,12 +889,64 @@ redo: } } + if (!to) { + rc = swap_page(page); + goto next; + } + + newpage = lru_to_page(to); + lock_page(newpage); + /* - * Page is properly locked and writeback is complete. + * Pages are properly locked and writeback is complete. * Try to migrate the page. */ - rc = swap_page(page); - goto next; + mapping = page_mapping(page); + if (!mapping) + goto unlock_both; + + /* + * Trigger writeout if page is dirty + */ + if (PageDirty(page)) { + switch (pageout(page, mapping)) { + case PAGE_KEEP: + case PAGE_ACTIVATE: + goto unlock_both; + + case PAGE_SUCCESS: + unlock_page(newpage); + goto next; + + case PAGE_CLEAN: + ; /* try to migrate the page below */ + } + } + /* + * If we have no buffer or can release the buffer + * then do a simple migration. + */ + if (!page_has_buffers(page) || + try_to_release_page(page, GFP_KERNEL)) { + rc = migrate_page(newpage, page); + goto unlock_both; + } + + /* + * On early passes with mapped pages simply + * retry. There may be a lock held for some + * buffers that may go away. Later + * swap them out. + */ + if (pass > 4) { + unlock_page(newpage); + newpage = NULL; + rc = swap_page(page); + goto next; + } + +unlock_both: + unlock_page(newpage); unlock_page: unlock_page(page); @@ -758,7 +959,10 @@ next: list_move(&page->lru, failed); nr_failed++; } else { - /* Success */ + if (newpage) { + /* Successful migration. Return page to LRU */ + move_to_lru(newpage); + } list_move(&page->lru, moved); } } -- cgit v1.2.3 From a3351e525e4768c29aa5d22ef59b5b38e0361e53 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Wed, 1 Feb 2006 03:05:39 -0800 Subject: [PATCH] Direct Migration V9: remove_from_swap() to remove swap ptes Add remove_from_swap remove_from_swap() allows the restoration of the pte entries that existed before page migration occurred for anonymous pages by walking the reverse maps. This reduces swap use and establishes regular pte's without the need for page faults. Signed-off-by: Christoph Lameter Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/rmap.h | 1 + include/linux/swap.h | 1 + mm/rmap.c | 29 +++++++++++++++++++++++++++++ mm/swapfile.c | 9 +++++++++ mm/vmscan.c | 9 +++++++++ 5 files changed, 49 insertions(+) (limited to 'include') diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 0f1ea2d6ed86..d6b9bcd1384c 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -92,6 +92,7 @@ static inline void page_dup_rmap(struct page *page) */ int page_referenced(struct page *, int is_locked); int try_to_unmap(struct page *, int ignore_refs); +void remove_from_swap(struct page *page); /* * Called from mm/filemap_xip.c to unmap empty zero page diff --git a/include/linux/swap.h b/include/linux/swap.h index d359fc022433..229b6d04b4b6 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -248,6 +248,7 @@ extern int remove_exclusive_swap_page(struct page *); struct backing_dev_info; extern spinlock_t swap_lock; +extern int remove_vma_swap(struct vm_area_struct *vma, struct page *page); /* linux/mm/thrash.c */ extern struct mm_struct * swap_token_mm; diff --git a/mm/rmap.c b/mm/rmap.c index 13fad5fcdf79..f4b91d7aa5cf 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -206,6 +206,35 @@ out: return anon_vma; } +#ifdef CONFIG_MIGRATION +/* + * Remove an anonymous page from swap replacing the swap pte's + * through real pte's pointing to valid pages and then releasing + * the page from the swap cache. + * + * Must hold page lock on page. + */ +void remove_from_swap(struct page *page) +{ + struct anon_vma *anon_vma; + struct vm_area_struct *vma; + + if (!PageAnon(page) || !PageSwapCache(page)) + return; + + anon_vma = page_lock_anon_vma(page); + if (!anon_vma) + return; + + list_for_each_entry(vma, &anon_vma->head, anon_vma_node) + remove_vma_swap(vma, page); + + spin_unlock(&anon_vma->lock); + + delete_from_swap_cache(page); +} +#endif + /* * At what user virtual address is page expected in vma? */ diff --git a/mm/swapfile.c b/mm/swapfile.c index 9678182e0eef..1f9cf0d073b8 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -554,6 +554,15 @@ static int unuse_mm(struct mm_struct *mm, return 0; } +#ifdef CONFIG_MIGRATION +int remove_vma_swap(struct vm_area_struct *vma, struct page *page) +{ + swp_entry_t entry = { .val = page_private(page) }; + + return unuse_vma(vma, entry, page); +} +#endif + /* * Scan swap_map from current position to next entry still in use. * Recycle to start on reaching the end, returning 0 when empty. diff --git a/mm/vmscan.c b/mm/vmscan.c index 8f326ce2b690..5e98b86feb74 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -804,6 +804,15 @@ int migrate_page(struct page *newpage, struct page *page) migrate_page_copy(newpage, page); + /* + * Remove auxiliary swap entries and replace + * them with real ptes. + * + * Note that a real pte entry will allow processes that are not + * waiting on the page lock to use the new page via the page tables + * before the new page is unlocked. + */ + remove_from_swap(newpage); return 0; } -- cgit v1.2.3 From e965f9630c651fa4249039fd4b80c9392d07a856 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Wed, 1 Feb 2006 03:05:41 -0800 Subject: [PATCH] Direct Migration V9: Avoid writeback / page_migrate() method Migrate a page with buffers without requiring writeback This introduces a new address space operation migratepage() that may be used by a filesystem to implement its own version of page migration. A version is provided that migrates buffers attached to pages. Some filesystems (ext2, ext3, xfs) are modified to utilize this feature. The swapper address space operation are modified so that a regular migrate_page() will occur for anonymous pages without writeback (migrate_pages forces every anonymous page to have a swap entry). Signed-off-by: Mike Kravetz Signed-off-by: Christoph Lameter Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/buffer.c | 60 +++++++++++++++++++++++++++++++++++++++++++++ fs/ext2/inode.c | 2 ++ fs/ext3/inode.c | 2 ++ fs/xfs/linux-2.6/xfs_aops.c | 1 + fs/xfs/linux-2.6/xfs_buf.c | 1 + include/linux/fs.h | 8 ++++++ include/linux/swap.h | 5 ++++ mm/rmap.c | 1 + mm/swap_state.c | 1 + mm/vmscan.c | 20 ++++++++++++++- 10 files changed, 100 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/fs/buffer.c b/fs/buffer.c index 3dc712f29d2d..8bcbac87a28c 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3049,6 +3049,66 @@ asmlinkage long sys_bdflush(int func, long data) return 0; } +/* + * Migration function for pages with buffers. This function can only be used + * if the underlying filesystem guarantees that no other references to "page" + * exist. + */ +#ifdef CONFIG_MIGRATION +int buffer_migrate_page(struct page *newpage, struct page *page) +{ + struct address_space *mapping = page->mapping; + struct buffer_head *bh, *head; + + if (!mapping) + return -EAGAIN; + + if (!page_has_buffers(page)) + return migrate_page(newpage, page); + + head = page_buffers(page); + + if (migrate_page_remove_references(newpage, page, 3)) + return -EAGAIN; + + bh = head; + do { + get_bh(bh); + lock_buffer(bh); + bh = bh->b_this_page; + + } while (bh != head); + + ClearPagePrivate(page); + set_page_private(newpage, page_private(page)); + set_page_private(page, 0); + put_page(page); + get_page(newpage); + + bh = head; + do { + set_bh_page(bh, newpage, bh_offset(bh)); + bh = bh->b_this_page; + + } while (bh != head); + + SetPagePrivate(newpage); + + migrate_page_copy(newpage, page); + + bh = head; + do { + unlock_buffer(bh); + put_bh(bh); + bh = bh->b_this_page; + + } while (bh != head); + + return 0; +} +EXPORT_SYMBOL(buffer_migrate_page); +#endif + /* * Buffer-head allocation */ diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index e7d3f0522d01..a717837f272e 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -706,6 +706,7 @@ struct address_space_operations ext2_aops = { .bmap = ext2_bmap, .direct_IO = ext2_direct_IO, .writepages = ext2_writepages, + .migratepage = buffer_migrate_page, }; struct address_space_operations ext2_aops_xip = { @@ -723,6 +724,7 @@ struct address_space_operations ext2_nobh_aops = { .bmap = ext2_bmap, .direct_IO = ext2_direct_IO, .writepages = ext2_writepages, + .migratepage = buffer_migrate_page, }; /* diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index 8824e84f8a56..3fc4238e9703 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c @@ -1559,6 +1559,7 @@ static struct address_space_operations ext3_ordered_aops = { .invalidatepage = ext3_invalidatepage, .releasepage = ext3_releasepage, .direct_IO = ext3_direct_IO, + .migratepage = buffer_migrate_page, }; static struct address_space_operations ext3_writeback_aops = { @@ -1572,6 +1573,7 @@ static struct address_space_operations ext3_writeback_aops = { .invalidatepage = ext3_invalidatepage, .releasepage = ext3_releasepage, .direct_IO = ext3_direct_IO, + .migratepage = buffer_migrate_page, }; static struct address_space_operations ext3_journalled_aops = { diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c index 120626789406..9892268e3005 100644 --- a/fs/xfs/linux-2.6/xfs_aops.c +++ b/fs/xfs/linux-2.6/xfs_aops.c @@ -1462,4 +1462,5 @@ struct address_space_operations linvfs_aops = { .commit_write = generic_commit_write, .bmap = linvfs_bmap, .direct_IO = linvfs_direct_IO, + .migratepage = buffer_migrate_page, }; diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index a36a8e3b703f..bfb4f2917bb6 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c @@ -1521,6 +1521,7 @@ xfs_mapping_buftarg( struct address_space *mapping; static struct address_space_operations mapping_aops = { .sync_page = block_sync_page, + .migratepage = fail_migrate_page, }; inode = new_inode(bdev->bd_inode->i_sb); diff --git a/include/linux/fs.h b/include/linux/fs.h index 84bb449b9b01..e059da947007 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -363,6 +363,8 @@ struct address_space_operations { loff_t offset, unsigned long nr_segs); struct page* (*get_xip_page)(struct address_space *, sector_t, int); + /* migrate the contents of a page to the specified target */ + int (*migratepage) (struct page *, struct page *); }; struct backing_dev_info; @@ -1719,6 +1721,12 @@ extern void simple_release_fs(struct vfsmount **mount, int *count); extern ssize_t simple_read_from_buffer(void __user *, size_t, loff_t *, const void *, size_t); +#ifdef CONFIG_MIGRATION +extern int buffer_migrate_page(struct page *, struct page *); +#else +#define buffer_migrate_page NULL +#endif + extern int inode_change_ok(struct inode *, struct iattr *); extern int __must_check inode_setattr(struct inode *, struct iattr *); diff --git a/include/linux/swap.h b/include/linux/swap.h index 229b6d04b4b6..f3e17d5963c3 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -193,13 +193,18 @@ extern int isolate_lru_page(struct page *p); extern int putback_lru_pages(struct list_head *l); extern int migrate_page(struct page *, struct page *); extern void migrate_page_copy(struct page *, struct page *); +extern int migrate_page_remove_references(struct page *, struct page *, int); extern int migrate_pages(struct list_head *l, struct list_head *t, struct list_head *moved, struct list_head *failed); +extern int fail_migrate_page(struct page *, struct page *); #else static inline int isolate_lru_page(struct page *p) { return -ENOSYS; } static inline int putback_lru_pages(struct list_head *l) { return 0; } static inline int migrate_pages(struct list_head *l, struct list_head *t, struct list_head *moved, struct list_head *failed) { return -ENOSYS; } +/* Possible settings for the migrate_page() method in address_operations */ +#define migrate_page NULL +#define fail_migrate_page NULL #endif #ifdef CONFIG_MMU diff --git a/mm/rmap.c b/mm/rmap.c index f4b91d7aa5cf..df2c41c2a9a2 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -233,6 +233,7 @@ void remove_from_swap(struct page *page) delete_from_swap_cache(page); } +EXPORT_SYMBOL(remove_from_swap); #endif /* diff --git a/mm/swap_state.c b/mm/swap_state.c index 7b09ac503fec..db8a3d3e1636 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -27,6 +27,7 @@ static struct address_space_operations swap_aops = { .writepage = swap_writepage, .sync_page = block_sync_page, .set_page_dirty = __set_page_dirty_nobuffers, + .migratepage = migrate_page, }; static struct backing_dev_info swap_backing_dev_info = { diff --git a/mm/vmscan.c b/mm/vmscan.c index 5e98b86feb74..5a610804cd06 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -614,6 +614,15 @@ int putback_lru_pages(struct list_head *l) return count; } +/* + * Non migratable page + */ +int fail_migrate_page(struct page *newpage, struct page *page) +{ + return -EIO; +} +EXPORT_SYMBOL(fail_migrate_page); + /* * swapout a single page * page is locked upon entry, unlocked on exit @@ -659,6 +668,7 @@ unlock_retry: retry: return -EAGAIN; } +EXPORT_SYMBOL(swap_page); /* * Page migration was first developed in the context of the memory hotplug @@ -674,7 +684,7 @@ retry: * Remove references for a page and establish the new page with the correct * basic settings to be able to stop accesses to the page. */ -static int migrate_page_remove_references(struct page *newpage, +int migrate_page_remove_references(struct page *newpage, struct page *page, int nr_refs) { struct address_space *mapping = page_mapping(page); @@ -749,6 +759,7 @@ static int migrate_page_remove_references(struct page *newpage, return 0; } +EXPORT_SYMBOL(migrate_page_remove_references); /* * Copy the page to its new location @@ -788,6 +799,7 @@ void migrate_page_copy(struct page *newpage, struct page *page) if (PageWriteback(newpage)) end_page_writeback(newpage); } +EXPORT_SYMBOL(migrate_page_copy); /* * Common logic to directly migrate a single page suitable for @@ -815,6 +827,7 @@ int migrate_page(struct page *newpage, struct page *page) remove_from_swap(newpage); return 0; } +EXPORT_SYMBOL(migrate_page); /* * migrate_pages @@ -914,6 +927,11 @@ redo: if (!mapping) goto unlock_both; + if (mapping->a_ops->migratepage) { + rc = mapping->a_ops->migratepage(newpage, page); + goto unlock_both; + } + /* * Trigger writeout if page is dirty */ -- cgit v1.2.3 From 7fd6b1413082c303613fc137aca9a004740cacf0 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Wed, 1 Feb 2006 03:05:52 -0800 Subject: [PATCH] slab: fix kzalloc and kstrdup caller report for CONFIG_DEBUG_SLAB Fix kzalloc() and kstrdup() caller report for CONFIG_DEBUG_SLAB. We must pass the caller to __cache_alloc() instead of directly doing __builtin_return_address(0) there; otherwise kzalloc() and kstrdup() are reported as the allocation site instead of the real one. Thanks to Valdis Kletnieks for reporting the problem and Steven Rostedt for the original idea. Signed-off-by: Pekka Enberg Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/slab.h | 7 +++++++ mm/slab.c | 29 ++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/linux/slab.h b/include/linux/slab.h index 1fb77a9cc148..8cf52939d0ab 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -76,7 +76,14 @@ struct cache_sizes { kmem_cache_t *cs_dmacachep; }; extern struct cache_sizes malloc_sizes[]; + +#ifndef CONFIG_DEBUG_SLAB extern void *__kmalloc(size_t, gfp_t); +#else +extern void *__kmalloc_track_caller(size_t, gfp_t, void*); +#define __kmalloc(size, flags) \ + __kmalloc_track_caller(size, flags, __builtin_return_address(0)) +#endif static inline void *kmalloc(size_t size, gfp_t flags) { diff --git a/mm/slab.c b/mm/slab.c index 6fbd6a1cdeb4..67527268b01c 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -2687,7 +2687,8 @@ static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags) return objp; } -static inline void *__cache_alloc(struct kmem_cache *cachep, gfp_t flags) +static __always_inline void * +__cache_alloc(struct kmem_cache *cachep, gfp_t flags, void *caller) { unsigned long save_flags; void *objp; @@ -2698,7 +2699,7 @@ static inline void *__cache_alloc(struct kmem_cache *cachep, gfp_t flags) objp = ____cache_alloc(cachep, flags); local_irq_restore(save_flags); objp = cache_alloc_debugcheck_after(cachep, flags, objp, - __builtin_return_address(0)); + caller); prefetchw(objp); return objp; } @@ -2927,7 +2928,7 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp) */ void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags) { - return __cache_alloc(cachep, flags); + return __cache_alloc(cachep, flags, __builtin_return_address(0)); } EXPORT_SYMBOL(kmem_cache_alloc); @@ -3041,7 +3042,8 @@ EXPORT_SYMBOL(kmalloc_node); * platforms. For example, on i386, it means that the memory must come * from the first 16MB. */ -void *__kmalloc(size_t size, gfp_t flags) +static __always_inline void *__do_kmalloc(size_t size, gfp_t flags, + void *caller) { struct kmem_cache *cachep; @@ -3053,10 +3055,27 @@ void *__kmalloc(size_t size, gfp_t flags) cachep = __find_general_cachep(size, flags); if (unlikely(cachep == NULL)) return NULL; - return __cache_alloc(cachep, flags); + return __cache_alloc(cachep, flags, caller); +} + +#ifndef CONFIG_DEBUG_SLAB + +void *__kmalloc(size_t size, gfp_t flags) +{ + return __do_kmalloc(size, flags, NULL); } EXPORT_SYMBOL(__kmalloc); +#else + +void *__kmalloc_track_caller(size_t size, gfp_t flags, void *caller) +{ + return __do_kmalloc(size, flags, caller); +} +EXPORT_SYMBOL(__kmalloc_track_caller); + +#endif + #ifdef CONFIG_SMP /** * __alloc_percpu - allocate one copy of the object for every present -- cgit v1.2.3 From 39931e41becd6abeb2014747369d8b6392f5dbac Mon Sep 17 00:00:00 2001 From: Albert Herranz Date: Wed, 1 Feb 2006 03:05:57 -0800 Subject: [PATCH] powerpc: fix for kexec ppc32 - kexec.h is included from assembly code, thus C code must be properly protected. - (embedded) ppc32 systems use machine_kexec_simple whose declaration vanished during a recent powerpc merge change. Signed-off-by: Albert Herranz Cc: Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-powerpc/kexec.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/asm-powerpc/kexec.h b/include/asm-powerpc/kexec.h index 640a6459f2f4..bda2f217e6fe 100644 --- a/include/asm-powerpc/kexec.h +++ b/include/asm-powerpc/kexec.h @@ -33,6 +33,7 @@ #ifdef CONFIG_KEXEC +#ifndef __ASSEMBLY__ #ifdef __powerpc64__ /* * This function is responsible for capturing register states if coming @@ -104,7 +105,6 @@ static inline void crash_setup_regs(struct pt_regs *newregs, struct pt_regs *oldregs) { } #endif /* !__powerpc64 __ */ -#ifndef __ASSEMBLY__ #define MAX_NOTE_BYTES 1024 #ifdef __powerpc64__ @@ -121,6 +121,8 @@ extern void default_machine_kexec(struct kimage *image); extern int default_machine_kexec_prepare(struct kimage *image); extern void default_machine_crash_shutdown(struct pt_regs *regs); +extern void machine_kexec_simple(struct kimage *image); + #endif /* ! __ASSEMBLY__ */ #endif /* CONFIG_KEXEC */ #endif /* __KERNEL__ */ -- cgit v1.2.3 From 740172947b315fa97f8d29b0b9809b1ea1201642 Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Wed, 1 Feb 2006 03:05:59 -0800 Subject: [PATCH] sh: SH4-202 microdev updates A few trivial updates for the microdev board support code: - Update for __IO_PREFIX changes. - Consolidate headers into a single microdev.h. - Update the microdev_defconfig. - Add init values for the S1D13806 used by s1d13xxxfb. Signed-off-by: Paul Mundt Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/sh/boards/superh/microdev/io.c | 192 ++++++++------- arch/sh/boards/superh/microdev/irq.c | 2 +- arch/sh/boards/superh/microdev/setup.c | 166 ++++++++++++- arch/sh/configs/microdev_defconfig | 410 ++++++++++++++++++++------------- include/asm-sh/microdev.h | 80 +++++++ include/asm-sh/microdev/io.h | 53 ----- include/asm-sh/microdev/irq.h | 72 ------ 7 files changed, 582 insertions(+), 393 deletions(-) create mode 100644 include/asm-sh/microdev.h delete mode 100644 include/asm-sh/microdev/io.h delete mode 100644 include/asm-sh/microdev/irq.h (limited to 'include') diff --git a/arch/sh/boards/superh/microdev/io.c b/arch/sh/boards/superh/microdev/io.c index fe83b2c03076..1ed7f880b8c7 100644 --- a/arch/sh/boards/superh/microdev/io.c +++ b/arch/sh/boards/superh/microdev/io.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include /* * we need to have a 'safe' address to re-direct all I/O requests @@ -52,8 +52,90 @@ #define IO_ISP1161_PHYS 0xa7700000ul /* Physical address of Philips ISP1161x USB chip */ #define IO_SUPERIO_PHYS 0xa7800000ul /* Physical address of SMSC FDC37C93xAPM SuperIO chip */ -#define PORT2ADDR(x) (microdev_isa_port2addr(x)) +/* + * map I/O ports to memory-mapped addresses + */ +static unsigned long microdev_isa_port2addr(unsigned long offset) +{ + unsigned long result; + + if ((offset >= IO_LAN91C111_BASE) && + (offset < IO_LAN91C111_BASE + IO_LAN91C111_EXTENT)) { + /* + * SMSC LAN91C111 Ethernet chip + */ + result = IO_LAN91C111_PHYS + offset - IO_LAN91C111_BASE; + } else if ((offset >= IO_SUPERIO_BASE) && + (offset < IO_SUPERIO_BASE + IO_SUPERIO_EXTENT)) { + /* + * SMSC FDC37C93xAPM SuperIO chip + * + * Configuration Registers + */ + result = IO_SUPERIO_PHYS + (offset << 1); +#if 0 + } else if (offset == KBD_DATA_REG || offset == KBD_CNTL_REG || + offset == KBD_STATUS_REG) { + /* + * SMSC FDC37C93xAPM SuperIO chip + * + * PS/2 Keyboard + Mouse (ports 0x60 and 0x64). + */ + result = IO_SUPERIO_PHYS + (offset << 1); +#endif + } else if (((offset >= IO_IDE1_BASE) && + (offset < IO_IDE1_BASE + IO_IDE_EXTENT)) || + (offset == IO_IDE1_MISC)) { + /* + * SMSC FDC37C93xAPM SuperIO chip + * + * IDE #1 + */ + result = IO_SUPERIO_PHYS + (offset << 1); + } else if (((offset >= IO_IDE2_BASE) && + (offset < IO_IDE2_BASE + IO_IDE_EXTENT)) || + (offset == IO_IDE2_MISC)) { + /* + * SMSC FDC37C93xAPM SuperIO chip + * + * IDE #2 + */ + result = IO_SUPERIO_PHYS + (offset << 1); + } else if ((offset >= IO_SERIAL1_BASE) && + (offset < IO_SERIAL1_BASE + IO_SERIAL_EXTENT)) { + /* + * SMSC FDC37C93xAPM SuperIO chip + * + * Serial #1 + */ + result = IO_SUPERIO_PHYS + (offset << 1); + } else if ((offset >= IO_SERIAL2_BASE) && + (offset < IO_SERIAL2_BASE + IO_SERIAL_EXTENT)) { + /* + * SMSC FDC37C93xAPM SuperIO chip + * + * Serial #2 + */ + result = IO_SUPERIO_PHYS + (offset << 1); + } else if ((offset >= IO_ISP1161_BASE) && + (offset < IO_ISP1161_BASE + IO_ISP1161_EXTENT)) { + /* + * Philips USB ISP1161x chip + */ + result = IO_ISP1161_PHYS + offset - IO_ISP1161_BASE; + } else { + /* + * safe default. + */ + printk("Warning: unexpected port in %s( offset = 0x%lx )\n", + __FUNCTION__, offset); + result = PVR; + } + + return result; +} +#define PORT2ADDR(x) (microdev_isa_port2addr(x)) static inline void delay(void) { @@ -94,6 +176,17 @@ unsigned int microdev_inl(unsigned long port) return *(volatile unsigned int*)PORT2ADDR(port); } +void microdev_outw(unsigned short b, unsigned long port) +{ +#ifdef CONFIG_PCI + if (port >= PCIBIOS_MIN_IO) { + microdev_pci_outw(b, port); + return; + } +#endif + *(volatile unsigned short*)PORT2ADDR(port) = b; +} + void microdev_outb(unsigned char b, unsigned long port) { #ifdef CONFIG_PCI @@ -158,17 +251,6 @@ void microdev_outb(unsigned char b, unsigned long port) } } -void microdev_outw(unsigned short b, unsigned long port) -{ -#ifdef CONFIG_PCI - if (port >= PCIBIOS_MIN_IO) { - microdev_pci_outw(b, port); - return; - } -#endif - *(volatile unsigned short*)PORT2ADDR(port) = b; -} - void microdev_outl(unsigned int b, unsigned long port) { #ifdef CONFIG_PCI @@ -284,87 +366,3 @@ void microdev_outsl(unsigned long port, const void *buffer, unsigned long count) while (count--) *port_addr = *buf++; } - -/* - * map I/O ports to memory-mapped addresses - */ -unsigned long microdev_isa_port2addr(unsigned long offset) -{ - unsigned long result; - - if ((offset >= IO_LAN91C111_BASE) && - (offset < IO_LAN91C111_BASE + IO_LAN91C111_EXTENT)) { - /* - * SMSC LAN91C111 Ethernet chip - */ - result = IO_LAN91C111_PHYS + offset - IO_LAN91C111_BASE; - } else if ((offset >= IO_SUPERIO_BASE) && - (offset < IO_SUPERIO_BASE + IO_SUPERIO_EXTENT)) { - /* - * SMSC FDC37C93xAPM SuperIO chip - * - * Configuration Registers - */ - result = IO_SUPERIO_PHYS + (offset << 1); -#if 0 - } else if (offset == KBD_DATA_REG || offset == KBD_CNTL_REG || - offset == KBD_STATUS_REG) { - /* - * SMSC FDC37C93xAPM SuperIO chip - * - * PS/2 Keyboard + Mouse (ports 0x60 and 0x64). - */ - result = IO_SUPERIO_PHYS + (offset << 1); -#endif - } else if (((offset >= IO_IDE1_BASE) && - (offset < IO_IDE1_BASE + IO_IDE_EXTENT)) || - (offset == IO_IDE1_MISC)) { - /* - * SMSC FDC37C93xAPM SuperIO chip - * - * IDE #1 - */ - result = IO_SUPERIO_PHYS + (offset << 1); - } else if (((offset >= IO_IDE2_BASE) && - (offset < IO_IDE2_BASE + IO_IDE_EXTENT)) || - (offset == IO_IDE2_MISC)) { - /* - * SMSC FDC37C93xAPM SuperIO chip - * - * IDE #2 - */ - result = IO_SUPERIO_PHYS + (offset << 1); - } else if ((offset >= IO_SERIAL1_BASE) && - (offset < IO_SERIAL1_BASE + IO_SERIAL_EXTENT)) { - /* - * SMSC FDC37C93xAPM SuperIO chip - * - * Serial #1 - */ - result = IO_SUPERIO_PHYS + (offset << 1); - } else if ((offset >= IO_SERIAL2_BASE) && - (offset < IO_SERIAL2_BASE + IO_SERIAL_EXTENT)) { - /* - * SMSC FDC37C93xAPM SuperIO chip - * - * Serial #2 - */ - result = IO_SUPERIO_PHYS + (offset << 1); - } else if ((offset >= IO_ISP1161_BASE) && - (offset < IO_ISP1161_BASE + IO_ISP1161_EXTENT)) { - /* - * Philips USB ISP1161x chip - */ - result = IO_ISP1161_PHYS + offset - IO_ISP1161_BASE; - } else { - /* - * safe default. - */ - printk("Warning: unexpected port in %s( offset = 0x%lx )\n", - __FUNCTION__, offset); - result = PVR; - } - - return result; -} - diff --git a/arch/sh/boards/superh/microdev/irq.c b/arch/sh/boards/superh/microdev/irq.c index 1395c1e65da4..efcbd86b7cd2 100644 --- a/arch/sh/boards/superh/microdev/irq.c +++ b/arch/sh/boards/superh/microdev/irq.c @@ -15,7 +15,7 @@ #include #include -#include +#include #define NUM_EXTERNAL_IRQS 16 /* IRL0 .. IRL15 */ diff --git a/arch/sh/boards/superh/microdev/setup.c b/arch/sh/boards/superh/microdev/setup.c index 1c1d65fb12df..892b14d31405 100644 --- a/arch/sh/boards/superh/microdev/setup.c +++ b/arch/sh/boards/superh/microdev/setup.c @@ -3,7 +3,7 @@ * * Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com) * Copyright (C) 2003, 2004 SuperH, Inc. - * Copyright (C) 2004 Paul Mundt + * Copyright (C) 2004, 2005 Paul Mundt * * SuperH SH4-202 MicroDev board support. * @@ -15,11 +15,10 @@ #include #include #include +#include