Using 8042 to reset the CPU
Posted: Fri Feb 04, 2005 5:57 pm
I found some code in Minix that has me scratching my head. It resets the CPU by pulsing the reset line, which makes sense. What's kind of odd is that it also pulses the A20 line. There's a comment that attempts to explain why, but it doesn't really make sense to me. Here's the code:
Any idea why the A20 line is pulsed? Do you think this is really necessary...?
Code: Select all
if (protected_mode) {
/* Use the AT keyboard controller to reset the processor.
* The A20 line is kept enabled in case this code is ever
* run from extended memory, and because some machines
* appear to drive the fake A20 high instead of low just
* after reset, leading to an illegal opode trap. This bug
* is more of a problem if the fake A20 is in use, as it
* would be if the keyboard reset were used for real mode.
*/
kb_wait();
out_byte(KB_COMMAND,
KB_PULSE_OUTPUT | (0x0F & ~(KB_GATE_A20 | KB_RESET)));
milli_delay(10);
/* If the nice method fails then do a reset. In protected
* mode this means a processor shutdown.
*/
printf("Hard reset...\n");
milli_delay(250);
}