Skip to content
Snippets Groups Projects
Commit 75a4b9b7 authored by John Hodge's avatar John Hodge
Browse files

Kernel - Implemented fallback to VGA when VESA is unavaliable

- Reworked parts of VTerm for it.
- Also fixed bugs in drvutil
parent 2bfc6ebc
Branches
Tags
No related merge requests found
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#define MAX_INPUT_CHARS8 (MAX_INPUT_CHARS32*4) #define MAX_INPUT_CHARS8 (MAX_INPUT_CHARS32*4)
//#define DEFAULT_OUTPUT "BochsGA" //#define DEFAULT_OUTPUT "BochsGA"
#define DEFAULT_OUTPUT "Vesa" #define DEFAULT_OUTPUT "Vesa"
#define FALLBACK_OUTPUT "x86_VGAText"
#define DEFAULT_INPUT "PS2Keyboard" #define DEFAULT_INPUT "PS2Keyboard"
#define DEFAULT_WIDTH 640 #define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 480 #define DEFAULT_HEIGHT 480
...@@ -108,7 +109,7 @@ const Uint16 caVT100Colours[] = { ...@@ -108,7 +109,7 @@ const Uint16 caVT100Colours[] = {
}; };
// === GLOBALS === // === GLOBALS ===
MODULE_DEFINE(0, VERSION, VTerm, VT_Install, NULL, DEFAULT_OUTPUT, DEFAULT_INPUT, NULL); MODULE_DEFINE(0, VERSION, VTerm, VT_Install, NULL, FALLBACK_OUTPUT, DEFAULT_INPUT, NULL);
tDevFS_Driver gVT_DrvInfo = { tDevFS_Driver gVT_DrvInfo = {
NULL, "VTerm", NULL, "VTerm",
{ {
...@@ -168,11 +169,11 @@ int VT_Install(char **Arguments) ...@@ -168,11 +169,11 @@ int VT_Install(char **Arguments)
Log_Debug("VTerm", "Argument '%s'", arg); Log_Debug("VTerm", "Argument '%s'", arg);
if( strcmp(opt, "Video") == 0 ) { if( strcmp(opt, "Video") == 0 ) {
if( !gsVT_OutputDevice && Modules_InitialiseBuiltin( val ) == 0 ) if( !gsVT_OutputDevice )
gsVT_OutputDevice = strdup(val); gsVT_OutputDevice = strdup(val);
} }
else if( strcmp(opt, "Input") == 0 ) { else if( strcmp(opt, "Input") == 0 ) {
if( !gsVT_InputDevice && Modules_InitialiseBuiltin( val ) == 0 ) if( !gsVT_InputDevice )
gsVT_InputDevice = strdup(val); gsVT_InputDevice = strdup(val);
} }
else if( strcmp(opt, "Width") == 0 ) { else if( strcmp(opt, "Width") == 0 ) {
...@@ -188,16 +189,21 @@ int VT_Install(char **Arguments) ...@@ -188,16 +189,21 @@ int VT_Install(char **Arguments)
} }
// Apply Defaults // Apply Defaults
if(!gsVT_OutputDevice) gsVT_OutputDevice = strdup(DEFAULT_OUTPUT); if(!gsVT_OutputDevice) gsVT_OutputDevice = (char*)DEFAULT_OUTPUT;
if(!gsVT_InputDevice) gsVT_InputDevice = strdup(DEFAULT_INPUT); else if( Module_EnsureLoaded( gsVT_OutputDevice ) ) gsVT_OutputDevice = (char*)DEFAULT_OUTPUT;
if( Module_EnsureLoaded( gsVT_OutputDevice ) ) gsVT_OutputDevice = (char*)FALLBACK_OUTPUT;
// Create paths if(!gsVT_InputDevice) gsVT_InputDevice = (char*)DEFAULT_INPUT;
else if( Module_EnsureLoaded( gsVT_InputDevice ) ) gsVT_InputDevice = (char*)DEFAULT_INPUT;
// Create device paths
{ {
char *tmp; char *tmp;
tmp = malloc( 9 + strlen(gsVT_OutputDevice) + 1 ); tmp = malloc( 9 + strlen(gsVT_OutputDevice) + 1 );
strcpy(tmp, "/Devices/"); strcpy(tmp, "/Devices/");
strcpy(&tmp[9], gsVT_OutputDevice); strcpy(&tmp[9], gsVT_OutputDevice);
gsVT_OutputDevice = tmp; gsVT_OutputDevice = tmp;
tmp = malloc( 9 + strlen(gsVT_InputDevice) + 1 ); tmp = malloc( 9 + strlen(gsVT_InputDevice) + 1 );
strcpy(tmp, "/Devices/"); strcpy(tmp, "/Devices/");
strcpy(&tmp[9], gsVT_InputDevice); strcpy(&tmp[9], gsVT_InputDevice);
...@@ -244,7 +250,6 @@ int VT_Install(char **Arguments) ...@@ -244,7 +250,6 @@ int VT_Install(char **Arguments)
// Set kernel output to VT0 // Set kernel output to VT0
Debug_SetKTerminal("/Devices/VTerm/0"); Debug_SetKTerminal("/Devices/VTerm/0");
Log_Log("VTerm", "Returning %i", MODULE_ERR_OK);
return MODULE_ERR_OK; return MODULE_ERR_OK;
} }
...@@ -318,12 +323,15 @@ void VT_SetResolution(int Width, int Height) ...@@ -318,12 +323,15 @@ void VT_SetResolution(int Width, int Height)
// Resize the text terminals // Resize the text terminals
giVT_RealWidth = mode.width; giVT_RealWidth = mode.width;
giVT_RealHeight = mode.height; giVT_RealHeight = mode.height;
Log_Debug("VTerm", "Resizing terminals to %ix%i",
giVT_RealWidth/giVT_CharWidth, giVT_RealHeight/giVT_CharHeight);
for( i = 0; i < NUM_VTS; i ++ ) for( i = 0; i < NUM_VTS; i ++ )
{ {
if( gVT_Terminals[i].Mode != TERM_MODE_TEXT ) continue; if( gVT_Terminals[i].Mode != TERM_MODE_TEXT ) continue;
gVT_Terminals[i].TextWidth = giVT_RealWidth/giVT_CharWidth; gVT_Terminals[i].TextWidth = giVT_RealWidth/giVT_CharWidth;
gVT_Terminals[i].TextHeight = giVT_RealHeight/giVT_CharHeight; gVT_Terminals[i].TextHeight = giVT_RealHeight/giVT_CharHeight;
gVT_Terminals[i].ScrollHeight = gVT_Terminals[i].TextHeight;
gVT_Terminals[i].Text = realloc( gVT_Terminals[i].Text = realloc(
gVT_Terminals[i].Text, gVT_Terminals[i].Text,
...@@ -1465,6 +1473,7 @@ void VT_int_ScrollFramebuffer( tVTerm *Term, int Count ) ...@@ -1465,6 +1473,7 @@ void VT_int_ScrollFramebuffer( tVTerm *Term, int Count )
// BLIT to 0,0 from 0,giVT_CharHeight // BLIT to 0,0 from 0,giVT_CharHeight
buf.Op = VIDEO_2DOP_BLIT; buf.Op = VIDEO_2DOP_BLIT;
buf.SrcX = 0; buf.DstX = 0; buf.SrcX = 0; buf.DstX = 0;
// TODO: Don't assume character dimensions
buf.W = Term->TextWidth * giVT_CharWidth; buf.W = Term->TextWidth * giVT_CharWidth;
if( Count > 0 ) if( Count > 0 )
{ {
......
...@@ -26,7 +26,7 @@ Uint64 DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length, ...@@ -26,7 +26,7 @@ Uint64 DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length,
" operation %i", op); " operation %i", op);
} }
if(op*4 > SizeofHandlers) { if(op*sizeof(void*) > SizeofHandlers) {
Log_Warning("DrvUtil", "DrvUtil_Video_2DStream: Driver does" Log_Warning("DrvUtil", "DrvUtil_Video_2DStream: Driver does"
" not support op %i", op); " not support op %i", op);
return Length-rem; return Length-rem;
...@@ -49,7 +49,7 @@ Uint64 DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length, ...@@ -49,7 +49,7 @@ Uint64 DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length,
Ent, Ent,
((Uint16*)stream)[0], ((Uint16*)stream)[1], ((Uint16*)stream)[0], ((Uint16*)stream)[1],
((Uint16*)stream)[2], ((Uint16*)stream)[3], ((Uint16*)stream)[2], ((Uint16*)stream)[3],
((Uint32*)stream)[4] ((Uint32*)stream)[2]
); );
rem -= 12; rem -= 12;
...@@ -72,7 +72,7 @@ Uint64 DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length, ...@@ -72,7 +72,7 @@ Uint64 DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length,
((Uint16*)stream)[4], ((Uint16*)stream)[5] ((Uint16*)stream)[4], ((Uint16*)stream)[5]
); );
rem -= 16; rem -= 12;
stream = (void*)((tVAddr)stream + 12); stream = (void*)((tVAddr)stream + 12);
break; break;
......
...@@ -13,12 +13,14 @@ ...@@ -13,12 +13,14 @@
int Module_int_Initialise(tModule *Module, const char *ArgString); int Module_int_Initialise(tModule *Module, const char *ArgString);
void Modules_int_GetBuiltinArray(void); void Modules_int_GetBuiltinArray(void);
void Modules_LoadBuiltins(void); void Modules_LoadBuiltins(void);
void Modules_SetBuiltinParams(char *Name, char *ArgString); void Modules_SetBuiltinParams(const char *Name, char *ArgString);
int Modules_InitialiseBuiltin(const char *Name);
// int Module_RegisterLoader(tModuleLoader *Loader); // int Module_RegisterLoader(tModuleLoader *Loader);
// int Module_LoadMem(void *Buffer, Uint Length, char *ArgString); // int Module_LoadMem(void *Buffer, Uint Length, char *ArgString);
// int Module_LoadFile(char *Path, char *ArgString); // int Module_LoadFile(char *Path, char *ArgString);
int Module_int_ResolveDeps(tModule *Info); int Module_int_ResolveDeps(tModule *Info);
int Module_IsLoaded(const char *Name); int Module_IsLoaded(const char *Name);
// int Module_EnsureLoaded(const char *Name);
// === EXPORTS === // === EXPORTS ===
EXPORT(Module_RegisterLoader); EXPORT(Module_RegisterLoader);
...@@ -283,7 +285,7 @@ int Modules_InitialiseBuiltin(const char *Name) ...@@ -283,7 +285,7 @@ int Modules_InitialiseBuiltin(const char *Name)
/** /**
* \brief Sets the parameters for a builtin module * \brief Sets the parameters for a builtin module
*/ */
void Modules_SetBuiltinParams(char *Name, char *ArgString) void Modules_SetBuiltinParams(const char *Name, char *ArgString)
{ {
int i; int i;
...@@ -429,3 +431,19 @@ int Module_IsLoaded(const char *Name) ...@@ -429,3 +431,19 @@ int Module_IsLoaded(const char *Name)
// not found - return false // not found - return false
return 0; return 0;
} }
/**
* \brief Load a module if needed
*/
int Module_EnsureLoaded(const char *Name)
{
if( Module_IsLoaded(Name) )
return 0;
if( Modules_InitialiseBuiltin(Name) == 0 )
return 0;
// TODO: Load from a file?
return -1;
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment