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;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,45 @@
|
||||
|
||||
#include <stdef.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);
|
||||
|
||||
/*
|
||||
* Initialize the boot console
|
||||
*
|
||||
* @Attr: Attributes to set [NULL for default]
|
||||
*/
|
||||
VOID BootVidInitCons(BOOTCONS_ATTR *Attr);
|
||||
|
||||
/*
|
||||
* Turn off the boot console
|
||||
*/
|
||||
VOID BootVidDeInitCons(VOID);
|
||||
|
||||
/*
|
||||
* Write a string to the boot console
|
||||
*
|
||||
* @String: String to write
|
||||
* @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_ */
|
||||
|
||||
@@ -40,4 +40,7 @@ KiKernelEntry(VOID)
|
||||
|
||||
/* Initialize boot video */
|
||||
BootVidInit();
|
||||
|
||||
/* Init bootcons */
|
||||
BootVidInitCons(NULL);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ CFLAGS = \
|
||||
-MMD \
|
||||
-DPRINTF_DISABLE_SUPPORT_PTRDIFF_T \
|
||||
-DPRINTF_DISABLE_SUPPORT_FLOAT \
|
||||
-I../xt/flanterm/src \
|
||||
-I../head \
|
||||
-I../target \
|
||||
-I$(ST_PROJECT_ROOT)/paw/spkg/head \
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user