diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-11-10 16:25:59 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-11-10 16:26:18 +0100 |
commit | 2ac5e14c08a4d855f53e7b7c519e0864ffe469bf (patch) | |
tree | ceb5c944c9936eca77d41cb3babe3d99a7f26840 | |
parent | c653bb09b3cbc4fdbb595501c4adbb161607a1fe (diff) | |
download | serenity-2ac5e14c08a4d855f53e7b7c519e0864ffe469bf.zip |
Merge VGA into VirtualConsole.
-rwxr-xr-x | Kernel/Boot/boot.asm | 4 | ||||
-rw-r--r-- | Kernel/Console.cpp | 1 | ||||
-rw-r--r-- | Kernel/Keyboard.cpp | 1 | ||||
-rw-r--r-- | Kernel/Makefile | 1 | ||||
-rw-r--r-- | Kernel/PIC.cpp | 1 | ||||
-rw-r--r-- | Kernel/Process.cpp | 1 | ||||
-rw-r--r-- | Kernel/VGA.cpp | 89 | ||||
-rw-r--r-- | Kernel/VGA.h | 15 | ||||
-rw-r--r-- | Kernel/VirtualConsole.cpp | 35 | ||||
-rw-r--r-- | Kernel/VirtualConsole.h | 3 | ||||
-rw-r--r-- | Kernel/i386.cpp | 1 | ||||
-rw-r--r-- | Kernel/init.cpp | 2 | ||||
-rw-r--r-- | Kernel/kmalloc.cpp | 3 |
13 files changed, 34 insertions, 123 deletions
diff --git a/Kernel/Boot/boot.asm b/Kernel/Boot/boot.asm index cf208c303e..fdd0027e94 100755 --- a/Kernel/Boot/boot.asm +++ b/Kernel/Boot/boot.asm @@ -189,10 +189,10 @@ heads: dw 2 msg_sectors_loaded: - db "sectors loaded", 0x0d, 0x0a, 0 + db "done!", 0x0d, 0x0a, 0 message: - db "boot!", 0x0d, 0x0a, 0 + db "Loading kernel", 0 fug_message: db "FUG!", 0x0d, 0x0a, 0 diff --git a/Kernel/Console.cpp b/Kernel/Console.cpp index 7f8ce46888..8a8b2bfc57 100644 --- a/Kernel/Console.cpp +++ b/Kernel/Console.cpp @@ -1,5 +1,4 @@ #include "Console.h" -#include "VGA.h" #include "IO.h" #include "kprintf.h" diff --git a/Kernel/Keyboard.cpp b/Kernel/Keyboard.cpp index 2c41efb2a7..9768de481a 100644 --- a/Kernel/Keyboard.cpp +++ b/Kernel/Keyboard.cpp @@ -1,7 +1,6 @@ #include "types.h" #include "i386.h" #include "IO.h" -#include "VGA.h" #include "PIC.h" #include "Keyboard.h" #include "VirtualConsole.h" diff --git a/Kernel/Makefile b/Kernel/Makefile index 1528847873..bc7faaca17 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -1,7 +1,6 @@ KERNEL_OBJS = \ _start.o \ init.o \ - VGA.o \ kmalloc.o \ StdLib.o \ i386.o \ diff --git a/Kernel/PIC.cpp b/Kernel/PIC.cpp index fc91f3ca97..b85a1cd937 100644 --- a/Kernel/PIC.cpp +++ b/Kernel/PIC.cpp @@ -1,7 +1,6 @@ #include "types.h" #include "i386.h" #include "IO.h" -#include "VGA.h" #include "PIC.h" #include "Assertions.h" diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 0cc7c6d4f9..f6e74782db 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1,7 +1,6 @@ #include "types.h" #include "Process.h" #include "kmalloc.h" -#include "VGA.h" #include "StdLib.h" #include "i386.h" #include "system.h" diff --git a/Kernel/VGA.cpp b/Kernel/VGA.cpp deleted file mode 100644 index f927abed54..0000000000 --- a/Kernel/VGA.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "types.h" -#include "VGA.h" -#include "i386.h" -#include "IO.h" -#include "StdLib.h" -#include "Process.h" - -static byte* vga_mem = nullptr; - -void vga_clear_row(word line) -{ - InterruptDisabler disabler; - word* linemem = (word*)&vga_mem[line * 160]; - for (word i = 0; i < 80; ++i) { - linemem[i] = 0x0720; - } -} - -void vga_clear() -{ - InterruptDisabler disabler; - for (word i = 0; i < 25; ++i) - vga_clear_row(i); -} - -void vga_putch_at(byte row, byte column, byte ch, byte attr) -{ - word cur = (row * 160) + (column * 2); - vga_mem[cur] = ch; - vga_mem[cur + 1] = attr; -} - -word vga_get_start_address() -{ - word value; - IO::out8(0x3d4, 0x0d); - value = IO::in8(0x3d5) << 8; - IO::out8(0x3d4, 0x0c); - value |= IO::in8(0x3d5); - return value; -} - -void vga_set_start_address(word value) -{ - IO::out8(0x3d4, 0x0c); - IO::out8(0x3d5, MSB(value)); - IO::out8(0x3d4, 0x0d); - IO::out8(0x3d5, LSB(value)); -} - -void vga_init() -{ - vga_mem = (byte*)0xb8000; - - for (word i = 0; i < (80 * 25); ++i) { - vga_mem[i*2] = ' '; - vga_mem[i*2 + 1] = 0x07; - } - - vga_set_cursor(0); -} - -WORD vga_get_cursor() -{ - WORD value; - IO::out8(0x3d4, 0x0e); - value = IO::in8(0x3d5) << 8; - IO::out8(0x3d4, 0x0f); - value |= IO::in8(0x3d5); - return value; -} - -void vga_set_cursor(WORD value) -{ - IO::out8(0x3d4, 0x0e); - IO::out8(0x3d5, MSB(value)); - IO::out8(0x3d4, 0x0f); - IO::out8(0x3d5, LSB(value)); -} - -void vga_set_cursor(BYTE row, BYTE column) -{ - vga_set_cursor(row * 80 + column); -} - -void vga_set_cursor(byte row, byte column, word start_address) -{ - vga_set_cursor((start_address) + (row * 80 + column)); -} diff --git a/Kernel/VGA.h b/Kernel/VGA.h deleted file mode 100644 index b34bbd1075..0000000000 --- a/Kernel/VGA.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "types.h" - -void vga_init(); -void vga_set_cursor(WORD); -void vga_set_cursor(byte row, byte column, word start_address); -void vga_set_cursor(BYTE row, BYTE column); -WORD vga_get_cursor(); -void vga_putch_at(byte row, byte column, byte ch, byte attr); -void vga_scroll_up(); -void vga_clear(); -void vga_clear_row(word); -word vga_get_start_address(); -void vga_set_start_address(word); diff --git a/Kernel/VirtualConsole.cpp b/Kernel/VirtualConsole.cpp index 530913f47a..f963684ce3 100644 --- a/Kernel/VirtualConsole.cpp +++ b/Kernel/VirtualConsole.cpp @@ -1,7 +1,7 @@ #include "VirtualConsole.h" -#include "VGA.h" #include "kmalloc.h" #include "i386.h" +#include "IO.h" #include "StdLib.h" #include "Keyboard.h" #include <AK/String.h> @@ -10,6 +10,26 @@ static byte* s_vga_buffer; static VirtualConsole* s_consoles[6]; static int s_active_console; +void VirtualConsole::get_vga_cursor(byte& row, byte& column) +{ + word value; + IO::out8(0x3d4, 0x0e); + value = IO::in8(0x3d5) << 8; + IO::out8(0x3d4, 0x0f); + value |= IO::in8(0x3d5); + row = value / 80; + column = value % 80; +} + +void VirtualConsole::flush_vga_cursor() +{ + word value = m_current_vga_start_address + (m_cursor_row * 80 + m_cursor_column); + IO::out8(0x3d4, 0x0e); + IO::out8(0x3d5, MSB(value)); + IO::out8(0x3d4, 0x0f); + IO::out8(0x3d5, LSB(value)); +} + void VirtualConsole::initialize() { s_vga_buffer = (byte*)0xb8000; @@ -25,9 +45,7 @@ VirtualConsole::VirtualConsole(unsigned index, InitialContents initial_contents) m_buffer = (byte*)kmalloc_eternal(80 * 25 * 2); if (initial_contents == AdoptCurrentVGABuffer) { memcpy(m_buffer, s_vga_buffer, 80 * 25 * 2); - auto vgaCursor = vga_get_cursor(); - m_cursor_row = vgaCursor / 80; - m_cursor_column = vgaCursor % 80; + get_vga_cursor(m_cursor_row, m_cursor_column); } else { word* line_mem = reinterpret_cast<word*>(m_buffer); for (word i = 0; i < 80 * 25; ++i) @@ -79,7 +97,7 @@ void VirtualConsole::set_active(bool b) memcpy(s_vga_buffer, m_buffer, 80 * 25 * 2); set_vga_start_row(0); - vga_set_cursor(m_cursor_row, m_cursor_column, m_current_vga_start_address); + flush_vga_cursor(); Keyboard::the().setClient(this); } @@ -331,7 +349,7 @@ void VirtualConsole::set_cursor(unsigned row, unsigned column) m_cursor_row = row; m_cursor_column = column; if (m_active) - vga_set_cursor(m_cursor_row, m_cursor_column, m_current_vga_start_address); + flush_vga_cursor(); } void VirtualConsole::put_character_at(unsigned row, unsigned column, byte ch) @@ -453,5 +471,8 @@ void VirtualConsole::set_vga_start_row(word row) m_vga_start_row = row; m_current_vga_start_address = row * 80; m_current_vga_window = s_vga_buffer + row * 160; - vga_set_start_address(m_current_vga_start_address); + IO::out8(0x3d4, 0x0c); + IO::out8(0x3d5, MSB(m_current_vga_start_address)); + IO::out8(0x3d4, 0x0d); + IO::out8(0x3d5, LSB(m_current_vga_start_address)); } diff --git a/Kernel/VirtualConsole.h b/Kernel/VirtualConsole.h index 545a8a4894..8c5ce2ec8e 100644 --- a/Kernel/VirtualConsole.h +++ b/Kernel/VirtualConsole.h @@ -29,6 +29,9 @@ private: void set_active(bool); void on_char(byte, bool shouldEmit); + void get_vga_cursor(byte& row, byte& column); + void flush_vga_cursor(); + byte* m_buffer; unsigned m_index; bool m_active { false }; diff --git a/Kernel/i386.cpp b/Kernel/i386.cpp index 24b872bc20..89eb65ffd3 100644 --- a/Kernel/i386.cpp +++ b/Kernel/i386.cpp @@ -1,6 +1,5 @@ #include "types.h" #include "kmalloc.h" -#include "VGA.h" #include "i386.h" #include "Assertions.h" #include "Process.h" diff --git a/Kernel/init.cpp b/Kernel/init.cpp index ffcbc3d03e..641d5cdec7 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -1,5 +1,4 @@ #include "types.h" -#include "VGA.h" #include "kmalloc.h" #include "i386.h" #include "i8253.h" @@ -267,7 +266,6 @@ void init() #endif kmalloc_init(); - vga_init(); auto console = make<Console>(); diff --git a/Kernel/kmalloc.cpp b/Kernel/kmalloc.cpp index 7f8446e34c..367d4fcbe7 100644 --- a/Kernel/kmalloc.cpp +++ b/Kernel/kmalloc.cpp @@ -7,9 +7,8 @@ #include "kmalloc.h" #include "StdLib.h" #include "i386.h" -#include "VGA.h" #include "system.h" -#include "Assertions.h" +#include <AK/Assertions.h> #define SANITIZE_KMALLOC |