Skip to content

Commit 617f3bd

Browse files
committed
[FREELDR:PC] Cache the type of video card installed on the system (reactos#8505)
Cache the type when initializing the video, instead of invoking every time `PcVideoDetectVideoCard()`. Indeed, the video card is not going to change magically at runtime by the user :D
1 parent 0ffed7f commit 617f3bd

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

boot/freeldr/freeldr/arch/i386/pc/machpc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,6 +1807,7 @@ MachInit(const char *CmdLine)
18071807
MachVtbl.HwIdle = PcHwIdle;
18081808

18091809
HalpCalibrateStallExecution();
1810+
PcVideoInit();
18101811
}
18111812

18121813
VOID

boot/freeldr/freeldr/arch/i386/pc/pcvideo.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ typedef struct
110110

111111
UCHAR MachDefaultTextColor = COLOR_GRAY;
112112

113+
static ULONG VideoCard = VIDEOCARD_CGA_OR_OTHER; /* Type of video card installed on the system */
113114
static USHORT BiosVideoMode; /* Current video mode as known by BIOS */
114115
static ULONG ScreenWidth = 80; /* Screen Width in characters */
115116
static ULONG ScreenHeight = 25; /* Screen Height in characters */
@@ -587,7 +588,7 @@ PcVideoSetMode80x25(VOID)
587588
static BOOLEAN
588589
PcVideoSetMode80x50_80x43(VOID)
589590
{
590-
if (VIDEOCARD_VGA == PcVideoDetectVideoCard())
591+
if (VideoCard == VIDEOCARD_VGA)
591592
{
592593
PcVideoSetBiosMode(0x03);
593594
PcVideoSetFont8x8();
@@ -597,7 +598,7 @@ PcVideoSetMode80x50_80x43(VOID)
597598
ScreenWidth = 80;
598599
ScreenHeight = 50;
599600
}
600-
else if (VIDEOCARD_EGA == PcVideoDetectVideoCard())
601+
else if (VideoCard == VIDEOCARD_EGA)
601602
{
602603
PcVideoSetBiosMode(0x03);
603604
PcVideoSetFont8x8();
@@ -843,6 +844,13 @@ PcVideoSetMemoryBank(USHORT BankNumber)
843844
CurrentMemoryBank = BankNumber;
844845
}
845846

847+
VOID
848+
PcVideoInit(VOID)
849+
{
850+
/* Detect the installed video card */
851+
VideoCard = PcVideoDetectVideoCard();
852+
}
853+
846854
VIDEODISPLAYMODE
847855
PcVideoSetDisplayMode(PCSTR DisplayModeName, BOOLEAN Init)
848856
{
@@ -854,21 +862,21 @@ PcVideoSetDisplayMode(PCSTR DisplayModeName, BOOLEAN Init)
854862
return DisplayMode;
855863
}
856864

857-
if (VIDEOCARD_CGA_OR_OTHER == PcVideoDetectVideoCard())
865+
if (VideoCard == VIDEOCARD_CGA_OR_OTHER)
858866
{
859867
TRACE("CGA or other display adapter detected.\n");
860868
printf("CGA or other display adapter detected.\n");
861869
printf("Using 80x25 text mode.\n");
862870
VideoMode = VIDEOMODE_NORMAL_TEXT;
863871
}
864-
else if (VIDEOCARD_EGA == PcVideoDetectVideoCard())
872+
else if (VideoCard == VIDEOCARD_EGA)
865873
{
866874
TRACE("EGA display adapter detected.\n");
867875
printf("EGA display adapter detected.\n");
868876
printf("Using 80x25 text mode.\n");
869877
VideoMode = VIDEOMODE_NORMAL_TEXT;
870878
}
871-
else /* if (VIDEOCARD_VGA == PcVideoDetectVideoCard()) */
879+
else /* VIDEOCARD_VGA */
872880
{
873881
TRACE("VGA display adapter detected.\n");
874882

boot/freeldr/freeldr/include/arch/pc/machpc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ VOID PcConsPutChar(int Ch);
3030
BOOLEAN PcConsKbHit(VOID);
3131
int PcConsGetCh(VOID);
3232

33+
VOID PcVideoInit(VOID);
3334
VOID PcVideoClearScreen(UCHAR Attr);
3435
VIDEODISPLAYMODE PcVideoSetDisplayMode(PCSTR DisplayMode, BOOLEAN Init);
3536
VOID PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth);

0 commit comments

Comments
 (0)