VESA - Debugging issue on VIA S3 BIOS
[tpg/acess2.git] / KernelLand / Kernel / drv / vterm.c
index b5e42d3..1cc60be 100644 (file)
@@ -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"
 //#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;
@@ -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");
 }

UCC git Repository :: git.ucc.asn.au