old-trainOS/include/io.h

30 lines
493 B
C
Raw Normal View History

2015-08-09 00:42:56 +00:00
#pragma once
2015-08-13 12:56:50 +00:00
#include <inttypes.h>
#if defined(__cplusplus)
extern "C" {
#endif
2015-08-09 00:42:56 +00:00
/**
* @brief Outputs a byte on the given port.
* @param port The port number.
* @param data The byte to send.
*/
static inline void outb(uint16_t port, uint8_t data)
{
__asm__ volatile ("outb %0, %1" : : "a" (data), "Nd" (port));
}
2015-08-13 12:56:50 +00:00
static inline uint8_t inb(uint16_t port)
{
uint8_t data;
__asm__ volatile ("inb %1, %0" : "=a" (data) : "d" (port));
return data;
}
2015-08-13 12:56:50 +00:00
#if defined(__cplusplus)
}
#endif