From 038385afb0be64cfcb3808707818507d620d433a Mon Sep 17 00:00:00 2001 From: acevest Date: Wed, 24 Nov 2021 22:42:19 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A6=E5=8F=91=E9=87=8D=E5=90=AF=E7=9A=84?= =?utf8?q?=E6=97=B6=E5=80=99,=E5=9C=A8=E6=89=A7=E8=A1=8C=E9=87=8D=E5=90=AF?= =?utf8?q?=E5=89=8D=E7=AD=89=E5=BE=853=E7=A7=92=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- boot/reboot.S | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/boot/reboot.S b/boot/reboot.S index 6dcd94d..ac1fa26 100644 --- a/boot/reboot.S +++ b/boot/reboot.S @@ -16,29 +16,38 @@ #define ASM #include .global do_restart -.global do_reboot -.global do_poweroff -.extern printk +.global do_reboot +.global do_poweroff +.extern printk .text .code32 .align 32 do_restart: do_reboot: - movl $REBOOT_RESTART,RebootFlag - pushl $msgReboot + movl $REBOOT_RESTART,reboot_flag + pushl $msg_reboot call printk addl $4,%esp jmp _do_reboot -msgReboot: .asciz "Rebooting ..........." + do_poweroff: - movl $REBOOT_POWEROFF,RebootFlag - pushl $msgPowerOff + movl $REBOOT_POWEROFF,reboot_flag + pushl $msg_poweroff call printk addl $4,%esp jmp _do_reboot -msgPowerOff: .asciz "Shutdown System......" + _do_reboot: + + # 刚打印完提示字符串,先等待3秒钟 + sti + movl $300, %ecx + .delay: + hlt + loop .delay + + # Disable All Interrupts cli @@ -60,9 +69,9 @@ _do_reboot: # Modify 'jmp' Instruction In Real Mode Code - cmpl $REBOOT_POWEROFF,RebootFlag + cmpl $REBOOT_POWEROFF,reboot_flag je 1f - cmpl $REBOOT_RESTART,RebootFlag + cmpl $REBOOT_RESTART,reboot_flag je 2f 1: movl $JUMPEND,%ecx @@ -114,7 +123,7 @@ GDTR: IDTR: IDTRLimit: .word 0x3FF IDTRBase: .long 0x0 -RebootFlag: .long REBOOT_RESTART +reboot_flag: .long REBOOT_RESTART .align 16 .code16 Code16: @@ -147,3 +156,7 @@ SHUTDOWN: REBOOT: ljmp $0xFFFF,$0x0000 Code16End: + + +msg_reboot: .asciz "\nREBOOTING...........\n" +msg_poweroff: .asciz "\nSHUTDOWN SYSTEM NOW......\n" \ No newline at end of file -- 2.44.0