ptos: bootvid: Add boot console to bootvid

Signed-off-by: Chloe M. <chloe@yiffware.org>
This commit is contained in:
2026-07-10 10:14:58 +00:00
parent 85e8f11a89
commit 2594613412
4 changed files with 127 additions and 0 deletions
+84
View File
@@ -9,11 +9,23 @@
#include <drivers/bootvid/fbio.h>
#include <ex/trace.h>
#include <ke/bpal.h>
#include "flanterm.h"
#include "flanterm_backends/fb.h"
/* Bootcons attributes */
#define DEFAULT_BG 0x000000
#define DEFAULT_FG 0xFFB000
#define DTRACE(Fmt, ...) \
TRACE("[ BOOTVID ]: " Fmt, ##__VA_ARGS__)
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
BootVidInit(VOID)
@@ -26,3 +38,75 @@ BootVidInit(VOID)
DTRACE("framebuffer width : %d px\n", Framebuffer.Width);
DTRACE("framebuffer height : %d px\n", Framebuffer.Height);
}
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
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;
}
+36
View File
@@ -11,9 +11,45 @@
#include <ptdef.h>
/*
* Boot console attributes
*
* @Background: Console background color
* @Foreground: Console foreground color
*/
typedef struct {
ULONG Background;
ULONG Foreground;
} BOOTCONS_ATTR;
/*
* Initialize the boot video driver
*/
VOID BootVidInit(VOID);
/*
* De-initialize the boot video console
*/
VOID BootVidDeInitCons(VOID);
/*
* Initialize the boot video console
*
* @Attr: Console attributes to initialize
*/
VOID BootVidInitCons(BOOTCONS_ATTR *Attr);
/*
* Write to the boot console
*
* @String: String to write to boot console
* @Length: Length of string to write
*/
VOID BootVidConsWrite(const CHAR *String, USIZE Length);
/*
* Returns true if the boot console is enabled
*/
BOOLEAN BootVidConsEn(VOID);
#endif /* !_BOOTVID_FBIO_H_ */
+3
View File
@@ -42,4 +42,7 @@ KiKernelInit(VOID)
/* Initialize the boot video driver */
BootVidInit();
/* Initialize the boot video console */
BootVidInitCons(NULL);
}
+4
View File
@@ -7,9 +7,13 @@
*/
#include <hal/serial.h>
#include <drivers/bootvid/fbio.h>
void
_putchar(char c)
{
HalSerialWrite(&c, 1);
if (BootVidConsEn()) {
BootVidConsWrite(&c, 1);
}
}