#include #include #include #include #include #include int main(int argc, char *argv[]) { struct i386_ioperm_args ioperm; int error, i, port; for (i = 1; i < argc; i++) { port = strtol(argv[i], NULL, 0); ioperm.start = port; ioperm.length = 1; ioperm.enable = 1; error = sysarch(I386_SET_IOPERM, &ioperm); if (error) { perror("i386_set_ioperm"); exit(1); } } port = 0; while (port < 65536) { ioperm.start = port; ioperm.length = -1; error = sysarch(I386_GET_IOPERM, &ioperm); if (error) { perror("i386_set_ioperm"); exit(1); } assert(ioperm.length >= 0); if (ioperm.length == 0) { break; } if (ioperm.enable) { printf("Enabled: 0x%04x - 0x%04x\n", ioperm.start, ioperm.start + ioperm.length - 1); } port += ioperm.length; } for (i = 1; i < argc; i++) { port = strtol(argv[i], NULL, 0); printf("inb[%d] = 0x%02x\n", port, inb(port)); outb(port, 0xA5); } }