]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
pc-chainloader bootcheck
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 25 Aug 2010 19:55:48 +0000 (21:55 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 25 Aug 2010 19:55:48 +0000 (21:55 +0200)
Makefile.am
grub-core/tests/boot/pc-chainloader.S [new file with mode: 0644]
grub-core/tests/boot/pc-chainloader.cfg [new file with mode: 0644]

index f948a7a2ff71fcddacf39cba4d05e4601e554ff5..b97f012bc1994021ddb0016c577ea68601bd7da8 100644 (file)
@@ -129,6 +129,12 @@ linux.init.i386: $(srcdir)/grub-core/tests/boot/linux.init-i386.S
 multiboot.elf: $(srcdir)/grub-core/tests/boot/multiboot.S
        $(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include
 
+pc-chainloader.elf: $(srcdir)/grub-core/tests/boot/pc-chainloader.S
+       $(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,-N -Wl,-Ttext,0x7c00 -m32
+
+pc-chainloader.bin: pc-chainloader.elf
+       $(OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn $< $@;
+
 multiboot2.elf: $(srcdir)/grub-core/tests/boot/multiboot.S
        $(TARGET_CC) -o $@ $< -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,-N -Wl,-Ttext,0x100000 -m32 -I$(srcdir)/include -DMULTIBOOT2=1
 
@@ -212,8 +218,15 @@ bootcheck-multiboot: multiboot.elf $(srcdir)/grub-core/tests/boot/multiboot.cfg
 bootcheck-multiboot2: multiboot2.elf $(srcdir)/grub-core/tests/boot/multiboot2.cfg grub-shell
        timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=$(QEMU32) --files=/multiboot2.elf=multiboot2.elf $(srcdir)/grub-core/tests/boot/multiboot2.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
 
+bootcheck-pc-chainloader: pc-chainloader.bin $(srcdir)/grub-core/tests/boot/pc-chainloader.cfg grub-shell
+       timeout -s KILL $(BOOTCHECK_TIMEOUT) ./grub-shell --qemu-opts="$(GRUB_QEMU_OPTS)" --boot=$(BOOTTARGET) --qemu=$(QEMU32) --files=/pc-chainloader.bin=pc-chainloader.bin $(srcdir)/grub-core/tests/boot/pc-chainloader.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
+
 BOOTCHECKS= 
 
+if COND_i386_pc
+BOOTCHECKS += bootcheck-pc-chainloader
+endif
+
 BOOTCHECKS += bootcheck-multiboot bootcheck-multiboot2
 
 BOOTCHECKS += bootcheck-linux16-i386 bootcheck-linux16-x86_64
diff --git a/grub-core/tests/boot/pc-chainloader.S b/grub-core/tests/boot/pc-chainloader.S
new file mode 100644 (file)
index 0000000..fc74299
--- /dev/null
@@ -0,0 +1,63 @@
+
+#define SHUTDOWN_PORT 0x8900
+
+       .text
+       .globl _start
+_start:
+base:  
+       .code16
+       jmp cont
+
+portmsg:
+       xorw %ax, %ax
+1:     
+       movb 0(%si), %al
+       test %ax, %ax
+       jz 1f
+       outb %al, %dx
+       incw %si
+       jmp 1b
+1:
+       ret
+
+serialmsg:     
+1:     
+       movb 0(%si), %bl
+       testb %bl, %bl
+       jz 1f
+       movw $0x3fd, %dx
+2:     
+       inb %dx, %al
+       testb $0x20, %al
+       jz   2b
+
+       movw $0x3f8, %dx
+       movb %bl, %al
+       outb %al, %dx
+       incw %si
+       jmp 1b
+1:
+       ret
+
+cont:  
+       xorw %ax, %ax
+       movw %ax, %ds
+       lea message, %si
+       call serialmsg
+       lea shutdown, %si
+       movw $SHUTDOWN_PORT, %dx
+       call portmsg
+
+1:
+       hlt
+       jmp 1b
+
+shutdown:
+       .ascii "Shutdown"
+       .byte 0
+message:
+       .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
+       .byte 0
+
+       . = base + 510
+       .short 0xaa55
\ No newline at end of file
diff --git a/grub-core/tests/boot/pc-chainloader.cfg b/grub-core/tests/boot/pc-chainloader.cfg
new file mode 100644 (file)
index 0000000..1e80a5b
--- /dev/null
@@ -0,0 +1,4 @@
+chainloader /pc-chainloader.bin
+boot
+# Shouln't happen
+halt