[tables] Redefine methods for accessing linker tables

Intel's C compiler (icc) chokes on the zero-length arrays that we
currently use as part of the mechanism for accessing linker table
entries.  Abstract away the zero-length arrays, to make a port to icc
easier.

Introduce macros such as for_each_table_entry() to simplify the common
case of iterating over all entries in a linker table.

Represent table names as #defined string constants rather than
unquoted literals; this avoids visual confusion between table names
and C variable or type names, and also allows us to force a
compilation error in the event of incorrect table names.
This commit is contained in:
Michael Brown
2009-03-12 19:41:40 +00:00
parent 3ed468e0c5
commit 1266d7902b
48 changed files with 239 additions and 264 deletions

View File

@@ -26,18 +26,6 @@ EFI_HANDLE efi_image_handle;
/** System table passed to entry point */
EFI_SYSTEM_TABLE *efi_systab;
/** Declared used EFI protocols */
static struct efi_protocol efi_protocols[0] \
__table_start ( struct efi_protocol, efi_protocols );
static struct efi_protocol efi_protocols_end[0] \
__table_end ( struct efi_protocol, efi_protocols );
/** Declared used EFI configuration tables */
static struct efi_config_table efi_config_tables[0] \
__table_start ( struct efi_config_table, efi_config_tables );
static struct efi_config_table efi_config_tables_end[0] \
__table_end ( struct efi_config_table, efi_config_tables );
/**
* Look up EFI configuration table
*
@@ -92,7 +80,7 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle,
/* Look up used protocols */
bs = systab->BootServices;
for ( prot = efi_protocols ; prot < efi_protocols_end ; prot++ ) {
for_each_table_entry ( prot, EFI_PROTOCOLS ) {
if ( ( efirc = bs->LocateProtocol ( &prot->u.guid, NULL,
prot->protocol ) ) == 0 ) {
DBGC ( systab, "EFI protocol %s is at %p\n",
@@ -106,7 +94,7 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle,
}
/* Look up used configuration tables */
for ( tab = efi_config_tables ; tab < efi_config_tables_end ; tab++ ) {
for_each_table_entry ( tab, EFI_CONFIG_TABLES ) {
if ( ( *(tab->table) = efi_find_table ( &tab->u.guid ) ) ) {
DBGC ( systab, "EFI configuration table %s is at %p\n",
uuid_ntoa ( &tab->u.uuid ), *(tab->table) );