30 lines
874 B
C++
30 lines
874 B
C++
|
|
#pragma once
|
|
|
|
#if !defined(BAD_APPLE_OS_KERNEL_PIC_HPP_INCLUDED)
|
|
#define BAD_APPLE_OS_KERNEL_PIC_HPP_INCLUDED
|
|
|
|
#include <cstdint>
|
|
|
|
#include "os/interrupt.hpp"
|
|
#include "os/port.hpp"
|
|
|
|
inline constexpr std::uint16_t PORT_PIC1 = 0x20;
|
|
inline constexpr std::uint16_t PORT_PIC2 = 0xA0;
|
|
inline constexpr std::uint8_t PIC_CMD_EOI = 0x20;
|
|
|
|
[[nodiscard]] bool initPICs(std::uint8_t masterOffset, std::uint8_t slaveOffset) noexcept;
|
|
__attribute__((no_caller_saved_registers))
|
|
void sendEndOfInterrupt(std::uint8_t irq) noexcept;
|
|
void maskIRQ(std::uint8_t irq) noexcept;
|
|
void unmaskIRQ(std::uint8_t irq) noexcept;
|
|
[[nodiscard]] std::uint16_t readPICIRR() noexcept;
|
|
[[nodiscard]] std::uint16_t readPICISR() noexcept;
|
|
|
|
[[nodiscard]] constexpr bool isValidPICOffset(std::uint8_t offset) noexcept
|
|
{
|
|
return (offset & 7) == 0;
|
|
}
|
|
|
|
#endif // !defined(BAD_APPLE_OS_KERNEL_PIC_HPP_INCLUDED)
|