From 9fc3341bd5a5dcfeb4980b75eed2a743c604b638 Mon Sep 17 00:00:00 2001 From: Jacob Pan Date: Thu, 7 Oct 2010 14:12:39 -0700 Subject: SFI: fix table alignment SFI spec does not require any dword alignment of its tables other than SYST base table. IA FW may produce byte aligned mmap table that the current code cannot handle. Also added __packed attribute for sfi structures. Signed-off-by: Jacob Pan --- bootstub.c | 2 +- sfi.c | 7 ++++--- sfi.h | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/bootstub.c b/bootstub.c index f003113..bb5a3c8 100644 --- a/bootstub.c +++ b/bootstub.c @@ -182,7 +182,7 @@ int bootstub(void) setup_idt(); setup_gdt(); setup_spi(); - bs_printk("Bootstub Version: 0.9 ...\n"); + bs_printk("Bootstub Version: 1.0 ...\n"); setup_boot_params((struct boot_params *)BOOT_PARAMS_OFFSET, (struct setup_header *)SETUP_HEADER_OFFSET); bs_printk("Jump to kernel 32bit entry ...\n"); diff --git a/sfi.c b/sfi.c index 5834c5a..1b75c9e 100644 --- a/sfi.c +++ b/sfi.c @@ -33,7 +33,7 @@ static unsigned long sfi_search_mmap(unsigned long start, int len) unsigned long i = 0; char *pchar = (char *)start; - for (i = 0; i < len; i += 4, pchar += 4) { + for (i = 0; i < len; i++, pchar++) { if (pchar[0] == 'M' && pchar[1] == 'M' && pchar[2] == 'A' @@ -55,9 +55,10 @@ void sfi_setup_e820(struct boot_params *bp) /* search for sfi mmap table */ sb = (struct sfi_table *)sfi_search_mmap(SFI_BASE_ADDR, SFI_LENGTH); - if (!sb) + if (!sb) { + bs_printk("Bootstub: failed to locate SFI MMAP table\n"); return; - + } bs_printk("Bootstub: will use sfi mmap table for e820 table\n"); num = SFI_GET_ENTRY_NUM(sb, sfi_mem_entry); mentry = (struct sfi_mem_entry *)sb->pentry; diff --git a/sfi.h b/sfi.h index f190f96..019cc96 100644 --- a/sfi.h +++ b/sfi.h @@ -26,7 +26,7 @@ struct sfi_mem_entry { u64 vir_start; u64 pages; u64 attrib; -}; +}__attribute__((packed)); struct sfi_table_header { char signature[4]; @@ -35,12 +35,12 @@ struct sfi_table_header { u8 checksum; char oem_id[6]; char oem_table_id[8]; -}; +}__attribute__((packed)); struct sfi_table { struct sfi_table_header header; u64 pentry[1]; -}; +}__attribute__((packed)); #define SFI_TBL_HEADER_LEN 24 -- cgit v1.2.3