Created
April 19, 2026 20:35
-
-
Save khanzf/9605fb5a9c052a863d9db58653edce3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <fcntl.h> | |
| #include <unistd.h> | |
| #include <machine/cpufunc.h> | |
| int main() { | |
| /* Opening /dev/io grants the process permission to use outb/inb | |
| instructions on FreeBSD x86/amd64 systems. */ | |
| int fd = open("/dev/io", O_RDWR); | |
| if (fd == -1) { | |
| perror("open /dev/io (Are you root?)"); | |
| printf("Note: Ensure 'io' device is available or use 'kldload io'\n"); | |
| return 1; | |
| } | |
| printf("Permission granted. Triggering hard reset via port 0xcf9...\n"); | |
| /* * Port 0xcf9: Reset Control Register | |
| * Value 0x06: | |
| * Bit 1 (SYS_RST): System Reset | |
| * Bit 2 (RST_CPU): Reset CPU | |
| */ | |
| outb(0xcf9, 0x06); | |
| /* If it hasn't rebooted yet, the CPU might need a moment to process */ | |
| usleep(10000); | |
| close(fd); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment