diff options
author | aqua <aqua@iserlohn-fortress.net> | 2022-12-10 20:56:57 +0200 |
---|---|---|
committer | aqua <aqua@iserlohn-fortress.net> | 2022-12-11 11:32:51 +0200 |
commit | 9b2a78fa52249ab481493550490aa5f37872dcf6 (patch) | |
tree | 127031268b9b42b0fbdae3d87684d9c045983677 /i686 | |
parent | Rename CCFLAGS to CFLAGS (diff) | |
download | kernel-9b2a78fa52249ab481493550490aa5f37872dcf6.tar.xz |
Rewrite drivers/uart and drivers/vga in cpp
Diffstat (limited to 'i686')
-rw-r--r-- | i686/sys/cpuid.h | 2 | ||||
-rw-r--r-- | i686/sys/io.h | 23 | ||||
-rw-r--r-- | i686/sys/io.hpp | 15 | ||||
-rw-r--r-- | i686/toolchain.mk | 31 |
4 files changed, 55 insertions, 16 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); + } +}; diff --git a/i686/toolchain.mk b/i686/toolchain.mk index 43c758c..ae2fb35 100644 --- a/i686/toolchain.mk +++ b/i686/toolchain.mk @@ -1,19 +1,20 @@ ARCH=i686 # define compiler, linker, archiver and strip and their flags -# -AS := i686-elf-as -CC := i686-elf-gcc -CFLAGS := -Wall -Wextra -Wpedantic -Wshadow -Wconversion -fanalyzer -ffreestanding -std=gnu11 -mgeneral-regs-only -CFLAGS += $(shell echo ${CONFIG_CFLAGS}) -LD := i686-elf-ld -LDFLAGS := -static -nostdlib -LDFLAGS += $(shell echo ${CONFIG_LDFLAGS}) -AR := i686-elf-ar -ARFLAGS := -crus -STRIP := i686-elf-strip - -# test framework -GTEST := $(shell pkg-config --cflags --libs gtest gtest_main) -GMOCK := $(shell pkg-config --cflags --libs gmock) +# FIXME: cpp threadsafe statics +AS := i686-elf-as +CC := i686-elf-gcc +CXX := i686-elf-g++ +CFLAGS := -Wall -Wextra -Wpedantic -Wshadow -Wconversion -fanalyzer -ffreestanding -std=gnu11 \ + -mgeneral-regs-only +CFLAGS += $(shell echo ${CONFIG_CFLAGS}) +CXXFLAGS := -Wall -Wextra -Wpedantic -Wshadow -Wconversion -ffreestanding -std=c++17 \ + -mgeneral-regs-only -fno-use-cxa-atexit -fno-threadsafe-statics -fno-exceptions -fno-rtti +CXXFLAGS += $(shell echo ${CONFIG_CXXFLAGS}) +LD := i686-elf-ld +LDFLAGS := -static -nostdlib +LDFLAGS += $(shell echo ${CONFIG_LDFLAGS}) +AR := i686-elf-ar +ARFLAGS := -crus +STRIP := i686-elf-strip |