Shutdown manually
This commit is contained in:
parent
dc10619461
commit
708745c8a7
4 changed files with 134 additions and 4 deletions
|
@ -21,12 +21,16 @@
|
||||||
#define SYSCALL_OPEN 5
|
#define SYSCALL_OPEN 5
|
||||||
#define SYSCALL_WRITE 4
|
#define SYSCALL_WRITE 4
|
||||||
#define SYSCALL_RESET 55
|
#define SYSCALL_RESET 55
|
||||||
|
#define SYSCALL_FSYNC 95
|
||||||
|
#define SYSCALL_ARCH 165
|
||||||
#define SYSCALL_EXIT 1
|
#define SYSCALL_EXIT 1
|
||||||
|
#define SYSCALL_ARCH_IOPL 4
|
||||||
#define SYSCALL_INT 0x80
|
#define SYSCALL_INT 0x80
|
||||||
|
|
||||||
#define RESET_NOSYNC 0x4
|
#define RESET_NOSYNC 0x4
|
||||||
#define RESET_HALT 0x8
|
#define RESET_HALT 0x8
|
||||||
#define RESET_POWEROFF 0x4000
|
#define RESET_POWEROFF 0x4000
|
||||||
|
#define SHUTDOWN_PORT 0x8900
|
||||||
|
|
||||||
.section ".init", "ax"
|
.section ".init", "ax"
|
||||||
.global start,_start
|
.global start,_start
|
||||||
|
@ -53,6 +57,39 @@ _start:
|
||||||
int $SYSCALL_INT
|
int $SYSCALL_INT
|
||||||
addl $16, %esp
|
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. */
|
/* shutdown. */
|
||||||
movl $SYSCALL_RESET, %eax
|
movl $SYSCALL_RESET, %eax
|
||||||
pushl $(RESET_POWEROFF|RESET_HALT|RESET_NOSYNC)
|
pushl $(RESET_POWEROFF|RESET_HALT|RESET_NOSYNC)
|
||||||
|
@ -71,4 +108,7 @@ device:
|
||||||
message:
|
message:
|
||||||
.ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
|
.ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
|
||||||
messageend:
|
messageend:
|
||||||
|
iopl_arg:
|
||||||
|
.long SHUTDOWN_PORT
|
||||||
|
.long 1
|
||||||
|
.long 1
|
||||||
|
|
|
@ -18,14 +18,18 @@
|
||||||
|
|
||||||
#define MODE_RDRW 2
|
#define MODE_RDRW 2
|
||||||
#define FLAGS_NONE 0
|
#define FLAGS_NONE 0
|
||||||
|
#define SYSCALL_ARCH 165
|
||||||
#define SYSCALL_OPEN 5
|
#define SYSCALL_OPEN 5
|
||||||
#define SYSCALL_WRITE 4
|
#define SYSCALL_WRITE 4
|
||||||
#define SYSCALL_RESET 55
|
#define SYSCALL_RESET 55
|
||||||
#define SYSCALL_EXIT 1
|
#define SYSCALL_EXIT 1
|
||||||
|
#define SYSCALL_ARCH_IOPL 4
|
||||||
|
#define SYSCALL_FSYNC 95
|
||||||
|
|
||||||
#define RESET_NOSYNC 0x4
|
#define RESET_NOSYNC 0x4
|
||||||
#define RESET_HALT 0x8
|
#define RESET_HALT 0x8
|
||||||
#define RESET_POWEROFF 0x4000
|
#define RESET_POWEROFF 0x4000
|
||||||
|
#define SHUTDOWN_PORT 0x8900
|
||||||
|
|
||||||
.section ".init", "ax"
|
.section ".init", "ax"
|
||||||
.global start,_start
|
.global start,_start
|
||||||
|
@ -40,11 +44,39 @@ _start:
|
||||||
movq %rax, %rdi
|
movq %rax, %rdi
|
||||||
|
|
||||||
/* write. */
|
/* write. */
|
||||||
movq $SYSCALL_WRITE, %rax
|
|
||||||
leaq message, %rsi
|
leaq message, %rsi
|
||||||
movq $(messageend-message), %rdx
|
movq $SYSCALL_WRITE, %rax
|
||||||
|
movq $(messageend - message), %rdx
|
||||||
syscall
|
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. */
|
/* shutdown. */
|
||||||
movq $SYSCALL_RESET, %rax
|
movq $SYSCALL_RESET, %rax
|
||||||
movq $(RESET_POWEROFF|RESET_HALT|RESET_NOSYNC), %rdi
|
movq $(RESET_POWEROFF|RESET_HALT|RESET_NOSYNC), %rdi
|
||||||
|
@ -60,3 +92,7 @@ device:
|
||||||
message:
|
message:
|
||||||
.ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
|
.ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
|
||||||
messageend:
|
messageend:
|
||||||
|
iopl_arg:
|
||||||
|
.long SHUTDOWN_PORT
|
||||||
|
.long 1
|
||||||
|
.long 1
|
|
@ -23,12 +23,15 @@
|
||||||
#define SYSCALL_RESET 208
|
#define SYSCALL_RESET 208
|
||||||
#define SYSCALL_EXIT 1
|
#define SYSCALL_EXIT 1
|
||||||
#define SYSCALL_MKNOD 14
|
#define SYSCALL_MKNOD 14
|
||||||
|
#define SYSCALL_ARCH 165
|
||||||
#define SYSCALL_MOUNT 410
|
#define SYSCALL_MOUNT 410
|
||||||
#define SYSCALL_INT 0x80
|
#define SYSCALL_INT 0x80
|
||||||
|
#define SYSCALL_ARCH_IOPL 2
|
||||||
|
|
||||||
#define RESET_NOSYNC 0x4
|
#define RESET_NOSYNC 0x4
|
||||||
#define RESET_HALT 0x8
|
#define RESET_HALT 0x8
|
||||||
#define RESET_POWEROFF 0x800
|
#define RESET_POWEROFF 0x800
|
||||||
|
#define SHUTDOWN_PORT 0x8900
|
||||||
|
|
||||||
.section ".init", "ax"
|
.section ".init", "ax"
|
||||||
.global start,_start
|
.global start,_start
|
||||||
|
@ -64,6 +67,30 @@ _start:
|
||||||
leaq message, %rsi
|
leaq message, %rsi
|
||||||
syscall
|
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. */
|
/* shutdown. */
|
||||||
movq $SYSCALL_RESET, %rax
|
movq $SYSCALL_RESET, %rax
|
||||||
movq $(RESET_POWEROFF|RESET_HALT|RESET_NOSYNC), %rdi
|
movq $(RESET_POWEROFF|RESET_HALT|RESET_NOSYNC), %rdi
|
||||||
|
@ -119,3 +146,5 @@ tmpfs_args:
|
||||||
/* Alignment long. */
|
/* Alignment long. */
|
||||||
.long 0
|
.long 0
|
||||||
tmpfs_args_end:
|
tmpfs_args_end:
|
||||||
|
iopl_arg:
|
||||||
|
.long 3
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#define SYSCALL_WRITE 4
|
#define SYSCALL_WRITE 4
|
||||||
#define SYSCALL_RESET 88
|
#define SYSCALL_RESET 88
|
||||||
|
#define SYSCALL_IOPL 110
|
||||||
#define SYSCALL_EXIT 1
|
#define SYSCALL_EXIT 1
|
||||||
#define SYSCALL_INT 0x80
|
#define SYSCALL_INT 0x80
|
||||||
|
|
||||||
|
@ -26,6 +27,8 @@
|
||||||
#define SHUTDOWN_MAGIC2 0x28121969
|
#define SHUTDOWN_MAGIC2 0x28121969
|
||||||
#define SHUTDOWN_MAGIC3 0x4321fedc
|
#define SHUTDOWN_MAGIC3 0x4321fedc
|
||||||
|
|
||||||
|
#define SHUTDOWN_PORT 0x8900
|
||||||
|
|
||||||
.text
|
.text
|
||||||
.global start, _start
|
.global start, _start
|
||||||
_start:
|
_start:
|
||||||
|
@ -37,6 +40,28 @@ start:
|
||||||
movl $(messageend-message), %edx
|
movl $(messageend-message), %edx
|
||||||
int $SYSCALL_INT
|
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. */
|
/* shutdown. */
|
||||||
movl $SYSCALL_RESET, %eax
|
movl $SYSCALL_RESET, %eax
|
||||||
movl $SHUTDOWN_MAGIC1, %ebx
|
movl $SHUTDOWN_MAGIC1, %ebx
|
||||||
|
|
Loading…
Reference in a new issue