41 lines
939 B
C
41 lines
939 B
C
// io.h
|
|
// Author: Josh Holtrop
|
|
// Created: 02/26/04
|
|
// Implements basic port input/output functions
|
|
|
|
#ifndef __HOS_IO__
|
|
#define __HOS_IO__ __HOS_IO__
|
|
|
|
#include "hos_defines.h"
|
|
|
|
//void outportb(unsigned int port, unsigned char value);
|
|
//inline void outportw(unsigned int port, unsigned int value);
|
|
//inline unsigned char inportb(unsigned short port);
|
|
|
|
//Writes a byte out to a port
|
|
static inline void outportb(unsigned int port, unsigned char value) // Output a byte to a port
|
|
{
|
|
asm volatile ("outb %%al,%%dx"::"d" (port), "a" (value));
|
|
}
|
|
|
|
//Writes a word out to a port
|
|
static inline void outportw(unsigned int port, unsigned int value) // Output a word to a port
|
|
{
|
|
asm volatile ("outw %%ax,%%dx"::"d" (port), "a" (value));
|
|
}
|
|
|
|
//Reads a byte from a port
|
|
static inline unsigned char inportb(unsigned short port)
|
|
{
|
|
unsigned char ret_val;
|
|
|
|
asm volatile("inb %w1,%b0"
|
|
: "=a"(ret_val)
|
|
: "d"(port));
|
|
return ret_val;
|
|
}
|
|
|
|
#endif
|
|
|
|
|