I have a new to me machine. I'd like to find out if its capable of rebooting using all seven methods of rebooting. I know I can simply use the reboot=? command in the kernel command line in grub or lilo.
When I peruse the kernel source I see that native_machine_emergency_restart will try my selection, but if that fails it will try something else until it succeeds or loops forever.
I'd like a to write a test utility that would write a line to a log file and then try reboot method x, if it was still running after trying this method it would simply exit with and error code.
I was able to do the keyboard method, PCIreset method, but when I try the triple fault method, instead of rebooting I get a segmentation fault. I think this is because my program isn't running in ring zero.
Since I feel certain I will encounter the same difficulties as I progress further I was wondering If I could get some direction on how to accomplish this task.
here is the code for triple fault
Quote:
#include <unistd.h>
#include <stdio.h>
#include <sys/io.h>
static inline void lidt(int *p, int size) {
volatile unsigned short pd[3];
pd[0] = sizeof(int);
pd[1] = (unsigned short )p;
pd[2] = (unsigned short )p >> 16;
asm volatile("lidt (%0)" : : "r" (pd));
} /* end lidt */
int main ( int argc, char *argv[] ) {
int zero = 0;
/* asm("movl 0x0, %eax
lidt %eax
int 0x1" );
*/
lidt( &zero , sizeof( zero) );
__asm__ ( "int $0x00");
} /* end main */
|
regards Tom Bodine