提交 8b4e2fa4 编写于 作者: R Rafael J. Wysocki

Merge branch 'acpi-lpss' into acpi-cleanup

The following commits depend on the 'acpi-lpss' material.
...@@ -52,10 +52,6 @@ ...@@ -52,10 +52,6 @@
/* Asm macros */ /* Asm macros */
#define ACPI_ASM_MACROS
#define BREAKPOINT3
#define ACPI_DISABLE_IRQS() local_irq_disable()
#define ACPI_ENABLE_IRQS() local_irq_enable()
#define ACPI_FLUSH_CPU_CACHE() #define ACPI_FLUSH_CPU_CACHE()
static inline int static inline int
......
...@@ -454,6 +454,16 @@ config X86_MDFLD ...@@ -454,6 +454,16 @@ config X86_MDFLD
endif endif
config X86_INTEL_LPSS
bool "Intel Low Power Subsystem Support"
depends on ACPI
select COMMON_CLK
---help---
Select to build support for Intel Low Power Subsystem such as
found on Intel Lynxpoint PCH. Selecting this option enables
things like clock tree (common clock framework) which are needed
by the LPSS peripheral drivers.
config X86_RDC321X config X86_RDC321X
bool "RDC R-321x SoC" bool "RDC R-321x SoC"
depends on X86_32 depends on X86_32
......
...@@ -49,10 +49,6 @@ ...@@ -49,10 +49,6 @@
/* Asm macros */ /* Asm macros */
#define ACPI_ASM_MACROS
#define BREAKPOINT3
#define ACPI_DISABLE_IRQS() local_irq_disable()
#define ACPI_ENABLE_IRQS() local_irq_enable()
#define ACPI_FLUSH_CPU_CACHE() wbinvd() #define ACPI_FLUSH_CPU_CACHE() wbinvd()
int __acpi_acquire_global_lock(unsigned int *lock); int __acpi_acquire_global_lock(unsigned int *lock);
......
...@@ -38,6 +38,7 @@ acpi-y += processor_core.o ...@@ -38,6 +38,7 @@ acpi-y += processor_core.o
acpi-y += ec.o acpi-y += ec.o
acpi-$(CONFIG_ACPI_DOCK) += dock.o acpi-$(CONFIG_ACPI_DOCK) += dock.o
acpi-y += pci_root.o pci_link.o pci_irq.o acpi-y += pci_root.o pci_link.o pci_irq.o
acpi-y += csrt.o
acpi-y += acpi_platform.o acpi-y += acpi_platform.o
acpi-y += power.o acpi-y += power.o
acpi-y += event.o acpi-y += event.o
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/err.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
...@@ -21,17 +22,34 @@ ...@@ -21,17 +22,34 @@
ACPI_MODULE_NAME("platform"); ACPI_MODULE_NAME("platform");
static int acpi_create_platform_clks(struct acpi_device *adev)
{
static struct platform_device *pdev;
/* Create Lynxpoint LPSS clocks */
if (!pdev && !strncmp(acpi_device_hid(adev), "INT33C", 6)) {
pdev = platform_device_register_simple("clk-lpt", -1, NULL, 0);
if (IS_ERR(pdev))
return PTR_ERR(pdev);
}
return 0;
}
/** /**
* acpi_create_platform_device - Create platform device for ACPI device node * acpi_create_platform_device - Create platform device for ACPI device node
* @adev: ACPI device node to create a platform device for. * @adev: ACPI device node to create a platform device for.
* @flags: ACPI_PLATFORM_* flags that affect the creation of the platform
* devices.
* *
* Check if the given @adev can be represented as a platform device and, if * Check if the given @adev can be represented as a platform device and, if
* that's the case, create and register a platform device, populate its common * that's the case, create and register a platform device, populate its common
* resources and returns a pointer to it. Otherwise, return %NULL. * resources and returns a pointer to it. Otherwise, return %NULL.
* *
* The platform device's name will be taken from the @adev's _HID and _UID. * Name of the platform device will be the same as @adev's.
*/ */
struct platform_device *acpi_create_platform_device(struct acpi_device *adev) struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
unsigned long flags)
{ {
struct platform_device *pdev = NULL; struct platform_device *pdev = NULL;
struct acpi_device *acpi_parent; struct acpi_device *acpi_parent;
...@@ -41,6 +59,11 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev) ...@@ -41,6 +59,11 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
struct resource *resources; struct resource *resources;
int count; int count;
if ((flags & ACPI_PLATFORM_CLK) && acpi_create_platform_clks(adev)) {
dev_err(&adev->dev, "failed to create clocks\n");
return NULL;
}
/* If the ACPI node already has a physical device attached, skip it. */ /* If the ACPI node already has a physical device attached, skip it. */
if (adev->physical_node_count) if (adev->physical_node_count)
return NULL; return NULL;
......
...@@ -31,6 +31,7 @@ acpi-y += \ ...@@ -31,6 +31,7 @@ acpi-y += \
evgpeinit.o \ evgpeinit.o \
evgpeutil.o \ evgpeutil.o \
evglock.o \ evglock.o \
evhandler.o \
evmisc.o \ evmisc.o \
evregion.o \ evregion.o \
evrgnini.o \ evrgnini.o \
...@@ -90,6 +91,7 @@ acpi-y += \ ...@@ -90,6 +91,7 @@ acpi-y += \
nsobject.o \ nsobject.o \
nsparse.o \ nsparse.o \
nspredef.o \ nspredef.o \
nsprepkg.o \
nsrepair.o \ nsrepair.o \
nsrepair2.o \ nsrepair2.o \
nssearch.o \ nssearch.o \
...@@ -104,7 +106,9 @@ acpi-$(ACPI_FUTURE_USAGE) += nsdumpdv.o ...@@ -104,7 +106,9 @@ acpi-$(ACPI_FUTURE_USAGE) += nsdumpdv.o
acpi-y += \ acpi-y += \
psargs.o \ psargs.o \
psloop.o \ psloop.o \
psobject.o \
psopcode.o \ psopcode.o \
psopinfo.o \
psparse.o \ psparse.o \
psscope.o \ psscope.o \
pstree.o \ pstree.o \
...@@ -126,7 +130,7 @@ acpi-y += \ ...@@ -126,7 +130,7 @@ acpi-y += \
rsutils.o \ rsutils.o \
rsxface.o rsxface.o
acpi-$(ACPI_FUTURE_USAGE) += rsdump.o acpi-$(ACPI_FUTURE_USAGE) += rsdump.o rsdumpinfo.o
acpi-y += \ acpi-y += \
tbfadt.o \ tbfadt.o \
...@@ -155,8 +159,10 @@ acpi-y += \ ...@@ -155,8 +159,10 @@ acpi-y += \
utmutex.o \ utmutex.o \
utobject.o \ utobject.o \
utosi.o \ utosi.o \
utownerid.o \
utresrc.o \ utresrc.o \
utstate.o \ utstate.o \
utstring.o \
utxface.o \ utxface.o \
utxfinit.o \ utxfinit.o \
utxferror.o \ utxferror.o \
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
* *
* Note: The order of these include files is important. * Note: The order of these include files is important.
*/ */
#include <acpi/acconfig.h> /* Global configuration constants */
#include "acmacros.h" /* C macros */ #include "acmacros.h" /* C macros */
#include "aclocal.h" /* Internal data types */ #include "aclocal.h" /* Internal data types */
#include "acobject.h" /* ACPI internal object */ #include "acobject.h" /* ACPI internal object */
......
...@@ -114,6 +114,21 @@ ACPI_HW_DEPENDENT_RETURN_VOID(void ...@@ -114,6 +114,21 @@ ACPI_HW_DEPENDENT_RETURN_VOID(void
acpi_db_generate_gpe(char *gpe_arg, acpi_db_generate_gpe(char *gpe_arg,
char *block_arg)) char *block_arg))
/*
* dbconvert - miscellaneous conversion routines
*/
acpi_status acpi_db_hex_char_to_value(int hex_char, u8 *return_value);
acpi_status acpi_db_convert_to_package(char *string, union acpi_object *object);
acpi_status
acpi_db_convert_to_object(acpi_object_type type,
char *string, union acpi_object *object);
u8 *acpi_db_encode_pld_buffer(struct acpi_pld_info *pld_info);
void acpi_db_dump_pld_buffer(union acpi_object *obj_desc);
/* /*
* dbmethod - control method commands * dbmethod - control method commands
*/ */
...@@ -191,6 +206,8 @@ void ...@@ -191,6 +206,8 @@ void
acpi_db_create_execution_threads(char *num_threads_arg, acpi_db_create_execution_threads(char *num_threads_arg,
char *num_loops_arg, char *method_name_arg); char *num_loops_arg, char *method_name_arg);
void acpi_db_delete_objects(u32 count, union acpi_object *objects);
#ifdef ACPI_DBG_TRACK_ALLOCATIONS #ifdef ACPI_DBG_TRACK_ALLOCATIONS
u32 acpi_db_get_cache_info(struct acpi_memory_list *cache); u32 acpi_db_get_cache_info(struct acpi_memory_list *cache);
#endif #endif
......
...@@ -158,10 +158,23 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, ...@@ -158,10 +158,23 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
void *context); void *context);
/* /*
* evregion - Address Space handling * evhandler - Address space handling
*/ */
u8
acpi_ev_has_default_handler(struct acpi_namespace_node *node,
acpi_adr_space_type space_id);
acpi_status acpi_ev_install_region_handlers(void); acpi_status acpi_ev_install_region_handlers(void);
acpi_status
acpi_ev_install_space_handler(struct acpi_namespace_node *node,
acpi_adr_space_type space_id,
acpi_adr_space_handler handler,
acpi_adr_space_setup setup, void *context);
/*
* evregion - Operation region support
*/
acpi_status acpi_ev_initialize_op_regions(void); acpi_status acpi_ev_initialize_op_regions(void);
acpi_status acpi_status
...@@ -179,12 +192,6 @@ void ...@@ -179,12 +192,6 @@ void
acpi_ev_detach_region(union acpi_operand_object *region_obj, acpi_ev_detach_region(union acpi_operand_object *region_obj,
u8 acpi_ns_is_locked); u8 acpi_ns_is_locked);
acpi_status
acpi_ev_install_space_handler(struct acpi_namespace_node *node,
acpi_adr_space_type space_id,
acpi_adr_space_handler handler,
acpi_adr_space_setup setup, void *context);
acpi_status acpi_status
acpi_ev_execute_reg_methods(struct acpi_namespace_node *node, acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
acpi_adr_space_type space_id); acpi_adr_space_type space_id);
......
...@@ -192,14 +192,6 @@ ACPI_EXTERN u8 acpi_gbl_integer_bit_width; ...@@ -192,14 +192,6 @@ ACPI_EXTERN u8 acpi_gbl_integer_bit_width;
ACPI_EXTERN u8 acpi_gbl_integer_byte_width; ACPI_EXTERN u8 acpi_gbl_integer_byte_width;
ACPI_EXTERN u8 acpi_gbl_integer_nybble_width; ACPI_EXTERN u8 acpi_gbl_integer_nybble_width;
/* Mutex for _OSI support */
ACPI_EXTERN acpi_mutex acpi_gbl_osi_mutex;
/* Reader/Writer lock is used for namespace walk and dynamic table unload */
ACPI_EXTERN struct acpi_rw_lock acpi_gbl_namespace_rw_lock;
/***************************************************************************** /*****************************************************************************
* *
* Mutual exclusion within ACPICA subsystem * Mutual exclusion within ACPICA subsystem
...@@ -233,6 +225,14 @@ ACPI_EXTERN u8 acpi_gbl_global_lock_pending; ...@@ -233,6 +225,14 @@ ACPI_EXTERN u8 acpi_gbl_global_lock_pending;
ACPI_EXTERN acpi_spinlock acpi_gbl_gpe_lock; /* For GPE data structs and registers */ ACPI_EXTERN acpi_spinlock acpi_gbl_gpe_lock; /* For GPE data structs and registers */
ACPI_EXTERN acpi_spinlock acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */ ACPI_EXTERN acpi_spinlock acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */
/* Mutex for _OSI support */
ACPI_EXTERN acpi_mutex acpi_gbl_osi_mutex;
/* Reader/Writer lock is used for namespace walk and dynamic table unload */
ACPI_EXTERN struct acpi_rw_lock acpi_gbl_namespace_rw_lock;
/***************************************************************************** /*****************************************************************************
* *
* Miscellaneous globals * Miscellaneous globals
...@@ -252,7 +252,7 @@ ACPI_EXTERN acpi_cache_t *acpi_gbl_operand_cache; ...@@ -252,7 +252,7 @@ ACPI_EXTERN acpi_cache_t *acpi_gbl_operand_cache;
ACPI_EXTERN struct acpi_global_notify_handler acpi_gbl_global_notify[2]; ACPI_EXTERN struct acpi_global_notify_handler acpi_gbl_global_notify[2];
ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler; ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler;
ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler; ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler;
ACPI_EXTERN acpi_tbl_handler acpi_gbl_table_handler; ACPI_EXTERN acpi_table_handler acpi_gbl_table_handler;
ACPI_EXTERN void *acpi_gbl_table_handler_context; ACPI_EXTERN void *acpi_gbl_table_handler_context;
ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk; ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk;
ACPI_EXTERN acpi_interface_handler acpi_gbl_interface_handler; ACPI_EXTERN acpi_interface_handler acpi_gbl_interface_handler;
...@@ -304,6 +304,7 @@ extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS]; ...@@ -304,6 +304,7 @@ extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS];
ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list; ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list;
ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list; ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list;
ACPI_EXTERN u8 acpi_gbl_display_final_mem_stats; ACPI_EXTERN u8 acpi_gbl_display_final_mem_stats;
ACPI_EXTERN u8 acpi_gbl_disable_mem_tracking;
#endif #endif
/***************************************************************************** /*****************************************************************************
...@@ -365,19 +366,18 @@ ACPI_EXTERN u8 acpi_gbl_sleep_type_b; ...@@ -365,19 +366,18 @@ ACPI_EXTERN u8 acpi_gbl_sleep_type_b;
* *
****************************************************************************/ ****************************************************************************/
extern struct acpi_fixed_event_info
acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS];
ACPI_EXTERN struct acpi_fixed_event_handler
acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS];
ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
ACPI_EXTERN struct acpi_gpe_block_info
*acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
#if (!ACPI_REDUCED_HARDWARE) #if (!ACPI_REDUCED_HARDWARE)
ACPI_EXTERN u8 acpi_gbl_all_gpes_initialized; ACPI_EXTERN u8 acpi_gbl_all_gpes_initialized;
ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
ACPI_EXTERN struct acpi_gpe_block_info
*acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
ACPI_EXTERN acpi_gbl_event_handler acpi_gbl_global_event_handler; ACPI_EXTERN acpi_gbl_event_handler acpi_gbl_global_event_handler;
ACPI_EXTERN void *acpi_gbl_global_event_handler_context; ACPI_EXTERN void *acpi_gbl_global_event_handler_context;
ACPI_EXTERN struct acpi_fixed_event_handler
acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS];
extern struct acpi_fixed_event_info
acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS];
#endif /* !ACPI_REDUCED_HARDWARE */ #endif /* !ACPI_REDUCED_HARDWARE */
...@@ -415,6 +415,8 @@ ACPI_EXTERN u8 acpi_gbl_db_output_flags; ...@@ -415,6 +415,8 @@ ACPI_EXTERN u8 acpi_gbl_db_output_flags;
ACPI_EXTERN u8 acpi_gbl_db_opt_disasm; ACPI_EXTERN u8 acpi_gbl_db_opt_disasm;
ACPI_EXTERN u8 acpi_gbl_db_opt_verbose; ACPI_EXTERN u8 acpi_gbl_db_opt_verbose;
ACPI_EXTERN struct acpi_external_list *acpi_gbl_external_list;
ACPI_EXTERN struct acpi_external_file *acpi_gbl_external_file_list;
#endif #endif
#ifdef ACPI_DEBUGGER #ifdef ACPI_DEBUGGER
...@@ -426,6 +428,7 @@ extern u8 acpi_gbl_db_terminate_threads; ...@@ -426,6 +428,7 @@ extern u8 acpi_gbl_db_terminate_threads;
ACPI_EXTERN u8 acpi_gbl_db_opt_tables; ACPI_EXTERN u8 acpi_gbl_db_opt_tables;
ACPI_EXTERN u8 acpi_gbl_db_opt_stats; ACPI_EXTERN u8 acpi_gbl_db_opt_stats;
ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods; ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods;
ACPI_EXTERN u8 acpi_gbl_db_opt_no_region_support;
ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS]; ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS];
ACPI_EXTERN acpi_object_type acpi_gbl_db_arg_types[ACPI_DEBUGGER_MAX_ARGS]; ACPI_EXTERN acpi_object_type acpi_gbl_db_arg_types[ACPI_DEBUGGER_MAX_ARGS];
......
...@@ -458,7 +458,7 @@ void acpi_ex_reacquire_interpreter(void); ...@@ -458,7 +458,7 @@ void acpi_ex_reacquire_interpreter(void);
void acpi_ex_relinquish_interpreter(void); void acpi_ex_relinquish_interpreter(void);
void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc); u8 acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc);
void acpi_ex_acquire_global_lock(u32 rule); void acpi_ex_acquire_global_lock(u32 rule);
......
...@@ -189,11 +189,10 @@ struct acpi_namespace_node { ...@@ -189,11 +189,10 @@ struct acpi_namespace_node {
#define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */ #define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */
#define ANOBJ_ALLOCATED_BUFFER 0x40 /* Method AML buffer is dynamic (install_method) */ #define ANOBJ_ALLOCATED_BUFFER 0x40 /* Method AML buffer is dynamic (install_method) */
#define ANOBJ_IS_EXTERNAL 0x08 /* i_aSL only: This object created via External() */ #define ANOBJ_IS_EXTERNAL 0x08 /* iASL only: This object created via External() */
#define ANOBJ_METHOD_NO_RETVAL 0x10 /* i_aSL only: Method has no return value */ #define ANOBJ_METHOD_NO_RETVAL 0x10 /* iASL only: Method has no return value */
#define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* i_aSL only: Method has at least one return value */ #define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* iASL only: Method has at least one return value */
#define ANOBJ_IS_BIT_OFFSET 0x40 /* i_aSL only: Reference is a bit offset */ #define ANOBJ_IS_REFERENCED 0x80 /* iASL only: Object was referenced */
#define ANOBJ_IS_REFERENCED 0x80 /* i_aSL only: Object was referenced */
/* Internal ACPI table management - master table list */ /* Internal ACPI table management - master table list */
...@@ -411,11 +410,10 @@ struct acpi_gpe_notify_info { ...@@ -411,11 +410,10 @@ struct acpi_gpe_notify_info {
struct acpi_gpe_notify_info *next; struct acpi_gpe_notify_info *next;
}; };
struct acpi_gpe_notify_object { /*
struct acpi_namespace_node *node; * GPE dispatch info. At any time, the GPE can have at most one type
struct acpi_gpe_notify_object *next; * of dispatch - Method, Handler, or Implicit Notify.
}; */
union acpi_gpe_dispatch_info { union acpi_gpe_dispatch_info {
struct acpi_namespace_node *method_node; /* Method node for this GPE level */ struct acpi_namespace_node *method_node; /* Method node for this GPE level */
struct acpi_gpe_handler_info *handler; /* Installed GPE handler */ struct acpi_gpe_handler_info *handler; /* Installed GPE handler */
...@@ -679,6 +677,8 @@ struct acpi_opcode_info { ...@@ -679,6 +677,8 @@ struct acpi_opcode_info {
u8 type; /* Opcode type */ u8 type; /* Opcode type */
}; };
/* Value associated with the parse object */
union acpi_parse_value { union acpi_parse_value {
u64 integer; /* Integer constant (Up to 64 bits) */ u64 integer; /* Integer constant (Up to 64 bits) */
u32 size; /* bytelist or field size */ u32 size; /* bytelist or field size */
...@@ -1023,6 +1023,31 @@ struct acpi_port_info { ...@@ -1023,6 +1023,31 @@ struct acpi_port_info {
#define ACPI_ASCII_ZERO 0x30 #define ACPI_ASCII_ZERO 0x30
/*****************************************************************************
*
* Disassembler
*
****************************************************************************/
struct acpi_external_list {
char *path;
char *internal_path;
struct acpi_external_list *next;
u32 value;
u16 length;
u8 type;
u8 flags;
};
/* Values for Flags field above */
#define ACPI_IPATH_ALLOCATED 0x01
struct acpi_external_file {
char *path;
struct acpi_external_file *next;
};
/***************************************************************************** /*****************************************************************************
* *
* Debugger * Debugger
......
...@@ -49,14 +49,18 @@ ...@@ -49,14 +49,18 @@
* get into potential aligment issues -- see the STORE macros below. * get into potential aligment issues -- see the STORE macros below.
* Use with care. * Use with care.
*/ */
#define ACPI_GET8(ptr) *ACPI_CAST_PTR (u8, ptr) #define ACPI_CAST8(ptr) ACPI_CAST_PTR (u8, (ptr))
#define ACPI_GET16(ptr) *ACPI_CAST_PTR (u16, ptr) #define ACPI_CAST16(ptr) ACPI_CAST_PTR (u16, (ptr))
#define ACPI_GET32(ptr) *ACPI_CAST_PTR (u32, ptr) #define ACPI_CAST32(ptr) ACPI_CAST_PTR (u32, (ptr))
#define ACPI_GET64(ptr) *ACPI_CAST_PTR (u64, ptr) #define ACPI_CAST64(ptr) ACPI_CAST_PTR (u64, (ptr))
#define ACPI_SET8(ptr) *ACPI_CAST_PTR (u8, ptr) #define ACPI_GET8(ptr) (*ACPI_CAST8 (ptr))
#define ACPI_SET16(ptr) *ACPI_CAST_PTR (u16, ptr) #define ACPI_GET16(ptr) (*ACPI_CAST16 (ptr))
#define ACPI_SET32(ptr) *ACPI_CAST_PTR (u32, ptr) #define ACPI_GET32(ptr) (*ACPI_CAST32 (ptr))
#define ACPI_SET64(ptr) *ACPI_CAST_PTR (u64, ptr) #define ACPI_GET64(ptr) (*ACPI_CAST64 (ptr))
#define ACPI_SET8(ptr, val) (*ACPI_CAST8 (ptr) = (u8) (val))
#define ACPI_SET16(ptr, val) (*ACPI_CAST16 (ptr) = (u16) (val))
#define ACPI_SET32(ptr, val) (*ACPI_CAST32 (ptr) = (u32) (val))
#define ACPI_SET64(ptr, val) (*ACPI_CAST64 (ptr) = (u64) (val))
/* /*
* printf() format helpers * printf() format helpers
...@@ -293,6 +297,26 @@ ...@@ -293,6 +297,26 @@
#define ACPI_16BIT_MASK 0x0000FFFF #define ACPI_16BIT_MASK 0x0000FFFF
#define ACPI_24BIT_MASK 0x00FFFFFF #define ACPI_24BIT_MASK 0x00FFFFFF
/* Macros to extract flag bits from position zero */
#define ACPI_GET_1BIT_FLAG(value) ((value) & ACPI_1BIT_MASK)
#define ACPI_GET_2BIT_FLAG(value) ((value) & ACPI_2BIT_MASK)
#define ACPI_GET_3BIT_FLAG(value) ((value) & ACPI_3BIT_MASK)
#define ACPI_GET_4BIT_FLAG(value) ((value) & ACPI_4BIT_MASK)
/* Macros to extract flag bits from position one and above */
#define ACPI_EXTRACT_1BIT_FLAG(field, position) (ACPI_GET_1BIT_FLAG ((field) >> position))
#define ACPI_EXTRACT_2BIT_FLAG(field, position) (ACPI_GET_2BIT_FLAG ((field) >> position))
#define ACPI_EXTRACT_3BIT_FLAG(field, position) (ACPI_GET_3BIT_FLAG ((field) >> position))
#define ACPI_EXTRACT_4BIT_FLAG(field, position) (ACPI_GET_4BIT_FLAG ((field) >> position))
/* ACPI Pathname helpers */
#define ACPI_IS_ROOT_PREFIX(c) ((c) == (u8) 0x5C) /* Backslash */
#define ACPI_IS_PARENT_PREFIX(c) ((c) == (u8) 0x5E) /* Carat */
#define ACPI_IS_PATH_SEPARATOR(c) ((c) == (u8) 0x2E) /* Period (dot) */
/* /*
* An object of type struct acpi_namespace_node can appear in some contexts * An object of type struct acpi_namespace_node can appear in some contexts
* where a pointer to an object of type union acpi_operand_object can also * where a pointer to an object of type union acpi_operand_object can also
...@@ -364,137 +388,6 @@ ...@@ -364,137 +388,6 @@
#endif /* ACPI_NO_ERROR_MESSAGES */ #endif /* ACPI_NO_ERROR_MESSAGES */
/*
* Debug macros that are conditionally compiled
*/
#ifdef ACPI_DEBUG_OUTPUT
/*
* Function entry tracing
*/
#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \
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) \
acpi_ut_trace_u32(ACPI_DEBUG_PARAMETERS, (u32)b)
#define ACPI_FUNCTION_TRACE_STR(a, b) ACPI_FUNCTION_NAME(a) \
acpi_ut_trace_str(ACPI_DEBUG_PARAMETERS, (char *)b)
#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr()
/*
* Function exit tracing.
* WARNING: These macros include a return statement. This is usually considered
* 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 "_AcpiFunctionName" 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)
#else
#define ACPI_DO_WHILE0(a) a
#endif
#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 u64 _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, (u64) _s); \
return (_s); })
#define return_UINT32(s) ACPI_DO_WHILE0 ({ \
register u32 _s = (u32) (s); \
acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) _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, (u64) (s)); \
return((s)); })
#define return_UINT8(s) return_VALUE(s)
#define return_UINT32(s) return_VALUE(s)
#endif /* ACPI_SIMPLE_RETURN_MACROS */
/* Conditional execution */
#define ACPI_DEBUG_EXEC(a) a
#define ACPI_DEBUG_ONLY_MEMBERS(a) a;
#define _VERBOSE_STRUCTURES
/* Various object display routines for debug */
#define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a), 0)
#define ACPI_DUMP_OPERANDS(a, b ,c) acpi_ex_dump_operands(a, b, c)
#define ACPI_DUMP_ENTRY(a, b) acpi_ns_dump_entry (a, b)
#define ACPI_DUMP_PATHNAME(a, b, c, d) acpi_ns_dump_pathname(a, b, c, d)
#define ACPI_DUMP_BUFFER(a, b) acpi_ut_debug_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT)
#else
/*
* This is the non-debug case -- make everything go away,
* leaving no executable debug code!
*/
#define ACPI_DEBUG_EXEC(a)
#define ACPI_DEBUG_ONLY_MEMBERS(a)
#define ACPI_FUNCTION_TRACE(a)
#define ACPI_FUNCTION_TRACE_PTR(a, b)
#define ACPI_FUNCTION_TRACE_U32(a, b)
#define ACPI_FUNCTION_TRACE_STR(a, b)
#define ACPI_FUNCTION_EXIT
#define ACPI_FUNCTION_STATUS_EXIT(s)
#define ACPI_FUNCTION_VALUE_EXIT(s)
#define ACPI_FUNCTION_ENTRY()
#define ACPI_DUMP_STACK_ENTRY(a)
#define ACPI_DUMP_OPERANDS(a, b, c)
#define ACPI_DUMP_ENTRY(a, b)
#define ACPI_DUMP_TABLES(a, b)
#define ACPI_DUMP_PATHNAME(a, b, c, d)
#define ACPI_DUMP_BUFFER(a, b)
#define ACPI_DEBUG_PRINT(pl)
#define ACPI_DEBUG_PRINT_RAW(pl)
#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 /* ACPI_DEBUG_OUTPUT */
#if (!ACPI_REDUCED_HARDWARE) #if (!ACPI_REDUCED_HARDWARE)
#define ACPI_HW_OPTIONAL_FUNCTION(addr) addr #define ACPI_HW_OPTIONAL_FUNCTION(addr) addr
#else #else
......
...@@ -218,6 +218,18 @@ acpi_ns_check_parameter_count(char *pathname, ...@@ -218,6 +218,18 @@ acpi_ns_check_parameter_count(char *pathname,
u32 user_param_count, u32 user_param_count,
const union acpi_predefined_info *info); const union acpi_predefined_info *info);
acpi_status
acpi_ns_check_object_type(struct acpi_predefined_data *data,
union acpi_operand_object **return_object_ptr,
u32 expected_btypes, u32 package_index);
/*
* nsprepkg - Validation of predefined name packages
*/
acpi_status
acpi_ns_check_package(struct acpi_predefined_data *data,
union acpi_operand_object **return_object_ptr);
/* /*
* nsnames - Name and Scope manipulation * nsnames - Name and Scope manipulation
*/ */
...@@ -333,8 +345,6 @@ acpi_ns_install_node(struct acpi_walk_state *walk_state, ...@@ -333,8 +345,6 @@ acpi_ns_install_node(struct acpi_walk_state *walk_state,
/* /*
* nsutils - Utility functions * nsutils - Utility functions
*/ */
u8 acpi_ns_valid_root_prefix(char prefix);
acpi_object_type acpi_ns_get_type(struct acpi_namespace_node *node); acpi_object_type acpi_ns_get_type(struct acpi_namespace_node *node);
u32 acpi_ns_local(acpi_object_type type); u32 acpi_ns_local(acpi_object_type type);
......
...@@ -307,7 +307,7 @@ struct acpi_object_addr_handler { ...@@ -307,7 +307,7 @@ struct acpi_object_addr_handler {
struct acpi_namespace_node *node; /* Parent device */ struct acpi_namespace_node *node; /* Parent device */
void *context; void *context;
acpi_adr_space_setup setup; acpi_adr_space_setup setup;
union acpi_operand_object *region_list; /* regions using this handler */ union acpi_operand_object *region_list; /* Regions using this handler */
union acpi_operand_object *next; union acpi_operand_object *next;
}; };
......
...@@ -105,7 +105,28 @@ union acpi_parse_object *acpi_ps_find_name(union acpi_parse_object *scope, ...@@ -105,7 +105,28 @@ union acpi_parse_object *acpi_ps_find_name(union acpi_parse_object *scope,
union acpi_parse_object *acpi_ps_get_parent(union acpi_parse_object *op); union acpi_parse_object *acpi_ps_get_parent(union acpi_parse_object *op);
/* /*
* psopcode - AML Opcode information * psobject - support for parse object processing
*/
acpi_status
acpi_ps_build_named_op(struct acpi_walk_state *walk_state,
u8 *aml_op_start,
union acpi_parse_object *unnamed_op,
union acpi_parse_object **op);
acpi_status
acpi_ps_create_op(struct acpi_walk_state *walk_state,
u8 *aml_op_start, union acpi_parse_object **new_op);
acpi_status
acpi_ps_complete_op(struct acpi_walk_state *walk_state,
union acpi_parse_object **op, acpi_status status);
acpi_status
acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
union acpi_parse_object *op, acpi_status status);
/*
* psopinfo - AML Opcode information
*/ */
const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode); const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode);
...@@ -211,8 +232,6 @@ void acpi_ps_free_op(union acpi_parse_object *op); ...@@ -211,8 +232,6 @@ void acpi_ps_free_op(union acpi_parse_object *op);
u8 acpi_ps_is_leading_char(u32 c); u8 acpi_ps_is_leading_char(u32 c);
u8 acpi_ps_is_prefix_char(u32 c);
#ifdef ACPI_FUTURE_USAGE #ifdef ACPI_FUTURE_USAGE
u32 acpi_ps_get_name(union acpi_parse_object *op); u32 acpi_ps_get_name(union acpi_parse_object *op);
#endif /* ACPI_FUTURE_USAGE */ #endif /* ACPI_FUTURE_USAGE */
......
/****************************************************************************** /******************************************************************************
* *
* Name: acpredef - Information table for ACPI predefined methods and objects * Name: acpredef - Information table for ACPI predefined methods and objects
* $Revision: 1.1 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -51,13 +50,13 @@ ...@@ -51,13 +50,13 @@
* *
* 1) PTYPE1 packages do not contain sub-packages. * 1) PTYPE1 packages do not contain sub-packages.
* *
* ACPI_PTYPE1_FIXED: Fixed length, 1 or 2 object types: * ACPI_PTYPE1_FIXED: Fixed-length length, 1 or 2 object types:
* object type * object type
* count * count
* object type * object type
* count * count
* *
* ACPI_PTYPE1_VAR: Variable length: * ACPI_PTYPE1_VAR: Variable-length length:
* object type (Int/Buf/Ref) * object type (Int/Buf/Ref)
* *
* ACPI_PTYPE1_OPTION: Package has some required and some optional elements * ACPI_PTYPE1_OPTION: Package has some required and some optional elements
...@@ -85,10 +84,10 @@ ...@@ -85,10 +84,10 @@
* count * count
* (Used for _CST) * (Used for _CST)
* *
* ACPI_PTYPE2_FIXED: Each subpackage is of fixed length * ACPI_PTYPE2_FIXED: Each subpackage is of Fixed-length
* (Used for _PRT) * (Used for _PRT)
* *
* ACPI_PTYPE2_MIN: Each subpackage has a variable but minimum length * ACPI_PTYPE2_MIN: Each subpackage has a Variable-length but minimum length
* (Used for _HPX) * (Used for _HPX)
* *
* ACPI_PTYPE2_REV_FIXED: Revision at start, each subpackage is Fixed-length * ACPI_PTYPE2_REV_FIXED: Revision at start, each subpackage is Fixed-length
...@@ -124,7 +123,8 @@ enum acpi_return_package_types { ...@@ -124,7 +123,8 @@ enum acpi_return_package_types {
* These are the names that can actually be evaluated via acpi_evaluate_object. * These are the names that can actually be evaluated via acpi_evaluate_object.
* Not present in this table are the following: * Not present in this table are the following:
* *
* 1) Predefined/Reserved names that are never evaluated via acpi_evaluate_object: * 1) Predefined/Reserved names that are never evaluated via
* acpi_evaluate_object:
* _Lxx and _Exx GPE methods * _Lxx and _Exx GPE methods
* _Qxx EC methods * _Qxx EC methods
* _T_x compiler temporary variables * _T_x compiler temporary variables
...@@ -149,6 +149,8 @@ enum acpi_return_package_types { ...@@ -149,6 +149,8 @@ enum acpi_return_package_types {
* information about the expected structure of the package. This information * information about the expected structure of the package. This information
* is saved here (rather than in a separate table) in order to minimize the * is saved here (rather than in a separate table) in order to minimize the
* overall size of the stored data. * overall size of the stored data.
*
* Note: The additional braces are intended to promote portability.
*/ */
static const union acpi_predefined_info predefined_names[] = { static const union acpi_predefined_info predefined_names[] = {
{{"_AC0", 0, ACPI_RTYPE_INTEGER}}, {{"_AC0", 0, ACPI_RTYPE_INTEGER}},
......
...@@ -347,18 +347,21 @@ extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[]; ...@@ -347,18 +347,21 @@ extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[];
extern struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[]; extern struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[];
/* /*
* rsdump * rsdumpinfo
*/ */
extern struct acpi_rsdump_info acpi_rs_dump_irq[]; extern struct acpi_rsdump_info acpi_rs_dump_irq[];
extern struct acpi_rsdump_info acpi_rs_dump_prt[];
extern struct acpi_rsdump_info acpi_rs_dump_dma[]; 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_start_dpf[];
extern struct acpi_rsdump_info acpi_rs_dump_end_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_io[];
extern struct acpi_rsdump_info acpi_rs_dump_io_flags[];
extern struct acpi_rsdump_info acpi_rs_dump_fixed_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_vendor[];
extern struct acpi_rsdump_info acpi_rs_dump_end_tag[]; 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_memory24[];
extern struct acpi_rsdump_info acpi_rs_dump_memory32[]; extern struct acpi_rsdump_info acpi_rs_dump_memory32[];
extern struct acpi_rsdump_info acpi_rs_dump_memory_flags[];
extern struct acpi_rsdump_info acpi_rs_dump_fixed_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_address16[];
extern struct acpi_rsdump_info acpi_rs_dump_address32[]; extern struct acpi_rsdump_info acpi_rs_dump_address32[];
...@@ -372,6 +375,7 @@ extern struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[]; ...@@ -372,6 +375,7 @@ extern struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[];
extern struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[]; extern struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[];
extern struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[]; extern struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[];
extern struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[]; extern struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[];
extern struct acpi_rsdump_info acpi_rs_dump_general_flags[];
#endif #endif
#endif /* __ACRESRC_H__ */ #endif /* __ACRESRC_H__ */
...@@ -483,39 +483,17 @@ acpi_ut_short_divide(u64 in_dividend, ...@@ -483,39 +483,17 @@ acpi_ut_short_divide(u64 in_dividend,
/* /*
* utmisc * utmisc
*/ */
void ut_convert_backslashes(char *pathname);
const char *acpi_ut_validate_exception(acpi_status status); const char *acpi_ut_validate_exception(acpi_status status);
u8 acpi_ut_is_pci_root_bridge(char *id); u8 acpi_ut_is_pci_root_bridge(char *id);
u8 acpi_ut_is_aml_table(struct acpi_table_header *table); u8 acpi_ut_is_aml_table(struct acpi_table_header *table);
acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id);
void acpi_ut_release_owner_id(acpi_owner_id * owner_id);
acpi_status acpi_status
acpi_ut_walk_package_tree(union acpi_operand_object *source_object, acpi_ut_walk_package_tree(union acpi_operand_object *source_object,
void *target_object, void *target_object,
acpi_pkg_callback walk_callback, void *context); acpi_pkg_callback walk_callback, void *context);
void acpi_ut_strupr(char *src_string);
void acpi_ut_strlwr(char *src_string);
int acpi_ut_stricmp(char *string1, char *string2);
void acpi_ut_print_string(char *string, u8 max_length);
u8 acpi_ut_valid_acpi_name(u32 name);
void acpi_ut_repair_name(char *name);
u8 acpi_ut_valid_acpi_char(char character, u32 position);
acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer);
/* Values for Base above (16=Hex, 10=Decimal) */ /* Values for Base above (16=Hex, 10=Decimal) */
#define ACPI_ANY_BASE 0 #define ACPI_ANY_BASE 0
...@@ -531,16 +509,26 @@ acpi_ut_display_init_pathname(u8 type, ...@@ -531,16 +509,26 @@ acpi_ut_display_init_pathname(u8 type,
char *path); char *path);
#endif #endif
/*
* utownerid - Support for Table/Method Owner IDs
*/
acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id);
void acpi_ut_release_owner_id(acpi_owner_id * owner_id);
/* /*
* utresrc * utresrc
*/ */
acpi_status acpi_status
acpi_ut_walk_aml_resources(u8 *aml, acpi_ut_walk_aml_resources(struct acpi_walk_state *walk_state,
u8 *aml,
acpi_size aml_length, acpi_size aml_length,
acpi_walk_aml_callback user_function, acpi_walk_aml_callback user_function,
void **context); void **context);
acpi_status acpi_ut_validate_resource(void *aml, u8 *return_index); acpi_status
acpi_ut_validate_resource(struct acpi_walk_state *walk_state,
void *aml, u8 *return_index);
u32 acpi_ut_get_descriptor_length(void *aml); u32 acpi_ut_get_descriptor_length(void *aml);
...@@ -553,6 +541,27 @@ u8 acpi_ut_get_resource_type(void *aml); ...@@ -553,6 +541,27 @@ u8 acpi_ut_get_resource_type(void *aml);
acpi_status acpi_status
acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, u8 **end_tag); acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, u8 **end_tag);
/*
* utstring - String and character utilities
*/
void acpi_ut_strupr(char *src_string);
void acpi_ut_strlwr(char *src_string);
int acpi_ut_stricmp(char *string1, char *string2);
acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer);
void acpi_ut_print_string(char *string, u8 max_length);
void ut_convert_backslashes(char *pathname);
u8 acpi_ut_valid_acpi_name(u32 name);
u8 acpi_ut_valid_acpi_char(char character, u32 position);
void acpi_ut_repair_name(char *name);
/* /*
* utmutex - mutex support * utmutex - mutex support
*/ */
......
...@@ -199,6 +199,12 @@ struct aml_resource_fixed_dma { ...@@ -199,6 +199,12 @@ struct aml_resource_fixed_dma {
struct aml_resource_large_header { struct aml_resource_large_header {
AML_RESOURCE_LARGE_HEADER_COMMON}; AML_RESOURCE_LARGE_HEADER_COMMON};
/* General Flags for address space resource descriptors */
#define ACPI_RESOURCE_FLAG_DEC 2
#define ACPI_RESOURCE_FLAG_MIF 4
#define ACPI_RESOURCE_FLAG_MAF 8
struct aml_resource_memory24 { struct aml_resource_memory24 {
AML_RESOURCE_LARGE_HEADER_COMMON u8 flags; AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
u16 minimum; u16 minimum;
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#include "acinterp.h" #include "acinterp.h"
#include "acnamesp.h" #include "acnamesp.h"
#ifdef ACPI_DISASSEMBLER #ifdef ACPI_DISASSEMBLER
#include <acpi/acdisasm.h> #include "acdisasm.h"
#endif #endif
#define _COMPONENT ACPI_DISPATCHER #define _COMPONENT ACPI_DISPATCHER
...@@ -151,6 +151,7 @@ acpi_ds_create_method_mutex(union acpi_operand_object *method_desc) ...@@ -151,6 +151,7 @@ acpi_ds_create_method_mutex(union acpi_operand_object *method_desc)
status = acpi_os_create_mutex(&mutex_desc->mutex.os_mutex); status = acpi_os_create_mutex(&mutex_desc->mutex.os_mutex);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
acpi_ut_delete_object_desc(mutex_desc);
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }
...@@ -378,7 +379,8 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread, ...@@ -378,7 +379,8 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
*/ */
info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
if (!info) { if (!info) {
return_ACPI_STATUS(AE_NO_MEMORY); status = AE_NO_MEMORY;
goto cleanup;
} }
info->parameters = &this_walk_state->operands[0]; info->parameters = &this_walk_state->operands[0];
......
...@@ -388,7 +388,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, ...@@ -388,7 +388,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
union acpi_parse_object *parent; union acpi_parse_object *parent;
union acpi_operand_object *obj_desc = NULL; union acpi_operand_object *obj_desc = NULL;
acpi_status status = AE_OK; acpi_status status = AE_OK;
unsigned i; u32 i;
u16 index; u16 index;
u16 reference_count; u16 reference_count;
...@@ -703,7 +703,7 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, ...@@ -703,7 +703,7 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
/* Truncate value if we are executing from a 32-bit ACPI table */ /* Truncate value if we are executing from a 32-bit ACPI table */
#ifndef ACPI_NO_METHOD_EXECUTION #ifndef ACPI_NO_METHOD_EXECUTION
acpi_ex_truncate_for32bit_table(obj_desc); (void)acpi_ex_truncate_for32bit_table(obj_desc);
#endif #endif
break; break;
...@@ -725,8 +725,18 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, ...@@ -725,8 +725,18 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
case AML_TYPE_LITERAL: case AML_TYPE_LITERAL:
obj_desc->integer.value = op->common.value.integer; obj_desc->integer.value = op->common.value.integer;
#ifndef ACPI_NO_METHOD_EXECUTION #ifndef ACPI_NO_METHOD_EXECUTION
acpi_ex_truncate_for32bit_table(obj_desc); if (acpi_ex_truncate_for32bit_table(obj_desc)) {
/* Warn if we found a 64-bit constant in a 32-bit table */
ACPI_WARNING((AE_INFO,
"Truncated 64-bit constant found in 32-bit table: %8.8X%8.8X => %8.8X",
ACPI_FORMAT_UINT64(op->common.
value.integer),
(u32)obj_desc->integer.value));
}
#endif #endif
break; break;
......
...@@ -486,18 +486,18 @@ acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state, ...@@ -486,18 +486,18 @@ acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
ACPI_FUNCTION_TRACE_PTR(ds_eval_table_region_operands, op); ACPI_FUNCTION_TRACE_PTR(ds_eval_table_region_operands, op);
/* /*
* This is where we evaluate the signature_string and oem_iDString * This is where we evaluate the Signature string, oem_id string,
* and oem_table_iDString of the data_table_region declaration * and oem_table_id string of the Data Table Region declaration
*/ */
node = op->common.node; node = op->common.node;
/* next_op points to signature_string op */ /* next_op points to Signature string op */
next_op = op->common.value.arg; next_op = op->common.value.arg;
/* /*
* Evaluate/create the signature_string and oem_iDString * Evaluate/create the Signature string, oem_id string,
* and oem_table_iDString operands * and oem_table_id string operands
*/ */
status = acpi_ds_create_operands(walk_state, next_op); status = acpi_ds_create_operands(walk_state, next_op);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
...@@ -505,8 +505,8 @@ acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state, ...@@ -505,8 +505,8 @@ acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
} }
/* /*
* Resolve the signature_string and oem_iDString * Resolve the Signature string, oem_id string,
* and oem_table_iDString operands * and oem_table_id string operands
*/ */
status = acpi_ex_resolve_operands(op->common.aml_opcode, status = acpi_ex_resolve_operands(op->common.aml_opcode,
ACPI_WALK_OPERANDS, walk_state); ACPI_WALK_OPERANDS, walk_state);
......
...@@ -178,7 +178,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, ...@@ -178,7 +178,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
if (!op) { if (!op) {
ACPI_ERROR((AE_INFO, "Null Op")); ACPI_ERROR((AE_INFO, "Null Op"));
return_UINT8(TRUE); return_VALUE(TRUE);
} }
/* /*
...@@ -210,7 +210,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, ...@@ -210,7 +210,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
"At Method level, result of [%s] not used\n", "At Method level, result of [%s] not used\n",
acpi_ps_get_opcode_name(op->common. acpi_ps_get_opcode_name(op->common.
aml_opcode))); aml_opcode)));
return_UINT8(FALSE); return_VALUE(FALSE);
} }
/* Get info on the parent. The root_op is AML_SCOPE */ /* Get info on the parent. The root_op is AML_SCOPE */
...@@ -219,7 +219,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, ...@@ -219,7 +219,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode); acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode);
if (parent_info->class == AML_CLASS_UNKNOWN) { if (parent_info->class == AML_CLASS_UNKNOWN) {
ACPI_ERROR((AE_INFO, "Unknown parent opcode Op=%p", op)); ACPI_ERROR((AE_INFO, "Unknown parent opcode Op=%p", op));
return_UINT8(FALSE); return_VALUE(FALSE);
} }
/* /*
...@@ -307,7 +307,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, ...@@ -307,7 +307,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
acpi_ps_get_opcode_name(op->common.parent->common. acpi_ps_get_opcode_name(op->common.parent->common.
aml_opcode), op)); aml_opcode), op));
return_UINT8(TRUE); return_VALUE(TRUE);
result_not_used: result_not_used:
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
...@@ -316,7 +316,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, ...@@ -316,7 +316,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
acpi_ps_get_opcode_name(op->common.parent->common. acpi_ps_get_opcode_name(op->common.parent->common.
aml_opcode), op)); aml_opcode), op));
return_UINT8(FALSE); return_VALUE(FALSE);
} }
/******************************************************************************* /*******************************************************************************
......
...@@ -149,7 +149,7 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state, ...@@ -149,7 +149,7 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
/* Truncate the predicate to 32-bits if necessary */ /* Truncate the predicate to 32-bits if necessary */
acpi_ex_truncate_for32bit_table(local_obj_desc); (void)acpi_ex_truncate_for32bit_table(local_obj_desc);
/* /*
* Save the result of the predicate evaluation on * Save the result of the predicate evaluation on
...@@ -706,7 +706,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) ...@@ -706,7 +706,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
* ACPI 2.0 support for 64-bit integers: Truncate numeric * ACPI 2.0 support for 64-bit integers: Truncate numeric
* result value if we are executing from a 32-bit ACPI table * result value if we are executing from a 32-bit ACPI table
*/ */
acpi_ex_truncate_for32bit_table(walk_state->result_obj); (void)acpi_ex_truncate_for32bit_table(walk_state->result_obj);
/* /*
* Check if we just completed the evaluation of a * Check if we just completed the evaluation of a
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#include "acnamesp.h" #include "acnamesp.h"
#ifdef ACPI_ASL_COMPILER #ifdef ACPI_ASL_COMPILER
#include <acpi/acdisasm.h> #include "acdisasm.h"
#endif #endif
#define _COMPONENT ACPI_DISPATCHER #define _COMPONENT ACPI_DISPATCHER
...@@ -178,7 +178,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, ...@@ -178,7 +178,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
* Target of Scope() not found. Generate an External for it, and * Target of Scope() not found. Generate an External for it, and
* insert the name into the namespace. * insert the name into the namespace.
*/ */
acpi_dm_add_to_external_list(path, ACPI_TYPE_DEVICE, 0); acpi_dm_add_to_external_list(op, path, ACPI_TYPE_DEVICE,
0);
status = status =
acpi_ns_lookup(walk_state->scope_info, path, acpi_ns_lookup(walk_state->scope_info, path,
object_type, ACPI_IMODE_LOAD_PASS1, object_type, ACPI_IMODE_LOAD_PASS1,
......
...@@ -561,8 +561,8 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context) ...@@ -561,8 +561,8 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
status = AE_NO_MEMORY; status = AE_NO_MEMORY;
} else { } else {
/* /*
* Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the
* control method that corresponds to this GPE * _Lxx/_Exx control method that corresponds to this GPE
*/ */
info->prefix_node = info->prefix_node =
local_gpe_event_info->dispatch.method_node; local_gpe_event_info->dispatch.method_node;
...@@ -707,7 +707,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, ...@@ -707,7 +707,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, ACPI_EXCEPTION((AE_INFO, status,
"Unable to clear GPE%02X", gpe_number)); "Unable to clear GPE%02X", gpe_number));
return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
} }
} }
...@@ -724,7 +724,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, ...@@ -724,7 +724,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, ACPI_EXCEPTION((AE_INFO, status,
"Unable to disable GPE%02X", gpe_number)); "Unable to disable GPE%02X", gpe_number));
return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
} }
/* /*
...@@ -765,7 +765,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, ...@@ -765,7 +765,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
gpe_event_info); gpe_event_info);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, ACPI_EXCEPTION((AE_INFO, status,
"Unable to queue handler for GPE%2X - event disabled", "Unable to queue handler for GPE%02X - event disabled",
gpe_number)); gpe_number));
} }
break; break;
...@@ -784,7 +784,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, ...@@ -784,7 +784,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
break; break;
} }
return_UINT32(ACPI_INTERRUPT_HANDLED); return_VALUE(ACPI_INTERRUPT_HANDLED);
} }
#endif /* !ACPI_REDUCED_HARDWARE */ #endif /* !ACPI_REDUCED_HARDWARE */
...@@ -405,13 +405,13 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, ...@@ -405,13 +405,13 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
(*return_gpe_block) = gpe_block; (*return_gpe_block) = gpe_block;
} }
ACPI_DEBUG_PRINT((ACPI_DB_INIT, ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
"GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", " Initialized GPE %02X to %02X [%4.4s] %u regs on interrupt 0x%X\n",
(u32) gpe_block->block_base_number, (u32)gpe_block->block_base_number,
(u32) (gpe_block->block_base_number + (u32)(gpe_block->block_base_number +
(gpe_block->gpe_count - 1)), (gpe_block->gpe_count - 1)),
gpe_device->name.ascii, gpe_block->register_count, gpe_device->name.ascii, gpe_block->register_count,
interrupt_number)); interrupt_number));
/* Update global count of currently available GPEs */ /* Update global count of currently available GPEs */
...@@ -496,9 +496,11 @@ acpi_ev_initialize_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, ...@@ -496,9 +496,11 @@ acpi_ev_initialize_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
} }
if (gpe_enabled_count) { if (gpe_enabled_count) {
ACPI_DEBUG_PRINT((ACPI_DB_INIT, ACPI_INFO((AE_INFO,
"Enabled %u GPEs in this block\n", "Enabled %u GPEs in block %02X to %02X",
gpe_enabled_count)); gpe_enabled_count, (u32)gpe_block->block_base_number,
(u32)(gpe_block->block_base_number +
(gpe_block->gpe_count - 1))));
} }
gpe_block->initialized = TRUE; gpe_block->initialized = TRUE;
......
...@@ -86,6 +86,9 @@ acpi_status acpi_ev_gpe_initialize(void) ...@@ -86,6 +86,9 @@ acpi_status acpi_ev_gpe_initialize(void)
ACPI_FUNCTION_TRACE(ev_gpe_initialize); ACPI_FUNCTION_TRACE(ev_gpe_initialize);
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
"Initializing General Purpose Events (GPEs):\n"));
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
......
/******************************************************************************
*
* Module Name: evhandler - Support for Address Space handlers
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2012, Intel Corp.
* 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 <acpi/acpi.h>
#include "accommon.h"
#include "acevents.h"
#include "acnamesp.h"
#include "acinterp.h"
#define _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME("evhandler")
/* Local prototypes */
static acpi_status
acpi_ev_install_handler(acpi_handle obj_handle,
u32 level, void *context, void **return_value);
/* These are the address spaces that will get default handlers */
u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
ACPI_ADR_SPACE_SYSTEM_MEMORY,
ACPI_ADR_SPACE_SYSTEM_IO,
ACPI_ADR_SPACE_PCI_CONFIG,
ACPI_ADR_SPACE_DATA_TABLE
};
/*******************************************************************************
*
* FUNCTION: acpi_ev_install_region_handlers
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Installs the core subsystem default address space handlers.
*
******************************************************************************/
acpi_status acpi_ev_install_region_handlers(void)
{
acpi_status status;
u32 i;
ACPI_FUNCTION_TRACE(ev_install_region_handlers);
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/*
* All address spaces (PCI Config, EC, SMBus) are scope dependent and
* registration must occur for a specific device.
*
* In the case of the system memory and IO address spaces there is
* currently no device associated with the address space. For these we
* use the root.
*
* We install the default PCI config space handler at the root so that
* this space is immediately available even though the we have not
* enumerated all the PCI Root Buses yet. This is to conform to the ACPI
* specification which states that the PCI config space must be always
* available -- even though we are nowhere near ready to find the PCI root
* buses at this point.
*
* NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler
* has already been installed (via acpi_install_address_space_handler).
* Similar for AE_SAME_HANDLER.
*/
for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
status = acpi_ev_install_space_handler(acpi_gbl_root_node,
acpi_gbl_default_address_spaces
[i],
ACPI_DEFAULT_HANDLER,
NULL, NULL);
switch (status) {
case AE_OK:
case AE_SAME_HANDLER:
case AE_ALREADY_EXISTS:
/* These exceptions are all OK */
status = AE_OK;
break;
default:
goto unlock_and_exit;
}
}
unlock_and_exit:
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_has_default_handler
*
* PARAMETERS: node - Namespace node for the device
* space_id - The address space ID
*
* RETURN: TRUE if default handler is installed, FALSE otherwise
*
* DESCRIPTION: Check if the default handler is installed for the requested
* space ID.
*
******************************************************************************/
u8
acpi_ev_has_default_handler(struct acpi_namespace_node *node,
acpi_adr_space_type space_id)
{
union acpi_operand_object *obj_desc;
union acpi_operand_object *handler_obj;
/* Must have an existing internal object */
obj_desc = acpi_ns_get_attached_object(node);
if (obj_desc) {
handler_obj = obj_desc->device.handler;
/* Walk the linked list of handlers for this object */
while (handler_obj) {
if (handler_obj->address_space.space_id == space_id) {
if (handler_obj->address_space.handler_flags &
ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) {
return (TRUE);
}
}
handler_obj = handler_obj->address_space.next;
}
}
return (FALSE);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_install_handler
*
* PARAMETERS: walk_namespace callback
*
* DESCRIPTION: This routine installs an address handler into objects that are
* of type Region or Device.
*
* If the Object is a Device, and the device has a handler of
* the same type then the search is terminated in that branch.
*
* This is because the existing handler is closer in proximity
* to any more regions than the one we are trying to install.
*
******************************************************************************/
static acpi_status
acpi_ev_install_handler(acpi_handle obj_handle,
u32 level, void *context, void **return_value)
{
union acpi_operand_object *handler_obj;
union acpi_operand_object *next_handler_obj;
union acpi_operand_object *obj_desc;
struct acpi_namespace_node *node;
acpi_status status;
ACPI_FUNCTION_NAME(ev_install_handler);
handler_obj = (union acpi_operand_object *)context;
/* Parameter validation */
if (!handler_obj) {
return (AE_OK);
}
/* Convert and validate the device handle */
node = acpi_ns_validate_handle(obj_handle);
if (!node) {
return (AE_BAD_PARAMETER);
}
/*
* We only care about regions and objects that are allowed to have
* address space handlers
*/
if ((node->type != ACPI_TYPE_DEVICE) &&
(node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
return (AE_OK);
}
/* Check for an existing internal object */
obj_desc = acpi_ns_get_attached_object(node);
if (!obj_desc) {
/* No object, just exit */
return (AE_OK);
}
/* Devices are handled different than regions */
if (obj_desc->common.type == ACPI_TYPE_DEVICE) {
/* Check if this Device already has a handler for this address space */
next_handler_obj = obj_desc->device.handler;
while (next_handler_obj) {
/* Found a handler, is it for the same address space? */
if (next_handler_obj->address_space.space_id ==
handler_obj->address_space.space_id) {
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
"Found handler for region [%s] in device %p(%p) "
"handler %p\n",
acpi_ut_get_region_name
(handler_obj->address_space.
space_id), obj_desc,
next_handler_obj,
handler_obj));
/*
* Since the object we found it on was a device, then it
* means that someone has already installed a handler for
* the branch of the namespace from this device on. Just
* bail out telling the walk routine to not traverse this
* branch. This preserves the scoping rule for handlers.
*/
return (AE_CTRL_DEPTH);
}
/* Walk the linked list of handlers attached to this device */
next_handler_obj = next_handler_obj->address_space.next;
}
/*
* As long as the device didn't have a handler for this space we
* don't care about it. We just ignore it and proceed.
*/
return (AE_OK);
}
/* Object is a Region */
if (obj_desc->region.space_id != handler_obj->address_space.space_id) {
/* This region is for a different address space, just ignore it */
return (AE_OK);
}
/*
* Now we have a region and it is for the handler's address space type.
*
* First disconnect region for any previous handler (if any)
*/
acpi_ev_detach_region(obj_desc, FALSE);
/* Connect the region to the new handler */
status = acpi_ev_attach_region(handler_obj, obj_desc, FALSE);
return (status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_install_space_handler
*
* PARAMETERS: node - Namespace node for the device
* space_id - The address space ID
* handler - Address of the handler
* setup - Address of the setup function
* context - Value passed to the handler on each access
*
* RETURN: Status
*
* DESCRIPTION: Install a handler for all op_regions of a given space_id.
* Assumes namespace is locked
*
******************************************************************************/
acpi_status
acpi_ev_install_space_handler(struct acpi_namespace_node * node,
acpi_adr_space_type space_id,
acpi_adr_space_handler handler,
acpi_adr_space_setup setup, void *context)
{
union acpi_operand_object *obj_desc;
union acpi_operand_object *handler_obj;
acpi_status status;
acpi_object_type type;
u8 flags = 0;
ACPI_FUNCTION_TRACE(ev_install_space_handler);
/*
* This registration is valid for only the types below and the root. This
* is where the default handlers get placed.
*/
if ((node->type != ACPI_TYPE_DEVICE) &&
(node->type != ACPI_TYPE_PROCESSOR) &&
(node->type != ACPI_TYPE_THERMAL) && (node != acpi_gbl_root_node)) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
if (handler == ACPI_DEFAULT_HANDLER) {
flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED;
switch (space_id) {
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
handler = acpi_ex_system_memory_space_handler;
setup = acpi_ev_system_memory_region_setup;
break;
case ACPI_ADR_SPACE_SYSTEM_IO:
handler = acpi_ex_system_io_space_handler;
setup = acpi_ev_io_space_region_setup;
break;
case ACPI_ADR_SPACE_PCI_CONFIG:
handler = acpi_ex_pci_config_space_handler;
setup = acpi_ev_pci_config_region_setup;
break;
case ACPI_ADR_SPACE_CMOS:
handler = acpi_ex_cmos_space_handler;
setup = acpi_ev_cmos_region_setup;
break;
case ACPI_ADR_SPACE_PCI_BAR_TARGET:
handler = acpi_ex_pci_bar_space_handler;
setup = acpi_ev_pci_bar_region_setup;
break;
case ACPI_ADR_SPACE_DATA_TABLE:
handler = acpi_ex_data_table_space_handler;
setup = NULL;
break;
default:
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
}
/* If the caller hasn't specified a setup routine, use the default */
if (!setup) {
setup = acpi_ev_default_region_setup;
}
/* Check for an existing internal object */
obj_desc = acpi_ns_get_attached_object(node);
if (obj_desc) {
/*
* The attached device object already exists. Make sure the handler
* is not already installed.
*/
handler_obj = obj_desc->device.handler;
/* Walk the handler list for this device */
while (handler_obj) {
/* Same space_id indicates a handler already installed */
if (handler_obj->address_space.space_id == space_id) {
if (handler_obj->address_space.handler ==
handler) {
/*
* It is (relatively) OK to attempt to install the SAME
* handler twice. This can easily happen with the
* PCI_Config space.
*/
status = AE_SAME_HANDLER;
goto unlock_and_exit;
} else {
/* A handler is already installed */
status = AE_ALREADY_EXISTS;
}
goto unlock_and_exit;
}
/* Walk the linked list of handlers */
handler_obj = handler_obj->address_space.next;
}
} else {
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
"Creating object on Device %p while installing handler\n",
node));
/* obj_desc does not exist, create one */
if (node->type == ACPI_TYPE_ANY) {
type = ACPI_TYPE_DEVICE;
} else {
type = node->type;
}
obj_desc = acpi_ut_create_internal_object(type);
if (!obj_desc) {
status = AE_NO_MEMORY;
goto unlock_and_exit;
}
/* Init new descriptor */
obj_desc->common.type = (u8)type;
/* Attach the new object to the Node */
status = acpi_ns_attach_object(node, obj_desc, type);
/* Remove local reference to the object */
acpi_ut_remove_reference(obj_desc);
if (ACPI_FAILURE(status)) {
goto unlock_and_exit;
}
}
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
"Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n",
acpi_ut_get_region_name(space_id), space_id,
acpi_ut_get_node_name(node), node, obj_desc));
/*
* Install the handler
*
* At this point there is no existing handler. Just allocate the object
* for the handler and link it into the list.
*/
handler_obj =
acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER);
if (!handler_obj) {
status = AE_NO_MEMORY;
goto unlock_and_exit;
}
/* Init handler obj */
handler_obj->address_space.space_id = (u8)space_id;
handler_obj->address_space.handler_flags = flags;
handler_obj->address_space.region_list = NULL;
handler_obj->address_space.node = node;
handler_obj->address_space.handler = handler;
handler_obj->address_space.context = context;
handler_obj->address_space.setup = setup;
/* Install at head of Device.address_space list */
handler_obj->address_space.next = obj_desc->device.handler;
/*
* The Device object is the first reference on the handler_obj.
* Each region that uses the handler adds a reference.
*/
obj_desc->device.handler = handler_obj;
/*
* Walk the namespace finding all of the regions this
* handler will manage.
*
* Start at the device and search the branch toward
* the leaf nodes until either the leaf is encountered or
* a device is detected that has an address handler of the
* same type.
*
* In either case, back up and search down the remainder
* of the branch
*/
status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
ACPI_NS_WALK_UNLOCK,
acpi_ev_install_handler, NULL,
handler_obj, NULL);
unlock_and_exit:
return_ACPI_STATUS(status);
}
/****************************************************************************** /******************************************************************************
* *
* Module Name: evregion - ACPI address_space (op_region) handler dispatch * Module Name: evregion - Operation Region support
* *
*****************************************************************************/ *****************************************************************************/
...@@ -50,10 +50,9 @@ ...@@ -50,10 +50,9 @@
#define _COMPONENT ACPI_EVENTS #define _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME("evregion") ACPI_MODULE_NAME("evregion")
extern u8 acpi_gbl_default_address_spaces[];
/* Local prototypes */ /* Local prototypes */
static u8
acpi_ev_has_default_handler(struct acpi_namespace_node *node,
acpi_adr_space_type space_id);
static void acpi_ev_orphan_ec_reg_method(void); static void acpi_ev_orphan_ec_reg_method(void);
...@@ -61,135 +60,6 @@ static acpi_status ...@@ -61,135 +60,6 @@ static acpi_status
acpi_ev_reg_run(acpi_handle obj_handle, acpi_ev_reg_run(acpi_handle obj_handle,
u32 level, void *context, void **return_value); u32 level, void *context, void **return_value);
static acpi_status
acpi_ev_install_handler(acpi_handle obj_handle,
u32 level, void *context, void **return_value);
/* These are the address spaces that will get default handlers */
#define ACPI_NUM_DEFAULT_SPACES 4
static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
ACPI_ADR_SPACE_SYSTEM_MEMORY,
ACPI_ADR_SPACE_SYSTEM_IO,
ACPI_ADR_SPACE_PCI_CONFIG,
ACPI_ADR_SPACE_DATA_TABLE
};
/*******************************************************************************
*
* FUNCTION: acpi_ev_install_region_handlers
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Installs the core subsystem default address space handlers.
*
******************************************************************************/
acpi_status acpi_ev_install_region_handlers(void)
{
acpi_status status;
u32 i;
ACPI_FUNCTION_TRACE(ev_install_region_handlers);
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/*
* All address spaces (PCI Config, EC, SMBus) are scope dependent and
* registration must occur for a specific device.
*
* In the case of the system memory and IO address spaces there is
* currently no device associated with the address space. For these we
* use the root.
*
* We install the default PCI config space handler at the root so that
* this space is immediately available even though the we have not
* enumerated all the PCI Root Buses yet. This is to conform to the ACPI
* specification which states that the PCI config space must be always
* available -- even though we are nowhere near ready to find the PCI root
* buses at this point.
*
* NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler
* has already been installed (via acpi_install_address_space_handler).
* Similar for AE_SAME_HANDLER.
*/
for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
status = acpi_ev_install_space_handler(acpi_gbl_root_node,
acpi_gbl_default_address_spaces
[i],
ACPI_DEFAULT_HANDLER,
NULL, NULL);
switch (status) {
case AE_OK:
case AE_SAME_HANDLER:
case AE_ALREADY_EXISTS:
/* These exceptions are all OK */
status = AE_OK;
break;
default:
goto unlock_and_exit;
}
}
unlock_and_exit:
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_has_default_handler
*
* PARAMETERS: node - Namespace node for the device
* space_id - The address space ID
*
* RETURN: TRUE if default handler is installed, FALSE otherwise
*
* DESCRIPTION: Check if the default handler is installed for the requested
* space ID.
*
******************************************************************************/
static u8
acpi_ev_has_default_handler(struct acpi_namespace_node *node,
acpi_adr_space_type space_id)
{
union acpi_operand_object *obj_desc;
union acpi_operand_object *handler_obj;
/* Must have an existing internal object */
obj_desc = acpi_ns_get_attached_object(node);
if (obj_desc) {
handler_obj = obj_desc->device.handler;
/* Walk the linked list of handlers for this object */
while (handler_obj) {
if (handler_obj->address_space.space_id == space_id) {
if (handler_obj->address_space.handler_flags &
ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) {
return (TRUE);
}
}
handler_obj = handler_obj->address_space.next;
}
}
return (FALSE);
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ev_initialize_op_regions * FUNCTION: acpi_ev_initialize_op_regions
...@@ -239,91 +109,6 @@ acpi_status acpi_ev_initialize_op_regions(void) ...@@ -239,91 +109,6 @@ acpi_status acpi_ev_initialize_op_regions(void)
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }
/*******************************************************************************
*
* FUNCTION: acpi_ev_execute_reg_method
*
* PARAMETERS: region_obj - Region object
* function - Passed to _REG: On (1) or Off (0)
*
* RETURN: Status
*
* DESCRIPTION: Execute _REG method for a region
*
******************************************************************************/
acpi_status
acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
{
struct acpi_evaluate_info *info;
union acpi_operand_object *args[3];
union acpi_operand_object *region_obj2;
acpi_status status;
ACPI_FUNCTION_TRACE(ev_execute_reg_method);
region_obj2 = acpi_ns_get_secondary_object(region_obj);
if (!region_obj2) {
return_ACPI_STATUS(AE_NOT_EXIST);
}
if (region_obj2->extra.method_REG == NULL) {
return_ACPI_STATUS(AE_OK);
}
/* Allocate and initialize the evaluation information block */
info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
if (!info) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
info->prefix_node = region_obj2->extra.method_REG;
info->pathname = NULL;
info->parameters = args;
info->flags = ACPI_IGNORE_RETURN_VALUE;
/*
* The _REG method has two arguments:
*
* arg0 - Integer:
* Operation region space ID Same value as region_obj->Region.space_id
*
* arg1 - Integer:
* connection status 1 for connecting the handler, 0 for disconnecting
* the handler (Passed as a parameter)
*/
args[0] =
acpi_ut_create_integer_object((u64) region_obj->region.space_id);
if (!args[0]) {
status = AE_NO_MEMORY;
goto cleanup1;
}
args[1] = acpi_ut_create_integer_object((u64) function);
if (!args[1]) {
status = AE_NO_MEMORY;
goto cleanup2;
}
args[2] = NULL; /* Terminate list */
/* Execute the method, no return value */
ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
(ACPI_TYPE_METHOD, info->prefix_node, NULL));
status = acpi_ns_evaluate(info);
acpi_ut_remove_reference(args[1]);
cleanup2:
acpi_ut_remove_reference(args[0]);
cleanup1:
ACPI_FREE(info);
return_ACPI_STATUS(status);
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ev_address_space_dispatch * FUNCTION: acpi_ev_address_space_dispatch
...@@ -709,351 +494,86 @@ acpi_ev_attach_region(union acpi_operand_object *handler_obj, ...@@ -709,351 +494,86 @@ acpi_ev_attach_region(union acpi_operand_object *handler_obj,
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ev_install_handler * FUNCTION: acpi_ev_execute_reg_method
*
* PARAMETERS: walk_namespace callback
*
* DESCRIPTION: This routine installs an address handler into objects that are
* of type Region or Device.
*
* If the Object is a Device, and the device has a handler of
* the same type then the search is terminated in that branch.
*
* This is because the existing handler is closer in proximity
* to any more regions than the one we are trying to install.
*
******************************************************************************/
static acpi_status
acpi_ev_install_handler(acpi_handle obj_handle,
u32 level, void *context, void **return_value)
{
union acpi_operand_object *handler_obj;
union acpi_operand_object *next_handler_obj;
union acpi_operand_object *obj_desc;
struct acpi_namespace_node *node;
acpi_status status;
ACPI_FUNCTION_NAME(ev_install_handler);
handler_obj = (union acpi_operand_object *)context;
/* Parameter validation */
if (!handler_obj) {
return (AE_OK);
}
/* Convert and validate the device handle */
node = acpi_ns_validate_handle(obj_handle);
if (!node) {
return (AE_BAD_PARAMETER);
}
/*
* We only care about regions and objects that are allowed to have
* address space handlers
*/
if ((node->type != ACPI_TYPE_DEVICE) &&
(node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
return (AE_OK);
}
/* Check for an existing internal object */
obj_desc = acpi_ns_get_attached_object(node);
if (!obj_desc) {
/* No object, just exit */
return (AE_OK);
}
/* Devices are handled different than regions */
if (obj_desc->common.type == ACPI_TYPE_DEVICE) {
/* Check if this Device already has a handler for this address space */
next_handler_obj = obj_desc->device.handler;
while (next_handler_obj) {
/* Found a handler, is it for the same address space? */
if (next_handler_obj->address_space.space_id ==
handler_obj->address_space.space_id) {
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
"Found handler for region [%s] in device %p(%p) "
"handler %p\n",
acpi_ut_get_region_name
(handler_obj->address_space.
space_id), obj_desc,
next_handler_obj,
handler_obj));
/*
* Since the object we found it on was a device, then it
* means that someone has already installed a handler for
* the branch of the namespace from this device on. Just
* bail out telling the walk routine to not traverse this
* branch. This preserves the scoping rule for handlers.
*/
return (AE_CTRL_DEPTH);
}
/* Walk the linked list of handlers attached to this device */
next_handler_obj = next_handler_obj->address_space.next;
}
/*
* As long as the device didn't have a handler for this space we
* don't care about it. We just ignore it and proceed.
*/
return (AE_OK);
}
/* Object is a Region */
if (obj_desc->region.space_id != handler_obj->address_space.space_id) {
/* This region is for a different address space, just ignore it */
return (AE_OK);
}
/*
* Now we have a region and it is for the handler's address space type.
*
* First disconnect region for any previous handler (if any)
*/
acpi_ev_detach_region(obj_desc, FALSE);
/* Connect the region to the new handler */
status = acpi_ev_attach_region(handler_obj, obj_desc, FALSE);
return (status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ev_install_space_handler
* *
* PARAMETERS: node - Namespace node for the device * PARAMETERS: region_obj - Region object
* space_id - The address space ID * function - Passed to _REG: On (1) or Off (0)
* handler - Address of the handler
* setup - Address of the setup function
* context - Value passed to the handler on each access
* *
* RETURN: Status * RETURN: Status
* *
* DESCRIPTION: Install a handler for all op_regions of a given space_id. * DESCRIPTION: Execute _REG method for a region
* Assumes namespace is locked
* *
******************************************************************************/ ******************************************************************************/
acpi_status acpi_status
acpi_ev_install_space_handler(struct acpi_namespace_node * node, acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
acpi_adr_space_type space_id,
acpi_adr_space_handler handler,
acpi_adr_space_setup setup, void *context)
{ {
union acpi_operand_object *obj_desc; struct acpi_evaluate_info *info;
union acpi_operand_object *handler_obj; union acpi_operand_object *args[3];
union acpi_operand_object *region_obj2;
acpi_status status; acpi_status status;
acpi_object_type type;
u8 flags = 0;
ACPI_FUNCTION_TRACE(ev_install_space_handler); ACPI_FUNCTION_TRACE(ev_execute_reg_method);
/*
* This registration is valid for only the types below and the root. This
* is where the default handlers get placed.
*/
if ((node->type != ACPI_TYPE_DEVICE) &&
(node->type != ACPI_TYPE_PROCESSOR) &&
(node->type != ACPI_TYPE_THERMAL) && (node != acpi_gbl_root_node)) {
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
if (handler == ACPI_DEFAULT_HANDLER) { region_obj2 = acpi_ns_get_secondary_object(region_obj);
flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED; if (!region_obj2) {
return_ACPI_STATUS(AE_NOT_EXIST);
switch (space_id) {
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
handler = acpi_ex_system_memory_space_handler;
setup = acpi_ev_system_memory_region_setup;
break;
case ACPI_ADR_SPACE_SYSTEM_IO:
handler = acpi_ex_system_io_space_handler;
setup = acpi_ev_io_space_region_setup;
break;
case ACPI_ADR_SPACE_PCI_CONFIG:
handler = acpi_ex_pci_config_space_handler;
setup = acpi_ev_pci_config_region_setup;
break;
case ACPI_ADR_SPACE_CMOS:
handler = acpi_ex_cmos_space_handler;
setup = acpi_ev_cmos_region_setup;
break;
case ACPI_ADR_SPACE_PCI_BAR_TARGET:
handler = acpi_ex_pci_bar_space_handler;
setup = acpi_ev_pci_bar_region_setup;
break;
case ACPI_ADR_SPACE_DATA_TABLE:
handler = acpi_ex_data_table_space_handler;
setup = NULL;
break;
default:
status = AE_BAD_PARAMETER;
goto unlock_and_exit;
}
} }
/* If the caller hasn't specified a setup routine, use the default */ if (region_obj2->extra.method_REG == NULL) {
return_ACPI_STATUS(AE_OK);
if (!setup) {
setup = acpi_ev_default_region_setup;
} }
/* Check for an existing internal object */ /* Allocate and initialize the evaluation information block */
obj_desc = acpi_ns_get_attached_object(node);
if (obj_desc) {
/*
* The attached device object already exists. Make sure the handler
* is not already installed.
*/
handler_obj = obj_desc->device.handler;
/* Walk the handler list for this device */
while (handler_obj) {
/* Same space_id indicates a handler already installed */
if (handler_obj->address_space.space_id == space_id) {
if (handler_obj->address_space.handler ==
handler) {
/*
* It is (relatively) OK to attempt to install the SAME
* handler twice. This can easily happen with the
* PCI_Config space.
*/
status = AE_SAME_HANDLER;
goto unlock_and_exit;
} else {
/* A handler is already installed */
status = AE_ALREADY_EXISTS;
}
goto unlock_and_exit;
}
/* Walk the linked list of handlers */
handler_obj = handler_obj->address_space.next;
}
} else {
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
"Creating object on Device %p while installing handler\n",
node));
/* obj_desc does not exist, create one */
if (node->type == ACPI_TYPE_ANY) {
type = ACPI_TYPE_DEVICE;
} else {
type = node->type;
}
obj_desc = acpi_ut_create_internal_object(type);
if (!obj_desc) {
status = AE_NO_MEMORY;
goto unlock_and_exit;
}
/* Init new descriptor */
obj_desc->common.type = (u8) type;
/* Attach the new object to the Node */
status = acpi_ns_attach_object(node, obj_desc, type);
/* Remove local reference to the object */
acpi_ut_remove_reference(obj_desc);
if (ACPI_FAILURE(status)) { info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
goto unlock_and_exit; if (!info) {
} return_ACPI_STATUS(AE_NO_MEMORY);
} }
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, info->prefix_node = region_obj2->extra.method_REG;
"Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", info->pathname = NULL;
acpi_ut_get_region_name(space_id), space_id, info->parameters = args;
acpi_ut_get_node_name(node), node, obj_desc)); info->flags = ACPI_IGNORE_RETURN_VALUE;
/* /*
* Install the handler * The _REG method has two arguments:
*
* arg0 - Integer:
* Operation region space ID Same value as region_obj->Region.space_id
* *
* At this point there is no existing handler. Just allocate the object * arg1 - Integer:
* for the handler and link it into the list. * connection status 1 for connecting the handler, 0 for disconnecting
* the handler (Passed as a parameter)
*/ */
handler_obj = args[0] =
acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER); acpi_ut_create_integer_object((u64)region_obj->region.space_id);
if (!handler_obj) { if (!args[0]) {
status = AE_NO_MEMORY; status = AE_NO_MEMORY;
goto unlock_and_exit; goto cleanup1;
} }
/* Init handler obj */ args[1] = acpi_ut_create_integer_object((u64)function);
if (!args[1]) {
status = AE_NO_MEMORY;
goto cleanup2;
}
handler_obj->address_space.space_id = (u8) space_id; args[2] = NULL; /* Terminate list */
handler_obj->address_space.handler_flags = flags;
handler_obj->address_space.region_list = NULL;
handler_obj->address_space.node = node;
handler_obj->address_space.handler = handler;
handler_obj->address_space.context = context;
handler_obj->address_space.setup = setup;
/* Install at head of Device.address_space list */ /* Execute the method, no return value */
handler_obj->address_space.next = obj_desc->device.handler; ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
(ACPI_TYPE_METHOD, info->prefix_node, NULL));
/* status = acpi_ns_evaluate(info);
* The Device object is the first reference on the handler_obj. acpi_ut_remove_reference(args[1]);
* Each region that uses the handler adds a reference.
*/
obj_desc->device.handler = handler_obj;
/* cleanup2:
* Walk the namespace finding all of the regions this acpi_ut_remove_reference(args[0]);
* handler will manage.
*
* Start at the device and search the branch toward
* the leaf nodes until either the leaf is encountered or
* a device is detected that has an address handler of the
* same type.
*
* In either case, back up and search down the remainder
* of the branch
*/
status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
ACPI_NS_WALK_UNLOCK,
acpi_ev_install_handler, NULL,
handler_obj, NULL);
unlock_and_exit: cleanup1:
ACPI_FREE(info);
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }
......
...@@ -89,7 +89,7 @@ static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context) ...@@ -89,7 +89,7 @@ static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context)
*/ */
interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
return_UINT32(interrupt_handled); return_VALUE(interrupt_handled);
} }
/******************************************************************************* /*******************************************************************************
...@@ -120,7 +120,7 @@ u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context) ...@@ -120,7 +120,7 @@ u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context)
interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
return_UINT32(interrupt_handled); return_VALUE(interrupt_handled);
} }
/****************************************************************************** /******************************************************************************
......
...@@ -56,13 +56,13 @@ ACPI_MODULE_NAME("evxface") ...@@ -56,13 +56,13 @@ ACPI_MODULE_NAME("evxface")
* *
* FUNCTION: acpi_install_notify_handler * FUNCTION: acpi_install_notify_handler
* *
* PARAMETERS: Device - The device for which notifies will be handled * PARAMETERS: device - The device for which notifies will be handled
* handler_type - The type of handler: * handler_type - The type of handler:
* ACPI_SYSTEM_NOTIFY: System Handler (00-7F) * ACPI_SYSTEM_NOTIFY: System Handler (00-7F)
* ACPI_DEVICE_NOTIFY: Device Handler (80-FF) * ACPI_DEVICE_NOTIFY: Device Handler (80-FF)
* ACPI_ALL_NOTIFY: Both System and Device * ACPI_ALL_NOTIFY: Both System and Device
* Handler - Address of the handler * handler - Address of the handler
* Context - Value passed to the handler on each GPE * context - Value passed to the handler on each GPE
* *
* RETURN: Status * RETURN: Status
* *
...@@ -217,12 +217,12 @@ ACPI_EXPORT_SYMBOL(acpi_install_notify_handler) ...@@ -217,12 +217,12 @@ ACPI_EXPORT_SYMBOL(acpi_install_notify_handler)
* *
* FUNCTION: acpi_remove_notify_handler * FUNCTION: acpi_remove_notify_handler
* *
* PARAMETERS: Device - The device for which the handler is installed * PARAMETERS: device - The device for which the handler is installed
* handler_type - The type of handler: * handler_type - The type of handler:
* ACPI_SYSTEM_NOTIFY: System Handler (00-7F) * ACPI_SYSTEM_NOTIFY: System Handler (00-7F)
* ACPI_DEVICE_NOTIFY: Device Handler (80-FF) * ACPI_DEVICE_NOTIFY: Device Handler (80-FF)
* ACPI_ALL_NOTIFY: Both System and Device * ACPI_ALL_NOTIFY: Both System and Device
* Handler - Address of the handler * handler - Address of the handler
* *
* RETURN: Status * RETURN: Status
* *
...@@ -249,7 +249,8 @@ acpi_remove_notify_handler(acpi_handle device, ...@@ -249,7 +249,8 @@ acpi_remove_notify_handler(acpi_handle device,
(handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
return_ACPI_STATUS(AE_BAD_PARAMETER); return_ACPI_STATUS(AE_BAD_PARAMETER);
} }
/* Make sure all deferred tasks are completed */
/* Make sure all deferred notify tasks are completed */
acpi_os_wait_events_complete(); acpi_os_wait_events_complete();
...@@ -596,7 +597,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device, ...@@ -596,7 +597,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }
/* Allocate memory for the handler object */ /* Allocate and init handler object (before lock) */
handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_handler_info)); handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_handler_info));
if (!handler) { if (!handler) {
...@@ -622,16 +623,15 @@ acpi_install_gpe_handler(acpi_handle gpe_device, ...@@ -622,16 +623,15 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
goto free_and_exit; goto free_and_exit;
} }
/* Allocate and init handler object */
handler->address = address; handler->address = address;
handler->context = context; handler->context = context;
handler->method_node = gpe_event_info->dispatch.method_node; handler->method_node = gpe_event_info->dispatch.method_node;
handler->original_flags = gpe_event_info->flags & handler->original_flags = (u8)(gpe_event_info->flags &
(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); (ACPI_GPE_XRUPT_TYPE_MASK |
ACPI_GPE_DISPATCH_MASK));
/* /*
* If the GPE is associated with a method, it might have been enabled * If the GPE is associated with a method, it may have been enabled
* automatically during initialization, in which case it has to be * automatically during initialization, in which case it has to be
* disabled now to avoid spurious execution of the handler. * disabled now to avoid spurious execution of the handler.
*/ */
...@@ -646,7 +646,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device, ...@@ -646,7 +646,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
gpe_event_info->dispatch.handler = handler; gpe_event_info->dispatch.handler = handler;
/* Setup up dispatch flags to indicate handler (vs. method) */ /* Setup up dispatch flags to indicate handler (vs. method/notify) */
gpe_event_info->flags &= gpe_event_info->flags &=
~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK);
...@@ -697,7 +697,7 @@ acpi_remove_gpe_handler(acpi_handle gpe_device, ...@@ -697,7 +697,7 @@ acpi_remove_gpe_handler(acpi_handle gpe_device,
return_ACPI_STATUS(AE_BAD_PARAMETER); return_ACPI_STATUS(AE_BAD_PARAMETER);
} }
/* Make sure all deferred tasks are completed */ /* Make sure all deferred GPE tasks are completed */
acpi_os_wait_events_complete(); acpi_os_wait_events_complete();
...@@ -747,10 +747,10 @@ acpi_remove_gpe_handler(acpi_handle gpe_device, ...@@ -747,10 +747,10 @@ acpi_remove_gpe_handler(acpi_handle gpe_device,
* enabled, it should be enabled at this point to restore the * enabled, it should be enabled at this point to restore the
* post-initialization configuration. * post-initialization configuration.
*/ */
if ((handler->original_flags & ACPI_GPE_DISPATCH_METHOD) &&
if ((handler->original_flags & ACPI_GPE_DISPATCH_METHOD) handler->originally_enabled) {
&& handler->originally_enabled)
(void)acpi_ev_add_gpe_reference(gpe_event_info); (void)acpi_ev_add_gpe_reference(gpe_event_info);
}
/* Now we can free the handler object */ /* Now we can free the handler object */
......
...@@ -61,7 +61,6 @@ ACPI_MODULE_NAME("evxfevnt") ...@@ -61,7 +61,6 @@ ACPI_MODULE_NAME("evxfevnt")
* DESCRIPTION: Transfers the system into ACPI mode. * DESCRIPTION: Transfers the system into ACPI mode.
* *
******************************************************************************/ ******************************************************************************/
acpi_status acpi_enable(void) acpi_status acpi_enable(void)
{ {
acpi_status status; acpi_status status;
...@@ -210,8 +209,8 @@ ACPI_EXPORT_SYMBOL(acpi_enable_event) ...@@ -210,8 +209,8 @@ ACPI_EXPORT_SYMBOL(acpi_enable_event)
* *
* FUNCTION: acpi_disable_event * FUNCTION: acpi_disable_event
* *
* PARAMETERS: Event - The fixed eventto be enabled * PARAMETERS: event - The fixed event to be disabled
* Flags - Reserved * flags - Reserved
* *
* RETURN: Status * RETURN: Status
* *
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
ACPI_MODULE_NAME("evxfgpe") ACPI_MODULE_NAME("evxfgpe")
#if (!ACPI_REDUCED_HARDWARE) /* Entire module */ #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
/****************************************************************************** /*******************************************************************************
* *
* FUNCTION: acpi_update_all_gpes * FUNCTION: acpi_update_all_gpes
* *
...@@ -172,6 +172,7 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number) ...@@ -172,6 +172,7 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number)
acpi_os_release_lock(acpi_gbl_gpe_lock, flags); acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }
ACPI_EXPORT_SYMBOL(acpi_disable_gpe) ACPI_EXPORT_SYMBOL(acpi_disable_gpe)
...@@ -225,7 +226,7 @@ acpi_setup_gpe_for_wake(acpi_handle wake_device, ...@@ -225,7 +226,7 @@ acpi_setup_gpe_for_wake(acpi_handle wake_device,
ACPI_CAST_PTR(struct acpi_namespace_node, wake_device); ACPI_CAST_PTR(struct acpi_namespace_node, wake_device);
} }
/* Validate WakeDevice is of type Device */ /* Validate wake_device is of type Device */
if (device_node->type != ACPI_TYPE_DEVICE) { if (device_node->type != ACPI_TYPE_DEVICE) {
return_ACPI_STATUS (AE_BAD_PARAMETER); return_ACPI_STATUS (AE_BAD_PARAMETER);
...@@ -432,8 +433,8 @@ ACPI_EXPORT_SYMBOL(acpi_clear_gpe) ...@@ -432,8 +433,8 @@ ACPI_EXPORT_SYMBOL(acpi_clear_gpe)
* *
* PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
* gpe_number - GPE level within the GPE block * gpe_number - GPE level within the GPE block
* event_status - Where the current status of the event will * event_status - Where the current status of the event
* be returned * will be returned
* *
* RETURN: Status * RETURN: Status
* *
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "actables.h" #include "actables.h"
#include "acdispat.h" #include "acdispat.h"
#include "acevents.h" #include "acevents.h"
#include "amlcode.h"
#define _COMPONENT ACPI_EXECUTER #define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME("exconfig") ACPI_MODULE_NAME("exconfig")
...@@ -120,8 +121,11 @@ acpi_ex_add_table(u32 table_index, ...@@ -120,8 +121,11 @@ acpi_ex_add_table(u32 table_index,
acpi_ns_exec_module_code_list(); acpi_ns_exec_module_code_list();
acpi_ex_enter_interpreter(); acpi_ex_enter_interpreter();
/* Update GPEs for any new _Lxx/_Exx methods. Ignore errors */ /*
* Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is
* responsible for discovering any new wake GPEs by running _PRW methods
* that may have been loaded by this table.
*/
status = acpi_tb_get_owner_id(table_index, &owner_id); status = acpi_tb_get_owner_id(table_index, &owner_id);
if (ACPI_SUCCESS(status)) { if (ACPI_SUCCESS(status)) {
acpi_ev_update_gpes(owner_id); acpi_ev_update_gpes(owner_id);
...@@ -158,12 +162,12 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state, ...@@ -158,12 +162,12 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
ACPI_FUNCTION_TRACE(ex_load_table_op); ACPI_FUNCTION_TRACE(ex_load_table_op);
/* Validate lengths for the signature_string, OEMIDString, OEMtable_iD */ /* Validate lengths for the Signature, oem_id, and oem_table_id strings */
if ((operand[0]->string.length > ACPI_NAME_SIZE) || if ((operand[0]->string.length > ACPI_NAME_SIZE) ||
(operand[1]->string.length > ACPI_OEM_ID_SIZE) || (operand[1]->string.length > ACPI_OEM_ID_SIZE) ||
(operand[2]->string.length > ACPI_OEM_TABLE_ID_SIZE)) { (operand[2]->string.length > ACPI_OEM_TABLE_ID_SIZE)) {
return_ACPI_STATUS(AE_BAD_PARAMETER); return_ACPI_STATUS(AE_AML_STRING_LIMIT);
} }
/* Find the ACPI table in the RSDT/XSDT */ /* Find the ACPI table in the RSDT/XSDT */
...@@ -210,8 +214,8 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state, ...@@ -210,8 +214,8 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
/* parameter_path (optional parameter) */ /* parameter_path (optional parameter) */
if (operand[4]->string.length > 0) { if (operand[4]->string.length > 0) {
if ((operand[4]->string.pointer[0] != '\\') && if ((operand[4]->string.pointer[0] != AML_ROOT_PREFIX) &&
(operand[4]->string.pointer[0] != '^')) { (operand[4]->string.pointer[0] != AML_PARENT_PREFIX)) {
/* /*
* Path is not absolute, so it will be relative to the node * Path is not absolute, so it will be relative to the node
* referenced by the root_path_string (or the NS root if omitted) * referenced by the root_path_string (or the NS root if omitted)
...@@ -301,7 +305,7 @@ acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer) ...@@ -301,7 +305,7 @@ acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer)
acpi_ev_address_space_dispatch(obj_desc, NULL, ACPI_READ, acpi_ev_address_space_dispatch(obj_desc, NULL, ACPI_READ,
region_offset, 8, &value); region_offset, 8, &value);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return status; return (status);
} }
*buffer = (u8)value; *buffer = (u8)value;
...@@ -309,7 +313,7 @@ acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer) ...@@ -309,7 +313,7 @@ acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer)
region_offset++; region_offset++;
} }
return AE_OK; return (AE_OK);
} }
/******************************************************************************* /*******************************************************************************
......
...@@ -176,7 +176,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, ...@@ -176,7 +176,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
/* Save the Result */ /* Save the Result */
acpi_ex_truncate_for32bit_table(return_desc); (void)acpi_ex_truncate_for32bit_table(return_desc);
*result_desc = return_desc; *result_desc = return_desc;
return_ACPI_STATUS(AE_OK); return_ACPI_STATUS(AE_OK);
} }
......
...@@ -464,9 +464,8 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) ...@@ -464,9 +464,8 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
ACPI_FUNCTION_NAME(ex_dump_operand) ACPI_FUNCTION_NAME(ex_dump_operand)
if (! /* Check if debug output enabled */
((ACPI_LV_EXEC & acpi_dbg_level) if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_EXEC, _COMPONENT)) {
&& (_COMPONENT & acpi_dbg_layer))) {
return; return;
} }
...@@ -811,9 +810,10 @@ void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags) ...@@ -811,9 +810,10 @@ void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags)
ACPI_FUNCTION_ENTRY(); ACPI_FUNCTION_ENTRY();
if (!flags) { if (!flags) {
if (!
((ACPI_LV_OBJECTS & acpi_dbg_level) /* Check if debug output enabled */
&& (_COMPONENT & acpi_dbg_layer))) {
if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_OBJECTS, _COMPONENT)) {
return; return;
} }
} }
...@@ -999,9 +999,10 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags) ...@@ -999,9 +999,10 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
} }
if (!flags) { if (!flags) {
if (!
((ACPI_LV_OBJECTS & acpi_dbg_level) /* Check if debug output enabled */
&& (_COMPONENT & acpi_dbg_layer))) {
if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_OBJECTS, _COMPONENT)) {
return_VOID; return_VOID;
} }
} }
......
...@@ -329,7 +329,6 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc, ...@@ -329,7 +329,6 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc,
static u8 static u8
acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value) acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value)
{ {
ACPI_FUNCTION_NAME(ex_register_overflow);
if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) { if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) {
/* /*
......
...@@ -377,7 +377,8 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, ...@@ -377,7 +377,8 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED); return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
} }
/* Must have a valid thread. */ /* Must have a valid thread ID */
if (!walk_state->thread) { if (!walk_state->thread) {
ACPI_ERROR((AE_INFO, ACPI_ERROR((AE_INFO,
"Cannot release Mutex [%4.4s], null thread info", "Cannot release Mutex [%4.4s], null thread info",
......
...@@ -948,13 +948,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) ...@@ -948,13 +948,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
*/ */
return_desc = return_desc =
acpi_ut_create_integer_object((u64) acpi_ut_create_integer_object((u64)
temp_desc-> temp_desc->buffer.pointer[operand[0]->reference.value]);
buffer.
pointer
[operand
[0]->
reference.
value]);
if (!return_desc) { if (!return_desc) {
status = AE_NO_MEMORY; status = AE_NO_MEMORY;
goto cleanup; goto cleanup;
......
...@@ -276,7 +276,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc, ...@@ -276,7 +276,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
/* Invalid field access type */ /* Invalid field access type */
ACPI_ERROR((AE_INFO, "Unknown field access type 0x%X", access)); ACPI_ERROR((AE_INFO, "Unknown field access type 0x%X", access));
return_UINT32(0); return_VALUE(0);
} }
if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) { if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) {
...@@ -289,7 +289,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc, ...@@ -289,7 +289,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
} }
*return_byte_alignment = byte_alignment; *return_byte_alignment = byte_alignment;
return_UINT32(bit_length); return_VALUE(bit_length);
} }
/******************************************************************************* /*******************************************************************************
......
...@@ -142,9 +142,9 @@ acpi_ex_system_memory_space_handler(u32 function, ...@@ -142,9 +142,9 @@ acpi_ex_system_memory_space_handler(u32 function,
} }
/* /*
* Attempt to map from the requested address to the end of the region. * October 2009: Attempt to map from the requested address to the
* However, we will never map more than one page, nor will we cross * end of the region. However, we will never map more than one
* a page boundary. * page, nor will we cross a page boundary.
*/ */
map_length = (acpi_size) map_length = (acpi_size)
((mem_info->address + mem_info->length) - address); ((mem_info->address + mem_info->length) - address);
...@@ -154,12 +154,15 @@ acpi_ex_system_memory_space_handler(u32 function, ...@@ -154,12 +154,15 @@ acpi_ex_system_memory_space_handler(u32 function,
* a page boundary, just map up to the page boundary, do not cross. * a page boundary, just map up to the page boundary, do not cross.
* On some systems, crossing a page boundary while mapping regions * On some systems, crossing a page boundary while mapping regions
* can cause warnings if the pages have different attributes * can cause warnings if the pages have different attributes
* due to resource management * due to resource management.
*
* This has the added benefit of constraining a single mapping to
* one page, which is similar to the original code that used a 4k
* maximum window.
*/ */
page_boundary_map_length = page_boundary_map_length =
ACPI_ROUND_UP(address, ACPI_DEFAULT_PAGE_SIZE) - address; ACPI_ROUND_UP(address, ACPI_DEFAULT_PAGE_SIZE) - address;
if (page_boundary_map_length == 0) {
if (!page_boundary_map_length) {
page_boundary_map_length = ACPI_DEFAULT_PAGE_SIZE; page_boundary_map_length = ACPI_DEFAULT_PAGE_SIZE;
} }
...@@ -236,19 +239,19 @@ acpi_ex_system_memory_space_handler(u32 function, ...@@ -236,19 +239,19 @@ acpi_ex_system_memory_space_handler(u32 function,
switch (bit_width) { switch (bit_width) {
case 8: case 8:
ACPI_SET8(logical_addr_ptr) = (u8) * value; ACPI_SET8(logical_addr_ptr, *value);
break; break;
case 16: case 16:
ACPI_SET16(logical_addr_ptr) = (u16) * value; ACPI_SET16(logical_addr_ptr, *value);
break; break;
case 32: case 32:
ACPI_SET32(logical_addr_ptr) = (u32) * value; ACPI_SET32(logical_addr_ptr, *value);
break; break;
case 64: case 64:
ACPI_SET64(logical_addr_ptr) = (u64) * value; ACPI_SET64(logical_addr_ptr, *value);
break; break;
default: default:
......
...@@ -487,14 +487,33 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc, ...@@ -487,14 +487,33 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
default: default:
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Storing %s (%p) directly into node (%p) with no implicit conversion\n", "Storing [%s] (%p) directly into node [%s] (%p)"
" with no implicit conversion\n",
acpi_ut_get_object_type_name(source_desc), acpi_ut_get_object_type_name(source_desc),
source_desc, node)); source_desc,
acpi_ut_get_object_type_name(target_desc),
node));
/* No conversions for all other types. Just attach the source object */ /*
* No conversions for all other types. Directly store a copy of
* the source object. NOTE: This is a departure from the ACPI
* spec, which states "If conversion is impossible, abort the
* running control method".
*
* This code implements "If conversion is impossible, treat the
* Store operation as a CopyObject".
*/
status =
acpi_ut_copy_iobject_to_iobject(source_desc, &new_desc,
walk_state);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
status = acpi_ns_attach_object(node, source_desc, status =
source_desc->common.type); acpi_ns_attach_object(node, new_desc,
new_desc->common.type);
acpi_ut_remove_reference(new_desc);
break; break;
} }
......
...@@ -253,7 +253,7 @@ acpi_ex_store_object_to_object(union acpi_operand_object *source_desc, ...@@ -253,7 +253,7 @@ acpi_ex_store_object_to_object(union acpi_operand_object *source_desc,
/* Truncate value if we are executing from a 32-bit ACPI table */ /* Truncate value if we are executing from a 32-bit ACPI table */
acpi_ex_truncate_for32bit_table(dest_desc); (void)acpi_ex_truncate_for32bit_table(dest_desc);
break; break;
case ACPI_TYPE_STRING: case ACPI_TYPE_STRING:
......
...@@ -202,35 +202,39 @@ void acpi_ex_relinquish_interpreter(void) ...@@ -202,35 +202,39 @@ void acpi_ex_relinquish_interpreter(void)
* *
* PARAMETERS: obj_desc - Object to be truncated * PARAMETERS: obj_desc - Object to be truncated
* *
* RETURN: none * RETURN: TRUE if a truncation was performed, FALSE otherwise.
* *
* DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is
* 32-bit, as determined by the revision of the DSDT. * 32-bit, as determined by the revision of the DSDT.
* *
******************************************************************************/ ******************************************************************************/
void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc) u8 acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc)
{ {
ACPI_FUNCTION_ENTRY(); ACPI_FUNCTION_ENTRY();
/* /*
* Object must be a valid number and we must be executing * Object must be a valid number and we must be executing
* a control method. NS node could be there for AML_INT_NAMEPATH_OP. * a control method. Object could be NS node for AML_INT_NAMEPATH_OP.
*/ */
if ((!obj_desc) || if ((!obj_desc) ||
(ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) || (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) ||
(obj_desc->common.type != ACPI_TYPE_INTEGER)) { (obj_desc->common.type != ACPI_TYPE_INTEGER)) {
return; return (FALSE);
} }
if (acpi_gbl_integer_byte_width == 4) { if ((acpi_gbl_integer_byte_width == 4) &&
(obj_desc->integer.value > (u64)ACPI_UINT32_MAX)) {
/* /*
* We are running a method that exists in a 32-bit ACPI table. * We are executing in a 32-bit ACPI table.
* Truncate the value to 32 bits by zeroing out the upper 32-bit field * Truncate the value to 32 bits by zeroing out the upper 32-bit field
*/ */
obj_desc->integer.value &= (u64) ACPI_UINT32_MAX; obj_desc->integer.value &= (u64)ACPI_UINT32_MAX;
return (TRUE);
} }
return (FALSE);
} }
/******************************************************************************* /*******************************************************************************
...@@ -336,7 +340,7 @@ static u32 acpi_ex_digits_needed(u64 value, u32 base) ...@@ -336,7 +340,7 @@ static u32 acpi_ex_digits_needed(u64 value, u32 base)
/* u64 is unsigned, so we don't worry about a '-' prefix */ /* u64 is unsigned, so we don't worry about a '-' prefix */
if (value == 0) { if (value == 0) {
return_UINT32(1); return_VALUE(1);
} }
current_value = value; current_value = value;
...@@ -350,7 +354,7 @@ static u32 acpi_ex_digits_needed(u64 value, u32 base) ...@@ -350,7 +354,7 @@ static u32 acpi_ex_digits_needed(u64 value, u32 base)
num_digits++; num_digits++;
} }
return_UINT32(num_digits); return_VALUE(num_digits);
} }
/******************************************************************************* /*******************************************************************************
......
...@@ -108,8 +108,7 @@ acpi_status acpi_hw_set_mode(u32 mode) ...@@ -108,8 +108,7 @@ acpi_status acpi_hw_set_mode(u32 mode)
* enable bits to default * enable bits to default
*/ */
status = acpi_hw_write_port(acpi_gbl_FADT.smi_command, status = acpi_hw_write_port(acpi_gbl_FADT.smi_command,
(u32) acpi_gbl_FADT.acpi_disable, (u32)acpi_gbl_FADT.acpi_disable, 8);
8);
ACPI_DEBUG_PRINT((ACPI_DB_INFO, ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Attempting to enable Legacy (non-ACPI) mode\n")); "Attempting to enable Legacy (non-ACPI) mode\n"));
break; break;
...@@ -152,18 +151,18 @@ u32 acpi_hw_get_mode(void) ...@@ -152,18 +151,18 @@ u32 acpi_hw_get_mode(void)
* system does not support mode transition. * system does not support mode transition.
*/ */
if (!acpi_gbl_FADT.smi_command) { if (!acpi_gbl_FADT.smi_command) {
return_UINT32(ACPI_SYS_MODE_ACPI); return_VALUE(ACPI_SYS_MODE_ACPI);
} }
status = acpi_read_bit_register(ACPI_BITREG_SCI_ENABLE, &value); status = acpi_read_bit_register(ACPI_BITREG_SCI_ENABLE, &value);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return_UINT32(ACPI_SYS_MODE_LEGACY); return_VALUE(ACPI_SYS_MODE_LEGACY);
} }
if (value) { if (value) {
return_UINT32(ACPI_SYS_MODE_ACPI); return_VALUE(ACPI_SYS_MODE_ACPI);
} else { } else {
return_UINT32(ACPI_SYS_MODE_LEGACY); return_VALUE(ACPI_SYS_MODE_LEGACY);
} }
} }
......
...@@ -200,7 +200,6 @@ acpi_status acpi_hw_extended_wake_prep(u8 sleep_state) ...@@ -200,7 +200,6 @@ acpi_status acpi_hw_extended_wake_prep(u8 sleep_state)
* FUNCTION: acpi_hw_extended_wake * FUNCTION: acpi_hw_extended_wake
* *
* PARAMETERS: sleep_state - Which sleep state we just exited * PARAMETERS: sleep_state - Which sleep state we just exited
* flags - Reserved, set to zero
* *
* RETURN: Status * RETURN: Status
* *
......
...@@ -69,8 +69,10 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, ...@@ -69,8 +69,10 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info) u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info)
{ {
return (u32)1 << (gpe_event_info->gpe_number -
gpe_event_info->register_info->base_gpe_number); return ((u32)1 <<
(gpe_event_info->gpe_number -
gpe_event_info->register_info->base_gpe_number));
} }
/****************************************************************************** /******************************************************************************
......
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
#include <acpi/acpi.h> #include <acpi/acpi.h>
#include "accommon.h" #include "accommon.h"
#include "acnamesp.h"
#include "acevents.h" #include "acevents.h"
#define _COMPONENT ACPI_HARDWARE #define _COMPONENT ACPI_HARDWARE
...@@ -364,8 +363,7 @@ acpi_status acpi_hw_write_pm1_control(u32 pm1a_control, u32 pm1b_control) ...@@ -364,8 +363,7 @@ acpi_status acpi_hw_write_pm1_control(u32 pm1a_control, u32 pm1b_control)
* DESCRIPTION: Read from the specified ACPI register * DESCRIPTION: Read from the specified ACPI register
* *
******************************************************************************/ ******************************************************************************/
acpi_status acpi_status acpi_hw_register_read(u32 register_id, u32 *return_value)
acpi_hw_register_read(u32 register_id, u32 * return_value)
{ {
u32 value = 0; u32 value = 0;
acpi_status status; acpi_status status;
...@@ -485,7 +483,7 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) ...@@ -485,7 +483,7 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
&acpi_gbl_xpm1b_status); &acpi_gbl_xpm1b_status);
break; break;
case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access */ case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */
status = acpi_hw_write_multiple(value, status = acpi_hw_write_multiple(value,
&acpi_gbl_xpm1a_enable, &acpi_gbl_xpm1a_enable,
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
#include <acpi/acpi.h> #include <acpi/acpi.h>
#include <linux/acpi.h> #include <linux/acpi.h>
#include "accommon.h" #include "accommon.h"
#include <linux/module.h>
#define _COMPONENT ACPI_HARDWARE #define _COMPONENT ACPI_HARDWARE
ACPI_MODULE_NAME("hwsleep") ACPI_MODULE_NAME("hwsleep")
...@@ -178,7 +177,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state) ...@@ -178,7 +177,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
* to still read the right value. Ideally, this block would go * to still read the right value. Ideally, this block would go
* away entirely. * away entirely.
*/ */
acpi_os_stall(10000000); acpi_os_stall(10 * ACPI_USEC_PER_SEC);
status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL, status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL,
sleep_enable_reg_info-> sleep_enable_reg_info->
...@@ -323,7 +322,8 @@ acpi_status acpi_hw_legacy_wake(u8 sleep_state) ...@@ -323,7 +322,8 @@ acpi_status acpi_hw_legacy_wake(u8 sleep_state)
* and use it to determine whether the system is rebooting or * and use it to determine whether the system is rebooting or
* resuming. Clear WAK_STS for compatibility. * resuming. Clear WAK_STS for compatibility.
*/ */
acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1); (void)acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS,
ACPI_CLEAR_STATUS);
acpi_gbl_system_awake_and_running = TRUE; acpi_gbl_system_awake_and_running = TRUE;
/* Enable power button */ /* Enable power button */
......
...@@ -176,10 +176,11 @@ acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed) ...@@ -176,10 +176,11 @@ acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed)
/* /*
* Compute Duration (Requires a 64-bit multiply and divide): * Compute Duration (Requires a 64-bit multiply and divide):
* *
* time_elapsed = (delta_ticks * 1000000) / PM_TIMER_FREQUENCY; * time_elapsed (microseconds) =
* (delta_ticks * ACPI_USEC_PER_SEC) / ACPI_PM_TIMER_FREQUENCY;
*/ */
status = acpi_ut_short_divide(((u64) delta_ticks) * 1000000, status = acpi_ut_short_divide(((u64)delta_ticks) * ACPI_USEC_PER_SEC,
PM_TIMER_FREQUENCY, &quotient, NULL); ACPI_PM_TIMER_FREQUENCY, &quotient, NULL);
*time_elapsed = (u32) quotient; *time_elapsed = (u32) quotient;
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
......
...@@ -135,7 +135,7 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width) ...@@ -135,7 +135,7 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width)
if ((bit_width != 8) && (bit_width != 16) && (bit_width != 32)) { if ((bit_width != 8) && (bit_width != 16) && (bit_width != 32)) {
ACPI_ERROR((AE_INFO, ACPI_ERROR((AE_INFO,
"Bad BitWidth parameter: %8.8X", bit_width)); "Bad BitWidth parameter: %8.8X", bit_width));
return AE_BAD_PARAMETER; return (AE_BAD_PARAMETER);
} }
port_info = acpi_protected_ports; port_info = acpi_protected_ports;
...@@ -234,11 +234,11 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width) ...@@ -234,11 +234,11 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width)
status = acpi_hw_validate_io_request(address, width); status = acpi_hw_validate_io_request(address, width);
if (ACPI_SUCCESS(status)) { if (ACPI_SUCCESS(status)) {
status = acpi_os_read_port(address, value, width); status = acpi_os_read_port(address, value, width);
return status; return (status);
} }
if (status != AE_AML_ILLEGAL_ADDRESS) { if (status != AE_AML_ILLEGAL_ADDRESS) {
return status; return (status);
} }
/* /*
...@@ -253,7 +253,7 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width) ...@@ -253,7 +253,7 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width)
if (acpi_hw_validate_io_request(address, 8) == AE_OK) { if (acpi_hw_validate_io_request(address, 8) == AE_OK) {
status = acpi_os_read_port(address, &one_byte, 8); status = acpi_os_read_port(address, &one_byte, 8);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return status; return (status);
} }
*value |= (one_byte << i); *value |= (one_byte << i);
...@@ -262,7 +262,7 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width) ...@@ -262,7 +262,7 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width)
address++; address++;
} }
return AE_OK; return (AE_OK);
} }
/****************************************************************************** /******************************************************************************
...@@ -297,11 +297,11 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width) ...@@ -297,11 +297,11 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width)
status = acpi_hw_validate_io_request(address, width); status = acpi_hw_validate_io_request(address, width);
if (ACPI_SUCCESS(status)) { if (ACPI_SUCCESS(status)) {
status = acpi_os_write_port(address, value, width); status = acpi_os_write_port(address, value, width);
return status; return (status);
} }
if (status != AE_AML_ILLEGAL_ADDRESS) { if (status != AE_AML_ILLEGAL_ADDRESS) {
return status; return (status);
} }
/* /*
...@@ -317,12 +317,12 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width) ...@@ -317,12 +317,12 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width)
status = status =
acpi_os_write_port(address, (value >> i) & 0xFF, 8); acpi_os_write_port(address, (value >> i) & 0xFF, 8);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return status; return (status);
} }
} }
address++; address++;
} }
return AE_OK; return (AE_OK);
} }
...@@ -80,10 +80,10 @@ acpi_status acpi_reset(void) ...@@ -80,10 +80,10 @@ acpi_status acpi_reset(void)
if (reset_reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { if (reset_reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
/* /*
* For I/O space, write directly to the OSL. This * For I/O space, write directly to the OSL. This bypasses the port
* bypasses the port validation mechanism, which may * validation mechanism, which may block a valid write to the reset
* block a valid write to the reset register. Spec * register.
* section 4.7.3.6 requires register width to be 8. * Spec section 4.7.3.6 requires register width to be 8.
*/ */
status = status =
acpi_os_write_port((acpi_io_address) reset_reg->address, acpi_os_write_port((acpi_io_address) reset_reg->address,
...@@ -333,7 +333,7 @@ ACPI_EXPORT_SYMBOL(acpi_read_bit_register) ...@@ -333,7 +333,7 @@ ACPI_EXPORT_SYMBOL(acpi_read_bit_register)
* FUNCTION: acpi_write_bit_register * FUNCTION: acpi_write_bit_register
* *
* PARAMETERS: register_id - ID of ACPI Bit Register to access * PARAMETERS: register_id - ID of ACPI Bit Register to access
* Value - Value to write to the register, in bit * value - Value to write to the register, in bit
* position zero. The bit is automatically * position zero. The bit is automatically
* shifted to the correct position. * shifted to the correct position.
* *
......
...@@ -41,9 +41,9 @@ ...@@ -41,9 +41,9 @@
* POSSIBILITY OF SUCH DAMAGES. * POSSIBILITY OF SUCH DAMAGES.
*/ */
#include <linux/export.h>
#include <acpi/acpi.h> #include <acpi/acpi.h>
#include "accommon.h" #include "accommon.h"
#include <linux/module.h>
#define _COMPONENT ACPI_HARDWARE #define _COMPONENT ACPI_HARDWARE
ACPI_MODULE_NAME("hwxfsleep") ACPI_MODULE_NAME("hwxfsleep")
...@@ -207,7 +207,7 @@ acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void) ...@@ -207,7 +207,7 @@ acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
(u32)acpi_gbl_FADT.s4_bios_request, 8); (u32)acpi_gbl_FADT.s4_bios_request, 8);
do { do {
acpi_os_stall(1000); acpi_os_stall(ACPI_USEC_PER_MSEC);
status = status =
acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value); acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
...@@ -350,7 +350,7 @@ ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep) ...@@ -350,7 +350,7 @@ ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep)
* *
* RETURN: Status * RETURN: Status
* *
* DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231) * DESCRIPTION: Enter a system sleep state
* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
* *
******************************************************************************/ ******************************************************************************/
...@@ -382,8 +382,9 @@ ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state) ...@@ -382,8 +382,9 @@ ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state)
* RETURN: Status * RETURN: Status
* *
* DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
* sleep. * sleep. Called with interrupts DISABLED.
* Called with interrupts DISABLED. * We break wake/resume into 2 stages so that OSPM can handle
* various OS-specific tasks between the two steps.
* *
******************************************************************************/ ******************************************************************************/
acpi_status acpi_leave_sleep_state_prep(u8 sleep_state) acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <acpi/acpi.h> #include <acpi/acpi.h>
#include "accommon.h" #include "accommon.h"
#include "acnamesp.h" #include "acnamesp.h"
#include <acpi/acoutput.h>
#define _COMPONENT ACPI_NAMESPACE #define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME("nsdump") ACPI_MODULE_NAME("nsdump")
...@@ -77,8 +78,9 @@ void acpi_ns_print_pathname(u32 num_segments, char *pathname) ...@@ -77,8 +78,9 @@ void acpi_ns_print_pathname(u32 num_segments, char *pathname)
ACPI_FUNCTION_NAME(ns_print_pathname); ACPI_FUNCTION_NAME(ns_print_pathname);
if (!(acpi_dbg_level & ACPI_LV_NAMES) /* Check if debug output enabled */
|| !(acpi_dbg_layer & ACPI_NAMESPACE)) {
if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_NAMES, ACPI_NAMESPACE)) {
return; return;
} }
...@@ -127,7 +129,7 @@ acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component) ...@@ -127,7 +129,7 @@ acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component)
/* Do this only if the requested debug level and component are enabled */ /* Do this only if the requested debug level and component are enabled */
if (!(acpi_dbg_level & level) || !(acpi_dbg_layer & component)) { if (!ACPI_IS_DEBUG_ENABLED(level, component)) {
return_VOID; return_VOID;
} }
...@@ -729,5 +731,5 @@ void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth) ...@@ -729,5 +731,5 @@ void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth)
ACPI_OWNER_ID_MAX, search_handle); ACPI_OWNER_ID_MAX, search_handle);
return_VOID; return_VOID;
} }
#endif /* _ACPI_ASL_COMPILER */ #endif
#endif /* defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) */ #endif
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
*/ */
#include <acpi/acpi.h> #include <acpi/acpi.h>
#include "accommon.h"
/* TBD: This entire module is apparently obsolete and should be removed */ /* TBD: This entire module is apparently obsolete and should be removed */
......
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
#include "acnamesp.h" #include "acnamesp.h"
#include "acdispat.h" #include "acdispat.h"
#include "acinterp.h" #include "acinterp.h"
#include <linux/nmi.h>
#define _COMPONENT ACPI_NAMESPACE #define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME("nsinit") ACPI_MODULE_NAME("nsinit")
...@@ -87,7 +86,7 @@ acpi_status acpi_ns_initialize_objects(void) ...@@ -87,7 +86,7 @@ acpi_status acpi_ns_initialize_objects(void)
ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
"**** Starting initialization of namespace objects ****\n")); "**** Starting initialization of namespace objects ****\n"));
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
"Completing Region/Field/Buffer/Package initialization:")); "Completing Region/Field/Buffer/Package initialization:\n"));
/* Set all init info to zero */ /* Set all init info to zero */
...@@ -103,7 +102,7 @@ acpi_status acpi_ns_initialize_objects(void) ...@@ -103,7 +102,7 @@ acpi_status acpi_ns_initialize_objects(void)
} }
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
"\nInitialized %u/%u Regions %u/%u Fields %u/%u " " Initialized %u/%u Regions %u/%u Fields %u/%u "
"Buffers %u/%u Packages (%u nodes)\n", "Buffers %u/%u Packages (%u nodes)\n",
info.op_region_init, info.op_region_count, info.op_region_init, info.op_region_count,
info.field_init, info.field_count, info.field_init, info.field_count,
...@@ -150,7 +149,7 @@ acpi_status acpi_ns_initialize_devices(void) ...@@ -150,7 +149,7 @@ acpi_status acpi_ns_initialize_devices(void)
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
"Initializing Device/Processor/Thermal objects " "Initializing Device/Processor/Thermal objects "
"by executing _INI methods:")); "and executing _INI/_STA methods:\n"));
/* Tree analysis: find all subtrees that contain _INI methods */ /* Tree analysis: find all subtrees that contain _INI methods */
...@@ -208,7 +207,7 @@ acpi_status acpi_ns_initialize_devices(void) ...@@ -208,7 +207,7 @@ acpi_status acpi_ns_initialize_devices(void)
} }
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
"\nExecuted %u _INI methods requiring %u _STA executions " " Executed %u _INI methods requiring %u _STA executions "
"(examined %u objects)\n", "(examined %u objects)\n",
info.num_INI, info.num_STA, info.device_count)); info.num_INI, info.num_STA, info.device_count));
...@@ -349,14 +348,6 @@ acpi_ns_init_one_object(acpi_handle obj_handle, ...@@ -349,14 +348,6 @@ acpi_ns_init_one_object(acpi_handle obj_handle,
acpi_ut_get_type_name(type))); acpi_ut_get_type_name(type)));
} }
/*
* Print a dot for each object unless we are going to print the entire
* pathname
*/
if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
}
/* /*
* We ignore errors from above, and always return OK, since we don't want * We ignore errors from above, and always return OK, since we don't want
* to abort the walk on any single error. * to abort the walk on any single error.
...@@ -572,20 +563,10 @@ acpi_ns_init_one_device(acpi_handle obj_handle, ...@@ -572,20 +563,10 @@ acpi_ns_init_one_device(acpi_handle obj_handle,
info->parameters = NULL; info->parameters = NULL;
info->flags = ACPI_IGNORE_RETURN_VALUE; info->flags = ACPI_IGNORE_RETURN_VALUE;
/*
* Some hardware relies on this being executed as atomically
* as possible (without an NMI being received in the middle of
* this) - so disable NMIs and initialize the device:
*/
status = acpi_ns_evaluate(info); status = acpi_ns_evaluate(info);
if (ACPI_SUCCESS(status)) { if (ACPI_SUCCESS(status)) {
walk_info->num_INI++; walk_info->num_INI++;
if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) &&
(!(acpi_dbg_level & ACPI_LV_INFO))) {
ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
}
} }
#ifdef ACPI_DEBUG_OUTPUT #ifdef ACPI_DEBUG_OUTPUT
else if (status != AE_NOT_FOUND) { else if (status != AE_NOT_FOUND) {
......
...@@ -126,7 +126,8 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node, ...@@ -126,7 +126,8 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node,
* the node, In external format (name segments separated by path * the node, In external format (name segments separated by path
* separators.) * separators.)
* *
* DESCRIPTION: Used for debug printing in acpi_ns_search_table(). * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually
* for error and debug statements.
* *
******************************************************************************/ ******************************************************************************/
......
/****************************************************************************** /******************************************************************************
* *
* Module Name: nspredef - Validation of ACPI predefined methods and objects * Module Name: nspredef - Validation of ACPI predefined methods and objects
* $Revision: 1.1 $
* *
*****************************************************************************/ *****************************************************************************/
...@@ -73,27 +72,6 @@ ACPI_MODULE_NAME("nspredef") ...@@ -73,27 +72,6 @@ ACPI_MODULE_NAME("nspredef")
* *
******************************************************************************/ ******************************************************************************/
/* Local prototypes */ /* Local prototypes */
static acpi_status
acpi_ns_check_package(struct acpi_predefined_data *data,
union acpi_operand_object **return_object_ptr);
static acpi_status
acpi_ns_check_package_list(struct acpi_predefined_data *data,
const union acpi_predefined_info *package,
union acpi_operand_object **elements, u32 count);
static acpi_status
acpi_ns_check_package_elements(struct acpi_predefined_data *data,
union acpi_operand_object **elements,
u8 type1,
u32 count1,
u8 type2, u32 count2, u32 start_index);
static acpi_status
acpi_ns_check_object_type(struct acpi_predefined_data *data,
union acpi_operand_object **return_object_ptr,
u32 expected_btypes, u32 package_index);
static acpi_status static acpi_status
acpi_ns_check_reference(struct acpi_predefined_data *data, acpi_ns_check_reference(struct acpi_predefined_data *data,
union acpi_operand_object *return_object); union acpi_operand_object *return_object);
...@@ -148,7 +126,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, ...@@ -148,7 +126,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
pathname = acpi_ns_get_external_pathname(node); pathname = acpi_ns_get_external_pathname(node);
if (!pathname) { if (!pathname) {
return AE_OK; /* Could not get pathname, ignore */ return (AE_OK); /* Could not get pathname, ignore */
} }
/* /*
...@@ -406,564 +384,6 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct ...@@ -406,564 +384,6 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
return (NULL); /* Not found */ return (NULL); /* Not found */
} }
/*******************************************************************************
*
* FUNCTION: acpi_ns_check_package
*
* PARAMETERS: data - Pointer to validation data structure
* return_object_ptr - Pointer to the object returned from the
* evaluation of a method or object
*
* RETURN: Status
*
* DESCRIPTION: Check a returned package object for the correct count and
* correct type of all sub-objects.
*
******************************************************************************/
static acpi_status
acpi_ns_check_package(struct acpi_predefined_data *data,
union acpi_operand_object **return_object_ptr)
{
union acpi_operand_object *return_object = *return_object_ptr;
const union acpi_predefined_info *package;
union acpi_operand_object **elements;
acpi_status status = AE_OK;
u32 expected_count;
u32 count;
u32 i;
ACPI_FUNCTION_NAME(ns_check_package);
/* The package info for this name is in the next table entry */
package = data->predefined + 1;
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
"%s Validating return Package of Type %X, Count %X\n",
data->pathname, package->ret_info.type,
return_object->package.count));
/*
* For variable-length Packages, we can safely remove all embedded
* and trailing NULL package elements
*/
acpi_ns_remove_null_elements(data, package->ret_info.type,
return_object);
/* Extract package count and elements array */
elements = return_object->package.elements;
count = return_object->package.count;
/* The package must have at least one element, else invalid */
if (!count) {
ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
"Return Package has no elements (empty)"));
return (AE_AML_OPERAND_VALUE);
}
/*
* Decode the type of the expected package contents
*
* PTYPE1 packages contain no subpackages
* PTYPE2 packages contain sub-packages
*/
switch (package->ret_info.type) {
case ACPI_PTYPE1_FIXED:
/*
* The package count is fixed and there are no sub-packages
*
* If package is too small, exit.
* If package is larger than expected, issue warning but continue
*/
expected_count =
package->ret_info.count1 + package->ret_info.count2;
if (count < expected_count) {
goto package_too_small;
} else if (count > expected_count) {
ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
"%s: Return Package is larger than needed - "
"found %u, expected %u\n",
data->pathname, count,
expected_count));
}
/* Validate all elements of the returned package */
status = acpi_ns_check_package_elements(data, elements,
package->ret_info.
object_type1,
package->ret_info.
count1,
package->ret_info.
object_type2,
package->ret_info.
count2, 0);
break;
case ACPI_PTYPE1_VAR:
/*
* The package count is variable, there are no sub-packages, and all
* elements must be of the same type
*/
for (i = 0; i < count; i++) {
status = acpi_ns_check_object_type(data, elements,
package->ret_info.
object_type1, i);
if (ACPI_FAILURE(status)) {
return (status);
}
elements++;
}
break;
case ACPI_PTYPE1_OPTION:
/*
* The package count is variable, there are no sub-packages. There are
* a fixed number of required elements, and a variable number of
* optional elements.
*
* Check if package is at least as large as the minimum required
*/
expected_count = package->ret_info3.count;
if (count < expected_count) {
goto package_too_small;
}
/* Variable number of sub-objects */
for (i = 0; i < count; i++) {
if (i < package->ret_info3.count) {
/* These are the required package elements (0, 1, or 2) */
status =
acpi_ns_check_object_type(data, elements,
package->
ret_info3.
object_type[i],
i);
if (ACPI_FAILURE(status)) {
return (status);
}
} else {
/* These are the optional package elements */
status =
acpi_ns_check_object_type(data, elements,
package->
ret_info3.
tail_object_type,
i);
if (ACPI_FAILURE(status)) {
return (status);
}
}
elements++;
}
break;
case ACPI_PTYPE2_REV_FIXED:
/* First element is the (Integer) revision */
status = acpi_ns_check_object_type(data, elements,
ACPI_RTYPE_INTEGER, 0);
if (ACPI_FAILURE(status)) {
return (status);
}
elements++;
count--;
/* Examine the sub-packages */
status =
acpi_ns_check_package_list(data, package, elements, count);
break;
case ACPI_PTYPE2_PKG_COUNT:
/* First element is the (Integer) count of sub-packages to follow */
status = acpi_ns_check_object_type(data, elements,
ACPI_RTYPE_INTEGER, 0);
if (ACPI_FAILURE(status)) {
return (status);
}
/*
* Count cannot be larger than the parent package length, but allow it
* to be smaller. The >= accounts for the Integer above.
*/
expected_count = (u32) (*elements)->integer.value;
if (expected_count >= count) {
goto package_too_small;
}
count = expected_count;
elements++;
/* Examine the sub-packages */
status =
acpi_ns_check_package_list(data, package, elements, count);
break;
case ACPI_PTYPE2:
case ACPI_PTYPE2_FIXED:
case ACPI_PTYPE2_MIN:
case ACPI_PTYPE2_COUNT:
case ACPI_PTYPE2_FIX_VAR:
/*
* These types all return a single Package that consists of a
* variable number of sub-Packages.
*
* First, ensure that the first element is a sub-Package. If not,
* the BIOS may have incorrectly returned the object as a single
* package instead of a Package of Packages (a common error if
* there is only one entry). We may be able to repair this by
* wrapping the returned Package with a new outer Package.
*/
if (*elements
&& ((*elements)->common.type != ACPI_TYPE_PACKAGE)) {
/* Create the new outer package and populate it */
status =
acpi_ns_wrap_with_package(data, return_object,
return_object_ptr);
if (ACPI_FAILURE(status)) {
return (status);
}
/* Update locals to point to the new package (of 1 element) */
return_object = *return_object_ptr;
elements = return_object->package.elements;
count = 1;
}
/* Examine the sub-packages */
status =
acpi_ns_check_package_list(data, package, elements, count);
break;
default:
/* Should not get here if predefined info table is correct */
ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
"Invalid internal return type in table entry: %X",
package->ret_info.type));
return (AE_AML_INTERNAL);
}
return (status);
package_too_small:
/* Error exit for the case with an incorrect package count */
ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
"Return Package is too small - found %u elements, expected %u",
count, expected_count));
return (AE_AML_OPERAND_VALUE);
}
/*******************************************************************************
*
* FUNCTION: acpi_ns_check_package_list
*
* PARAMETERS: data - Pointer to validation data structure
* package - Pointer to package-specific info for method
* elements - Element list of parent package. All elements
* of this list should be of type Package.
* count - Count of subpackages
*
* RETURN: Status
*
* DESCRIPTION: Examine a list of subpackages
*
******************************************************************************/
static acpi_status
acpi_ns_check_package_list(struct acpi_predefined_data *data,
const union acpi_predefined_info *package,
union acpi_operand_object **elements, u32 count)
{
union acpi_operand_object *sub_package;
union acpi_operand_object **sub_elements;
acpi_status status;
u32 expected_count;
u32 i;
u32 j;
/*
* Validate each sub-Package in the parent Package
*
* NOTE: assumes list of sub-packages contains no NULL elements.
* Any NULL elements should have been removed by earlier call
* to acpi_ns_remove_null_elements.
*/
for (i = 0; i < count; i++) {
sub_package = *elements;
sub_elements = sub_package->package.elements;
data->parent_package = sub_package;
/* Each sub-object must be of type Package */
status = acpi_ns_check_object_type(data, &sub_package,
ACPI_RTYPE_PACKAGE, i);
if (ACPI_FAILURE(status)) {
return (status);
}
/* Examine the different types of expected sub-packages */
data->parent_package = sub_package;
switch (package->ret_info.type) {
case ACPI_PTYPE2:
case ACPI_PTYPE2_PKG_COUNT:
case ACPI_PTYPE2_REV_FIXED:
/* Each subpackage has a fixed number of elements */
expected_count =
package->ret_info.count1 + package->ret_info.count2;
if (sub_package->package.count < expected_count) {
goto package_too_small;
}
status =
acpi_ns_check_package_elements(data, sub_elements,
package->ret_info.
object_type1,
package->ret_info.
count1,
package->ret_info.
object_type2,
package->ret_info.
count2, 0);
if (ACPI_FAILURE(status)) {
return (status);
}
break;
case ACPI_PTYPE2_FIX_VAR:
/*
* Each subpackage has a fixed number of elements and an
* optional element
*/
expected_count =
package->ret_info.count1 + package->ret_info.count2;
if (sub_package->package.count < expected_count) {
goto package_too_small;
}
status =
acpi_ns_check_package_elements(data, sub_elements,
package->ret_info.
object_type1,
package->ret_info.
count1,
package->ret_info.
object_type2,
sub_package->package.
count -
package->ret_info.
count1, 0);
if (ACPI_FAILURE(status)) {
return (status);
}
break;
case ACPI_PTYPE2_FIXED:
/* Each sub-package has a fixed length */
expected_count = package->ret_info2.count;
if (sub_package->package.count < expected_count) {
goto package_too_small;
}
/* Check the type of each sub-package element */
for (j = 0; j < expected_count; j++) {
status =
acpi_ns_check_object_type(data,
&sub_elements[j],
package->
ret_info2.
object_type[j],
j);
if (ACPI_FAILURE(status)) {
return (status);
}
}
break;
case ACPI_PTYPE2_MIN:
/* Each sub-package has a variable but minimum length */
expected_count = package->ret_info.count1;
if (sub_package->package.count < expected_count) {
goto package_too_small;
}
/* Check the type of each sub-package element */
status =
acpi_ns_check_package_elements(data, sub_elements,
package->ret_info.
object_type1,
sub_package->package.
count, 0, 0, 0);
if (ACPI_FAILURE(status)) {
return (status);
}
break;
case ACPI_PTYPE2_COUNT:
/*
* First element is the (Integer) count of elements, including
* the count field (the ACPI name is num_elements)
*/
status = acpi_ns_check_object_type(data, sub_elements,
ACPI_RTYPE_INTEGER,
0);
if (ACPI_FAILURE(status)) {
return (status);
}
/*
* Make sure package is large enough for the Count and is
* is as large as the minimum size
*/
expected_count = (u32)(*sub_elements)->integer.value;
if (sub_package->package.count < expected_count) {
goto package_too_small;
}
if (sub_package->package.count <
package->ret_info.count1) {
expected_count = package->ret_info.count1;
goto package_too_small;
}
if (expected_count == 0) {
/*
* Either the num_entries element was originally zero or it was
* a NULL element and repaired to an Integer of value zero.
* In either case, repair it by setting num_entries to be the
* actual size of the subpackage.
*/
expected_count = sub_package->package.count;
(*sub_elements)->integer.value = expected_count;
}
/* Check the type of each sub-package element */
status =
acpi_ns_check_package_elements(data,
(sub_elements + 1),
package->ret_info.
object_type1,
(expected_count - 1),
0, 0, 1);
if (ACPI_FAILURE(status)) {
return (status);
}
break;
default: /* Should not get here, type was validated by caller */
return (AE_AML_INTERNAL);
}
elements++;
}
return (AE_OK);
package_too_small:
/* The sub-package count was smaller than required */
ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
"Return Sub-Package[%u] is too small - found %u elements, expected %u",
i, sub_package->package.count, expected_count));
return (AE_AML_OPERAND_VALUE);
}
/*******************************************************************************
*
* FUNCTION: acpi_ns_check_package_elements
*
* PARAMETERS: data - Pointer to validation data structure
* elements - Pointer to the package elements array
* type1 - Object type for first group
* count1 - Count for first group
* type2 - Object type for second group
* count2 - Count for second group
* start_index - Start of the first group of elements
*
* RETURN: Status
*
* DESCRIPTION: Check that all elements of a package are of the correct object
* type. Supports up to two groups of different object types.
*
******************************************************************************/
static acpi_status
acpi_ns_check_package_elements(struct acpi_predefined_data *data,
union acpi_operand_object **elements,
u8 type1,
u32 count1,
u8 type2, u32 count2, u32 start_index)
{
union acpi_operand_object **this_element = elements;
acpi_status status;
u32 i;
/*
* Up to two groups of package elements are supported by the data
* structure. All elements in each group must be of the same type.
* The second group can have a count of zero.
*/
for (i = 0; i < count1; i++) {
status = acpi_ns_check_object_type(data, this_element,
type1, i + start_index);
if (ACPI_FAILURE(status)) {
return (status);
}
this_element++;
}
for (i = 0; i < count2; i++) {
status = acpi_ns_check_object_type(data, this_element,
type2,
(i + count1 + start_index));
if (ACPI_FAILURE(status)) {
return (status);
}
this_element++;
}
return (AE_OK);
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ns_check_object_type * FUNCTION: acpi_ns_check_object_type
...@@ -983,7 +403,7 @@ acpi_ns_check_package_elements(struct acpi_predefined_data *data, ...@@ -983,7 +403,7 @@ acpi_ns_check_package_elements(struct acpi_predefined_data *data,
* *
******************************************************************************/ ******************************************************************************/
static acpi_status acpi_status
acpi_ns_check_object_type(struct acpi_predefined_data *data, acpi_ns_check_object_type(struct acpi_predefined_data *data,
union acpi_operand_object **return_object_ptr, union acpi_operand_object **return_object_ptr,
u32 expected_btypes, u32 package_index) u32 expected_btypes, u32 package_index)
......
/******************************************************************************
*
* Module Name: nsprepkg - Validation of package objects for predefined names
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2012, Intel Corp.
* 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 <acpi/acpi.h>
#include "accommon.h"
#include "acnamesp.h"
#include "acpredef.h"
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME("nsprepkg")
/* Local prototypes */
static acpi_status
acpi_ns_check_package_list(struct acpi_predefined_data *data,
const union acpi_predefined_info *package,
union acpi_operand_object **elements, u32 count);
static acpi_status
acpi_ns_check_package_elements(struct acpi_predefined_data *data,
union acpi_operand_object **elements,
u8 type1,
u32 count1,
u8 type2, u32 count2, u32 start_index);
/*******************************************************************************
*
* FUNCTION: acpi_ns_check_package
*
* PARAMETERS: data - Pointer to validation data structure
* return_object_ptr - Pointer to the object returned from the
* evaluation of a method or object
*
* RETURN: Status
*
* DESCRIPTION: Check a returned package object for the correct count and
* correct type of all sub-objects.
*
******************************************************************************/
acpi_status
acpi_ns_check_package(struct acpi_predefined_data *data,
union acpi_operand_object **return_object_ptr)
{
union acpi_operand_object *return_object = *return_object_ptr;
const union acpi_predefined_info *package;
union acpi_operand_object **elements;
acpi_status status = AE_OK;
u32 expected_count;
u32 count;
u32 i;
ACPI_FUNCTION_NAME(ns_check_package);
/* The package info for this name is in the next table entry */
package = data->predefined + 1;
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
"%s Validating return Package of Type %X, Count %X\n",
data->pathname, package->ret_info.type,
return_object->package.count));
/*
* For variable-length Packages, we can safely remove all embedded
* and trailing NULL package elements
*/
acpi_ns_remove_null_elements(data, package->ret_info.type,
return_object);
/* Extract package count and elements array */
elements = return_object->package.elements;
count = return_object->package.count;
/* The package must have at least one element, else invalid */
if (!count) {
ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
"Return Package has no elements (empty)"));
return (AE_AML_OPERAND_VALUE);
}
/*
* Decode the type of the expected package contents
*
* PTYPE1 packages contain no subpackages
* PTYPE2 packages contain sub-packages
*/
switch (package->ret_info.type) {
case ACPI_PTYPE1_FIXED:
/*
* The package count is fixed and there are no sub-packages
*
* If package is too small, exit.
* If package is larger than expected, issue warning but continue
*/
expected_count =
package->ret_info.count1 + package->ret_info.count2;
if (count < expected_count) {
goto package_too_small;
} else if (count > expected_count) {
ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
"%s: Return Package is larger than needed - "
"found %u, expected %u\n",
data->pathname, count,
expected_count));
}
/* Validate all elements of the returned package */
status = acpi_ns_check_package_elements(data, elements,
package->ret_info.
object_type1,
package->ret_info.
count1,
package->ret_info.
object_type2,
package->ret_info.
count2, 0);
break;
case ACPI_PTYPE1_VAR:
/*
* The package count is variable, there are no sub-packages, and all
* elements must be of the same type
*/
for (i = 0; i < count; i++) {
status = acpi_ns_check_object_type(data, elements,
package->ret_info.
object_type1, i);
if (ACPI_FAILURE(status)) {
return (status);
}
elements++;
}
break;
case ACPI_PTYPE1_OPTION:
/*
* The package count is variable, there are no sub-packages. There are
* a fixed number of required elements, and a variable number of
* optional elements.
*
* Check if package is at least as large as the minimum required
*/
expected_count = package->ret_info3.count;
if (count < expected_count) {
goto package_too_small;
}
/* Variable number of sub-objects */
for (i = 0; i < count; i++) {
if (i < package->ret_info3.count) {
/* These are the required package elements (0, 1, or 2) */
status =
acpi_ns_check_object_type(data, elements,
package->
ret_info3.
object_type[i],
i);
if (ACPI_FAILURE(status)) {
return (status);
}
} else {
/* These are the optional package elements */
status =
acpi_ns_check_object_type(data, elements,
package->
ret_info3.
tail_object_type,
i);
if (ACPI_FAILURE(status)) {
return (status);
}
}
elements++;
}
break;
case ACPI_PTYPE2_REV_FIXED:
/* First element is the (Integer) revision */
status = acpi_ns_check_object_type(data, elements,
ACPI_RTYPE_INTEGER, 0);
if (ACPI_FAILURE(status)) {
return (status);
}
elements++;
count--;
/* Examine the sub-packages */
status =
acpi_ns_check_package_list(data, package, elements, count);
break;
case ACPI_PTYPE2_PKG_COUNT:
/* First element is the (Integer) count of sub-packages to follow */
status = acpi_ns_check_object_type(data, elements,
ACPI_RTYPE_INTEGER, 0);
if (ACPI_FAILURE(status)) {
return (status);
}
/*
* Count cannot be larger than the parent package length, but allow it
* to be smaller. The >= accounts for the Integer above.
*/
expected_count = (u32)(*elements)->integer.value;
if (expected_count >= count) {
goto package_too_small;
}
count = expected_count;
elements++;
/* Examine the sub-packages */
status =
acpi_ns_check_package_list(data, package, elements, count);
break;
case ACPI_PTYPE2:
case ACPI_PTYPE2_FIXED:
case ACPI_PTYPE2_MIN:
case ACPI_PTYPE2_COUNT:
case ACPI_PTYPE2_FIX_VAR:
/*
* These types all return a single Package that consists of a
* variable number of sub-Packages.
*
* First, ensure that the first element is a sub-Package. If not,
* the BIOS may have incorrectly returned the object as a single
* package instead of a Package of Packages (a common error if
* there is only one entry). We may be able to repair this by
* wrapping the returned Package with a new outer Package.
*/
if (*elements
&& ((*elements)->common.type != ACPI_TYPE_PACKAGE)) {
/* Create the new outer package and populate it */
status =
acpi_ns_wrap_with_package(data, return_object,
return_object_ptr);
if (ACPI_FAILURE(status)) {
return (status);
}
/* Update locals to point to the new package (of 1 element) */
return_object = *return_object_ptr;
elements = return_object->package.elements;
count = 1;
}
/* Examine the sub-packages */
status =
acpi_ns_check_package_list(data, package, elements, count);
break;
default:
/* Should not get here if predefined info table is correct */
ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
"Invalid internal return type in table entry: %X",
package->ret_info.type));
return (AE_AML_INTERNAL);
}
return (status);
package_too_small:
/* Error exit for the case with an incorrect package count */
ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
"Return Package is too small - found %u elements, expected %u",
count, expected_count));
return (AE_AML_OPERAND_VALUE);
}
/*******************************************************************************
*
* FUNCTION: acpi_ns_check_package_list
*
* PARAMETERS: data - Pointer to validation data structure
* package - Pointer to package-specific info for method
* elements - Element list of parent package. All elements
* of this list should be of type Package.
* count - Count of subpackages
*
* RETURN: Status
*
* DESCRIPTION: Examine a list of subpackages
*
******************************************************************************/
static acpi_status
acpi_ns_check_package_list(struct acpi_predefined_data *data,
const union acpi_predefined_info *package,
union acpi_operand_object **elements, u32 count)
{
union acpi_operand_object *sub_package;
union acpi_operand_object **sub_elements;
acpi_status status;
u32 expected_count;
u32 i;
u32 j;
/*
* Validate each sub-Package in the parent Package
*
* NOTE: assumes list of sub-packages contains no NULL elements.
* Any NULL elements should have been removed by earlier call
* to acpi_ns_remove_null_elements.
*/
for (i = 0; i < count; i++) {
sub_package = *elements;
sub_elements = sub_package->package.elements;
data->parent_package = sub_package;
/* Each sub-object must be of type Package */
status = acpi_ns_check_object_type(data, &sub_package,
ACPI_RTYPE_PACKAGE, i);
if (ACPI_FAILURE(status)) {
return (status);
}
/* Examine the different types of expected sub-packages */
data->parent_package = sub_package;
switch (package->ret_info.type) {
case ACPI_PTYPE2:
case ACPI_PTYPE2_PKG_COUNT:
case ACPI_PTYPE2_REV_FIXED:
/* Each subpackage has a fixed number of elements */
expected_count =
package->ret_info.count1 + package->ret_info.count2;
if (sub_package->package.count < expected_count) {
goto package_too_small;
}
status =
acpi_ns_check_package_elements(data, sub_elements,
package->ret_info.
object_type1,
package->ret_info.
count1,
package->ret_info.
object_type2,
package->ret_info.
count2, 0);
if (ACPI_FAILURE(status)) {
return (status);
}
break;
case ACPI_PTYPE2_FIX_VAR:
/*
* Each subpackage has a fixed number of elements and an
* optional element
*/
expected_count =
package->ret_info.count1 + package->ret_info.count2;
if (sub_package->package.count < expected_count) {
goto package_too_small;
}
status =
acpi_ns_check_package_elements(data, sub_elements,
package->ret_info.
object_type1,
package->ret_info.
count1,
package->ret_info.
object_type2,
sub_package->package.
count -
package->ret_info.
count1, 0);
if (ACPI_FAILURE(status)) {
return (status);
}
break;
case ACPI_PTYPE2_FIXED:
/* Each sub-package has a fixed length */
expected_count = package->ret_info2.count;
if (sub_package->package.count < expected_count) {
goto package_too_small;
}
/* Check the type of each sub-package element */
for (j = 0; j < expected_count; j++) {
status =
acpi_ns_check_object_type(data,
&sub_elements[j],
package->
ret_info2.
object_type[j],
j);
if (ACPI_FAILURE(status)) {
return (status);
}
}
break;
case ACPI_PTYPE2_MIN:
/* Each sub-package has a variable but minimum length */
expected_count = package->ret_info.count1;
if (sub_package->package.count < expected_count) {
goto package_too_small;
}
/* Check the type of each sub-package element */
status =
acpi_ns_check_package_elements(data, sub_elements,
package->ret_info.
object_type1,
sub_package->package.
count, 0, 0, 0);
if (ACPI_FAILURE(status)) {
return (status);
}
break;
case ACPI_PTYPE2_COUNT:
/*
* First element is the (Integer) count of elements, including
* the count field (the ACPI name is num_elements)
*/
status = acpi_ns_check_object_type(data, sub_elements,
ACPI_RTYPE_INTEGER,
0);
if (ACPI_FAILURE(status)) {
return (status);
}
/*
* Make sure package is large enough for the Count and is
* is as large as the minimum size
*/
expected_count = (u32)(*sub_elements)->integer.value;
if (sub_package->package.count < expected_count) {
goto package_too_small;
}
if (sub_package->package.count <
package->ret_info.count1) {
expected_count = package->ret_info.count1;
goto package_too_small;
}
if (expected_count == 0) {
/*
* Either the num_entries element was originally zero or it was
* a NULL element and repaired to an Integer of value zero.
* In either case, repair it by setting num_entries to be the
* actual size of the subpackage.
*/
expected_count = sub_package->package.count;
(*sub_elements)->integer.value = expected_count;
}
/* Check the type of each sub-package element */
status =
acpi_ns_check_package_elements(data,
(sub_elements + 1),
package->ret_info.
object_type1,
(expected_count - 1),
0, 0, 1);
if (ACPI_FAILURE(status)) {
return (status);
}
break;
default: /* Should not get here, type was validated by caller */
return (AE_AML_INTERNAL);
}
elements++;
}
return (AE_OK);
package_too_small:
/* The sub-package count was smaller than required */
ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
"Return Sub-Package[%u] is too small - found %u elements, expected %u",
i, sub_package->package.count, expected_count));
return (AE_AML_OPERAND_VALUE);
}
/*******************************************************************************
*
* FUNCTION: acpi_ns_check_package_elements
*
* PARAMETERS: data - Pointer to validation data structure
* elements - Pointer to the package elements array
* type1 - Object type for first group
* count1 - Count for first group
* type2 - Object type for second group
* count2 - Count for second group
* start_index - Start of the first group of elements
*
* RETURN: Status
*
* DESCRIPTION: Check that all elements of a package are of the correct object
* type. Supports up to two groups of different object types.
*
******************************************************************************/
static acpi_status
acpi_ns_check_package_elements(struct acpi_predefined_data *data,
union acpi_operand_object **elements,
u8 type1,
u32 count1,
u8 type2, u32 count2, u32 start_index)
{
union acpi_operand_object **this_element = elements;
acpi_status status;
u32 i;
/*
* Up to two groups of package elements are supported by the data
* structure. All elements in each group must be of the same type.
* The second group can have a count of zero.
*/
for (i = 0; i < count1; i++) {
status = acpi_ns_check_object_type(data, this_element,
type1, i + start_index);
if (ACPI_FAILURE(status)) {
return (status);
}
this_element++;
}
for (i = 0; i < count2; i++) {
status = acpi_ns_check_object_type(data, this_element,
type2,
(i + count1 + start_index));
if (ACPI_FAILURE(status)) {
return (status);
}
this_element++;
}
return (AE_OK);
}
...@@ -55,7 +55,8 @@ ACPI_MODULE_NAME("nsrepair2") ...@@ -55,7 +55,8 @@ ACPI_MODULE_NAME("nsrepair2")
*/ */
typedef typedef
acpi_status(*acpi_repair_function) (struct acpi_predefined_data *data, acpi_status(*acpi_repair_function) (struct acpi_predefined_data *data,
union acpi_operand_object **return_object_ptr); union acpi_operand_object
**return_object_ptr);
typedef struct acpi_repair_info { typedef struct acpi_repair_info {
char name[ACPI_NAME_SIZE]; char name[ACPI_NAME_SIZE];
......
...@@ -328,6 +328,11 @@ acpi_ns_search_and_enter(u32 target_name, ...@@ -328,6 +328,11 @@ acpi_ns_search_and_enter(u32 target_name,
if ((status == AE_OK) && (flags & ACPI_NS_ERROR_IF_FOUND)) { if ((status == AE_OK) && (flags & ACPI_NS_ERROR_IF_FOUND)) {
status = AE_ALREADY_EXISTS; status = AE_ALREADY_EXISTS;
} }
#ifdef ACPI_ASL_COMPILER
if (*return_node && (*return_node)->type == ACPI_TYPE_ANY) {
(*return_node)->flags |= ANOBJ_IS_EXTERNAL;
}
#endif
/* Either found it or there was an error: finished either way */ /* Either found it or there was an error: finished either way */
......
...@@ -46,14 +46,11 @@ ...@@ -46,14 +46,11 @@
#include "accommon.h" #include "accommon.h"
#include "acnamesp.h" #include "acnamesp.h"
#include "amlcode.h" #include "amlcode.h"
#include "actables.h"
#define _COMPONENT ACPI_NAMESPACE #define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME("nsutils") ACPI_MODULE_NAME("nsutils")
/* Local prototypes */ /* Local prototypes */
static u8 acpi_ns_valid_path_separator(char sep);
#ifdef ACPI_OBSOLETE_FUNCTIONS #ifdef ACPI_OBSOLETE_FUNCTIONS
acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search); acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search);
#endif #endif
...@@ -97,42 +94,6 @@ acpi_ns_print_node_pathname(struct acpi_namespace_node *node, ...@@ -97,42 +94,6 @@ acpi_ns_print_node_pathname(struct acpi_namespace_node *node,
} }
} }
/*******************************************************************************
*
* FUNCTION: acpi_ns_valid_root_prefix
*
* PARAMETERS: prefix - Character to be checked
*
* RETURN: TRUE if a valid prefix
*
* DESCRIPTION: Check if a character is a valid ACPI Root prefix
*
******************************************************************************/
u8 acpi_ns_valid_root_prefix(char prefix)
{
return ((u8) (prefix == '\\'));
}
/*******************************************************************************
*
* FUNCTION: acpi_ns_valid_path_separator
*
* PARAMETERS: sep - Character to be checked
*
* RETURN: TRUE if a valid path separator
*
* DESCRIPTION: Check if a character is a valid ACPI path separator
*
******************************************************************************/
static u8 acpi_ns_valid_path_separator(char sep)
{
return ((u8) (sep == '.'));
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ns_get_type * FUNCTION: acpi_ns_get_type
...@@ -151,10 +112,10 @@ acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node) ...@@ -151,10 +112,10 @@ acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node)
if (!node) { if (!node) {
ACPI_WARNING((AE_INFO, "Null Node parameter")); ACPI_WARNING((AE_INFO, "Null Node parameter"));
return_UINT32(ACPI_TYPE_ANY); return_VALUE(ACPI_TYPE_ANY);
} }
return_UINT32((acpi_object_type) node->type); return_VALUE(node->type);
} }
/******************************************************************************* /*******************************************************************************
...@@ -179,10 +140,10 @@ u32 acpi_ns_local(acpi_object_type type) ...@@ -179,10 +140,10 @@ u32 acpi_ns_local(acpi_object_type type)
/* Type code out of range */ /* Type code out of range */
ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type)); ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type));
return_UINT32(ACPI_NS_NORMAL); return_VALUE(ACPI_NS_NORMAL);
} }
return_UINT32((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); return_VALUE(acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
} }
/******************************************************************************* /*******************************************************************************
...@@ -218,19 +179,19 @@ void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info) ...@@ -218,19 +179,19 @@ void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info)
* *
* strlen() + 1 covers the first name_seg, which has no path separator * strlen() + 1 covers the first name_seg, which has no path separator
*/ */
if (acpi_ns_valid_root_prefix(*next_external_char)) { if (ACPI_IS_ROOT_PREFIX(*next_external_char)) {
info->fully_qualified = TRUE; info->fully_qualified = TRUE;
next_external_char++; next_external_char++;
/* Skip redundant root_prefix, like \\_SB.PCI0.SBRG.EC0 */ /* Skip redundant root_prefix, like \\_SB.PCI0.SBRG.EC0 */
while (acpi_ns_valid_root_prefix(*next_external_char)) { while (ACPI_IS_ROOT_PREFIX(*next_external_char)) {
next_external_char++; next_external_char++;
} }
} else { } else {
/* Handle Carat prefixes */ /* Handle Carat prefixes */
while (*next_external_char == '^') { while (ACPI_IS_PARENT_PREFIX(*next_external_char)) {
info->num_carats++; info->num_carats++;
next_external_char++; next_external_char++;
} }
...@@ -244,7 +205,7 @@ void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info) ...@@ -244,7 +205,7 @@ void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info)
if (*next_external_char) { if (*next_external_char) {
info->num_segments = 1; info->num_segments = 1;
for (i = 0; next_external_char[i]; i++) { for (i = 0; next_external_char[i]; i++) {
if (acpi_ns_valid_path_separator(next_external_char[i])) { if (ACPI_IS_PATH_SEPARATOR(next_external_char[i])) {
info->num_segments++; info->num_segments++;
} }
} }
...@@ -282,7 +243,7 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info) ...@@ -282,7 +243,7 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
/* Setup the correct prefixes, counts, and pointers */ /* Setup the correct prefixes, counts, and pointers */
if (info->fully_qualified) { if (info->fully_qualified) {
internal_name[0] = '\\'; internal_name[0] = AML_ROOT_PREFIX;
if (num_segments <= 1) { if (num_segments <= 1) {
result = &internal_name[1]; result = &internal_name[1];
...@@ -302,7 +263,7 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info) ...@@ -302,7 +263,7 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
i = 0; i = 0;
if (info->num_carats) { if (info->num_carats) {
for (i = 0; i < info->num_carats; i++) { for (i = 0; i < info->num_carats; i++) {
internal_name[i] = '^'; internal_name[i] = AML_PARENT_PREFIX;
} }
} }
...@@ -322,7 +283,7 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info) ...@@ -322,7 +283,7 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
for (; num_segments; num_segments--) { for (; num_segments; num_segments--) {
for (i = 0; i < ACPI_NAME_SIZE; i++) { for (i = 0; i < ACPI_NAME_SIZE; i++) {
if (acpi_ns_valid_path_separator(*external_name) || if (ACPI_IS_PATH_SEPARATOR(*external_name) ||
(*external_name == 0)) { (*external_name == 0)) {
/* Pad the segment with underscore(s) if segment is short */ /* Pad the segment with underscore(s) if segment is short */
...@@ -339,7 +300,7 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info) ...@@ -339,7 +300,7 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
/* Now we must have a path separator, or the pathname is bad */ /* Now we must have a path separator, or the pathname is bad */
if (!acpi_ns_valid_path_separator(*external_name) && if (!ACPI_IS_PATH_SEPARATOR(*external_name) &&
(*external_name != 0)) { (*external_name != 0)) {
return_ACPI_STATUS(AE_BAD_PATHNAME); return_ACPI_STATUS(AE_BAD_PATHNAME);
} }
...@@ -457,13 +418,13 @@ acpi_ns_externalize_name(u32 internal_name_length, ...@@ -457,13 +418,13 @@ acpi_ns_externalize_name(u32 internal_name_length,
/* Check for a prefix (one '\' | one or more '^') */ /* Check for a prefix (one '\' | one or more '^') */
switch (internal_name[0]) { switch (internal_name[0]) {
case '\\': case AML_ROOT_PREFIX:
prefix_length = 1; prefix_length = 1;
break; break;
case '^': case AML_PARENT_PREFIX:
for (i = 0; i < internal_name_length; i++) { for (i = 0; i < internal_name_length; i++) {
if (internal_name[i] == '^') { if (ACPI_IS_PARENT_PREFIX(internal_name[i])) {
prefix_length = i + 1; prefix_length = i + 1;
} else { } else {
break; break;
...@@ -664,17 +625,17 @@ void acpi_ns_terminate(void) ...@@ -664,17 +625,17 @@ void acpi_ns_terminate(void)
u32 acpi_ns_opens_scope(acpi_object_type type) u32 acpi_ns_opens_scope(acpi_object_type type)
{ {
ACPI_FUNCTION_TRACE_STR(ns_opens_scope, acpi_ut_get_type_name(type)); ACPI_FUNCTION_ENTRY();
if (!acpi_ut_valid_object_type(type)) { if (type > ACPI_TYPE_LOCAL_MAX) {
/* type code out of range */ /* type code out of range */
ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type)); ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type));
return_UINT32(ACPI_NS_NORMAL); return (ACPI_NS_NORMAL);
} }
return_UINT32(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE); return (((u32)acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
} }
/******************************************************************************* /*******************************************************************************
...@@ -710,6 +671,8 @@ acpi_ns_get_node(struct acpi_namespace_node *prefix_node, ...@@ -710,6 +671,8 @@ acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
ACPI_FUNCTION_TRACE_PTR(ns_get_node, ACPI_CAST_PTR(char, pathname)); ACPI_FUNCTION_TRACE_PTR(ns_get_node, ACPI_CAST_PTR(char, pathname));
/* Simplest case is a null pathname */
if (!pathname) { if (!pathname) {
*return_node = prefix_node; *return_node = prefix_node;
if (!prefix_node) { if (!prefix_node) {
...@@ -718,6 +681,13 @@ acpi_ns_get_node(struct acpi_namespace_node *prefix_node, ...@@ -718,6 +681,13 @@ acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
return_ACPI_STATUS(AE_OK); return_ACPI_STATUS(AE_OK);
} }
/* Quick check for a reference to the root */
if (ACPI_IS_ROOT_PREFIX(pathname[0]) && (!pathname[1])) {
*return_node = acpi_gbl_root_node;
return_ACPI_STATUS(AE_OK);
}
/* Convert path to internal representation */ /* Convert path to internal representation */
status = acpi_ns_internalize_name(pathname, &internal_path); status = acpi_ns_internalize_name(pathname, &internal_path);
......
...@@ -76,12 +76,12 @@ struct acpi_namespace_node *acpi_ns_get_next_node(struct acpi_namespace_node ...@@ -76,12 +76,12 @@ struct acpi_namespace_node *acpi_ns_get_next_node(struct acpi_namespace_node
/* It's really the parent's _scope_ that we want */ /* It's really the parent's _scope_ that we want */
return parent_node->child; return (parent_node->child);
} }
/* Otherwise just return the next peer */ /* Otherwise just return the next peer */
return child_node->peer; return (child_node->peer);
} }
/******************************************************************************* /*******************************************************************************
......
...@@ -236,7 +236,7 @@ acpi_evaluate_object(acpi_handle handle, ...@@ -236,7 +236,7 @@ acpi_evaluate_object(acpi_handle handle,
* 2) No handle, not fully qualified pathname (error) * 2) No handle, not fully qualified pathname (error)
* 3) Valid handle * 3) Valid handle
*/ */
if ((pathname) && (acpi_ns_valid_root_prefix(pathname[0]))) { if ((pathname) && (ACPI_IS_ROOT_PREFIX(pathname[0]))) {
/* The path is fully qualified, just evaluate by name */ /* The path is fully qualified, just evaluate by name */
...@@ -492,7 +492,7 @@ acpi_walk_namespace(acpi_object_type type, ...@@ -492,7 +492,7 @@ acpi_walk_namespace(acpi_object_type type,
*/ */
status = acpi_ut_acquire_read_lock(&acpi_gbl_namespace_rw_lock); status = acpi_ut_acquire_read_lock(&acpi_gbl_namespace_rw_lock);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return status; return_ACPI_STATUS(status);
} }
/* /*
...@@ -550,7 +550,7 @@ acpi_ns_get_device_callback(acpi_handle obj_handle, ...@@ -550,7 +550,7 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status); return (status);
} }
node = acpi_ns_validate_handle(obj_handle); node = acpi_ns_validate_handle(obj_handle);
...@@ -602,17 +602,22 @@ acpi_ns_get_device_callback(acpi_handle obj_handle, ...@@ -602,17 +602,22 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
/* Walk the CID list */ /* Walk the CID list */
found = 0; found = FALSE;
for (i = 0; i < cid->count; i++) { for (i = 0; i < cid->count; i++) {
if (ACPI_STRCMP(cid->ids[i].string, info->hid) if (ACPI_STRCMP(cid->ids[i].string, info->hid)
== 0) { == 0) {
found = 1;
/* Found a matching CID */
found = TRUE;
break; break;
} }
} }
ACPI_FREE(cid); ACPI_FREE(cid);
if (!found) if (!found) {
return (AE_OK); return (AE_OK);
}
} }
} }
......
...@@ -107,7 +107,7 @@ acpi_get_handle(acpi_handle parent, ...@@ -107,7 +107,7 @@ acpi_get_handle(acpi_handle parent,
* *
* Error for <null Parent + relative path> * Error for <null Parent + relative path>
*/ */
if (acpi_ns_valid_root_prefix(pathname[0])) { if (ACPI_IS_ROOT_PREFIX(pathname[0])) {
/* Pathname is fully qualified (starts with '\') */ /* Pathname is fully qualified (starts with '\') */
...@@ -290,7 +290,7 @@ acpi_get_object_info(acpi_handle handle, ...@@ -290,7 +290,7 @@ acpi_get_object_info(acpi_handle handle,
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
goto cleanup; return (status);
} }
node = acpi_ns_validate_handle(handle); node = acpi_ns_validate_handle(handle);
...@@ -539,14 +539,14 @@ acpi_status acpi_install_method(u8 *buffer) ...@@ -539,14 +539,14 @@ acpi_status acpi_install_method(u8 *buffer)
/* Parameter validation */ /* Parameter validation */
if (!buffer) { if (!buffer) {
return AE_BAD_PARAMETER; return (AE_BAD_PARAMETER);
} }
/* Table must be a DSDT or SSDT */ /* Table must be a DSDT or SSDT */
if (!ACPI_COMPARE_NAME(table->signature, ACPI_SIG_DSDT) && if (!ACPI_COMPARE_NAME(table->signature, ACPI_SIG_DSDT) &&
!ACPI_COMPARE_NAME(table->signature, ACPI_SIG_SSDT)) { !ACPI_COMPARE_NAME(table->signature, ACPI_SIG_SSDT)) {
return AE_BAD_HEADER; return (AE_BAD_HEADER);
} }
/* First AML opcode in the table must be a control method */ /* First AML opcode in the table must be a control method */
...@@ -554,7 +554,7 @@ acpi_status acpi_install_method(u8 *buffer) ...@@ -554,7 +554,7 @@ acpi_status acpi_install_method(u8 *buffer)
parser_state.aml = buffer + sizeof(struct acpi_table_header); parser_state.aml = buffer + sizeof(struct acpi_table_header);
opcode = acpi_ps_peek_opcode(&parser_state); opcode = acpi_ps_peek_opcode(&parser_state);
if (opcode != AML_METHOD_OP) { if (opcode != AML_METHOD_OP) {
return AE_BAD_PARAMETER; return (AE_BAD_PARAMETER);
} }
/* Extract method information from the raw AML */ /* Extract method information from the raw AML */
...@@ -572,13 +572,13 @@ acpi_status acpi_install_method(u8 *buffer) ...@@ -572,13 +572,13 @@ acpi_status acpi_install_method(u8 *buffer)
*/ */
aml_buffer = ACPI_ALLOCATE(aml_length); aml_buffer = ACPI_ALLOCATE(aml_length);
if (!aml_buffer) { if (!aml_buffer) {
return AE_NO_MEMORY; return (AE_NO_MEMORY);
} }
method_obj = acpi_ut_create_internal_object(ACPI_TYPE_METHOD); method_obj = acpi_ut_create_internal_object(ACPI_TYPE_METHOD);
if (!method_obj) { if (!method_obj) {
ACPI_FREE(aml_buffer); ACPI_FREE(aml_buffer);
return AE_NO_MEMORY; return (AE_NO_MEMORY);
} }
/* Lock namespace for acpi_ns_lookup, we may be creating a new node */ /* Lock namespace for acpi_ns_lookup, we may be creating a new node */
...@@ -644,12 +644,12 @@ acpi_status acpi_install_method(u8 *buffer) ...@@ -644,12 +644,12 @@ acpi_status acpi_install_method(u8 *buffer)
/* Remove local reference to the method object */ /* Remove local reference to the method object */
acpi_ut_remove_reference(method_obj); acpi_ut_remove_reference(method_obj);
return status; return (status);
error_exit: error_exit:
ACPI_FREE(aml_buffer); ACPI_FREE(aml_buffer);
ACPI_FREE(method_obj); ACPI_FREE(method_obj);
return status; return (status);
} }
ACPI_EXPORT_SYMBOL(acpi_install_method) ACPI_EXPORT_SYMBOL(acpi_install_method)
...@@ -108,7 +108,7 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) ...@@ -108,7 +108,7 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state)
/* Byte 0 is a special case, either bits [0:3] or [0:5] are used */ /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */
package_length |= (aml[0] & byte_zero_mask); package_length |= (aml[0] & byte_zero_mask);
return_UINT32(package_length); return_VALUE(package_length);
} }
/******************************************************************************* /*******************************************************************************
...@@ -162,7 +162,7 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state) ...@@ -162,7 +162,7 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
/* Point past any namestring prefix characters (backslash or carat) */ /* Point past any namestring prefix characters (backslash or carat) */
while (acpi_ps_is_prefix_char(*end)) { while (ACPI_IS_ROOT_PREFIX(*end) || ACPI_IS_PARENT_PREFIX(*end)) {
end++; end++;
} }
...@@ -798,7 +798,8 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state, ...@@ -798,7 +798,8 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
subop = acpi_ps_peek_opcode(parser_state); subop = acpi_ps_peek_opcode(parser_state);
if (subop == 0 || if (subop == 0 ||
acpi_ps_is_leading_char(subop) || acpi_ps_is_leading_char(subop) ||
acpi_ps_is_prefix_char(subop)) { ACPI_IS_ROOT_PREFIX(subop) ||
ACPI_IS_PARENT_PREFIX(subop)) {
/* null_name or name_string */ /* null_name or name_string */
......
...@@ -58,350 +58,15 @@ ...@@ -58,350 +58,15 @@
#define _COMPONENT ACPI_PARSER #define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME("psloop") ACPI_MODULE_NAME("psloop")
static u32 acpi_gbl_depth = 0;
/* Local prototypes */ /* Local prototypes */
static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state);
static acpi_status
acpi_ps_build_named_op(struct acpi_walk_state *walk_state,
u8 * aml_op_start,
union acpi_parse_object *unnamed_op,
union acpi_parse_object **op);
static acpi_status
acpi_ps_create_op(struct acpi_walk_state *walk_state,
u8 * aml_op_start, union acpi_parse_object **new_op);
static acpi_status static acpi_status
acpi_ps_get_arguments(struct acpi_walk_state *walk_state, acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
u8 * aml_op_start, union acpi_parse_object *op); u8 * aml_op_start, union acpi_parse_object *op);
static acpi_status
acpi_ps_complete_op(struct acpi_walk_state *walk_state,
union acpi_parse_object **op, acpi_status status);
static acpi_status
acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
union acpi_parse_object *op, acpi_status status);
static void static void
acpi_ps_link_module_code(union acpi_parse_object *parent_op, acpi_ps_link_module_code(union acpi_parse_object *parent_op,
u8 *aml_start, u32 aml_length, acpi_owner_id owner_id); u8 *aml_start, u32 aml_length, acpi_owner_id owner_id);
/*******************************************************************************
*
* FUNCTION: acpi_ps_get_aml_opcode
*
* PARAMETERS: walk_state - Current state
*
* RETURN: Status
*
* DESCRIPTION: Extract the next AML opcode from the input stream.
*
******************************************************************************/
static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state)
{
ACPI_FUNCTION_TRACE_PTR(ps_get_aml_opcode, walk_state);
walk_state->aml_offset =
(u32) ACPI_PTR_DIFF(walk_state->parser_state.aml,
walk_state->parser_state.aml_start);
walk_state->opcode = acpi_ps_peek_opcode(&(walk_state->parser_state));
/*
* First cut to determine what we have found:
* 1) A valid AML opcode
* 2) A name string
* 3) An unknown/invalid opcode
*/
walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode);
switch (walk_state->op_info->class) {
case AML_CLASS_ASCII:
case AML_CLASS_PREFIX:
/*
* Starts with a valid prefix or ASCII char, this is a name
* string. Convert the bare name string to a namepath.
*/
walk_state->opcode = AML_INT_NAMEPATH_OP;
walk_state->arg_types = ARGP_NAMESTRING;
break;
case AML_CLASS_UNKNOWN:
/* The opcode is unrecognized. Complain and skip unknown opcodes */
if (walk_state->pass_number == 2) {
ACPI_ERROR((AE_INFO,
"Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring",
walk_state->opcode,
(u32)(walk_state->aml_offset +
sizeof(struct acpi_table_header))));
ACPI_DUMP_BUFFER(walk_state->parser_state.aml - 16, 48);
#ifdef ACPI_ASL_COMPILER
/*
* This is executed for the disassembler only. Output goes
* to the disassembled ASL output file.
*/
acpi_os_printf
("/*\nError: Unknown opcode 0x%.2X at table offset 0x%.4X, context:\n",
walk_state->opcode,
(u32)(walk_state->aml_offset +
sizeof(struct acpi_table_header)));
/* Dump the context surrounding the invalid opcode */
acpi_ut_dump_buffer(((u8 *)walk_state->parser_state.
aml - 16), 48, DB_BYTE_DISPLAY,
walk_state->aml_offset +
sizeof(struct acpi_table_header) -
16);
acpi_os_printf(" */\n");
#endif
}
/* Increment past one-byte or two-byte opcode */
walk_state->parser_state.aml++;
if (walk_state->opcode > 0xFF) { /* Can only happen if first byte is 0x5B */
walk_state->parser_state.aml++;
}
return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
default:
/* Found opcode info, this is a normal opcode */
walk_state->parser_state.aml +=
acpi_ps_get_opcode_size(walk_state->opcode);
walk_state->arg_types = walk_state->op_info->parse_args;
break;
}
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ps_build_named_op
*
* PARAMETERS: walk_state - Current state
* aml_op_start - Begin of named Op in AML
* unnamed_op - Early Op (not a named Op)
* op - Returned Op
*
* RETURN: Status
*
* DESCRIPTION: Parse a named Op
*
******************************************************************************/
static acpi_status
acpi_ps_build_named_op(struct acpi_walk_state *walk_state,
u8 * aml_op_start,
union acpi_parse_object *unnamed_op,
union acpi_parse_object **op)
{
acpi_status status = AE_OK;
union acpi_parse_object *arg = NULL;
ACPI_FUNCTION_TRACE_PTR(ps_build_named_op, walk_state);
unnamed_op->common.value.arg = NULL;
unnamed_op->common.arg_list_length = 0;
unnamed_op->common.aml_opcode = walk_state->opcode;
/*
* Get and append arguments until we find the node that contains
* the name (the type ARGP_NAME).
*/
while (GET_CURRENT_ARG_TYPE(walk_state->arg_types) &&
(GET_CURRENT_ARG_TYPE(walk_state->arg_types) != ARGP_NAME)) {
status =
acpi_ps_get_next_arg(walk_state,
&(walk_state->parser_state),
GET_CURRENT_ARG_TYPE(walk_state->
arg_types), &arg);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
acpi_ps_append_arg(unnamed_op, arg);
INCREMENT_ARG_LIST(walk_state->arg_types);
}
/*
* Make sure that we found a NAME and didn't run out of arguments
*/
if (!GET_CURRENT_ARG_TYPE(walk_state->arg_types)) {
return_ACPI_STATUS(AE_AML_NO_OPERAND);
}
/* We know that this arg is a name, move to next arg */
INCREMENT_ARG_LIST(walk_state->arg_types);
/*
* Find the object. This will either insert the object into
* the namespace or simply look it up
*/
walk_state->op = NULL;
status = walk_state->descending_callback(walk_state, op);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "During name lookup/catalog"));
return_ACPI_STATUS(status);
}
if (!*op) {
return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
}
status = acpi_ps_next_parse_state(walk_state, *op, status);
if (ACPI_FAILURE(status)) {
if (status == AE_CTRL_PENDING) {
return_ACPI_STATUS(AE_CTRL_PARSE_PENDING);
}
return_ACPI_STATUS(status);
}
acpi_ps_append_arg(*op, unnamed_op->common.value.arg);
acpi_gbl_depth++;
if ((*op)->common.aml_opcode == AML_REGION_OP ||
(*op)->common.aml_opcode == AML_DATA_REGION_OP) {
/*
* Defer final parsing of an operation_region body, because we don't
* have enough info in the first pass to parse it correctly (i.e.,
* there may be method calls within the term_arg elements of the body.)
*
* However, we must continue parsing because the opregion is not a
* standalone package -- we don't know where the end is at this point.
*
* (Length is unknown until parse of the body complete)
*/
(*op)->named.data = aml_op_start;
(*op)->named.length = 0;
}
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ps_create_op
*
* PARAMETERS: walk_state - Current state
* aml_op_start - Op start in AML
* new_op - Returned Op
*
* RETURN: Status
*
* DESCRIPTION: Get Op from AML
*
******************************************************************************/
static acpi_status
acpi_ps_create_op(struct acpi_walk_state *walk_state,
u8 * aml_op_start, union acpi_parse_object **new_op)
{
acpi_status status = AE_OK;
union acpi_parse_object *op;
union acpi_parse_object *named_op = NULL;
union acpi_parse_object *parent_scope;
u8 argument_count;
const struct acpi_opcode_info *op_info;
ACPI_FUNCTION_TRACE_PTR(ps_create_op, walk_state);
status = acpi_ps_get_aml_opcode(walk_state);
if (status == AE_CTRL_PARSE_CONTINUE) {
return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
}
/* Create Op structure and append to parent's argument list */
walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode);
op = acpi_ps_alloc_op(walk_state->opcode);
if (!op) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
if (walk_state->op_info->flags & AML_NAMED) {
status =
acpi_ps_build_named_op(walk_state, aml_op_start, op,
&named_op);
acpi_ps_free_op(op);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
*new_op = named_op;
return_ACPI_STATUS(AE_OK);
}
/* Not a named opcode, just allocate Op and append to parent */
if (walk_state->op_info->flags & AML_CREATE) {
/*
* Backup to beginning of create_XXXfield declaration
* body_length is unknown until we parse the body
*/
op->named.data = aml_op_start;
op->named.length = 0;
}
if (walk_state->opcode == AML_BANK_FIELD_OP) {
/*
* Backup to beginning of bank_field declaration
* body_length is unknown until we parse the body
*/
op->named.data = aml_op_start;
op->named.length = 0;
}
parent_scope = acpi_ps_get_parent_scope(&(walk_state->parser_state));
acpi_ps_append_arg(parent_scope, op);
if (parent_scope) {
op_info =
acpi_ps_get_opcode_info(parent_scope->common.aml_opcode);
if (op_info->flags & AML_HAS_TARGET) {
argument_count =
acpi_ps_get_argument_count(op_info->type);
if (parent_scope->common.arg_list_length >
argument_count) {
op->common.flags |= ACPI_PARSEOP_TARGET;
}
} else if (parent_scope->common.aml_opcode == AML_INCREMENT_OP) {
op->common.flags |= ACPI_PARSEOP_TARGET;
}
}
if (walk_state->descending_callback != NULL) {
/*
* Find the object. This will either insert the object into
* the namespace or simply look it up
*/
walk_state->op = *new_op = op;
status = walk_state->descending_callback(walk_state, &op);
status = acpi_ps_next_parse_state(walk_state, op, status);
if (status == AE_CTRL_PENDING) {
status = AE_CTRL_PARSE_PENDING;
}
}
return_ACPI_STATUS(status);
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ps_get_arguments * FUNCTION: acpi_ps_get_arguments
...@@ -709,288 +374,6 @@ acpi_ps_link_module_code(union acpi_parse_object *parent_op, ...@@ -709,288 +374,6 @@ acpi_ps_link_module_code(union acpi_parse_object *parent_op,
} }
} }
/*******************************************************************************
*
* FUNCTION: acpi_ps_complete_op
*
* PARAMETERS: walk_state - Current state
* op - Returned Op
* status - Parse status before complete Op
*
* RETURN: Status
*
* DESCRIPTION: Complete Op
*
******************************************************************************/
static acpi_status
acpi_ps_complete_op(struct acpi_walk_state *walk_state,
union acpi_parse_object **op, acpi_status status)
{
acpi_status status2;
ACPI_FUNCTION_TRACE_PTR(ps_complete_op, walk_state);
/*
* Finished one argument of the containing scope
*/
walk_state->parser_state.scope->parse_scope.arg_count--;
/* Close this Op (will result in parse subtree deletion) */
status2 = acpi_ps_complete_this_op(walk_state, *op);
if (ACPI_FAILURE(status2)) {
return_ACPI_STATUS(status2);
}
*op = NULL;
switch (status) {
case AE_OK:
break;
case AE_CTRL_TRANSFER:
/* We are about to transfer to a called method */
walk_state->prev_op = NULL;
walk_state->prev_arg_types = walk_state->arg_types;
return_ACPI_STATUS(status);
case AE_CTRL_END:
acpi_ps_pop_scope(&(walk_state->parser_state), op,
&walk_state->arg_types,
&walk_state->arg_count);
if (*op) {
walk_state->op = *op;
walk_state->op_info =
acpi_ps_get_opcode_info((*op)->common.aml_opcode);
walk_state->opcode = (*op)->common.aml_opcode;
status = walk_state->ascending_callback(walk_state);
status =
acpi_ps_next_parse_state(walk_state, *op, status);
status2 = acpi_ps_complete_this_op(walk_state, *op);
if (ACPI_FAILURE(status2)) {
return_ACPI_STATUS(status2);
}
}
status = AE_OK;
break;
case AE_CTRL_BREAK:
case AE_CTRL_CONTINUE:
/* Pop off scopes until we find the While */
while (!(*op) || ((*op)->common.aml_opcode != AML_WHILE_OP)) {
acpi_ps_pop_scope(&(walk_state->parser_state), op,
&walk_state->arg_types,
&walk_state->arg_count);
}
/* Close this iteration of the While loop */
walk_state->op = *op;
walk_state->op_info =
acpi_ps_get_opcode_info((*op)->common.aml_opcode);
walk_state->opcode = (*op)->common.aml_opcode;
status = walk_state->ascending_callback(walk_state);
status = acpi_ps_next_parse_state(walk_state, *op, status);
status2 = acpi_ps_complete_this_op(walk_state, *op);
if (ACPI_FAILURE(status2)) {
return_ACPI_STATUS(status2);
}
status = AE_OK;
break;
case AE_CTRL_TERMINATE:
/* Clean up */
do {
if (*op) {
status2 =
acpi_ps_complete_this_op(walk_state, *op);
if (ACPI_FAILURE(status2)) {
return_ACPI_STATUS(status2);
}
acpi_ut_delete_generic_state
(acpi_ut_pop_generic_state
(&walk_state->control_state));
}
acpi_ps_pop_scope(&(walk_state->parser_state), op,
&walk_state->arg_types,
&walk_state->arg_count);
} while (*op);
return_ACPI_STATUS(AE_OK);
default: /* All other non-AE_OK status */
do {
if (*op) {
status2 =
acpi_ps_complete_this_op(walk_state, *op);
if (ACPI_FAILURE(status2)) {
return_ACPI_STATUS(status2);
}
}
acpi_ps_pop_scope(&(walk_state->parser_state), op,
&walk_state->arg_types,
&walk_state->arg_count);
} while (*op);
#if 0
/*
* TBD: Cleanup parse ops on error
*/
if (*op == NULL) {
acpi_ps_pop_scope(parser_state, op,
&walk_state->arg_types,
&walk_state->arg_count);
}
#endif
walk_state->prev_op = NULL;
walk_state->prev_arg_types = walk_state->arg_types;
return_ACPI_STATUS(status);
}
/* This scope complete? */
if (acpi_ps_has_completed_scope(&(walk_state->parser_state))) {
acpi_ps_pop_scope(&(walk_state->parser_state), op,
&walk_state->arg_types,
&walk_state->arg_count);
ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *op));
} else {
*op = NULL;
}
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ps_complete_final_op
*
* PARAMETERS: walk_state - Current state
* op - Current Op
* status - Current parse status before complete last
* Op
*
* RETURN: Status
*
* DESCRIPTION: Complete last Op.
*
******************************************************************************/
static acpi_status
acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
union acpi_parse_object *op, acpi_status status)
{
acpi_status status2;
ACPI_FUNCTION_TRACE_PTR(ps_complete_final_op, walk_state);
/*
* Complete the last Op (if not completed), and clear the scope stack.
* It is easily possible to end an AML "package" with an unbounded number
* of open scopes (such as when several ASL blocks are closed with
* sequential closing braces). We want to terminate each one cleanly.
*/
ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "AML package complete at Op %p\n",
op));
do {
if (op) {
if (walk_state->ascending_callback != NULL) {
walk_state->op = op;
walk_state->op_info =
acpi_ps_get_opcode_info(op->common.
aml_opcode);
walk_state->opcode = op->common.aml_opcode;
status =
walk_state->ascending_callback(walk_state);
status =
acpi_ps_next_parse_state(walk_state, op,
status);
if (status == AE_CTRL_PENDING) {
status =
acpi_ps_complete_op(walk_state, &op,
AE_OK);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
if (status == AE_CTRL_TERMINATE) {
status = AE_OK;
/* Clean up */
do {
if (op) {
status2 =
acpi_ps_complete_this_op
(walk_state, op);
if (ACPI_FAILURE
(status2)) {
return_ACPI_STATUS
(status2);
}
}
acpi_ps_pop_scope(&
(walk_state->
parser_state),
&op,
&walk_state->
arg_types,
&walk_state->
arg_count);
} while (op);
return_ACPI_STATUS(status);
}
else if (ACPI_FAILURE(status)) {
/* First error is most important */
(void)
acpi_ps_complete_this_op(walk_state,
op);
return_ACPI_STATUS(status);
}
}
status2 = acpi_ps_complete_this_op(walk_state, op);
if (ACPI_FAILURE(status2)) {
return_ACPI_STATUS(status2);
}
}
acpi_ps_pop_scope(&(walk_state->parser_state), &op,
&walk_state->arg_types,
&walk_state->arg_count);
} while (op);
return_ACPI_STATUS(status);
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ps_parse_loop * FUNCTION: acpi_ps_parse_loop
...@@ -1177,10 +560,6 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state) ...@@ -1177,10 +560,6 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
walk_state->op_info = walk_state->op_info =
acpi_ps_get_opcode_info(op->common.aml_opcode); acpi_ps_get_opcode_info(op->common.aml_opcode);
if (walk_state->op_info->flags & AML_NAMED) { if (walk_state->op_info->flags & AML_NAMED) {
if (acpi_gbl_depth) {
acpi_gbl_depth--;
}
if (op->common.aml_opcode == AML_REGION_OP || if (op->common.aml_opcode == AML_REGION_OP ||
op->common.aml_opcode == AML_DATA_REGION_OP) { op->common.aml_opcode == AML_DATA_REGION_OP) {
/* /*
......
/******************************************************************************
*
* Module Name: psobject - Support for parse objects
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2012, Intel Corp.
* 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 <acpi/acpi.h>
#include "accommon.h"
#include "acparser.h"
#include "amlcode.h"
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME("psobject")
/* Local prototypes */
static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state);
/*******************************************************************************
*
* FUNCTION: acpi_ps_get_aml_opcode
*
* PARAMETERS: walk_state - Current state
*
* RETURN: Status
*
* DESCRIPTION: Extract the next AML opcode from the input stream.
*
******************************************************************************/
static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state)
{
ACPI_FUNCTION_TRACE_PTR(ps_get_aml_opcode, walk_state);
walk_state->aml_offset =
(u32)ACPI_PTR_DIFF(walk_state->parser_state.aml,
walk_state->parser_state.aml_start);
walk_state->opcode = acpi_ps_peek_opcode(&(walk_state->parser_state));
/*
* First cut to determine what we have found:
* 1) A valid AML opcode
* 2) A name string
* 3) An unknown/invalid opcode
*/
walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode);
switch (walk_state->op_info->class) {
case AML_CLASS_ASCII:
case AML_CLASS_PREFIX:
/*
* Starts with a valid prefix or ASCII char, this is a name
* string. Convert the bare name string to a namepath.
*/
walk_state->opcode = AML_INT_NAMEPATH_OP;
walk_state->arg_types = ARGP_NAMESTRING;
break;
case AML_CLASS_UNKNOWN:
/* The opcode is unrecognized. Complain and skip unknown opcodes */
if (walk_state->pass_number == 2) {
ACPI_ERROR((AE_INFO,
"Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring",
walk_state->opcode,
(u32)(walk_state->aml_offset +
sizeof(struct acpi_table_header))));
ACPI_DUMP_BUFFER((walk_state->parser_state.aml - 16),
48);
#ifdef ACPI_ASL_COMPILER
/*
* This is executed for the disassembler only. Output goes
* to the disassembled ASL output file.
*/
acpi_os_printf
("/*\nError: Unknown opcode 0x%.2X at table offset 0x%.4X, context:\n",
walk_state->opcode,
(u32)(walk_state->aml_offset +
sizeof(struct acpi_table_header)));
/* Dump the context surrounding the invalid opcode */
acpi_ut_dump_buffer(((u8 *)walk_state->parser_state.
aml - 16), 48, DB_BYTE_DISPLAY,
(walk_state->aml_offset +
sizeof(struct acpi_table_header) -
16));
acpi_os_printf(" */\n");
#endif
}
/* Increment past one-byte or two-byte opcode */
walk_state->parser_state.aml++;
if (walk_state->opcode > 0xFF) { /* Can only happen if first byte is 0x5B */
walk_state->parser_state.aml++;
}
return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
default:
/* Found opcode info, this is a normal opcode */
walk_state->parser_state.aml +=
acpi_ps_get_opcode_size(walk_state->opcode);
walk_state->arg_types = walk_state->op_info->parse_args;
break;
}
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ps_build_named_op
*
* PARAMETERS: walk_state - Current state
* aml_op_start - Begin of named Op in AML
* unnamed_op - Early Op (not a named Op)
* op - Returned Op
*
* RETURN: Status
*
* DESCRIPTION: Parse a named Op
*
******************************************************************************/
acpi_status
acpi_ps_build_named_op(struct acpi_walk_state *walk_state,
u8 *aml_op_start,
union acpi_parse_object *unnamed_op,
union acpi_parse_object **op)
{
acpi_status status = AE_OK;
union acpi_parse_object *arg = NULL;
ACPI_FUNCTION_TRACE_PTR(ps_build_named_op, walk_state);
unnamed_op->common.value.arg = NULL;
unnamed_op->common.arg_list_length = 0;
unnamed_op->common.aml_opcode = walk_state->opcode;
/*
* Get and append arguments until we find the node that contains
* the name (the type ARGP_NAME).
*/
while (GET_CURRENT_ARG_TYPE(walk_state->arg_types) &&
(GET_CURRENT_ARG_TYPE(walk_state->arg_types) != ARGP_NAME)) {
status =
acpi_ps_get_next_arg(walk_state,
&(walk_state->parser_state),
GET_CURRENT_ARG_TYPE(walk_state->
arg_types), &arg);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
acpi_ps_append_arg(unnamed_op, arg);
INCREMENT_ARG_LIST(walk_state->arg_types);
}
/*
* Make sure that we found a NAME and didn't run out of arguments
*/
if (!GET_CURRENT_ARG_TYPE(walk_state->arg_types)) {
return_ACPI_STATUS(AE_AML_NO_OPERAND);
}
/* We know that this arg is a name, move to next arg */
INCREMENT_ARG_LIST(walk_state->arg_types);
/*
* Find the object. This will either insert the object into
* the namespace or simply look it up
*/
walk_state->op = NULL;
status = walk_state->descending_callback(walk_state, op);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, "During name lookup/catalog"));
return_ACPI_STATUS(status);
}
if (!*op) {
return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
}
status = acpi_ps_next_parse_state(walk_state, *op, status);
if (ACPI_FAILURE(status)) {
if (status == AE_CTRL_PENDING) {
return_ACPI_STATUS(AE_CTRL_PARSE_PENDING);
}
return_ACPI_STATUS(status);
}
acpi_ps_append_arg(*op, unnamed_op->common.value.arg);
if ((*op)->common.aml_opcode == AML_REGION_OP ||
(*op)->common.aml_opcode == AML_DATA_REGION_OP) {
/*
* Defer final parsing of an operation_region body, because we don't
* have enough info in the first pass to parse it correctly (i.e.,
* there may be method calls within the term_arg elements of the body.)
*
* However, we must continue parsing because the opregion is not a
* standalone package -- we don't know where the end is at this point.
*
* (Length is unknown until parse of the body complete)
*/
(*op)->named.data = aml_op_start;
(*op)->named.length = 0;
}
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ps_create_op
*
* PARAMETERS: walk_state - Current state
* aml_op_start - Op start in AML
* new_op - Returned Op
*
* RETURN: Status
*
* DESCRIPTION: Get Op from AML
*
******************************************************************************/
acpi_status
acpi_ps_create_op(struct acpi_walk_state *walk_state,
u8 *aml_op_start, union acpi_parse_object **new_op)
{
acpi_status status = AE_OK;
union acpi_parse_object *op;
union acpi_parse_object *named_op = NULL;
union acpi_parse_object *parent_scope;
u8 argument_count;
const struct acpi_opcode_info *op_info;
ACPI_FUNCTION_TRACE_PTR(ps_create_op, walk_state);
status = acpi_ps_get_aml_opcode(walk_state);
if (status == AE_CTRL_PARSE_CONTINUE) {
return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
}
/* Create Op structure and append to parent's argument list */
walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode);
op = acpi_ps_alloc_op(walk_state->opcode);
if (!op) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
if (walk_state->op_info->flags & AML_NAMED) {
status =
acpi_ps_build_named_op(walk_state, aml_op_start, op,
&named_op);
acpi_ps_free_op(op);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
*new_op = named_op;
return_ACPI_STATUS(AE_OK);
}
/* Not a named opcode, just allocate Op and append to parent */
if (walk_state->op_info->flags & AML_CREATE) {
/*
* Backup to beginning of create_XXXfield declaration
* body_length is unknown until we parse the body
*/
op->named.data = aml_op_start;
op->named.length = 0;
}
if (walk_state->opcode == AML_BANK_FIELD_OP) {
/*
* Backup to beginning of bank_field declaration
* body_length is unknown until we parse the body
*/
op->named.data = aml_op_start;
op->named.length = 0;
}
parent_scope = acpi_ps_get_parent_scope(&(walk_state->parser_state));
acpi_ps_append_arg(parent_scope, op);
if (parent_scope) {
op_info =
acpi_ps_get_opcode_info(parent_scope->common.aml_opcode);
if (op_info->flags & AML_HAS_TARGET) {
argument_count =
acpi_ps_get_argument_count(op_info->type);
if (parent_scope->common.arg_list_length >
argument_count) {
op->common.flags |= ACPI_PARSEOP_TARGET;
}
} else if (parent_scope->common.aml_opcode == AML_INCREMENT_OP) {
op->common.flags |= ACPI_PARSEOP_TARGET;
}
}
if (walk_state->descending_callback != NULL) {
/*
* Find the object. This will either insert the object into
* the namespace or simply look it up
*/
walk_state->op = *new_op = op;
status = walk_state->descending_callback(walk_state, &op);
status = acpi_ps_next_parse_state(walk_state, op, status);
if (status == AE_CTRL_PENDING) {
status = AE_CTRL_PARSE_PENDING;
}
}
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ps_complete_op
*
* PARAMETERS: walk_state - Current state
* op - Returned Op
* status - Parse status before complete Op
*
* RETURN: Status
*
* DESCRIPTION: Complete Op
*
******************************************************************************/
acpi_status
acpi_ps_complete_op(struct acpi_walk_state *walk_state,
union acpi_parse_object **op, acpi_status status)
{
acpi_status status2;
ACPI_FUNCTION_TRACE_PTR(ps_complete_op, walk_state);
/*
* Finished one argument of the containing scope
*/
walk_state->parser_state.scope->parse_scope.arg_count--;
/* Close this Op (will result in parse subtree deletion) */
status2 = acpi_ps_complete_this_op(walk_state, *op);
if (ACPI_FAILURE(status2)) {
return_ACPI_STATUS(status2);
}
*op = NULL;
switch (status) {
case AE_OK:
break;
case AE_CTRL_TRANSFER:
/* We are about to transfer to a called method */
walk_state->prev_op = NULL;
walk_state->prev_arg_types = walk_state->arg_types;
return_ACPI_STATUS(status);
case AE_CTRL_END:
acpi_ps_pop_scope(&(walk_state->parser_state), op,
&walk_state->arg_types,
&walk_state->arg_count);
if (*op) {
walk_state->op = *op;
walk_state->op_info =
acpi_ps_get_opcode_info((*op)->common.aml_opcode);
walk_state->opcode = (*op)->common.aml_opcode;
status = walk_state->ascending_callback(walk_state);
status =
acpi_ps_next_parse_state(walk_state, *op, status);
status2 = acpi_ps_complete_this_op(walk_state, *op);
if (ACPI_FAILURE(status2)) {
return_ACPI_STATUS(status2);
}
}
status = AE_OK;
break;
case AE_CTRL_BREAK:
case AE_CTRL_CONTINUE:
/* Pop off scopes until we find the While */
while (!(*op) || ((*op)->common.aml_opcode != AML_WHILE_OP)) {
acpi_ps_pop_scope(&(walk_state->parser_state), op,
&walk_state->arg_types,
&walk_state->arg_count);
}
/* Close this iteration of the While loop */
walk_state->op = *op;
walk_state->op_info =
acpi_ps_get_opcode_info((*op)->common.aml_opcode);
walk_state->opcode = (*op)->common.aml_opcode;
status = walk_state->ascending_callback(walk_state);
status = acpi_ps_next_parse_state(walk_state, *op, status);
status2 = acpi_ps_complete_this_op(walk_state, *op);
if (ACPI_FAILURE(status2)) {
return_ACPI_STATUS(status2);
}
status = AE_OK;
break;
case AE_CTRL_TERMINATE:
/* Clean up */
do {
if (*op) {
status2 =
acpi_ps_complete_this_op(walk_state, *op);
if (ACPI_FAILURE(status2)) {
return_ACPI_STATUS(status2);
}
acpi_ut_delete_generic_state
(acpi_ut_pop_generic_state
(&walk_state->control_state));
}
acpi_ps_pop_scope(&(walk_state->parser_state), op,
&walk_state->arg_types,
&walk_state->arg_count);
} while (*op);
return_ACPI_STATUS(AE_OK);
default: /* All other non-AE_OK status */
do {
if (*op) {
status2 =
acpi_ps_complete_this_op(walk_state, *op);
if (ACPI_FAILURE(status2)) {
return_ACPI_STATUS(status2);
}
}
acpi_ps_pop_scope(&(walk_state->parser_state), op,
&walk_state->arg_types,
&walk_state->arg_count);
} while (*op);
#if 0
/*
* TBD: Cleanup parse ops on error
*/
if (*op == NULL) {
acpi_ps_pop_scope(parser_state, op,
&walk_state->arg_types,
&walk_state->arg_count);
}
#endif
walk_state->prev_op = NULL;
walk_state->prev_arg_types = walk_state->arg_types;
return_ACPI_STATUS(status);
}
/* This scope complete? */
if (acpi_ps_has_completed_scope(&(walk_state->parser_state))) {
acpi_ps_pop_scope(&(walk_state->parser_state), op,
&walk_state->arg_types,
&walk_state->arg_count);
ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *op));
} else {
*op = NULL;
}
return_ACPI_STATUS(AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ps_complete_final_op
*
* PARAMETERS: walk_state - Current state
* op - Current Op
* status - Current parse status before complete last
* Op
*
* RETURN: Status
*
* DESCRIPTION: Complete last Op.
*
******************************************************************************/
acpi_status
acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
union acpi_parse_object *op, acpi_status status)
{
acpi_status status2;
ACPI_FUNCTION_TRACE_PTR(ps_complete_final_op, walk_state);
/*
* Complete the last Op (if not completed), and clear the scope stack.
* It is easily possible to end an AML "package" with an unbounded number
* of open scopes (such as when several ASL blocks are closed with
* sequential closing braces). We want to terminate each one cleanly.
*/
ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "AML package complete at Op %p\n",
op));
do {
if (op) {
if (walk_state->ascending_callback != NULL) {
walk_state->op = op;
walk_state->op_info =
acpi_ps_get_opcode_info(op->common.
aml_opcode);
walk_state->opcode = op->common.aml_opcode;
status =
walk_state->ascending_callback(walk_state);
status =
acpi_ps_next_parse_state(walk_state, op,
status);
if (status == AE_CTRL_PENDING) {
status =
acpi_ps_complete_op(walk_state, &op,
AE_OK);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
}
if (status == AE_CTRL_TERMINATE) {
status = AE_OK;
/* Clean up */
do {
if (op) {
status2 =
acpi_ps_complete_this_op
(walk_state, op);
if (ACPI_FAILURE
(status2)) {
return_ACPI_STATUS
(status2);
}
}
acpi_ps_pop_scope(&
(walk_state->
parser_state),
&op,
&walk_state->
arg_types,
&walk_state->
arg_count);
} while (op);
return_ACPI_STATUS(status);
}
else if (ACPI_FAILURE(status)) {
/* First error is most important */
(void)
acpi_ps_complete_this_op(walk_state,
op);
return_ACPI_STATUS(status);
}
}
status2 = acpi_ps_complete_this_op(walk_state, op);
if (ACPI_FAILURE(status2)) {
return_ACPI_STATUS(status2);
}
}
acpi_ps_pop_scope(&(walk_state->parser_state), &op,
&walk_state->arg_types,
&walk_state->arg_count);
} while (op);
return_ACPI_STATUS(status);
}
...@@ -43,16 +43,12 @@ ...@@ -43,16 +43,12 @@
#include <acpi/acpi.h> #include <acpi/acpi.h>
#include "accommon.h" #include "accommon.h"
#include "acparser.h"
#include "acopcode.h" #include "acopcode.h"
#include "amlcode.h" #include "amlcode.h"
#define _COMPONENT ACPI_PARSER #define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME("psopcode") ACPI_MODULE_NAME("psopcode")
static const u8 acpi_gbl_argument_count[] =
{ 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 6 };
/******************************************************************************* /*******************************************************************************
* *
* NAME: acpi_gbl_aml_op_info * NAME: acpi_gbl_aml_op_info
...@@ -63,7 +59,6 @@ static const u8 acpi_gbl_argument_count[] = ...@@ -63,7 +59,6 @@ static const u8 acpi_gbl_argument_count[] =
* the operand type. * the operand type.
* *
******************************************************************************/ ******************************************************************************/
/* /*
* Summary of opcode types/flags * Summary of opcode types/flags
* *
...@@ -181,7 +176,6 @@ static const u8 acpi_gbl_argument_count[] = ...@@ -181,7 +176,6 @@ static const u8 acpi_gbl_argument_count[] =
AML_CREATE_QWORD_FIELD_OP AML_CREATE_QWORD_FIELD_OP
******************************************************************************/ ******************************************************************************/
/* /*
* Master Opcode information table. A summary of everything we know about each * Master Opcode information table. A summary of everything we know about each
* opcode, all in one place. * opcode, all in one place.
...@@ -656,169 +650,3 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = { ...@@ -656,169 +650,3 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = {
/*! [End] no source code translation !*/ /*! [End] no source code translation !*/
}; };
/*
* This table is directly indexed by the opcodes, and returns an
* index into the table above
*/
static const u8 acpi_gbl_short_op_index[256] = {
/* 0 1 2 3 4 5 6 7 */
/* 8 9 A B C D E F */
/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK,
/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK,
/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK,
/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX,
/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D,
/* 0x38 */ 0x7F, 0x80, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC,
/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK,
/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22,
/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30,
/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72,
/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74,
/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A,
/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61,
/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK,
/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45,
};
/*
* This table is indexed by the second opcode of the extended opcode
* pair. It returns an index into the opcode table (acpi_gbl_aml_op_info)
*/
static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = {
/* 0 1 2 3 4 5 6 7 */
/* 8 9 A B C D E F */
/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK,
/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B,
/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK,
/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
/* 0x88 */ 0x7C,
};
/*******************************************************************************
*
* FUNCTION: acpi_ps_get_opcode_info
*
* PARAMETERS: opcode - The AML opcode
*
* RETURN: A pointer to the info about the opcode.
*
* DESCRIPTION: Find AML opcode description based on the opcode.
* NOTE: This procedure must ALWAYS return a valid pointer!
*
******************************************************************************/
const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode)
{
ACPI_FUNCTION_NAME(ps_get_opcode_info);
/*
* Detect normal 8-bit opcode or extended 16-bit opcode
*/
if (!(opcode & 0xFF00)) {
/* Simple (8-bit) opcode: 0-255, can't index beyond table */
return (&acpi_gbl_aml_op_info
[acpi_gbl_short_op_index[(u8) opcode]]);
}
if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) &&
(((u8) opcode) <= MAX_EXTENDED_OPCODE)) {
/* Valid extended (16-bit) opcode */
return (&acpi_gbl_aml_op_info
[acpi_gbl_long_op_index[(u8) opcode]]);
}
/* Unknown AML opcode */
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Unknown AML opcode [%4.4X]\n", opcode));
return (&acpi_gbl_aml_op_info[_UNK]);
}
/*******************************************************************************
*
* FUNCTION: acpi_ps_get_opcode_name
*
* PARAMETERS: opcode - The AML opcode
*
* RETURN: A pointer to the name of the opcode (ASCII String)
* Note: Never returns NULL.
*
* DESCRIPTION: Translate an opcode into a human-readable string
*
******************************************************************************/
char *acpi_ps_get_opcode_name(u16 opcode)
{
#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
const struct acpi_opcode_info *op;
op = acpi_ps_get_opcode_info(opcode);
/* Always guaranteed to return a valid pointer */
return (op->name);
#else
return ("OpcodeName unavailable");
#endif
}
/*******************************************************************************
*
* FUNCTION: acpi_ps_get_argument_count
*
* PARAMETERS: op_type - Type associated with the AML opcode
*
* RETURN: Argument count
*
* DESCRIPTION: Obtain the number of expected arguments for an AML opcode
*
******************************************************************************/
u8 acpi_ps_get_argument_count(u32 op_type)
{
if (op_type <= AML_TYPE_EXEC_6A_0T_1R) {
return (acpi_gbl_argument_count[op_type]);
}
return (0);
}
/******************************************************************************
*
* Module Name: psopinfo - AML opcode information functions and dispatch tables
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2012, Intel Corp.
* 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 <acpi/acpi.h>
#include "accommon.h"
#include "acparser.h"
#include "acopcode.h"
#include "amlcode.h"
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME("psopinfo")
extern const u8 acpi_gbl_short_op_index[];
extern const u8 acpi_gbl_long_op_index[];
static const u8 acpi_gbl_argument_count[] =
{ 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 6 };
/*******************************************************************************
*
* FUNCTION: acpi_ps_get_opcode_info
*
* PARAMETERS: opcode - The AML opcode
*
* RETURN: A pointer to the info about the opcode.
*
* DESCRIPTION: Find AML opcode description based on the opcode.
* NOTE: This procedure must ALWAYS return a valid pointer!
*
******************************************************************************/
const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode)
{
ACPI_FUNCTION_NAME(ps_get_opcode_info);
/*
* Detect normal 8-bit opcode or extended 16-bit opcode
*/
if (!(opcode & 0xFF00)) {
/* Simple (8-bit) opcode: 0-255, can't index beyond table */
return (&acpi_gbl_aml_op_info
[acpi_gbl_short_op_index[(u8)opcode]]);
}
if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) &&
(((u8)opcode) <= MAX_EXTENDED_OPCODE)) {
/* Valid extended (16-bit) opcode */
return (&acpi_gbl_aml_op_info
[acpi_gbl_long_op_index[(u8)opcode]]);
}
/* Unknown AML opcode */
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Unknown AML opcode [%4.4X]\n", opcode));
return (&acpi_gbl_aml_op_info[_UNK]);
}
/*******************************************************************************
*
* FUNCTION: acpi_ps_get_opcode_name
*
* PARAMETERS: opcode - The AML opcode
*
* RETURN: A pointer to the name of the opcode (ASCII String)
* Note: Never returns NULL.
*
* DESCRIPTION: Translate an opcode into a human-readable string
*
******************************************************************************/
char *acpi_ps_get_opcode_name(u16 opcode)
{
#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
const struct acpi_opcode_info *op;
op = acpi_ps_get_opcode_info(opcode);
/* Always guaranteed to return a valid pointer */
return (op->name);
#else
return ("OpcodeName unavailable");
#endif
}
/*******************************************************************************
*
* FUNCTION: acpi_ps_get_argument_count
*
* PARAMETERS: op_type - Type associated with the AML opcode
*
* RETURN: Argument count
*
* DESCRIPTION: Obtain the number of expected arguments for an AML opcode
*
******************************************************************************/
u8 acpi_ps_get_argument_count(u32 op_type)
{
if (op_type <= AML_TYPE_EXEC_6A_0T_1R) {
return (acpi_gbl_argument_count[op_type]);
}
return (0);
}
/*
* This table is directly indexed by the opcodes It returns
* an index into the opcode table (acpi_gbl_aml_op_info)
*/
const u8 acpi_gbl_short_op_index[256] = {
/* 0 1 2 3 4 5 6 7 */
/* 8 9 A B C D E F */
/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK,
/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK,
/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK,
/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX,
/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D,
/* 0x38 */ 0x7F, 0x80, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC,
/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK,
/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22,
/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30,
/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72,
/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74,
/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A,
/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61,
/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK,
/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45,
};
/*
* This table is indexed by the second opcode of the extended opcode
* pair. It returns an index into the opcode table (acpi_gbl_aml_op_info)
*/
const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = {
/* 0 1 2 3 4 5 6 7 */
/* 8 9 A B C D E F */
/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK,
/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B,
/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK,
/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
/* 0x88 */ 0x7C,
};
...@@ -201,14 +201,6 @@ u8 acpi_ps_is_leading_char(u32 c) ...@@ -201,14 +201,6 @@ u8 acpi_ps_is_leading_char(u32 c)
return ((u8) (c == '_' || (c >= 'A' && c <= 'Z'))); return ((u8) (c == '_' || (c >= 'A' && c <= 'Z')));
} }
/*
* Is "c" a namestring prefix character?
*/
u8 acpi_ps_is_prefix_char(u32 c)
{
return ((u8) (c == '\\' || c == '^'));
}
/* /*
* Get op's name (4-byte name segment) or 0 if unnamed * Get op's name (4-byte name segment) or 0 if unnamed
*/ */
......
...@@ -84,7 +84,7 @@ static u8 acpi_rs_count_set_bits(u16 bit_field) ...@@ -84,7 +84,7 @@ static u8 acpi_rs_count_set_bits(u16 bit_field)
bit_field &= (u16) (bit_field - 1); bit_field &= (u16) (bit_field - 1);
} }
return bits_set; return (bits_set);
} }
/******************************************************************************* /*******************************************************************************
...@@ -407,7 +407,9 @@ acpi_rs_get_list_length(u8 * aml_buffer, ...@@ -407,7 +407,9 @@ acpi_rs_get_list_length(u8 * aml_buffer,
/* Validate the Resource Type and Resource Length */ /* Validate the Resource Type and Resource Length */
status = acpi_ut_validate_resource(aml_buffer, &resource_index); status =
acpi_ut_validate_resource(NULL, aml_buffer,
&resource_index);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
/* /*
* Exit on failure. Cannot continue because the descriptor length * Exit on failure. Cannot continue because the descriptor length
......
...@@ -98,7 +98,7 @@ acpi_buffer_to_resource(u8 *aml_buffer, ...@@ -98,7 +98,7 @@ acpi_buffer_to_resource(u8 *aml_buffer,
/* Perform the AML-to-Resource conversion */ /* Perform the AML-to-Resource conversion */
status = acpi_ut_walk_aml_resources(aml_buffer, aml_buffer_length, status = acpi_ut_walk_aml_resources(NULL, aml_buffer, aml_buffer_length,
acpi_rs_convert_aml_to_resources, acpi_rs_convert_aml_to_resources,
&current_resource_ptr); &current_resource_ptr);
if (status == AE_AML_NO_RESOURCE_END_TAG) { if (status == AE_AML_NO_RESOURCE_END_TAG) {
...@@ -174,7 +174,7 @@ acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, ...@@ -174,7 +174,7 @@ acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
/* Do the conversion */ /* Do the conversion */
resource = output_buffer->pointer; resource = output_buffer->pointer;
status = acpi_ut_walk_aml_resources(aml_start, aml_buffer_length, status = acpi_ut_walk_aml_resources(NULL, aml_start, aml_buffer_length,
acpi_rs_convert_aml_to_resources, acpi_rs_convert_aml_to_resources,
&resource); &resource);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
...@@ -480,8 +480,7 @@ acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, ...@@ -480,8 +480,7 @@ acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer,
status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed); status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed);
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", ACPI_DEBUG_PRINT((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n",
(u32) aml_size_needed, (u32)aml_size_needed, acpi_format_exception(status)));
acpi_format_exception(status)));
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }
......
...@@ -77,419 +77,16 @@ static void acpi_rs_dump_address_common(union acpi_resource_data *resource); ...@@ -77,419 +77,16 @@ static void acpi_rs_dump_address_common(union acpi_resource_data *resource);
static void static void
acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table); 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))
/*******************************************************************************
*
* Resource Descriptor info tables
*
* Note: The first table entry must be a Title or Literal and must contain
* the table length (number of table entries)
*
******************************************************************************/
struct acpi_rsdump_info acpi_rs_dump_irq[7] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_irq), "IRQ", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.descriptor_length),
"Descriptor Length", NULL},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.triggering), "Triggering",
acpi_gbl_he_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.polarity), "Polarity",
acpi_gbl_ll_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.sharable), "Sharing",
acpi_gbl_shr_decode},
{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_typ_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(dma.bus_master), "Mastering",
acpi_gbl_bm_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.transfer), "Transfer Type",
acpi_gbl_siz_decode},
{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[4] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_start_dpf),
"Start-Dependent-Functions", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(start_dpf.descriptor_length),
"Descriptor Length", 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), "EndTag",
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_rw_decode},
{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_rw_decode},
{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_rw_decode},
{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_he_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.polarity), "Polarity",
acpi_gbl_ll_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.sharable), "Sharing",
acpi_gbl_shr_decode},
{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}
};
struct acpi_rsdump_info acpi_rs_dump_gpio[16] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_gpio), "GPIO", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.revision_id), "RevisionId", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.connection_type),
"ConnectionType", acpi_gbl_ct_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.producer_consumer),
"ProducerConsumer", acpi_gbl_consume_decode},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.pin_config), "PinConfig",
acpi_gbl_ppc_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.sharable), "Sharable",
acpi_gbl_shr_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.io_restriction),
"IoRestriction", acpi_gbl_ior_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.triggering), "Triggering",
acpi_gbl_he_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.polarity), "Polarity",
acpi_gbl_ll_decode},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.drive_strength), "DriveStrength",
NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.debounce_timeout),
"DebounceTimeout", NULL},
{ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(gpio.resource_source),
"ResourceSource", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.pin_table_length),
"PinTableLength", NULL},
{ACPI_RSD_WORDLIST, ACPI_RSD_OFFSET(gpio.pin_table), "PinTable", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.vendor_length), "VendorLength",
NULL},
{ACPI_RSD_SHORTLISTX, ACPI_RSD_OFFSET(gpio.vendor_data), "VendorData",
NULL},
};
struct acpi_rsdump_info acpi_rs_dump_fixed_dma[4] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_dma),
"FixedDma", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.request_lines),
"RequestLines", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.channels), "Channels",
NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_dma.width), "TransferWidth",
acpi_gbl_dts_decode},
};
#define ACPI_RS_DUMP_COMMON_SERIAL_BUS \
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.revision_id), "RevisionId", NULL}, \
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type), "Type", acpi_gbl_sbt_decode}, \
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.producer_consumer), "ProducerConsumer", acpi_gbl_consume_decode}, \
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.slave_mode), "SlaveMode", acpi_gbl_sm_decode}, \
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type_revision_id), "TypeRevisionId", NULL}, \
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.type_data_length), "TypeDataLength", NULL}, \
{ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (common_serial_bus.resource_source), "ResourceSource", NULL}, \
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.vendor_length), "VendorLength", NULL}, \
{ACPI_RSD_SHORTLISTX,ACPI_RSD_OFFSET (common_serial_bus.vendor_data), "VendorData", NULL},
struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[10] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_common_serial_bus),
"Common Serial Bus", NULL},
ACPI_RS_DUMP_COMMON_SERIAL_BUS
};
struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[13] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_i2c_serial_bus),
"I2C Serial Bus", NULL},
ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG,
ACPI_RSD_OFFSET(i2c_serial_bus.
access_mode),
"AccessMode", acpi_gbl_am_decode},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET(i2c_serial_bus.connection_speed),
"ConnectionSpeed", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(i2c_serial_bus.slave_address),
"SlaveAddress", NULL},
};
struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[17] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_spi_serial_bus),
"Spi Serial Bus", NULL},
ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG,
ACPI_RSD_OFFSET(spi_serial_bus.
wire_mode), "WireMode",
acpi_gbl_wm_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(spi_serial_bus.device_polarity),
"DevicePolarity", acpi_gbl_dp_decode},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.data_bit_length),
"DataBitLength", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_phase),
"ClockPhase", acpi_gbl_cph_decode},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_polarity),
"ClockPolarity", acpi_gbl_cpo_decode},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(spi_serial_bus.device_selection),
"DeviceSelection", NULL},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET(spi_serial_bus.connection_speed),
"ConnectionSpeed", NULL},
};
struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[19] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_uart_serial_bus),
"Uart Serial Bus", NULL},
ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_2BITFLAG,
ACPI_RSD_OFFSET(uart_serial_bus.
flow_control),
"FlowControl", acpi_gbl_fc_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.stop_bits),
"StopBits", acpi_gbl_sb_decode},
{ACPI_RSD_3BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.data_bits),
"DataBits", acpi_gbl_bpb_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.endian), "Endian",
acpi_gbl_ed_decode},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.parity), "Parity",
acpi_gbl_pt_decode},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.lines_enabled),
"LinesEnabled", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.rx_fifo_size),
"RxFifoSize", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.tx_fifo_size),
"TxFifoSize", NULL},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET(uart_serial_bus.default_baud_rate),
"ConnectionSpeed", NULL},
};
/*
* 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_dec_decode},
{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", (void *)"Memory Range"},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect),
"Write Protect", acpi_gbl_rw_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching),
"Caching", acpi_gbl_mem_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.range_type),
"Range Type", acpi_gbl_mtp_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.translation),
"Translation", acpi_gbl_ttp_decode}
};
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", (void *)"I/O Range"},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type),
"Range Type", acpi_gbl_rng_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation),
"Translation", acpi_gbl_ttp_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation_type),
"Translation Type", acpi_gbl_trs_decode}
};
/*
* 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_descriptor * FUNCTION: acpi_rs_dump_descriptor
* *
* PARAMETERS: Resource * PARAMETERS: resource - Buffer containing the resource
* table - Table entry to decode the resource
* *
* RETURN: None * RETURN: None
* *
* DESCRIPTION: * DESCRIPTION: Dump a resource descriptor based on a dump table entry.
* *
******************************************************************************/ ******************************************************************************/
...@@ -654,7 +251,8 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) ...@@ -654,7 +251,8 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
/* /*
* Optional resource_source for Address resources * Optional resource_source for Address resources
*/ */
acpi_rs_dump_resource_source(ACPI_CAST_PTR(struct acpi_rs_dump_resource_source(ACPI_CAST_PTR
(struct
acpi_resource_source, acpi_resource_source,
target)); target));
break; break;
...@@ -765,8 +363,9 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list) ...@@ -765,8 +363,9 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
ACPI_FUNCTION_ENTRY(); ACPI_FUNCTION_ENTRY();
if (!(acpi_dbg_level & ACPI_LV_RESOURCES) /* Check if debug output enabled */
|| !(_COMPONENT & acpi_dbg_layer)) {
if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_RESOURCES, _COMPONENT)) {
return; return;
} }
...@@ -827,8 +426,9 @@ void acpi_rs_dump_irq_list(u8 * route_table) ...@@ -827,8 +426,9 @@ void acpi_rs_dump_irq_list(u8 * route_table)
ACPI_FUNCTION_ENTRY(); ACPI_FUNCTION_ENTRY();
if (!(acpi_dbg_level & ACPI_LV_RESOURCES) /* Check if debug output enabled */
|| !(_COMPONENT & acpi_dbg_layer)) {
if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_RESOURCES, _COMPONENT)) {
return; return;
} }
......
/*******************************************************************************
*
* Module Name: rsdumpinfo - Tables used to display resource descriptors.
*
******************************************************************************/
/*
* Copyright (C) 2000 - 2012, Intel Corp.
* 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 <acpi/acpi.h>
#include "accommon.h"
#include "acresrc.h"
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME("rsdumpinfo")
#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
#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))
/*******************************************************************************
*
* Resource Descriptor info tables
*
* Note: The first table entry must be a Title or Literal and must contain
* the table length (number of table entries)
*
******************************************************************************/
struct acpi_rsdump_info acpi_rs_dump_irq[7] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_irq), "IRQ", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.descriptor_length),
"Descriptor Length", NULL},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.triggering), "Triggering",
acpi_gbl_he_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.polarity), "Polarity",
acpi_gbl_ll_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(irq.sharable), "Sharing",
acpi_gbl_shr_decode},
{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_typ_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(dma.bus_master), "Mastering",
acpi_gbl_bm_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.transfer), "Transfer Type",
acpi_gbl_siz_decode},
{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[4] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_start_dpf),
"Start-Dependent-Functions", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(start_dpf.descriptor_length),
"Descriptor Length", 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), "EndTag",
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_rw_decode},
{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_rw_decode},
{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_rw_decode},
{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_he_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.polarity), "Polarity",
acpi_gbl_ll_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(extended_irq.sharable), "Sharing",
acpi_gbl_shr_decode},
{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}
};
struct acpi_rsdump_info acpi_rs_dump_gpio[16] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_gpio), "GPIO", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.revision_id), "RevisionId", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.connection_type),
"ConnectionType", acpi_gbl_ct_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.producer_consumer),
"ProducerConsumer", acpi_gbl_consume_decode},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.pin_config), "PinConfig",
acpi_gbl_ppc_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.sharable), "Sharing",
acpi_gbl_shr_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.io_restriction),
"IoRestriction", acpi_gbl_ior_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.triggering), "Triggering",
acpi_gbl_he_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.polarity), "Polarity",
acpi_gbl_ll_decode},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.drive_strength), "DriveStrength",
NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.debounce_timeout),
"DebounceTimeout", NULL},
{ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(gpio.resource_source),
"ResourceSource", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.pin_table_length),
"PinTableLength", NULL},
{ACPI_RSD_WORDLIST, ACPI_RSD_OFFSET(gpio.pin_table), "PinTable", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.vendor_length), "VendorLength",
NULL},
{ACPI_RSD_SHORTLISTX, ACPI_RSD_OFFSET(gpio.vendor_data), "VendorData",
NULL},
};
struct acpi_rsdump_info acpi_rs_dump_fixed_dma[4] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_dma),
"FixedDma", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.request_lines),
"RequestLines", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.channels), "Channels",
NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_dma.width), "TransferWidth",
acpi_gbl_dts_decode},
};
#define ACPI_RS_DUMP_COMMON_SERIAL_BUS \
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.revision_id), "RevisionId", NULL}, \
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type), "Type", acpi_gbl_sbt_decode}, \
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.producer_consumer), "ProducerConsumer", acpi_gbl_consume_decode}, \
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.slave_mode), "SlaveMode", acpi_gbl_sm_decode}, \
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type_revision_id), "TypeRevisionId", NULL}, \
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.type_data_length), "TypeDataLength", NULL}, \
{ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (common_serial_bus.resource_source), "ResourceSource", NULL}, \
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.vendor_length), "VendorLength", NULL}, \
{ACPI_RSD_SHORTLISTX,ACPI_RSD_OFFSET (common_serial_bus.vendor_data), "VendorData", NULL},
struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[10] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_common_serial_bus),
"Common Serial Bus", NULL},
ACPI_RS_DUMP_COMMON_SERIAL_BUS
};
struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[13] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_i2c_serial_bus),
"I2C Serial Bus", NULL},
ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG,
ACPI_RSD_OFFSET(i2c_serial_bus.
access_mode),
"AccessMode", acpi_gbl_am_decode},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET(i2c_serial_bus.connection_speed),
"ConnectionSpeed", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(i2c_serial_bus.slave_address),
"SlaveAddress", NULL},
};
struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[17] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_spi_serial_bus),
"Spi Serial Bus", NULL},
ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG,
ACPI_RSD_OFFSET(spi_serial_bus.
wire_mode), "WireMode",
acpi_gbl_wm_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(spi_serial_bus.device_polarity),
"DevicePolarity", acpi_gbl_dp_decode},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.data_bit_length),
"DataBitLength", NULL},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_phase),
"ClockPhase", acpi_gbl_cph_decode},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_polarity),
"ClockPolarity", acpi_gbl_cpo_decode},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(spi_serial_bus.device_selection),
"DeviceSelection", NULL},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET(spi_serial_bus.connection_speed),
"ConnectionSpeed", NULL},
};
struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[19] = {
{ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_uart_serial_bus),
"Uart Serial Bus", NULL},
ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_2BITFLAG,
ACPI_RSD_OFFSET(uart_serial_bus.
flow_control),
"FlowControl", acpi_gbl_fc_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.stop_bits),
"StopBits", acpi_gbl_sb_decode},
{ACPI_RSD_3BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.data_bits),
"DataBits", acpi_gbl_bpb_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.endian), "Endian",
acpi_gbl_ed_decode},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.parity), "Parity",
acpi_gbl_pt_decode},
{ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.lines_enabled),
"LinesEnabled", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.rx_fifo_size),
"RxFifoSize", NULL},
{ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.tx_fifo_size),
"TxFifoSize", NULL},
{ACPI_RSD_UINT32, ACPI_RSD_OFFSET(uart_serial_bus.default_baud_rate),
"ConnectionSpeed", NULL},
};
/*
* Tables used for common address descriptor flag fields
*/
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_dec_decode},
{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}
};
struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = {
{ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags),
"Resource Type", (void *)"Memory Range"},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect),
"Write Protect", acpi_gbl_rw_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching),
"Caching", acpi_gbl_mem_decode},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.range_type),
"Range Type", acpi_gbl_mtp_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.translation),
"Translation", acpi_gbl_ttp_decode}
};
struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = {
{ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags),
"Resource Type", (void *)"I/O Range"},
{ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type),
"Range Type", acpi_gbl_rng_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation),
"Translation", acpi_gbl_ttp_decode},
{ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation_type),
"Translation Type", acpi_gbl_trs_decode}
};
/*
* Table used to dump _PRT contents
*/
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}
};
#endif
...@@ -53,7 +53,7 @@ ACPI_MODULE_NAME("rsirq") ...@@ -53,7 +53,7 @@ ACPI_MODULE_NAME("rsirq")
* acpi_rs_get_irq * acpi_rs_get_irq
* *
******************************************************************************/ ******************************************************************************/
struct acpi_rsconvert_info acpi_rs_get_irq[8] = { struct acpi_rsconvert_info acpi_rs_get_irq[9] = {
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ, {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ,
ACPI_RS_SIZE(struct acpi_resource_irq), ACPI_RS_SIZE(struct acpi_resource_irq),
ACPI_RSC_TABLE_SIZE(acpi_rs_get_irq)}, ACPI_RSC_TABLE_SIZE(acpi_rs_get_irq)},
...@@ -80,7 +80,7 @@ struct acpi_rsconvert_info acpi_rs_get_irq[8] = { ...@@ -80,7 +80,7 @@ struct acpi_rsconvert_info acpi_rs_get_irq[8] = {
{ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3}, {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3},
/* Get flags: Triggering[0], Polarity[3], Sharing[4] */ /* Get flags: Triggering[0], Polarity[3], Sharing[4], Wake[5] */
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering), {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
AML_OFFSET(irq.flags), AML_OFFSET(irq.flags),
...@@ -92,7 +92,11 @@ struct acpi_rsconvert_info acpi_rs_get_irq[8] = { ...@@ -92,7 +92,11 @@ struct acpi_rsconvert_info acpi_rs_get_irq[8] = {
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable), {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
AML_OFFSET(irq.flags), AML_OFFSET(irq.flags),
4} 4},
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.wake_capable),
AML_OFFSET(irq.flags),
5}
}; };
/******************************************************************************* /*******************************************************************************
...@@ -101,7 +105,7 @@ struct acpi_rsconvert_info acpi_rs_get_irq[8] = { ...@@ -101,7 +105,7 @@ struct acpi_rsconvert_info acpi_rs_get_irq[8] = {
* *
******************************************************************************/ ******************************************************************************/
struct acpi_rsconvert_info acpi_rs_set_irq[13] = { struct acpi_rsconvert_info acpi_rs_set_irq[14] = {
/* Start with a default descriptor of length 3 */ /* Start with a default descriptor of length 3 */
{ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ, {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ,
...@@ -114,7 +118,7 @@ struct acpi_rsconvert_info acpi_rs_set_irq[13] = { ...@@ -114,7 +118,7 @@ struct acpi_rsconvert_info acpi_rs_set_irq[13] = {
AML_OFFSET(irq.irq_mask), AML_OFFSET(irq.irq_mask),
ACPI_RS_OFFSET(data.irq.interrupt_count)}, ACPI_RS_OFFSET(data.irq.interrupt_count)},
/* Set the flags byte */ /* Set flags: Triggering[0], Polarity[3], Sharing[4], Wake[5] */
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering), {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
AML_OFFSET(irq.flags), AML_OFFSET(irq.flags),
...@@ -128,6 +132,10 @@ struct acpi_rsconvert_info acpi_rs_set_irq[13] = { ...@@ -128,6 +132,10 @@ struct acpi_rsconvert_info acpi_rs_set_irq[13] = {
AML_OFFSET(irq.flags), AML_OFFSET(irq.flags),
4}, 4},
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.wake_capable),
AML_OFFSET(irq.flags),
5},
/* /*
* All done if the output descriptor length is required to be 3 * All done if the output descriptor length is required to be 3
* (i.e., optimization to 2 bytes cannot be attempted) * (i.e., optimization to 2 bytes cannot be attempted)
...@@ -181,7 +189,7 @@ struct acpi_rsconvert_info acpi_rs_set_irq[13] = { ...@@ -181,7 +189,7 @@ struct acpi_rsconvert_info acpi_rs_set_irq[13] = {
* *
******************************************************************************/ ******************************************************************************/
struct acpi_rsconvert_info acpi_rs_convert_ext_irq[9] = { struct acpi_rsconvert_info acpi_rs_convert_ext_irq[10] = {
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ, {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ,
ACPI_RS_SIZE(struct acpi_resource_extended_irq), ACPI_RS_SIZE(struct acpi_resource_extended_irq),
ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_irq)}, ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_irq)},
...@@ -190,8 +198,10 @@ struct acpi_rsconvert_info acpi_rs_convert_ext_irq[9] = { ...@@ -190,8 +198,10 @@ struct acpi_rsconvert_info acpi_rs_convert_ext_irq[9] = {
sizeof(struct aml_resource_extended_irq), sizeof(struct aml_resource_extended_irq),
0}, 0},
/* Flag bits */ /*
* Flags: Producer/Consumer[0], Triggering[1], Polarity[2],
* Sharing[3], Wake[4]
*/
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.producer_consumer), {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.producer_consumer),
AML_OFFSET(extended_irq.flags), AML_OFFSET(extended_irq.flags),
0}, 0},
...@@ -208,19 +218,21 @@ struct acpi_rsconvert_info acpi_rs_convert_ext_irq[9] = { ...@@ -208,19 +218,21 @@ struct acpi_rsconvert_info acpi_rs_convert_ext_irq[9] = {
AML_OFFSET(extended_irq.flags), AML_OFFSET(extended_irq.flags),
3}, 3},
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.wake_capable),
AML_OFFSET(extended_irq.flags),
4},
/* IRQ Table length (Byte4) */ /* IRQ Table length (Byte4) */
{ACPI_RSC_COUNT, ACPI_RS_OFFSET(data.extended_irq.interrupt_count), {ACPI_RSC_COUNT, ACPI_RS_OFFSET(data.extended_irq.interrupt_count),
AML_OFFSET(extended_irq.interrupt_count), AML_OFFSET(extended_irq.interrupt_count),
sizeof(u32)} sizeof(u32)},
,
/* Copy every IRQ in the table, each is 32 bits */ /* Copy every IRQ in the table, each is 32 bits */
{ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.extended_irq.interrupts[0]), {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.extended_irq.interrupts[0]),
AML_OFFSET(extended_irq.interrupts[0]), AML_OFFSET(extended_irq.interrupts[0]),
0} 0},
,
/* Optional resource_source (Index and String) */ /* Optional resource_source (Index and String) */
...@@ -285,7 +297,6 @@ struct acpi_rsconvert_info acpi_rs_convert_fixed_dma[4] = { ...@@ -285,7 +297,6 @@ struct acpi_rsconvert_info acpi_rs_convert_fixed_dma[4] = {
* request_lines * request_lines
* Channels * Channels
*/ */
{ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_dma.request_lines), {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_dma.request_lines),
AML_OFFSET(fixed_dma.request_lines), AML_OFFSET(fixed_dma.request_lines),
2}, 2},
...@@ -293,5 +304,4 @@ struct acpi_rsconvert_info acpi_rs_convert_fixed_dma[4] = { ...@@ -293,5 +304,4 @@ struct acpi_rsconvert_info acpi_rs_convert_fixed_dma[4] = {
{ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_dma.width), {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_dma.width),
AML_OFFSET(fixed_dma.width), AML_OFFSET(fixed_dma.width),
1}, 1},
}; };
...@@ -217,9 +217,10 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, ...@@ -217,9 +217,10 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
/* Perform final sanity check on the new AML resource descriptor */ /* Perform final sanity check on the new AML resource descriptor */
status = status = acpi_ut_validate_resource(NULL,
acpi_ut_validate_resource(ACPI_CAST_PTR ACPI_CAST_PTR(union
(union aml_resource, aml), NULL); aml_resource,
aml), NULL);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }
......
...@@ -156,8 +156,7 @@ struct acpi_rsconvert_info acpi_rs_get_vendor_small[3] = { ...@@ -156,8 +156,7 @@ struct acpi_rsconvert_info acpi_rs_get_vendor_small[3] = {
{ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length), {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
0, 0,
sizeof(u8)} sizeof(u8)},
,
/* Vendor data */ /* Vendor data */
...@@ -181,8 +180,7 @@ struct acpi_rsconvert_info acpi_rs_get_vendor_large[3] = { ...@@ -181,8 +180,7 @@ struct acpi_rsconvert_info acpi_rs_get_vendor_large[3] = {
{ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length), {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
0, 0,
sizeof(u8)} sizeof(u8)},
,
/* Vendor data */ /* Vendor data */
......
...@@ -136,30 +136,30 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, ...@@ -136,30 +136,30 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
/* /*
* Mask and shift the flag bit * Mask and shift the flag bit
*/ */
ACPI_SET8(destination) = (u8) ACPI_SET8(destination,
((ACPI_GET8(source) >> info->value) & 0x01); ((ACPI_GET8(source) >> info->value) & 0x01));
break; break;
case ACPI_RSC_2BITFLAG: case ACPI_RSC_2BITFLAG:
/* /*
* Mask and shift the flag bits * Mask and shift the flag bits
*/ */
ACPI_SET8(destination) = (u8) ACPI_SET8(destination,
((ACPI_GET8(source) >> info->value) & 0x03); ((ACPI_GET8(source) >> info->value) & 0x03));
break; break;
case ACPI_RSC_3BITFLAG: case ACPI_RSC_3BITFLAG:
/* /*
* Mask and shift the flag bits * Mask and shift the flag bits
*/ */
ACPI_SET8(destination) = (u8) ACPI_SET8(destination,
((ACPI_GET8(source) >> info->value) & 0x07); ((ACPI_GET8(source) >> info->value) & 0x07));
break; break;
case ACPI_RSC_COUNT: case ACPI_RSC_COUNT:
item_count = ACPI_GET8(source); item_count = ACPI_GET8(source);
ACPI_SET8(destination) = (u8) item_count; ACPI_SET8(destination, item_count);
resource->length = resource->length + resource->length = resource->length +
(info->value * (item_count - 1)); (info->value * (item_count - 1));
...@@ -168,7 +168,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, ...@@ -168,7 +168,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
case ACPI_RSC_COUNT16: case ACPI_RSC_COUNT16:
item_count = aml_resource_length; item_count = aml_resource_length;
ACPI_SET16(destination) = item_count; ACPI_SET16(destination, item_count);
resource->length = resource->length + resource->length = resource->length +
(info->value * (item_count - 1)); (info->value * (item_count - 1));
...@@ -181,13 +181,13 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, ...@@ -181,13 +181,13 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
resource->length = resource->length + item_count; resource->length = resource->length + item_count;
item_count = item_count / 2; item_count = item_count / 2;
ACPI_SET16(destination) = item_count; ACPI_SET16(destination, item_count);
break; break;
case ACPI_RSC_COUNT_GPIO_VEN: case ACPI_RSC_COUNT_GPIO_VEN:
item_count = ACPI_GET8(source); item_count = ACPI_GET8(source);
ACPI_SET8(destination) = (u8)item_count; ACPI_SET8(destination, item_count);
resource->length = resource->length + resource->length = resource->length +
(info->value * item_count); (info->value * item_count);
...@@ -216,7 +216,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, ...@@ -216,7 +216,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
} }
resource->length = resource->length + item_count; resource->length = resource->length + item_count;
ACPI_SET16(destination) = item_count; ACPI_SET16(destination, item_count);
break; break;
case ACPI_RSC_COUNT_SERIAL_VEN: case ACPI_RSC_COUNT_SERIAL_VEN:
...@@ -224,7 +224,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, ...@@ -224,7 +224,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
item_count = ACPI_GET16(source) - info->value; item_count = ACPI_GET16(source) - info->value;
resource->length = resource->length + item_count; resource->length = resource->length + item_count;
ACPI_SET16(destination) = item_count; ACPI_SET16(destination, item_count);
break; break;
case ACPI_RSC_COUNT_SERIAL_RES: case ACPI_RSC_COUNT_SERIAL_RES:
...@@ -234,7 +234,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, ...@@ -234,7 +234,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
- ACPI_GET16(source) - info->value; - ACPI_GET16(source) - info->value;
resource->length = resource->length + item_count; resource->length = resource->length + item_count;
ACPI_SET16(destination) = item_count; ACPI_SET16(destination, item_count);
break; break;
case ACPI_RSC_LENGTH: case ACPI_RSC_LENGTH:
...@@ -385,7 +385,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, ...@@ -385,7 +385,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
} }
target = ACPI_ADD_PTR(char, resource, info->value); target = ACPI_ADD_PTR(char, resource, info->value);
ACPI_SET8(target) = (u8) item_count; ACPI_SET8(target, item_count);
break; break;
case ACPI_RSC_BITMASK16: case ACPI_RSC_BITMASK16:
...@@ -401,7 +401,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, ...@@ -401,7 +401,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
} }
target = ACPI_ADD_PTR(char, resource, info->value); target = ACPI_ADD_PTR(char, resource, info->value);
ACPI_SET8(target) = (u8) item_count; ACPI_SET8(target, item_count);
break; break;
case ACPI_RSC_EXIT_NE: case ACPI_RSC_EXIT_NE:
...@@ -514,37 +514,40 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, ...@@ -514,37 +514,40 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
/* /*
* Clear the flag byte * Clear the flag byte
*/ */
ACPI_SET8(destination) = 0; ACPI_SET8(destination, 0);
break; break;
case ACPI_RSC_1BITFLAG: case ACPI_RSC_1BITFLAG:
/* /*
* Mask and shift the flag bit * Mask and shift the flag bit
*/ */
ACPI_SET8(destination) |= (u8) ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
((ACPI_GET8(source) & 0x01) << info->value); ((ACPI_GET8(source) & 0x01) << info->
value));
break; break;
case ACPI_RSC_2BITFLAG: case ACPI_RSC_2BITFLAG:
/* /*
* Mask and shift the flag bits * Mask and shift the flag bits
*/ */
ACPI_SET8(destination) |= (u8) ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
((ACPI_GET8(source) & 0x03) << info->value); ((ACPI_GET8(source) & 0x03) << info->
value));
break; break;
case ACPI_RSC_3BITFLAG: case ACPI_RSC_3BITFLAG:
/* /*
* Mask and shift the flag bits * Mask and shift the flag bits
*/ */
ACPI_SET8(destination) |= (u8) ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
((ACPI_GET8(source) & 0x07) << info->value); ((ACPI_GET8(source) & 0x07) << info->
value));
break; break;
case ACPI_RSC_COUNT: case ACPI_RSC_COUNT:
item_count = ACPI_GET8(source); item_count = ACPI_GET8(source);
ACPI_SET8(destination) = (u8) item_count; ACPI_SET8(destination, item_count);
aml_length = aml_length =
(u16) (aml_length + (u16) (aml_length +
...@@ -561,18 +564,18 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, ...@@ -561,18 +564,18 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
case ACPI_RSC_COUNT_GPIO_PIN: case ACPI_RSC_COUNT_GPIO_PIN:
item_count = ACPI_GET16(source); item_count = ACPI_GET16(source);
ACPI_SET16(destination) = (u16)aml_length; ACPI_SET16(destination, aml_length);
aml_length = (u16)(aml_length + item_count * 2); aml_length = (u16)(aml_length + item_count * 2);
target = ACPI_ADD_PTR(void, aml, info->value); target = ACPI_ADD_PTR(void, aml, info->value);
ACPI_SET16(target) = (u16)aml_length; ACPI_SET16(target, aml_length);
acpi_rs_set_resource_length(aml_length, aml); acpi_rs_set_resource_length(aml_length, aml);
break; break;
case ACPI_RSC_COUNT_GPIO_VEN: case ACPI_RSC_COUNT_GPIO_VEN:
item_count = ACPI_GET16(source); item_count = ACPI_GET16(source);
ACPI_SET16(destination) = (u16)item_count; ACPI_SET16(destination, item_count);
aml_length = aml_length =
(u16)(aml_length + (info->value * item_count)); (u16)(aml_length + (info->value * item_count));
...@@ -584,7 +587,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, ...@@ -584,7 +587,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
/* Set resource source string length */ /* Set resource source string length */
item_count = ACPI_GET16(source); item_count = ACPI_GET16(source);
ACPI_SET16(destination) = (u16)aml_length; ACPI_SET16(destination, aml_length);
/* Compute offset for the Vendor Data */ /* Compute offset for the Vendor Data */
...@@ -594,7 +597,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, ...@@ -594,7 +597,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
/* Set vendor offset only if there is vendor data */ /* Set vendor offset only if there is vendor data */
if (resource->data.gpio.vendor_length) { if (resource->data.gpio.vendor_length) {
ACPI_SET16(target) = (u16)aml_length; ACPI_SET16(target, aml_length);
} }
acpi_rs_set_resource_length(aml_length, aml); acpi_rs_set_resource_length(aml_length, aml);
...@@ -603,7 +606,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, ...@@ -603,7 +606,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
case ACPI_RSC_COUNT_SERIAL_VEN: case ACPI_RSC_COUNT_SERIAL_VEN:
item_count = ACPI_GET16(source); item_count = ACPI_GET16(source);
ACPI_SET16(destination) = item_count + info->value; ACPI_SET16(destination, item_count + info->value);
aml_length = (u16)(aml_length + item_count); aml_length = (u16)(aml_length + item_count);
acpi_rs_set_resource_length(aml_length, aml); acpi_rs_set_resource_length(aml_length, aml);
break; break;
...@@ -686,7 +689,8 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, ...@@ -686,7 +689,8 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
* Optional resource_source (Index and String) * Optional resource_source (Index and String)
*/ */
aml_length = aml_length =
acpi_rs_set_resource_source(aml, (acpi_rs_length) acpi_rs_set_resource_source(aml,
(acpi_rs_length)
aml_length, source); aml_length, source);
acpi_rs_set_resource_length(aml_length, aml); acpi_rs_set_resource_length(aml_length, aml);
break; break;
...@@ -706,10 +710,12 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource, ...@@ -706,10 +710,12 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
/* /*
* 8-bit encoded bitmask (DMA macro) * 8-bit encoded bitmask (DMA macro)
*/ */
ACPI_SET8(destination) = (u8) ACPI_SET8(destination,
acpi_rs_encode_bitmask(source, acpi_rs_encode_bitmask(source,
*ACPI_ADD_PTR(u8, resource, *ACPI_ADD_PTR(u8,
info->value)); resource,
info->
value)));
break; break;
case ACPI_RSC_BITMASK16: case ACPI_RSC_BITMASK16:
......
...@@ -53,7 +53,7 @@ ACPI_MODULE_NAME("rsserial") ...@@ -53,7 +53,7 @@ ACPI_MODULE_NAME("rsserial")
* acpi_rs_convert_gpio * acpi_rs_convert_gpio
* *
******************************************************************************/ ******************************************************************************/
struct acpi_rsconvert_info acpi_rs_convert_gpio[17] = { struct acpi_rsconvert_info acpi_rs_convert_gpio[18] = {
{ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GPIO, {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GPIO,
ACPI_RS_SIZE(struct acpi_resource_gpio), ACPI_RS_SIZE(struct acpi_resource_gpio),
ACPI_RSC_TABLE_SIZE(acpi_rs_convert_gpio)}, ACPI_RSC_TABLE_SIZE(acpi_rs_convert_gpio)},
...@@ -75,10 +75,14 @@ struct acpi_rsconvert_info acpi_rs_convert_gpio[17] = { ...@@ -75,10 +75,14 @@ struct acpi_rsconvert_info acpi_rs_convert_gpio[17] = {
AML_OFFSET(gpio.flags), AML_OFFSET(gpio.flags),
0}, 0},
{ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.sharable), {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.gpio.sharable),
AML_OFFSET(gpio.int_flags), AML_OFFSET(gpio.int_flags),
3}, 3},
{ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.gpio.wake_capable),
AML_OFFSET(gpio.int_flags),
4},
{ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.io_restriction), {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.io_restriction),
AML_OFFSET(gpio.int_flags), AML_OFFSET(gpio.int_flags),
0}, 0},
......
...@@ -108,7 +108,7 @@ u16 acpi_rs_encode_bitmask(u8 * list, u8 count) ...@@ -108,7 +108,7 @@ u16 acpi_rs_encode_bitmask(u8 * list, u8 count)
mask |= (0x1 << list[i]); mask |= (0x1 << list[i]);
} }
return mask; return (mask);
} }
/******************************************************************************* /*******************************************************************************
...@@ -358,8 +358,10 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length, ...@@ -358,8 +358,10 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length,
* *
* Zero the entire area of the buffer. * Zero the entire area of the buffer.
*/ */
total_length = (u32) total_length =
ACPI_STRLEN(ACPI_CAST_PTR(char, &aml_resource_source[1])) + 1; (u32)
ACPI_STRLEN(ACPI_CAST_PTR(char, &aml_resource_source[1])) +
1;
total_length = (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(total_length); total_length = (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(total_length);
ACPI_MEMSET(resource_source->string_ptr, 0, total_length); ACPI_MEMSET(resource_source->string_ptr, 0, total_length);
...@@ -675,7 +677,9 @@ acpi_rs_get_method_data(acpi_handle handle, ...@@ -675,7 +677,9 @@ acpi_rs_get_method_data(acpi_handle handle,
/* Execute the method, no parameters */ /* Execute the method, no parameters */
status = status =
acpi_ut_evaluate_object(handle, path, ACPI_BTYPE_BUFFER, &obj_desc); acpi_ut_evaluate_object(ACPI_CAST_PTR
(struct acpi_namespace_node, handle), path,
ACPI_BTYPE_BUFFER, &obj_desc);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }
......
...@@ -423,7 +423,7 @@ ACPI_EXPORT_SYMBOL(acpi_resource_to_address64) ...@@ -423,7 +423,7 @@ ACPI_EXPORT_SYMBOL(acpi_resource_to_address64)
* *
* RETURN: Status * RETURN: Status
* *
* DESCRIPTION: Walk a resource template for the specified evice to find a * DESCRIPTION: Walk a resource template for the specified device to find a
* vendor-defined resource that matches the supplied UUID and * vendor-defined resource that matches the supplied UUID and
* UUID subtype. Returns a struct acpi_resource of type Vendor. * UUID subtype. Returns a struct acpi_resource of type Vendor.
* *
...@@ -522,57 +522,42 @@ acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context) ...@@ -522,57 +522,42 @@ acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context)
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_walk_resources * FUNCTION: acpi_walk_resource_buffer
* *
* PARAMETERS: device_handle - Handle to the device object for the * PARAMETERS: buffer - Formatted buffer returned by one of the
* device we are querying * various Get*Resource functions
* name - Method name of the resources we want.
* (METHOD_NAME__CRS, METHOD_NAME__PRS, or
* METHOD_NAME__AEI)
* user_function - Called for each resource * user_function - Called for each resource
* context - Passed to user_function * context - Passed to user_function
* *
* RETURN: Status * RETURN: Status
* *
* DESCRIPTION: Retrieves the current or possible resource list for the * DESCRIPTION: Walks the input resource template. The user_function is called
* specified device. The user_function is called once for * once for each resource in the list.
* each resource in the list.
* *
******************************************************************************/ ******************************************************************************/
acpi_status acpi_status
acpi_walk_resources(acpi_handle device_handle, acpi_walk_resource_buffer(struct acpi_buffer * buffer,
char *name, acpi_walk_resource_callback user_function,
acpi_walk_resource_callback user_function, void *context) void *context)
{ {
acpi_status status; acpi_status status = AE_OK;
struct acpi_buffer buffer;
struct acpi_resource *resource; struct acpi_resource *resource;
struct acpi_resource *resource_end; struct acpi_resource *resource_end;
ACPI_FUNCTION_TRACE(acpi_walk_resources); ACPI_FUNCTION_TRACE(acpi_walk_resource_buffer);
/* Parameter validation */ /* Parameter validation */
if (!device_handle || !user_function || !name || if (!buffer || !buffer->pointer || !user_function) {
(!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) &&
!ACPI_COMPARE_NAME(name, METHOD_NAME__PRS) &&
!ACPI_COMPARE_NAME(name, METHOD_NAME__AEI))) {
return_ACPI_STATUS(AE_BAD_PARAMETER); return_ACPI_STATUS(AE_BAD_PARAMETER);
} }
/* Get the _CRS/_PRS/_AEI resource list */ /* Buffer contains the resource list and length */
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
status = acpi_rs_get_method_data(device_handle, name, &buffer);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Buffer now contains the resource list */
resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer); resource = ACPI_CAST_PTR(struct acpi_resource, buffer->pointer);
resource_end = resource_end =
ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length); ACPI_ADD_PTR(struct acpi_resource, buffer->pointer, buffer->length);
/* Walk the resource list until the end_tag is found (or buffer end) */ /* Walk the resource list until the end_tag is found (or buffer end) */
...@@ -606,11 +591,63 @@ acpi_walk_resources(acpi_handle device_handle, ...@@ -606,11 +591,63 @@ acpi_walk_resources(acpi_handle device_handle,
/* Get the next resource descriptor */ /* Get the next resource descriptor */
resource = resource = ACPI_NEXT_RESOURCE(resource);
ACPI_ADD_PTR(struct acpi_resource, resource,
resource->length);
} }
return_ACPI_STATUS(status);
}
ACPI_EXPORT_SYMBOL(acpi_walk_resource_buffer)
/*******************************************************************************
*
* FUNCTION: acpi_walk_resources
*
* PARAMETERS: device_handle - Handle to the device object for the
* device we are querying
* name - Method name of the resources we want.
* (METHOD_NAME__CRS, METHOD_NAME__PRS, or
* METHOD_NAME__AEI)
* user_function - Called for each resource
* context - Passed to user_function
*
* RETURN: Status
*
* DESCRIPTION: Retrieves the current or possible resource list for the
* specified device. The user_function is called once for
* each resource in the list.
*
******************************************************************************/
acpi_status
acpi_walk_resources(acpi_handle device_handle,
char *name,
acpi_walk_resource_callback user_function, void *context)
{
acpi_status status;
struct acpi_buffer buffer;
ACPI_FUNCTION_TRACE(acpi_walk_resources);
/* Parameter validation */
if (!device_handle || !user_function || !name ||
(!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) &&
!ACPI_COMPARE_NAME(name, METHOD_NAME__PRS) &&
!ACPI_COMPARE_NAME(name, METHOD_NAME__AEI))) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
/* Get the _CRS/_PRS/_AEI 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);
}
/* Walk the resource list and cleanup */
status = acpi_walk_resource_buffer(&buffer, user_function, context);
ACPI_FREE(buffer.pointer); ACPI_FREE(buffer.pointer);
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }
......
...@@ -172,6 +172,7 @@ static struct acpi_fadt_pm_info fadt_pm_info_table[] = { ...@@ -172,6 +172,7 @@ static struct acpi_fadt_pm_info fadt_pm_info_table[] = {
* FUNCTION: acpi_tb_init_generic_address * FUNCTION: acpi_tb_init_generic_address
* *
* PARAMETERS: generic_address - GAS struct to be initialized * PARAMETERS: generic_address - GAS struct to be initialized
* space_id - ACPI Space ID for this register
* byte_width - Width of this register * byte_width - Width of this register
* address - Address of the register * address - Address of the register
* *
...@@ -407,8 +408,8 @@ static void acpi_tb_convert_fadt(void) ...@@ -407,8 +408,8 @@ static void acpi_tb_convert_fadt(void)
* should be zero are indeed zero. This will workaround BIOSs that * should be zero are indeed zero. This will workaround BIOSs that
* inadvertently place values in these fields. * inadvertently place values in these fields.
* *
* The ACPI 1.0 reserved fields that will be zeroed are the bytes located at * The ACPI 1.0 reserved fields that will be zeroed are the bytes located
* offset 45, 55, 95, and the word located at offset 109, 110. * at offset 45, 55, 95, and the word located at offset 109, 110.
* *
* Note: The FADT revision value is unreliable. Only the length can be * Note: The FADT revision value is unreliable. Only the length can be
* trusted. * trusted.
......
...@@ -147,7 +147,7 @@ acpi_status acpi_tb_initialize_facs(void) ...@@ -147,7 +147,7 @@ acpi_status acpi_tb_initialize_facs(void)
ACPI_CAST_INDIRECT_PTR(struct ACPI_CAST_INDIRECT_PTR(struct
acpi_table_header, acpi_table_header,
&acpi_gbl_FACS)); &acpi_gbl_FACS));
return status; return (status);
} }
#endif /* !ACPI_REDUCED_HARDWARE */ #endif /* !ACPI_REDUCED_HARDWARE */
......
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
#include <linux/export.h> #include <linux/export.h>
#include <acpi/acpi.h> #include <acpi/acpi.h>
#include "accommon.h" #include "accommon.h"
#include "acnamesp.h"
#include "actables.h" #include "actables.h"
#define _COMPONENT ACPI_TABLES #define _COMPONENT ACPI_TABLES
...@@ -437,7 +436,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_table_by_index) ...@@ -437,7 +436,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_table_by_index)
* *
******************************************************************************/ ******************************************************************************/
acpi_status acpi_status
acpi_install_table_handler(acpi_tbl_handler handler, void *context) acpi_install_table_handler(acpi_table_handler handler, void *context)
{ {
acpi_status status; acpi_status status;
...@@ -483,7 +482,7 @@ ACPI_EXPORT_SYMBOL(acpi_install_table_handler) ...@@ -483,7 +482,7 @@ ACPI_EXPORT_SYMBOL(acpi_install_table_handler)
* DESCRIPTION: Remove table event handler * DESCRIPTION: Remove table event handler
* *
******************************************************************************/ ******************************************************************************/
acpi_status acpi_remove_table_handler(acpi_tbl_handler handler) acpi_status acpi_remove_table_handler(acpi_table_handler handler)
{ {
acpi_status status; acpi_status status;
......
...@@ -192,7 +192,7 @@ static acpi_status acpi_tb_load_namespace(void) ...@@ -192,7 +192,7 @@ static acpi_status acpi_tb_load_namespace(void)
(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
} }
ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); ACPI_INFO((AE_INFO, "All ACPI Tables successfully acquired"));
unlock_and_exit: unlock_and_exit:
(void)acpi_ut_release_mutex(ACPI_MTX_TABLES); (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
......
...@@ -214,7 +214,7 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id, ...@@ -214,7 +214,7 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id,
if ((space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) && if ((space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
(space_id != ACPI_ADR_SPACE_SYSTEM_IO)) { (space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
return_UINT32(0); return_VALUE(0);
} }
range_info = acpi_gbl_address_range_list[space_id]; range_info = acpi_gbl_address_range_list[space_id];
...@@ -256,7 +256,7 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id, ...@@ -256,7 +256,7 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id,
range_info = range_info->next; range_info = range_info->next;
} }
return_UINT32(overlap_count); return_VALUE(overlap_count);
} }
/******************************************************************************* /*******************************************************************************
......
...@@ -785,7 +785,7 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc, ...@@ -785,7 +785,7 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
status = acpi_os_create_mutex(&dest_desc->mutex.os_mutex); status = acpi_os_create_mutex(&dest_desc->mutex.os_mutex);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return status; return (status);
} }
break; break;
...@@ -795,7 +795,7 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc, ...@@ -795,7 +795,7 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
&dest_desc->event. &dest_desc->event.
os_semaphore); os_semaphore);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return status; return (status);
} }
break; break;
......
...@@ -166,11 +166,9 @@ acpi_debug_print(u32 requested_debug_level, ...@@ -166,11 +166,9 @@ acpi_debug_print(u32 requested_debug_level,
acpi_thread_id thread_id; acpi_thread_id thread_id;
va_list args; va_list args;
/* /* Check if debug output enabled */
* Stay silent if the debug level or component ID is disabled
*/ if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
if (!(requested_debug_level & acpi_dbg_level) ||
!(component_id & acpi_dbg_layer)) {
return; return;
} }
...@@ -236,8 +234,9 @@ acpi_debug_print_raw(u32 requested_debug_level, ...@@ -236,8 +234,9 @@ acpi_debug_print_raw(u32 requested_debug_level,
{ {
va_list args; va_list args;
if (!(requested_debug_level & acpi_dbg_level) || /* Check if debug output enabled */
!(component_id & acpi_dbg_layer)) {
if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
return; return;
} }
...@@ -272,9 +271,13 @@ acpi_ut_trace(u32 line_number, ...@@ -272,9 +271,13 @@ acpi_ut_trace(u32 line_number,
acpi_gbl_nesting_level++; acpi_gbl_nesting_level++;
acpi_ut_track_stack_ptr(); acpi_ut_track_stack_ptr();
acpi_debug_print(ACPI_LV_FUNCTIONS, /* Check if enabled up-front for performance */
line_number, function_name, module_name, component_id,
"%s\n", acpi_gbl_fn_entry_str); if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
acpi_debug_print(ACPI_LV_FUNCTIONS,
line_number, function_name, module_name,
component_id, "%s\n", acpi_gbl_fn_entry_str);
}
} }
ACPI_EXPORT_SYMBOL(acpi_ut_trace) ACPI_EXPORT_SYMBOL(acpi_ut_trace)
...@@ -304,9 +307,14 @@ acpi_ut_trace_ptr(u32 line_number, ...@@ -304,9 +307,14 @@ acpi_ut_trace_ptr(u32 line_number,
acpi_gbl_nesting_level++; acpi_gbl_nesting_level++;
acpi_ut_track_stack_ptr(); acpi_ut_track_stack_ptr();
acpi_debug_print(ACPI_LV_FUNCTIONS, /* Check if enabled up-front for performance */
line_number, function_name, module_name, component_id,
"%s %p\n", acpi_gbl_fn_entry_str, pointer); if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
acpi_debug_print(ACPI_LV_FUNCTIONS,
line_number, function_name, module_name,
component_id, "%s %p\n", acpi_gbl_fn_entry_str,
pointer);
}
} }
/******************************************************************************* /*******************************************************************************
...@@ -335,9 +343,14 @@ acpi_ut_trace_str(u32 line_number, ...@@ -335,9 +343,14 @@ acpi_ut_trace_str(u32 line_number,
acpi_gbl_nesting_level++; acpi_gbl_nesting_level++;
acpi_ut_track_stack_ptr(); acpi_ut_track_stack_ptr();
acpi_debug_print(ACPI_LV_FUNCTIONS, /* Check if enabled up-front for performance */
line_number, function_name, module_name, component_id,
"%s %s\n", acpi_gbl_fn_entry_str, string); if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
acpi_debug_print(ACPI_LV_FUNCTIONS,
line_number, function_name, module_name,
component_id, "%s %s\n", acpi_gbl_fn_entry_str,
string);
}
} }
/******************************************************************************* /*******************************************************************************
...@@ -366,9 +379,14 @@ acpi_ut_trace_u32(u32 line_number, ...@@ -366,9 +379,14 @@ acpi_ut_trace_u32(u32 line_number,
acpi_gbl_nesting_level++; acpi_gbl_nesting_level++;
acpi_ut_track_stack_ptr(); acpi_ut_track_stack_ptr();
acpi_debug_print(ACPI_LV_FUNCTIONS, /* Check if enabled up-front for performance */
line_number, function_name, module_name, component_id,
"%s %08X\n", acpi_gbl_fn_entry_str, integer); if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
acpi_debug_print(ACPI_LV_FUNCTIONS,
line_number, function_name, module_name,
component_id, "%s %08X\n",
acpi_gbl_fn_entry_str, integer);
}
} }
/******************************************************************************* /*******************************************************************************
...@@ -393,9 +411,13 @@ acpi_ut_exit(u32 line_number, ...@@ -393,9 +411,13 @@ acpi_ut_exit(u32 line_number,
const char *module_name, u32 component_id) const char *module_name, u32 component_id)
{ {
acpi_debug_print(ACPI_LV_FUNCTIONS, /* Check if enabled up-front for performance */
line_number, function_name, module_name, component_id,
"%s\n", acpi_gbl_fn_exit_str); if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
acpi_debug_print(ACPI_LV_FUNCTIONS,
line_number, function_name, module_name,
component_id, "%s\n", acpi_gbl_fn_exit_str);
}
acpi_gbl_nesting_level--; acpi_gbl_nesting_level--;
} }
...@@ -425,17 +447,23 @@ acpi_ut_status_exit(u32 line_number, ...@@ -425,17 +447,23 @@ acpi_ut_status_exit(u32 line_number,
u32 component_id, acpi_status status) u32 component_id, acpi_status status)
{ {
if (ACPI_SUCCESS(status)) { /* Check if enabled up-front for performance */
acpi_debug_print(ACPI_LV_FUNCTIONS,
line_number, function_name, module_name, if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
component_id, "%s %s\n", acpi_gbl_fn_exit_str, if (ACPI_SUCCESS(status)) {
acpi_format_exception(status)); acpi_debug_print(ACPI_LV_FUNCTIONS,
} else { line_number, function_name,
acpi_debug_print(ACPI_LV_FUNCTIONS, module_name, component_id, "%s %s\n",
line_number, function_name, module_name, acpi_gbl_fn_exit_str,
component_id, "%s ****Exception****: %s\n", acpi_format_exception(status));
acpi_gbl_fn_exit_str, } else {
acpi_format_exception(status)); acpi_debug_print(ACPI_LV_FUNCTIONS,
line_number, function_name,
module_name, component_id,
"%s ****Exception****: %s\n",
acpi_gbl_fn_exit_str,
acpi_format_exception(status));
}
} }
acpi_gbl_nesting_level--; acpi_gbl_nesting_level--;
...@@ -465,10 +493,15 @@ acpi_ut_value_exit(u32 line_number, ...@@ -465,10 +493,15 @@ acpi_ut_value_exit(u32 line_number,
const char *module_name, u32 component_id, u64 value) const char *module_name, u32 component_id, u64 value)
{ {
acpi_debug_print(ACPI_LV_FUNCTIONS, /* Check if enabled up-front for performance */
line_number, function_name, module_name, component_id,
"%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
ACPI_FORMAT_UINT64(value)); acpi_debug_print(ACPI_LV_FUNCTIONS,
line_number, function_name, module_name,
component_id, "%s %8.8X%8.8X\n",
acpi_gbl_fn_exit_str,
ACPI_FORMAT_UINT64(value));
}
acpi_gbl_nesting_level--; acpi_gbl_nesting_level--;
} }
...@@ -497,9 +530,14 @@ acpi_ut_ptr_exit(u32 line_number, ...@@ -497,9 +530,14 @@ acpi_ut_ptr_exit(u32 line_number,
const char *module_name, u32 component_id, u8 *ptr) const char *module_name, u32 component_id, u8 *ptr)
{ {
acpi_debug_print(ACPI_LV_FUNCTIONS, /* Check if enabled up-front for performance */
line_number, function_name, module_name, component_id,
"%s %p\n", acpi_gbl_fn_exit_str, ptr); if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
acpi_debug_print(ACPI_LV_FUNCTIONS,
line_number, function_name, module_name,
component_id, "%s %p\n", acpi_gbl_fn_exit_str,
ptr);
}
acpi_gbl_nesting_level--; acpi_gbl_nesting_level--;
} }
......
...@@ -340,7 +340,7 @@ void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list) ...@@ -340,7 +340,7 @@ void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list)
{ {
union acpi_operand_object **internal_obj; union acpi_operand_object **internal_obj;
ACPI_FUNCTION_TRACE(ut_delete_internal_object_list); ACPI_FUNCTION_ENTRY();
/* Walk the null-terminated internal list */ /* Walk the null-terminated internal list */
...@@ -351,7 +351,7 @@ void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list) ...@@ -351,7 +351,7 @@ void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list)
/* Free the combined parameter pointer list and object array */ /* Free the combined parameter pointer list and object array */
ACPI_FREE(obj_list); ACPI_FREE(obj_list);
return_VOID; return;
} }
/******************************************************************************* /*******************************************************************************
...@@ -484,7 +484,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) ...@@ -484,7 +484,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
union acpi_generic_state *state; union acpi_generic_state *state;
u32 i; u32 i;
ACPI_FUNCTION_TRACE_PTR(ut_update_object_reference, object); ACPI_FUNCTION_NAME(ut_update_object_reference);
while (object) { while (object) {
...@@ -493,7 +493,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) ...@@ -493,7 +493,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
if (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) { if (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) {
ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
"Object %p is NS handle\n", object)); "Object %p is NS handle\n", object));
return_ACPI_STATUS(AE_OK); return (AE_OK);
} }
/* /*
...@@ -530,18 +530,42 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) ...@@ -530,18 +530,42 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
*/ */
for (i = 0; i < object->package.count; i++) { for (i = 0; i < object->package.count; i++) {
/* /*
* Push each element onto the stack for later processing. * Null package elements are legal and can be simply
* Note: There can be null elements within the package, * ignored.
* these are simply ignored
*/ */
status = next_object = object->package.elements[i];
acpi_ut_create_update_state_and_push if (!next_object) {
(object->package.elements[i], action, continue;
&state_list); }
if (ACPI_FAILURE(status)) {
goto error_exit; switch (next_object->common.type) {
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
/*
* For these very simple sub-objects, we can just
* update the reference count here and continue.
* Greatly increases performance of this operation.
*/
acpi_ut_update_ref_count(next_object,
action);
break;
default:
/*
* For complex sub-objects, push them onto the stack
* for later processing (this eliminates recursion.)
*/
status =
acpi_ut_create_update_state_and_push
(next_object, action, &state_list);
if (ACPI_FAILURE(status)) {
goto error_exit;
}
break;
} }
} }
next_object = NULL;
break; break;
case ACPI_TYPE_BUFFER_FIELD: case ACPI_TYPE_BUFFER_FIELD:
...@@ -619,7 +643,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) ...@@ -619,7 +643,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
} }
} }
return_ACPI_STATUS(AE_OK); return (AE_OK);
error_exit: error_exit:
...@@ -633,7 +657,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) ...@@ -633,7 +657,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
acpi_ut_delete_generic_state(state); acpi_ut_delete_generic_state(state);
} }
return_ACPI_STATUS(status); return (status);
} }
/******************************************************************************* /*******************************************************************************
...@@ -652,12 +676,12 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) ...@@ -652,12 +676,12 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
void acpi_ut_add_reference(union acpi_operand_object *object) void acpi_ut_add_reference(union acpi_operand_object *object)
{ {
ACPI_FUNCTION_TRACE_PTR(ut_add_reference, object); ACPI_FUNCTION_NAME(ut_add_reference);
/* Ensure that we have a valid object */ /* Ensure that we have a valid object */
if (!acpi_ut_valid_internal_object(object)) { if (!acpi_ut_valid_internal_object(object)) {
return_VOID; return;
} }
ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
...@@ -667,7 +691,7 @@ void acpi_ut_add_reference(union acpi_operand_object *object) ...@@ -667,7 +691,7 @@ void acpi_ut_add_reference(union acpi_operand_object *object)
/* Increment the reference count */ /* Increment the reference count */
(void)acpi_ut_update_object_reference(object, REF_INCREMENT); (void)acpi_ut_update_object_reference(object, REF_INCREMENT);
return_VOID; return;
} }
/******************************************************************************* /*******************************************************************************
...@@ -685,7 +709,7 @@ void acpi_ut_add_reference(union acpi_operand_object *object) ...@@ -685,7 +709,7 @@ void acpi_ut_add_reference(union acpi_operand_object *object)
void acpi_ut_remove_reference(union acpi_operand_object *object) void acpi_ut_remove_reference(union acpi_operand_object *object)
{ {
ACPI_FUNCTION_TRACE_PTR(ut_remove_reference, object); ACPI_FUNCTION_NAME(ut_remove_reference);
/* /*
* Allow a NULL pointer to be passed in, just ignore it. This saves * Allow a NULL pointer to be passed in, just ignore it. This saves
...@@ -694,13 +718,13 @@ void acpi_ut_remove_reference(union acpi_operand_object *object) ...@@ -694,13 +718,13 @@ void acpi_ut_remove_reference(union acpi_operand_object *object)
*/ */
if (!object || if (!object ||
(ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) { (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) {
return_VOID; return;
} }
/* Ensure that we have a valid object */ /* Ensure that we have a valid object */
if (!acpi_ut_valid_internal_object(object)) { if (!acpi_ut_valid_internal_object(object)) {
return_VOID; return;
} }
ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
...@@ -713,5 +737,5 @@ void acpi_ut_remove_reference(union acpi_operand_object *object) ...@@ -713,5 +737,5 @@ void acpi_ut_remove_reference(union acpi_operand_object *object)
* of all subobjects!) * of all subobjects!)
*/ */
(void)acpi_ut_update_object_reference(object, REF_DECREMENT); (void)acpi_ut_update_object_reference(object, REF_DECREMENT);
return_VOID; return;
} }
...@@ -68,7 +68,7 @@ ACPI_MODULE_NAME("uteval") ...@@ -68,7 +68,7 @@ ACPI_MODULE_NAME("uteval")
******************************************************************************/ ******************************************************************************/
acpi_status acpi_status
acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, acpi_ut_evaluate_object(struct acpi_namespace_node * prefix_node,
char *path, char *path,
u32 expected_return_btypes, u32 expected_return_btypes,
union acpi_operand_object **return_desc) union acpi_operand_object **return_desc)
......
...@@ -293,11 +293,11 @@ acpi_status acpi_ut_init_globals(void) ...@@ -293,11 +293,11 @@ acpi_status acpi_ut_init_globals(void)
/* GPE support */ /* GPE support */
acpi_gbl_all_gpes_initialized = FALSE;
acpi_gbl_gpe_xrupt_list_head = NULL; acpi_gbl_gpe_xrupt_list_head = NULL;
acpi_gbl_gpe_fadt_blocks[0] = NULL; acpi_gbl_gpe_fadt_blocks[0] = NULL;
acpi_gbl_gpe_fadt_blocks[1] = NULL; acpi_gbl_gpe_fadt_blocks[1] = NULL;
acpi_current_gpe_count = 0; acpi_current_gpe_count = 0;
acpi_gbl_all_gpes_initialized = FALSE;
acpi_gbl_global_event_handler = NULL; acpi_gbl_global_event_handler = NULL;
...@@ -357,17 +357,24 @@ acpi_status acpi_ut_init_globals(void) ...@@ -357,17 +357,24 @@ acpi_status acpi_ut_init_globals(void)
acpi_gbl_root_node_struct.peer = NULL; acpi_gbl_root_node_struct.peer = NULL;
acpi_gbl_root_node_struct.object = NULL; acpi_gbl_root_node_struct.object = NULL;
#ifdef ACPI_DISASSEMBLER
acpi_gbl_external_list = NULL;
#endif
#ifdef ACPI_DEBUG_OUTPUT #ifdef ACPI_DEBUG_OUTPUT
acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX); acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX);
#endif #endif
#ifdef ACPI_DBG_TRACK_ALLOCATIONS #ifdef ACPI_DBG_TRACK_ALLOCATIONS
acpi_gbl_display_final_mem_stats = FALSE; acpi_gbl_display_final_mem_stats = FALSE;
acpi_gbl_disable_mem_tracking = FALSE;
#endif #endif
return_ACPI_STATUS(AE_OK); return_ACPI_STATUS(AE_OK);
} }
/* Public globals */
ACPI_EXPORT_SYMBOL(acpi_gbl_FADT) ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
ACPI_EXPORT_SYMBOL(acpi_dbg_level) ACPI_EXPORT_SYMBOL(acpi_dbg_level)
ACPI_EXPORT_SYMBOL(acpi_dbg_layer) ACPI_EXPORT_SYMBOL(acpi_dbg_layer)
......
...@@ -66,11 +66,11 @@ acpi_status acpi_ut_create_rw_lock(struct acpi_rw_lock *lock) ...@@ -66,11 +66,11 @@ acpi_status acpi_ut_create_rw_lock(struct acpi_rw_lock *lock)
lock->num_readers = 0; lock->num_readers = 0;
status = acpi_os_create_mutex(&lock->reader_mutex); status = acpi_os_create_mutex(&lock->reader_mutex);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return status; return (status);
} }
status = acpi_os_create_mutex(&lock->writer_mutex); status = acpi_os_create_mutex(&lock->writer_mutex);
return status; return (status);
} }
void acpi_ut_delete_rw_lock(struct acpi_rw_lock *lock) void acpi_ut_delete_rw_lock(struct acpi_rw_lock *lock)
...@@ -108,7 +108,7 @@ acpi_status acpi_ut_acquire_read_lock(struct acpi_rw_lock *lock) ...@@ -108,7 +108,7 @@ acpi_status acpi_ut_acquire_read_lock(struct acpi_rw_lock *lock)
status = acpi_os_acquire_mutex(lock->reader_mutex, ACPI_WAIT_FOREVER); status = acpi_os_acquire_mutex(lock->reader_mutex, ACPI_WAIT_FOREVER);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return status; return (status);
} }
/* Acquire the write lock only for the first reader */ /* Acquire the write lock only for the first reader */
...@@ -121,7 +121,7 @@ acpi_status acpi_ut_acquire_read_lock(struct acpi_rw_lock *lock) ...@@ -121,7 +121,7 @@ acpi_status acpi_ut_acquire_read_lock(struct acpi_rw_lock *lock)
} }
acpi_os_release_mutex(lock->reader_mutex); acpi_os_release_mutex(lock->reader_mutex);
return status; return (status);
} }
acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock) acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock)
...@@ -130,7 +130,7 @@ acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock) ...@@ -130,7 +130,7 @@ acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock)
status = acpi_os_acquire_mutex(lock->reader_mutex, ACPI_WAIT_FOREVER); status = acpi_os_acquire_mutex(lock->reader_mutex, ACPI_WAIT_FOREVER);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return status; return (status);
} }
/* Release the write lock only for the very last reader */ /* Release the write lock only for the very last reader */
...@@ -141,7 +141,7 @@ acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock) ...@@ -141,7 +141,7 @@ acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock)
} }
acpi_os_release_mutex(lock->reader_mutex); acpi_os_release_mutex(lock->reader_mutex);
return status; return (status);
} }
/******************************************************************************* /*******************************************************************************
...@@ -165,7 +165,7 @@ acpi_status acpi_ut_acquire_write_lock(struct acpi_rw_lock *lock) ...@@ -165,7 +165,7 @@ acpi_status acpi_ut_acquire_write_lock(struct acpi_rw_lock *lock)
acpi_status status; acpi_status status;
status = acpi_os_acquire_mutex(lock->writer_mutex, ACPI_WAIT_FOREVER); status = acpi_os_acquire_mutex(lock->writer_mutex, ACPI_WAIT_FOREVER);
return status; return (status);
} }
void acpi_ut_release_write_lock(struct acpi_rw_lock *lock) void acpi_ut_release_write_lock(struct acpi_rw_lock *lock)
......
...@@ -48,36 +48,6 @@ ...@@ -48,36 +48,6 @@
#define _COMPONENT ACPI_UTILITIES #define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME("utmisc") ACPI_MODULE_NAME("utmisc")
#if defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP
/*******************************************************************************
*
* FUNCTION: ut_convert_backslashes
*
* PARAMETERS: pathname - File pathname string to be converted
*
* RETURN: Modifies the input Pathname
*
* DESCRIPTION: Convert all backslashes (0x5C) to forward slashes (0x2F) within
* the entire input file pathname string.
*
******************************************************************************/
void ut_convert_backslashes(char *pathname)
{
if (!pathname) {
return;
}
while (*pathname) {
if (*pathname == '\\') {
*pathname = '/';
}
pathname++;
}
}
#endif
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ut_is_pci_root_bridge * FUNCTION: acpi_ut_is_pci_root_bridge
...@@ -89,7 +59,6 @@ void ut_convert_backslashes(char *pathname) ...@@ -89,7 +59,6 @@ void ut_convert_backslashes(char *pathname)
* DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID.
* *
******************************************************************************/ ******************************************************************************/
u8 acpi_ut_is_pci_root_bridge(char *id) u8 acpi_ut_is_pci_root_bridge(char *id)
{ {
...@@ -134,362 +103,6 @@ u8 acpi_ut_is_aml_table(struct acpi_table_header *table) ...@@ -134,362 +103,6 @@ u8 acpi_ut_is_aml_table(struct acpi_table_header *table)
return (FALSE); return (FALSE);
} }
/*******************************************************************************
*
* FUNCTION: acpi_ut_allocate_owner_id
*
* PARAMETERS: owner_id - Where the new owner ID is returned
*
* RETURN: Status
*
* DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
* track objects created by the table or method, to be deleted
* when the method exits or the table is unloaded.
*
******************************************************************************/
acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
{
u32 i;
u32 j;
u32 k;
acpi_status status;
ACPI_FUNCTION_TRACE(ut_allocate_owner_id);
/* Guard against multiple allocations of ID to the same location */
if (*owner_id) {
ACPI_ERROR((AE_INFO, "Owner ID [0x%2.2X] already exists",
*owner_id));
return_ACPI_STATUS(AE_ALREADY_EXISTS);
}
/* Mutex for the global ID mask */
status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/*
* Find a free owner ID, cycle through all possible IDs on repeated
* allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have
* to be scanned twice.
*/
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 */
}
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 */
break;
}
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 OwnerId: %2.2X\n",
(unsigned int)*owner_id));
goto exit;
}
}
acpi_gbl_next_owner_id_offset = 0;
}
/*
* 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.
*/
status = AE_OWNER_ID_LIMIT;
ACPI_ERROR((AE_INFO,
"Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT"));
exit:
(void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_release_owner_id
*
* PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_ID
*
* RETURN: None. No error is returned because we are either exiting a
* 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 - 255
*
******************************************************************************/
void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
{
acpi_owner_id owner_id = *owner_id_ptr;
acpi_status status;
u32 index;
u32 bit;
ACPI_FUNCTION_TRACE_U32(ut_release_owner_id, owner_id);
/* Always clear the input owner_id (zero is an invalid ID) */
*owner_id_ptr = 0;
/* Zero is not a valid owner_ID */
if (owner_id == 0) {
ACPI_ERROR((AE_INFO, "Invalid OwnerId: 0x%2.2X", owner_id));
return_VOID;
}
/* Mutex for the global ID mask */
status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
if (ACPI_FAILURE(status)) {
return_VOID;
}
/* Normalize the ID to zero */
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[index] & bit) {
acpi_gbl_owner_id_mask[index] ^= bit;
} else {
ACPI_ERROR((AE_INFO,
"Release of non-allocated OwnerId: 0x%2.2X",
owner_id + 1));
}
(void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
return_VOID;
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_strupr (strupr)
*
* PARAMETERS: src_string - The source string to convert
*
* RETURN: None
*
* DESCRIPTION: Convert string to uppercase
*
* NOTE: This is not a POSIX function, so it appears here, not in utclib.c
*
******************************************************************************/
void acpi_ut_strupr(char *src_string)
{
char *string;
ACPI_FUNCTION_ENTRY();
if (!src_string) {
return;
}
/* Walk entire string, uppercasing the letters */
for (string = src_string; *string; string++) {
*string = (char)ACPI_TOUPPER(*string);
}
return;
}
#ifdef ACPI_ASL_COMPILER
/*******************************************************************************
*
* FUNCTION: acpi_ut_strlwr (strlwr)
*
* PARAMETERS: src_string - The source string to convert
*
* RETURN: None
*
* DESCRIPTION: Convert string to lowercase
*
* NOTE: This is not a POSIX function, so it appears here, not in utclib.c
*
******************************************************************************/
void acpi_ut_strlwr(char *src_string)
{
char *string;
ACPI_FUNCTION_ENTRY();
if (!src_string) {
return;
}
/* Walk entire string, lowercasing the letters */
for (string = src_string; *string; string++) {
*string = (char)ACPI_TOLOWER(*string);
}
return;
}
/******************************************************************************
*
* FUNCTION: acpi_ut_stricmp
*
* PARAMETERS: string1 - first string to compare
* string2 - second string to compare
*
* RETURN: int that signifies string relationship. Zero means strings
* are equal.
*
* DESCRIPTION: Implementation of the non-ANSI stricmp function (compare
* strings with no case sensitivity)
*
******************************************************************************/
int acpi_ut_stricmp(char *string1, char *string2)
{
int c1;
int c2;
do {
c1 = tolower((int)*string1);
c2 = tolower((int)*string2);
string1++;
string2++;
}
while ((c1 == c2) && (c1));
return (c1 - c2);
}
#endif
/*******************************************************************************
*
* FUNCTION: acpi_ut_print_string
*
* PARAMETERS: string - Null terminated ASCII string
* max_length - Maximum output length
*
* RETURN: None
*
* DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
* sequences.
*
******************************************************************************/
void acpi_ut_print_string(char *string, u8 max_length)
{
u32 i;
if (!string) {
acpi_os_printf("<\"NULL STRING PTR\">");
return;
}
acpi_os_printf("\"");
for (i = 0; string[i] && (i < max_length); i++) {
/* Escape sequences */
switch (string[i]) {
case 0x07:
acpi_os_printf("\\a"); /* BELL */
break;
case 0x08:
acpi_os_printf("\\b"); /* BACKSPACE */
break;
case 0x0C:
acpi_os_printf("\\f"); /* FORMFEED */
break;
case 0x0A:
acpi_os_printf("\\n"); /* LINEFEED */
break;
case 0x0D:
acpi_os_printf("\\r"); /* CARRIAGE RETURN */
break;
case 0x09:
acpi_os_printf("\\t"); /* HORIZONTAL TAB */
break;
case 0x0B:
acpi_os_printf("\\v"); /* VERTICAL TAB */
break;
case '\'': /* Single Quote */
case '\"': /* Double Quote */
case '\\': /* Backslash */
acpi_os_printf("\\%c", (int)string[i]);
break;
default:
/* Check for printable character or hex escape */
if (ACPI_IS_PRINT(string[i])) {
/* This is a normal character */
acpi_os_printf("%c", (int)string[i]);
} else {
/* All others will be Hex escapes */
acpi_os_printf("\\x%2.2X", (s32) string[i]);
}
break;
}
}
acpi_os_printf("\"");
if (i == max_length && string[i]) {
acpi_os_printf("...");
}
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ut_dword_byte_swap * FUNCTION: acpi_ut_dword_byte_swap
...@@ -559,379 +172,6 @@ void acpi_ut_set_integer_width(u8 revision) ...@@ -559,379 +172,6 @@ void acpi_ut_set_integer_width(u8 revision)
} }
} }
#ifdef ACPI_DEBUG_OUTPUT
/*******************************************************************************
*
* FUNCTION: acpi_ut_display_init_pathname
*
* PARAMETERS: type - Object type of the node
* obj_handle - Handle whose pathname will be displayed
* path - Additional path string to be appended.
* (NULL if no extra path)
*
* RETURN: acpi_status
*
* DESCRIPTION: Display full pathname of an object, DEBUG ONLY
*
******************************************************************************/
void
acpi_ut_display_init_pathname(u8 type,
struct acpi_namespace_node *obj_handle,
char *path)
{
acpi_status status;
struct acpi_buffer buffer;
ACPI_FUNCTION_ENTRY();
/* Only print the path if the appropriate debug level is enabled */
if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
return;
}
/* Get the full pathname to the node */
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
status = acpi_ns_handle_to_pathname(obj_handle, &buffer);
if (ACPI_FAILURE(status)) {
return;
}
/* Print what we're doing */
switch (type) {
case ACPI_TYPE_METHOD:
acpi_os_printf("Executing ");
break;
default:
acpi_os_printf("Initializing ");
break;
}
/* Print the object type and pathname */
acpi_os_printf("%-12s %s",
acpi_ut_get_type_name(type), (char *)buffer.pointer);
/* Extra path is used to append names like _STA, _INI, etc. */
if (path) {
acpi_os_printf(".%s", path);
}
acpi_os_printf("\n");
ACPI_FREE(buffer.pointer);
}
#endif
/*******************************************************************************
*
* FUNCTION: acpi_ut_valid_acpi_char
*
* PARAMETERS: char - The character to be examined
* position - Byte position (0-3)
*
* RETURN: TRUE if the character is valid, FALSE otherwise
*
* DESCRIPTION: Check for a valid ACPI character. Must be one of:
* 1) Upper case alpha
* 2) numeric
* 3) underscore
*
* We allow a '!' as the last character because of the ASF! table
*
******************************************************************************/
u8 acpi_ut_valid_acpi_char(char character, u32 position)
{
if (!((character >= 'A' && character <= 'Z') ||
(character >= '0' && character <= '9') || (character == '_'))) {
/* Allow a '!' in the last position */
if (character == '!' && position == 3) {
return (TRUE);
}
return (FALSE);
}
return (TRUE);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_valid_acpi_name
*
* PARAMETERS: name - The name to be examined
*
* RETURN: TRUE if the name is valid, FALSE otherwise
*
* DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
* 1) Upper case alpha
* 2) numeric
* 3) underscore
*
******************************************************************************/
u8 acpi_ut_valid_acpi_name(u32 name)
{
u32 i;
ACPI_FUNCTION_ENTRY();
for (i = 0; i < ACPI_NAME_SIZE; i++) {
if (!acpi_ut_valid_acpi_char
((ACPI_CAST_PTR(char, &name))[i], i)) {
return (FALSE);
}
}
return (TRUE);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_repair_name
*
* PARAMETERS: name - The ACPI name to be repaired
*
* RETURN: Repaired version of the name
*
* DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and
* return the new name. NOTE: the Name parameter must reside in
* read/write memory, cannot be a const.
*
* An ACPI Name must consist of valid ACPI characters. We will repair the name
* if necessary because we don't want to abort because of this, but we want
* all namespace names to be printable. A warning message is appropriate.
*
* This issue came up because there are in fact machines that exhibit
* this problem, and we want to be able to enable ACPI support for them,
* even though there are a few bad names.
*
******************************************************************************/
void acpi_ut_repair_name(char *name)
{
u32 i;
u8 found_bad_char = FALSE;
u32 original_name;
ACPI_FUNCTION_NAME(ut_repair_name);
ACPI_MOVE_NAME(&original_name, name);
/* Check each character in the name */
for (i = 0; i < ACPI_NAME_SIZE; i++) {
if (acpi_ut_valid_acpi_char(name[i], i)) {
continue;
}
/*
* Replace a bad character with something printable, yet technically
* still invalid. This prevents any collisions with existing "good"
* names in the namespace.
*/
name[i] = '*';
found_bad_char = TRUE;
}
if (found_bad_char) {
/* Report warning only if in strict mode or debug mode */
if (!acpi_gbl_enable_interpreter_slack) {
ACPI_WARNING((AE_INFO,
"Found bad character(s) in name, repaired: [%4.4s]\n",
name));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Found bad character(s) in name, repaired: [%4.4s]\n",
name));
}
}
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_strtoul64
*
* PARAMETERS: string - Null terminated string
* base - Radix of the string: 16 or ACPI_ANY_BASE;
* ACPI_ANY_BASE means 'in behalf of to_integer'
* ret_integer - Where the converted integer is returned
*
* RETURN: Status and Converted value
*
* DESCRIPTION: Convert a string into an unsigned value. Performs either a
* 32-bit or 64-bit conversion, depending on the current mode
* of the interpreter.
* NOTE: Does not support Octal strings, not needed.
*
******************************************************************************/
acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)
{
u32 this_digit = 0;
u64 return_value = 0;
u64 quotient;
u64 dividend;
u32 to_integer_op = (base == ACPI_ANY_BASE);
u32 mode32 = (acpi_gbl_integer_byte_width == 4);
u8 valid_digits = 0;
u8 sign_of0x = 0;
u8 term = 0;
ACPI_FUNCTION_TRACE_STR(ut_stroul64, string);
switch (base) {
case ACPI_ANY_BASE:
case 16:
break;
default:
/* Invalid Base */
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
if (!string) {
goto error_exit;
}
/* Skip over any white space in the buffer */
while ((*string) && (ACPI_IS_SPACE(*string) || *string == '\t')) {
string++;
}
if (to_integer_op) {
/*
* Base equal to ACPI_ANY_BASE means 'ToInteger operation case'.
* We need to determine if it is decimal or hexadecimal.
*/
if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
sign_of0x = 1;
base = 16;
/* Skip over the leading '0x' */
string += 2;
} else {
base = 10;
}
}
/* Any string left? Check that '0x' is not followed by white space. */
if (!(*string) || ACPI_IS_SPACE(*string) || *string == '\t') {
if (to_integer_op) {
goto error_exit;
} else {
goto all_done;
}
}
/*
* Perform a 32-bit or 64-bit conversion, depending upon the current
* execution mode of the interpreter
*/
dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
/* Main loop: convert the string to a 32- or 64-bit integer */
while (*string) {
if (ACPI_IS_DIGIT(*string)) {
/* Convert ASCII 0-9 to Decimal value */
this_digit = ((u8)*string) - '0';
} else if (base == 10) {
/* Digit is out of range; possible in to_integer case only */
term = 1;
} else {
this_digit = (u8)ACPI_TOUPPER(*string);
if (ACPI_IS_XDIGIT((char)this_digit)) {
/* Convert ASCII Hex char to value */
this_digit = this_digit - 'A' + 10;
} else {
term = 1;
}
}
if (term) {
if (to_integer_op) {
goto error_exit;
} else {
break;
}
} else if ((valid_digits == 0) && (this_digit == 0)
&& !sign_of0x) {
/* Skip zeros */
string++;
continue;
}
valid_digits++;
if (sign_of0x
&& ((valid_digits > 16)
|| ((valid_digits > 8) && mode32))) {
/*
* This is to_integer operation case.
* No any restrictions for string-to-integer conversion,
* see ACPI spec.
*/
goto error_exit;
}
/* Divide the digit into the correct position */
(void)acpi_ut_short_divide((dividend - (u64)this_digit),
base, &quotient, NULL);
if (return_value > quotient) {
if (to_integer_op) {
goto error_exit;
} else {
break;
}
}
return_value *= base;
return_value += this_digit;
string++;
}
/* All done, normal exit */
all_done:
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
ACPI_FORMAT_UINT64(return_value)));
*ret_integer = return_value;
return_ACPI_STATUS(AE_OK);
error_exit:
/* Base was set/validated above */
if (base == 10) {
return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT);
} else {
return_ACPI_STATUS(AE_BAD_HEX_CONSTANT);
}
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ut_create_update_state_and_push * FUNCTION: acpi_ut_create_update_state_and_push
...@@ -1097,3 +337,71 @@ acpi_ut_walk_package_tree(union acpi_operand_object *source_object, ...@@ -1097,3 +337,71 @@ acpi_ut_walk_package_tree(union acpi_operand_object *source_object,
return_ACPI_STATUS(AE_AML_INTERNAL); return_ACPI_STATUS(AE_AML_INTERNAL);
} }
#ifdef ACPI_DEBUG_OUTPUT
/*******************************************************************************
*
* FUNCTION: acpi_ut_display_init_pathname
*
* PARAMETERS: type - Object type of the node
* obj_handle - Handle whose pathname will be displayed
* path - Additional path string to be appended.
* (NULL if no extra path)
*
* RETURN: acpi_status
*
* DESCRIPTION: Display full pathname of an object, DEBUG ONLY
*
******************************************************************************/
void
acpi_ut_display_init_pathname(u8 type,
struct acpi_namespace_node *obj_handle,
char *path)
{
acpi_status status;
struct acpi_buffer buffer;
ACPI_FUNCTION_ENTRY();
/* Only print the path if the appropriate debug level is enabled */
if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
return;
}
/* Get the full pathname to the node */
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
status = acpi_ns_handle_to_pathname(obj_handle, &buffer);
if (ACPI_FAILURE(status)) {
return;
}
/* Print what we're doing */
switch (type) {
case ACPI_TYPE_METHOD:
acpi_os_printf("Executing ");
break;
default:
acpi_os_printf("Initializing ");
break;
}
/* Print the object type and pathname */
acpi_os_printf("%-12s %s",
acpi_ut_get_type_name(type), (char *)buffer.pointer);
/* Extra path is used to append names like _STA, _INI, etc. */
if (path) {
acpi_os_printf(".%s", path);
}
acpi_os_printf("\n");
ACPI_FREE(buffer.pointer);
}
#endif
...@@ -419,7 +419,7 @@ void acpi_ut_delete_object_desc(union acpi_operand_object *object) ...@@ -419,7 +419,7 @@ void acpi_ut_delete_object_desc(union acpi_operand_object *object)
{ {
ACPI_FUNCTION_TRACE_PTR(ut_delete_object_desc, object); ACPI_FUNCTION_TRACE_PTR(ut_delete_object_desc, object);
/* Object must be a union acpi_operand_object */ /* Object must be of type union acpi_operand_object */
if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) { if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
ACPI_ERROR((AE_INFO, ACPI_ERROR((AE_INFO,
......
/*******************************************************************************
*
* Module Name: utownerid - Support for Table/Method Owner IDs
*
******************************************************************************/
/*
* Copyright (C) 2000 - 2012, Intel Corp.
* 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 <acpi/acpi.h>
#include "accommon.h"
#include "acnamesp.h"
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME("utownerid")
/*******************************************************************************
*
* FUNCTION: acpi_ut_allocate_owner_id
*
* PARAMETERS: owner_id - Where the new owner ID is returned
*
* RETURN: Status
*
* DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
* track objects created by the table or method, to be deleted
* when the method exits or the table is unloaded.
*
******************************************************************************/
acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
{
u32 i;
u32 j;
u32 k;
acpi_status status;
ACPI_FUNCTION_TRACE(ut_allocate_owner_id);
/* Guard against multiple allocations of ID to the same location */
if (*owner_id) {
ACPI_ERROR((AE_INFO, "Owner ID [0x%2.2X] already exists",
*owner_id));
return_ACPI_STATUS(AE_ALREADY_EXISTS);
}
/* Mutex for the global ID mask */
status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/*
* Find a free owner ID, cycle through all possible IDs on repeated
* allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have
* to be scanned twice.
*/
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 */
}
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 */
break;
}
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 OwnerId: %2.2X\n",
(unsigned int)*owner_id));
goto exit;
}
}
acpi_gbl_next_owner_id_offset = 0;
}
/*
* 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.
*/
status = AE_OWNER_ID_LIMIT;
ACPI_ERROR((AE_INFO,
"Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT"));
exit:
(void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
return_ACPI_STATUS(status);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_release_owner_id
*
* PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_ID
*
* RETURN: None. No error is returned because we are either exiting a
* 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 - 255
*
******************************************************************************/
void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
{
acpi_owner_id owner_id = *owner_id_ptr;
acpi_status status;
u32 index;
u32 bit;
ACPI_FUNCTION_TRACE_U32(ut_release_owner_id, owner_id);
/* Always clear the input owner_id (zero is an invalid ID) */
*owner_id_ptr = 0;
/* Zero is not a valid owner_ID */
if (owner_id == 0) {
ACPI_ERROR((AE_INFO, "Invalid OwnerId: 0x%2.2X", owner_id));
return_VOID;
}
/* Mutex for the global ID mask */
status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
if (ACPI_FAILURE(status)) {
return_VOID;
}
/* Normalize the ID to zero */
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[index] & bit) {
acpi_gbl_owner_id_mask[index] ^= bit;
} else {
ACPI_ERROR((AE_INFO,
"Release of non-allocated OwnerId: 0x%2.2X",
owner_id + 1));
}
(void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
return_VOID;
}
...@@ -127,7 +127,9 @@ const char *acpi_gbl_rw_decode[] = { ...@@ -127,7 +127,9 @@ const char *acpi_gbl_rw_decode[] = {
const char *acpi_gbl_shr_decode[] = { const char *acpi_gbl_shr_decode[] = {
"Exclusive", "Exclusive",
"Shared" "Shared",
"ExclusiveAndWake", /* ACPI 5.0 */
"SharedAndWake" /* ACPI 5.0 */
}; };
const char *acpi_gbl_siz_decode[] = { const char *acpi_gbl_siz_decode[] = {
...@@ -383,26 +385,16 @@ static const u8 acpi_gbl_resource_types[] = { ...@@ -383,26 +385,16 @@ static const u8 acpi_gbl_resource_types[] = {
ACPI_VARIABLE_LENGTH /* 0E *serial_bus */ ACPI_VARIABLE_LENGTH /* 0E *serial_bus */
}; };
/*
* For the iASL compiler/disassembler, we don't want any error messages
* because the disassembler uses the resource validation code to determine
* if Buffer objects are actually Resource Templates.
*/
#ifdef ACPI_ASL_COMPILER
#define ACPI_RESOURCE_ERROR(plist)
#else
#define ACPI_RESOURCE_ERROR(plist) ACPI_ERROR(plist)
#endif
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ut_walk_aml_resources * FUNCTION: acpi_ut_walk_aml_resources
* *
* PARAMETERS: aml - Pointer to the raw AML resource template * PARAMETERS: walk_state - Current walk info
* aml_length - Length of the entire template * PARAMETERS: aml - Pointer to the raw AML resource template
* user_function - Called once for each descriptor found. If * aml_length - Length of the entire template
* NULL, a pointer to the end_tag is returned * user_function - Called once for each descriptor found. If
* context - Passed to user_function * NULL, a pointer to the end_tag is returned
* context - Passed to user_function
* *
* RETURN: Status * RETURN: Status
* *
...@@ -412,7 +404,8 @@ static const u8 acpi_gbl_resource_types[] = { ...@@ -412,7 +404,8 @@ static const u8 acpi_gbl_resource_types[] = {
******************************************************************************/ ******************************************************************************/
acpi_status acpi_status
acpi_ut_walk_aml_resources(u8 * aml, acpi_ut_walk_aml_resources(struct acpi_walk_state *walk_state,
u8 *aml,
acpi_size aml_length, acpi_size aml_length,
acpi_walk_aml_callback user_function, void **context) acpi_walk_aml_callback user_function, void **context)
{ {
...@@ -441,7 +434,8 @@ acpi_ut_walk_aml_resources(u8 * aml, ...@@ -441,7 +434,8 @@ acpi_ut_walk_aml_resources(u8 * aml,
/* Validate the Resource Type and Resource Length */ /* Validate the Resource Type and Resource Length */
status = acpi_ut_validate_resource(aml, &resource_index); status =
acpi_ut_validate_resource(walk_state, aml, &resource_index);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
/* /*
* Exit on failure. Cannot continue because the descriptor length * Exit on failure. Cannot continue because the descriptor length
...@@ -498,7 +492,8 @@ acpi_ut_walk_aml_resources(u8 * aml, ...@@ -498,7 +492,8 @@ acpi_ut_walk_aml_resources(u8 * aml,
/* Insert an end_tag anyway. acpi_rs_get_list_length always leaves room */ /* Insert an end_tag anyway. acpi_rs_get_list_length always leaves room */
(void)acpi_ut_validate_resource(end_tag, &resource_index); (void)acpi_ut_validate_resource(walk_state, end_tag,
&resource_index);
status = status =
user_function(end_tag, 2, offset, resource_index, context); user_function(end_tag, 2, offset, resource_index, context);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
...@@ -513,9 +508,10 @@ acpi_ut_walk_aml_resources(u8 * aml, ...@@ -513,9 +508,10 @@ acpi_ut_walk_aml_resources(u8 * aml,
* *
* FUNCTION: acpi_ut_validate_resource * FUNCTION: acpi_ut_validate_resource
* *
* PARAMETERS: aml - Pointer to the raw AML resource descriptor * PARAMETERS: walk_state - Current walk info
* return_index - Where the resource index is returned. NULL * aml - Pointer to the raw AML resource descriptor
* if the index is not required. * 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 * RETURN: Status, and optionally the Index into the global resource tables
* *
...@@ -525,7 +521,9 @@ acpi_ut_walk_aml_resources(u8 * aml, ...@@ -525,7 +521,9 @@ acpi_ut_walk_aml_resources(u8 * aml,
* *
******************************************************************************/ ******************************************************************************/
acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index) acpi_status
acpi_ut_validate_resource(struct acpi_walk_state *walk_state,
void *aml, u8 *return_index)
{ {
union aml_resource *aml_resource; union aml_resource *aml_resource;
u8 resource_type; u8 resource_type;
...@@ -627,10 +625,12 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index) ...@@ -627,10 +625,12 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
if ((aml_resource->common_serial_bus.type == 0) || if ((aml_resource->common_serial_bus.type == 0) ||
(aml_resource->common_serial_bus.type > (aml_resource->common_serial_bus.type >
AML_RESOURCE_MAX_SERIALBUSTYPE)) { AML_RESOURCE_MAX_SERIALBUSTYPE)) {
ACPI_RESOURCE_ERROR((AE_INFO, if (walk_state) {
"Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X", ACPI_ERROR((AE_INFO,
aml_resource->common_serial_bus. "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",
type)); aml_resource->common_serial_bus.
type));
}
return (AE_AML_INVALID_RESOURCE_TYPE); return (AE_AML_INVALID_RESOURCE_TYPE);
} }
} }
...@@ -645,18 +645,22 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index) ...@@ -645,18 +645,22 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
invalid_resource: invalid_resource:
ACPI_RESOURCE_ERROR((AE_INFO, if (walk_state) {
"Invalid/unsupported resource descriptor: Type 0x%2.2X", ACPI_ERROR((AE_INFO,
resource_type)); "Invalid/unsupported resource descriptor: Type 0x%2.2X",
resource_type));
}
return (AE_AML_INVALID_RESOURCE_TYPE); return (AE_AML_INVALID_RESOURCE_TYPE);
bad_resource_length: bad_resource_length:
ACPI_RESOURCE_ERROR((AE_INFO, if (walk_state) {
"Invalid resource descriptor length: Type " ACPI_ERROR((AE_INFO,
"0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X", "Invalid resource descriptor length: Type "
resource_type, resource_length, "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X",
minimum_resource_length)); resource_type, resource_length,
minimum_resource_length));
}
return (AE_AML_BAD_RESOURCE_LENGTH); return (AE_AML_BAD_RESOURCE_LENGTH);
} }
...@@ -800,8 +804,7 @@ u32 acpi_ut_get_descriptor_length(void *aml) ...@@ -800,8 +804,7 @@ u32 acpi_ut_get_descriptor_length(void *aml)
******************************************************************************/ ******************************************************************************/
acpi_status acpi_status
acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc, acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, u8 **end_tag)
u8 ** end_tag)
{ {
acpi_status status; acpi_status status;
...@@ -816,7 +819,7 @@ acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc, ...@@ -816,7 +819,7 @@ acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc,
/* Validate the template and get a pointer to the end_tag */ /* Validate the template and get a pointer to the end_tag */
status = acpi_ut_walk_aml_resources(obj_desc->buffer.pointer, status = acpi_ut_walk_aml_resources(NULL, obj_desc->buffer.pointer,
obj_desc->buffer.length, NULL, obj_desc->buffer.length, NULL,
(void **)end_tag); (void **)end_tag);
......
...@@ -97,14 +97,13 @@ void ...@@ -97,14 +97,13 @@ void
acpi_ut_push_generic_state(union acpi_generic_state **list_head, acpi_ut_push_generic_state(union acpi_generic_state **list_head,
union acpi_generic_state *state) union acpi_generic_state *state)
{ {
ACPI_FUNCTION_TRACE(ut_push_generic_state); ACPI_FUNCTION_ENTRY();
/* Push the state object onto the front of the list (stack) */ /* Push the state object onto the front of the list (stack) */
state->common.next = *list_head; state->common.next = *list_head;
*list_head = state; *list_head = state;
return;
return_VOID;
} }
/******************************************************************************* /*******************************************************************************
...@@ -124,7 +123,7 @@ union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state ...@@ -124,7 +123,7 @@ union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state
{ {
union acpi_generic_state *state; union acpi_generic_state *state;
ACPI_FUNCTION_TRACE(ut_pop_generic_state); ACPI_FUNCTION_ENTRY();
/* Remove the state object at the head of the list (stack) */ /* Remove the state object at the head of the list (stack) */
...@@ -136,7 +135,7 @@ union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state ...@@ -136,7 +135,7 @@ union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state
*list_head = state->common.next; *list_head = state->common.next;
} }
return_PTR(state); return (state);
} }
/******************************************************************************* /*******************************************************************************
...@@ -186,13 +185,13 @@ struct acpi_thread_state *acpi_ut_create_thread_state(void) ...@@ -186,13 +185,13 @@ struct acpi_thread_state *acpi_ut_create_thread_state(void)
{ {
union acpi_generic_state *state; union acpi_generic_state *state;
ACPI_FUNCTION_TRACE(ut_create_thread_state); ACPI_FUNCTION_ENTRY();
/* Create the generic state object */ /* Create the generic state object */
state = acpi_ut_create_generic_state(); state = acpi_ut_create_generic_state();
if (!state) { if (!state) {
return_PTR(NULL); return (NULL);
} }
/* Init fields specific to the update struct */ /* Init fields specific to the update struct */
...@@ -207,7 +206,7 @@ struct acpi_thread_state *acpi_ut_create_thread_state(void) ...@@ -207,7 +206,7 @@ struct acpi_thread_state *acpi_ut_create_thread_state(void)
state->thread.thread_id = (acpi_thread_id) 1; state->thread.thread_id = (acpi_thread_id) 1;
} }
return_PTR((struct acpi_thread_state *)state); return ((struct acpi_thread_state *)state);
} }
/******************************************************************************* /*******************************************************************************
...@@ -230,13 +229,13 @@ union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object ...@@ -230,13 +229,13 @@ union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
{ {
union acpi_generic_state *state; union acpi_generic_state *state;
ACPI_FUNCTION_TRACE_PTR(ut_create_update_state, object); ACPI_FUNCTION_ENTRY();
/* Create the generic state object */ /* Create the generic state object */
state = acpi_ut_create_generic_state(); state = acpi_ut_create_generic_state();
if (!state) { if (!state) {
return_PTR(NULL); return (NULL);
} }
/* Init fields specific to the update struct */ /* Init fields specific to the update struct */
...@@ -244,8 +243,7 @@ union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object ...@@ -244,8 +243,7 @@ union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
state->common.descriptor_type = ACPI_DESC_TYPE_STATE_UPDATE; state->common.descriptor_type = ACPI_DESC_TYPE_STATE_UPDATE;
state->update.object = object; state->update.object = object;
state->update.value = action; state->update.value = action;
return (state);
return_PTR(state);
} }
/******************************************************************************* /*******************************************************************************
...@@ -267,13 +265,13 @@ union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object, ...@@ -267,13 +265,13 @@ union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
{ {
union acpi_generic_state *state; union acpi_generic_state *state;
ACPI_FUNCTION_TRACE_PTR(ut_create_pkg_state, internal_object); ACPI_FUNCTION_ENTRY();
/* Create the generic state object */ /* Create the generic state object */
state = acpi_ut_create_generic_state(); state = acpi_ut_create_generic_state();
if (!state) { if (!state) {
return_PTR(NULL); return (NULL);
} }
/* Init fields specific to the update struct */ /* Init fields specific to the update struct */
...@@ -283,8 +281,7 @@ union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object, ...@@ -283,8 +281,7 @@ union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
state->pkg.dest_object = external_object; state->pkg.dest_object = external_object;
state->pkg.index = index; state->pkg.index = index;
state->pkg.num_packages = 1; state->pkg.num_packages = 1;
return (state);
return_PTR(state);
} }
/******************************************************************************* /*******************************************************************************
...@@ -304,21 +301,20 @@ union acpi_generic_state *acpi_ut_create_control_state(void) ...@@ -304,21 +301,20 @@ union acpi_generic_state *acpi_ut_create_control_state(void)
{ {
union acpi_generic_state *state; union acpi_generic_state *state;
ACPI_FUNCTION_TRACE(ut_create_control_state); ACPI_FUNCTION_ENTRY();
/* Create the generic state object */ /* Create the generic state object */
state = acpi_ut_create_generic_state(); state = acpi_ut_create_generic_state();
if (!state) { if (!state) {
return_PTR(NULL); return (NULL);
} }
/* Init fields specific to the control struct */ /* Init fields specific to the control struct */
state->common.descriptor_type = ACPI_DESC_TYPE_STATE_CONTROL; state->common.descriptor_type = ACPI_DESC_TYPE_STATE_CONTROL;
state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING; state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING;
return (state);
return_PTR(state);
} }
/******************************************************************************* /*******************************************************************************
...@@ -336,12 +332,12 @@ union acpi_generic_state *acpi_ut_create_control_state(void) ...@@ -336,12 +332,12 @@ union acpi_generic_state *acpi_ut_create_control_state(void)
void acpi_ut_delete_generic_state(union acpi_generic_state *state) void acpi_ut_delete_generic_state(union acpi_generic_state *state)
{ {
ACPI_FUNCTION_TRACE(ut_delete_generic_state); ACPI_FUNCTION_ENTRY();
/* Ignore null state */ /* Ignore null state */
if (state) { if (state) {
(void)acpi_os_release_object(acpi_gbl_state_cache, state); (void)acpi_os_release_object(acpi_gbl_state_cache, state);
} }
return_VOID; return;
} }
/*******************************************************************************
*
* Module Name: utstring - Common functions for strings and characters
*
******************************************************************************/
/*
* Copyright (C) 2000 - 2012, Intel Corp.
* 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 <acpi/acpi.h>
#include "accommon.h"
#include "acnamesp.h"
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME("utstring")
/*
* Non-ANSI C library functions - strlwr, strupr, stricmp, and a 64-bit
* version of strtoul.
*/
#ifdef ACPI_ASL_COMPILER
/*******************************************************************************
*
* FUNCTION: acpi_ut_strlwr (strlwr)
*
* PARAMETERS: src_string - The source string to convert
*
* RETURN: None
*
* DESCRIPTION: Convert string to lowercase
*
* NOTE: This is not a POSIX function, so it appears here, not in utclib.c
*
******************************************************************************/
void acpi_ut_strlwr(char *src_string)
{
char *string;
ACPI_FUNCTION_ENTRY();
if (!src_string) {
return;
}
/* Walk entire string, lowercasing the letters */
for (string = src_string; *string; string++) {
*string = (char)ACPI_TOLOWER(*string);
}
return;
}
/******************************************************************************
*
* FUNCTION: acpi_ut_stricmp (stricmp)
*
* PARAMETERS: string1 - first string to compare
* string2 - second string to compare
*
* RETURN: int that signifies string relationship. Zero means strings
* are equal.
*
* DESCRIPTION: Implementation of the non-ANSI stricmp function (compare
* strings with no case sensitivity)
*
******************************************************************************/
int acpi_ut_stricmp(char *string1, char *string2)
{
int c1;
int c2;
do {
c1 = tolower((int)*string1);
c2 = tolower((int)*string2);
string1++;
string2++;
}
while ((c1 == c2) && (c1));
return (c1 - c2);
}
#endif
/*******************************************************************************
*
* FUNCTION: acpi_ut_strupr (strupr)
*
* PARAMETERS: src_string - The source string to convert
*
* RETURN: None
*
* DESCRIPTION: Convert string to uppercase
*
* NOTE: This is not a POSIX function, so it appears here, not in utclib.c
*
******************************************************************************/
void acpi_ut_strupr(char *src_string)
{
char *string;
ACPI_FUNCTION_ENTRY();
if (!src_string) {
return;
}
/* Walk entire string, uppercasing the letters */
for (string = src_string; *string; string++) {
*string = (char)ACPI_TOUPPER(*string);
}
return;
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_strtoul64
*
* PARAMETERS: string - Null terminated string
* base - Radix of the string: 16 or ACPI_ANY_BASE;
* ACPI_ANY_BASE means 'in behalf of to_integer'
* ret_integer - Where the converted integer is returned
*
* RETURN: Status and Converted value
*
* DESCRIPTION: Convert a string into an unsigned value. Performs either a
* 32-bit or 64-bit conversion, depending on the current mode
* of the interpreter.
* NOTE: Does not support Octal strings, not needed.
*
******************************************************************************/
acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)
{
u32 this_digit = 0;
u64 return_value = 0;
u64 quotient;
u64 dividend;
u32 to_integer_op = (base == ACPI_ANY_BASE);
u32 mode32 = (acpi_gbl_integer_byte_width == 4);
u8 valid_digits = 0;
u8 sign_of0x = 0;
u8 term = 0;
ACPI_FUNCTION_TRACE_STR(ut_stroul64, string);
switch (base) {
case ACPI_ANY_BASE:
case 16:
break;
default:
/* Invalid Base */
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
if (!string) {
goto error_exit;
}
/* Skip over any white space in the buffer */
while ((*string) && (ACPI_IS_SPACE(*string) || *string == '\t')) {
string++;
}
if (to_integer_op) {
/*
* Base equal to ACPI_ANY_BASE means 'ToInteger operation case'.
* We need to determine if it is decimal or hexadecimal.
*/
if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
sign_of0x = 1;
base = 16;
/* Skip over the leading '0x' */
string += 2;
} else {
base = 10;
}
}
/* Any string left? Check that '0x' is not followed by white space. */
if (!(*string) || ACPI_IS_SPACE(*string) || *string == '\t') {
if (to_integer_op) {
goto error_exit;
} else {
goto all_done;
}
}
/*
* Perform a 32-bit or 64-bit conversion, depending upon the current
* execution mode of the interpreter
*/
dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
/* Main loop: convert the string to a 32- or 64-bit integer */
while (*string) {
if (ACPI_IS_DIGIT(*string)) {
/* Convert ASCII 0-9 to Decimal value */
this_digit = ((u8)*string) - '0';
} else if (base == 10) {
/* Digit is out of range; possible in to_integer case only */
term = 1;
} else {
this_digit = (u8)ACPI_TOUPPER(*string);
if (ACPI_IS_XDIGIT((char)this_digit)) {
/* Convert ASCII Hex char to value */
this_digit = this_digit - 'A' + 10;
} else {
term = 1;
}
}
if (term) {
if (to_integer_op) {
goto error_exit;
} else {
break;
}
} else if ((valid_digits == 0) && (this_digit == 0)
&& !sign_of0x) {
/* Skip zeros */
string++;
continue;
}
valid_digits++;
if (sign_of0x
&& ((valid_digits > 16)
|| ((valid_digits > 8) && mode32))) {
/*
* This is to_integer operation case.
* No any restrictions for string-to-integer conversion,
* see ACPI spec.
*/
goto error_exit;
}
/* Divide the digit into the correct position */
(void)acpi_ut_short_divide((dividend - (u64)this_digit),
base, &quotient, NULL);
if (return_value > quotient) {
if (to_integer_op) {
goto error_exit;
} else {
break;
}
}
return_value *= base;
return_value += this_digit;
string++;
}
/* All done, normal exit */
all_done:
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
ACPI_FORMAT_UINT64(return_value)));
*ret_integer = return_value;
return_ACPI_STATUS(AE_OK);
error_exit:
/* Base was set/validated above */
if (base == 10) {
return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT);
} else {
return_ACPI_STATUS(AE_BAD_HEX_CONSTANT);
}
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_print_string
*
* PARAMETERS: string - Null terminated ASCII string
* max_length - Maximum output length
*
* RETURN: None
*
* DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
* sequences.
*
******************************************************************************/
void acpi_ut_print_string(char *string, u8 max_length)
{
u32 i;
if (!string) {
acpi_os_printf("<\"NULL STRING PTR\">");
return;
}
acpi_os_printf("\"");
for (i = 0; string[i] && (i < max_length); i++) {
/* Escape sequences */
switch (string[i]) {
case 0x07:
acpi_os_printf("\\a"); /* BELL */
break;
case 0x08:
acpi_os_printf("\\b"); /* BACKSPACE */
break;
case 0x0C:
acpi_os_printf("\\f"); /* FORMFEED */
break;
case 0x0A:
acpi_os_printf("\\n"); /* LINEFEED */
break;
case 0x0D:
acpi_os_printf("\\r"); /* CARRIAGE RETURN */
break;
case 0x09:
acpi_os_printf("\\t"); /* HORIZONTAL TAB */
break;
case 0x0B:
acpi_os_printf("\\v"); /* VERTICAL TAB */
break;
case '\'': /* Single Quote */
case '\"': /* Double Quote */
case '\\': /* Backslash */
acpi_os_printf("\\%c", (int)string[i]);
break;
default:
/* Check for printable character or hex escape */
if (ACPI_IS_PRINT(string[i])) {
/* This is a normal character */
acpi_os_printf("%c", (int)string[i]);
} else {
/* All others will be Hex escapes */
acpi_os_printf("\\x%2.2X", (s32) string[i]);
}
break;
}
}
acpi_os_printf("\"");
if (i == max_length && string[i]) {
acpi_os_printf("...");
}
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_valid_acpi_char
*
* PARAMETERS: char - The character to be examined
* position - Byte position (0-3)
*
* RETURN: TRUE if the character is valid, FALSE otherwise
*
* DESCRIPTION: Check for a valid ACPI character. Must be one of:
* 1) Upper case alpha
* 2) numeric
* 3) underscore
*
* We allow a '!' as the last character because of the ASF! table
*
******************************************************************************/
u8 acpi_ut_valid_acpi_char(char character, u32 position)
{
if (!((character >= 'A' && character <= 'Z') ||
(character >= '0' && character <= '9') || (character == '_'))) {
/* Allow a '!' in the last position */
if (character == '!' && position == 3) {
return (TRUE);
}
return (FALSE);
}
return (TRUE);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_valid_acpi_name
*
* PARAMETERS: name - The name to be examined
*
* RETURN: TRUE if the name is valid, FALSE otherwise
*
* DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
* 1) Upper case alpha
* 2) numeric
* 3) underscore
*
******************************************************************************/
u8 acpi_ut_valid_acpi_name(u32 name)
{
u32 i;
ACPI_FUNCTION_ENTRY();
for (i = 0; i < ACPI_NAME_SIZE; i++) {
if (!acpi_ut_valid_acpi_char
((ACPI_CAST_PTR(char, &name))[i], i)) {
return (FALSE);
}
}
return (TRUE);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_repair_name
*
* PARAMETERS: name - The ACPI name to be repaired
*
* RETURN: Repaired version of the name
*
* DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and
* return the new name. NOTE: the Name parameter must reside in
* read/write memory, cannot be a const.
*
* An ACPI Name must consist of valid ACPI characters. We will repair the name
* if necessary because we don't want to abort because of this, but we want
* all namespace names to be printable. A warning message is appropriate.
*
* This issue came up because there are in fact machines that exhibit
* this problem, and we want to be able to enable ACPI support for them,
* even though there are a few bad names.
*
******************************************************************************/
void acpi_ut_repair_name(char *name)
{
u32 i;
u8 found_bad_char = FALSE;
u32 original_name;
ACPI_FUNCTION_NAME(ut_repair_name);
ACPI_MOVE_NAME(&original_name, name);
/* Check each character in the name */
for (i = 0; i < ACPI_NAME_SIZE; i++) {
if (acpi_ut_valid_acpi_char(name[i], i)) {
continue;
}
/*
* Replace a bad character with something printable, yet technically
* still invalid. This prevents any collisions with existing "good"
* names in the namespace.
*/
name[i] = '*';
found_bad_char = TRUE;
}
if (found_bad_char) {
/* Report warning only if in strict mode or debug mode */
if (!acpi_gbl_enable_interpreter_slack) {
ACPI_WARNING((AE_INFO,
"Invalid character(s) in name (0x%.8X), repaired: [%4.4s]",
original_name, name));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Invalid character(s) in name (0x%.8X), repaired: [%4.4s]",
original_name, name));
}
}
}
#if defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP
/*******************************************************************************
*
* FUNCTION: ut_convert_backslashes
*
* PARAMETERS: pathname - File pathname string to be converted
*
* RETURN: Modifies the input Pathname
*
* DESCRIPTION: Convert all backslashes (0x5C) to forward slashes (0x2F) within
* the entire input file pathname string.
*
******************************************************************************/
void ut_convert_backslashes(char *pathname)
{
if (!pathname) {
return;
}
while (*pathname) {
if (*pathname == '\\') {
*pathname = '/';
}
pathname++;
}
}
#endif
...@@ -436,10 +436,10 @@ acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation, ...@@ -436,10 +436,10 @@ acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation,
struct acpi_memory_list *mem_list; struct acpi_memory_list *mem_list;
acpi_status status; acpi_status status;
ACPI_FUNCTION_TRACE(ut_remove_allocation); ACPI_FUNCTION_NAME(ut_remove_allocation);
if (acpi_gbl_disable_mem_tracking) { if (acpi_gbl_disable_mem_tracking) {
return_ACPI_STATUS(AE_OK); return (AE_OK);
} }
mem_list = acpi_gbl_global_list; mem_list = acpi_gbl_global_list;
...@@ -450,12 +450,12 @@ acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation, ...@@ -450,12 +450,12 @@ acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation,
ACPI_ERROR((module, line, ACPI_ERROR((module, line,
"Empty allocation list, nothing to free!")); "Empty allocation list, nothing to free!"));
return_ACPI_STATUS(AE_OK); return (AE_OK);
} }
status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY); status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status); return (status);
} }
/* Unlink */ /* Unlink */
...@@ -470,15 +470,15 @@ acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation, ...@@ -470,15 +470,15 @@ acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation,
(allocation->next)->previous = allocation->previous; (allocation->next)->previous = allocation->previous;
} }
ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Freeing %p, size 0%X\n",
&allocation->user_space, allocation->size));
/* Mark the segment as deleted */ /* Mark the segment as deleted */
ACPI_MEMSET(&allocation->user_space, 0xEA, allocation->size); ACPI_MEMSET(&allocation->user_space, 0xEA, allocation->size);
ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n",
allocation->size));
status = acpi_ut_release_mutex(ACPI_MTX_MEMORY); status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
return_ACPI_STATUS(status); return (status);
} }
/******************************************************************************* /*******************************************************************************
......
...@@ -44,11 +44,7 @@ ...@@ -44,11 +44,7 @@
#include <linux/export.h> #include <linux/export.h>
#include <acpi/acpi.h> #include <acpi/acpi.h>
#include "accommon.h" #include "accommon.h"
#include "acevents.h"
#include "acnamesp.h"
#include "acdebug.h" #include "acdebug.h"
#include "actables.h"
#include "acinterp.h"
#define _COMPONENT ACPI_UTILITIES #define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME("utxface") ACPI_MODULE_NAME("utxface")
......
...@@ -297,9 +297,9 @@ ACPI_EXPORT_SYMBOL(acpi_bios_warning) ...@@ -297,9 +297,9 @@ ACPI_EXPORT_SYMBOL(acpi_bios_warning)
* *
* PARAMETERS: module_name - Caller's module name (for error output) * PARAMETERS: module_name - Caller's module name (for error output)
* line_number - Caller's line number (for error output) * line_number - Caller's line number (for error output)
* Pathname - Full pathname to the node * pathname - Full pathname to the node
* node_flags - From Namespace node for the method/object * node_flags - From Namespace node for the method/object
* Format - Printf format string + additional args * format - Printf format string + additional args
* *
* RETURN: None * RETURN: None
* *
......
/*
* Support for Core System Resources Table (CSRT)
*
* Copyright (C) 2013, Intel Corporation
* Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
* Andy Shevchenko <andriy.shevchenko@linux.intel.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#define pr_fmt(fmt) "ACPI: CSRT: " fmt
#include <linux/acpi.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/sizes.h>
ACPI_MODULE_NAME("CSRT");
static int __init acpi_csrt_parse_shared_info(struct platform_device *pdev,
const struct acpi_csrt_group *grp)
{
const struct acpi_csrt_shared_info *si;
struct resource res[3];
size_t nres;
int ret;
memset(res, 0, sizeof(res));
nres = 0;
si = (const struct acpi_csrt_shared_info *)&grp[1];
/*
* The peripherals that are listed on CSRT typically support only
* 32-bit addresses so we only use the low part of MMIO base for
* now.
*/
if (!si->mmio_base_high && si->mmio_base_low) {
/*
* There is no size of the memory resource in shared_info
* so we assume that it is 4k here.
*/
res[nres].start = si->mmio_base_low;
res[nres].end = res[0].start + SZ_4K - 1;
res[nres++].flags = IORESOURCE_MEM;
}
if (si->gsi_interrupt) {
int irq = acpi_register_gsi(NULL, si->gsi_interrupt,
si->interrupt_mode,
si->interrupt_polarity);
res[nres].start = irq;
res[nres].end = irq;
res[nres++].flags = IORESOURCE_IRQ;
}
if (si->base_request_line || si->num_handshake_signals) {
/*
* We pass the driver a DMA resource describing the range
* of request lines the device supports.
*/
res[nres].start = si->base_request_line;
res[nres].end = res[nres].start + si->num_handshake_signals - 1;
res[nres++].flags = IORESOURCE_DMA;
}
ret = platform_device_add_resources(pdev, res, nres);
if (ret) {
if (si->gsi_interrupt)
acpi_unregister_gsi(si->gsi_interrupt);
return ret;
}
return 0;
}
static int __init
acpi_csrt_parse_resource_group(const struct acpi_csrt_group *grp)
{
struct platform_device *pdev;
char vendor[5], name[16];
int ret, i;
vendor[0] = grp->vendor_id;
vendor[1] = grp->vendor_id >> 8;
vendor[2] = grp->vendor_id >> 16;
vendor[3] = grp->vendor_id >> 24;
vendor[4] = '\0';
if (grp->shared_info_length != sizeof(struct acpi_csrt_shared_info))
return -ENODEV;
snprintf(name, sizeof(name), "%s%04X", vendor, grp->device_id);
pdev = platform_device_alloc(name, PLATFORM_DEVID_AUTO);
if (!pdev)
return -ENOMEM;
/* Add resources based on the shared info */
ret = acpi_csrt_parse_shared_info(pdev, grp);
if (ret)
goto fail;
ret = platform_device_add(pdev);
if (ret)
goto fail;
for (i = 0; i < pdev->num_resources; i++)
dev_dbg(&pdev->dev, "%pR\n", &pdev->resource[i]);
return 0;
fail:
platform_device_put(pdev);
return ret;
}
/*
* CSRT or Core System Resources Table is a proprietary ACPI table
* introduced by Microsoft. This table can contain devices that are not in
* the system DSDT table. In particular DMA controllers might be described
* here.
*
* We present these devices as normal platform devices that don't have ACPI
* IDs or handle. The platform device name will be something like
* <VENDOR><DEVID>.<n>.auto for example: INTL9C06.0.auto.
*/
void __init acpi_csrt_init(void)
{
struct acpi_csrt_group *grp, *end;
struct acpi_table_csrt *csrt;
acpi_status status;
int ret;
status = acpi_get_table(ACPI_SIG_CSRT, 0,
(struct acpi_table_header **)&csrt);
if (ACPI_FAILURE(status)) {
if (status != AE_NOT_FOUND)
pr_warn("failed to get the CSRT table\n");
return;
}
pr_debug("parsing CSRT table for devices\n");
grp = (struct acpi_csrt_group *)(csrt + 1);
end = (struct acpi_csrt_group *)((void *)csrt + csrt->header.length);
while (grp < end) {
ret = acpi_csrt_parse_resource_group(grp);
if (ret) {
pr_warn("error in parsing resource group: %d\n", ret);
return;
}
grp = (struct acpi_csrt_group *)((void *)grp + grp->length);
}
}
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
int init_acpi_device_notify(void); int init_acpi_device_notify(void);
int acpi_scan_init(void); int acpi_scan_init(void);
int acpi_sysfs_init(void); int acpi_sysfs_init(void);
void acpi_csrt_init(void);
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
extern struct dentry *acpi_debugfs_dir; extern struct dentry *acpi_debugfs_dir;
...@@ -117,6 +118,10 @@ static inline void suspend_nvs_restore(void) {} ...@@ -117,6 +118,10 @@ static inline void suspend_nvs_restore(void) {}
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
struct platform_device; struct platform_device;
struct platform_device *acpi_create_platform_device(struct acpi_device *adev); /* Flags for acpi_create_platform_device */
#define ACPI_PLATFORM_CLK BIT(0)
struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
unsigned long flags);
#endif /* _ACPI_INTERNAL_H_ */ #endif /* _ACPI_INTERNAL_H_ */
...@@ -273,7 +273,7 @@ static int __init acpi_parse_srat(struct acpi_table_header *table) ...@@ -273,7 +273,7 @@ static int __init acpi_parse_srat(struct acpi_table_header *table)
static int __init static int __init
acpi_table_parse_srat(enum acpi_srat_type id, acpi_table_parse_srat(enum acpi_srat_type id,
acpi_table_entry_handler handler, unsigned int max_entries) acpi_tbl_entry_handler handler, unsigned int max_entries)
{ {
return acpi_table_parse_entries(ACPI_SIG_SRAT, return acpi_table_parse_entries(ACPI_SIG_SRAT,
sizeof(struct acpi_table_srat), id, sizeof(struct acpi_table_srat), id,
......
...@@ -64,10 +64,11 @@ ...@@ -64,10 +64,11 @@
#define ACPI_PROCESSOR_CLASS "processor" #define ACPI_PROCESSOR_CLASS "processor"
#define _COMPONENT ACPI_PROCESSOR_COMPONENT #define _COMPONENT ACPI_PROCESSOR_COMPONENT
ACPI_MODULE_NAME("processor_idle"); ACPI_MODULE_NAME("processor_idle");
#define PM_TIMER_TICK_NS (1000000000ULL/PM_TIMER_FREQUENCY) #define PM_TIMER_TICK_NS (1000000000ULL/ACPI_PM_TIMER_FREQUENCY)
#define C2_OVERHEAD 1 /* 1us */ #define C2_OVERHEAD 1 /* 1us */
#define C3_OVERHEAD 1 /* 1us */ #define C3_OVERHEAD 1 /* 1us */
#define PM_TIMER_TICKS_TO_US(p) (((p) * 1000)/(PM_TIMER_FREQUENCY/1000)) #define PM_TIMER_TICKS_TO_US(p) \
(((p) * 1000)/(ACPI_PM_TIMER_FREQUENCY/1000))
static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER; static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER;
module_param(max_cstate, uint, 0000); module_param(max_cstate, uint, 0000);
......
...@@ -38,14 +38,14 @@ static const struct acpi_device_id acpi_platform_device_ids[] = { ...@@ -38,14 +38,14 @@ static const struct acpi_device_id acpi_platform_device_ids[] = {
{ "PNP0D40" }, { "PNP0D40" },
/* Haswell LPSS devices */ /* Haswell LPSS devices */
{ "INT33C0", 0 }, { "INT33C0", ACPI_PLATFORM_CLK },
{ "INT33C1", 0 }, { "INT33C1", ACPI_PLATFORM_CLK },
{ "INT33C2", 0 }, { "INT33C2", ACPI_PLATFORM_CLK },
{ "INT33C3", 0 }, { "INT33C3", ACPI_PLATFORM_CLK },
{ "INT33C4", 0 }, { "INT33C4", ACPI_PLATFORM_CLK },
{ "INT33C5", 0 }, { "INT33C5", ACPI_PLATFORM_CLK },
{ "INT33C6", 0 }, { "INT33C6", ACPI_PLATFORM_CLK },
{ "INT33C7", 0 }, { "INT33C7", ACPI_PLATFORM_CLK },
{ } { }
}; };
...@@ -1573,6 +1573,7 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, ...@@ -1573,6 +1573,7 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used, static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
void *not_used, void **ret_not_used) void *not_used, void **ret_not_used)
{ {
const struct acpi_device_id *id;
acpi_status status = AE_OK; acpi_status status = AE_OK;
struct acpi_device *device; struct acpi_device *device;
unsigned long long sta_not_used; unsigned long long sta_not_used;
...@@ -1588,9 +1589,10 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used, ...@@ -1588,9 +1589,10 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
if (acpi_bus_get_device(handle, &device)) if (acpi_bus_get_device(handle, &device))
return AE_CTRL_DEPTH; return AE_CTRL_DEPTH;
if (!acpi_match_device_ids(device, acpi_platform_device_ids)) { id = __acpi_match_device(device, acpi_platform_device_ids);
if (id) {
/* This is a known good platform device. */ /* This is a known good platform device. */
acpi_create_platform_device(device); acpi_create_platform_device(device, id->driver_data);
} else if (device_attach(&device->dev) < 0) { } else if (device_attach(&device->dev) < 0) {
status = AE_CTRL_DEPTH; status = AE_CTRL_DEPTH;
} }
...@@ -1726,6 +1728,7 @@ int __init acpi_scan_init(void) ...@@ -1726,6 +1728,7 @@ int __init acpi_scan_init(void)
} }
acpi_pci_root_init(); acpi_pci_root_init();
acpi_csrt_init();
/* /*
* Enumerate devices in the ACPI namespace. * Enumerate devices in the ACPI namespace.
......
...@@ -204,7 +204,7 @@ int __init ...@@ -204,7 +204,7 @@ int __init
acpi_table_parse_entries(char *id, acpi_table_parse_entries(char *id,
unsigned long table_size, unsigned long table_size,
int entry_id, int entry_id,
acpi_table_entry_handler handler, acpi_tbl_entry_handler handler,
unsigned int max_entries) unsigned int max_entries)
{ {
struct acpi_table_header *table_header = NULL; struct acpi_table_header *table_header = NULL;
...@@ -269,7 +269,7 @@ acpi_table_parse_entries(char *id, ...@@ -269,7 +269,7 @@ acpi_table_parse_entries(char *id,
int __init int __init
acpi_table_parse_madt(enum acpi_madt_type id, acpi_table_parse_madt(enum acpi_madt_type id,
acpi_table_entry_handler handler, unsigned int max_entries) acpi_tbl_entry_handler handler, unsigned int max_entries)
{ {
return acpi_table_parse_entries(ACPI_SIG_MADT, return acpi_table_parse_entries(ACPI_SIG_MADT,
sizeof(struct acpi_table_madt), id, sizeof(struct acpi_table_madt), id,
...@@ -285,7 +285,7 @@ acpi_table_parse_madt(enum acpi_madt_type id, ...@@ -285,7 +285,7 @@ acpi_table_parse_madt(enum acpi_madt_type id,
* Scan the ACPI System Descriptor Table (STD) for a table matching @id, * Scan the ACPI System Descriptor Table (STD) for a table matching @id,
* run @handler on it. Return 0 if table found, return on if not. * run @handler on it. Return 0 if table found, return on if not.
*/ */
int __init acpi_table_parse(char *id, acpi_table_handler handler) int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)
{ {
struct acpi_table_header *table = NULL; struct acpi_table_header *table = NULL;
acpi_size tbl_size; acpi_size tbl_size;
......
...@@ -22,6 +22,7 @@ obj-$(CONFIG_ARCH_U8500) += ux500/ ...@@ -22,6 +22,7 @@ obj-$(CONFIG_ARCH_U8500) += ux500/
obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
obj-$(CONFIG_ARCH_SUNXI) += clk-sunxi.o obj-$(CONFIG_ARCH_SUNXI) += clk-sunxi.o
obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o
obj-$(CONFIG_X86) += x86/
# Chip specific # Chip specific
obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
......
clk-x86-lpss-objs := clk-lpss.o clk-lpt.o
obj-$(CONFIG_X86_INTEL_LPSS) += clk-x86-lpss.o
/*
* Intel Low Power Subsystem clocks.
*
* Copyright (C) 2013, Intel Corporation
* Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
* Heikki Krogerus <heikki.krogerus@linux.intel.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/acpi.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/module.h>
static int clk_lpss_is_mmio_resource(struct acpi_resource *res, void *data)
{
struct resource r;
return !acpi_dev_resource_memory(res, &r);
}
static acpi_status clk_lpss_find_mmio(acpi_handle handle, u32 level,
void *data, void **retval)
{
struct resource_list_entry *rentry;
struct list_head resource_list;
struct acpi_device *adev;
const char *uid = data;
int ret;
if (acpi_bus_get_device(handle, &adev))
return AE_OK;
if (uid) {
if (!adev->pnp.unique_id)
return AE_OK;
if (strcmp(uid, adev->pnp.unique_id))
return AE_OK;
}
INIT_LIST_HEAD(&resource_list);
ret = acpi_dev_get_resources(adev, &resource_list,
clk_lpss_is_mmio_resource, NULL);
if (ret < 0)
return AE_NO_MEMORY;
list_for_each_entry(rentry, &resource_list, node)
if (resource_type(&rentry->res) == IORESOURCE_MEM) {
*(struct resource *)retval = rentry->res;
break;
}
acpi_dev_free_resource_list(&resource_list);
return AE_OK;
}
/**
* clk_register_lpss_gate - register LPSS clock gate
* @name: name of this clock gate
* @parent_name: parent clock name
* @hid: ACPI _HID of the device
* @uid: ACPI _UID of the device (optional)
* @offset: LPSS PRV_CLOCK_PARAMS offset
*
* Creates and registers LPSS clock gate.
*/
struct clk *clk_register_lpss_gate(const char *name, const char *parent_name,
const char *hid, const char *uid,
unsigned offset)
{
struct resource res = { };
void __iomem *mmio_base;
acpi_status status;
struct clk *clk;
/*
* First try to look the device and its mmio resource from the
* ACPI namespace.
*/
status = acpi_get_devices(hid, clk_lpss_find_mmio, (void *)uid,
(void **)&res);
if (ACPI_FAILURE(status) || !res.start)
return ERR_PTR(-ENODEV);
mmio_base = ioremap(res.start, resource_size(&res));
if (!mmio_base)
return ERR_PTR(-ENOMEM);
clk = clk_register_gate(NULL, name, parent_name, 0, mmio_base + offset,
0, 0, NULL);
if (IS_ERR(clk))
iounmap(mmio_base);
return clk;
}
/*
* Intel Low Power Subsystem clock.
*
* Copyright (C) 2013, Intel Corporation
* Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
* Heikki Krogerus <heikki.krogerus@linux.intel.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef __CLK_LPSS_H
#define __CLK_LPSS_H
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/clk.h>
#ifdef CONFIG_ACPI
extern struct clk *clk_register_lpss_gate(const char *name,
const char *parent_name,
const char *hid, const char *uid,
unsigned offset);
#else
static inline struct clk *clk_register_lpss_gate(const char *name,
const char *parent_name,
const char *hid,
const char *uid,
unsigned offset)
{
return ERR_PTR(-ENODEV);
}
#endif
#endif /* __CLK_LPSS_H */
/*
* Intel Lynxpoint LPSS clocks.
*
* Copyright (C) 2013, Intel Corporation
* Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
* Heikki Krogerus <heikki.krogerus@linux.intel.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/acpi.h>
#include <linux/clk.h>
#include <linux/clkdev.h>
#include <linux/clk-provider.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include "clk-lpss.h"
#define PRV_CLOCK_PARAMS 0x800
static int lpt_clk_probe(struct platform_device *pdev)
{
struct clk *clk;
/* LPSS free running clock */
clk = clk_register_fixed_rate(&pdev->dev, "lpss_clk", NULL, CLK_IS_ROOT,
100000000);
if (IS_ERR(clk))
return PTR_ERR(clk);
/* Shared DMA clock */
clk_register_clkdev(clk, "hclk", "INTL9C60.0.auto");
/* SPI clocks */
clk = clk_register_lpss_gate("spi0_clk", "lpss_clk", "INT33C0", NULL,
PRV_CLOCK_PARAMS);
if (!IS_ERR(clk))
clk_register_clkdev(clk, NULL, "INT33C0:00");
clk = clk_register_lpss_gate("spi1_clk", "lpss_clk", "INT33C1", NULL,
PRV_CLOCK_PARAMS);
if (!IS_ERR(clk))
clk_register_clkdev(clk, NULL, "INT33C1:00");
/* I2C clocks */
clk = clk_register_lpss_gate("i2c0_clk", "lpss_clk", "INT33C2", NULL,
PRV_CLOCK_PARAMS);
if (!IS_ERR(clk))
clk_register_clkdev(clk, NULL, "INT33C2:00");
clk = clk_register_lpss_gate("i2c1_clk", "lpss_clk", "INT33C3", NULL,
PRV_CLOCK_PARAMS);
if (!IS_ERR(clk))
clk_register_clkdev(clk, NULL, "INT33C3:00");
/* UART clocks */
clk = clk_register_lpss_gate("uart0_clk", "lpss_clk", "INT33C4", NULL,
PRV_CLOCK_PARAMS);
if (!IS_ERR(clk))
clk_register_clkdev(clk, NULL, "INT33C4:00");
clk = clk_register_lpss_gate("uart1_clk", "lpss_clk", "INT33C5", NULL,
PRV_CLOCK_PARAMS);
if (!IS_ERR(clk))
clk_register_clkdev(clk, NULL, "INT33C5:00");
return 0;
}
static struct platform_driver lpt_clk_driver = {
.driver = {
.name = "clk-lpt",
.owner = THIS_MODULE,
},
.probe = lpt_clk_probe,
};
static int __init lpt_clk_init(void)
{
return platform_driver_register(&lpt_clk_driver);
}
arch_initcall(lpt_clk_init);
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
/* Maximum sleep allowed via Sleep() operator */ /* Maximum sleep allowed via Sleep() operator */
#define ACPI_MAX_SLEEP 2000 /* Two seconds */ #define ACPI_MAX_SLEEP 2000 /* 2000 millisec == two seconds */
/* Address Range lists are per-space_id (Memory and I/O only) */ /* Address Range lists are per-space_id (Memory and I/O only) */
...@@ -150,11 +150,6 @@ ...@@ -150,11 +150,6 @@
* *
*****************************************************************************/ *****************************************************************************/
/* Number of distinct GPE register blocks and register width */
#define ACPI_MAX_GPE_BLOCKS 2
#define ACPI_GPE_REGISTER_WIDTH 8
/* Method info (in WALK_STATE), containing local variables and argumetns */ /* Method info (in WALK_STATE), containing local variables and argumetns */
#define ACPI_METHOD_NUM_LOCALS 8 #define ACPI_METHOD_NUM_LOCALS 8
...@@ -163,12 +158,6 @@ ...@@ -163,12 +158,6 @@
#define ACPI_METHOD_NUM_ARGS 7 #define ACPI_METHOD_NUM_ARGS 7
#define ACPI_METHOD_MAX_ARG 6 #define ACPI_METHOD_MAX_ARG 6
/* 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 * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG
*/ */
...@@ -186,17 +175,6 @@ ...@@ -186,17 +175,6 @@
*/ */
#define ACPI_RESULTS_OBJ_NUM_MAX 255 #define ACPI_RESULTS_OBJ_NUM_MAX 255
/* Names within the namespace are 4 bytes long */
#define ACPI_NAME_SIZE 4
#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */
#define ACPI_PATH_SEPARATOR '.'
/* Sizes for ACPI table headers */
#define ACPI_OEM_ID_SIZE 6
#define ACPI_OEM_TABLE_ID_SIZE 8
/* Constants used in searching for the RSDP in low memory */ /* Constants used in searching for the RSDP in low memory */
#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */ #define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */
...@@ -213,6 +191,7 @@ ...@@ -213,6 +191,7 @@
/* Maximum space_ids for Operation Regions */ /* Maximum space_ids for Operation Regions */
#define ACPI_MAX_ADDRESS_SPACE 255 #define ACPI_MAX_ADDRESS_SPACE 255
#define ACPI_NUM_DEFAULT_SPACES 4
/* Array sizes. Used for range checking also */ /* Array sizes. Used for range checking also */
......
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
#define ACPI_EXAMPLE 0x00004000 #define ACPI_EXAMPLE 0x00004000
#define ACPI_DRIVER 0x00008000 #define ACPI_DRIVER 0x00008000
#define DT_COMPILER 0x00010000 #define DT_COMPILER 0x00010000
#define ASL_PREPROCESSOR 0x00020000
#define ACPI_ALL_COMPONENTS 0x0001FFFF #define ACPI_ALL_COMPONENTS 0x0001FFFF
#define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS) #define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS)
...@@ -262,18 +263,140 @@ ...@@ -262,18 +263,140 @@
* Common parameters used for debug output functions: * Common parameters used for debug output functions:
* line number, function name, module(file) name, component ID * line number, function name, module(file) name, component ID
*/ */
#define ACPI_DEBUG_PARAMETERS __LINE__, ACPI_GET_FUNCTION_NAME, _acpi_module_name, _COMPONENT #define ACPI_DEBUG_PARAMETERS \
__LINE__, ACPI_GET_FUNCTION_NAME, _acpi_module_name, _COMPONENT
/* Check if debug output is currently dynamically enabled */
#define ACPI_IS_DEBUG_ENABLED(level, component) \
((level & acpi_dbg_level) && (component & acpi_dbg_layer))
/* /*
* Master debug print macros * Master debug print macros
* Print message if and only if: * Print message if and only if:
* 1) Debug print for the current component is enabled * 1) Debug print for the current component is enabled
* 2) Debug error level or trace level for the print statement is enabled * 2) Debug error level or trace level for the print statement is enabled
*
* November 2012: Moved the runtime check for whether to actually emit the
* debug message outside of the print function itself. This improves overall
* performance at a relatively small code cost. Implementation involves the
* use of variadic macros supported by C99.
*
* Note: the ACPI_DO_WHILE0 macro is used to prevent some compilers from
* complaining about these constructs. On other compilers the do...while
* adds some extra code, so this feature is optional.
*/ */
#define ACPI_DEBUG_PRINT(plist) acpi_debug_print plist #ifdef ACPI_USE_DO_WHILE_0
#define ACPI_DEBUG_PRINT_RAW(plist) acpi_debug_print_raw plist #define ACPI_DO_WHILE0(a) do a while(0)
#else #else
#define ACPI_DO_WHILE0(a) a
#endif
/* DEBUG_PRINT functions */
#define ACPI_DEBUG_PRINT(plist) ACPI_ACTUAL_DEBUG plist
#define ACPI_DEBUG_PRINT_RAW(plist) ACPI_ACTUAL_DEBUG_RAW plist
/* Helper macros for DEBUG_PRINT */
#define ACPI_DO_DEBUG_PRINT(function, level, line, filename, modulename, component, ...) \
ACPI_DO_WHILE0 ({ \
if (ACPI_IS_DEBUG_ENABLED (level, component)) \
{ \
function (level, line, filename, modulename, component, __VA_ARGS__); \
} \
})
#define ACPI_ACTUAL_DEBUG(level, line, filename, modulename, component, ...) \
ACPI_DO_DEBUG_PRINT (acpi_debug_print, level, line, \
filename, modulename, component, __VA_ARGS__)
#define ACPI_ACTUAL_DEBUG_RAW(level, line, filename, modulename, component, ...) \
ACPI_DO_DEBUG_PRINT (acpi_debug_print_raw, level, line, \
filename, modulename, component, __VA_ARGS__)
/*
* Function entry tracing
*
* The name of the function is emitted as a local variable that is
* intended to be used by both the entry trace and the exit trace.
*/
/* Helper macro */
#define ACPI_TRACE_ENTRY(name, function, cast, param) \
ACPI_FUNCTION_NAME (name) \
function (ACPI_DEBUG_PARAMETERS, cast (param))
/* The actual entry trace macros */
#define ACPI_FUNCTION_TRACE(name) \
ACPI_FUNCTION_NAME(name) \
acpi_ut_trace (ACPI_DEBUG_PARAMETERS)
#define ACPI_FUNCTION_TRACE_PTR(name, pointer) \
ACPI_TRACE_ENTRY (name, acpi_ut_trace_ptr, (void *), pointer)
#define ACPI_FUNCTION_TRACE_U32(name, value) \
ACPI_TRACE_ENTRY (name, acpi_ut_trace_u32, (u32), value)
#define ACPI_FUNCTION_TRACE_STR(name, string) \
ACPI_TRACE_ENTRY (name, acpi_ut_trace_str, (char *), string)
#define ACPI_FUNCTION_ENTRY() \
acpi_ut_track_stack_ptr()
/*
* Function exit tracing
*
* These macros include a return statement. This is usually considered
* bad form, but having a separate exit macro before the actual return
* is very ugly and difficult to maintain.
*
* One of the FUNCTION_TRACE macros above must be used in conjunction
* with these macros so that "_AcpiFunctionName" is defined.
*/
/* Exit trace helper macro */
#define ACPI_TRACE_EXIT(function, cast, param) \
ACPI_DO_WHILE0 ({ \
function (ACPI_DEBUG_PARAMETERS, cast (param)); \
return ((param)); \
})
/* The actual exit macros */
#define return_VOID \
ACPI_DO_WHILE0 ({ \
acpi_ut_exit (ACPI_DEBUG_PARAMETERS); \
return; \
})
#define return_ACPI_STATUS(status) \
ACPI_TRACE_EXIT (acpi_ut_status_exit, (acpi_status), status)
#define return_PTR(pointer) \
ACPI_TRACE_EXIT (acpi_ut_ptr_exit, (u8 *), pointer)
#define return_VALUE(value) \
ACPI_TRACE_EXIT (acpi_ut_value_exit, (u64), value)
/* Conditional execution */
#define ACPI_DEBUG_EXEC(a) a
#define ACPI_DEBUG_ONLY_MEMBERS(a) a;
#define _VERBOSE_STRUCTURES
/* Various object display routines for debug */
#define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a), 0)
#define ACPI_DUMP_OPERANDS(a, b ,c) acpi_ex_dump_operands(a, b, c)
#define ACPI_DUMP_ENTRY(a, b) acpi_ns_dump_entry (a, b)
#define ACPI_DUMP_PATHNAME(a, b, c, d) acpi_ns_dump_pathname(a, b, c, d)
#define ACPI_DUMP_BUFFER(a, b) acpi_ut_debug_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT)
#else /* ACPI_DEBUG_OUTPUT */
/* /*
* This is the non-debug case -- make everything go away, * This is the non-debug case -- make everything go away,
* leaving no executable debug code! * leaving no executable debug code!
...@@ -281,6 +404,32 @@ ...@@ -281,6 +404,32 @@
#define ACPI_FUNCTION_NAME(a) #define ACPI_FUNCTION_NAME(a)
#define ACPI_DEBUG_PRINT(pl) #define ACPI_DEBUG_PRINT(pl)
#define ACPI_DEBUG_PRINT_RAW(pl) #define ACPI_DEBUG_PRINT_RAW(pl)
#define ACPI_DEBUG_EXEC(a)
#define ACPI_DEBUG_ONLY_MEMBERS(a)
#define ACPI_FUNCTION_TRACE(a)
#define ACPI_FUNCTION_TRACE_PTR(a, b)
#define ACPI_FUNCTION_TRACE_U32(a, b)
#define ACPI_FUNCTION_TRACE_STR(a, b)
#define ACPI_FUNCTION_EXIT
#define ACPI_FUNCTION_STATUS_EXIT(s)
#define ACPI_FUNCTION_VALUE_EXIT(s)
#define ACPI_FUNCTION_ENTRY()
#define ACPI_DUMP_STACK_ENTRY(a)
#define ACPI_DUMP_OPERANDS(a, b, c)
#define ACPI_DUMP_ENTRY(a, b)
#define ACPI_DUMP_TABLES(a, b)
#define ACPI_DUMP_PATHNAME(a, b, c, d)
#define ACPI_DUMP_BUFFER(a, b)
#define ACPI_DEBUG_PRINT(pl)
#define ACPI_DEBUG_PRINT_RAW(pl)
#define ACPI_IS_DEBUG_ENABLED(level, component) 0
/* Return macros must have a return statement at the minimum */
#define return_VOID return
#define return_ACPI_STATUS(s) return(s)
#define return_VALUE(s) return(s)
#define return_PTR(s) return(s)
#endif /* ACPI_DEBUG_OUTPUT */ #endif /* ACPI_DEBUG_OUTPUT */
......
...@@ -102,10 +102,8 @@ acpi_os_physical_table_override(struct acpi_table_header *existing_table, ...@@ -102,10 +102,8 @@ acpi_os_physical_table_override(struct acpi_table_header *existing_table,
/* /*
* Spinlock primitives * Spinlock primitives
*/ */
#ifndef acpi_os_create_lock #ifndef acpi_os_create_lock
acpi_status acpi_status acpi_os_create_lock(acpi_spinlock * out_handle);
acpi_os_create_lock(acpi_spinlock *out_handle);
#endif #endif
void acpi_os_delete_lock(acpi_spinlock handle); void acpi_os_delete_lock(acpi_spinlock handle);
...@@ -148,6 +146,8 @@ void acpi_os_release_mutex(acpi_mutex handle); ...@@ -148,6 +146,8 @@ void acpi_os_release_mutex(acpi_mutex handle);
*/ */
void *acpi_os_allocate(acpi_size size); void *acpi_os_allocate(acpi_size size);
void acpi_os_free(void *memory);
void __iomem *acpi_os_map_memory(acpi_physical_address where, void __iomem *acpi_os_map_memory(acpi_physical_address where,
acpi_size length); acpi_size length);
...@@ -180,12 +180,13 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object); ...@@ -180,12 +180,13 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object);
* Interrupt handlers * Interrupt handlers
*/ */
acpi_status acpi_status
acpi_os_install_interrupt_handler(u32 gsi, acpi_os_install_interrupt_handler(u32 interrupt_number,
acpi_osd_handler service_routine, acpi_osd_handler service_routine,
void *context); void *context);
acpi_status acpi_status
acpi_os_remove_interrupt_handler(u32 gsi, acpi_osd_handler service_routine); acpi_os_remove_interrupt_handler(u32 interrupt_number,
acpi_osd_handler service_routine);
void acpi_os_gpe_count(u32 gpe_number); void acpi_os_gpe_count(u32 gpe_number);
void acpi_os_fixed_event_count(u32 fixed_event_number); void acpi_os_fixed_event_count(u32 fixed_event_number);
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
/* Current ACPICA subsystem version in YYYYMMDD format */ /* Current ACPICA subsystem version in YYYYMMDD format */
#define ACPI_CA_VERSION 0x20121018 #define ACPI_CA_VERSION 0x20121220
#include <acpi/acconfig.h> #include <acpi/acconfig.h>
#include <acpi/actypes.h> #include <acpi/actypes.h>
...@@ -56,11 +56,20 @@ ...@@ -56,11 +56,20 @@
extern u8 acpi_gbl_permanent_mmap; extern u8 acpi_gbl_permanent_mmap;
/* /*
* Globals that are publicly available, allowing for * Globals that are publically available
* run time configuration
*/ */
extern u32 acpi_current_gpe_count;
extern struct acpi_table_fadt acpi_gbl_FADT;
extern u8 acpi_gbl_system_awake_and_running;
extern u8 acpi_gbl_reduced_hardware; /* ACPI 5.0 */
/* Runtime configuration of debug print levels */
extern u32 acpi_dbg_level; extern u32 acpi_dbg_level;
extern u32 acpi_dbg_layer; extern u32 acpi_dbg_layer;
/* ACPICA runtime options */
extern u8 acpi_gbl_enable_interpreter_slack; extern u8 acpi_gbl_enable_interpreter_slack;
extern u8 acpi_gbl_all_methods_serialized; extern u8 acpi_gbl_all_methods_serialized;
extern u8 acpi_gbl_create_osi_method; extern u8 acpi_gbl_create_osi_method;
...@@ -99,14 +108,9 @@ extern u8 acpi_gbl_disable_auto_repair; ...@@ -99,14 +108,9 @@ extern u8 acpi_gbl_disable_auto_repair;
#endif /* !ACPI_REDUCED_HARDWARE */ #endif /* !ACPI_REDUCED_HARDWARE */
extern u32 acpi_current_gpe_count;
extern struct acpi_table_fadt acpi_gbl_FADT;
extern u8 acpi_gbl_system_awake_and_running;
extern u8 acpi_gbl_reduced_hardware; /* ACPI 5.0 */
extern u32 acpi_rsdt_forced; extern u32 acpi_rsdt_forced;
/* /*
* Global interfaces * Initialization
*/ */
acpi_status acpi_status
acpi_initialize_tables(struct acpi_table_desc *initial_storage, acpi_initialize_tables(struct acpi_table_desc *initial_storage,
...@@ -120,13 +124,15 @@ acpi_status acpi_initialize_objects(u32 flags); ...@@ -120,13 +124,15 @@ acpi_status acpi_initialize_objects(u32 flags);
acpi_status acpi_terminate(void); acpi_status acpi_terminate(void);
/*
* Miscellaneous global interfaces
*/
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable(void))
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable(void))
#ifdef ACPI_FUTURE_USAGE #ifdef ACPI_FUTURE_USAGE
acpi_status acpi_subsystem_status(void); acpi_status acpi_subsystem_status(void);
#endif #endif
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable(void))
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable(void))
#ifdef ACPI_FUTURE_USAGE #ifdef ACPI_FUTURE_USAGE
acpi_status acpi_get_system_info(struct acpi_buffer *ret_buffer); acpi_status acpi_get_system_info(struct acpi_buffer *ret_buffer);
#endif #endif
...@@ -191,9 +197,9 @@ acpi_status ...@@ -191,9 +197,9 @@ acpi_status
acpi_get_table_by_index(u32 table_index, struct acpi_table_header **out_table); acpi_get_table_by_index(u32 table_index, struct acpi_table_header **out_table);
acpi_status acpi_status
acpi_install_table_handler(acpi_tbl_handler handler, void *context); acpi_install_table_handler(acpi_table_handler handler, void *context);
acpi_status acpi_remove_table_handler(acpi_tbl_handler handler); acpi_status acpi_remove_table_handler(acpi_table_handler handler);
/* /*
* Namespace and name interfaces * Namespace and name interfaces
...@@ -437,6 +443,11 @@ acpi_status ...@@ -437,6 +443,11 @@ acpi_status
acpi_get_event_resources(acpi_handle device_handle, acpi_get_event_resources(acpi_handle device_handle,
struct acpi_buffer *ret_buffer); struct acpi_buffer *ret_buffer);
acpi_status
acpi_walk_resource_buffer(struct acpi_buffer *buffer,
acpi_walk_resource_callback user_function,
void *context);
acpi_status acpi_status
acpi_walk_resources(acpi_handle device, acpi_walk_resources(acpi_handle device,
char *name, char *name,
...@@ -462,6 +473,10 @@ acpi_buffer_to_resource(u8 *aml_buffer, ...@@ -462,6 +473,10 @@ acpi_buffer_to_resource(u8 *aml_buffer,
*/ */
acpi_status acpi_reset(void); acpi_status acpi_reset(void);
acpi_status acpi_read(u64 *value, struct acpi_generic_address *reg);
acpi_status acpi_write(u64 value, struct acpi_generic_address *reg);
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
acpi_read_bit_register(u32 register_id, acpi_read_bit_register(u32 register_id,
u32 *return_value)) u32 *return_value))
...@@ -470,20 +485,6 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status ...@@ -470,20 +485,6 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
acpi_write_bit_register(u32 register_id, acpi_write_bit_register(u32 register_id,
u32 value)) u32 value))
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
acpi_set_firmware_waking_vector(u32
physical_address))
#if ACPI_MACHINE_WIDTH == 64
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
acpi_set_firmware_waking_vector64(u64
physical_address))
#endif
acpi_status acpi_read(u64 *value, struct acpi_generic_address *reg);
acpi_status acpi_write(u64 value, struct acpi_generic_address *reg);
/* /*
* Sleep/Wake interfaces * Sleep/Wake interfaces
*/ */
...@@ -500,6 +501,15 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state); ...@@ -500,6 +501,15 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state);
acpi_status acpi_leave_sleep_state(u8 sleep_state); acpi_status acpi_leave_sleep_state(u8 sleep_state);
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
acpi_set_firmware_waking_vector(u32
physical_address))
#if ACPI_MACHINE_WIDTH == 64
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
acpi_set_firmware_waking_vector64(u64
physical_address))
#endif
/* /*
* ACPI Timer interfaces * ACPI Timer interfaces
*/ */
......
...@@ -102,8 +102,11 @@ typedef u32 acpi_rsdesc_size; /* Max Resource Descriptor size is (Length+3) = (6 ...@@ -102,8 +102,11 @@ typedef u32 acpi_rsdesc_size; /* Max Resource Descriptor size is (Length+3) = (6
#define ACPI_EXCLUSIVE (u8) 0x00 #define ACPI_EXCLUSIVE (u8) 0x00
#define ACPI_SHARED (u8) 0x01 #define ACPI_SHARED (u8) 0x01
#define ACPI_EXCLUSIVE_AND_WAKE (u8) 0x02
#define ACPI_SHARED_AND_WAKE (u8) 0x03 /* Wake */
#define ACPI_NOT_WAKE_CAPABLE (u8) 0x00
#define ACPI_WAKE_CAPABLE (u8) 0x01
/* /*
* DMA Attributes * DMA Attributes
...@@ -171,6 +174,7 @@ struct acpi_resource_irq { ...@@ -171,6 +174,7 @@ struct acpi_resource_irq {
u8 triggering; u8 triggering;
u8 polarity; u8 polarity;
u8 sharable; u8 sharable;
u8 wake_capable;
u8 interrupt_count; u8 interrupt_count;
u8 interrupts[1]; u8 interrupts[1];
}; };
...@@ -346,6 +350,7 @@ struct acpi_resource_extended_irq { ...@@ -346,6 +350,7 @@ struct acpi_resource_extended_irq {
u8 triggering; u8 triggering;
u8 polarity; u8 polarity;
u8 sharable; u8 sharable;
u8 wake_capable;
u8 interrupt_count; u8 interrupt_count;
struct acpi_resource_source resource_source; struct acpi_resource_source resource_source;
u32 interrupts[1]; u32 interrupts[1];
...@@ -365,6 +370,7 @@ struct acpi_resource_gpio { ...@@ -365,6 +370,7 @@ struct acpi_resource_gpio {
u8 producer_consumer; /* For values, see Producer/Consumer above */ u8 producer_consumer; /* For values, see Producer/Consumer above */
u8 pin_config; u8 pin_config;
u8 sharable; /* For values, see Interrupt Attributes above */ u8 sharable; /* For values, see Interrupt Attributes above */
u8 wake_capable; /* For values, see Interrupt Attributes above */
u8 io_restriction; u8 io_restriction;
u8 triggering; /* For values, see Interrupt Attributes above */ u8 triggering; /* For values, see Interrupt Attributes above */
u8 polarity; /* For values, see Interrupt Attributes above */ u8 polarity; /* For values, see Interrupt Attributes above */
...@@ -591,7 +597,10 @@ struct acpi_resource { ...@@ -591,7 +597,10 @@ struct acpi_resource {
#define ACPI_RS_SIZE_MIN (u32) ACPI_ROUND_UP_TO_NATIVE_WORD (12) #define ACPI_RS_SIZE_MIN (u32) ACPI_ROUND_UP_TO_NATIVE_WORD (12)
#define ACPI_RS_SIZE(type) (u32) (ACPI_RS_SIZE_NO_DATA + sizeof (type)) #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) /* Macro for walking resource templates with multiple descriptors */
#define ACPI_NEXT_RESOURCE(res) \
ACPI_ADD_PTR (struct acpi_resource, (res), (res)->length)
struct acpi_pci_routing_table { struct acpi_pci_routing_table {
u32 length; u32 length;
......
...@@ -326,8 +326,6 @@ enum acpi_preferred_pm_profiles { ...@@ -326,8 +326,6 @@ enum acpi_preferred_pm_profiles {
#pragma pack() #pragma pack()
#define ACPI_FADT_OFFSET(f) (u16) ACPI_OFFSET (struct acpi_table_fadt, f)
/* /*
* Internal table-related structures * Internal table-related structures
*/ */
...@@ -359,11 +357,14 @@ struct acpi_table_desc { ...@@ -359,11 +357,14 @@ struct acpi_table_desc {
/* /*
* Get the remaining ACPI tables * Get the remaining ACPI tables
*/ */
#include <acpi/actbl1.h> #include <acpi/actbl1.h>
#include <acpi/actbl2.h> #include <acpi/actbl2.h>
#include <acpi/actbl3.h> #include <acpi/actbl3.h>
/* Macros used to generate offsets to specific table fields */
#define ACPI_FADT_OFFSET(f) (u16) ACPI_OFFSET (struct acpi_table_fadt, f)
/* /*
* Sizes of the various flavors of FADT. We need to look closely * Sizes of the various flavors of FADT. We need to look closely
* at the FADT length because the version number essentially tells * at the FADT length because the version number essentially tells
......
...@@ -768,7 +768,7 @@ struct acpi_madt_interrupt_source { ...@@ -768,7 +768,7 @@ struct acpi_madt_interrupt_source {
struct acpi_madt_local_x2apic { struct acpi_madt_local_x2apic {
struct acpi_subtable_header header; struct acpi_subtable_header header;
u16 reserved; /* Reserved - must be zero */ u16 reserved; /* reserved - must be zero */
u32 local_apic_id; /* Processor x2APIC ID */ u32 local_apic_id; /* Processor x2APIC ID */
u32 lapic_flags; u32 lapic_flags;
u32 uid; /* ACPI processor UID */ u32 uid; /* ACPI processor UID */
...@@ -781,14 +781,14 @@ struct acpi_madt_local_x2apic_nmi { ...@@ -781,14 +781,14 @@ struct acpi_madt_local_x2apic_nmi {
u16 inti_flags; u16 inti_flags;
u32 uid; /* ACPI processor UID */ u32 uid; /* ACPI processor UID */
u8 lint; /* LINTn to which NMI is connected */ u8 lint; /* LINTn to which NMI is connected */
u8 reserved[3]; u8 reserved[3]; /* reserved - must be zero */
}; };
/* 11: Generic Interrupt (ACPI 5.0) */ /* 11: Generic Interrupt (ACPI 5.0) */
struct acpi_madt_generic_interrupt { struct acpi_madt_generic_interrupt {
struct acpi_subtable_header header; struct acpi_subtable_header header;
u16 reserved; /* Reserved - must be zero */ u16 reserved; /* reserved - must be zero */
u32 gic_id; u32 gic_id;
u32 uid; u32 uid;
u32 flags; u32 flags;
......
...@@ -261,9 +261,28 @@ struct acpi_csrt_group { ...@@ -261,9 +261,28 @@ struct acpi_csrt_group {
u16 subdevice_id; u16 subdevice_id;
u16 revision; u16 revision;
u16 reserved; u16 reserved;
u32 info_length; u32 shared_info_length;
/* Shared data (length = info_length) immediately follows */ /* Shared data immediately follows (Length = shared_info_length) */
};
/* Shared Info subtable */
struct acpi_csrt_shared_info {
u16 major_version;
u16 minor_version;
u32 mmio_base_low;
u32 mmio_base_high;
u32 gsi_interrupt;
u8 interrupt_polarity;
u8 interrupt_mode;
u8 num_channels;
u8 dma_address_width;
u16 base_request_line;
u16 num_handshake_signals;
u32 max_block_size;
/* Resource descriptors immediately follow (Length = Group length - shared_info_length) */
}; };
/* Resource Descriptor subtable */ /* Resource Descriptor subtable */
......
...@@ -68,13 +68,13 @@ ...@@ -68,13 +68,13 @@
#define ACPI_SIG_PCCT "PCCT" /* Platform Communications Channel Table */ #define ACPI_SIG_PCCT "PCCT" /* Platform Communications Channel Table */
#define ACPI_SIG_PMTT "PMTT" /* Platform Memory Topology Table */ #define ACPI_SIG_PMTT "PMTT" /* Platform Memory Topology Table */
#define ACPI_SIG_RASF "RASF" /* RAS Feature table */ #define ACPI_SIG_RASF "RASF" /* RAS Feature table */
#define ACPI_SIG_TPM2 "TPM2" /* Trusted Platform Module 2.0 H/W interface table */
#define ACPI_SIG_S3PT "S3PT" /* S3 Performance (sub)Table */ #define ACPI_SIG_S3PT "S3PT" /* S3 Performance (sub)Table */
#define ACPI_SIG_PCCS "PCC" /* PCC Shared Memory Region */ #define ACPI_SIG_PCCS "PCC" /* PCC Shared Memory Region */
/* Reserved table signatures */ /* Reserved table signatures */
#define ACPI_SIG_CSRT "CSRT" /* Core System Resources Table */
#define ACPI_SIG_MATR "MATR" /* Memory Address Translation Table */ #define ACPI_SIG_MATR "MATR" /* Memory Address Translation Table */
#define ACPI_SIG_MSDM "MSDM" /* Microsoft Data Management Table */ #define ACPI_SIG_MSDM "MSDM" /* Microsoft Data Management Table */
#define ACPI_SIG_WPBT "WPBT" /* Windows Platform Binary Table */ #define ACPI_SIG_WPBT "WPBT" /* Windows Platform Binary Table */
...@@ -550,6 +550,36 @@ enum acpi_rasf_status { ...@@ -550,6 +550,36 @@ enum acpi_rasf_status {
#define ACPI_RASF_ERROR (1<<2) #define ACPI_RASF_ERROR (1<<2)
#define ACPI_RASF_STATUS (0x1F<<3) #define ACPI_RASF_STATUS (0x1F<<3)
/*******************************************************************************
*
* TPM2 - Trusted Platform Module (TPM) 2.0 Hardware Interface Table
* Version 3
*
* Conforms to "TPM 2.0 Hardware Interface Table (TPM2)" 29 November 2011
*
******************************************************************************/
struct acpi_table_tpm2 {
struct acpi_table_header header; /* Common ACPI table header */
u32 flags;
u64 control_address;
u32 start_method;
};
/* Control area structure (not part of table, pointed to by control_address) */
struct acpi_tpm2_control {
u32 reserved;
u32 error;
u32 cancel;
u32 start;
u64 interrupt_control;
u32 command_size;
u64 command_address;
u32 response_size;
u64 response_address;
};
/* Reset to default packing */ /* Reset to default packing */
#pragma pack() #pragma pack()
......
...@@ -341,7 +341,7 @@ typedef u32 acpi_physical_address; ...@@ -341,7 +341,7 @@ typedef u32 acpi_physical_address;
/* PM Timer ticks per second (HZ) */ /* PM Timer ticks per second (HZ) */
#define PM_TIMER_FREQUENCY 3579545 #define ACPI_PM_TIMER_FREQUENCY 3579545
/******************************************************************************* /*******************************************************************************
* *
...@@ -373,6 +373,21 @@ typedef u32 acpi_name; /* 4-byte ACPI name */ ...@@ -373,6 +373,21 @@ typedef u32 acpi_name; /* 4-byte ACPI name */
typedef char *acpi_string; /* Null terminated ASCII string */ typedef char *acpi_string; /* Null terminated ASCII string */
typedef void *acpi_handle; /* Actually a ptr to a NS Node */ typedef void *acpi_handle; /* Actually a ptr to a NS Node */
/* Time constants for timer calculations */
#define ACPI_MSEC_PER_SEC 1000L
#define ACPI_USEC_PER_MSEC 1000L
#define ACPI_USEC_PER_SEC 1000000L
#define ACPI_100NSEC_PER_USEC 10L
#define ACPI_100NSEC_PER_MSEC 10000L
#define ACPI_100NSEC_PER_SEC 10000000L
#define ACPI_NSEC_PER_USEC 1000L
#define ACPI_NSEC_PER_MSEC 1000000L
#define ACPI_NSEC_PER_SEC 1000000000L
/* Owner IDs are used to track namespace nodes for selective deletion */ /* Owner IDs are used to track namespace nodes for selective deletion */
typedef u8 acpi_owner_id; typedef u8 acpi_owner_id;
...@@ -390,10 +405,6 @@ typedef u8 acpi_owner_id; ...@@ -390,10 +405,6 @@ typedef u8 acpi_owner_id;
#define ACPI_MAX16_DECIMAL_DIGITS 5 #define ACPI_MAX16_DECIMAL_DIGITS 5
#define ACPI_MAX8_DECIMAL_DIGITS 3 #define ACPI_MAX8_DECIMAL_DIGITS 3
/* PM Timer ticks per second (HZ) */
#define PM_TIMER_FREQUENCY 3579545
/* /*
* Constants with special meanings * Constants with special meanings
*/ */
...@@ -474,6 +485,7 @@ typedef u64 acpi_integer; ...@@ -474,6 +485,7 @@ typedef u64 acpi_integer;
*/ */
#define ACPI_FULL_INITIALIZATION 0x00 #define ACPI_FULL_INITIALIZATION 0x00
#define ACPI_NO_ADDRESS_SPACE_INIT 0x01 #define ACPI_NO_ADDRESS_SPACE_INIT 0x01
#define ACPI_NO_HARDWARE_INIT 0x02
#define ACPI_NO_EVENT_INIT 0x04 #define ACPI_NO_EVENT_INIT 0x04
#define ACPI_NO_HANDLER_INIT 0x08 #define ACPI_NO_HANDLER_INIT 0x08
#define ACPI_NO_ACPI_ENABLE 0x10 #define ACPI_NO_ACPI_ENABLE 0x10
...@@ -595,7 +607,7 @@ typedef u32 acpi_object_type; ...@@ -595,7 +607,7 @@ typedef u32 acpi_object_type;
/* /*
* These are special object types that never appear in * These are special object types that never appear in
* a Namespace node, only in a union acpi_operand_object * a Namespace node, only in an object of union acpi_operand_object
*/ */
#define ACPI_TYPE_LOCAL_EXTRA 0x1C #define ACPI_TYPE_LOCAL_EXTRA 0x1C
#define ACPI_TYPE_LOCAL_DATA 0x1D #define ACPI_TYPE_LOCAL_DATA 0x1D
...@@ -662,7 +674,7 @@ typedef u32 acpi_event_status; ...@@ -662,7 +674,7 @@ typedef u32 acpi_event_status;
#define ACPI_GPE_MAX 0xFF #define ACPI_GPE_MAX 0xFF
#define ACPI_NUM_GPE 256 #define ACPI_NUM_GPE 256
/* Actions for acpi_set_gpe_wake_mask, acpi_hw_low_set_gpe */ /* Actions for acpi_set_gpe, acpi_gpe_wakeup, acpi_hw_low_set_gpe */
#define ACPI_GPE_ENABLE 0 #define ACPI_GPE_ENABLE 0
#define ACPI_GPE_DISABLE 1 #define ACPI_GPE_DISABLE 1
...@@ -880,6 +892,10 @@ struct acpi_buffer { ...@@ -880,6 +892,10 @@ struct acpi_buffer {
void *pointer; /* pointer to buffer */ void *pointer; /* pointer to buffer */
}; };
/* Free a buffer created in an struct acpi_buffer via ACPI_ALLOCATE_LOCAL_BUFFER */
#define ACPI_FREE_BUFFER(b) ACPI_FREE(b.pointer)
/* /*
* name_type for acpi_get_name * name_type for acpi_get_name
*/ */
...@@ -968,7 +984,11 @@ acpi_status(*acpi_exception_handler) (acpi_status aml_status, ...@@ -968,7 +984,11 @@ acpi_status(*acpi_exception_handler) (acpi_status aml_status,
/* Table Event handler (Load, load_table, etc.) and types */ /* Table Event handler (Load, load_table, etc.) and types */
typedef typedef
acpi_status(*acpi_tbl_handler) (u32 event, void *table, void *context); acpi_status(*acpi_table_handler) (u32 event, void *table, void *context);
#define ACPI_TABLE_LOAD 0x0
#define ACPI_TABLE_UNLOAD 0x1
#define ACPI_NUM_TABLE_EVENTS 2
/* Address Spaces (For Operation Regions) */ /* Address Spaces (For Operation Regions) */
......
/****************************************************************************** /******************************************************************************
* *
* Name: acenv.h - Generation environment specific items * Name: acenv.h - Host and compiler configuration
* *
*****************************************************************************/ *****************************************************************************/
...@@ -44,6 +44,12 @@ ...@@ -44,6 +44,12 @@
#ifndef __ACENV_H__ #ifndef __ACENV_H__
#define __ACENV_H__ #define __ACENV_H__
/*
* Environment configuration. The purpose of this file is to interface ACPICA
* to the local environment. This includes compiler-specific, OS-specific,
* and machine-specific configuration.
*/
/* Types for ACPI_MUTEX_TYPE */ /* Types for ACPI_MUTEX_TYPE */
#define ACPI_BINARY_SEMAPHORE 0 #define ACPI_BINARY_SEMAPHORE 0
...@@ -60,145 +66,200 @@ ...@@ -60,145 +66,200 @@
* *
*****************************************************************************/ *****************************************************************************/
#ifdef ACPI_LIBRARY /* iASL configuration */
/*
* Note: The non-debug version of the acpi_library does not contain any
* debug support, for minimal size. The debug version uses ACPI_FULL_DEBUG
*/
#define ACPI_USE_LOCAL_CACHE
#endif
#ifdef ACPI_ASL_COMPILER #ifdef ACPI_ASL_COMPILER
#define ACPI_DEBUG_OUTPUT
#define ACPI_APPLICATION #define ACPI_APPLICATION
#define ACPI_DISASSEMBLER #define ACPI_DISASSEMBLER
#define ACPI_DEBUG_OUTPUT
#define ACPI_CONSTANT_EVAL_ONLY #define ACPI_CONSTANT_EVAL_ONLY
#define ACPI_LARGE_NAMESPACE_NODE #define ACPI_LARGE_NAMESPACE_NODE
#define ACPI_DATA_TABLE_DISASSEMBLY #define ACPI_DATA_TABLE_DISASSEMBLY
#define ACPI_SINGLE_THREADED
#endif #endif
/* acpi_exec configuration. Multithreaded with full AML debugger */
#ifdef ACPI_EXEC_APP #ifdef ACPI_EXEC_APP
#undef DEBUGGER_THREADING
#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED
#define ACPI_FULL_DEBUG
#define ACPI_APPLICATION #define ACPI_APPLICATION
#define ACPI_DEBUGGER #define ACPI_FULL_DEBUG
#define ACPI_MUTEX_DEBUG #define ACPI_MUTEX_DEBUG
#define ACPI_DBG_TRACK_ALLOCATIONS #define ACPI_DBG_TRACK_ALLOCATIONS
#endif #endif
/* acpi_names configuration. Single threaded with debugger output enabled. */
#ifdef ACPI_NAMES_APP
#define ACPI_DEBUGGER
#define ACPI_APPLICATION
#define ACPI_SINGLE_THREADED
#endif
/*
* acpi_bin/acpi_help/acpi_src configuration. All single threaded, with
* no debug output.
*/
#if (defined ACPI_BIN_APP) || \
(defined ACPI_SRC_APP) || \
(defined ACPI_XTRACT_APP)
#define ACPI_APPLICATION
#define ACPI_SINGLE_THREADED
#endif
#ifdef ACPI_HELP_APP
#define ACPI_APPLICATION
#define ACPI_SINGLE_THREADED
#define ACPI_NO_ERROR_MESSAGES
#endif
/* Linkable ACPICA library */
#ifdef ACPI_LIBRARY
#define ACPI_USE_LOCAL_CACHE
#define ACPI_FUTURE_USAGE
#endif
/* Common for all ACPICA applications */
#ifdef ACPI_APPLICATION #ifdef ACPI_APPLICATION
#define ACPI_USE_SYSTEM_CLIBRARY #define ACPI_USE_SYSTEM_CLIBRARY
#define ACPI_USE_LOCAL_CACHE #define ACPI_USE_LOCAL_CACHE
#endif #endif
/* Common debug support */
#ifdef ACPI_FULL_DEBUG #ifdef ACPI_FULL_DEBUG
#define ACPI_DEBUGGER #define ACPI_DEBUGGER
#define ACPI_DEBUG_OUTPUT #define ACPI_DEBUG_OUTPUT
#define ACPI_DISASSEMBLER #define ACPI_DISASSEMBLER
#endif #endif
/*
* Environment configuration. The purpose of this file is to interface to the
* local generation environment.
*
* 1) ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library.
* Otherwise, local versions of string/memory functions will be used.
* 2) ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and
* the standard header files may be used.
*
* The ACPI subsystem only uses low level C library functions that do not call
* operating system services and may therefore be inlined in the code.
*
* It may be necessary to tailor these include files to the target
* generation environment.
*
*
* Functions and constants used from each header:
*
* string.h: memcpy
* memset
* strcat
* strcmp
* strcpy
* strlen
* strncmp
* strncat
* strncpy
*
* stdlib.h: strtoul
*
* stdarg.h: va_list
* va_arg
* va_start
* va_end
*
*/
/*! [Begin] no source code translation */ /*! [Begin] no source code translation */
/******************************************************************************
*
* Host configuration files. The compiler configuration files are included
* by the host files.
*
*****************************************************************************/
#if defined(_LINUX) || defined(__linux__) #if defined(_LINUX) || defined(__linux__)
#include <acpi/platform/aclinux.h> #include <acpi/platform/aclinux.h>
#elif defined(_AED_EFI)
#include "acefi.h"
#elif defined(WIN32)
#include "acwin.h"
#elif defined(WIN64)
#include "acwin64.h"
#elif defined(MSDOS) /* Must appear after WIN32 and WIN64 check */
#include "acdos16.h"
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include "acfreebsd.h" #include "acfreebsd.h"
#elif defined(__NetBSD__) #elif defined(__NetBSD__)
#include "acnetbsd.h" #include "acnetbsd.h"
#elif defined(__sun)
#include "acsolaris.h"
#elif defined(MODESTO) #elif defined(MODESTO)
#include "acmodesto.h" #include "acmodesto.h"
#elif defined(NETWARE) #elif defined(NETWARE)
#include "acnetware.h" #include "acnetware.h"
#elif defined(__sun) #elif defined(_CYGWIN)
#include "acsolaris.h" #include "accygwin.h"
#else #elif defined(WIN32)
#include "acwin.h"
#elif defined(WIN64)
#include "acwin64.h"
/* All other environments */ #elif defined(_WRS_LIB_BUILD)
#include "acvxworks.h"
#define ACPI_USE_STANDARD_HEADERS #elif defined(__OS2__)
#include "acos2.h"
#define COMPILER_DEPENDENT_INT64 long long #elif defined(_AED_EFI)
#define COMPILER_DEPENDENT_UINT64 unsigned long long #include "acefi.h"
#elif defined(__HAIKU__)
#include "achaiku.h"
#else
/* Unknown environment */
#error Unknown target environment
#endif #endif
/*! [End] no source code translation !*/ /*! [End] no source code translation !*/
/****************************************************************************** /******************************************************************************
* *
* Miscellaneous configuration * Setup defaults for the required symbols that were not defined in one of
* the host/compiler files above.
* *
*****************************************************************************/ *****************************************************************************/
/* /* 64-bit data types */
* Are mutexes supported by the host? default is no, use binary semaphores.
*/ #ifndef COMPILER_DEPENDENT_INT64
#define COMPILER_DEPENDENT_INT64 long long
#endif
#ifndef COMPILER_DEPENDENT_UINT64
#define COMPILER_DEPENDENT_UINT64 unsigned long long
#endif
/* Type of mutex supported by host. Default is binary semaphores. */
#ifndef ACPI_MUTEX_TYPE #ifndef ACPI_MUTEX_TYPE
#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE #define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE
#endif #endif
/* Global Lock acquire/release */
#ifndef ACPI_ACQUIRE_GLOBAL_LOCK
#define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acquired) acquired = 1
#endif
#ifndef ACPI_RELEASE_GLOBAL_LOCK
#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, pending) pending = 0
#endif
/* Flush CPU cache - used when going to sleep. Wbinvd or similar. */
#ifndef ACPI_FLUSH_CPU_CACHE
#define ACPI_FLUSH_CPU_CACHE()
#endif
/* "inline" keywords - configurable since inline is not standardized */ /* "inline" keywords - configurable since inline is not standardized */
#ifndef ACPI_INLINE #ifndef ACPI_INLINE
#define ACPI_INLINE #define ACPI_INLINE
#endif #endif
/*
* Configurable calling conventions:
*
* ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
* ACPI_EXTERNAL_XFACE - External ACPI interfaces
* ACPI_INTERNAL_XFACE - Internal ACPI interfaces
* ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
*/
#ifndef ACPI_SYSTEM_XFACE
#define ACPI_SYSTEM_XFACE
#endif
#ifndef ACPI_EXTERNAL_XFACE
#define ACPI_EXTERNAL_XFACE
#endif
#ifndef ACPI_INTERNAL_XFACE
#define ACPI_INTERNAL_XFACE
#endif
#ifndef ACPI_INTERNAL_VAR_XFACE
#define ACPI_INTERNAL_VAR_XFACE
#endif
/* /*
* Debugger threading model * Debugger threading model
* Use single threaded if the entire subsystem is contained in an application * Use single threaded if the entire subsystem is contained in an application
...@@ -222,17 +283,26 @@ ...@@ -222,17 +283,26 @@
* *
*****************************************************************************/ *****************************************************************************/
#define ACPI_IS_ASCII(c) ((c) < 0x80)
#ifdef ACPI_USE_SYSTEM_CLIBRARY
/* /*
* Use the standard C library headers. * ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library.
* We want to keep these to a minimum. * Otherwise, local versions of string/memory functions will be used.
* ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and
* the standard header files may be used.
*
* The ACPICA subsystem only uses low level C library functions that do not call
* operating system services and may therefore be inlined in the code.
*
* It may be necessary to tailor these include files to the target
* generation environment.
*/ */
#ifdef ACPI_USE_SYSTEM_CLIBRARY
/* Use the standard C library headers. We want to keep these to a minimum. */
#ifdef ACPI_USE_STANDARD_HEADERS #ifdef ACPI_USE_STANDARD_HEADERS
/*
* Use the standard headers from the standard locations /* Use the standard headers from the standard locations */
*/
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -240,9 +310,8 @@ ...@@ -240,9 +310,8 @@
#endif /* ACPI_USE_STANDARD_HEADERS */ #endif /* ACPI_USE_STANDARD_HEADERS */
/* /* We will be linking to the standard Clib functions */
* We will be linking to the standard Clib functions
*/
#define ACPI_STRSTR(s1,s2) strstr((s1), (s2)) #define ACPI_STRSTR(s1,s2) strstr((s1), (s2))
#define ACPI_STRCHR(s1,c) strchr((s1), (c)) #define ACPI_STRCHR(s1,c) strchr((s1), (c))
#define ACPI_STRLEN(s) (acpi_size) strlen((s)) #define ACPI_STRLEN(s) (acpi_size) strlen((s))
...@@ -274,13 +343,12 @@ ...@@ -274,13 +343,12 @@
* *
*****************************************************************************/ *****************************************************************************/
/* /*
* Use local definitions of C library macros and functions * Use local definitions of C library macros and functions. These function
* NOTE: The function implementations may not be as efficient * implementations may not be as efficient as an inline or assembly code
* as an inline or assembly code implementation provided by a * implementation provided by a native C library, but they are functionally
* native C library. * equivalent.
*/ */
#ifndef va_arg #ifndef va_arg
#ifndef _VALIST #ifndef _VALIST
...@@ -288,22 +356,22 @@ ...@@ -288,22 +356,22 @@
typedef char *va_list; typedef char *va_list;
#endif /* _VALIST */ #endif /* _VALIST */
/* /* Storage alignment properties */
* Storage alignment properties
*/
#define _AUPBND (sizeof (acpi_native_int) - 1) #define _AUPBND (sizeof (acpi_native_int) - 1)
#define _ADNBND (sizeof (acpi_native_int) - 1) #define _ADNBND (sizeof (acpi_native_int) - 1)
/* /* Variable argument list macro definitions */
* Variable argument list macro definitions
*/
#define _bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd))) #define _bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd)))
#define va_arg(ap, T) (*(T *)(((ap) += (_bnd (T, _AUPBND))) - (_bnd (T,_ADNBND)))) #define va_arg(ap, T) (*(T *)(((ap) += (_bnd (T, _AUPBND))) - (_bnd (T,_ADNBND))))
#define va_end(ap) (void) 0 #define va_end(ap) (ap = (va_list) NULL)
#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND)))) #define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND))))
#endif /* va_arg */ #endif /* va_arg */
/* Use the local (ACPICA) definitions of the clib functions */
#define ACPI_STRSTR(s1,s2) acpi_ut_strstr ((s1), (s2)) #define ACPI_STRSTR(s1,s2) acpi_ut_strstr ((s1), (s2))
#define ACPI_STRCHR(s1,c) acpi_ut_strchr ((s1), (c)) #define ACPI_STRCHR(s1,c) acpi_ut_strchr ((s1), (c))
#define ACPI_STRLEN(s) (acpi_size) acpi_ut_strlen ((s)) #define ACPI_STRLEN(s) (acpi_size) acpi_ut_strlen ((s))
...@@ -322,59 +390,4 @@ typedef char *va_list; ...@@ -322,59 +390,4 @@ typedef char *va_list;
#endif /* ACPI_USE_SYSTEM_CLIBRARY */ #endif /* ACPI_USE_SYSTEM_CLIBRARY */
/******************************************************************************
*
* Assembly code macros
*
*****************************************************************************/
/*
* Handle platform- and compiler-specific assembly language differences.
* These should already have been defined by the platform includes above.
*
* Notes:
* 1) Interrupt 3 is used to break into a debugger
* 2) Interrupts are turned off during ACPI register setup
*/
/* Unrecognized compiler, use defaults */
#ifndef ACPI_ASM_MACROS
/*
* Calling conventions:
*
* ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
* ACPI_EXTERNAL_XFACE - External ACPI interfaces
* ACPI_INTERNAL_XFACE - Internal ACPI interfaces
* ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
*/
#define ACPI_SYSTEM_XFACE
#define ACPI_EXTERNAL_XFACE
#define ACPI_INTERNAL_XFACE
#define ACPI_INTERNAL_VAR_XFACE
#define ACPI_ASM_MACROS
#define BREAKPOINT3
#define ACPI_DISABLE_IRQS()
#define ACPI_ENABLE_IRQS()
#define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acq)
#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, acq)
#endif /* ACPI_ASM_MACROS */
#ifdef ACPI_APPLICATION
/* Don't want software interrupts within a ring3 application */
#undef BREAKPOINT3
#define BREAKPOINT3
#endif
/******************************************************************************
*
* Compiler-specific information is contained in the compiler-specific
* headers.
*
*****************************************************************************/
#endif /* __ACENV_H__ */ #endif /* __ACENV_H__ */
...@@ -64,8 +64,4 @@ ...@@ -64,8 +64,4 @@
*/ */
#define ACPI_UNUSED_VAR __attribute__ ((unused)) #define ACPI_UNUSED_VAR __attribute__ ((unused))
#ifdef _ANSI
#define inline
#endif
#endif /* __ACGCC_H__ */ #endif /* __ACGCC_H__ */
...@@ -108,7 +108,6 @@ ...@@ -108,7 +108,6 @@
#include <acpi/platform/acgcc.h> #include <acpi/platform/acgcc.h>
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <acpi/actypes.h> #include <acpi/actypes.h>
/* /*
......
...@@ -74,9 +74,10 @@ enum acpi_address_range_id { ...@@ -74,9 +74,10 @@ enum acpi_address_range_id {
/* Table Handlers */ /* Table Handlers */
typedef int (*acpi_table_handler) (struct acpi_table_header *table); typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *table);
typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, const unsigned long end); typedef int (*acpi_tbl_entry_handler)(struct acpi_subtable_header *header,
const unsigned long end);
#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE #ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
void acpi_initrd_override(void *data, size_t size); void acpi_initrd_override(void *data, size_t size);
...@@ -95,10 +96,14 @@ int acpi_mps_check (void); ...@@ -95,10 +96,14 @@ int acpi_mps_check (void);
int acpi_numa_init (void); int acpi_numa_init (void);
int acpi_table_init (void); int acpi_table_init (void);
int acpi_table_parse (char *id, acpi_table_handler handler); int acpi_table_parse(char *id, acpi_tbl_table_handler handler);
int __init acpi_table_parse_entries(char *id, unsigned long table_size, int __init acpi_table_parse_entries(char *id, unsigned long table_size,
int entry_id, acpi_table_entry_handler handler, unsigned int max_entries); int entry_id,
int acpi_table_parse_madt (enum acpi_madt_type id, acpi_table_entry_handler handler, unsigned int max_entries); acpi_tbl_entry_handler handler,
unsigned int max_entries);
int acpi_table_parse_madt(enum acpi_madt_type id,
acpi_tbl_entry_handler handler,
unsigned int max_entries);
int acpi_parse_mcfg (struct acpi_table_header *header); int acpi_parse_mcfg (struct acpi_table_header *header);
void acpi_table_print_madt_entry (struct acpi_subtable_header *madt); void acpi_table_print_madt_entry (struct acpi_subtable_header *madt);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册