Fixed login text-entry bug, fixes to KMS (graphics is still buggy)
authorJohn Hodge <[email protected]>
Wed, 21 Apr 2010 05:24:26 +0000 (13:24 +0800)
committerJohn Hodge <[email protected]>
Wed, 21 Apr 2010 05:24:26 +0000 (13:24 +0800)
Kernel/Makefile.BuildNum
Kernel/drv/vterm.c
Makefile.cfg
Modules/Display/BochsGA/bochsvbe.c
Usermode/Applications/login_src/main.c

index bacdc56..96d15cb 100644 (file)
@@ -1 +1 @@
-BUILD_NUM = 1933
+BUILD_NUM = 1946
index fe2ccd9..5c88786 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Acess2 Virtual Terminal Driver
  */
-#define DEBUG  0
+#define DEBUG  1
 #include <acess.h>
 #include <fs_devfs.h>
 #include <modules.h>
@@ -19,8 +19,8 @@
 #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       "BochsGA"
+//#define DEFAULT_OUTPUT       "VGA"
+#define DEFAULT_OUTPUT "BochsGA"
 //#define DEFAULT_OUTPUT       "Vesa"
 #define DEFAULT_INPUT  "PS2Keyboard"
 #define        DEFAULT_WIDTH   80
@@ -69,6 +69,7 @@ tVFS_Node     *VT_FindDir(tVFS_Node *Node, char *Name);
 Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
 Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
  int   VT_Terminal_IOCtl(tVFS_Node *Node, int Id, void *Data);
+void   VT_SetResolution(int IsTextMode, int Width, int Height);
 void   VT_SetTerminal(int ID);
 void   VT_KBCallBack(Uint32 Codepoint);
 void   VT_int_PutString(tVTerm *Term, Uint8 *Buffer, Uint Count);
@@ -204,6 +205,7 @@ void VT_InitOutput()
 {
        giVT_OutputDevHandle = VFS_Open(gsVT_OutputDevice, VFS_OPENFLAG_WRITE);
        VT_SetTerminal( 0 );
+       VT_SetResolution(1, 640, 480);
 }
 
 /**
@@ -490,6 +492,11 @@ void VT_SetTerminal(int ID)
                VFS_IOCtl(giVT_OutputDevHandle, VIDEO_IOCTL_SETCURSOR, &pos);
        }
        
+       if( gpVT_CurTerm->Mode == TERM_MODE_TEXT )
+               VT_SetResolution( 1, gpVT_CurTerm->Width*giVT_CharWidth, gpVT_CurTerm->Height*giVT_CharHeight );
+       else
+               VT_SetResolution( 0, gpVT_CurTerm->Width, gpVT_CurTerm->Height );
+       
        // Update the screen
        VT_int_UpdateScreen( &gVT_Terminals[ ID ], 1 );
 }
@@ -1009,7 +1016,7 @@ void VT_int_ChangeMode(tVTerm *Term, int NewMode)
 Uint8  *VT_Font_GetChar(Uint32 Codepoint);
 
 // === GLOBALS ===
-int    giVT_CharWidth = FONT_WIDTH+1;
+int    giVT_CharWidth = FONT_WIDTH;
 int    giVT_CharHeight = FONT_HEIGHT;
 
 // === CODE ===
index 51c4802..57c285a 100644 (file)
@@ -28,7 +28,7 @@ DRIVERS =
 MODULES  = Storage/ATA Storage/FDD
 MODULES += Network/NE2000
 MODULES += Display/VESA
-#MODULES += Display/BochsGA
+MODULES += Display/BochsGA
 MODULES += Filesystems/Ext2
 MODULES += Filesystems/FAT
 MODULES += IPStack
index 8f73ccb..3c8309e 100644 (file)
@@ -78,12 +78,11 @@ tDevFS_Driver       gBGA_DriverStruct = {
  int   giBGA_BufferFormat = 0;\r
 tVideo_IOCtl_Pos       gBGA_CursorPos = {-1,-1};\r
 Uint   *gBGA_Framebuffer;\r
-tBGA_Mode      gpBGA_CurrentMode;\r
+const tBGA_Mode        *gpBGA_CurrentMode;\r
 const tBGA_Mode        gBGA_Modes[] = {\r
-       {},\r
-       {640,480,32, 0, 640*480*4},\r
-       {800,600,32, 0, 800*600*4},\r
-       {1024,768,32, 0, 1024*768*4}\r
+       {640,480,32, 640*480*4},\r
+       {800,600,32, 800*600*4},\r
+       {1024,768,32, 1024*768*4}\r
 };\r
 #define        BGA_MODE_COUNT  (sizeof(gBGA_Modes)/sizeof(gBGA_Modes[0]))\r
 \r
@@ -111,7 +110,7 @@ int BGA_Install(char **Arguments)
        }\r
        \r
        // Map Framebuffer to hardware address\r
-       gBGA_Framebuffer = (void *) MM_MapHWPage(VBE_DISPI_LFB_PHYSICAL_ADDRESS, 768);  // 768 pages (3Mb)\r
+       gBGA_Framebuffer = (void *) MM_MapHWPages(VBE_DISPI_LFB_PHYSICAL_ADDRESS, 768); // 768 pages (3Mb)\r
        \r
        return MODULE_ERR_OK;\r
 }\r
@@ -122,7 +121,7 @@ int BGA_Install(char **Arguments)
 void BGA_Uninstall()\r
 {\r
        DevFS_DelDevice( &gBGA_DriverStruct );\r
-       MM_UnmapHWPage( VBE_DISPI_LFB_PHYSICAL_ADDRESS, 768 );\r
+       MM_UnmapHWPages( VBE_DISPI_LFB_PHYSICAL_ADDRESS, 768 );\r
 }\r
 \r
 /**\r
@@ -153,8 +152,8 @@ Uint64 BGA_Write(tVFS_Node *node, Uint64 off, Uint64 len, void *Buffer)
        \r
        // Check Mode\r
        if(giBGA_CurrentMode == -1) {\r
-               LEAVE('i', -1);\r
-               return -1;\r
+               Log_Notice("BGA", "Setting video mode to #0 (640x480x32)");\r
+               BGA_int_UpdateMode(0);  // Mode Zero is 640x480\r
        }\r
        \r
        // Text Mode\r
@@ -163,41 +162,39 @@ Uint64 BGA_Write(tVFS_Node *node, Uint64 off, Uint64 len, void *Buffer)
        case VIDEO_BUFFMT_TEXT:\r
                {\r
                tVT_Char        *chars = Buffer;\r
-                int    pitch = gpBGA_CurrentMode->width * giVT_CharWidth;\r
-                int    x, y;\r
+                int    x, y;   // Characters/Rows\r
+                int    widthInChars = gpBGA_CurrentMode->width/giVT_CharWidth;\r
                Uint32  *dest;\r
                \r
                off /= sizeof(tVT_Char);\r
-               dest = (void*)gBGA_Framebuffer;\r
-               x = (off % gpBGA_CurrentMode->width) * giVT_CharWidth;\r
-               y = (off / gpBGA_CurrentMode->width) * giVT_CharHeight;\r
+               len /= sizeof(tVT_Char);\r
+               \r
+               x = (off % widthInChars);\r
+               y = (off / widthInChars);\r
                \r
                // Sanity Check\r
-               if(y > gpBGA_CurrentMode->height) {\r
+               if(y > gpBGA_CurrentMode->height / giVT_CharHeight) {\r
                        LEAVE('i', 0);\r
                        return 0;\r
                }\r
                \r
-               dest += y * pitch;\r
-               dest += x * giVT_CharWidth;\r
-               len /= sizeof(tVT_Char);\r
+               dest = (Uint32 *)gBGA_Framebuffer;\r
+               dest += y * gpBGA_CurrentMode->width * giVT_CharHeight;\r
                while(len--)\r
                {\r
                        VT_Font_Render(\r
                                chars->Ch,\r
-                               dest, pitch,\r
+                               dest + x*giVT_CharWidth, gpBGA_CurrentMode->width,\r
                                VT_Colour12to24(chars->BGCol),\r
                                VT_Colour12to24(chars->FGCol)\r
                                );\r
                        \r
-                       dest += giVT_CharWidth;\r
-                       \r
                        chars ++;\r
-                       x += giVT_CharWidth;\r
-                       if( x >= pitch ) {\r
+                       x ++;\r
+                       if( x >= widthInChars ) {\r
                                x = 0;\r
-                               y += giVT_CharHeight;\r
-                               dest += pitch*(giVT_CharHeight-1);\r
+                               y ++;   // Why am I keeping track of this?\r
+                               dest += gpBGA_CurrentMode->width*giVT_CharHeight;\r
                        }\r
                }\r
                }\r
@@ -344,15 +341,9 @@ int BGA_int_UpdateMode(int id)
        // Sanity Check\r
        if(id < 0 || id >= BGA_MODE_COUNT)      return -1;\r
        \r
-       // Check if it is a text mode\r
-       if( gBGA_Modes[id].flags & MODEFLAG_TEXT )\r
-               BGA_int_SetMode(\r
-                       gBGA_Modes[id].width*giVT_CharWidth,\r
-                       gBGA_Modes[id].height*giVT_CharHeight);\r
-       else    // Graphics?\r
-               BGA_int_SetMode(\r
-                       gBGA_Modes[id].width,\r
-                       gBGA_Modes[id].height);\r
+       BGA_int_SetMode(\r
+               gBGA_Modes[id].width,\r
+               gBGA_Modes[id].height);\r
        \r
        giBGA_CurrentMode = id;\r
        gpBGA_CurrentMode = &gBGA_Modes[id];\r
@@ -379,10 +370,6 @@ int BGA_int_FindMode(tVideo_IOCtl_Mode *info)
                LogF("Mode %i (%ix%ix%i), ", i, gBGA_Modes[i].width, gBGA_Modes[i].height, gBGA_Modes[i].bpp);\r
                #endif\r
                \r
-               // Check if this mode is the same type as what we want\r
-               if( !(gBGA_Modes[i].flags & MODEFLAG_TEXT) != !(info->flags & VIDEO_FLAG_TEXT) )\r
-                       continue;\r
-               \r
                // Ooh! A perfect match\r
                if(gBGA_Modes[i].width == info->width\r
                && gBGA_Modes[i].height == info->height\r
@@ -417,10 +404,6 @@ int BGA_int_FindMode(tVideo_IOCtl_Mode *info)
        info->height = gBGA_Modes[best].height;\r
        info->bpp = gBGA_Modes[best].bpp;\r
        \r
-       info->flags = 0;\r
-       if(gBGA_Modes[best].flags & MODEFLAG_TEXT)\r
-               info->flags |= VIDEO_FLAG_TEXT;\r
-       \r
        return best;\r
 }\r
 \r
@@ -441,10 +424,6 @@ int BGA_int_ModeInfo(tVideo_IOCtl_Mode *info)
        info->height = gBGA_Modes[info->id].height;\r
        info->bpp = gBGA_Modes[info->id].bpp;\r
        \r
-       info->flags = 0;\r
-       if(gBGA_Modes[info->id].flags & MODEFLAG_TEXT)\r
-               info->flags |= VIDEO_FLAG_TEXT;\r
-       \r
        return 1;\r
 }\r
 \r
index 2866dbd..cf58c1b 100644 (file)
@@ -87,6 +87,7 @@ char *GetUsername()
        while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
        {
                if(ch == '\b') {
+                       if( pos == 0 )  continue;
                        pos --;
                        ret[pos] = '\0';
                }
@@ -122,6 +123,7 @@ char *GetPassword()
        while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
        {
                if(ch == '\b') {
+                       if( pos == 0 )  continue;
                        pos --;
                        ret[pos] = '\0';
                }

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