aboutsummaryrefslogtreecommitdiffstats
path: root/portio.hpp
blob: 0a10651d213493c78f712987f08bbc6c75b11571 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef PORTIO_HPP
#define PORTIO_HPP

#include <cstdint>

inline void outb(std::uint16_t port, std::uint8_t val)
{
    asm volatile("outb %b0, %w1" :: "a"(val), "Nd"(port) : "memory");
}

inline std::uint8_t inb(std::uint16_t port)
{
    std::uint8_t val;
    asm volatile("inb %w1, %b0" : "=a"(val) : "Nd"(port) : "memory");
    return val;
}
 
inline void io_wait()
{
    outb(0x80, 0);
}

#endif // PORTIO_HPP