Skip to content

Commit 5894d0b

Browse files
committed
[BOOTVID] Reorganize some definitions used in the per-architecture bootvids (reactos#8547)
In addition: - simplify the no-op `PrepareForSetPixel()` definitions; - const-ify immutable data arrays for the VGA PC bootvid.
1 parent 44e4781 commit 5894d0b

10 files changed

Lines changed: 45 additions & 66 deletions

File tree

‎drivers/base/bootvid/arm/arm.h‎

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,6 @@
77

88
#pragma once
99

10-
extern PUSHORT VgaArmBase;
11-
12-
#define LCDTIMING0_PPL(x) ((((x) / 16 - 1) & 0x3f) << 2)
13-
#define LCDTIMING1_LPP(x) (((x) & 0x3ff) - 1)
14-
#define LCDCONTROL_LCDPWR (1 << 11)
15-
#define LCDCONTROL_LCDEN (1)
16-
#define LCDCONTROL_LCDBPP(x) (((x) & 7) << 1)
17-
#define LCDCONTROL_LCDTFT (1 << 5)
18-
19-
#define PL110_LCDTIMING0 (PVOID)0xE0020000
20-
#define PL110_LCDTIMING1 (PVOID)0xE0020004
21-
#define PL110_LCDTIMING2 (PVOID)0xE0020008
22-
#define PL110_LCDUPBASE (PVOID)0xE0020010
23-
#define PL110_LCDLPBASE (PVOID)0xE0020014
24-
#define PL110_LCDCONTROL (PVOID)0xE0020018
25-
2610
#define READ_REGISTER_ULONG(r) (*(volatile ULONG * const)(r))
2711
#define WRITE_REGISTER_ULONG(r, v) (*(volatile ULONG *)(r) = (v))
2812

@@ -34,8 +18,7 @@ InitPaletteWithTable(
3418
_In_reads_(Count) const ULONG* Table,
3519
_In_ ULONG Count);
3620

37-
VOID
38-
PrepareForSetPixel(VOID);
21+
#define PrepareForSetPixel()
3922

4023
VOID
4124
SetPixel(

‎drivers/base/bootvid/arm/bootvid.c‎

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,24 @@
1010
#define NDEBUG
1111
#include <debug.h>
1212

13-
PUSHORT VgaArmBase;
14-
PHYSICAL_ADDRESS VgaPhysical;
13+
/* GLOBALS ********************************************************************/
14+
15+
#define LCDTIMING0_PPL(x) ((((x) / 16 - 1) & 0x3f) << 2)
16+
#define LCDTIMING1_LPP(x) (((x) & 0x3ff) - 1)
17+
#define LCDCONTROL_LCDPWR (1 << 11)
18+
#define LCDCONTROL_LCDEN (1)
19+
#define LCDCONTROL_LCDBPP(x) (((x) & 7) << 1)
20+
#define LCDCONTROL_LCDTFT (1 << 5)
21+
22+
#define PL110_LCDTIMING0 (PVOID)0xE0020000
23+
#define PL110_LCDTIMING1 (PVOID)0xE0020004
24+
#define PL110_LCDTIMING2 (PVOID)0xE0020008
25+
#define PL110_LCDUPBASE (PVOID)0xE0020010
26+
#define PL110_LCDLPBASE (PVOID)0xE0020014
27+
#define PL110_LCDCONTROL (PVOID)0xE0020018
28+
29+
static PUSHORT VgaArmBase;
30+
static PHYSICAL_ADDRESS VgaPhysical;
1531

1632
/* PRIVATE FUNCTIONS *********************************************************/
1733

@@ -31,13 +47,6 @@ VidpBuildColor(
3147
return ((Red & 0x1F) << 11) | ((Green & 0x1F) << 6) | ((Blue & 0x1F));
3248
}
3349

34-
VOID
35-
PrepareForSetPixel(VOID)
36-
{
37-
/* Nothing to prepare */
38-
NOTHING;
39-
}
40-
4150
FORCEINLINE
4251
VOID
4352
SetPixel(

‎drivers/base/bootvid/i386/pc/bootdata.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
*/
88

99
#include "precomp.h"
10+
#include "vga.h"
1011

1112
//
1213
// Minimal Attribute Controller Registers initialization command stream.
1314
// Compatible EGA.
1415
//
15-
USHORT AT_Initialization[] =
16+
const USHORT AT_Initialization[] =
1617
{
1718
/* Reset ATC to index mode */
1819
IB,
@@ -43,7 +44,7 @@ USHORT AT_Initialization[] =
4344
// 640x480 256-color 60Hz mode (BIOS mode 12) set command stream for VGA.
4445
// Adapted from win32ss/drivers/miniport/vga_new/vgadata.c
4546
//
46-
USHORT VGA_640x480[] =
47+
const USHORT VGA_640x480[] =
4748
{
4849
/* Write the Sequencer Registers */
4950
OWM,

‎drivers/base/bootvid/i386/pc/bootvid.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
static BOOLEAN
1414
VgaInterpretCmdStream(
15-
_In_ PUSHORT CmdStream)
15+
_In_ const USHORT* CmdStream)
1616
{
1717
USHORT Cmd;
1818
UCHAR Major, Minor;
@@ -23,7 +23,8 @@ VgaInterpretCmdStream(
2323
USHORT ShortValue;
2424

2525
/* First make sure that we have a Command Stream */
26-
if (!CmdStream) return TRUE;
26+
if (!CmdStream)
27+
return TRUE;
2728

2829
/* Loop as long as we have commands */
2930
while (*CmdStream != EOD)
@@ -63,7 +64,7 @@ VgaInterpretCmdStream(
6364
Count = *CmdStream++;
6465

6566
/* Write the USHORT to the port; the buffer is what's in the command stream */
66-
WRITE_PORT_BUFFER_USHORT((PUSHORT)(VgaRegisterBase + Port), CmdStream, Count);
67+
WRITE_PORT_BUFFER_USHORT((PUSHORT)(VgaRegisterBase + Port), (PUSHORT)CmdStream, Count);
6768

6869
/* Move past the buffer in the command stream */
6970
CmdStream += Count;

‎drivers/base/bootvid/i386/pc/pc.h‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77

88
#pragma once
99

10+
#include "vga.h"
11+
1012
extern ULONG_PTR VgaRegisterBase;
1113
extern ULONG_PTR VgaBase;
12-
extern USHORT AT_Initialization[];
13-
extern USHORT VGA_640x480[];
14-
extern UCHAR PixelMask[8];
14+
extern const USHORT AT_Initialization[];
15+
extern const USHORT VGA_640x480[];
16+
extern const UCHAR PixelMask[8];
1517

1618
#define __inpb(Port) \
1719
READ_PORT_UCHAR((PUCHAR)(VgaRegisterBase + (Port)))

‎drivers/base/bootvid/i386/pc/vga.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
/* GLOBALS *******************************************************************/
1414

15-
static UCHAR lMaskTable[8] =
15+
static const UCHAR lMaskTable[8] =
1616
{
1717
(1 << 8) - (1 << 0),
1818
(1 << 7) - (1 << 0),
@@ -23,7 +23,7 @@ static UCHAR lMaskTable[8] =
2323
(1 << 2) - (1 << 0),
2424
(1 << 1) - (1 << 0)
2525
};
26-
static UCHAR rMaskTable[8] =
26+
static const UCHAR rMaskTable[8] =
2727
{
2828
(1 << 7),
2929
(1 << 7) + (1 << 6),
@@ -34,7 +34,7 @@ static UCHAR rMaskTable[8] =
3434
(1 << 7) + (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3) + (1 << 2) + (1 << 1),
3535
(1 << 7) + (1 << 6) + (1 << 5) + (1 << 4) + (1 << 3) + (1 << 2) + (1 << 1) + (1 << 0),
3636
};
37-
UCHAR PixelMask[8] =
37+
const UCHAR PixelMask[8] =
3838
{
3939
(1 << 7),
4040
(1 << 6),
@@ -45,7 +45,7 @@ UCHAR PixelMask[8] =
4545
(1 << 1),
4646
(1 << 0),
4747
};
48-
static ULONG lookup[16] =
48+
static const ULONG lookup[16] =
4949
{
5050
0x0000,
5151
0x0100,

‎drivers/base/bootvid/i386/pc98/bootvid.c‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@
88
/* INCLUDES *******************************************************************/
99

1010
#include "precomp.h"
11+
#include <drivers/pc98/video.h>
1112

1213
/* GLOBALS ********************************************************************/
1314

14-
static ULONG_PTR PegcControl = 0;
15-
ULONG_PTR FrameBuffer = 0;
15+
#define BYTES_PER_SCANLINE (SCREEN_WIDTH / 8)
1616

1717
#define PEGC_MAX_COLORS 256
1818

19+
static ULONG_PTR PegcControl = 0;
20+
ULONG_PTR FrameBuffer = 0;
21+
1922
/* PRIVATE FUNCTIONS **********************************************************/
2023

2124
static BOOLEAN
@@ -318,12 +321,6 @@ PreserveRow(
318321
WRITE_REGISTER_ULONG(NewPosition++, READ_REGISTER_ULONG(OldPosition++));
319322
}
320323

321-
VOID
322-
PrepareForSetPixel(VOID)
323-
{
324-
NOTHING;
325-
}
326-
327324
VOID
328325
DoScroll(
329326
_In_ ULONG Scroll)

‎drivers/base/bootvid/i386/pc98/pc98.h‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@
77

88
#pragma once
99

10-
/* INCLUDES *******************************************************************/
11-
12-
#include <drivers/pc98/video.h>
13-
1410
/* GLOBALS ********************************************************************/
1511

16-
#define BYTES_PER_SCANLINE (SCREEN_WIDTH / 8)
1712
#define FB_OFFSET(x, y) ((y) * SCREEN_WIDTH + (x))
1813

1914
extern ULONG_PTR FrameBuffer;
@@ -25,8 +20,7 @@ InitPaletteWithTable(
2520
_In_reads_(Count) const ULONG* Table,
2621
_In_ ULONG Count);
2722

28-
VOID
29-
PrepareForSetPixel(VOID);
23+
#define PrepareForSetPixel()
3024

3125
FORCEINLINE
3226
VOID

‎drivers/base/bootvid/i386/xbox/bootvid.c‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
/* GLOBALS ********************************************************************/
1717

18+
#define BB_OFFSET(x, y) ((y) * SCREEN_WIDTH + (x))
19+
#define FB_OFFSET(x, y) (((PanV + (y)) * FrameBufferWidth + PanH + (x)) * BytesPerPixel)
20+
1821
static ULONG_PTR FrameBufferStart = 0;
1922
static ULONG FrameBufferWidth, FrameBufferHeight, PanH, PanV;
2023
static UCHAR BytesPerPixel;
@@ -248,13 +251,6 @@ InitPaletteWithTable(
248251
ApplyPalette();
249252
}
250253

251-
VOID
252-
PrepareForSetPixel(VOID)
253-
{
254-
/* Nothing to prepare */
255-
NOTHING;
256-
}
257-
258254
VOID
259255
SetPixel(
260256
_In_ ULONG Left,

‎drivers/base/bootvid/i386/xbox/xbox.h‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,12 @@
99

1010
#pragma once
1111

12-
#define BB_OFFSET(x, y) ((y) * SCREEN_WIDTH + (x))
13-
#define FB_OFFSET(x, y) (((PanV + (y)) * FrameBufferWidth + PanH + (x)) * BytesPerPixel)
14-
1512
VOID
1613
InitPaletteWithTable(
1714
_In_reads_(Count) const ULONG* Table,
1815
_In_ ULONG Count);
1916

20-
VOID
21-
PrepareForSetPixel(VOID);
17+
#define PrepareForSetPixel()
2218

2319
VOID
2420
SetPixel(

0 commit comments

Comments
 (0)