Can random code damage your hardware when run in Real Mode? If yes, give some examples how. What happens when the ACPI tables are overwritten? Is it possible to disable the CPU fan through code, and have the CPU overheat and break, or does the BIOS have moron-proof failsafes incase someone would do that?
>>33
I actually have. MCS-48/51, 65xx, PIC, AVR, etc.
/* THERAC-25 Improved Control Software */
#include "therac25hw.h"
/* Assume hardware is in a "safe" state after reset,
i.e. the beam is turned off. */
reset_vec() {
if(hwReadResetStatus()&RS_WATCHDOG) {
put_msg("Unexpected reset by watchdog. %d dosed before reset.",
hwReadDoseCounter()); /* assume dose counter persists across soft resets */
}
for(;;) { /* main loop */
struct treatment_params tp;
int c;
if(!hwPatientPresent()) {
put_msg("PC LOAD PATIENT");
wait_any_key();
}
while((c=get_key())!=KEY_START) {
/* do stuff with UI here, changes tp appropriately */
hwResetWatchdog();
}
put_msg("Are you sure you want to dose?");
if((c=get_key())==KEY_START) {
/* initialize the hardware and DOES NOT RETURN until
after everything is setup correctly */
hwInitialize(&tp);
hwDoseCounterReset();
put_msg("Dosing started. Press any key to abort.");
hwStartDosing(); /* HEKTIK DOSING! */
while(!hwKeyBufferNonEmpty() && hwPatientPresent()
&& tp.dose < hwReadDoseCounter())
hwWatchDogReset(); /* if the CPU hangs, the watchdog will reset it and stop dosing */
hwStopDosing();
if(!hwPatientPresent())
put_msg("Patient escaped!");
else
put_msg("Dosing %s after %d of %d units",
hwKeyBufferNonEmpty() ? "aborted" : "finished",
hwReadDoseCounter(), tp.dose);
}
}
}