feat(io): IoPort
This commit is contained in:
@@ -12,11 +12,21 @@ void* operator new(std::size_t size)
|
|||||||
return Memory::g_heap->Request(size);
|
return Memory::g_heap->Request(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* operator new[](std::size_t size)
|
||||||
|
{
|
||||||
|
return Memory::g_heap->Request(size);
|
||||||
|
}
|
||||||
|
|
||||||
void operator delete(void* block)
|
void operator delete(void* block)
|
||||||
{
|
{
|
||||||
Memory::g_heap->Free(block);
|
Memory::g_heap->Free(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void operator delete[](void* block)
|
||||||
|
{
|
||||||
|
delete block;
|
||||||
|
}
|
||||||
|
|
||||||
void operator delete(void* block, long unsigned int)
|
void operator delete(void* block, long unsigned int)
|
||||||
{
|
{
|
||||||
Memory::g_heap->Free(block);
|
Memory::g_heap->Free(block);
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* PortIo.hpp
|
||||||
|
* Inline Intel port IO functions
|
||||||
|
* Copyright (c) 2025 Daniel Hammer
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace Io {
|
||||||
|
// OSDev website has the parameters for out(b/w/l) in the opposite order in their example,
|
||||||
|
// (port, then value), but the manpage on GNU ('man outb') has it in this order.
|
||||||
|
|
||||||
|
inline void Out8(uint8_t value, uint16_t port) {
|
||||||
|
asm ("outb %0, %1" : : "a"(value), "Nd"(port) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Out16(uint16_t value, uint16_t port) {
|
||||||
|
asm ("outw %0, %1" : : "a"(value), "Nd"(port) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Out32(uint32_t value, uint16_t port) {
|
||||||
|
asm ("outl %0, %1" : : "a"(value), "Nd"(port) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint8_t In8(uint16_t port) {
|
||||||
|
asm ("inb %0" : : "Nd"(port) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint16_t In16(uint16_t port) {
|
||||||
|
asm ("inw %0" : : "Nd"(port) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint32_t In32(uint16_t port) {
|
||||||
|
asm ("inl %0" : : "Nd"(port) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void IoPortWait() {
|
||||||
|
Out8(0x80, 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
+1
-6
@@ -7,7 +7,6 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limine.h>
|
#include <limine.h>
|
||||||
|
|
||||||
#include <Hal/GDT.hpp>
|
#include <Hal/GDT.hpp>
|
||||||
#include <Terminal/Terminal.hpp>
|
#include <Terminal/Terminal.hpp>
|
||||||
#include <Libraries/String.hpp>
|
#include <Libraries/String.hpp>
|
||||||
@@ -16,20 +15,16 @@
|
|||||||
#include <Memory/Memmap.hpp>
|
#include <Memory/Memmap.hpp>
|
||||||
#include <Memory/Heap.hpp>
|
#include <Memory/Heap.hpp>
|
||||||
#include <Memory/HHDM.hpp>
|
#include <Memory/HHDM.hpp>
|
||||||
|
|
||||||
#include <CppLib/Stream.hpp>
|
#include <CppLib/Stream.hpp>
|
||||||
#include <CppLib/Vector.hpp>
|
#include <CppLib/Vector.hpp>
|
||||||
#include <CppLib/CString.hpp>
|
#include <CppLib/CString.hpp>
|
||||||
|
|
||||||
#include <Platform/Limine.hpp>
|
#include <Platform/Limine.hpp>
|
||||||
#include <Platform/Util.hpp>
|
#include <Platform/Util.hpp>
|
||||||
|
|
||||||
#include <Libraries/Memory.hpp>
|
#include <Libraries/Memory.hpp>
|
||||||
|
|
||||||
#include <Hal/IDT.hpp>
|
#include <Hal/IDT.hpp>
|
||||||
|
|
||||||
#include <Memory/PageFrameAllocator.hpp>
|
#include <Memory/PageFrameAllocator.hpp>
|
||||||
#include <Memory/HHDM.hpp>
|
#include <Memory/HHDM.hpp>
|
||||||
|
#include <Io/IoPort.hpp>
|
||||||
|
|
||||||
using namespace Kt;
|
using namespace Kt;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user