00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef linux
00014
00015 #include <stdio.h>
00016 #include <stdlib.h>
00017
00018 int main()
00019 {
00020 printf("outb doesn't work on this platform.\n");
00021 exit(-1);
00022 }
00023
00024 #else
00025
00026 #include <unistd.h>
00027 #include <sys/io.h>
00028 #include <sys/types.h>
00029 #include <stdio.h>
00030 #include <string.h>
00031 #include <stdlib.h>
00032 #include <signal.h>
00033
00034
00035 int main(int argc, char **argv)
00036 {
00037 unsigned long port;
00038 char val;
00039
00040 if(argc < 2)
00041 {
00042 printf("usage: <port> <value>\n");
00043 exit(-1);
00044 }
00045
00046 port = strtoul(argv[1],NULL,0);
00047 val = (char) strtol(argv[2],NULL,0);
00048 if(geteuid() && getuid())
00049 {
00050 printf("Must be root for this program to work.\n");
00051 exit(-1);
00052 }
00053
00054 if(-1 == iopl(3))
00055 {
00056 printf("Can't set privaledge level.\n");
00057 }
00058 outb(port,val);
00059 }
00060 #endif