From 66eedf1200c4af0eccd450fbfb51a2b667d32275 Mon Sep 17 00:00:00 2001 From: Achilleas Anagnostopoulos Date: Thu, 30 Mar 2017 08:37:03 +0100 Subject: [PATCH] Initialize a minimal terminal attached to a text console device --- kernel/hal/hal.go | 21 +++++++++++++++++++++ kernel/kmain.go | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/kernel/hal/hal.go b/kernel/hal/hal.go index e69de29..61bdc9e 100644 --- a/kernel/hal/hal.go +++ b/kernel/hal/hal.go @@ -0,0 +1,21 @@ +package hal + +import ( + "github.com/achilleasa/gopher-os/kernel/driver/tty" + "github.com/achilleasa/gopher-os/kernel/driver/video/console" + "github.com/achilleasa/gopher-os/kernel/hal/multiboot" +) + +var ( + egaConsole = &console.Ega{} + ActiveTerminal = &tty.Vt{} +) + +// InitTerminal provides a basic terminal to allow the kernel to emit some output +// till everything is properly setup +func InitTerminal() { + fbInfo := multiboot.GetFramebufferInfo() + + egaConsole.Init(uint16(fbInfo.Width), uint16(fbInfo.Height), uintptr(fbInfo.PhysAddr)) + ActiveTerminal.AttachTo(egaConsole) +} diff --git a/kernel/kmain.go b/kernel/kmain.go index f0ebda4..3f1127b 100644 --- a/kernel/kmain.go +++ b/kernel/kmain.go @@ -3,6 +3,7 @@ package kernel import ( _ "unsafe" // required for go:linkname + "github.com/achilleasa/gopher-os/kernel/hal" "github.com/achilleasa/gopher-os/kernel/hal/multiboot" ) @@ -19,4 +20,8 @@ import ( //go:noinline func Kmain(multibootInfoPtr uint32) { multiboot.SetInfoPtr(uintptr(multibootInfoPtr)) + + // Initialize and clear the terminal + hal.InitTerminal() + hal.ActiveTerminal.Clear() }