/**************************************************************************************
 Copyright (c) 2002
      The UbixOS Project

 $Id: io.c,v 1.5 2002/04/26 22:52:45 reddawg Exp $
**************************************************************************************/

/* Input a byte from a port     */
inline unsigned char inportb_p(unsigned int port) {
  unsigned char ret;
  asm volatile ("inb %%dx,%%al;outb %%al,$0x80":"=a" (ret):"d" (port));
  return ret;
  }

/* Output a byte to a port      */
inline void outportb_p(unsigned int port,unsigned char value) {
  asm volatile ("outb %%al,%%dx;outb %%al,$0x80"::"d" (port), "a" (value));
  }

/* Output a word to a port      */
inline void outportw_p(unsigned int port,unsigned int value) {
  asm volatile ("outw %%ax,%%dx;outb %%al,$0x80"::"d" (port), "a" (value));
  }
 
/* Input a byte from a port     */
inline unsigned char inportb(unsigned int port) {
  unsigned char ret;
 
  asm volatile ("inb %%dx,%%al":"=a" (ret):"d" (port));
  return ret;
  }

/* Input a word from a port     */
inline unsigned char inportw(unsigned int port) {
  unsigned char ret;

  asm volatile ("inw %%dx,%%ax":"=a" (ret):"d" (port));
  return ret;
  }
 
/* Output a byte to a port      */
inline void outportb(unsigned int port,unsigned char value) {
  asm volatile ("outb %%al,%%dx"::"d" (port), "a" (value));
}
 
/* Output a word to a port      */
inline void outportw(unsigned int port,unsigned int value) {
  asm volatile ("outw %%ax,%%dx"::"d" (port), "a" (value));
  }
