Sunday, 11 March 2012

Rebooting Operating System

Eva Os Reboot

                                 How To ReBooT??

Keyboard - reboot via the keyboard controller. The original IBM PC had the CPU reset line tied to the keyboard controller. Writing the appropriate magic value pulses the line and the machine resets. This is all very straightforward, except for the fact that modern machines don't have keyboard controllers (they're actually part of the embedded controller) and even more modern machines don't even pretend to have a keyboard controller. Now, embedded controllers run software. But i am using this method in my Eva Operating System because its the easiest way i came across and right now i dont have any other choice, but in future  i'll try my best to do it with PCI or ACPI.

 // eva.c 
 //      @author<Vishal Mishra><>
//           @change fri-Mar-11,19:01 
void reboot(void)
        char temp;

       asm volatile("cli");
        /* flush the keyboard controller */
                temp = inb(0x64);
                if (temp & 1)
        }while(temp & 2);

        /* send the CPU reset line */
        outb(0x64, 0xFE);

        asm volatile("hlt");

Triple Fault -A triple fault is a special kind of exception generated by the CPU when an exception occurs while the CPU is trying to invoke the double fault exception handler, which itself handles exceptions occurring while trying to invoke a regular exception handler.
x86 processors beginning with the 80286 will cause a shutdown cycle to occur when a triple fault is encountered. This typically causes the motherboard hardware to initiate a CPU reset which in turn causes the whole computer to reboot. attempt to generate a triple fault. This is done by loading an empty interrupt descriptor table and then calling int(3). The interrupt fails (there's no IDT), the fault handler fails (there's no IDT) and the CPU enters a condition which should, in theory, then trigger a reset. Except there doesn't seem to be a requirement that this happen and it just doesn't work on a bunch of machines.

PCI - Traditional PCI config space access is achieved by writing a 32 bit value to io port 0xcf8 to identify the bus, device, function and config register. Port 0xcfc then contains the register in question. But if you write the appropriate pair of magic values to 0xcf9, the machine will reboot. Spectacular! And not standardised in any way (certainly not part of the PCI spec), so different chipsets may have different requirements. 

EFI -The Unified Extensible Firmware Interface (UEFI) is a specification that defines a software interface between an operating system and platform firmware.
The original EFI (Extensible Firmware Interface) specification was developed by Intel. In 2005, development of the EFI specification ceased in favor of UEFI, which had evolved from EFI 1.10.
EFI runtime services provide an entry point to reboot the machine. It usually even works! As long as EFI runtime services are working at all, which may be a stretch.

ACPI -the Advanced Configuration and Power Interface (ACPI) specification provides an open standard for device configuration and power management by the operating system.
 Recent versions of the ACPI  let you provide an address (typically memory or system IO space) and a value to write there. The idea is that writing the value to the address resets the system. It turns out that doing so often fails. It's also impossible to represent the PCI reboot method via ACPI, because the PCI reboot method requires a pair of values and ACPI only gives you one.


Post a Comment