Commit c5fc42ac authored by Bob Moore's avatar Bob Moore Committed by Len Brown

ACPICA: misc fixes for new Table Manager:

Signed-off-by: default avatarAlexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent f3d2e786
...@@ -61,7 +61,7 @@ ACPI_MODULE_NAME("tbinstal") ...@@ -61,7 +61,7 @@ ACPI_MODULE_NAME("tbinstal")
*****************************************************************************/ *****************************************************************************/
acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc) acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc)
{ {
u8 checksum; acpi_status status;
ACPI_FUNCTION_TRACE(tb_verify_table); ACPI_FUNCTION_TRACE(tb_verify_table);
...@@ -84,17 +84,9 @@ acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc) ...@@ -84,17 +84,9 @@ acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc)
/* Always calculate checksum, ignore bad checksum if requested */ /* Always calculate checksum, ignore bad checksum if requested */
checksum = acpi_tb_checksum(ACPI_CAST_PTR(void, table_desc->pointer), status =
table_desc->length); acpi_tb_verify_checksum(table_desc->pointer, table_desc->length);
return_ACPI_STATUS(status);
#if (ACPI_CHECKSUM_ABORT)
if (checksum) {
return_ACPI_STATUS(AE_BAD_CHECKSUM);
}
#endif
return_ACPI_STATUS(AE_OK);
} }
/******************************************************************************* /*******************************************************************************
...@@ -188,7 +180,7 @@ acpi_status acpi_tb_resize_root_table_list(void) ...@@ -188,7 +180,7 @@ acpi_status acpi_tb_resize_root_table_list(void)
/* allow_resize flag is a parameter to acpi_initialize_tables */ /* allow_resize flag is a parameter to acpi_initialize_tables */
if (!(acpi_gbl_root_table_list.flags & ACPI_TABLE_FLAGS_ALLOW_RESIZE)) { if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
ACPI_ERROR((AE_INFO, ACPI_ERROR((AE_INFO,
"Resize of Root Table Array is not allowed")); "Resize of Root Table Array is not allowed"));
return_ACPI_STATUS(AE_SUPPORT); return_ACPI_STATUS(AE_SUPPORT);
...@@ -212,18 +204,14 @@ acpi_status acpi_tb_resize_root_table_list(void) ...@@ -212,18 +204,14 @@ acpi_status acpi_tb_resize_root_table_list(void)
acpi_gbl_root_table_list.size * acpi_gbl_root_table_list.size *
sizeof(struct acpi_table_desc)); sizeof(struct acpi_table_desc));
if (acpi_gbl_root_table_list.flags & ACPI_TABLE_ORIGIN_MASK == if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
ACPI_TABLE_ORIGIN_ALLOCATED) {
ACPI_FREE(acpi_gbl_root_table_list.tables); ACPI_FREE(acpi_gbl_root_table_list.tables);
} }
} }
acpi_gbl_root_table_list.tables = tables; acpi_gbl_root_table_list.tables = tables;
acpi_gbl_root_table_list.size += ACPI_ROOT_TABLE_SIZE_INCREMENT; acpi_gbl_root_table_list.size += ACPI_ROOT_TABLE_SIZE_INCREMENT;
acpi_gbl_root_table_list.flags = (u8) (ACPI_TABLE_ORIGIN_ALLOCATED | acpi_gbl_root_table_list.flags |= (u8) ACPI_ROOT_ORIGIN_ALLOCATED;
(acpi_gbl_root_table_list.
flags &
~ACPI_TABLE_ORIGIN_MASK));
return_ACPI_STATUS(AE_OK); return_ACPI_STATUS(AE_OK);
} }
...@@ -348,8 +336,7 @@ void acpi_tb_terminate(void) ...@@ -348,8 +336,7 @@ void acpi_tb_terminate(void)
* Delete the root table array if allocated locally. Array cannot be * Delete the root table array if allocated locally. Array cannot be
* mapped, so we don't need to check for that flag. * mapped, so we don't need to check for that flag.
*/ */
if ((acpi_gbl_root_table_list.flags & ACPI_TABLE_ORIGIN_MASK) == if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
ACPI_TABLE_ORIGIN_ALLOCATED) {
ACPI_FREE(acpi_gbl_root_table_list.tables); ACPI_FREE(acpi_gbl_root_table_list.tables);
} }
...@@ -497,7 +484,7 @@ u8 acpi_tb_is_table_loaded(acpi_native_uint table_index) ...@@ -497,7 +484,7 @@ u8 acpi_tb_is_table_loaded(acpi_native_uint table_index)
if (table_index < acpi_gbl_root_table_list.count) { if (table_index < acpi_gbl_root_table_list.count) {
is_loaded = (u8) is_loaded = (u8)
(acpi_gbl_root_table_list.tables[table_index]. (acpi_gbl_root_table_list.tables[table_index].
flags & ACPI_TABLE_FLAGS_LOADED); flags & ACPI_TABLE_IS_LOADED);
} }
(void)acpi_ut_release_mutex(ACPI_MTX_TABLES); (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
...@@ -524,10 +511,10 @@ void acpi_tb_set_table_loaded_flag(acpi_native_uint table_index, u8 is_loaded) ...@@ -524,10 +511,10 @@ void acpi_tb_set_table_loaded_flag(acpi_native_uint table_index, u8 is_loaded)
if (table_index < acpi_gbl_root_table_list.count) { if (table_index < acpi_gbl_root_table_list.count) {
if (is_loaded) { if (is_loaded) {
acpi_gbl_root_table_list.tables[table_index].flags |= acpi_gbl_root_table_list.tables[table_index].flags |=
ACPI_TABLE_FLAGS_LOADED; ACPI_TABLE_IS_LOADED;
} else { } else {
acpi_gbl_root_table_list.tables[table_index].flags &= acpi_gbl_root_table_list.tables[table_index].flags &=
~ACPI_TABLE_FLAGS_LOADED; ~ACPI_TABLE_IS_LOADED;
} }
} }
......
This diff is collapsed.
...@@ -82,9 +82,8 @@ acpi_status ...@@ -82,9 +82,8 @@ acpi_status
acpi_initialize_tables(struct acpi_table_desc *initial_table_array, acpi_initialize_tables(struct acpi_table_desc *initial_table_array,
u32 initial_table_count, u8 allow_resize) u32 initial_table_count, u8 allow_resize)
{ {
acpi_physical_address address; acpi_physical_address rsdp_address;
acpi_status status; acpi_status status;
struct acpi_table_rsdp *rsdp;
ACPI_FUNCTION_TRACE(acpi_initialize_tables); ACPI_FUNCTION_TRACE(acpi_initialize_tables);
...@@ -94,7 +93,7 @@ acpi_initialize_tables(struct acpi_table_desc *initial_table_array, ...@@ -94,7 +93,7 @@ acpi_initialize_tables(struct acpi_table_desc *initial_table_array,
*/ */
if (!initial_table_array) { if (!initial_table_array) {
acpi_gbl_root_table_list.size = initial_table_count; acpi_gbl_root_table_list.size = initial_table_count;
acpi_gbl_root_table_list.flags = ACPI_TABLE_FLAGS_ALLOW_RESIZE; acpi_gbl_root_table_list.flags = ACPI_ROOT_ALLOW_RESIZE;
status = acpi_tb_resize_root_table_list(); status = acpi_tb_resize_root_table_list();
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
...@@ -103,37 +102,33 @@ acpi_initialize_tables(struct acpi_table_desc *initial_table_array, ...@@ -103,37 +102,33 @@ acpi_initialize_tables(struct acpi_table_desc *initial_table_array,
} else { } else {
/* Root Table Array has been statically allocated by the host */ /* Root Table Array has been statically allocated by the host */
ACPI_MEMSET(initial_table_array,
initial_table_count *
sizeof(struct acpi_table_desc), 0);
acpi_gbl_root_table_list.tables = initial_table_array; acpi_gbl_root_table_list.tables = initial_table_array;
acpi_gbl_root_table_list.size = initial_table_count; acpi_gbl_root_table_list.size = initial_table_count;
acpi_gbl_root_table_list.flags = ACPI_TABLE_ORIGIN_UNKNOWN; acpi_gbl_root_table_list.flags = ACPI_ROOT_ORIGIN_UNKNOWN;
if (allow_resize) { if (allow_resize) {
acpi_gbl_root_table_list.flags = acpi_gbl_root_table_list.flags |=
ACPI_TABLE_FLAGS_ALLOW_RESIZE; ACPI_ROOT_ALLOW_RESIZE;
} }
} }
/* Get the RSDP and map it */ /* Get the address of the RSDP */
address = acpi_os_get_root_pointer(); rsdp_address = acpi_os_get_root_pointer();
if (!address) { if (!rsdp_address) {
return_ACPI_STATUS(AE_NOT_FOUND); return_ACPI_STATUS(AE_NOT_FOUND);
} }
rsdp = acpi_os_map_memory(address, sizeof(struct acpi_table_rsdp));
if (!rsdp) {
return_ACPI_STATUS(AE_NO_MEMORY);
}
ACPI_INFO((AE_INFO, "%.8s @ 0x%p",
rsdp->signature, ACPI_CAST_PTR(void, address)));
/* /*
* Get the root table (RSDT or XSDT) and extract all entries to the local * Get the root table (RSDT or XSDT) and extract all entries to the local
* Root Table Array. This array contains the information of the RSDT/XSDT * Root Table Array. This array contains the information of the RSDT/XSDT
* in a common, more useable format. * in a common, more useable format.
*/ */
status = acpi_tb_parse_root_table(rsdp, ACPI_TABLE_ORIGIN_MAPPED); status =
acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp)); acpi_tb_parse_root_table(rsdp_address, ACPI_TABLE_ORIGIN_MAPPED);
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }
...@@ -164,8 +159,7 @@ acpi_status acpi_reallocate_root_table(void) ...@@ -164,8 +159,7 @@ acpi_status acpi_reallocate_root_table(void)
* Only reallocate the root table if the host provided a static buffer * Only reallocate the root table if the host provided a static buffer
* for the table array in the call to acpi_initialize_tables. * for the table array in the call to acpi_initialize_tables.
*/ */
if ((acpi_gbl_root_table_list.flags & ACPI_TABLE_ORIGIN_MASK) != if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
ACPI_TABLE_ORIGIN_UNKNOWN) {
return_ACPI_STATUS(AE_SUPPORT); return_ACPI_STATUS(AE_SUPPORT);
} }
...@@ -185,7 +179,7 @@ acpi_status acpi_reallocate_root_table(void) ...@@ -185,7 +179,7 @@ acpi_status acpi_reallocate_root_table(void)
acpi_gbl_root_table_list.size = acpi_gbl_root_table_list.count; acpi_gbl_root_table_list.size = acpi_gbl_root_table_list.count;
acpi_gbl_root_table_list.tables = tables; acpi_gbl_root_table_list.tables = tables;
acpi_gbl_root_table_list.flags = acpi_gbl_root_table_list.flags =
ACPI_TABLE_ORIGIN_ALLOCATED | ACPI_TABLE_FLAGS_ALLOW_RESIZE; ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
return_ACPI_STATUS(AE_OK); return_ACPI_STATUS(AE_OK);
} }
...@@ -247,6 +241,12 @@ acpi_get_table_header(char *signature, ...@@ -247,6 +241,12 @@ acpi_get_table_header(char *signature,
acpi_native_uint i; acpi_native_uint i;
acpi_native_uint j; acpi_native_uint j;
/* Parameter validation */
if (!signature || !out_table_header) {
return (AE_BAD_PARAMETER);
}
/* /*
* Walk the root table list * Walk the root table list
*/ */
...@@ -267,7 +267,7 @@ acpi_get_table_header(char *signature, ...@@ -267,7 +267,7 @@ acpi_get_table_header(char *signature,
acpi_gbl_root_table_list.tables[i]. acpi_gbl_root_table_list.tables[i].
flags & ACPI_TABLE_ORIGIN_MASK); flags & ACPI_TABLE_ORIGIN_MASK);
if (!out_table_header) { if (!(*out_table_header)) {
return (AE_NO_MEMORY); return (AE_NO_MEMORY);
} }
...@@ -339,6 +339,12 @@ acpi_get_table(char *signature, ...@@ -339,6 +339,12 @@ acpi_get_table(char *signature,
acpi_native_uint j; acpi_native_uint j;
acpi_status status; acpi_status status;
/* Parameter validation */
if (!signature || !out_table) {
return (AE_BAD_PARAMETER);
}
/* /*
* Walk the root table list * Walk the root table list
*/ */
...@@ -387,6 +393,12 @@ acpi_get_table_by_index(acpi_native_uint table_index, ...@@ -387,6 +393,12 @@ acpi_get_table_by_index(acpi_native_uint table_index,
ACPI_FUNCTION_TRACE(acpi_get_table_by_index); ACPI_FUNCTION_TRACE(acpi_get_table_by_index);
/* Parameter validation */
if (!table) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
/* Validate index */ /* Validate index */
......
...@@ -996,9 +996,13 @@ acpi_ut_info(char *module_name, u32 line_number, char *format, ...) ...@@ -996,9 +996,13 @@ acpi_ut_info(char *module_name, u32 line_number, char *format, ...)
{ {
va_list args; va_list args;
acpi_os_printf("ACPI (%s-%04d): ", module_name, line_number); /*
* Removed module_name, line_number, and acpica version, not needed
* for info output
*/
acpi_os_printf("ACPI: ");
va_start(args, format); va_start(args, format);
acpi_os_vprintf(format, args); acpi_os_vprintf(format, args);
acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); acpi_os_printf("\n");
} }
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
/* Current ACPICA subsystem version in YYYYMMDD format */ /* Current ACPICA subsystem version in YYYYMMDD format */
#define ACPI_CA_VERSION 0x20060823 #define ACPI_CA_VERSION 0x20060828
/* /*
* OS name, used for the _OS object. The _OS object is essentially obsolete, * OS name, used for the _OS object. The _OS object is essentially obsolete,
......
...@@ -227,6 +227,16 @@ struct acpi_table_desc { ...@@ -227,6 +227,16 @@ struct acpi_table_desc {
u8 flags; u8 flags;
}; };
/* Flags for above */
#define ACPI_TABLE_ORIGIN_UNKNOWN (0)
#define ACPI_TABLE_ORIGIN_MAPPED (1)
#define ACPI_TABLE_ORIGIN_ALLOCATED (2)
#define ACPI_TABLE_ORIGIN_MASK (3)
#define ACPI_TABLE_IS_LOADED (4)
/* One internal RSDT for table management */
struct acpi_internal_rsdt { struct acpi_internal_rsdt {
struct acpi_table_desc *tables; struct acpi_table_desc *tables;
u32 count; u32 count;
...@@ -234,14 +244,11 @@ struct acpi_internal_rsdt { ...@@ -234,14 +244,11 @@ struct acpi_internal_rsdt {
u8 flags; u8 flags;
}; };
/* Flags for both structs above */ /* Flags for above */
#define ACPI_TABLE_ORIGIN_UNKNOWN (0) #define ACPI_ROOT_ORIGIN_UNKNOWN (0) /* ~ORIGIN_ALLOCATED */
#define ACPI_TABLE_ORIGIN_MAPPED (1) #define ACPI_ROOT_ORIGIN_ALLOCATED (1)
#define ACPI_TABLE_ORIGIN_ALLOCATED (2) #define ACPI_ROOT_ALLOW_RESIZE (2)
#define ACPI_TABLE_ORIGIN_MASK (3)
#define ACPI_TABLE_FLAGS_LOADED (4)
#define ACPI_TABLE_FLAGS_ALLOW_RESIZE (8)
/* Predefined (fixed) table indexes */ /* Predefined (fixed) table indexes */
......
...@@ -94,9 +94,11 @@ acpi_tb_print_table_header(acpi_physical_address address, ...@@ -94,9 +94,11 @@ acpi_tb_print_table_header(acpi_physical_address address,
u8 acpi_tb_checksum(u8 * buffer, acpi_native_uint length); u8 acpi_tb_checksum(u8 * buffer, acpi_native_uint length);
void acpi_tb_convert_fadt(struct acpi_table_fadt *fadt); acpi_status
acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length);
acpi_status acpi_tb_parse_root_table(struct acpi_table_rsdp *rsdp, u8 flags); acpi_status
acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags);
void *acpi_tb_map(acpi_physical_address address, u32 length, u32 flags); void *acpi_tb_map(acpi_physical_address address, u32 length, u32 flags);
......
...@@ -199,8 +199,8 @@ struct acpi_table_fadt { ...@@ -199,8 +199,8 @@ struct acpi_table_fadt {
u32 pm1b_control_block; /* Port address of Power Mgt 1b Control Reg Blk */ u32 pm1b_control_block; /* Port address of Power Mgt 1b Control Reg Blk */
u32 pm2_control_block; /* Port address of Power Mgt 2 Control Reg Blk */ u32 pm2_control_block; /* Port address of Power Mgt 2 Control Reg Blk */
u32 pm_timer_block; /* Port address of Power Mgt Timer Ctrl Reg Blk */ u32 pm_timer_block; /* Port address of Power Mgt Timer Ctrl Reg Blk */
u32 gpe0_block; /* Port addr of General Purpose acpi_event 0 Reg Blk */ u32 gpe0_block; /* Port addr of General Purpose Event 0 Reg Blk */
u32 gpe1_block; /* Port addr of General Purpose acpi_event 1 Reg Blk */ u32 gpe1_block; /* Port addr of General Purpose Event 1 Reg Blk */
u8 pm1_event_length; /* Byte Length of ports at pm1_x_evt_blk */ u8 pm1_event_length; /* Byte Length of ports at pm1_x_evt_blk */
u8 pm1_control_length; /* Byte Length of ports at pm1_x_cnt_blk */ u8 pm1_control_length; /* Byte Length of ports at pm1_x_cnt_blk */
u8 pm2_control_length; /* Byte Length of ports at pm2_cnt_blk */ u8 pm2_control_length; /* Byte Length of ports at pm2_cnt_blk */
...@@ -226,14 +226,14 @@ struct acpi_table_fadt { ...@@ -226,14 +226,14 @@ struct acpi_table_fadt {
u8 reserved4[3]; /* These three bytes must be zero */ u8 reserved4[3]; /* These three bytes must be zero */
u64 Xfacs; /* 64-bit physical address of FACS */ u64 Xfacs; /* 64-bit physical address of FACS */
u64 Xdsdt; /* 64-bit physical address of DSDT */ u64 Xdsdt; /* 64-bit physical address of DSDT */
struct acpi_generic_address xpm1a_event_block; /* Extended Power Mgt 1a acpi_event Reg Blk address */ struct acpi_generic_address xpm1a_event_block; /* Extended Power Mgt 1a Event Reg Blk address */
struct acpi_generic_address xpm1b_event_block; /* Extended Power Mgt 1b acpi_event Reg Blk address */ struct acpi_generic_address xpm1b_event_block; /* Extended Power Mgt 1b Event Reg Blk address */
struct acpi_generic_address xpm1a_control_block; /* Extended Power Mgt 1a Control Reg Blk address */ struct acpi_generic_address xpm1a_control_block; /* Extended Power Mgt 1a Control Reg Blk address */
struct acpi_generic_address xpm1b_control_block; /* Extended Power Mgt 1b Control Reg Blk address */ struct acpi_generic_address xpm1b_control_block; /* Extended Power Mgt 1b Control Reg Blk address */
struct acpi_generic_address xpm2_control_block; /* Extended Power Mgt 2 Control Reg Blk address */ struct acpi_generic_address xpm2_control_block; /* Extended Power Mgt 2 Control Reg Blk address */
struct acpi_generic_address xpm_timer_block; /* Extended Power Mgt Timer Ctrl Reg Blk address */ struct acpi_generic_address xpm_timer_block; /* Extended Power Mgt Timer Ctrl Reg Blk address */
struct acpi_generic_address xgpe0_block; /* Extended General Purpose acpi_event 0 Reg Blk address */ struct acpi_generic_address xgpe0_block; /* Extended General Purpose Event 0 Reg Blk address */
struct acpi_generic_address xgpe1_block; /* Extended General Purpose acpi_event 1 Reg Blk address */ struct acpi_generic_address xgpe1_block; /* Extended General Purpose Event 1 Reg Blk address */
}; };
/* FADT flags */ /* FADT flags */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment