/* iobitmap.c * Trival test program for checking the functioning of the x86 ioport bitmap. * * Copyright 2002 Red Hat, Inc. Written by Benjamin LaHaise. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include int main (void) { pid_t pid; int val, status = 0; if (ioperm(0x80, 0x80, 1)) { perror("ioperm(0x80, 0x80, 1) failed"); return 1; } val = inb(0x80); printf("read 0x%02x from io port. okay.\n", val); pid = fork(); if (-1 == pid) { perror("fork failed"); return 1; } if (0 == pid) { val = inb(0x80); printf("child read 0x%02x from io port. okay.\n", val); return 0; } if (-1 == waitpid(pid, &status, 0)) { perror("waitpid failed"); return 1; } if (WIFEXITED(status)) { printf("child exited with status %d\n", WEXITSTATUS(status)); return WEXITSTATUS(status) == 0 ? 0 : 1; } printf("unknown exit status 0x%04x\n", status); return 1; }