#pragma once #if !defined(BAD_APPLE_OS_PORT_HPP_INCLUDED) #define BAD_APPLE_OS_PORT_HPP_INCLUDED #include #define writePort8(port, value) \ { \ __asm__ __volatile__( \ "outb %0, %1" \ : \ : "a"(static_cast(value)), \ "Nd"(static_cast(port)) \ ); \ } #define readPort8(port) \ [&]() \ { \ std::uint8_t value = 0; \ __asm__ __volatile__( \ "inb %1, %0" \ : "=a"(value) \ : "Nd"(static_cast(port)) \ ); \ return value; \ }() #define writePort16(port, value) \ { \ __asm__ __volatile__( \ "outw %0, %1" \ : \ : "a"(static_cast(value)), \ "Nd"(static_cast(port)) \ ); \ } #define readPort16(port) \ [&]() \ { \ std::uint16_t value = 0; \ __asm__ __volatile__( \ "inw %1, %0" \ : "=a"(value) \ : "Nd"(static_cast(port)) \ ); \ return value; \ }() #define writePort32(port, value) \ { \ __asm__ __volatile__( \ "outl %0, %1" \ : \ : "a"(static_cast(value)), \ "Nd"(static_cast(port)) \ ); \ } #define readPort32(port) \ [&]() \ { \ std::uint32_t value = 0; \ __asm__ __volatile__( \ "inl %1, %0" \ : "=a"(value) \ : "Nd"(static_cast(port)) \ ); \ return value; \ }() inline void ioWait() noexcept { writePort8(0x80, 0); } #endif // !defined(BAD_APPLE_OS_PORT_HPP_INCLUDED)