Rebooting in Protected Mode
Asked Answered
D

4

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?

Durden answered 4/6, 2015 at 1:27 Comment(2)
Like this, I guessHemlock
I did not manage it in real mode, how did you do it? stackoverflow.com/questions/32682152/…Magnetostriction
K
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
Kurtkurth answered 4/6, 2015 at 3:19 Comment(0)
B
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);

Beaudette answered 10/10, 2017 at 1:57 Comment(1)
In my case it triple faults the CPU.Turbinal
M
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.

Muscolo answered 7/6, 2015 at 17:50 Comment(0)
E
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

Empiricism answered 7/6, 2015 at 20:35 Comment(0)
K
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
Kurtkurth answered 4/6, 2015 at 3:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.