#define NDEBUG
+/* BIOS Version number and Copyright */
+#include <reactos/buildno.h>
+#include <reactos/version.h>
+
#include "ntvdm.h"
#include "emulator.h"
#include "cpu/cpu.h"
#include "memory.h"
#include "bios.h"
+#include "bios32/bios32p.h"
+#include "rom.h"
#include "bios32/vbe.h"
// #include "vidbios.h"
+#include "bios32/vidbios32.h"
#include "io.h"
#include "hardware/video/svga.h"
-/* DEFINES ********************************************************************/
-
-/* BOP Identifiers */
-#define BOP_VIDEO_INT 0x10
-
/* MACROS *********************************************************************/
//
/* PRIVATE VARIABLES **********************************************************/
+/*
+ * WARNING! For compatibility purposes the string "IBM" should be at C000:001E.
+ */
+static const CHAR BiosInfo[] =
+ "00000000000 Emulation of IBM VGA Compatible ROM\0"
+ "CL-GD5434 VGA BIOS Version 1.41 \r\n"
+ "Copyright (C) ReactOS Team 1996-"COPYRIGHT_YEAR"\r\n"
+ "The original CL-GD5434 card was created by Cirrus Logic, Inc.\r\n\0"
+ "BIOS Date: 06/17/13\0";
+
+C_ASSERT(sizeof(BiosInfo)-1 <= 0xFF-0x05); // Ensures that we won't overflow on the Video Code
+
+
/*
* VGA Register Configurations for BIOS Video Modes.
* The configurations were checked against SeaBIOS VGA BIOS.
Attached = FALSE;
}
-BOOLEAN VidBiosInitialize(VOID)
+VOID VidBiosPost(VOID)
{
+ /*
+ * Initialize VGA BIOS32 RAM dynamic data
+ */
+
/* Some vectors are in fact addresses to tables */
((PULONG)BaseAddress)[0x1D] = (ULONG)NULL; // Video Parameter Tables
// Far pointer to the 8x8 graphics font for the 8x8 characters 80h-FFh
((PULONG)BaseAddress)[0x42] = (ULONG)NULL; // Relocated Default INT 10h Video Services
((PULONG)BaseAddress)[0x6D] = (ULONG)NULL; // Video BIOS Entry Point
- /* Initialize the VGA static function table */
- VgaStaticFuncTable = SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, VIDEO_STATE_INFO_OFFSET);
- RtlZeroMemory(VgaStaticFuncTable, sizeof(*VgaStaticFuncTable));
- VgaStaticFuncTable->SupportedModes[0] = 0xFF; // Modes 0x00 to 0x07 supported
- VgaStaticFuncTable->SupportedModes[1] = 0xFF; // Modes 0x08 to 0x0F supported
- VgaStaticFuncTable->SupportedModes[2] = 0x0F; // Modes 0x10 to 0x13 supported
- VgaStaticFuncTable->SupportedScanlines = 0x07; // Scanlines 200, 350 and 400 supported
- VgaStaticFuncTable->TextCharBlocksNumber = 0;
- VgaStaticFuncTable->MaxActiveTextCharBlocksNumber = 0;
- VgaStaticFuncTable->VGAFuncSupportFlags = 0x0CFD; // See: http://www.ctyme.com/intr/rb-0221.htm#Table46
- VgaStaticFuncTable->VGASavePtrFuncFlags = 0x18; // See: http://www.ctyme.com/intr/rb-0221.htm#Table47
-
- /* Fill the font tables */
- RtlMoveMemory(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, FONT_8x8_OFFSET),
- Font8x8, sizeof(Font8x8));
- RtlMoveMemory(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, FONT_8x16_OFFSET),
- Font8x16, sizeof(Font8x16));
- RtlMoveMemory(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, FONT_8x14_OFFSET),
- Font8x14, sizeof(Font8x14));
-
//
// FIXME: At the moment we always set a VGA mode. In the future,
// we should set this mode **only** when:
/* Synchronize our cursor position with VGA */
VidBiosSyncCursorPosition();
- /* Register the BIOS support BOPs */
- RegisterBop(BOP_VIDEO_INT, VidBiosVideoService);
+ /* Register the BIOS 32-bit Interrupts */
+ RegisterBiosInt32(BIOS_VIDEO_INTERRUPT, VidBiosVideoService);
+
+ /* Vectors that should be implemented */
+ RegisterBiosInt32(0x42, NULL); // Relocated Default INT 10h Video Services
+ RegisterBiosInt32(0x6D, NULL); // Video BIOS Entry Point
/* Initialize VBE */
VbeInitialized = VbeInitialize();
if (!VbeInitialized) DPRINT1("Couldn't initialize VBE!\n");
+}
+
+BOOLEAN VidBiosInitialize(VOID)
+{
+ UCHAR Checksum;
+
+ /*
+ * Initialize VGA BIOS32 static data
+ */
+
+ /* This is a ROM of size 'VIDEO_BIOS_ROM_SIZE' */
+ *(PWORD)(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, 0x0000)) = 0xAA55;
+ *(PBYTE)(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, 0x0002)) = VIDEO_BIOS_ROM_SIZE / 512; // Size in blocks of 512 bytes
+
+ /* Bootstrap code */
+ *(PWORD)(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, 0x0003)) = 0x90CB; // retf, nop
+ // RtlCopyMemory(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, 0xFFF0), Bootstrap, sizeof(Bootstrap));
+
+ /* Video BIOS Information */
+ RtlCopyMemory(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, 0x0005), BiosInfo, sizeof(BiosInfo)-1);
+
+ /* Initialize the VGA static function table */
+ VgaStaticFuncTable = SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, VIDEO_STATE_INFO_OFFSET);
+ RtlZeroMemory(VgaStaticFuncTable, sizeof(*VgaStaticFuncTable));
+ VgaStaticFuncTable->SupportedModes[0] = 0xFF; // Modes 0x00 to 0x07 supported
+ VgaStaticFuncTable->SupportedModes[1] = 0xFF; // Modes 0x08 to 0x0F supported
+ VgaStaticFuncTable->SupportedModes[2] = 0x0F; // Modes 0x10 to 0x13 supported
+ VgaStaticFuncTable->SupportedScanlines = 0x07; // Scanlines 200, 350 and 400 supported
+ VgaStaticFuncTable->TextCharBlocksNumber = 0;
+ VgaStaticFuncTable->MaxActiveTextCharBlocksNumber = 0;
+ VgaStaticFuncTable->VGAFuncSupportFlags = 0x0CFD; // See: http://www.ctyme.com/intr/rb-0221.htm#Table46
+ VgaStaticFuncTable->VGASavePtrFuncFlags = 0x18; // See: http://www.ctyme.com/intr/rb-0221.htm#Table47
+
+ /* Fill the font tables */
+ RtlMoveMemory(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, FONT_8x8_OFFSET),
+ Font8x8, sizeof(Font8x8));
+ RtlMoveMemory(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, FONT_8x16_OFFSET),
+ Font8x16, sizeof(Font8x16));
+ RtlMoveMemory(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, FONT_8x14_OFFSET),
+ Font8x14, sizeof(Font8x14));
+
+ VidBios32Initialize();
+
+ /* Compute the ROM checksum and store it */
+ *(PBYTE)(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, VIDEO_BIOS_ROM_SIZE - 1)) = 0x00;
+ Checksum = CalcRomChecksum(TO_LINEAR(VIDEO_BIOS_DATA_SEG, 0x0000), VIDEO_BIOS_ROM_SIZE);
+ *(PBYTE)(SEG_OFF_TO_PTR(VIDEO_BIOS_DATA_SEG, VIDEO_BIOS_ROM_SIZE - 1)) = (0xFF - Checksum + 1) & 0xFF;
+
+ WriteProtectRom((PVOID)TO_LINEAR(VIDEO_BIOS_DATA_SEG, 0x0000),
+ VIDEO_BIOS_ROM_SIZE);
return TRUE;
}