From: John Hodge Date: Tue, 22 Sep 2009 03:49:28 +0000 (+0800) Subject: Added cursor manipulation to vterm & vga X-Git-Tag: rel0.06~542 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=8a867fdf503d26e151bcc084a7147ba0f62271b0;p=tpg%2Facess2.git Added cursor manipulation to vterm & vga --- diff --git a/Kernel/drv/vga.c b/Kernel/drv/vga.c index 93f44f07..015423de 100644 --- a/Kernel/drv/vga.c +++ b/Kernel/drv/vga.c @@ -6,11 +6,16 @@ #include #include +// === CONSTANTS === +#define VGA_WIDTH 80 +#define VGA_HEIGHT 25 + // === PROTOTYPES === int VGA_Install(char **Arguments); Uint64 VGA_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer); int VGA_IOCtl(tVFS_Node *Node, int Id, void *Data); Uint16 VGA_int_GetWord(tVT_Char *Char); +void VGA_int_SetCursor(Sint16 x, Sint16 y); // === GLOBALS === MODULE_DEFINE(0, 0x000A, VGA, VGA_Install, NULL, NULL); @@ -18,7 +23,7 @@ tDevFS_Driver gVGA_DevInfo = { NULL, "VGA", { .NumACLs = 0, - .Size = 80*25*sizeof(tVT_Char), + .Size = VGA_WIDTH*VGA_HEIGHT*sizeof(tVT_Char), //.Read = VGA_Read, .Write = VGA_Write, .IOCtl = VGA_IOCtl @@ -85,15 +90,18 @@ int VGA_IOCtl(tVFS_Node *Node, int Id, void *Data) case DRV_IOCTL_VERSION: *(int*)Data = 50; return 1; case DRV_IOCTL_LOOKUP: return 0; - case VIDEO_IOCTL_SETMODE: return 0; // Ignored (Text Only ATM) case VIDEO_IOCTL_GETMODE: return 0; // Mode 0 only + case VIDEO_IOCTL_SETMODE: return 0; // Ignored (Text Only ATM) case VIDEO_IOCTL_FINDMODE: return 0; // Text Only! case VIDEO_IOCTL_MODEINFO: if( ((tVideo_IOCtl_Mode*)Data)->id != 0) return 0; - ((tVideo_IOCtl_Mode*)Data)->width = 80; - ((tVideo_IOCtl_Mode*)Data)->height = 25; + ((tVideo_IOCtl_Mode*)Data)->width = VGA_WIDTH; + ((tVideo_IOCtl_Mode*)Data)->height = VGA_HEIGHT; ((tVideo_IOCtl_Mode*)Data)->bpp = 4; return 1; + case VIDEO_IOCTL_SETCURSOR: + VGA_int_SetCursor( ((tVideo_IOCtl_Pos*)Data)->x, ((tVideo_IOCtl_Pos*)Data)->y ); + return 1; } return 0; } @@ -172,3 +180,18 @@ Uint16 VGA_int_GetWord(tVT_Char *Char) return ret; } + +/** + * \fn void VGA_int_SetCursor(Sint16 x, Sint16 y) + * \brief Updates the cursor position + */ +void VGA_int_SetCursor(Sint16 x, Sint16 y) +{ + int pos = x+y*VGA_WIDTH; + if(x == -1 || y == -1) + pos = -1; + outb(0x3D4, 14); + outb(0x3D5, pos >> 8); + outb(0x3D4, 15); + outb(0x3D5, pos); +} diff --git a/Kernel/drv/vterm.c b/Kernel/drv/vterm.c index bd50cd95..8aa7321b 100644 --- a/Kernel/drv/vterm.c +++ b/Kernel/drv/vterm.c @@ -17,6 +17,8 @@ #define DEFAULT_HEIGHT 25 #define DEFAULT_COLOUR (VT_COL_BLACK|(VT_COL_WHITE<<16)) +#define VT_FLAG_HIDECSR 0x01 + enum eVT_Modes { VT_MODE_TEXT8, // UTF-8 Text Mode (VT100 Emulation) VT_MODE_TEXT32, // UTF-32 Text Mode (Acess Native) @@ -30,6 +32,7 @@ enum eVT_Modes { // === TYPES === typedef struct { int Mode; + int Flags; int Width, Height; int ViewPos, WritePos; Uint32 CurColour; @@ -134,6 +137,7 @@ int VT_Install(char **Arguments) for( i = 0; i < NUM_VTS; i++ ) { gVT_Terminals[i].Mode = VT_MODE_TEXT8; + gVT_Terminals[i].Flags = 0; gVT_Terminals[i].Width = DEFAULT_WIDTH; gVT_Terminals[i].Height = DEFAULT_HEIGHT; gVT_Terminals[i].CurColour = DEFAULT_COLOUR; @@ -283,6 +287,7 @@ Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) //VT_int_PutString32(term, Buffer, Length); break; } + //LEAVE('i', 0); return 0; } @@ -336,6 +341,15 @@ void VT_int_PutString(tVTerm *Term, Uint8 *Buffer, Uint Count) VT_int_PutChar(Term, val); } } + + // Update cursor + if(Term->Flags & VT_FLAG_HIDECSR) + { + tVideo_IOCtl_Pos pos; + pos.x = Term->WritePos % Term->Width; + pos.y = Term->WritePos / Term->Width; + VFS_IOCtl(giVT_OutputDevHandle, VIDEO_IOCTL_SETCURSOR, &pos); + } } /** diff --git a/Kernel/include/tpl_drv_video.h b/Kernel/include/tpl_drv_video.h index 23d3907a..8f22c97d 100644 --- a/Kernel/include/tpl_drv_video.h +++ b/Kernel/include/tpl_drv_video.h @@ -37,6 +37,8 @@ enum eTplVideo_IOCtl { VIDEO_IOCTL_FINDMODE, //! \brief Get mode info - (tVideo_IOCtl_Mode *info) VIDEO_IOCTL_MODEINFO, + //! \brief Sets the cursor position (tVideo_IOCtl_Pos *pos) + VIDEO_IOCTL_SETCURSOR, //! \brief Request access to Framebuffer - (void *dest), Return Boolean Success VIDEO_IOCTL_REQLFB }; @@ -51,7 +53,12 @@ struct sVideo_IOCtl_Mode { Uint16 height; //!< Height Uint16 bpp; //!< Bits per Pixel }; +struct sVideo_IOCtl_Pos { + Sint16 x; + Sint16 y; +}; typedef struct sVideo_IOCtl_Mode tVideo_IOCtl_Mode; //!< Mode Type +typedef struct sVideo_IOCtl_Pos tVideo_IOCtl_Pos; //!< Mode Type /** * \struct sVT_Char