summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2012-07-09 23:55:23 +0200
committerMichael Brown2015-04-21 00:35:13 +0200
commitfac651cb5f52f4dc2435c5c11ada06215a5b9ec9 (patch)
tree84483181fd94b1740d0612386143cce2f9c5daca
parent[smp] Use highest free base memory page for SMP structures (diff)
downloadmemtest86-fac651cb5f52f4dc2435c5c11ada06215a5b9ec9.tar.gz
memtest86-fac651cb5f52f4dc2435c5c11ada06215a5b9ec9.tar.xz
memtest86-fac651cb5f52f4dc2435c5c11ada06215a5b9ec9.zip
[pxe] Add memtest.0 target which can be loaded as a PXE NBP
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--Makefile11
-rw-r--r--pxe.S77
2 files changed, 86 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index f215dd1..baf60e1 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ OBJS= head.o reloc.o main.o test.o init.o lib.o patn.o screen_buffer.o \
smp.o vmem.o random.o
-all: memtest.bin memtest
+all: memtest.bin memtest memtest.0
# Link it statically once so I know I don't have undefined
# symbols and then link it dynamically so I have full
@@ -45,10 +45,17 @@ bootsect.s: bootsect.S config.h defs.h
setup.s: setup.S config.h defs.h
$(CC) -E -traditional $< -o $@
+pxe.s: pxe.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_shared.bin -o memtest.bin
+memtest.0: memtest_shared.bin pxe.o setup.o memtest.bin.lds
+ $(LD) -T memtest.bin.lds pxe.o setup.o -b binary \
+ memtest_shared.bin -o memtest.0
+
reloc.o: reloc.c
$(CC) -c $(CFLAGS) -fno-strict-aliasing reloc.c
@@ -64,7 +71,7 @@ build_number:
clean:
rm -f *.o *.s *.iso memtest.bin memtest memtest_shared \
- memtest_shared.bin memtest.iso
+ memtest_shared.bin memtest.iso memtest.0
iso:
make all
diff --git a/pxe.S b/pxe.S
new file mode 100644
index 0000000..98d8b98
--- /dev/null
+++ b/pxe.S
@@ -0,0 +1,77 @@
+/*
+ * pxe.S Copyright (C) 2012 Michael Brown <mcb30@ipxe.org>
+ *
+ * pxe.S is loaded at 0x7c00 by the PXE ROM. It copies the 32-bit
+ * portion to 0x10000 and jumps into setup.S.
+ */
+
+#include "defs.h"
+
+#define RMSIZE (0x200 + 0x200*SETUPSECS)
+
+#define PXENV_ENTRY 0x0a
+#define PXENV_UNDI_SHUTDOWN 0x0005
+
+.code16
+.section ".bootsect", "ax", @progbits
+.org 0
+_pxe:
+
+.globl _main
+_main:
+ /* Canonicalise addresses */
+ ljmp $BOOTSEG, $pxe_start
+
+pxe_start:
+ /* Store PXENV+ entry point */
+ movl %es:PXENV_ENTRY(%bx), %eax
+ movl %eax, %cs:pxenv_vector
+
+ /* Copy 32-bit portion to TSTLOAD:0000. Perform copy in
+ * reverse in 1kB blocks, since regions will overlap and we
+ * need to copy more than the 64kB real-mode segment limit.
+ */
+ movw $_syssize, %bx /* Length is _syssize (paragraphs) */
+ addw $63, %bx
+ andw $~63, %bx /* Round up to nearest kB */
+ movw $(BOOTSEG + (RMSIZE >> 4)), %ax
+ addw %bx, %ax
+ movw %ax, %ds
+ movw $TSTLOAD, %ax
+ addw %bx, %ax
+ movw %ax, %es
+1: movw %ds, %ax /* Decrement %ds and %es by 1kB */
+ subw $64, %ax
+ movw %ax, %ds
+ movw %es, %ax
+ subw $64, %ax
+ movw %ax, %es
+ movw $256, %cx /* Copy 1kB block */
+ xorw %si, %si
+ xorw %di, %di
+ cld
+ rep movsl
+ subw $64, %bx
+ jnz 1b
+
+ /* Set up %ds and %es for access to local variables */
+ movw %cs, %ax
+ movw %ax, %ds
+ movw %ax, %es
+
+ /* Shutdown NIC */
+ movw $PXENV_UNDI_SHUTDOWN, %bx
+ movw $pxenv_undi_shutdown, %di
+ lcall *pxenv_vector
+
+ /* Jump to setup.S */
+ ljmp $(BOOTSEG + 0x20), $0
+
+pxenv_vector:
+ .word 0,0
+
+pxenv_undi_shutdown:
+ .word 0 /* Status */
+
+.org 512
+_epxe: