//#define DEFAULT_OUTPUT "BochsGA"
#define DEFAULT_OUTPUT "Vesa"
#define FALLBACK_OUTPUT "x86_VGAText"
-#define DEFAULT_INPUT "PS2Keyboard"
+#define DEFAULT_INPUT "Keyboard"
#define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 480
-#define DEFAULT_SCROLLBACK 2 // 2 Screens of text + current screen
+#define DEFAULT_SCROLLBACK 4 // 2 Screens of text + current screen
//#define DEFAULT_SCROLLBACK 0
// === TYPES ===
// === PROTOTYPES ===
int VT_Install(char **Arguments);
-char *VT_ReadDir(tVFS_Node *Node, int Pos);
+ int VT_ReadDir(tVFS_Node *Node, int Pos, char Dest[FILENAME_MAX]);
tVFS_Node *VT_FindDir(tVFS_Node *Node, const char *Name);
int VT_Root_IOCtl(tVFS_Node *Node, int Id, void *Data);
size_t VT_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
size_t VT_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer);
int VT_Terminal_IOCtl(tVFS_Node *Node, int Id, void *Data);
+void VT_Terminal_Reference(tVFS_Node *Node);
+void VT_Terminal_Close(tVFS_Node *Node);
+//void VT_SetTerminal(int Term);
// === CONSTANTS ===
VT_InitOutput();
VT_InitInput();
+
// Create Nodes
+ Log_Debug("VTerm", "Initialising nodes (and creating buffers)");
for( i = 0; i < NUM_VTS; i++ )
{
gVT_Terminals[i].Mode = TERM_MODE_TEXT;
DevFS_AddDevice( &gVT_DrvInfo );
// Set kernel output to VT0
+ Log_Debug("VTerm", "Setting kernel output to VT#0");
Debug_SetKTerminal("/Devices/VTerm/0");
return MODULE_ERR_OK;
if( Width != mode.width || Height != mode.height )
{
Log_Warning("VTerm",
- "Selected resolution (%ix%i is not supported) by the device, using (%ix%i)",
+ "Selected resolution (%ix%i) is not supported by the device, using (%ix%i)",
giVT_RealWidth, giVT_RealHeight,
mode.width, mode.height
);
* \fn char *VT_ReadDir(tVFS_Node *Node, int Pos)
* \brief Read from the VTerm Directory
*/
-char *VT_ReadDir(tVFS_Node *Node, int Pos)
+int VT_ReadDir(tVFS_Node *Node, int Pos, char Dest[FILENAME_MAX])
{
- if(Pos < 0) return NULL;
- if(Pos >= NUM_VTS) return NULL;
- return strdup( gVT_Terminals[Pos].Name );
+ if(Pos < 0) return -EINVAL;
+ if(Pos >= NUM_VTS) return -EINVAL;
+ strncpy(Dest, gVT_Terminals[Pos].Name, FILENAME_MAX);
+ return 0;
}
/**
*/
size_t VT_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
{
- int pos = 0;
- int avail;
+ int pos, avail;
tVTerm *term = &gVT_Terminals[ Node->Inode ];
Uint32 *codepoint_buf = Buffer;
Uint32 *codepoint_in;
avail = term->InputWrite - term->InputRead;
if(avail < 0)
avail += MAX_INPUT_CHARS8;
- if(avail > Length - pos)
- avail = Length - pos;
+ if(avail > Length)
+ avail = Length;
+ pos = 0;
while( avail -- )
{
((char*)Buffer)[pos] = term->InputBuffer[term->InputRead];
if(avail < 0)
avail += MAX_INPUT_CHARS32;
Length /= 4;
- if(avail > Length - pos)
- avail = Length - pos;
+ if(avail > Length)
+ avail = Length;
codepoint_in = (void*)term->InputBuffer;
codepoint_buf = Buffer;
+ pos = 0;
while( avail -- )
{
codepoint_buf[pos] = codepoint_in[term->InputRead];
return -1;
}
+void VT_Terminal_Reference(tVFS_Node *Node)
+{
+ // Append PID to list
+}
+
+void VT_Terminal_Close(tVFS_Node *Node)
+{
+ // Remove PID from list
+}
+
/**
* \fn void VT_SetTerminal(int ID)
* \brief Set the current terminal
giVT_CurrentTerminal = ID;
gpVT_CurTerm = &gVT_Terminals[ID];
+ LOG("Attempting VT_SetMode");
+
if( gpVT_CurTerm->Mode == TERM_MODE_TEXT )
{
VT_SetMode( VIDEO_BUFFMT_TEXT );
VFS_IOCtl(giVT_OutputDevHandle, VIDEO_IOCTL_SETCURSORBITMAP, gpVT_CurTerm->VideoCursor);
VT_SetMode( VIDEO_BUFFMT_FRAMEBUFFER );
}
-
+
+ LOG("Mode set");
+
if(gpVT_CurTerm->Buffer)
{
// TODO: Handle non equal sized
gpVT_CurTerm->Width*gpVT_CurTerm->Height*sizeof(Uint32),
gpVT_CurTerm->Buffer
);
+ LOG("Updated screen contents");
}
VT_int_UpdateCursor(gpVT_CurTerm, 1);
// Update the screen
VT_int_UpdateScreen(gpVT_CurTerm, 1);
+ LOG("done");
}