X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fdrv%2Fvterm.c;h=7d30511f4be7a09e221c14e0615e9c820b20d063;hb=6d88cd54792fd7c848f7bb2d1b93d002e2262ae2;hp=b5e42d3ea6141a42ffc9fe2ac67e79df59621908;hpb=c95a4a86afd477a8d6dc6949e0ce6175a41553d1;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/drv/vterm.c b/KernelLand/Kernel/drv/vterm.c index b5e42d3e..7d30511f 100644 --- a/KernelLand/Kernel/drv/vterm.c +++ b/KernelLand/Kernel/drv/vterm.c @@ -1,5 +1,9 @@ /* - * Acess2 Virtual Terminal Driver + * Acess2 Kernel + * - By John Hodge (thePowersGang) + * + * drv/vterm.c + * - Virtual Terminal - Initialisation and VFS Interface */ #define DEBUG 0 #include "vterm.h" @@ -17,10 +21,10 @@ //#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 === @@ -33,9 +37,12 @@ extern void Debug_SetKTerminal(const char *File); char *VT_ReadDir(tVFS_Node *Node, int Pos); tVFS_Node *VT_FindDir(tVFS_Node *Node, const char *Name); int VT_Root_IOCtl(tVFS_Node *Node, int Id, void *Data); -Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer); -Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer); +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 === @@ -160,7 +167,9 @@ int VT_Install(char **Arguments) 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; @@ -187,10 +196,12 @@ int VT_Install(char **Arguments) // Semaphore_Init(&gVT_Terminals[i].InputSemaphore, 0, MAX_INPUT_CHARS8, "VTerm", gVT_Terminals[i].Name); } + Log_Debug("VTerm", "Registering with DevFS"); // Add to DevFS 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; @@ -219,7 +230,7 @@ void VT_SetResolution(int Width, int Height) 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 ); @@ -340,7 +351,7 @@ int VT_Root_IOCtl(tVFS_Node *Node, int Id, void *Data) /** * \brief Read from a virtual terminal */ -Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) +size_t VT_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer) { int pos = 0; int avail; @@ -416,10 +427,9 @@ Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) } /** - * \fn Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer) * \brief Write to a virtual terminal */ -Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, const void *Buffer) +size_t VT_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer) { tVTerm *term = &gVT_Terminals[ Node->Inode ]; int size; @@ -700,6 +710,16 @@ int VT_Terminal_IOCtl(tVFS_Node *Node, int Id, void *Data) 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 @@ -738,6 +758,8 @@ void VT_SetTerminal(int ID) giVT_CurrentTerminal = ID; gpVT_CurTerm = &gVT_Terminals[ID]; + LOG("Attempting VT_SetMode"); + if( gpVT_CurTerm->Mode == TERM_MODE_TEXT ) { VT_SetMode( VIDEO_BUFFMT_TEXT ); @@ -749,7 +771,9 @@ void VT_SetTerminal(int ID) 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 @@ -759,9 +783,11 @@ void VT_SetTerminal(int ID) 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"); }