#define MAX_INPUT_CHARS32 64
#define MAX_INPUT_CHARS8 (MAX_INPUT_CHARS32*4)
#define VT_SCROLLBACK 2 // 2 Screens of text
-#define DEFAULT_OUTPUT "VGA"
+//#define DEFAULT_OUTPUT "VGA"
//#define DEFAULT_OUTPUT "BochsGA"
-//#define DEFAULT_OUTPUT "Vesa"
+#define DEFAULT_OUTPUT "Vesa"
#define DEFAULT_INPUT "PS2Keyboard"
#define DEFAULT_WIDTH 80
#define DEFAULT_HEIGHT 25
// === PROTOTYPES ===
int VT_Install(char **Arguments);
+void VT_InitOutput(void);
+void VT_InitInput(void);
char *VT_ReadDir(tVFS_Node *Node, int Pos);
tVFS_Node *VT_FindDir(tVFS_Node *Node, char *Name);
int VT_Root_IOCtl(tVFS_Node *Node, int Id, void *Data);
// Add to DevFS
DevFS_AddDevice( &gVT_DrvInfo );
+ VT_InitOutput();
+ VT_InitInput();
+
// Set kernel output to VT0
Debug_SetKTerminal("/Devices/VTerm/0");
void VT_InitOutput()
{
giVT_OutputDevHandle = VFS_Open(gsVT_OutputDevice, VFS_OPENFLAG_WRITE);
+ if(giVT_InputDevHandle == -1) {
+ Log_Warning("VTerm", "Oh F**k, I can't open the video device '%s'", gsVT_OutputDevice);
+ }
VT_SetTerminal( 0 );
VT_SetResolution(1, 640, 480);
}
giVT_RealHeight = mode.height;
VFS_IOCtl( giVT_OutputDevHandle, VIDEO_IOCTL_GETSETMODE, &tmp );
-
-
- if(IsTextMode)
- tmp = VIDEO_BUFFMT_TEXT;
- else
- tmp = VIDEO_BUFFMT_FRAMEBUFFER;
+ tmp = IsTextMode ? VIDEO_BUFFMT_TEXT : VIDEO_BUFFMT_FRAMEBUFFER;
VFS_IOCtl( giVT_OutputDevHandle, VIDEO_IOCTL_SETBUFFORMAT, &tmp );
}
* AcessOS 1\r
* Video BIOS Extensions (Vesa) Driver\r
*/\r
-#define DEBUG 1\r
+#define DEBUG 0\r
#define VERSION 0x100\r
\r
#include <acess.h>\r
\r
// === CONSTANTS ===\r
#define FLAG_LFB 0x1\r
+#define VESA_DEFAULT_FRAMEBUFFER (KERNEL_BASE|0xA0000)\r
\r
// === PROTOTYPES ===\r
int Vesa_Install(char **Arguments);\r
int giVesaCurrentMode = 0;\r
int giVesaCurrentFormat = VIDEO_BUFFMT_TEXT;\r
int giVesaDriverId = -1;\r
-char *gVesaFramebuffer = (void*)0xC00A0000;\r
+char *gpVesa_Framebuffer = (void*)VESA_DEFAULT_FRAMEBUFFER;\r
tVesa_Mode *gVesa_Modes;\r
int giVesaModeCount = 0;\r
int giVesaPageCount = 0;\r
// Call Interrupt\r
VM8086_Int(gpVesa_BiosState, 0x10);\r
if(gpVesa_BiosState->AX != 0x004F) {\r
- Log_Warning("Vesa", "Vesa_Install - VESA/VBE Unsupported (AX = 0x%x)\n", gpVesa_BiosState->AX);\r
+ Log_Warning("VESA", "Vesa_Install - VESA/VBE Unsupported (AX = 0x%x)\n", gpVesa_BiosState->AX);\r
return MODULE_ERR_NOTNEEDED;\r
}\r
\r
- Log_Debug("Vesa", "info->VideoModes = %04x:%04x", info->VideoModes.seg, info->VideoModes.ofs);\r
+ Log_Debug("VESA", "info->VideoModes = %04x:%04x", info->VideoModes.seg, info->VideoModes.ofs);\r
modes = (Uint16 *) VM8086_GetPointer(gpVesa_BiosState, info->VideoModes.seg, info->VideoModes.ofs);\r
\r
// Read Modes\r
gVesa_Modes[i].bpp = modeinfo->bpp;\r
\r
#if DEBUG\r
- Log_Log("Vesa", "0x%x - %ix%ix%i",\r
+ Log_Log("VESA", "0x%x - %ix%ix%i",\r
gVesa_Modes[i].code, gVesa_Modes[i].width, gVesa_Modes[i].height, gVesa_Modes[i].bpp);\r
#endif\r
}\r
tVT_Char *chars = Buffer;\r
int rem;\r
\r
+ Length /= sizeof(tVT_Char);\r
+ Offset /= sizeof(tVT_Char);\r
+ \r
if( giVesaCurrentFormat != VIDEO_BUFFMT_TEXT ) {\r
Log_Warning("VESA", "Vesa_Write - Mode 0 is not framebuffer");\r
LEAVE('i', -1);\r
return -1;\r
}\r
\r
- if( Offset + Length > 25*80*sizeof(tVT_Char) ) {\r
+ if( Offset + Length > 25*80 ) {\r
Log_Warning("VESA", "Vesa_Write - Framebuffer Overflow");\r
LEAVE('i', 0);\r
return 0;\r
}\r
\r
- fb += 2*(Offset/sizeof(tVT_Char));\r
+ fb += 2*Offset;\r
LOG("fb = %p", fb);\r
- for(rem = Length / sizeof(tVT_Char); rem --; fb ++, chars++)\r
+ for(rem = Length; rem --; fb ++, chars++)\r
{\r
if( chars->Ch < 0x80 )\r
*fb = chars->Ch & 0x7F;\r
//LOG("%08x (%03x,%03x) = %04x",\r
// chars->Ch, chars->BGCol, chars->FGCol, *fb);\r
}\r
- Length /= sizeof(tVT_Char);\r
Length *= sizeof(tVT_Char);\r
LEAVE('X', Length);\r
return Length;\r
case VIDEO_BUFFMT_TEXT:\r
{\r
tVT_Char *chars = Buffer;\r
- int pitch = gVesa_Modes[giVesaCurrentMode].width * giVT_CharWidth;\r
+ int pitch = gVesa_Modes[giVesaCurrentMode].width;\r
+ int widthInChars;\r
int x, y;\r
- Uint32 *dest;\r
- int rem;\r
+ Uint32 *dest = (void*)gpVesa_Framebuffer;\r
+ int i;\r
\r
+ Length /= sizeof(tVT_Char);\r
Offset /= sizeof(tVT_Char);\r
- dest = (void*)gVesaFramebuffer;\r
+ \r
LOG("gVesa_Modes[%i].width = %i", giVesaCurrentMode, gVesa_Modes[giVesaCurrentMode].width);\r
- x = (Offset % (gVesa_Modes[giVesaCurrentMode].width/giVT_CharWidth)) * giVT_CharWidth;\r
- y = (Offset / (gVesa_Modes[giVesaCurrentMode].width/giVT_CharWidth)) * giVT_CharHeight;\r
- LOG("(x,y) = (%i,%i)", x, y);\r
+ widthInChars = gVesa_Modes[giVesaCurrentMode].width/giVT_CharWidth;\r
+ x = Offset % widthInChars;\r
+ y = Offset / widthInChars;\r
+ LOG("(x,y) = (%i,%i) = [%i,%i]", x, y, x * giVT_CharWidth, y * giVT_CharHeight * pitch);\r
\r
// Sanity Check\r
- if(y > gVesa_Modes[giVesaCurrentMode].height) {\r
+ if(y > gVesa_Modes[giVesaCurrentMode].height/giVT_CharHeight) {\r
LEAVE('i', 0);\r
return 0;\r
}\r
\r
- dest += y * pitch;\r
+ dest += y * giVT_CharHeight * pitch;\r
dest += x * giVT_CharWidth;\r
- for( rem = Length / sizeof(tVT_Char); rem--; )\r
+ \r
+ LOG("dest = %p", dest);\r
+ \r
+ for( i = 0; i < Length; i++ )\r
{\r
VT_Font_Render(\r
chars->Ch,\r
dest += giVT_CharWidth;\r
\r
chars ++;\r
- x += giVT_CharWidth;\r
+ x ++;\r
if( x >= pitch ) {\r
x = 0;\r
- y += giVT_CharHeight;\r
+ y ++ ;\r
dest += pitch*(giVT_CharHeight-1);\r
}\r
}\r
- Length /= sizeof(tVT_Char);\r
Length *= sizeof(tVT_Char);\r
}\r
break;\r
\r
case VIDEO_BUFFMT_FRAMEBUFFER:\r
{\r
- Uint8 *destBuf = (Uint8*) ((Uint)gVesaFramebuffer + (Uint)Offset);\r
+ Uint8 *destBuf = (Uint8*) ((Uint)gpVesa_Framebuffer + (Uint)Offset);\r
\r
if(gVesa_Modes[giVesaCurrentMode].fbSize < Offset+Length)\r
{\r
\r
case VIDEO_IOCTL_SETBUFFORMAT:\r
ret = giVesaCurrentFormat;\r
- if(Data) giVesaCurrentFormat = *(int*)Data;\r
+ if(Data) {\r
+ Log_Log("VESA", "Buffer mode to %i", *(int*)Data);\r
+ giVesaCurrentFormat = *(int*)Data;\r
+ }\r
return ret;\r
\r
case VIDEO_IOCTL_REQLFB: // Request Linear Framebuffer\r
}\r
\r
int Vesa_Int_SetMode(int mode)\r
-{ \r
- #if DEBUG\r
- Log("Vesa_Int_SetMode: (mode=%i)", mode);\r
- #endif\r
+{\r
+ Log_Log("VESA", "Setting mode to %i", mode);\r
\r
// Sanity Check values\r
if(mode < 0 || mode > giVesaModeCount) return -1;\r
VM8086_Int(gpVesa_BiosState, 0x10);\r
\r
// Map Framebuffer\r
- MM_UnmapHWPages((tVAddr)gVesaFramebuffer, giVesaPageCount);\r
+ if( (tVAddr)gpVesa_Framebuffer != VESA_DEFAULT_FRAMEBUFFER )\r
+ MM_UnmapHWPages((tVAddr)gpVesa_Framebuffer, giVesaPageCount);\r
giVesaPageCount = (gVesa_Modes[mode].fbSize + 0xFFF) >> 12;\r
- gVesaFramebuffer = (void*)MM_MapHWPages(gVesa_Modes[mode].framebuffer, giVesaPageCount);\r
+ gpVesa_Framebuffer = (void*)MM_MapHWPages(gVesa_Modes[mode].framebuffer, giVesaPageCount);\r
\r
- Log("Vesa", "Framebuffer (Phys) = 0x%x", gVesa_Modes[mode].framebuffer);\r
- Log("Vesa", "Framebuffer (Virt) = 0x%x", gVesaFramebuffer);\r
+ Log_Log("VESA", "Framebuffer (Phys) = 0x%x", gVesa_Modes[mode].framebuffer);\r
+ Log_Log("VESA", "Framebuffer (Virt) = 0x%x", gpVesa_Framebuffer);\r
\r
// Record Mode Set\r
giVesaCurrentMode = mode;\r