[FREELDR] Abstract VGA BIOS specific code (#1736)

* [FREELDR] Abstract VGA BIOS specific code

WinLdrSetupSpecialDataPointers() uses INT 10h video interrupts, but they are not available on Xbox, so make them machine-specific.

CORE-16204 CORE-16210

* [FREELDR] Abstract getting extended BIOS data area

WinLdrSetupSpecialDataPointers() uses INT 15h AH=C1h to get extended BIOS data area, but it's not available on Xbox, so make it machine-specific.

CORE-16204 CORE-16210
This commit is contained in:
Stanislav Motylkov 2019-07-19 00:09:59 +03:00 committed by Hermès BÉLUSCA - MAÏTO
parent 7547f85b7e
commit 74bcf3083d
8 changed files with 106 additions and 53 deletions

View file

@ -77,6 +77,27 @@ DBG_DEFAULT_CHANNEL(HWDETECT);
#define CONTROLLER_TIMEOUT 250 #define CONTROLLER_TIMEOUT 250
VOID
PcGetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
{
REGS BiosRegs;
/* Get address and size of the extended BIOS data area */
BiosRegs.d.eax = 0xC100;
Int386(0x15, &BiosRegs, &BiosRegs);
if (INT386_SUCCESS(BiosRegs))
{
*ExtendedBIOSDataArea = BiosRegs.w.es << 4;
*ExtendedBIOSDataSize = 1024;
}
else
{
WARN("Int 15h AH=C1h call failed\n");
*ExtendedBIOSDataArea = 0;
*ExtendedBIOSDataSize = 0;
}
}
// NOTE: Similar to machxbox.c!XboxGetHarddiskConfigurationData(), // NOTE: Similar to machxbox.c!XboxGetHarddiskConfigurationData(),
// but with extended geometry support. // but with extended geometry support.
static static
@ -1379,6 +1400,7 @@ PcMachInit(const char *CmdLine)
MachVtbl.VideoSetDisplayMode = PcVideoSetDisplayMode; MachVtbl.VideoSetDisplayMode = PcVideoSetDisplayMode;
MachVtbl.VideoGetDisplaySize = PcVideoGetDisplaySize; MachVtbl.VideoGetDisplaySize = PcVideoGetDisplaySize;
MachVtbl.VideoGetBufferSize = PcVideoGetBufferSize; MachVtbl.VideoGetBufferSize = PcVideoGetBufferSize;
MachVtbl.VideoGetFontsFromFirmware = PcVideoGetFontsFromFirmware;
MachVtbl.VideoSetTextCursorPosition = PcVideoSetTextCursorPosition; MachVtbl.VideoSetTextCursorPosition = PcVideoSetTextCursorPosition;
MachVtbl.VideoHideShowTextCursor = PcVideoHideShowTextCursor; MachVtbl.VideoHideShowTextCursor = PcVideoHideShowTextCursor;
MachVtbl.VideoPutChar = PcVideoPutChar; MachVtbl.VideoPutChar = PcVideoPutChar;
@ -1390,6 +1412,7 @@ PcMachInit(const char *CmdLine)
MachVtbl.Beep = PcBeep; MachVtbl.Beep = PcBeep;
MachVtbl.PrepareForReactOS = PcPrepareForReactOS; MachVtbl.PrepareForReactOS = PcPrepareForReactOS;
MachVtbl.GetMemoryMap = PcMemGetMemoryMap; MachVtbl.GetMemoryMap = PcMemGetMemoryMap;
MachVtbl.GetExtendedBIOSData = PcGetExtendedBIOSData;
MachVtbl.GetFloppyCount = PcGetFloppyCount; MachVtbl.GetFloppyCount = PcGetFloppyCount;
MachVtbl.DiskGetBootPath = PcDiskGetBootPath; MachVtbl.DiskGetBootPath = PcDiskGetBootPath;
MachVtbl.DiskReadLogicalSectors = PcDiskReadLogicalSectors; MachVtbl.DiskReadLogicalSectors = PcDiskReadLogicalSectors;

View file

@ -23,6 +23,14 @@
DBG_DEFAULT_CHANNEL(HWDETECT); DBG_DEFAULT_CHANNEL(HWDETECT);
VOID
XboxGetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize)
{
TRACE("XboxGetExtendedBIOSData(): UNIMPLEMENTED\n");
*ExtendedBIOSDataArea = 0;
*ExtendedBIOSDataSize = 0;
}
// NOTE: Similar to machpc.c!PcGetHarddiskConfigurationData(), // NOTE: Similar to machpc.c!PcGetHarddiskConfigurationData(),
// but without extended geometry support. // but without extended geometry support.
static static
@ -201,6 +209,7 @@ XboxMachInit(const char *CmdLine)
MachVtbl.VideoSetDisplayMode = XboxVideoSetDisplayMode; MachVtbl.VideoSetDisplayMode = XboxVideoSetDisplayMode;
MachVtbl.VideoGetDisplaySize = XboxVideoGetDisplaySize; MachVtbl.VideoGetDisplaySize = XboxVideoGetDisplaySize;
MachVtbl.VideoGetBufferSize = XboxVideoGetBufferSize; MachVtbl.VideoGetBufferSize = XboxVideoGetBufferSize;
MachVtbl.VideoGetFontsFromFirmware = XboxVideoGetFontsFromFirmware;
MachVtbl.VideoHideShowTextCursor = XboxVideoHideShowTextCursor; MachVtbl.VideoHideShowTextCursor = XboxVideoHideShowTextCursor;
MachVtbl.VideoPutChar = XboxVideoPutChar; MachVtbl.VideoPutChar = XboxVideoPutChar;
MachVtbl.VideoCopyOffScreenBufferToVRAM = XboxVideoCopyOffScreenBufferToVRAM; MachVtbl.VideoCopyOffScreenBufferToVRAM = XboxVideoCopyOffScreenBufferToVRAM;
@ -211,6 +220,7 @@ XboxMachInit(const char *CmdLine)
MachVtbl.Beep = PcBeep; MachVtbl.Beep = PcBeep;
MachVtbl.PrepareForReactOS = XboxPrepareForReactOS; MachVtbl.PrepareForReactOS = XboxPrepareForReactOS;
MachVtbl.GetMemoryMap = XboxMemGetMemoryMap; MachVtbl.GetMemoryMap = XboxMemGetMemoryMap;
MachVtbl.GetExtendedBIOSData = XboxGetExtendedBIOSData;
MachVtbl.GetFloppyCount = XboxGetFloppyCount; MachVtbl.GetFloppyCount = XboxGetFloppyCount;
MachVtbl.DiskGetBootPath = DiskGetBootPath; MachVtbl.DiskGetBootPath = DiskGetBootPath;
MachVtbl.DiskReadLogicalSectors = XboxDiskReadLogicalSectors; MachVtbl.DiskReadLogicalSectors = XboxDiskReadLogicalSectors;

View file

@ -118,6 +118,20 @@ static BOOLEAN VesaVideoMode = FALSE; /* Are we using a VESA
static SVGA_MODE_INFORMATION VesaVideoModeInformation; /* Only valid when in VESA mode */ static SVGA_MODE_INFORMATION VesaVideoModeInformation; /* Only valid when in VESA mode */
static ULONG CurrentMemoryBank = 0; /* Currently selected VESA bank */ static ULONG CurrentMemoryBank = 0; /* Currently selected VESA bank */
enum
{
INT1FhFont = 0x00,
INT43hFont = 0x01,
ROM_8x14CharacterFont = 0x02,
ROM_8x8DoubleDotFontLo = 0x03,
ROM_8x8DoubleDotFontHi = 0x04,
ROM_AlphaAlternate = 0x05,
ROM_8x16Font = 0x06,
ROM_Alternate9x16Font = 0x07,
UltraVision_8x20Font = 0x11,
UltraVision_8x10Font = 0x12,
};
static ULONG static ULONG
PcVideoDetectVideoCard(VOID) PcVideoDetectVideoCard(VOID)
{ {
@ -957,6 +971,40 @@ PcVideoGetBufferSize(VOID)
return ScreenHeight * BytesPerScanLine; return ScreenHeight * BytesPerScanLine;
} }
VOID
PcVideoGetFontsFromFirmware(PULONG RomFontPointers)
{
REGS BiosRegs;
/* Get the address of the BIOS ROM fonts.
Int 10h, AX=1130h, BH = pointer specifier
returns: es:bp = address */
BiosRegs.d.eax = 0x1130;
BiosRegs.b.bh = ROM_8x14CharacterFont;
Int386(0x10, &BiosRegs, &BiosRegs);
RomFontPointers[0] = BiosRegs.w.es << 4 | BiosRegs.w.bp;
BiosRegs.b.bh = ROM_8x8DoubleDotFontLo;
Int386(0x10, &BiosRegs, &BiosRegs);
RomFontPointers[1] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
BiosRegs.b.bh = ROM_8x8DoubleDotFontHi;
Int386(0x10, &BiosRegs, &BiosRegs);
RomFontPointers[2] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
BiosRegs.b.bh = ROM_AlphaAlternate;
Int386(0x10, &BiosRegs, &BiosRegs);
RomFontPointers[3] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
BiosRegs.b.bh = ROM_8x16Font;
Int386(0x10, &BiosRegs, &BiosRegs);
RomFontPointers[4] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
BiosRegs.b.bh = ROM_Alternate9x16Font;
Int386(0x10, &BiosRegs, &BiosRegs);
RomFontPointers[5] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
}
VOID VOID
PcVideoSetTextCursorPosition(UCHAR X, UCHAR Y) PcVideoSetTextCursorPosition(UCHAR X, UCHAR Y)
{ {

View file

@ -20,6 +20,9 @@
*/ */
#include <freeldr.h> #include <freeldr.h>
#include <debug.h>
DBG_DEFAULT_CHANNEL(UI);
static PVOID FrameBuffer; static PVOID FrameBuffer;
static ULONG ScreenWidth; static ULONG ScreenWidth;
@ -180,6 +183,12 @@ XboxVideoGetBufferSize(VOID)
return (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT * (ScreenWidth / CHAR_WIDTH) * 2; return (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT * (ScreenWidth / CHAR_WIDTH) * 2;
} }
VOID
XboxVideoGetFontsFromFirmware(PULONG RomFontPointers)
{
TRACE("XboxVideoGetFontsFromFirmware(): UNIMPLEMENTED\n");
}
VOID VOID
XboxVideoSetTextCursorPosition(UCHAR X, UCHAR Y) XboxVideoSetTextCursorPosition(UCHAR X, UCHAR Y)
{ {

View file

@ -35,6 +35,7 @@ VOID XboxVideoClearScreen(UCHAR Attr);
VIDEODISPLAYMODE XboxVideoSetDisplayMode(char *DisplayModem, BOOLEAN Init); VIDEODISPLAYMODE XboxVideoSetDisplayMode(char *DisplayModem, BOOLEAN Init);
VOID XboxVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth); VOID XboxVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth);
ULONG XboxVideoGetBufferSize(VOID); ULONG XboxVideoGetBufferSize(VOID);
VOID XboxVideoGetFontsFromFirmware(PULONG RomFontPointers);
VOID XboxVideoSetTextCursorPosition(UCHAR X, UCHAR Y); VOID XboxVideoSetTextCursorPosition(UCHAR X, UCHAR Y);
VOID XboxVideoHideShowTextCursor(BOOLEAN Show); VOID XboxVideoHideShowTextCursor(BOOLEAN Show);
VOID XboxVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y); VOID XboxVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y);

View file

@ -36,6 +36,7 @@ VOID PcVideoClearScreen(UCHAR Attr);
VIDEODISPLAYMODE PcVideoSetDisplayMode(char *DisplayMode, BOOLEAN Init); VIDEODISPLAYMODE PcVideoSetDisplayMode(char *DisplayMode, BOOLEAN Init);
VOID PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth); VOID PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth);
ULONG PcVideoGetBufferSize(VOID); ULONG PcVideoGetBufferSize(VOID);
VOID PcVideoGetFontsFromFirmware(PULONG RomFontPointers);
VOID PcVideoSetTextCursorPosition(UCHAR X, UCHAR Y); VOID PcVideoSetTextCursorPosition(UCHAR X, UCHAR Y);
VOID PcVideoHideShowTextCursor(BOOLEAN Show); VOID PcVideoHideShowTextCursor(BOOLEAN Show);
VOID PcVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y); VOID PcVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y);

View file

@ -46,6 +46,7 @@ typedef struct tagMACHVTBL
VIDEODISPLAYMODE (*VideoSetDisplayMode)(char *DisplayMode, BOOLEAN Init); VIDEODISPLAYMODE (*VideoSetDisplayMode)(char *DisplayMode, BOOLEAN Init);
VOID (*VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth); VOID (*VideoGetDisplaySize)(PULONG Width, PULONG Height, PULONG Depth);
ULONG (*VideoGetBufferSize)(VOID); ULONG (*VideoGetBufferSize)(VOID);
VOID (*VideoGetFontsFromFirmware)(PULONG RomFontPointers);
VOID (*VideoSetTextCursorPosition)(UCHAR X, UCHAR Y); VOID (*VideoSetTextCursorPosition)(UCHAR X, UCHAR Y);
VOID (*VideoHideShowTextCursor)(BOOLEAN Show); VOID (*VideoHideShowTextCursor)(BOOLEAN Show);
VOID (*VideoPutChar)(int Ch, UCHAR Attr, unsigned X, unsigned Y); VOID (*VideoPutChar)(int Ch, UCHAR Attr, unsigned X, unsigned Y);
@ -60,6 +61,7 @@ typedef struct tagMACHVTBL
// NOTE: Not in the machine.c ... // NOTE: Not in the machine.c ...
FREELDR_MEMORY_DESCRIPTOR* (*GetMemoryDescriptor)(FREELDR_MEMORY_DESCRIPTOR* Current); FREELDR_MEMORY_DESCRIPTOR* (*GetMemoryDescriptor)(FREELDR_MEMORY_DESCRIPTOR* Current);
PFREELDR_MEMORY_DESCRIPTOR (*GetMemoryMap)(PULONG MaxMemoryMapSize); PFREELDR_MEMORY_DESCRIPTOR (*GetMemoryMap)(PULONG MaxMemoryMapSize);
VOID (*GetExtendedBIOSData)(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize);
UCHAR (*GetFloppyCount)(VOID); UCHAR (*GetFloppyCount)(VOID);
BOOLEAN (*DiskGetBootPath)(PCHAR BootPath, ULONG Size); BOOLEAN (*DiskGetBootPath)(PCHAR BootPath, ULONG Size);
@ -96,6 +98,8 @@ VOID MachInit(const char *CmdLine);
MachVtbl.VideoGetDisplaySize((W), (H), (D)) MachVtbl.VideoGetDisplaySize((W), (H), (D))
#define MachVideoGetBufferSize() \ #define MachVideoGetBufferSize() \
MachVtbl.VideoGetBufferSize() MachVtbl.VideoGetBufferSize()
#define MachVideoGetFontsFromFirmware(RomFontPointers) \
MachVtbl.VideoGetFontsFromFirmware((RomFontPointers))
#define MachVideoSetTextCursorPosition(X, Y) \ #define MachVideoSetTextCursorPosition(X, Y) \
MachVtbl.VideoSetTextCursorPosition((X), (Y)) MachVtbl.VideoSetTextCursorPosition((X), (Y))
#define MachVideoHideShowTextCursor(Show) \ #define MachVideoHideShowTextCursor(Show) \
@ -116,6 +120,8 @@ VOID MachInit(const char *CmdLine);
MachVtbl.Beep() MachVtbl.Beep()
#define MachPrepareForReactOS() \ #define MachPrepareForReactOS() \
MachVtbl.PrepareForReactOS() MachVtbl.PrepareForReactOS()
#define MachGetExtendedBIOSData(ExtendedBIOSDataArea, ExtendedBIOSDataSize) \
MachVtbl.GetExtendedBIOSData((ExtendedBIOSDataArea), (ExtendedBIOSDataSize))
#define MachGetFloppyCount() \ #define MachGetFloppyCount() \
MachVtbl.GetFloppyCount() MachVtbl.GetFloppyCount()
#define MachDiskGetBootPath(Path, Size) \ #define MachDiskGetBootPath(Path, Size) \

View file

@ -287,69 +287,24 @@ WinLdrMapSpecialPages(void)
#define ExtendedBIOSDataSize ((PULONG)0x744) #define ExtendedBIOSDataSize ((PULONG)0x744)
#define RomFontPointers ((PULONG)0x700) #define RomFontPointers ((PULONG)0x700)
enum
{
INT1FhFont = 0x00,
INT43hFont = 0x01,
ROM_8x14CharacterFont = 0x02,
ROM_8x8DoubleDotFontLo = 0x03,
ROM_8x8DoubleDotFontHi = 0x04,
ROM_AlphaAlternate = 0x05,
ROM_8x16Font = 0x06,
ROM_Alternate9x16Font = 0x07,
UltraVision_8x20Font = 0x11,
UltraVision_8x10Font = 0x12,
};
static static
void WinLdrSetupSpecialDataPointers(VOID) void WinLdrSetupSpecialDataPointers(VOID)
{ {
REGS BiosRegs; /* Get the address of the BIOS ROM fonts. Win 2003 videoprt reads these
/* Get the address of the bios rom fonts. Win 2003 videoprt reads these
values from address 0x700 .. 0x718 and store them in the registry values from address 0x700 .. 0x718 and store them in the registry
in HKLM\System\CurrentControlSet\Control\Wow\RomFontPointers in HKLM\System\CurrentControlSet\Control\Wow\RomFontPointers */
Int 10h, AX=1130h, BH = pointer specifier MachVideoGetFontsFromFirmware(RomFontPointers);
returns: es:bp = address */
BiosRegs.d.eax = 0x1130;
BiosRegs.b.bh = ROM_8x14CharacterFont;
Int386(0x10, &BiosRegs, &BiosRegs);
RomFontPointers[0] = BiosRegs.w.es << 4 | BiosRegs.w.bp;
BiosRegs.b.bh = ROM_8x8DoubleDotFontLo; /* Store address of the extended BIOS data area in 0x740 */
Int386(0x10, &BiosRegs, &BiosRegs); MachGetExtendedBIOSData(ExtendedBIOSDataArea, ExtendedBIOSDataSize);
RomFontPointers[1] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
BiosRegs.b.bh = ROM_8x8DoubleDotFontHi; if (*ExtendedBIOSDataArea == 0 && *ExtendedBIOSDataSize == 0)
Int386(0x10, &BiosRegs, &BiosRegs);
RomFontPointers[2] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
BiosRegs.b.bh = ROM_AlphaAlternate;
Int386(0x10, &BiosRegs, &BiosRegs);
RomFontPointers[3] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
BiosRegs.b.bh = ROM_8x16Font;
Int386(0x10, &BiosRegs, &BiosRegs);
RomFontPointers[4] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
BiosRegs.b.bh = ROM_Alternate9x16Font;
Int386(0x10, &BiosRegs, &BiosRegs);
RomFontPointers[5] = BiosRegs.w.es << 16 | BiosRegs.w.bp;
/* Store address of the extended bios data area in 0x740 */
BiosRegs.d.eax = 0xC100;
Int386(0x15, &BiosRegs, &BiosRegs);
if (INT386_SUCCESS(BiosRegs))
{ {
*ExtendedBIOSDataArea = BiosRegs.w.es << 4; WARN("Couldn't get address of extended BIOS data area\n");
*ExtendedBIOSDataSize = 1024;
TRACE("*ExtendedBIOSDataArea = 0x%lx\n", *ExtendedBIOSDataArea);
} }
else else
{ {
WARN("Couldn't get address of extended BIOS data area\n"); TRACE("*ExtendedBIOSDataArea = 0x%lx\n", *ExtendedBIOSDataArea);
*ExtendedBIOSDataArea = 0;
*ExtendedBIOSDataSize = 0;
} }
} }