#include "serial.hpp"
namespace {
- void outb(std::uint16_t port, std::uint8_t data) {
- asm volatile ("outb %1,%0" : : "dN"(port), "a"(data));
- }
- std::uint8_t inb(std::uint16_t port) {
- std::uint8_t data;
- asm volatile ("inb %1,%0" : "=a"(data) : "dN"(port));
- return data;
- }
}
bool os::init_serial_port() {
#include "utils.hpp"
+void os::cli() {
+ asm volatile("cli");
+}
+void os::sti() {
+ asm volatile("sti");
+}
+void os::hlt() {
+ asm volatile("hlt");
+}
+
void os::halt() {
- asm volatile (
- "cli\n"
- "\t1:\thlt\n"
- "\tjmp 1b"
- );
+ cli();
+ while (true) {
+ hlt();
+ }
+}
+
+void os::outb(std::uint16_t port, std::uint8_t data) {
+ asm volatile ("outb %1,%0" : : "dN"(port), "a"(data));
+}
+std::uint8_t os::inb(std::uint16_t port) {
+ std::uint8_t data;
+ asm volatile ("inb %1,%0" : "=a"(data) : "dN"(port));
+ return data;
}
#pragma once
+#include <cstdint>
+
namespace os {
+void cli();
+void sti();
+void hlt();
void halt();
+void outb(std::uint16_t port, std::uint8_t data);
+std::uint8_t inb(std::uint16_t port);
} // namespace os