-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathkbd-reboot.c
More file actions
39 lines (33 loc) · 723 Bytes
/
Copy pathkbd-reboot.c
File metadata and controls
39 lines (33 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
https://www.basicinputoutput.com/2024/11/the-keyboard-controller-interface.html
apt install ioport; outb 0x64 0xFE
pci reboot; outb 0xcf9 0x06 #warm, 0x0e for cold
reboot -ff
rmmod usbhid # disable kbd input
*/
#include <unistd.h>
#include <stdio.h>
#ifdef BSD
#include <err.h>
#include <machine/sysarch.h>
#include <machine/cpufunc.h>
#else
#include <sys/io.h>
#endif
int main(int argc, char** argv)
{
/* iopl()
inb() */
if (getuid()!=0) {
printf("Must be root to run %s, you're only %u.\n",argv[0],getuid());
return 1;
}
#ifdef BSD
if (i386_set_ioperm(0x60,5,1) == -1)
err(1,"i386_set_ioperm failed");
#else
iopl(3);
#endif
outb(0xFE,0x64);
return 0;
}