Re: [Etherboot-developers] booting non linux images
Brought to you by:
marty_connor,
stefanhajnoczi
|
From: <ebi...@ln...> - 2001-05-12 22:58:52
|
Anuradha Ratnaweera <anu...@gn...> writes:
> Hello,
>
> We have setup dhcp/tftp on debian 2.2 and things are working fine with a
> linux kernel tagged with mknbi-linux.
>
> We need to run a progarm called memtest86 which runs stand alone, i.e., it
> is completely contained in a bootable image. Its booting procedure is
> based on _very_ old linux kernels. And many signatures and magic numbers
> seem to be minix compliant. Therefore mknbi-linux doesn't work.
The attached patch to memtest86-2.5 builds it as an ELF image.
Etherboot cannot load an unpatched image memtest86 loads to low in
memory.
I have used this succesfully with the 4.6.10 with Multiboot support
compiled it.
Eric
diff -uNr memtest86-2.5/Makefile memtest86-2.5.eb3/Makefile
--- memtest86-2.5/Makefile Thu Sep 21 17:39:19 2000
+++ memtest86-2.5.eb3/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.eb3/core differ
diff -uNr memtest86-2.5/defs.h memtest86-2.5.eb3/defs.h
--- memtest86-2.5/defs.h Thu Sep 21 17:39:16 2000
+++ memtest86-2.5.eb3/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 memtest86-2.5/head.S memtest86-2.5.eb3/head.S
--- memtest86-2.5/head.S Thu Sep 21 16:48:25 2000
+++ memtest86-2.5.eb3/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 memtest86-2.5/head.lds memtest86-2.5.eb3/head.lds
--- memtest86-2.5/head.lds Wed Dec 31 17:00:00 1969
+++ memtest86-2.5.eb3/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 : { *(*) }
+}
diff -uNr memtest86-2.5/lib.c memtest86-2.5.eb3/lib.c
--- memtest86-2.5/lib.c Wed Oct 18 12:57:40 2000
+++ memtest86-2.5.eb3/lib.c Fri Mar 30 10:42:37 2001
@@ -839,8 +839,13 @@
/* now do hardwired init */
serial_echo_outb(0x03, UART_LCR); /* No parity, 8 data bits, 1 stop */
serial_echo_outb(0x83, UART_LCR); /* Access divisor latch */
+#if 1
serial_echo_outb(0x00, UART_DLM); /* 9600 baud */
serial_echo_outb(0x0c, UART_DLL);
+#else
+ serial_echo_outb(0x00, UART_DLM); /* 115200 baud */
+ serial_echo_outb(0x01, UART_DLL);
+#endif
serial_echo_outb(0x03, UART_LCR); /* Done with divisor */
/* Prior to disabling interrupts, read the LSR and RBR
diff -uNr memtest86-2.5/main.c memtest86-2.5.eb3/main.c
--- memtest86-2.5/main.c Fri Oct 20 16:51:49 2000
+++ memtest86-2.5.eb3/main.c Fri Mar 30 10:38:44 2001
@@ -66,6 +66,12 @@
/* Set pointer to common variable area */
v = (struct vars *)(TESTADR+TSTSIZE-0x400);
+ if (&segs > (int *)RELOBASE) {
+ v = (struct vars *)(RELOBASE+TESTADR+TSTSIZE-0x400);
+ if (v->firsttime == 0) {
+ restart();
+ }
+ }
/* If first time, initialize test */
if (v->firsttime == 0) {
@@ -392,7 +398,8 @@
for(i=0, pp=(char *)(SCREEN_ADR+0); i<80*24; i++, pp+=2) {
*pp = ' ';
}
- do_test();
+ p = (unsigned long *)TESTADR;
+ goto *p;
}
/* Compute the total number of ticks per pass */
diff -uNr memtest86-2.5/memtest86.lds memtest86-2.5.eb3/memtest86.lds
--- memtest86-2.5/memtest86.lds Wed Dec 31 17:00:00 1969
+++ memtest86-2.5.eb3/memtest86.lds Fri Mar 30 10:37:40 2001
@@ -0,0 +1,26 @@
+__testadr = 0x1000;
+__reloadr = 0x9800;
+__zeroadr = 0x12000;
+__zerosz = 0x400;
+__relobase = 0x100000;
+__start = __relobase + __reloadr;
+/*
+__relobase = 0;
+__start = __testadr;
+*/
+
+
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+PHDRS {
+ head PT_LOAD ;
+ relo PT_LOAD ;
+ zero PT_LOAD ;
+}
+ENTRY(__start);
+
+SECTIONS {
+ .head (__testadr + __relobase): { *(.head) } : head
+ .relo (__reloadr + __relobase): { *(.relo) } : relo
+ .zero (__zeroadr + __relobase): { . = . + __zerosz; nothing = . ; } : zero
+}
diff -uNr memtest86-2.5/relo.lds memtest86-2.5.eb3/relo.lds
--- memtest86-2.5/relo.lds Wed Dec 31 17:00:00 1969
+++ memtest86-2.5.eb3/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 memtest86-2.5/setup.S memtest86-2.5.eb3/setup.S
--- memtest86-2.5/setup.S Wed Sep 20 12:08:11 2000
+++ memtest86-2.5.eb3/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
|