/**
+ * Acess2 Kernel VBE Driver
+ * - By John Hodge (thePowersGang)
+ *
+ * common.h
+ * - Driver-internal definitions
*/
#ifndef _COMMON_H_
#define _COMMON_H_
-// === TYPES ===
-typedef struct sFarPtr
-{
- Uint16 ofs;
- Uint16 seg;
-} tFarPtr;
+#include "vbe.h"
+
+/**
+ * \name Mode Flags
+ * \{
+ */
+#define FLAG_LFB 0x01 //!< Framebuffer is a linear framebufer
+#define FLAG_POPULATED 0x02 //!< Mode information is populated
+#define FLAG_VALID 0x04 //!< Mode is valid (usable)
+#define FLAG_GRAPHICS 0x08 //!< Graphics mode
+/**
+ * \}
+ */
+// === TYPES ===
typedef struct sVesa_Mode
{
Uint16 code;
Uint32 fbSize;
Uint32 framebuffer;
} tVesa_Mode;
-
-typedef struct sVesa_CallModeInfo
-{
- /**
- * 0 : Mode is supported
- * 1 : Optional information avaliable (Xres onwards)
- * 2 : BIOS Output Supported
- * 3 : Colour Mode?
- * 4 : Graphics mode?
- * -- VBE v2.0+
- * 5 : Mode is not VGA compatible
- * 6 : Bank switched mode supported
- * 7 : Linear framebuffer mode supported
- * 8 : Double-scan mode avaliable
- */
- Uint16 attributes;
- /**
- * 0 : Window exists
- * 1 : Window is readable
- * 2 : Window is writable
- */
- Uint8 winA,winB;
- Uint16 granularity;
- Uint16 winsize;
- Uint16 segmentA, segmentB;
- tFarPtr realFctPtr;
- Uint16 pitch; // Bytes per scanline
-
- Uint16 Xres, Yres;
- Uint8 Wchar, Ychar, planes, bpp, banks;
- Uint8 memory_model, bank_size, image_pages;
- Uint8 reserved0;
-
- // -- VBE v1.2+
- Uint8 red_mask, red_position;
- Uint8 green_mask, green_position;
- Uint8 blue_mask, blue_position;
- Uint8 rsv_mask, rsv_position;
- Uint8 directcolor_attributes;
-
- // -- VBE v2.0+
- Uint32 physbase;
- Uint32 offscreen_ptr; // Start of offscreen memory
- Uint16 offscreen_size_kb; // Size of offscreen memory
-
- // -- VBE v3.0
- Uint16 lfb_pitch;
- Uint8 image_count_banked;
- Uint8 image_count_lfb;
-} tVesa_CallModeInfo;
-
-typedef struct sVesa_CallInfo
-{
- char signature[4]; // == "VESA"
- Uint16 Version; // == 0x0300 for Vesa 3.0
- tFarPtr OEMString; // isa vbeFarPtr
- Uint8 Capabilities[4];
- tFarPtr VideoModes; // isa vbeParPtr
- Uint16 TotalMemory; // as # of 64KB blocks
-} tVesa_CallInfo;
-
#endif
#include <timers.h>\r
\r
// === CONSTANTS ===\r
-#define FLAG_LFB 0x1\r
-#define FLAG_POPULATED 0x2\r
-#define FLAG_VALID 0x4\r
+#define USE_BIOS 1\r
#define VESA_DEFAULT_FRAMEBUFFER (KERNEL_BASE|0xA0000)\r
#define BLINKING_CURSOR 0\r
#if BLINKING_CURSOR\r
// === CODE ===\r
int Vesa_Install(char **Arguments)\r
{\r
- int rv;\r
-\r
for( int i = 0; Arguments && Arguments[i]; i ++ )\r
{\r
if( strcmp(Arguments[i], "nobios") == 0 )\r
}\r
}\r
\r
+ #if USE_BIOS\r
if( !gbVesa_DisableBIOSCalls )\r
{\r
gpVesa_BiosState = VM8086_Init();\r
\r
- if( (rv = VBE_int_GetModeList()) )\r
- return rv;\r
+ int rv = VBE_int_GetModeList();\r
+ if(rv) return rv;\r
}\r
+ #endif\r
\r
#if BLINKING_CURSOR\r
// Create blink timer\r
return MODULE_ERR_OK;\r
}\r
\r
+#if USE_BIOS\r
int VBE_int_GetModeList(void)\r
{\r
tVesa_CallInfo *info;\r
}\r
return 0;\r
}\r
+#endif\r
\r
\r
void VBE_int_FillMode_Int(tVesa_Mode *Mode, const tVesa_CallModeInfo *vbeinfo)\r
S_LOG(*vbeinfo, image_count_lfb, "%i");\r
LOG("}");\r
#endif\r
-\r
+ \r
Mode->flags = FLAG_POPULATED;\r
+ // Check if this mode is supported by hardware\r
if( !(vbeinfo->attributes & 1) )\r
{\r
#if DEBUG\r
Mode->bpp = 0;\r
return ;\r
case 0x90:\r
- Mode->flags |= FLAG_LFB;\r
+ Mode->flags |= FLAG_LFB|FLAG_GRAPHICS;\r
Mode->framebuffer = vbeinfo->physbase;\r
Mode->fbSize = vbeinfo->Yres*vbeinfo->pitch;\r
break;\r
\r
void Vesa_int_FillModeList(void)\r
{\r
+ #if USE_BIOS\r
if( !gbVesaModesChecked && !gbVesa_DisableBIOSCalls )\r
{\r
tVesa_CallModeInfo *modeinfo;\r
\r
gbVesaModesChecked = 1;\r
}\r
+ #endif\r
}\r
\r
/**\r
*/\r
size_t Vesa_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer, Uint Flags)\r
{\r
- // Framebuffer modes - just pass on\r
- if( gpVesaCurMode->flags & FLAG_LFB )\r
- return DrvUtil_Video_WriteLFB(&gVesa_BufInfo, Offset, Length, Buffer);\r
- \r
- // EGA text mode translation\r
- switch( gVesa_BufInfo.BufferFormat )\r
+ switch( gpVesaCurMode->flags & (FLAG_LFB|FLAG_GRAPHICS) )\r
{\r
- case VIDEO_BUFFMT_TEXT: {\r
- int num = Length / sizeof(tVT_Char);\r
- int ofs = Offset / sizeof(tVT_Char);\r
- int i = 0;\r
- const tVT_Char *chars = Buffer;\r
- Uint16 word;\r
- \r
- for( ; num--; i ++, ofs ++)\r
+ case 0:\r
+ // EGA text mode translation\r
+ switch( gVesa_BufInfo.BufferFormat )\r
{\r
- word = VBE_int_GetWord( &chars[i] );\r
- ((Uint16*)gVesa_BufInfo.Framebuffer)[ ofs ] = word;\r
+ case VIDEO_BUFFMT_TEXT: {\r
+ int num = Length / sizeof(tVT_Char);\r
+ int ofs = Offset / sizeof(tVT_Char);\r
+ int i = 0;\r
+ const tVT_Char *chars = Buffer;\r
+ \r
+ for( ; num--; i ++, ofs ++)\r
+ {\r
+ Uint16 word = VBE_int_GetWord( &chars[i] );\r
+ ((Uint16*)gVesa_BufInfo.Framebuffer)[ ofs ] = word;\r
+ }\r
+ \r
+ return Length; }\r
+ case VIDEO_BUFFMT_2DSTREAM:\r
+ return DrvUtil_Video_2DStream(NULL, Buffer, Length,\r
+ &gVBE_Text2DFunctions, sizeof(gVBE_Text2DFunctions));\r
+ default:\r
+ Log_Warning("VBE", "TODO: Alternate modes in EGA text mode");\r
+ return 0;\r
}\r
- \r
- return Length; }\r
- case VIDEO_BUFFMT_2DSTREAM:\r
- return DrvUtil_Video_2DStream(NULL, Buffer, Length,\r
- &gVBE_Text2DFunctions, sizeof(gVBE_Text2DFunctions));\r
+ return 0;\r
+ case FLAG_LFB|FLAG_GRAPHICS:\r
+ // Framebuffer modes - use DrvUtil Video\r
+ return DrvUtil_Video_WriteLFB(&gVesa_BufInfo, Offset, Length, Buffer);\r
default:\r
- Log_Warning("VBE", "TODO: Alternate modes in EGA text mode");\r
+ Log_Warning("VBE", "TODO: _Write %s%s",\r
+ (gpVesaCurMode->flags & FLAG_LFB ? "FLAG_LFB" : ""),\r
+ (gpVesaCurMode->flags & FLAG_GRAPHICS ? "FLAG_GRAPHICS" : "")\r
+ );\r
return 0;\r
}\r
-\r
}\r
\r
const char *csaVESA_IOCtls[] = {DRV_IOCTLNAMES, DRV_VIDEO_IOCTLNAMES, NULL};\r
#endif\r
\r
Mutex_Acquire( &glVesa_Lock );\r
- \r
+\r
+ #if USE_BIOS\r
if( gbVesa_DisableBIOSCalls )\r
{\r
ASSERT(mode == -1);\r
\r
LOG("Out: AX = %04x", gpVesa_BiosState->AX);\r
}\r
+ #else\r
+ ASSERT(mode == -1);\r
+ #endif\r
\r
// Map Framebuffer\r
if( gpVesaCurMode )\r
--- /dev/null
+/*
+ * Acess2 Kernel VBE Driver
+ * - By John Hodge (thePowersGang)
+ *
+ * vbe.h
+ * - Definitions for VBE structures
+ */
+#ifndef _VBE_H_
+#define _VBE_H_
+
+typedef struct sFarPtr
+{
+ Uint16 ofs;
+ Uint16 seg;
+} tFarPtr;
+
+typedef struct sVesa_CallModeInfo
+{
+ /**
+ * 0 : Mode is supported
+ * 1 : Optional information avaliable (Xres onwards)
+ * 2 : BIOS Output Supported
+ * 3 : Colour Mode?
+ * 4 : Graphics mode?
+ * -- VBE v2.0+
+ * 5 : Mode is not VGA compatible
+ * 6 : Bank switched mode supported
+ * 7 : Linear framebuffer mode supported
+ * 8 : Double-scan mode avaliable
+ */
+ Uint16 attributes;
+ /**
+ * 0 : Window exists
+ * 1 : Window is readable
+ * 2 : Window is writable
+ */
+ Uint8 winA,winB;
+ Uint16 granularity;
+ Uint16 winsize;
+ Uint16 segmentA, segmentB;
+ tFarPtr realFctPtr;
+ Uint16 pitch; // Bytes per scanline
+
+ Uint16 Xres, Yres;
+ Uint8 Wchar, Ychar, planes, bpp, banks;
+ Uint8 memory_model, bank_size, image_pages;
+ Uint8 reserved0;
+
+ // -- VBE v1.2+
+ Uint8 red_mask, red_position;
+ Uint8 green_mask, green_position;
+ Uint8 blue_mask, blue_position;
+ Uint8 rsv_mask, rsv_position;
+ Uint8 directcolor_attributes;
+
+ // -- VBE v2.0+
+ Uint32 physbase;
+ Uint32 offscreen_ptr; // Start of offscreen memory
+ Uint16 offscreen_size_kb; // Size of offscreen memory
+
+ // -- VBE v3.0
+ Uint16 lfb_pitch;
+ Uint8 image_count_banked;
+ Uint8 image_count_lfb;
+} PACKED tVesa_CallModeInfo;
+
+typedef struct sVesa_CallInfo
+{
+ char signature[4]; // == "VESA"
+ Uint16 Version; // == 0x0300 for Vesa 3.0
+ tFarPtr OEMString; // isa vbeFarPtr
+ Uint8 Capabilities[4];
+ tFarPtr VideoModes; // isa vbeParPtr
+ Uint16 TotalMemory; // as # of 64KB blocks
+} PACKED tVesa_CallInfo;
+
+
+#endif
+