aboutsummaryrefslogtreecommitdiff
path: root/i686/sys
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2022-12-10 20:56:57 +0200
committeraqua <aqua@iserlohn-fortress.net>2022-12-11 11:32:51 +0200
commit9b2a78fa52249ab481493550490aa5f37872dcf6 (patch)
tree127031268b9b42b0fbdae3d87684d9c045983677 /i686/sys
parentRename CCFLAGS to CFLAGS (diff)
downloadkernel-9b2a78fa52249ab481493550490aa5f37872dcf6.tar.xz
Rewrite drivers/uart and drivers/vga in cpp
Diffstat (limited to 'i686/sys')
-rw-r--r--i686/sys/cpuid.h2
-rw-r--r--i686/sys/io.h23
-rw-r--r--i686/sys/io.hpp15
3 files changed, 39 insertions, 1 deletions
diff --git a/i686/sys/cpuid.h b/i686/sys/cpuid.h
index 862601f..65b43c6 100644
--- a/i686/sys/cpuid.h
+++ b/i686/sys/cpuid.h
@@ -12,7 +12,7 @@ struct CPUVersion {
unsigned int family_ex : 8;
unsigned int __unused_2 : 4;
} __attribute__((packed, aligned(__alignof__(unsigned int))));
-_Static_assert(sizeof(struct CPUVersion) == sizeof(unsigned int), "cpuid version struct size");
+// FIXME _Static_assert(sizeof(struct CPUVersion) == sizeof(unsigned int), "cpuid version struct size");
unsigned int
family(const struct CPUVersion v)
diff --git a/i686/sys/io.h b/i686/sys/io.h
index 74d4950..b6c24c5 100644
--- a/i686/sys/io.h
+++ b/i686/sys/io.h
@@ -1,5 +1,27 @@
#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)
{
@@ -77,3 +99,4 @@ 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
new file mode 100644
index 0000000..bea9323
--- /dev/null
+++ b/i686/sys/io.hpp
@@ -0,0 +1,15 @@
+#pragma once
+
+template <typename T, unsigned short port> struct Port {
+ static void
+ out(T val, unsigned short offset = 0)
+ {
+ outb(val, port + offset);
+ }
+
+ static auto
+ in(unsigned short offset = 0)
+ {
+ return inb(port + offset);
+ }
+};