initial checkin from subversion
This commit is contained in:
52
parport-io.c
Normal file
52
parport-io.c
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
|
||||
void PortOpen(int port);
|
||||
void PortClose(int pPort);
|
||||
void PortWrite(int pPort, unsigned char val);
|
||||
unsigned int PortRead(int pPort);
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
//* #include "port.h"
|
||||
|
||||
void PortClose(int pPort)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioperm(pPort, 4, 0);
|
||||
if (ret != 0) {
|
||||
printf("Error: ioperm(%d,4,0): %d '%s'\n",
|
||||
pPort,errno, sys_errlist[errno] );
|
||||
exit(-1);
|
||||
}
|
||||
printf( "SUCCESS: ioperm(%d,4,0) .. %d\n", pPort, ret );
|
||||
}
|
||||
|
||||
void PortOpen(int pPort)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ioperm(pPort, 4, 1);
|
||||
if (ret != 0) {
|
||||
printf("Error: ioperm(%d,4,1): %d '%s'\n",
|
||||
pPort,errno, sys_errlist[errno] );
|
||||
exit(-1);
|
||||
}
|
||||
printf( "SUCCESS: ioperm(%d,4,1) .. %d\n", pPort, ret );
|
||||
}
|
||||
|
||||
unsigned int PortRead(int pPort)
|
||||
{
|
||||
// return( (inb(pPort)<<8) + inb(pPort+1));
|
||||
return( inb(pPort) );
|
||||
}
|
||||
|
||||
void PortWrite(int pPort, unsigned char val)
|
||||
{
|
||||
outb(val, pPort);
|
||||
}
|
||||
Reference in New Issue
Block a user