+
+scankbd() {
+u_char c;
+
+ c = inb(0x60);
+ if (c == 0xaa) { odt = 0x2a; return (0); }
+ if (c == 0xfa) { odt = 0x7a; return (0); }
+ c &= 0x7f;
+
+ if ( (odt&0x7f) == c )return(0);
+ if(odt == 0) { odt = c; return(0); }
+ return(kbd());
+}
+
+kbdreset()
+{
+ u_char c;
+
+ /* Enable interrupts and keyboard controller */
+ while (inb(0x64)&2); outb(0x64,0x60);
+ while (inb(0x64)&2); outb(0x60,0x4D);
+
+ /* Start keyboard stuff RESET */
+ while (inb(0x64)&2); /* wait input ready */
+ outb(0x60,0xFF); /* RESET */
+
+ while((c=inb(0x60))!=0xFA) ;
+
+ /* While we are here, defeat gatea20 */
+ while (inb(0x64)&2); /* wait input ready */
+ outb(0x64,0xd1);
+ while (inb(0x64)&2); /* wait input ready */
+ outb(0x60,0xdf);
+}
+
+u_char getchar() {
+ u_char c;
+
+ c = kbd();
+ if (c == '\b' || c == '\177') return(c);
+ if (c == '\r') c = '\n';
+ putchar(c);
+ return(c);
+}
+
+reset_cpu() {
+
+ while (inb(0x64)&2); /* wait input ready */
+ outb(0x64,0xFE); /* Reset Command */
+ wait(4000000);
+ /* NOTREACHED */
+}