Rebooting in Protected Mode

南笙酒味 提交于 2019-12-07 08:33:36

问题


In x86 Real Mode rebooting is very simple. You can either use the BIOS or:

jmp 0xFFFF:0000

But how should one reboot when in Protected Mode?


回答1:


I used to write 6 to port 0xcf9, but here is a bigger list: http://smackerelofopinion.blogspot.nl/2009/06/rebooting-pc.html?m=1




回答2:


The proper way to reboot on protected mode (x86 or x86_64) is to use the power management functions (if available)

  1. Advanced Configuration and Power Interface (ACPI)
  2. Advanced power management (APM)
  3. BIOS (under vm86 or emulator) - but I suggest don't bother to.

The quick and dirty way is to do triple fault.




回答3:


Information on PORT 0xCF9.
In order to write to it, one needs access to kernel mode (Meaning from a kernel driver).

0xCF9 port can get three values for three types of reset:

Writing 4 to 0xCF9:(INIT) Will INIT the CPU. Meaning it will jump to the initial location of booting but it will keep many CPU elements untouched. Most internal tables, chaches etc will remain unchanged by the Init call (but may change during it).

Writing 6 to 0xCF9:(RESET) Will RESET the CPU with all internal tables caches etc cleared to initial state.

Writing 0xE to 0xCF9:(RESTART) Will power cycle the mother board with everything that comes with it.

Example in a windows driver:

__outbyte(0xCF9, 0xE);




回答4:


Although I can't find a direct reference, the guys over on the OSDev forums suggested the following (apparently pulled from Linux code):

;Forcing reboot with keyb controller ;)
_reboot:
WKC:
    XOR         AL, AL
    IN          AL, 0x64
    TEST        AL, 0x02
    JNZ         WKC

    MOV         AL, 0xFC
    OUT         0x64, AL


来源:https://stackoverflow.com/questions/30633489/rebooting-in-protected-mode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!