Files
lcdproc/server/drivers/port.h
T

52 lines
956 B
C
Raw Normal View History

1999-12-09 23:15:14 +00:00
/*-----------------------------------------------------------------------------
* port.h (by damianf@wpi.edu)
* Low level I/O functions taken from led-stat.txt
*
* Jan 22 95
*
* DOS part (tested only with DOS version of GCC, DJGPP)
* by M.Prinke <m.prinke@trashcan.mcnet.de> 3/97
*/
/* #define DOS */
#ifndef PORT_H
#define PORT_H
#endif
#ifndef DOS
static inline int
port_in (int port)
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
unsigned char value;
__asm__ volatile ("inb %1,%0":"=a" (value)
:"d" ((unsigned short) port));
return value;
1999-12-09 23:15:14 +00:00
}
static inline void
port_out (unsigned short int port, unsigned char val)
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
__asm__ volatile ("outb %0,%1\n"::"a" (val), "d" (port)
);
1999-12-09 23:15:14 +00:00
}
#else
#include <pc.h>
static inline int
port_in (int port)
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
unsigned char value;
value = inportb ((unsigned short) port);
return (int) value;
1999-12-09 23:15:14 +00:00
}
static inline void
port_out (unsigned int port, unsigned char val)
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
outportb ((unsigned short) port, val);
1999-12-09 23:15:14 +00:00
}
#endif
/**** END OF FILE ****/