stos: bootvid: Add boot console support
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -9,11 +9,64 @@
|
||||
#include <drivers/bootvid/fbio.h>
|
||||
#include <ke/bpal.h>
|
||||
#include <ex/trace.h>
|
||||
#include <stdef.h>
|
||||
#include "flanterm.h"
|
||||
#include "flanterm_backends/fb.h"
|
||||
|
||||
#define DTRACE(Fmt, ...) \
|
||||
TRACE("[ BOOTVID ]: " Fmt, ##__VA_ARGS__)
|
||||
|
||||
/* Bootcons attributes */
|
||||
#define DEFAULT_BG 0x000000
|
||||
#define DEFAULT_FG 0xFFB000
|
||||
|
||||
static BPAL_FRAMEBUFFER Framebuffer;
|
||||
static struct flanterm_context *FtCtx = NULL;
|
||||
static BOOLEAN BootConsEnabled = false;
|
||||
static BOOTCONS_ATTR DefaultConsAttr = {
|
||||
.Foreground = DEFAULT_FG,
|
||||
.Background = DEFAULT_BG
|
||||
};
|
||||
|
||||
VOID
|
||||
BootVidInitCons(BOOTCONS_ATTR *Attr)
|
||||
{
|
||||
if (BootConsEnabled) {
|
||||
BootVidDeInitCons();
|
||||
}
|
||||
|
||||
if (Attr == NULL) {
|
||||
Attr = &DefaultConsAttr;
|
||||
}
|
||||
|
||||
FtCtx = flanterm_fb_init(
|
||||
NULL,
|
||||
NULL,
|
||||
Framebuffer.Address,
|
||||
Framebuffer.Width,
|
||||
Framebuffer.Height,
|
||||
Framebuffer.Pitch,
|
||||
Framebuffer.RedMaskSize,
|
||||
Framebuffer.RedMaskShift,
|
||||
Framebuffer.GreenMaskSize,
|
||||
Framebuffer.GreenMaskShift,
|
||||
Framebuffer.BlueMaskSize,
|
||||
Framebuffer.BlueMaskShift,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&Attr->Background,
|
||||
&Attr->Foreground,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0, 0, 0,
|
||||
0, 0, 0, 0
|
||||
);
|
||||
|
||||
BootConsEnabled = true;
|
||||
DTRACE("bootcons enabled\n");
|
||||
}
|
||||
|
||||
VOID
|
||||
BootVidInit(VOID)
|
||||
@@ -26,3 +79,35 @@ BootVidInit(VOID)
|
||||
DTRACE("framebuffer width: %d\n", Framebuffer.Width);
|
||||
DTRACE("framebuffer height: %d\n", Framebuffer.Height);
|
||||
}
|
||||
|
||||
VOID
|
||||
BootVidConsWrite(const CHAR *String, USIZE Length)
|
||||
{
|
||||
if (String == NULL || Length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BootConsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
flanterm_write(FtCtx, String, Length);
|
||||
}
|
||||
|
||||
VOID
|
||||
BootVidDeInitCons(VOID)
|
||||
{
|
||||
if (!BootConsEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
flanterm_deinit(FtCtx, NULL);
|
||||
FtCtx = NULL;
|
||||
BootConsEnabled = false;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
BootVidConsEn(VOID)
|
||||
{
|
||||
return BootConsEnabled;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user