2018-10-16 12:01:38 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
namespace IO {
|
|
|
|
|
2018-11-02 11:49:10 +03:00
|
|
|
inline byte in8(word port)
|
|
|
|
{
|
|
|
|
byte value;
|
|
|
|
asm volatile("inb %1, %0":"=a"(value):"Nd"(port));
|
|
|
|
return value;
|
|
|
|
}
|
2018-10-16 12:01:38 +03:00
|
|
|
|
2018-11-02 11:49:10 +03:00
|
|
|
inline word in16(word port)
|
|
|
|
{
|
|
|
|
word value;
|
|
|
|
asm volatile("inw %1, %0":"=a"(value):"Nd"(port));
|
|
|
|
return value;
|
|
|
|
}
|
2018-10-16 12:01:38 +03:00
|
|
|
|
2019-02-06 12:17:26 +03:00
|
|
|
inline dword in32(word port)
|
2018-11-02 11:49:10 +03:00
|
|
|
{
|
|
|
|
dword value;
|
|
|
|
asm volatile("inl %1, %0":"=a"(value):"Nd"(port));
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void out8(word port, byte value)
|
|
|
|
{
|
|
|
|
asm volatile("outb %0, %1"::"a"(value), "Nd"(port));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void out16(word port, word value)
|
|
|
|
{
|
|
|
|
asm volatile("outw %0, %1"::"a"(value), "Nd"(port));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void out32(word port, dword value)
|
|
|
|
{
|
|
|
|
asm volatile("outl %0, %1"::"a"(value), "Nd"(port));
|
|
|
|
}
|
2018-10-16 12:01:38 +03:00
|
|
|
}
|