]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Shutdown manually
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 27 Apr 2010 19:42:15 +0000 (21:42 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 27 Apr 2010 19:42:15 +0000 (21:42 +0200)
tests/boot/kfreebsd.init-i386.S
tests/boot/kfreebsd.init-x86_64.S
tests/boot/knetbsd.init-x86_64.S
tests/boot/linux.init-i386.S

index 8812b650bcc8f52974dea58ddb779f7dc42eb159..12c94a036e1bf7b975cf387032e6adafa584f428 100644 (file)
 #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
index edff0d782a6aa4e94a4c1a9583dc4e7fbe8811a8..d2907b3a8d475b32f7fae895564c499888ebdbbb 100644 (file)
 
 #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
index dfc64e99d9ced68bf8be05995429f30beabe57bd..05a4945940f06ef6375abe3daadb9eb509c24f78 100644 (file)
 #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
index a79a5787e0fbf4834bcc50cdebff5150077c33a8..f3eca6d88f62b5bfb748ea50bd9f1e5cd287dc6c 100644 (file)
@@ -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