[BOOTVID] Reorganize some definitions used in the per-architecture bootvids (#8547)

In addition:
- simplify the no-op `PrepareForSetPixel()` definitions;
- const-ify immutable data arrays for the VGA PC bootvid.
This commit is contained in:
Hermès Bélusca-Maïto
2025-12-29 14:21:23 +01:00
parent 44e4781600
commit 5894d0b443
10 changed files with 45 additions and 66 deletions

View File

@@ -7,22 +7,6 @@
#pragma once
extern PUSHORT VgaArmBase;
#define LCDTIMING0_PPL(x) ((((x) / 16 - 1) & 0x3f) << 2)
#define LCDTIMING1_LPP(x) (((x) & 0x3ff) - 1)
#define LCDCONTROL_LCDPWR (1 << 11)
#define LCDCONTROL_LCDEN (1)
#define LCDCONTROL_LCDBPP(x) (((x) & 7) << 1)
#define LCDCONTROL_LCDTFT (1 << 5)
#define PL110_LCDTIMING0 (PVOID)0xE0020000
#define PL110_LCDTIMING1 (PVOID)0xE0020004
#define PL110_LCDTIMING2 (PVOID)0xE0020008
#define PL110_LCDUPBASE (PVOID)0xE0020010
#define PL110_LCDLPBASE (PVOID)0xE0020014
#define PL110_LCDCONTROL (PVOID)0xE0020018
#define READ_REGISTER_ULONG(r) (*(volatile ULONG * const)(r))
#define WRITE_REGISTER_ULONG(r, v) (*(volatile ULONG *)(r) = (v))
@@ -34,8 +18,7 @@ InitPaletteWithTable(
_In_reads_(Count) const ULONG* Table,
_In_ ULONG Count);
VOID
PrepareForSetPixel(VOID);
#define PrepareForSetPixel()
VOID
SetPixel(

View File

@@ -10,8 +10,24 @@
#define NDEBUG
#include <debug.h>
PUSHORT VgaArmBase;
PHYSICAL_ADDRESS VgaPhysical;
/* GLOBALS ********************************************************************/
#define LCDTIMING0_PPL(x) ((((x) / 16 - 1) & 0x3f) << 2)
#define LCDTIMING1_LPP(x) (((x) & 0x3ff) - 1)
#define LCDCONTROL_LCDPWR (1 << 11)
#define LCDCONTROL_LCDEN (1)
#define LCDCONTROL_LCDBPP(x) (((x) & 7) << 1)
#define LCDCONTROL_LCDTFT (1 << 5)
#define PL110_LCDTIMING0 (PVOID)0xE0020000
#define PL110_LCDTIMING1 (PVOID)0xE0020004
#define PL110_LCDTIMING2 (PVOID)0xE0020008
#define PL110_LCDUPBASE (PVOID)0xE0020010
#define PL110_LCDLPBASE (PVOID)0xE0020014
#define PL110_LCDCONTROL (PVOID)0xE0020018
static PUSHORT VgaArmBase;
static PHYSICAL_ADDRESS VgaPhysical;
/* PRIVATE FUNCTIONS *********************************************************/
@@ -31,13 +47,6 @@ VidpBuildColor(
return ((Red & 0x1F) << 11) | ((Green & 0x1F) << 6) | ((Blue & 0x1F));
}
VOID
PrepareForSetPixel(VOID)
{
/* Nothing to prepare */
NOTHING;
}
FORCEINLINE
VOID
SetPixel(

View File

@@ -7,12 +7,13 @@
*/
#include "precomp.h"
#include "vga.h"
//
// Minimal Attribute Controller Registers initialization command stream.
// Compatible EGA.
//
USHORT AT_Initialization[] =
const USHORT AT_Initialization[] =
{
/* Reset ATC to index mode */
IB,
@@ -43,7 +44,7 @@ USHORT AT_Initialization[] =
// 640x480 256-color 60Hz mode (BIOS mode 12) set command stream for VGA.
// Adapted from win32ss/drivers/miniport/vga_new/vgadata.c
//
USHORT VGA_640x480[] =
const USHORT VGA_640x480[] =
{
/* Write the Sequencer Registers */
OWM,

View File

@@ -12,7 +12,7 @@
static BOOLEAN
VgaInterpretCmdStream(
_In_ PUSHORT CmdStream)
_In_ const USHORT* CmdStream)
{
USHORT Cmd;
UCHAR Major, Minor;
@@ -23,7 +23,8 @@ VgaInterpretCmdStream(
USHORT ShortValue;
/* First make sure that we have a Command Stream */
if (!CmdStream) return TRUE;
if (!CmdStream)
return TRUE;
/* Loop as long as we have commands */
while (*CmdStream != EOD)
@@ -63,7 +64,7 @@ VgaInterpretCmdStream(
Count = *CmdStream++;
/* Write the USHORT to the port; the buffer is what's in the command stream */
WRITE_PORT_BUFFER_USHORT((PUSHORT)(VgaRegisterBase + Port), CmdStream, Count);
WRITE_PORT_BUFFER_USHORT((PUSHORT)(VgaRegisterBase + Port), (PUSHORT)CmdStream, Count);
/* Move past the buffer in the command stream */
CmdStream += Count;

View File

@@ -7,11 +7,13 @@
#pragma once
#include "vga.h"
extern ULONG_PTR VgaRegisterBase;
extern ULONG_PTR VgaBase;
extern USHORT AT_Initialization[];
extern USHORT VGA_640x480[];
extern UCHAR PixelMask[8];
extern const USHORT AT_Initialization[];
extern const USHORT VGA_640x480[];
extern const UCHAR PixelMask[8];
#define __inpb(Port) \
READ_PORT_UCHAR((PUCHAR)(VgaRegisterBase + (Port)))

View File

@@ -12,7 +12,7 @@
/* GLOBALS *******************************************************************/
static UCHAR lMaskTable[8] =
static const UCHAR lMaskTable[8] =
{
(1 << 8) - (1 << 0),
(1 << 7) - (1 << 0),
@@ -23,7 +23,7 @@ static UCHAR lMaskTable[8] =
(1 << 2) - (1 << 0),
(1 << 1) - (1 << 0)
};
static UCHAR rMaskTable[8] =
static const UCHAR rMaskTable[8] =
{
(1 << 7),
(1 << 7) + (1 << 6),
@@ -34,7 +34,7 @@ static UCHAR rMaskTable[8] =
(1 << 7) + (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3) + (1 << 2) + (1 << 1),
(1 << 7) + (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3) + (1 << 2) + (1 << 1) + (1 << 0),
};
UCHAR PixelMask[8] =
const UCHAR PixelMask[8] =
{
(1 << 7),
(1 << 6),
@@ -45,7 +45,7 @@ UCHAR PixelMask[8] =
(1 << 1),
(1 << 0),
};
static ULONG lookup[16] =
static const ULONG lookup[16] =
{
0x0000,
0x0100,

View File

@@ -8,14 +8,17 @@
/* INCLUDES *******************************************************************/
#include "precomp.h"
#include <drivers/pc98/video.h>
/* GLOBALS ********************************************************************/
static ULONG_PTR PegcControl = 0;
ULONG_PTR FrameBuffer = 0;
#define BYTES_PER_SCANLINE (SCREEN_WIDTH / 8)
#define PEGC_MAX_COLORS 256
static ULONG_PTR PegcControl = 0;
ULONG_PTR FrameBuffer = 0;
/* PRIVATE FUNCTIONS **********************************************************/
static BOOLEAN
@@ -318,12 +321,6 @@ PreserveRow(
WRITE_REGISTER_ULONG(NewPosition++, READ_REGISTER_ULONG(OldPosition++));
}
VOID
PrepareForSetPixel(VOID)
{
NOTHING;
}
VOID
DoScroll(
_In_ ULONG Scroll)

View File

@@ -7,13 +7,8 @@
#pragma once
/* INCLUDES *******************************************************************/
#include <drivers/pc98/video.h>
/* GLOBALS ********************************************************************/
#define BYTES_PER_SCANLINE (SCREEN_WIDTH / 8)
#define FB_OFFSET(x, y) ((y) * SCREEN_WIDTH + (x))
extern ULONG_PTR FrameBuffer;
@@ -25,8 +20,7 @@ InitPaletteWithTable(
_In_reads_(Count) const ULONG* Table,
_In_ ULONG Count);
VOID
PrepareForSetPixel(VOID);
#define PrepareForSetPixel()
FORCEINLINE
VOID

View File

@@ -15,6 +15,9 @@
/* GLOBALS ********************************************************************/
#define BB_OFFSET(x, y) ((y) * SCREEN_WIDTH + (x))
#define FB_OFFSET(x, y) (((PanV + (y)) * FrameBufferWidth + PanH + (x)) * BytesPerPixel)
static ULONG_PTR FrameBufferStart = 0;
static ULONG FrameBufferWidth, FrameBufferHeight, PanH, PanV;
static UCHAR BytesPerPixel;
@@ -248,13 +251,6 @@ InitPaletteWithTable(
ApplyPalette();
}
VOID
PrepareForSetPixel(VOID)
{
/* Nothing to prepare */
NOTHING;
}
VOID
SetPixel(
_In_ ULONG Left,

View File

@@ -9,16 +9,12 @@
#pragma once
#define BB_OFFSET(x, y) ((y) * SCREEN_WIDTH + (x))
#define FB_OFFSET(x, y) (((PanV + (y)) * FrameBufferWidth + PanH + (x)) * BytesPerPixel)
VOID
InitPaletteWithTable(
_In_reads_(Count) const ULONG* Table,
_In_ ULONG Count);
VOID
PrepareForSetPixel(VOID);
#define PrepareForSetPixel()
VOID
SetPixel(