#ifndef __PHYSIO_HELPERS_H #define __PHYSIO_HELPERS_H #include #include "disk.h" /* * 8 bits helpers */ #define OUT8(port, value) \ _out(port, value & 0xFF); #define IN8(var, port) \ var = _in(port); /* * 16 bits helpers */ #ifdef BIG_ENDIAN #define OUT16(port, value) \ _out(port, (value >> 8) & 0xFF); \ _out(port+1, value & 0xFF); #define IN16(var, port) \ var = _in(port) << 8; \ var |= _in(port+1); #else #define OUT16(port, value) \ _out(port, (value >> 8) & 0xFF); \ _out(port+1, value & 0xFF); #define IN16(var, port) \ var = _in(port) << 8; \ var |= _in(port+1); #endif /* * 32 bits helpers */ #ifdef BIG_ENDIAN #define OUT32(port, value) \ _out(port, (value >> 24) & 0xFF); \ _out(port+1, (value >> 16) & 0xFF); \ _out(port+2, (value >> 8) & 0xFF); \ _out(port+3, value & 0xFF); #define IN32(var, port) \ var = _in(port) << 24; \ var |= _in(port+1) << 16; \ var |= _in(port+2) << 8; \ var |= _in(port+3); #else #define OUT32(port, value) \ _out(port, (value >> 24) & 0xFF); \ _out(port+1, (value >> 16) & 0xFF); \ _out(port+2, (value >> 8) & 0xFF); \ _out(port+3, value & 0xFF); #define IN32(var, port) \ var = _in(port) << 24; \ var |= _in(port+1) << 16; \ var |= _in(port+2) << 8; \ var |= _in(port+3); #endif /* * MISC Macros */ #define WAIT_HDD() \ _sleep(HDA_IRQ); #endif /* __PHYSIO_HELPERS_H */