37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
|
|
#pragma once
|
|
|
|
#if !defined(BAD_APPLE_OS_PORT_HPP_INCLUDED)
|
|
#define BAD_APPLE_OS_PORT_HPP_INCLUDED
|
|
|
|
#include <cstdint>
|
|
|
|
#define writePortByte(port, value) \
|
|
{ \
|
|
__asm__ __volatile__( \
|
|
"outb %0, %1" \
|
|
: \
|
|
: "a"(static_cast<std::uint8_t>(value)), \
|
|
"Nd"(static_cast<std::uint16_t>(port)) \
|
|
); \
|
|
}
|
|
|
|
#define readPortByte(port) \
|
|
[&]() \
|
|
{ \
|
|
std::uint8_t value = 0; \
|
|
__asm__ __volatile__( \
|
|
"inb %1, %0" \
|
|
: "=a"(value) \
|
|
: "Nd"(static_cast<std::uint16_t>(port)) \
|
|
); \
|
|
return value; \
|
|
}()
|
|
|
|
inline void ioWait() noexcept
|
|
{
|
|
writePortByte(0x80, 0);
|
|
}
|
|
|
|
#endif // !defined(BAD_APPLE_OS_PORT_HPP_INCLUDED)
|