Re: [Etherboot-developers] Bugfixed PXE (and patched patch)
Brought to you by:
marty_connor,
stefanhajnoczi
|
From: <ke...@us...> - 2001-06-28 04:46:06
|
Hi,
Thanks for unifying loader.S and pxeloader.S. I've made the constants
in loader.S and etherboot.h all in hex and added comments. I also put
the space reservation for the two words inside #ifdef PXELOADER as it's
not needed by other loaders and will increase their size. Here is the
latest patch, wrt 5.0.2.
diff -urP --exclude=Roms ../../etherboot-5.0.2/src/Makefile ./Makefile
--- ../../etherboot-5.0.2/src/Makefile Fri Jun 22 01:44:39 2001
+++ ./Makefile Thu Jun 28 13:35:39 2001
@@ -89,8 +89,8 @@
CPP= gcc -E
OBJCOPY= objcopy
VERSION_MAJOR= 5
VERSION_MINOR= 0
VERSION_PATCH= 2
VERSION= $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
CFLAGS32+= -DVERSION_MAJOR=$(VERSION_MAJOR) \
-DVERSION_MINOR=$(VERSION_MINOR) \
@@ -142,7 +142,7 @@
WDFLAGS= -DINCLUDE_WD -DWD_DEFAULT_MEM=0xCC000
W89C840FLAGS= -DINCLUDE_W89C840
-SRCS= boot1a.s comprefix.S liloprefix.S loader.S pxeloader.S start32.S serial.S
+SRCS= boot1a.s comprefix.S liloprefix.S loader.S start32.S serial.S
SRCS+= main.c pci.c osloader.c nfs.c misc.c ansiesc.c bootmenu.c config.c
SRCS+= md5.c floppy.c
@@ -254,11 +254,11 @@
bin/rzloader.s: loader.S $(MAKEDEPS)
$(CPP) $(LCONFIG) -DZLOADER -o $@ $<
-bin/pxeloader.s: pxeloader.S $(MAKEDEPS)
- $(CPP) $(LCONFIG) -o $@ $<
+bin/pxeloader.s: loader.S $(MAKEDEPS)
+ $(CPP) $(LCONFIG) -DPXELOADER -o $@ $<
-bin/pxezloader.s: pxeloader.S $(MAKEDEPS)
- $(CPP) $(LCONFIG) -DZLOADER -o $@ $<
+bin/pxezloader.s: loader.S $(MAKEDEPS)
+ $(CPP) $(LCONFIG) -DPXELOADER -DZLOADER -o $@ $<
bin/prloader.s: loader.S $(MAKEDEPS)
$(CPP) $(LCONFIG) -DPCI_PNP_HEADER -o $@ $<
diff -urP --exclude=Roms ../../etherboot-5.0.2/src/etherboot.h ./etherboot.h
--- ../../etherboot-5.0.2/src/etherboot.h Tue Jun 19 21:54:05 2001
+++ ./etherboot.h Thu Jun 28 09:06:36 2001
@@ -440,8 +440,11 @@
#define NFS_READ_SIZE 1024
#define FLOPPY_BOOT_LOCATION 0x7c00
+/* Must match offsets in loader.S */
+#define ROM_SEGMENT 0x1fa
+#define ROM_LENGTH 0x1fc
-#define ROM_INFO_LOCATION 0x7dfa
+#define ROM_INFO_LOCATION (FLOPPY_BOOT_LOCATION+ROM_SEGMENT)
/* at end of floppy boot block */
struct rom_info {
diff -urP --exclude=Roms ../../etherboot-5.0.2/src/genrules.pl ./genrules.pl
--- ../../etherboot-5.0.2/src/genrules.pl Mon Apr 23 23:51:53 2001
+++ ./genrules.pl Mon Jun 25 00:16:36 2001
@@ -141,6 +141,14 @@
cat \$(PRZLOADER) \$< > \$@
bin/makerom \$(MAKEROM_\$*) -p $ids -i\$(IDENT32) \$@
+bin32/$rom.pxe: bin32/$drv.img \$(PXELOADER)
+ cat \$(PXELOADER) \$< > \$@
+ bin/makerom -x \$(MAKEROM_\$*) -p $ids -i\$(IDENT32) \$@
+
+bin32/$rom.lzpxe: bin32/$drv.huf \$(PXEZLOADER)
+ cat \$(PXEZLOADER) \$< > \$@
+ bin/makerom -x \$(MAKEROM_\$*) -p $ids -i\$(IDENT32) \$@
+
EOF
}
foreach $rom (sort keys %roms_isa) {
@@ -149,6 +157,10 @@
bin32/$rom.rom: bin32/$rom.img \$(RLOADER)
bin32/$rom.lzrom: bin32/$rom.huf \$(RZLOADER)
+
+bin32/$rom.pxe: bin32/$rom.img \$(PXELOADER)
+
+bin32/$rom.lzpxe: bin32/$rom.huf \$(PXEZLOADER)
EOF
}
diff -urP --exclude=Roms ../../etherboot-5.0.2/src/loader.S ./loader.S
--- ../../etherboot-5.0.2/src/loader.S Sat Jun 16 15:36:25 2001
+++ ./loader.S Thu Jun 28 13:57:01 2001
@@ -16,10 +16,22 @@
*/
#endif
+#ifdef PXELOADER
+#ifdef PCI_PNP_HEADER
+#error Cannot have PXELOADER and PCI_PNP_HEADER
+#endif
+#endif
+
/* This provides for execution at 0x88000 to avoid disk-on-chip drivers */
#undef NOT_AT_0x9xxxx
#if (RELOC & 0xF0000) != 0x90000
#define NOT_AT_0x9xxxx
+#else
+#ifdef PXELOADER
+/* also don't depend on the amount of memory int 12 reports as it has been
+ decreased by PXE and not increased again even after releasing it */
+#define NOT_AT_0x9xxxx
+#endif / * PXELOADER */
#define MAX_SP ((RELOC & 0xF0000) + 0x10000 - RELOC)
/* e.g. RELOC = 0x84000, MAX_SP = 0x90000 - 0x84000 = 0xC000 */
#endif
@@ -63,11 +75,12 @@
#define SCRATCHVEC 0x300
/* Offsets of words containing ROM's CS and size (in 512 byte blocks)
- * from start of floppy boot block at 0x7C00
+ * from start of floppy boot block at 0x7c00
+ * Offsets must match those in etherboot.h
*/
-#define FLOPPY_SEGMENT 0x7C0
-#define ROM_SEGMENT 506
-#define ROM_LENGTH 508
+#define FLOPPY_SEGMENT 0x7c0
+#define ROM_SEGMENT 0x1fa
+#define ROM_LENGTH 0x1fc
/* Do not change these values unless you really know what you are doing
* the pre-computed lookup tables rely on the buffer size being 4kB or
@@ -87,6 +100,7 @@
.org 0
_start:
+#ifndef PXELOADER
.word 0xAA55 /* BIOS extension signature */
size: .byte 0 /* number of 512 byte blocks */
/* = number of 256 word blocks */
@@ -187,6 +201,126 @@
jmp blockmove
pnpentry:
movw $0,%ax
+#else /* PXELOADER */
+#define PXENV_UNDI_SHUTDOWN 0x05
+#define PXENV_UNLOAD_STACK 0x70
+ jmp startpxe
+size: .byte 64 /* number of 512 byte blocks */
+ /* PXE will not load more than 32K */
+ /* so this should be <= 64 */
+ /* filled in by makerom program */
+startpxe:
+ jmp $FLOPPY_SEGMENT, $n-_start
+n:
+ movw %sp, %bp
+
+ push %cs
+ pop %ds
+
+ movw $hellomsgend-hellomsg, %cx
+ movw $hellomsg-_start, %si
+ movw $0x0007, %bx /* page 0, attribute 7 (normal) */
+ movb $0x0e, %ah /* write char, tty mode */
+prloop_hellomsg:
+ lodsb
+ int $0x10
+ loop prloop_hellomsg
+
+ movw $MAGIC,%ax
+ jmp pxefind
+hellomsg:
+ .ascii "PXE loader for etherboot"
+#if defined(ZLOADER)
+ .ascii "(with ZLOADER)"
+#endif
+ .ascii "\r\n"
+hellomsgend:
+pxe_undi_shutdown_pkt:
+ .word 0
+pxe_unload_stack_pkt:
+ .word 0
+ .word 0,0,0,0,0
+PXEEntry:
+ .word 0,0
+pxefind:
+ les 4(%bp), %di /* !PXE structure */
+ cmpl $0x45585021, %es:(%di) /* '!PXE' signature */
+ je have_pxe
+ movl $0x202b564e, pxemsg2-_start /* 'NV+ ' */
+ mov $0x5650, %ax
+ int $0x1a
+ jc no_pxe
+ cmp $0x564e, %ax
+ jne no_pxe
+
+ cmpl $0x4e455850, %es:(%bx) /* 'PXEN' signature */
+ jne no_pxe
+ cmpw $0x2b56, %es:4(%bx) /* 'V+' signature */
+ jne no_pxe
+ mov %bx, %cs:PXEEntry -_start /* save them in case we use PXENV+ */
+ mov %es, %cs:PXEEntry+2-_start
+ cmpw $0x201, %es:6(%bx) /* API version 2.1 or higher */
+ jae get_pxe /* otherwise use PXENV+ */
+use_pxenv:
+ les %es:0x0a(%bx), %di
+ mov %di, %cs:PXEEntry -_start
+ mov %es, %cs:PXEEntry+2-_start
+ push %ds
+ pop %es
+ mov $pxe_undi_shutdown_pkt, %di
+ mov $PXENV_UNDI_SHUTDOWN, %bx
+ lcall %cs:(PXEEntry-_start)
+ mov $pxe_unload_stack_pkt, %di
+ mov $PXENV_UNLOAD_STACK, %bx
+ lcall %cs:(PXEEntry-_start)
+ jmp pxe
+get_pxe:
+ les %es:0x28(%bx), %di
+ cmpl $0x45585021, %es:(%di) /* '!PXE' signature */
+ jne no_pxe
+ jmp have_pxe
+/* mov %cs:PXEEntry+2-_start, %bx /* restore PXENV+ */
+/* mov %bx, %es
+ mov %cs:PXEEntry -_start, %bx
+ jmp use_pxenv */
+have_pxe:
+ les %es:0x10(%di), %di
+ mov %di, %cs:PXEEntry -_start
+ mov %es, %cs:PXEEntry+2-_start
+
+ pushw %cs
+ pushw $pxe_undi_shutdown_pkt
+ pushw $PXENV_UNDI_SHUTDOWN
+ lcall %cs:(PXEEntry-_start)
+ add $6, %sp
+ pushw %cs
+ pushw $pxe_unload_stack_pkt
+ pushw $PXENV_UNLOAD_STACK
+ lcall %cs:(PXEEntry-_start)
+ add $6, %sp
+
+pxe: movw $pxemsg-_start+3, %si
+ movw $pxemsgend-pxemsg-3, %cx
+ jmp pxe_print
+no_pxe:
+ movw $pxemsg-_start, %si
+ movw $pxemsgend-pxemsg, %cx
+pxe_print:
+ movw $0x0007, %bx /* page 0, attribute 7 (normal) */
+ movb $0x0e, %ah /* write char, tty mode */
+prloop_pxemsg:
+ lodsb
+ int $0x10
+ loop prloop_pxemsg
+
+ movw $MAGIC,%ax
+ jmp blockmove
+pxemsg:
+ .ascii "No PXE"
+pxemsg2:
+ .ascii " unloaded\r\n"
+pxemsgend:
+#endif /* PXELOADER*/
blockmove:
pushw %ax /* indicates whether PnP or legacy */
/* The following copy is a bit convoluted to save source code, so here a few
@@ -208,6 +342,16 @@
movw %ax, ROM_SEGMENT
movw %cx, ROM_LENGTH
popw %ds /* restore DS */
+
+/* PXE loads this code in FLOPPY_SEGMENT so we have to leave some room
+ or it will clobber code */
+#ifdef PXELOADER
+ jmp endrominfo
+ .org ROM_SEGMENT
+ .word 0
+ .word 0
+endrominfo:
+#endif /* PXELOADER */
#if !defined(ZLOADER) || defined(MOVEROM)
cld
diff -urP --exclude=Roms ../../etherboot-5.0.2/src/main.c ./main.c
--- ../../etherboot-5.0.2/src/main.c Sat Jun 23 13:25:42 2001
+++ ./main.c Tue Jun 26 23:07:53 2001
@@ -179,6 +179,7 @@
static inline void try_floppy_first(void)
{
#if (TRY_FLOPPY_FIRST > 0) && defined (FLOPPY)
+ int i;
printf("Trying floppy");
disk_init();
for (i = TRY_FLOPPY_FIRST; i-- > 0; ) {
diff -urP --exclude=Roms ../../etherboot-5.0.2/src/makerom.c ./makerom.c
--- ../../etherboot-5.0.2/src/makerom.c Sat Jun 23 21:10:15 2001
+++ ./makerom.c Thu Jun 28 13:25:50 2001
@@ -183,7 +183,7 @@
printf("%ld bytes read\n", fs);
if (ispxe) {
romsize=fs;
- rom[2] = romsize / 512L;
+ rom[2] = ( romsize / 512L ) + 1 ;
goto writerom ;
}
|