aboutsummaryrefslogtreecommitdiff
path: root/i686/sys
diff options
context:
space:
mode:
Diffstat (limited to 'i686/sys')
-rw-r--r--i686/sys/control.h25
-rw-r--r--i686/sys/cpuid.h35
-rw-r--r--i686/sys/io.h102
-rw-r--r--i686/sys/io.hpp33
-rw-r--r--i686/sys/syscall.h8
5 files changed, 0 insertions, 203 deletions
diff --git a/i686/sys/control.h b/i686/sys/control.h
deleted file mode 100644
index 7dde3c8..0000000
--- a/i686/sys/control.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma once
-
-static inline void
-abort()
-{
- /* Symbol h is already defined?
-asm volatile(R"(cli
-h: hlt
-jmp h)");
-*/
- asm volatile(R"(cli
-hlt)");
-}
-
-static inline void
-enable_interrupts()
-{
- asm volatile("sti");
-}
-
-static inline void
-disable_interrupts()
-{
- asm volatile("cli");
-}
diff --git a/i686/sys/cpuid.h b/i686/sys/cpuid.h
deleted file mode 100644
index 65b43c6..0000000
--- a/i686/sys/cpuid.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#pragma once
-
-#include <cpuid.h>
-
-struct CPUVersion {
- unsigned int stepping : 4;
- unsigned int model : 4;
- unsigned int family : 4;
- unsigned int type : 2;
- unsigned int __unused_1 : 2;
- unsigned int model_ex : 4;
- unsigned int family_ex : 8;
- unsigned int __unused_2 : 4;
-} __attribute__((packed, aligned(__alignof__(unsigned int))));
-// FIXME _Static_assert(sizeof(struct CPUVersion) == sizeof(unsigned int), "cpuid version struct size");
-
-unsigned int
-family(const struct CPUVersion v)
-{
- if (v.family == 0x0f) return v.family + v.family_ex;
- else
- return v.family;
-}
-
-unsigned int
-model(const struct CPUVersion v)
-{
- switch (v.family) {
- case 0x06:
- case 0x0f:
- return ((unsigned int)v.model_ex << 4) | v.model;
- default:
- return v.model;
- }
-}
diff --git a/i686/sys/io.h b/i686/sys/io.h
deleted file mode 100644
index b6c24c5..0000000
--- a/i686/sys/io.h
+++ /dev/null
@@ -1,102 +0,0 @@
-#pragma once
-
-// port listings
-enum UART {
- COM1 = 0x3f8,
- COM2 = 0x2f8,
- COM3 = 0x3e8,
- COM4 = 0x2e8,
- COM5 = 0x5f8,
- COM6 = 0x4f8,
- COM7 = 0x5e8,
- COM8 = 0x4e8,
-};
-enum UARTPortOffset {
- Data = 0, // read from receive buffer / write to transmit buffer | BaudDiv_l
- InterruptControl = 1, // interrupt enable | BaudDiv_h
- FifoControl = 2, // interrupt ID and FIFO control
- LineControl = 3, // most significant bit is the DLAB
- ModemControl = 4,
- LineStatus = 5,
- ModemStatus = 6,
- Scratch = 7,
-};
-
-static inline void
-outb(unsigned char val, unsigned short port)
-{
- asm volatile("outb %0,%1" : : "a"(val), "dN"(port));
-}
-
-static inline void
-outw(unsigned short val, unsigned short port)
-{
- asm volatile("outw %0,%1" : : "a"(val), "dN"(port));
-}
-
-static inline void
-outl(unsigned int val, unsigned short port)
-{
- asm volatile("outl %0,%1" : : "a"(val), "dN"(port));
-}
-
-static inline unsigned char
-inb(unsigned short port)
-{
- unsigned char val;
- asm volatile("inb %1,%0" : "=a"(val) : "dN"(port));
- return val;
-}
-
-static inline unsigned short
-inw(unsigned short port)
-{
- unsigned short val;
- asm volatile("inw %1,%0" : "=a"(val) : "dN"(port));
- return val;
-}
-
-static inline unsigned int
-inl(unsigned short port)
-{
- unsigned int val;
- asm volatile("inl %1,%0" : "=a"(val) : "dN"(port));
- return val;
-}
-
-static inline void
-outsb(unsigned short port, const void *__buf, unsigned long __n)
-{
- asm volatile("cld; rep; outsb" : "+S"(__buf), "+c"(__n) : "d"(port));
-}
-
-static inline void
-outsw(unsigned short port, const void *__buf, unsigned long __n)
-{
- asm volatile("cld; rep; outsw" : "+S"(__buf), "+c"(__n) : "d"(port));
-}
-
-static inline void
-outsl(unsigned short port, const void *__buf, unsigned long __n)
-{
- asm volatile("cld; rep; outsl" : "+S"(__buf), "+c"(__n) : "d"(port));
-}
-
-static inline void
-insb(unsigned short port, void *__buf, unsigned long __n)
-{
- asm volatile("cld; rep; insb" : "+D"(__buf), "+c"(__n) : "d"(port));
-}
-
-static inline void
-insw(unsigned short port, void *__buf, unsigned long __n)
-{
- asm volatile("cld; rep; insw" : "+D"(__buf), "+c"(__n) : "d"(port));
-}
-
-static inline void
-insl(unsigned short port, void *__buf, unsigned long __n)
-{
- asm volatile("cld; rep; insl" : "+D"(__buf), "+c"(__n) : "d"(port));
-}
-
diff --git a/i686/sys/io.hpp b/i686/sys/io.hpp
deleted file mode 100644
index 9759a3a..0000000
--- a/i686/sys/io.hpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#pragma once
-
-/**
- * Ports provide communication with devices on the x86 IO bus.
- */
-template <typename T, unsigned short port> struct Port {
- /**
- * Read value from port
- */
- static T
- in(unsigned short offset = 0)
- {
- if constexpr (sizeof(T) == sizeof(unsigned char)) return inb(port + offset);
- else if constexpr (sizeof(T) == sizeof(unsigned short))
- return inw(port + offset);
- else if constexpr (sizeof(T) == sizeof(unsigned int))
- return inl(port + offset);
- }
-
- /**
- * Write value to port
- */
- static void
- out(T val, unsigned short offset = 0)
- {
- if constexpr (sizeof(T) == sizeof(unsigned char)) outb(val, port + offset);
- else if constexpr (sizeof(T) == sizeof(unsigned short))
- outw(val, port + offset);
- else if constexpr (sizeof(T) == sizeof(unsigned int))
- outl(val, port + offset);
- }
-
-};
diff --git a/i686/sys/syscall.h b/i686/sys/syscall.h
deleted file mode 100644
index 9e62c89..0000000
--- a/i686/sys/syscall.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-
-static inline int
-syscall(int number)
-{
- asm volatile("int $0x80");
- return 0;
-}