From: Vladimir 'phcoder' Serbinenko Date: Tue, 27 Apr 2010 19:42:15 +0000 (+0200) Subject: Shutdown manually X-Git-Tag: 1.99~629^2~86 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=708745c8a74cbb7aa004fa400cb710e578cf0b8e;p=thirdparty%2Fgrub.git Shutdown manually --- diff --git a/tests/boot/kfreebsd.init-i386.S b/tests/boot/kfreebsd.init-i386.S index 8812b650b..12c94a036 100644 --- a/tests/boot/kfreebsd.init-i386.S +++ b/tests/boot/kfreebsd.init-i386.S @@ -21,12 +21,16 @@ #define SYSCALL_OPEN 5 #define SYSCALL_WRITE 4 #define SYSCALL_RESET 55 +#define SYSCALL_FSYNC 95 +#define SYSCALL_ARCH 165 #define SYSCALL_EXIT 1 +#define SYSCALL_ARCH_IOPL 4 #define SYSCALL_INT 0x80 #define RESET_NOSYNC 0x4 #define RESET_HALT 0x8 #define RESET_POWEROFF 0x4000 +#define SHUTDOWN_PORT 0x8900 .section ".init", "ax" .global start,_start @@ -52,6 +56,39 @@ _start: pushl $0 int $SYSCALL_INT addl $16, %esp + + /* fsync. */ + movl $SYSCALL_FSYNC, %eax + pushl %ecx + pushl $0 + int $SYSCALL_INT + addl $8, %esp + + /* IOPL. */ + movl $SYSCALL_ARCH, %eax + pushl $iopl_arg + pushl $SYSCALL_ARCH_IOPL + pushl $0 + int $SYSCALL_INT + addl $12, %esp + + movw $SHUTDOWN_PORT, %dx + movb $'S', %al + outb %al, %dx + movb $'h', %al + outb %al, %dx + movb $'u', %al + outb %al, %dx + movb $'t', %al + outb %al, %dx + movb $'d', %al + outb %al, %dx + movb $'o', %al + outb %al, %dx + movb $'w', %al + outb %al, %dx + movb $'n', %al + outb %al, %dx /* shutdown. */ movl $SYSCALL_RESET, %eax @@ -71,4 +108,7 @@ device: message: .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n" messageend: - \ No newline at end of file +iopl_arg: + .long SHUTDOWN_PORT + .long 1 + .long 1 diff --git a/tests/boot/kfreebsd.init-x86_64.S b/tests/boot/kfreebsd.init-x86_64.S index edff0d782..d2907b3a8 100644 --- a/tests/boot/kfreebsd.init-x86_64.S +++ b/tests/boot/kfreebsd.init-x86_64.S @@ -18,14 +18,18 @@ #define MODE_RDRW 2 #define FLAGS_NONE 0 +#define SYSCALL_ARCH 165 #define SYSCALL_OPEN 5 #define SYSCALL_WRITE 4 #define SYSCALL_RESET 55 #define SYSCALL_EXIT 1 +#define SYSCALL_ARCH_IOPL 4 +#define SYSCALL_FSYNC 95 #define RESET_NOSYNC 0x4 #define RESET_HALT 0x8 #define RESET_POWEROFF 0x4000 +#define SHUTDOWN_PORT 0x8900 .section ".init", "ax" .global start,_start @@ -40,10 +44,38 @@ _start: movq %rax, %rdi /* write. */ - movq $SYSCALL_WRITE, %rax leaq message, %rsi - movq $(messageend-message), %rdx + movq $SYSCALL_WRITE, %rax + movq $(messageend - message), %rdx + syscall + + /* fsync. */ + movq $SYSCALL_FSYNC, %rax syscall + + /* IOPL. */ + movq $SYSCALL_ARCH, %rax + movq $SYSCALL_ARCH_IOPL, %rdi + leaq iopl_arg, %rsi + syscall + + movw $SHUTDOWN_PORT, %dx + movb $'S', %al + outb %al, %dx + movb $'h', %al + outb %al, %dx + movb $'u', %al + outb %al, %dx + movb $'t', %al + outb %al, %dx + movb $'d', %al + outb %al, %dx + movb $'o', %al + outb %al, %dx + movb $'w', %al + outb %al, %dx + movb $'n', %al + outb %al, %dx /* shutdown. */ movq $SYSCALL_RESET, %rax @@ -60,3 +92,7 @@ device: message: .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n" messageend: +iopl_arg: + .long SHUTDOWN_PORT + .long 1 + .long 1 \ No newline at end of file diff --git a/tests/boot/knetbsd.init-x86_64.S b/tests/boot/knetbsd.init-x86_64.S index dfc64e99d..05a494594 100644 --- a/tests/boot/knetbsd.init-x86_64.S +++ b/tests/boot/knetbsd.init-x86_64.S @@ -23,12 +23,15 @@ #define SYSCALL_RESET 208 #define SYSCALL_EXIT 1 #define SYSCALL_MKNOD 14 +#define SYSCALL_ARCH 165 #define SYSCALL_MOUNT 410 #define SYSCALL_INT 0x80 +#define SYSCALL_ARCH_IOPL 2 #define RESET_NOSYNC 0x4 #define RESET_HALT 0x8 #define RESET_POWEROFF 0x800 +#define SHUTDOWN_PORT 0x8900 .section ".init", "ax" .global start,_start @@ -64,6 +67,30 @@ _start: leaq message, %rsi syscall + /* IOPL. */ + movq $SYSCALL_ARCH, %rax + movq $SYSCALL_ARCH_IOPL, %rdi + leaq iopl_arg, %rsi + syscall + + movw $SHUTDOWN_PORT, %dx + movb $'S', %al + outb %al, %dx + movb $'h', %al + outb %al, %dx + movb $'u', %al + outb %al, %dx + movb $'t', %al + outb %al, %dx + movb $'d', %al + outb %al, %dx + movb $'o', %al + outb %al, %dx + movb $'w', %al + outb %al, %dx + movb $'n', %al + outb %al, %dx + /* shutdown. */ movq $SYSCALL_RESET, %rax movq $(RESET_POWEROFF|RESET_HALT|RESET_NOSYNC), %rdi @@ -118,4 +145,6 @@ tmpfs_args: .long 0777 /* Alignment long. */ .long 0 -tmpfs_args_end: \ No newline at end of file +tmpfs_args_end: +iopl_arg: + .long 3 \ No newline at end of file diff --git a/tests/boot/linux.init-i386.S b/tests/boot/linux.init-i386.S index a79a5787e..f3eca6d88 100644 --- a/tests/boot/linux.init-i386.S +++ b/tests/boot/linux.init-i386.S @@ -18,6 +18,7 @@ #define SYSCALL_WRITE 4 #define SYSCALL_RESET 88 +#define SYSCALL_IOPL 110 #define SYSCALL_EXIT 1 #define SYSCALL_INT 0x80 @@ -26,6 +27,8 @@ #define SHUTDOWN_MAGIC2 0x28121969 #define SHUTDOWN_MAGIC3 0x4321fedc +#define SHUTDOWN_PORT 0x8900 + .text .global start, _start _start: @@ -37,6 +40,28 @@ start: movl $(messageend-message), %edx int $SYSCALL_INT + movl $SYSCALL_IOPL, %eax + movl $3, %ebx + int $SYSCALL_INT + + movw $SHUTDOWN_PORT, %dx + movb $'S', %al + outb %al, %dx + movb $'h', %al + outb %al, %dx + movb $'u', %al + outb %al, %dx + movb $'t', %al + outb %al, %dx + movb $'d', %al + outb %al, %dx + movb $'o', %al + outb %al, %dx + movb $'w', %al + outb %al, %dx + movb $'n', %al + outb %al, %dx + /* shutdown. */ movl $SYSCALL_RESET, %eax movl $SHUTDOWN_MAGIC1, %ebx