4

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?

Isaac D. Cohen
  • 797
  • 2
  • 10
  • 26

4 Answers4

5

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);

Sharon Katz
  • 898
  • 9
  • 12
3

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.

Non-maskable Interrupt
  • 3,841
  • 1
  • 19
  • 26
3

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

Chris Desjardins
  • 2,631
  • 1
  • 23
  • 25
2

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
Luke
  • 291
  • 2
  • 8