Added PIC initialization and keyboard.
This commit is contained in:
36
targets/_any/include/os/port.hpp
Normal file
36
targets/_any/include/os/port.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
#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)
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "./port.hpp"
|
||||
|
||||
inline constexpr std::uint16_t PORT_COM1 = 0x3F8;
|
||||
inline constexpr std::uint16_t PORT_COM2 = 0x2F8;
|
||||
inline constexpr std::uint16_t PORT_COM3 = 0x3E8;
|
||||
@@ -15,26 +17,6 @@ inline constexpr std::uint16_t PORT_COM6 = 0x4F8;
|
||||
inline constexpr std::uint16_t PORT_COM7 = 0x5E8;
|
||||
inline constexpr std::uint16_t PORT_COM8 = 0x4E8;
|
||||
|
||||
inline void writePortByte(std::uint16_t port, std::uint8_t value) noexcept
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"outb %0, %1"
|
||||
:
|
||||
: "a"(value), "Nd"(port)
|
||||
);
|
||||
}
|
||||
|
||||
inline std::uint8_t readPortByte(std::uint16_t port) noexcept
|
||||
{
|
||||
std::uint8_t value = 0;
|
||||
__asm__ __volatile__(
|
||||
"inb %1, %0"
|
||||
: "=a"(value)
|
||||
: "Nd"(port)
|
||||
);
|
||||
return value;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool initSerialPort(std::uint16_t port) noexcept
|
||||
{
|
||||
writePortByte(port + 1, 0x00); // Disable all interrupts
|
||||
|
||||
Reference in New Issue
Block a user