rendered paste body/* The deadly-inefficient cmd.c of PerlOS Kernel2 0.25a */
void kprintf(const char *fmt, ...);
void select_vc(unsigned which_vc);
void putch(unsigned c);
static int write(const unsigned char *str, unsigned len);
void wait(void);
void checkcmd(unsigned char cmd[], unsigned char params[]);
static void reboot(unsigned char message[]);
extern unsigned _printsh;
void diskinfo();
void checkcmd(unsigned char cmd[], unsigned char params[])
{
kprintf("\nCommand passed: %s with params: %s\n",cmd,params);
kprintf("chrlen:%u\n",sizeof(cmd));
kprintf("\"%s\"\n",cmd);
if(cmd == "reboot")
{
reboot(params);
}
else if(cmd == "diskinfo")
{
diskinfo();
}
kprintf("\n");
_printsh = 1;
}
static void reboot(unsigned char message[])
{
unsigned temp;
disable();
/* flush the keyboard controller */
do
{
temp = inportb(0x64);
if((temp & 0x01) != 0)
{
(void)inportb(0x60);
continue;
}
} while((temp & 0x02) != 0);
kprintf("reboot: %s\n\n\n",message);
/* pulse the CPU reset line */
kprintf("* setting tasklevel: 1\t\t");
tasklevel(1);
kprintf("* rebooting..\t\t");
// outportb(0x64, 0xFE);
/* ...and if that didn't work, just halt */
kprintf("[failed]\n");
while(1)
/* nothing */;
}