From cd78c42c78c949fb953550cc1b8ab845531c4f9c Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Mon, 22 Aug 2011 11:11:50 +0200 Subject: [PATCH] VGA Cursor code is now in vga.cpp. --- sortix/vga.cpp | 24 +++++++++++++++++++++--- sortix/vga.h | 1 + sortix/vgaterminal.cpp | 19 ++----------------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/sortix/vga.cpp b/sortix/vga.cpp index 3e95f4b3..6a46e779 100644 --- a/sortix/vga.cpp +++ b/sortix/vga.cpp @@ -35,6 +35,8 @@ namespace Sortix namespace VGA { uint16_t* const vga = (uint16_t* const) 0xB8000; + const int width = 80; + const int height = 80; DevVGAFrame* currentframe; @@ -43,6 +45,21 @@ namespace Sortix currentframe = NULL; } + // Changes the position of the hardware cursor. + void SetCursor(nat x, nat y) + { + nat value = x + y * width; + + // This sends a command to indicies 14 and 15 in the + // CRT Control Register of the VGA controller. These + // are the high and low bytes of the index that show + // where the hardware cursor is to be 'blinking'. + CPU::OutPortB(0x3D4, 14); + CPU::OutPortB(0x3D5, (value >> 8) & 0xFF); + CPU::OutPortB(0x3D4, 15); + CPU::OutPortB(0x3D5, (value >> 0) & 0xFF); + } + void SysCreateFrame(CPU::InterruptRegisters* R) { addr_t page = Page::Get(); @@ -82,7 +99,7 @@ namespace Sortix frame->physical = page; frame->userframe = userframe; - process->_endcodesection = mapto + 0x1000; + process->_endcodesection = mapto + 0x1000UL; R->eax = mapto; } @@ -106,7 +123,7 @@ namespace Sortix // TODO: Check if userframe is actually user-space writable! - //Log::PrintF("changeframe: fd = %u, frame = 0x%p, currentframe = 0x%p\n", fd, frame, currentframe); + //Log::PrintF("changeframe: fd = %u, frame = 0x%p, currentframe = 0x%p, userframe = 0x%p\n", fd, frame, currentframe, frame->userframe); while(true); // Check if we need to do anything. if ( frame == currentframe ) { R->eax = 0; return; } @@ -149,7 +166,8 @@ namespace Sortix VirtualMemory::MapUser((addr_t) frame->userframe, (addr_t) vga); frame->onscreen = true; - currentframe = frame; + currentframe = frame; + SetCursor(width, height-1); } void SysDeleteFrame(CPU::InterruptRegisters* R) diff --git a/sortix/vga.h b/sortix/vga.h index 42b1feb0..b7692f03 100644 --- a/sortix/vga.h +++ b/sortix/vga.h @@ -66,6 +66,7 @@ namespace Sortix }; void Init(); + void SetCursor(nat x, nat y); // System Calls. void SysCreateFrame(CPU::InterruptRegisters* R); diff --git a/sortix/vgaterminal.cpp b/sortix/vgaterminal.cpp index 5821e156..332f7031 100644 --- a/sortix/vgaterminal.cpp +++ b/sortix/vgaterminal.cpp @@ -49,30 +49,15 @@ namespace Sortix COMMAND, } ansimode; - // Changes the position of the hardware cursor. - void SetCursor(nat x, nat y) - { - nat value = x + y * width; - - // This sends a command to indicies 14 and 15 in the - // CRT Control Register of the VGA controller. These - // are the high and low bytes of the index that show - // where the hardware cursor is to be 'blinking'. - CPU::OutPortB(0x3D4, 14); - CPU::OutPortB(0x3D5, (value >> 8) & 0xFF); - CPU::OutPortB(0x3D4, 15); - CPU::OutPortB(0x3D5, (value >> 0) & 0xFF); - } - void UpdateCursor() { if ( showcursor ) { - SetCursor(column, line); + VGA::SetCursor(column, line); } else { - SetCursor(width, height-1); + VGA::SetCursor(width, height-1); } }