Refactors io.hpp: Now splits into asm.hpp with namespace ASM and io.hpp which exports the inb,outb function.

This commit is contained in:
Felix Queißner 2016-05-18 10:31:05 +02:00
parent 91b72ceb68
commit cb806c19ec
3 changed files with 34 additions and 12 deletions

View file

@ -0,0 +1,26 @@
#pragma once
namespace ASM
{
static inline void sti()
{
__asm__ volatile ("sti");
}
static inline void cli()
{
__asm__ volatile ("cli");
}
static inline void outb(uint16_t port, uint8_t data)
{
asm volatile ("outb %0, %1" : : "a" (data), "Nd" (port));
}
static inline uint8_t inb(uint16_t port)
{
uint8_t data;
asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
return data;
}
}

View file

@ -1,13 +1,7 @@
#pragma once
static inline void outb(uint16_t port, uint8_t data)
{
asm volatile ("outb %0, %1" : : "a" (data), "Nd" (port));
}
#include "asm.hpp"
static inline uint8_t inb(uint16_t port)
{
uint8_t data;
asm volatile ("inb %1, %0" : "=a" (data) : "d" (port));
return data;
}
// Import functions into global namespace
using ASM::inb;
using ASM::outb;

View file

@ -11,6 +11,8 @@
#include "elf.hpp"
#include "bsod.hpp"
#include "asm.hpp"
#include "driver/timer.hpp"
#include "driver/keyboard.hpp"
@ -185,7 +187,6 @@ extern "C" void init(Structure const & data)
Console::main << "Creating VMM Context...\n";
kernelContext = new (PMM::alloc().data()) VMMContext();
Console::main << "Mapping memory...\n";
for(uint32_t addr = 0; addr < 4096 * 1024; addr += 0x1000) {
kernelContext->map(
@ -209,7 +210,8 @@ extern "C" void init(Structure const & data)
Console::main << "Drivers installed.\n";
asm volatile("sti");
//asm volatile("sti");
ASM::sti();
Console::main << "Interrupts enabled.\n";