00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <stdio.h>
00034 #include "pcioDrv.h"
00035 #include "iodev.h"
00036
00037 static int pcioDrvId = 0;
00038
00039
00040 void
00041 pcioInit()
00042 {
00043 if ((pcioDrvId = open("/dev/pcio", 0)) < 0)
00044 {
00045 fprintf(stderr, "pcioInit: can't open /dev/pcio");
00046 }
00047 }
00048
00049 unsigned char
00050 inputb( unsigned short port )
00051 {
00052 struct _ioValStruct arg;
00053 arg.address = port;
00054 if (0 == pcioDrvId)
00055 pcioInit();
00056 ioctl( pcioDrvId, READ_8, &arg );
00057 return arg.value;
00058 }
00059
00060 void
00061 outputb( unsigned short port, unsigned char data )
00062 {
00063 struct _ioValStruct arg;
00064 arg.address = port;
00065 arg.value = data;
00066 if (0 == pcioDrvId)
00067 pcioInit();
00068 ioctl( pcioDrvId, WRITE_8, &arg );
00069 }
00070
00071 unsigned short
00072 inputw( unsigned short port )
00073 {
00074 struct _ioValStruct arg;
00075 arg.address = port;
00076 if (0 == pcioDrvId)
00077 pcioInit();
00078 ioctl( pcioDrvId, READ_16, &arg );
00079 return arg.value;
00080 }
00081
00082 void
00083 outputw( unsigned short port, unsigned short data )
00084 {
00085 struct _ioValStruct arg;
00086 arg.address = port;
00087 arg.value = data;
00088 if (0 == pcioDrvId)
00089 pcioInit();
00090 ioctl( pcioDrvId, WRITE_16, &arg );
00091 }
00092
00093 unsigned long
00094 inputl( unsigned short port )
00095 {
00096 struct _ioValStruct arg;
00097 arg.address = port;
00098 if (0 == pcioDrvId)
00099 pcioInit();
00100 ioctl( pcioDrvId, READ_32, &arg );
00101 return arg.value;
00102 }
00103
00104 void
00105 outputl( unsigned short port, unsigned long data )
00106 {
00107 struct _ioValStruct arg;
00108 arg.address = port;
00109 arg.value = data;
00110 if (0 == pcioDrvId)
00111 pcioInit();
00112 ioctl( pcioDrvId, WRITE_32, &arg );
00113 }