For my support guys I have adapted memtest86 so that it works as an
elf boot image, rather than relying on the x86 bios. Since linuxBIOS
can how handle elf images, and verifing if memory is setup correctly
are common task when bringing up a board I thought this might be
useful.
memtest86 can be obtained from:
http://reality.sgi.com/cbrady/memtest86/
diff -uNr --exclude=*~ memtest86-2.5/Makefile memtest86-2.5.eb1/Makefile
--- memtest86-2.5/Makefile Thu Sep 21 17:39:19 2000
+++ memtest86-2.5.eb1/Makefile Wed Mar 21 21:44:37 2001
@@ -43,6 +43,9 @@
memtest.bin: setup bootsect head.out relo.out build
./build bootsect setup head.out relo.out >memtest.bin
+memtest86.ebi: head.obj relo.obj memtest86.lds
+ ld -T memtest86.lds head.obj relo.obj -o $@
+
test.o: test.c test.h defs.h config.h
$(CC) -c $(CCFLAGS) test.c
@@ -69,12 +72,16 @@
$(OBJCOPY) relo relo.out; \
fi
+relo.obj: relo.out
+ ld -r -o $@ -T relo.lds -b binary $^
+
head.o: head.s
as -o $@ $<
head: $(OBJS)
ld -m elf_i386 -o $@ -e do_test -Ttext $(TXT_ADR) -Tdata $(DAT_ADR) \
-Map mapfile $(OBJS)
+
head.out: head
if hash encaps 2> /dev/null; then \
$(OBJDUMP) -o $(TXT_ADR) head >head.out; \
@@ -82,6 +89,9 @@
$(OBJCOPY) head head.out; \
fi
+head.obj: head.out
+ ld -r -o $@ -T head.lds -b binary $^
+
head.s: head.S test.h
$(CC) -E -traditional $< -o $@
@@ -108,7 +118,7 @@
clean:
rm -f *.o *.s build memtest.bin bootsect setup head head.out mapfile relo \
- relo.out mapfile.relo
+ relo.out mapfile.relo memtest86.ebi *.obj
install: all
dd <memtest.bin >$(FDISK) bs=8192
Binary files memtest86-2.5/core and memtest86-2.5.eb1/core differ
diff -uNr --exclude=*~ memtest86-2.5/defs.h memtest86-2.5.eb1/defs.h
--- memtest86-2.5/defs.h Thu Sep 21 17:39:16 2000
+++ memtest86-2.5.eb1/defs.h Wed Mar 21 21:42:05 2001
@@ -8,7 +8,7 @@
/*
* Caution!! Do not change TESTADR, MAINSZ, TESTSZ or RELOBASE without also
- * editing the Makefile.
+ * editing the Makefile & memtest86.lds.
*/
#define TESTADR 0x1000 /* Final adrs for the test code */
#define MAINSZ 0x8800 /* Size of primary test code */
diff -uNr --exclude=*~ memtest86-2.5/head.S memtest86-2.5.eb1/head.S
--- memtest86-2.5/head.S Thu Sep 21 16:48:25 2000
+++ memtest86-2.5.eb1/head.S Wed Mar 21 21:56:03 2001
@@ -59,12 +59,6 @@
cld
cli
- movl $(KERNEL_DS),%eax
- mov %ax,%ds
- mov %ax,%es
- mov %ax,%fs
- mov %ax,%gs
- mov %ax,%ss
mov $(TESTADR),%esp
/*
* start system 32-bit setup. We need to re-do some of the things done
diff -uNr --exclude=*~ memtest86-2.5/head.lds memtest86-2.5.eb1/head.lds
--- memtest86-2.5/head.lds Wed Dec 31 17:00:00 1969
+++ memtest86-2.5.eb1/head.lds Wed Mar 21 21:30:04 2001
@@ -0,0 +1,5 @@
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+SECTIONS {
+ .head : { *(*) }
+}
Binary files memtest86-2.5/memtest.binq and memtest86-2.5.eb1/memtest.binq differ
diff -uNr --exclude=*~ memtest86-2.5/memtest86.lds memtest86-2.5.eb1/memtest86.lds
--- memtest86-2.5/memtest86.lds Wed Dec 31 17:00:00 1969
+++ memtest86-2.5.eb1/memtest86.lds Wed Mar 21 21:57:06 2001
@@ -0,0 +1,18 @@
+TESTADR = 0x1000;
+RELOADR = 0x9800;
+ZEROADR = 0x12000;
+ZEROSZ = 0x400;
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+PHDRS {
+ head PT_LOAD ;
+ relo PT_LOAD ;
+ zero PT_LOAD ;
+}
+ENTRY(TESTADR);
+
+SECTIONS {
+ .head (TESTADR): { *(.head) } : head
+ .relo (RELOADR): { *(.relo) } : relo
+ .zero (ZEROADR): { . = . + ZEROSZ; nothing = . ; } : zero
+}
diff -uNr --exclude=*~ memtest86-2.5/relo.lds memtest86-2.5.eb1/relo.lds
--- memtest86-2.5/relo.lds Wed Dec 31 17:00:00 1969
+++ memtest86-2.5.eb1/relo.lds Wed Mar 21 21:29:50 2001
@@ -0,0 +1,5 @@
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+SECTIONS {
+ .relo : { *(*) }
+}
diff -uNr --exclude=*~ memtest86-2.5/setup.S memtest86-2.5.eb1/setup.S
--- memtest86-2.5/setup.S Wed Sep 20 12:08:11 2000
+++ memtest86-2.5.eb1/setup.S Wed Mar 21 21:10:16 2001
@@ -128,7 +128,12 @@
flush_instr:
mov ax,#KERNEL_DS
mov ds,ax
+ mov es,ax
mov ss,ax
+ mov fs,ax
+ mov gs,ax
+
+! Clear the video display
mov ax,#0x0720
mov ebx,#0xb8000
mov ecx,#0xc0000
Eric