mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 08:58:11 +00:00
Merge VGA into VirtualConsole.
This commit is contained in:
parent
c653bb09b3
commit
2ac5e14c08
13 changed files with 34 additions and 123 deletions
|
@ -189,10 +189,10 @@ heads:
|
||||||
dw 2
|
dw 2
|
||||||
|
|
||||||
msg_sectors_loaded:
|
msg_sectors_loaded:
|
||||||
db "sectors loaded", 0x0d, 0x0a, 0
|
db "done!", 0x0d, 0x0a, 0
|
||||||
|
|
||||||
message:
|
message:
|
||||||
db "boot!", 0x0d, 0x0a, 0
|
db "Loading kernel", 0
|
||||||
|
|
||||||
fug_message:
|
fug_message:
|
||||||
db "FUG!", 0x0d, 0x0a, 0
|
db "FUG!", 0x0d, 0x0a, 0
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "Console.h"
|
#include "Console.h"
|
||||||
#include "VGA.h"
|
|
||||||
#include "IO.h"
|
#include "IO.h"
|
||||||
#include "kprintf.h"
|
#include "kprintf.h"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "i386.h"
|
#include "i386.h"
|
||||||
#include "IO.h"
|
#include "IO.h"
|
||||||
#include "VGA.h"
|
|
||||||
#include "PIC.h"
|
#include "PIC.h"
|
||||||
#include "Keyboard.h"
|
#include "Keyboard.h"
|
||||||
#include "VirtualConsole.h"
|
#include "VirtualConsole.h"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
KERNEL_OBJS = \
|
KERNEL_OBJS = \
|
||||||
_start.o \
|
_start.o \
|
||||||
init.o \
|
init.o \
|
||||||
VGA.o \
|
|
||||||
kmalloc.o \
|
kmalloc.o \
|
||||||
StdLib.o \
|
StdLib.o \
|
||||||
i386.o \
|
i386.o \
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "i386.h"
|
#include "i386.h"
|
||||||
#include "IO.h"
|
#include "IO.h"
|
||||||
#include "VGA.h"
|
|
||||||
#include "PIC.h"
|
#include "PIC.h"
|
||||||
#include "Assertions.h"
|
#include "Assertions.h"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
#include "kmalloc.h"
|
#include "kmalloc.h"
|
||||||
#include "VGA.h"
|
|
||||||
#include "StdLib.h"
|
#include "StdLib.h"
|
||||||
#include "i386.h"
|
#include "i386.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
|
@ -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));
|
|
||||||
}
|
|
15
Kernel/VGA.h
15
Kernel/VGA.h
|
@ -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);
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "VirtualConsole.h"
|
#include "VirtualConsole.h"
|
||||||
#include "VGA.h"
|
|
||||||
#include "kmalloc.h"
|
#include "kmalloc.h"
|
||||||
#include "i386.h"
|
#include "i386.h"
|
||||||
|
#include "IO.h"
|
||||||
#include "StdLib.h"
|
#include "StdLib.h"
|
||||||
#include "Keyboard.h"
|
#include "Keyboard.h"
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
|
@ -10,6 +10,26 @@ static byte* s_vga_buffer;
|
||||||
static VirtualConsole* s_consoles[6];
|
static VirtualConsole* s_consoles[6];
|
||||||
static int s_active_console;
|
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()
|
void VirtualConsole::initialize()
|
||||||
{
|
{
|
||||||
s_vga_buffer = (byte*)0xb8000;
|
s_vga_buffer = (byte*)0xb8000;
|
||||||
|
@ -25,9 +45,7 @@ VirtualConsole::VirtualConsole(unsigned index, InitialContents initial_contents)
|
||||||
m_buffer = (byte*)kmalloc_eternal(80 * 25 * 2);
|
m_buffer = (byte*)kmalloc_eternal(80 * 25 * 2);
|
||||||
if (initial_contents == AdoptCurrentVGABuffer) {
|
if (initial_contents == AdoptCurrentVGABuffer) {
|
||||||
memcpy(m_buffer, s_vga_buffer, 80 * 25 * 2);
|
memcpy(m_buffer, s_vga_buffer, 80 * 25 * 2);
|
||||||
auto vgaCursor = vga_get_cursor();
|
get_vga_cursor(m_cursor_row, m_cursor_column);
|
||||||
m_cursor_row = vgaCursor / 80;
|
|
||||||
m_cursor_column = vgaCursor % 80;
|
|
||||||
} else {
|
} else {
|
||||||
word* line_mem = reinterpret_cast<word*>(m_buffer);
|
word* line_mem = reinterpret_cast<word*>(m_buffer);
|
||||||
for (word i = 0; i < 80 * 25; ++i)
|
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);
|
memcpy(s_vga_buffer, m_buffer, 80 * 25 * 2);
|
||||||
set_vga_start_row(0);
|
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);
|
Keyboard::the().setClient(this);
|
||||||
}
|
}
|
||||||
|
@ -331,7 +349,7 @@ void VirtualConsole::set_cursor(unsigned row, unsigned column)
|
||||||
m_cursor_row = row;
|
m_cursor_row = row;
|
||||||
m_cursor_column = column;
|
m_cursor_column = column;
|
||||||
if (m_active)
|
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)
|
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_vga_start_row = row;
|
||||||
m_current_vga_start_address = row * 80;
|
m_current_vga_start_address = row * 80;
|
||||||
m_current_vga_window = s_vga_buffer + row * 160;
|
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));
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,9 @@ private:
|
||||||
void set_active(bool);
|
void set_active(bool);
|
||||||
void on_char(byte, bool shouldEmit);
|
void on_char(byte, bool shouldEmit);
|
||||||
|
|
||||||
|
void get_vga_cursor(byte& row, byte& column);
|
||||||
|
void flush_vga_cursor();
|
||||||
|
|
||||||
byte* m_buffer;
|
byte* m_buffer;
|
||||||
unsigned m_index;
|
unsigned m_index;
|
||||||
bool m_active { false };
|
bool m_active { false };
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "kmalloc.h"
|
#include "kmalloc.h"
|
||||||
#include "VGA.h"
|
|
||||||
#include "i386.h"
|
#include "i386.h"
|
||||||
#include "Assertions.h"
|
#include "Assertions.h"
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "VGA.h"
|
|
||||||
#include "kmalloc.h"
|
#include "kmalloc.h"
|
||||||
#include "i386.h"
|
#include "i386.h"
|
||||||
#include "i8253.h"
|
#include "i8253.h"
|
||||||
|
@ -267,7 +266,6 @@ void init()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
kmalloc_init();
|
kmalloc_init();
|
||||||
vga_init();
|
|
||||||
|
|
||||||
auto console = make<Console>();
|
auto console = make<Console>();
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,8 @@
|
||||||
#include "kmalloc.h"
|
#include "kmalloc.h"
|
||||||
#include "StdLib.h"
|
#include "StdLib.h"
|
||||||
#include "i386.h"
|
#include "i386.h"
|
||||||
#include "VGA.h"
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "Assertions.h"
|
#include <AK/Assertions.h>
|
||||||
|
|
||||||
#define SANITIZE_KMALLOC
|
#define SANITIZE_KMALLOC
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue