aboutsummaryrefslogtreecommitdiff
path: root/src/ports.h
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2021-02-11 16:17:53 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2021-02-11 21:33:21 +0200
commit9a299f2fe91554a1b9d9db402391ae757c591ef8 (patch)
tree2ec839c869316804954e6b09220140346874aa8d /src/ports.h
parentGenerate target dependency files (diff)
downloadkernel.cpp-9a299f2fe91554a1b9d9db402391ae757c591ef8.tar.xz
Add comments to explain CGA ports better
Diffstat (limited to 'src/ports.h')
-rw-r--r--src/ports.h43
1 files changed, 0 insertions, 43 deletions
diff --git a/src/ports.h b/src/ports.h
deleted file mode 100644
index 0371bcc..0000000
--- a/src/ports.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#pragma once
-
-template <typename T>
-concept port_data_t = (is_same<T, uint8_t>::value || is_same<T, uint16_t>::value || is_same<T, uint32_t>::value);
-
-template <uint16_t port_num, port_data_t T>
-class Port {
-public:
- [[nodiscard]] T read() {
- T result;
-
- switch (sizeof(T)) {
- case 1:
- asm volatile("inb %1, %0" : "=a"(result) : "Nd"(port_num));
- break;
- case 2:
- asm volatile("inw %1, %0" : "=a"(result) : "Nd"(port_num));
- break;
- case 4:
- asm volatile("inl %1, %0" : "=a"(result) : "Nd"(port_num));
- break;
- }
-
- return result;
- }
-
- void write(T data) {
- switch (sizeof(T)) {
- case 1:
- asm volatile("outb %0, %1" : : "a"(data), "Nd"(port_num));
- break;
- case 2:
- asm volatile("outw %0, %1" : : "a"(data), "Nd"(port_num));
- break;
- case 4:
- asm volatile("outl %0, %1" : : "a"(data), "Nd"(port_num));
- break;
- }
- }
-};
-
-typedef Port<0x3d4, uint8_t> vga_horizontal_total;
-typedef Port<0x3d5, uint8_t> vga_horizontal_display_enable_end;