bootloader video_text_console: Refactor into the new ConsoleNode model.
Change-Id: I3dc59cbdfd28f1ada49b02e42d50ec2b52c40227 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4643 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
5e43707307
commit
4c73f34840
@@ -14,8 +14,20 @@ for platform in [ MultiBootSubDirSetup ] {
|
|||||||
video_blit.cpp
|
video_blit.cpp
|
||||||
video_splash.cpp
|
video_splash.cpp
|
||||||
;
|
;
|
||||||
|
|
||||||
Includes [ FGristFiles video_splash.cpp ]
|
Includes [ FGristFiles video_splash.cpp ]
|
||||||
: [ BuildFeatureAttribute zlib : headers ] ;
|
: [ BuildFeatureAttribute zlib : headers ] ;
|
||||||
|
|
||||||
|
|
||||||
|
local kernelDebugSources =
|
||||||
|
font.cpp
|
||||||
|
font_spleen.cpp
|
||||||
|
frame_buffer_console.cpp
|
||||||
|
;
|
||||||
|
BootStaticLibrary boot_video_text_console_$(platform:G=) :
|
||||||
|
$(kernelDebugSources)
|
||||||
|
video_text_console.cpp
|
||||||
|
;
|
||||||
|
SEARCH on [ FGristFiles $(kernelDebugSources) ]
|
||||||
|
= [ FDirName $(HAIKU_TOP) src system kernel debug ] ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,59 +13,70 @@
|
|||||||
extern console_module_info gFrameBufferConsoleModule;
|
extern console_module_info gFrameBufferConsoleModule;
|
||||||
|
|
||||||
|
|
||||||
class Console : public ConsoleNode {
|
class VideoTextConsole : public ConsoleNode {
|
||||||
public:
|
public:
|
||||||
Console();
|
VideoTextConsole(addr_t framebuffer);
|
||||||
|
|
||||||
virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer,
|
virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer,
|
||||||
size_t bufferSize);
|
size_t bufferSize);
|
||||||
virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer,
|
virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer,
|
||||||
size_t bufferSize);
|
size_t bufferSize);
|
||||||
|
|
||||||
|
virtual void ClearScreen();
|
||||||
|
virtual int32 Width();
|
||||||
|
virtual int32 Height();
|
||||||
|
virtual void SetCursor(int32 x, int32 y);
|
||||||
|
virtual void SetCursorVisible(bool visible);
|
||||||
|
virtual void SetColors(int32 foreground, int32 background);
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint16 fColor = 0x0f00;
|
||||||
|
bool fShowCursor;
|
||||||
|
int32 fCursorX, fCursorY;
|
||||||
|
int32 fScreenWidth, fScreenHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static uint16 sColor = 0x0f00;
|
|
||||||
static bool sShowCursor;
|
|
||||||
static int32 sCursorX, sCursorY;
|
|
||||||
static int32 sScreenWidth, sScreenHeight;
|
|
||||||
|
|
||||||
static Console sConsole;
|
|
||||||
FILE *stdin, *stdout, *stderr;
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
Console::Console()
|
VideoTextConsole::VideoTextConsole(addr_t framebuffer)
|
||||||
: ConsoleNode()
|
: ConsoleNode()
|
||||||
{
|
{
|
||||||
|
frame_buffer_update(framebuffer, gKernelArgs.frame_buffer.width,
|
||||||
|
gKernelArgs.frame_buffer.height, gKernelArgs.frame_buffer.depth,
|
||||||
|
gKernelArgs.frame_buffer.bytes_per_row);
|
||||||
|
gFrameBufferConsoleModule.get_size(&fScreenWidth, &fScreenHeight);
|
||||||
|
|
||||||
|
SetCursorVisible(false);
|
||||||
|
ClearScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
Console::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize)
|
VideoTextConsole::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize)
|
||||||
{
|
{
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
Console::WriteAt(void *cookie, off_t /*pos*/, const void *buffer,
|
VideoTextConsole::WriteAt(void *cookie, off_t /*pos*/, const void *buffer,
|
||||||
size_t bufferSize)
|
size_t bufferSize)
|
||||||
{
|
{
|
||||||
const char *string = (const char *)buffer;
|
const char *string = (const char *)buffer;
|
||||||
for (size_t i = 0; i < bufferSize; i++) {
|
for (size_t i = 0; i < bufferSize; i++) {
|
||||||
const char c = string[i];
|
const char c = string[i];
|
||||||
if (c == '\n' || sCursorX >= sScreenWidth) {
|
if (c == '\n' || fCursorX >= fScreenWidth) {
|
||||||
sCursorX = 0;
|
fCursorX = 0;
|
||||||
if (sCursorY == (sScreenHeight - 1)) {
|
if (fCursorY == (fScreenHeight - 1)) {
|
||||||
// Move the screen up and clear the bottom line.
|
// Move the screen up and clear the bottom line.
|
||||||
gFrameBufferConsoleModule.blit(0, 1, sScreenWidth, 0,
|
gFrameBufferConsoleModule.blit(0, 1, fScreenWidth, 0,
|
||||||
0, sScreenHeight - 1);
|
0, fScreenHeight - 1);
|
||||||
gFrameBufferConsoleModule.fill_glyph(0, sCursorY, sScreenWidth,
|
gFrameBufferConsoleModule.fill_glyph(0, fCursorY, fScreenWidth,
|
||||||
1, ' ', sColor);
|
1, ' ', fColor);
|
||||||
} else {
|
} else {
|
||||||
sCursorY++;
|
fCursorY++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,86 +86,66 @@ Console::WriteAt(void *cookie, off_t /*pos*/, const void *buffer,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
gFrameBufferConsoleModule.put_glyph(sCursorX, sCursorY, c, sColor);
|
gFrameBufferConsoleModule.put_glyph(fCursorX, fCursorY, c, fColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sCursorX++;
|
fCursorX++;
|
||||||
}
|
}
|
||||||
return bufferSize;
|
return bufferSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
console_clear_screen(void)
|
VideoTextConsole::ClearScreen()
|
||||||
{
|
{
|
||||||
gFrameBufferConsoleModule.clear(sColor);
|
gFrameBufferConsoleModule.clear(fColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
console_width(void)
|
VideoTextConsole::Width()
|
||||||
{
|
{
|
||||||
return sScreenWidth;
|
return fScreenWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
console_height()
|
VideoTextConsole::Height()
|
||||||
{
|
{
|
||||||
return sScreenHeight;
|
return fScreenHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
console_set_cursor(int32 x, int32 y)
|
VideoTextConsole::SetCursor(int32 x, int32 y)
|
||||||
{
|
{
|
||||||
sCursorX = x;
|
fCursorX = x;
|
||||||
sCursorY = y;
|
fCursorY = y;
|
||||||
if (sShowCursor)
|
if (fShowCursor)
|
||||||
console_show_cursor();
|
SetCursorVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
console_show_cursor()
|
VideoTextConsole::SetCursorVisible(bool visible)
|
||||||
{
|
{
|
||||||
sShowCursor = true;
|
fShowCursor = visible;
|
||||||
gFrameBufferConsoleModule.move_cursor(sCursorX, sCursorY);
|
if (fShowCursor)
|
||||||
|
gFrameBufferConsoleModule.move_cursor(fCursorX, fCursorY);
|
||||||
|
else
|
||||||
|
gFrameBufferConsoleModule.move_cursor(-1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
console_hide_cursor()
|
VideoTextConsole::SetColors(int32 foreground, int32 background)
|
||||||
{
|
{
|
||||||
sShowCursor = false;
|
fColor = (background & 0xf) << 4 | (foreground & 0xf);
|
||||||
gFrameBufferConsoleModule.move_cursor(-1, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
ConsoleNode*
|
||||||
console_set_color(int32 foreground, int32 background)
|
|
||||||
{
|
|
||||||
sColor = (background & 0xf) << 4 | (foreground & 0xf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
video_text_console_init(addr_t frameBuffer)
|
video_text_console_init(addr_t frameBuffer)
|
||||||
{
|
{
|
||||||
frame_buffer_update(frameBuffer, gKernelArgs.frame_buffer.width,
|
return new VideoTextConsole(frameBuffer);
|
||||||
gKernelArgs.frame_buffer.height, gKernelArgs.frame_buffer.depth,
|
|
||||||
gKernelArgs.frame_buffer.bytes_per_row);
|
|
||||||
gFrameBufferConsoleModule.get_size(&sScreenWidth, &sScreenHeight);
|
|
||||||
|
|
||||||
console_hide_cursor();
|
|
||||||
console_clear_screen();
|
|
||||||
|
|
||||||
// enable stdio functionality
|
|
||||||
stdin = (FILE *)&sConsole;
|
|
||||||
stdout = stderr = (FILE *)&sConsole;
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user