I have written some code to reset the CPU, based on the instructions in
PS2 Keyboard. This is called by some code in my command-prompt handler, which is very primitive. Code:
Code: Select all
void reset(void) {
while ((inportb(0x64) & 0x02) != 0);
outportb(0x64, 0xd1);
while ((inportb(0x64) & 0x02) != 0);
outportb(0x60, 0xfe);
}
And the caller:
Code: Select all
else if (!strcmp(buf, "reboot")) {
printf("Rebooting...\n");
reset();
}
The reset call works fine in both Qemu and Bochs; both reboot, so quickly that you can't see the printf output. However, on hardware it fails; there the printf is called and it goes back to the command line as if the reset() had done nothing. Does anyone know why this is?
Also, how do you halt the machine and power down? I've searched the wiki and the web in general, and nothing is obvious.
If I had an OS, there would be a link here.