diff -ur memtest86-3.5.orig/Makefile memtest86-3.5/Makefile --- memtest86-3.5.orig/Makefile 2009-01-06 07:03:23.000000000 +0100 +++ memtest86-3.5/Makefile 2010-01-23 16:13:09.000000000 +0100 @@ -8,13 +8,15 @@ # FDISK=/dev/fd0 -AS=as -32 -CC=gcc +AS=$(CROSS)as -32 +CC=$(CROSS)gcc +LD=$(CROSS)ld +OBJCOPY=$(CROSS)objcopy CFLAGS= -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin -ffreestanding -fPIC $(SMP_FL) OBJS= head.o reloc.o main.o test.o init.o lib.o patn.o screen_buffer.o \ - config.o linuxbios.o memsize.o pci.o controller.o random.o extra.o \ + config.o coreboot.o memsize.o pci.o controller.o random.o extra.o \ spd.o error.o dmi.o smp.o cpuid.o all: clean memtest.bin memtest @@ -31,22 +33,22 @@ $(LD) -shared -Bsymbolic -T memtest_shared.lds -o $@ $(OBJS) memtest_shared.bin: memtest_shared - objcopy -O binary $< memtest_shared.bin + $(OBJCOPY) -O binary $< memtest_shared.bin memtest: memtest_shared.bin memtest.lds $(LD) -s -T memtest.lds -b binary memtest_shared.bin -o $@ -head.s: head.S config.h defs.h test.h +head.pre.s: head.S config.h defs.h test.h $(CC) -E -traditional $< -o $@ -bootsect.s: bootsect.S config.h defs.h +bootsect.pre.s: bootsect.S config.h defs.h $(CC) -E -traditional $< -o $@ -setup.s: setup.S config.h defs.h +setup.pre.s: setup.S config.h defs.h $(CC) -E -traditional $< -o $@ -memtest.bin: memtest_shared.bin bootsect.o setup.o memtest.bin.lds - $(LD) -T memtest.bin.lds bootsect.o setup.o -b binary \ +memtest.bin: memtest_shared.bin bootsect.pre.o setup.pre.o memtest.bin.lds + $(LD) -T memtest.bin.lds bootsect.pre.o setup.pre.o -b binary \ memtest_shared.bin -o memtest.bin reloc.o: reloc.c @@ -56,7 +58,7 @@ $(CC) -c -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin -ffreestanding test.c clean: - rm -f *.o *.s *.iso memtest.bin memtest memtest_shared memtest_shared.bin + rm -f *.o *.pre.s *.iso memtest.bin memtest memtest_shared memtest_shared.bin iso: make all diff -ur memtest86-3.5.orig/init.c memtest86-3.5/init.c --- memtest86-3.5.orig/init.c 2009-01-06 07:01:03.000000000 +0100 +++ memtest86-3.5/init.c 2010-01-23 16:12:28.000000000 +0100 @@ -108,8 +108,8 @@ /* Determine the memory map */ if ((firmware == FIRMWARE_UNKNOWN) && (memsz_mode != SZ_MODE_PROBE)) { - if (query_linuxbios()) { - firmware = FIRMWARE_LINUXBIOS; + if (query_coreboot()) { + firmware = FIRMWARE_COREBOOT; } else if (query_pcbios()) { firmware = FIRMWARE_PCBIOS; diff -ur memtest86-3.5.orig/linuxbios.c memtest86-3.5/linuxbios.c --- memtest86-3.5.orig/linuxbios.c 2007-07-17 05:10:08.000000000 +0200 +++ memtest86-3.5/linuxbios.c 2010-01-23 16:24:46.000000000 +0100 @@ -1,10 +1,10 @@ -/* linuxbios.c - MemTest-86 Version 3.3 +/* coreboot.c - MemTest-86 * * Released under version 2 of the Gnu Public License. * By Eric Biederman */ -#include "linuxbios_tables.h" +#include "coreboot_tables.h" #include "test.h" static unsigned long ip_compute_csum(void *addr, unsigned long length) @@ -59,32 +59,32 @@ } -#define for_each_lbrec(head, rec) \ - for(rec = (struct lb_record *)(((char *)head) + sizeof(*head)); \ +#define for_each_cbrec(head, rec) \ + for(rec = (struct cb_record *)(((char *)head) + sizeof(*head)); \ (((char *)rec) < (((char *)head) + sizeof(*head) + head->table_bytes)) && \ (rec->size >= 1) && \ ((((char *)rec) + rec->size) <= (((char *)head) + sizeof(*head) + head->table_bytes)); \ - rec = (struct lb_record *)(((char *)rec) + rec->size)) + rec = (struct cb_record *)(((char *)rec) + rec->size)) -static int count_lb_records(struct lb_header *head) +static int count_cb_records(struct cb_header *head) { - struct lb_record *rec; + struct cb_record *rec; int count; count = 0; - for_each_lbrec(head, rec) { + for_each_cbrec(head, rec) { count++; } return count; } -static struct lb_header * __find_lb_table(unsigned long start, unsigned long end) +static struct cb_header * __find_cb_table(unsigned long start, unsigned long end) { unsigned long addr; /* For now be stupid.... */ for(addr = start; addr < end; addr += 16) { - struct lb_header *head = (struct lb_header *)addr; - struct lb_record *recs = (struct lb_record *)(addr + sizeof(*head)); + struct cb_header *head = (struct cb_header *)addr; + struct cb_record *recs = (struct cb_record *)(addr + sizeof(*head)); if (memcmp(head->signature, "LBIO", 4) != 0) continue; if (head->header_bytes != sizeof(*head)) @@ -94,42 +94,61 @@ if (ip_compute_csum((unsigned char *)recs, head->table_bytes) != head->table_checksum) continue; - if (count_lb_records(head) != head->table_entries) + if (count_cb_records(head) != head->table_entries) continue; return head; }; return 0; } -static struct lb_header * find_lb_table(void) +static struct cb_header * find_cb_table(void) { - struct lb_header *head; + struct cb_header *head; + struct cb_record *rec; + struct cb_forward *forward; head = 0; if (!head) { /* First try at address 0 */ - head = __find_lb_table(0x00000, 0x1000); + head = __find_cb_table(0x00000, 0x1000); } if (!head) { /* Then try at address 0xf0000 */ - head = __find_lb_table(0xf0000, 0x100000); + head = __find_cb_table(0xf0000, 0x100000); } + forward = 0; + if (head) { + /* Check whether there is a forward header */ + for_each_cbrec(head, rec) { + if (rec->tag == CB_TAG_FORWARD) { + forward = (struct cb_forward *)rec; + break; + } + } + } + if (forward) { + /* if there is, all valid information is in the + * referenced coreboot table + */ + head = __find_cb_table(forward->forward, 0x1000); + } + return head; } -int query_linuxbios(void) +int query_coreboot(void) { - struct lb_header *head; - struct lb_record *rec; - struct lb_memory *mem; + struct cb_header *head; + struct cb_record *rec; + struct cb_memory *mem; int i, entries; - head = find_lb_table(); + head = find_cb_table(); if (!head) { return 0; } mem = 0; - for_each_lbrec(head, rec) { - if (rec->tag == LB_TAG_MEMORY) { - mem = (struct lb_memory *)rec; + for_each_cbrec(head, rec) { + if (rec->tag == CB_TAG_MEMORY) { + mem = (struct cb_memory *)rec; break; } } @@ -149,7 +168,7 @@ } start = mem->map[i].start; size = mem->map[i].size; - type = (mem->map[i].type == LB_MEM_RAM)?E820_RAM: E820_RESERVED; + type = (mem->map[i].type == CB_MEM_RAM)?E820_RAM: E820_RESERVED; mem_info.e820[mem_info.e820_nr].addr = start; mem_info.e820[mem_info.e820_nr].size = size; mem_info.e820[mem_info.e820_nr].type = type; diff -ur memtest86-3.5.orig/linuxbios_tables.h memtest86-3.5/linuxbios_tables.h --- memtest86-3.5.orig/linuxbios_tables.h 2007-07-17 05:10:08.000000000 +0200 +++ memtest86-3.5/linuxbios_tables.h 2010-01-23 16:12:28.000000000 +0100 @@ -1,9 +1,9 @@ -#ifndef LINUXBIOS_TABLES_H -#define LINUXBIOS_TABLES_H +#ifndef COREBOOT_TABLES_H +#define COREBOOT_TABLES_H #include "stdint.h" -/* The linuxbios table information is for conveying information +/* The coreboot table information is for conveying information * from the firmware to the loaded OS image. Primarily this * is expected to be information that cannot be discovered by * other means, such as quering the hardware directly. @@ -32,7 +32,7 @@ */ -struct lb_header +struct cb_header { uint8_t signature[4]; /* LBIO */ uint32_t header_bytes; @@ -48,35 +48,39 @@ * boot enviroment record if you don't know what it easy. This allows * forward compatibility with records not yet defined. */ -struct lb_record { +struct cb_record { uint32_t tag; /* tag ID */ uint32_t size; /* size of record (in bytes) */ }; -#define LB_TAG_UNUSED 0x0000 +#define CB_TAG_UNUSED 0x0000 -#define LB_TAG_MEMORY 0x0001 +#define CB_TAG_MEMORY 0x0001 -struct lb_memory_range { +struct cb_memory_range { uint64_t start; uint64_t size; uint32_t type; -#define LB_MEM_RAM 1 -#define LB_MEM_RESERVED 2 - +#define CB_MEM_RAM 1 /* Memory anyone can use */ +#define CB_MEM_RESERVED 2 /* Don't use this memory region */ +#define CB_MEM_ACPI 3 /* ACPI Tables */ +#define CB_MEM_NVS 4 /* ACPI NVS Memory */ +#define CB_MEM_UNUSABLE 5 /* Unusable address space */ +#define CB_MEM_VENDOR_RSVD 6 /* Vendor Reserved */ +#define CB_MEM_TABLE 16 /* Ram configuration tables are kept in */ }; -struct lb_memory { +struct cb_memory { uint32_t tag; uint32_t size; - struct lb_memory_range map[0]; + struct cb_memory_range map[0]; }; -#define LB_TAG_HWRPB 0x0002 -struct lb_hwrpb { +#define CB_TAG_FORWARD 0x0011 +struct cb_forward { uint32_t tag; uint32_t size; - uint64_t hwrpb; + uint64_t forward; }; -#endif /* LINUXBIOS_TABLES_H */ +#endif /* COREBOOT_TABLES_H */ diff -ur memtest86-3.5.orig/memsize.c memtest86-3.5/memsize.c --- memtest86-3.5.orig/memsize.c 2009-01-01 23:02:10.000000000 +0100 +++ memtest86-3.5/memsize.c 2010-01-23 16:17:04.000000000 +0100 @@ -26,7 +26,7 @@ static void memsize_801(void); static int sanitize_e820_map(struct e820entry *orig_map, struct e820entry *new_bios, short old_nr); -static void memsize_linuxbios(); +static void memsize_coreboot(void); static void memsize_probe(void); static int check_ram(void); @@ -78,8 +78,8 @@ if (firmware == FIRMWARE_PCBIOS) { memsize_820(); } - else if (firmware == FIRMWARE_LINUXBIOS) { - memsize_linuxbios(); + else if (firmware == FIRMWARE_COREBOOT) { + memsize_coreboot(); } } @@ -107,7 +107,7 @@ } } } -static void memsize_linuxbios(void) +static void memsize_coreboot(void) { int i, n; /* Build the memory map for testing */ @@ -125,7 +125,7 @@ n++; } v->msegs = n; - cprint(LINE_INFO+1, COL_INF1-6, "LxBIOS"); + cprint(LINE_INFO+1, COL_INF1-6, "corebt"); } static void memsize_820() { diff -ur memtest86-3.5.orig/test.h memtest86-3.5/test.h --- memtest86-3.5.orig/test.h 2009-01-02 00:21:32.000000000 +0100 +++ memtest86-3.5/test.h 2010-01-23 16:16:29.000000000 +0100 @@ -96,7 +96,7 @@ int memcmp(const void *s1, const void *s2, ulong count); void *memmove(void *dest, const void *src, ulong n); int strncmp(const char *s1, const char *s2, ulong n); -int query_linuxbios(void); +int query_coreboot(void); int query_pcbios(void); int insertaddress(ulong); void printpatn(void); @@ -298,7 +298,7 @@ #define FIRMWARE_UNKNOWN 0 #define FIRMWARE_PCBIOS 1 -#define FIRMWARE_LINUXBIOS 2 +#define FIRMWARE_COREBOOT 2 extern struct vars * const v; extern unsigned char _start[], _end[], startup_32[];