ReactOS 0.4.16-dev-2232-gc2aaa52
bootvid.c File Reference
#include "precomp.h"
#include <debug.h>
#include <drivers/bootvid/framebuf.c>
Include dependency graph for bootvid.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define SCALING_SUPPORT
 
#define SCALING_PROPORTIONAL
 
#define BB_PIXEL(x, y)    ((PUCHAR)BackBuffer + (y) * SCREEN_WIDTH + (x))
 
#define FB_PIXEL(x, y)
 

Functions

static VOID ApplyPalette (VOID)
 
BOOLEAN NTAPI VidInitialize (_In_ BOOLEAN SetMode)
 
VOID NTAPI VidCleanUp (VOID)
 
VOID ResetDisplay (_In_ BOOLEAN SetMode)
 
VOID InitPaletteWithTable (_In_reads_(Count) const ULONG *Table, _In_ ULONG Count)
 
VOID SetPixel (_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
 
VOID PreserveRow (_In_ ULONG CurrentTop, _In_ ULONG TopDelta, _In_ BOOLEAN Restore)
 
VOID DoScroll (_In_ ULONG Scroll)
 
VOID DisplayCharacter (_In_ CHAR Character, _In_ ULONG Left, _In_ ULONG Top, _In_ ULONG TextColor, _In_ ULONG BackColor)
 
VOID NTAPI VidSolidColorFill (_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ UCHAR Color)
 
VOID NTAPI VidScreenToBufferBlt (_Out_writes_bytes_all_(Delta *Height) PUCHAR Buffer, _In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_ ULONG Delta)
 

Variables

static ULONG_PTR FrameBufferStart = 0
 
static ULONG FrameBufferSize
 
static ULONG ScreenWidth
 
static ULONG ScreenHeight
 
static ULONG BytesPerScanLine
 
static UCHAR BytesPerPixel
 
static PUCHAR BackBuffer = NULL
 
static SIZE_T BackBufferSize
 
static USHORT VidpXScale = 1
 
static USHORT VidpYScale = 1
 
static ULONG PanH
 
static ULONG PanV
 
static RGBQUAD CachedPalette [BV_MAX_COLORS]
 

Macro Definition Documentation

◆ BB_PIXEL

#define BB_PIXEL (   x,
  y 
)     ((PUCHAR)BackBuffer + (y) * SCREEN_WIDTH + (x))

Definition at line 27 of file bootvid.c.

◆ FB_PIXEL

#define FB_PIXEL (   x,
  y 
)
Value:
static ULONG PanV
Definition: bootvid.c:48
static UCHAR BytesPerPixel
Definition: bootvid.c:37
static ULONG BytesPerScanLine
Definition: bootvid.c:36
static USHORT VidpXScale
Definition: bootvid.c:42
static ULONG_PTR FrameBufferStart
Definition: bootvid.c:34
static ULONG PanH
Definition: bootvid.c:48
static USHORT VidpYScale
Definition: bootvid.c:43
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
unsigned char * PUCHAR
Definition: typedefs.h:53

Definition at line 30 of file bootvid.c.

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file bootvid.c.

◆ SCALING_PROPORTIONAL

#define SCALING_PROPORTIONAL

Definition at line 19 of file bootvid.c.

◆ SCALING_SUPPORT

#define SCALING_SUPPORT

Definition at line 18 of file bootvid.c.

Function Documentation

◆ ApplyPalette()

static VOID ApplyPalette ( VOID  )
static

Definition at line 56 of file bootvid.c.

57{
59 ULONG x, y;
60
61#ifdef COLORED_BORDERS
62 /* Top border */
63 for (x = 0; x < PanV * ScreenWidth; ++x)
64 {
65 *Frame++ = CachedPalette[BV_COLOR_BLACK];
66 }
67
68 /* Left border */
69 for (y = 0; y < VidpYScale * SCREEN_HEIGHT; ++y)
70 {
71 // Frame = (PULONG)(FrameBufferStart + FB_OFFSET(-(LONG)PanH, y));
73 for (x = 0; x < PanH; ++x)
74 {
75 *Frame++ = CachedPalette[BV_COLOR_BLACK];
76 }
77 }
78#endif // COLORED_BORDERS
79
80 /* Screen redraw */
81 PUCHAR Back = BackBuffer;
82 for (y = 0; y < SCREEN_HEIGHT; ++y)
83 {
84 Frame = (PULONG)FB_PIXEL(0, y);
85 PULONG Pixel = Frame;
86 for (x = 0; x < SCREEN_WIDTH; ++x)
87 {
88 for (ULONG j = VidpXScale; j > 0; --j)
89 *Pixel++ = CachedPalette[*Back];
90 Back++;
91 }
92 Pixel = Frame;
93 for (ULONG i = VidpYScale-1; i > 0; --i)
94 {
95 Pixel = (PULONG)((ULONG_PTR)Pixel + BytesPerScanLine);
97 }
98 }
99
100#ifdef COLORED_BORDERS
101 /* Right border */
102 for (y = 0; y < VidpYScale * SCREEN_HEIGHT; ++y)
103 {
104 // Frame = (PULONG)(FrameBufferStart + FB_OFFSET(SCREEN_WIDTH, y));
106 for (x = 0; x < PanH; ++x)
107 {
108 *Frame++ = CachedPalette[BV_COLOR_BLACK];
109 }
110 }
111
112 /* Bottom border */
113 // Frame = (PULONG)(FrameBufferStart + FB_OFFSET(-(LONG)PanH, SCREEN_HEIGHT));
115 for (x = 0; x < PanV * ScreenWidth; ++x)
116 {
117 *Frame++ = CachedPalette[BV_COLOR_BLACK];
118 }
119#endif // COLORED_BORDERS
120}
static ULONG ScreenWidth
Definition: bootvid.c:36
static RGBQUAD CachedPalette[BV_MAX_COLORS]
Definition: bootvid.c:50
#define FB_PIXEL(x, y)
Definition: bootvid.c:30
static PUCHAR BackBuffer
Definition: bootvid.c:38
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define SCREEN_WIDTH
Definition: pc98video.c:24
#define SCREEN_HEIGHT
Definition: pc98video.c:25
#define BV_COLOR_BLACK
Definition: display.h:15
uint32_t * PULONG
Definition: typedefs.h:59
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59

Referenced by InitPaletteWithTable().

◆ DisplayCharacter()

VOID DisplayCharacter ( _In_ CHAR  Character,
_In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  TextColor,
_In_ ULONG  BackColor 
)

Definition at line 448 of file bootvid.c.

454{
455 /* Get the font line for this character */
456 const UCHAR* FontChar = GetFontPtr(Character);
457
458 /* Loop each pixel height */
459 for (ULONG y = Top; y < Top + BOOTCHAR_HEIGHT; ++y, FontChar += FONT_PTR_DELTA)
460 {
461 /* Loop each pixel width */
462 ULONG x = Left;
463 for (UCHAR bit = 1 << (BOOTCHAR_WIDTH - 1); bit > 0; bit >>= 1, ++x)
464 {
465 /* If we should draw this pixel, use the text color. Otherwise
466 * this is a background pixel, draw it unless it's transparent. */
467 if (*FontChar & bit)
468 SetPixel(x, y, (UCHAR)TextColor);
469 else if (BackColor < BV_COLOR_NONE)
470 SetPixel(x, y, (UCHAR)BackColor);
471 }
472 }
473}
FORCEINLINE VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: bootvid.c:52
static LPHIST_ENTRY Top
Definition: history.c:53
#define GetFontPtr(_Char)
Definition: precomp.h:79
#define FONT_PTR_DELTA
Definition: precomp.h:80
#define BOOTCHAR_HEIGHT
Definition: precomp.h:24
#define BOOTCHAR_WIDTH
Definition: precomp.h:25
#define BV_COLOR_NONE
Definition: display.h:31
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ DoScroll()

VOID DoScroll ( _In_ ULONG  Scroll)

Definition at line 413 of file bootvid.c.

415{
417
418 /* Calculate the position in memory for the row */
419 PUCHAR OldPosition = BB_PIXEL(VidpScrollRegion.Left, VidpScrollRegion.Top + Scroll);
421
422 /* Start loop */
424 {
425 /* Scroll the row */
426 RtlCopyMemory(NewPosition, OldPosition, RowSize);
427
429 PULONG Pixel = Frame;
430 for (ULONG Count = 0; Count < RowSize; ++Count)
431 {
432 for (ULONG j = VidpXScale; j > 0; --j)
433 *Pixel++ = CachedPalette[NewPosition[Count]];
434 }
435 Pixel = Frame;
436 for (ULONG i = VidpYScale-1; i > 0; --i)
437 {
438 Pixel = (PULONG)((ULONG_PTR)Pixel + BytesPerScanLine);
439 RtlCopyMemory(Pixel, Frame, VidpXScale * RowSize * BytesPerPixel);
440 }
441
442 OldPosition += SCREEN_WIDTH;
443 NewPosition += SCREEN_WIDTH;
444 }
445}
URECT VidpScrollRegion
Definition: console.c:17
#define BB_PIXEL(x, y)
Definition: bootvid.c:27
int Count
Definition: noreturn.cpp:7
ULONG Right
Definition: precomp.h:53
ULONG Top
Definition: precomp.h:52
ULONG Bottom
Definition: precomp.h:54
ULONG Left
Definition: precomp.h:51

◆ InitPaletteWithTable()

VOID InitPaletteWithTable ( _In_reads_(Count) const ULONG Table,
_In_ ULONG  Count 
)

Definition at line 324 of file bootvid.c.

327{
328 const ULONG* Entry = Table;
329 ULONG i;
330 BOOLEAN HasChanged = FALSE;
331
332 for (i = 0; i < Count; i++, Entry++)
333 {
334 HasChanged |= !!((CachedPalette[i] ^ *Entry) & 0x00FFFFFF);
335 CachedPalette[i] = *Entry | 0xFF000000;
336 }
337
338 /* Re-apply the palette if it has changed */
339 if (HasChanged)
340 ApplyPalette();
341}
unsigned char BOOLEAN
#define FALSE
Definition: types.h:117
static VOID ApplyPalette(VOID)
Definition: bootvid.c:56
ASMGENDATA Table[]
Definition: genincdata.c:61
base of all file and directory entries
Definition: entries.h:83

◆ PreserveRow()

VOID PreserveRow ( _In_ ULONG  CurrentTop,
_In_ ULONG  TopDelta,
_In_ BOOLEAN  Restore 
)

Definition at line 363 of file bootvid.c.

367{
368 PUCHAR NewPosition, OldPosition;
369
370 /* Calculate the position in memory for the row */
371 if (Restore)
372 {
373 /* Restore the row by copying back the contents saved off-screen */
374 NewPosition = BB_PIXEL(0, CurrentTop);
375 OldPosition = BB_PIXEL(0, SCREEN_HEIGHT);
376 }
377 else
378 {
379 /* Preserve the row by saving its contents off-screen */
380 NewPosition = BB_PIXEL(0, SCREEN_HEIGHT);
381 OldPosition = BB_PIXEL(0, CurrentTop);
382 }
383
384 /* Set the count and copy the pixel data back to the other position in the backbuffer */
385 ULONG Count = TopDelta * SCREEN_WIDTH;
386 RtlCopyMemory(NewPosition, OldPosition, Count);
387
388 /* On restore, mirror the backbuffer changes to the framebuffer */
389 if (Restore)
390 {
391 NewPosition = BB_PIXEL(0, CurrentTop);
392 for (ULONG y = 0; y < TopDelta; ++y)
393 {
394 PULONG Frame = (PULONG)FB_PIXEL(0, CurrentTop + y);
395 PULONG Pixel = Frame;
396 for (Count = 0; Count < SCREEN_WIDTH; ++Count)
397 {
398 for (ULONG j = VidpXScale; j > 0; --j)
399 *Pixel++ = CachedPalette[*NewPosition];
400 NewPosition++;
401 }
402 Pixel = Frame;
403 for (ULONG i = VidpYScale-1; i > 0; --i)
404 {
405 Pixel = (PULONG)((ULONG_PTR)Pixel + BytesPerScanLine);
407 }
408 }
409 }
410}

◆ ResetDisplay()

VOID ResetDisplay ( _In_ BOOLEAN  SetMode)

Definition at line 312 of file bootvid.c.

314{
317
318 /* Re-initialize the palette and fill the screen black */
321}
VOID NTAPI VidSolidColorFill(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ UCHAR Color)
Definition: bootvid.c:298
#define InitializePalette()
Definition: precomp.h:73
static ULONG FrameBufferSize
Definition: bootvid.c:35
static SIZE_T BackBufferSize
Definition: bootvid.c:39
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

◆ SetPixel()

VOID SetPixel ( _In_ ULONG  Left,
_In_ ULONG  Top,
_In_ UCHAR  Color 
)

Definition at line 344 of file bootvid.c.

348{
349 PUCHAR Back = BB_PIXEL(Left, Top);
350 PULONG Frame = (PULONG)FB_PIXEL(Left, Top);
351
352 *Back = Color;
353 for (ULONG i = VidpYScale; i > 0; --i)
354 {
355 PULONG Pixel = Frame;
356 for (ULONG j = VidpXScale; j > 0; --j)
357 *Pixel++ = CachedPalette[Color];
358 Frame = (PULONG)((ULONG_PTR)Frame + BytesPerScanLine);
359 }
360}

◆ VidCleanUp()

VOID NTAPI VidCleanUp ( VOID  )

Definition at line 305 of file bootvid.c.

306{
307 /* Just fill the screen black */
309}

◆ VidInitialize()

BOOLEAN NTAPI VidInitialize ( _In_ BOOLEAN  SetMode)

Definition at line 126 of file bootvid.c.

128{
132 CM_FRAMEBUF_DEVICE_DATA VideoConfigData; /* Configuration data from hardware tree */
136
137 /* Find boot-time framebuffer display information from the LoaderBlock */
139 &VramSize,
140 &VideoConfigData,
141 NULL, // MonitorConfigData
142 &Interface,
143 &BusNumber);
144 if (!NT_SUCCESS(Status))
145 {
146 DPRINT1("Boot framebuffer does not exist!\n");
147 return FALSE;
148 }
149
150 /* The VRAM address must be page-aligned */
151 if (VramAddress.QuadPart % PAGE_SIZE != 0) // DPRINTed for diagnostics on some systems
152 DPRINT1("** VramAddress 0x%I64X isn't PAGE_SIZE aligned\n", VramAddress.QuadPart);
153 ASSERT(VramAddress.QuadPart % PAGE_SIZE == 0);
154 if (VramSize % PAGE_SIZE != 0)
155 DPRINT1("** VramSize %lu (0x%lx) isn't multiple of PAGE_SIZE\n", VramSize, VramSize);
156 // ASSERT(VramSize % PAGE_SIZE == 0); // This assert may fail, e.g. 800x600@32bpp UEFI GOP display
157
158 /* Retrieve the framebuffer address, its visible screen dimensions, and its attributes */
159 FrameBuffer.QuadPart = VramAddress.QuadPart + VideoConfigData.FrameBufferOffset;
160 ScreenWidth = VideoConfigData.ScreenWidth;
161 ScreenHeight = VideoConfigData.ScreenHeight;
163 {
164 DPRINT1("Unsupported screen resolution!\n");
165 return FALSE;
166 }
167
168 BytesPerPixel = (VideoConfigData.BitsPerPixel + 7) / 8; // Round up to nearest byte.
169 ASSERT(BytesPerPixel >= 1 && BytesPerPixel <= 4);
170 if (BytesPerPixel != 4)
171 {
173 DPRINT1("Unsupported BytesPerPixel = %u\n", BytesPerPixel);
174 return FALSE;
175 }
176
177 ASSERT(ScreenWidth <= VideoConfigData.PixelsPerScanLine);
179 if (BytesPerScanLine < 1)
180 {
181 DPRINT1("Invalid BytesPerScanLine = %lu\n", BytesPerScanLine);
182 return FALSE;
183 }
184
185 /* Compute the visible framebuffer size */
187
188 /* Verify that the framebuffer actually fits inside the video RAM */
189 if (FrameBuffer.QuadPart + FrameBufferSize > VramAddress.QuadPart + VramSize)
190 {
191 DPRINT1("The framebuffer exceeds video memory bounds!\n");
192 return FALSE;
193 }
194
195 /* Translate the framebuffer from bus-relative to physical address */
197 ULONG AddressSpace = 0; /* MMIO space */
199 BusNumber,
203 {
204 DPRINT1("Could not translate framebuffer bus address 0x%I64X\n", FrameBuffer.QuadPart);
205 return FALSE;
206 }
207
208 /* Map it into system space if necessary */
209 ULONG MappedSize = 0;
210 PVOID FrameBufferBase = NULL;
211 if (AddressSpace == 0)
212 {
213 /* Calculate page-aligned address and size for MmMapIoSpace() */
216 MappedSize = FrameBufferSize;
217 MappedSize += (ULONG)(TranslatedAddress.QuadPart - FrameBuffer.QuadPart); // BYTE_OFFSET()
218 MappedSize = ROUND_TO_PAGES(MappedSize);
219 /* Essentially MmMapVideoDisplay() */
220 FrameBufferBase = MmMapIoSpace(FrameBuffer, MappedSize, MmFrameBufferCached);
221 if (!FrameBufferBase)
222 FrameBufferBase = MmMapIoSpace(FrameBuffer, MappedSize, MmNonCached);
223 if (!FrameBufferBase)
224 {
225 DPRINT1("Could not map framebuffer 0x%I64X (%lu bytes)\n",
226 FrameBuffer.QuadPart, MappedSize);
227 goto Failure;
228 }
229 FrameBufferStart = (ULONG_PTR)FrameBufferBase;
230 FrameBufferStart += (TranslatedAddress.QuadPart - FrameBuffer.QuadPart); // BYTE_OFFSET()
231 }
232 else
233 {
234 /* The base is the translated address, no need to map */
236 }
237
238
239 /*
240 * Reserve off-screen area for the backbuffer that contains
241 * 8-bit indexed color screen image, plus preserved row data.
242 */
244
245 /* If there is enough video memory in the physical framebuffer,
246 * place the backbuffer in the hidden part of the framebuffer,
247 * otherwise allocate a zone for the backbuffer. */
248 if (VideoConfigData.FrameBufferOffset + FrameBufferSize + BackBufferSize
249 <= ((AddressSpace == 0) ? MappedSize : VramSize))
250 {
251 /* Backbuffer placed following the framebuffer in the hidden part */
253 // BackBuffer = (PUCHAR)(VramAddress + VramSize - BackBufferSize); // Or at the end of VRAM.
254 }
255 else
256 {
257 /* Allocate the backbuffer */
258 PHYSICAL_ADDRESS NullAddress = {{0, 0}};
259 PHYSICAL_ADDRESS HighestAddress = {{-1, -1}};
261 BackBufferSize, NullAddress, HighestAddress,
262 NullAddress, MmNonCached);
263 if (!BackBuffer)
264 {
265 DPRINT1("Could not allocate backbuffer (size: %lu)\n", (ULONG)BackBufferSize);
266 goto Failure;
267 }
268 }
269
270#ifdef SCALING_SUPPORT
271 /* Compute autoscaling; only integer (not fractional) scaling is supported */
274 ASSERT(VidpXScale >= 1);
275 ASSERT(VidpYScale >= 1);
276#ifdef SCALING_PROPORTIONAL
279#endif
280 DPRINT1("Scaling X = %hu, Y = %hu\n", VidpXScale, VidpYScale);
281#endif // SCALING_SUPPORT
282
283 /* Calculate left/right and top/bottom border values
284 * to keep the displayed area centered on the screen */
287 DPRINT1("Borders X = %lu, Y = %lu\n", PanH, PanV);
288
289 /* Reset the video mode if requested */
290 if (SetMode)
292
293 return TRUE;
294
295Failure:
296 /* We failed somewhere; unmap the framebuffer if we mapped it */
297 if (FrameBufferBase && (AddressSpace == 0))
298 MmUnmapIoSpace(FrameBufferBase, MappedSize);
299
300 return FALSE;
301}
#define ALIGN_DOWN_BY(size, align)
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
PVOID NTAPI MmAllocateContiguousMemorySpecifyCache(IN SIZE_T NumberOfBytes, IN PHYSICAL_ADDRESS LowestAcceptableAddress OPTIONAL, IN PHYSICAL_ADDRESS HighestAcceptableAddress, IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, IN MEMORY_CACHING_TYPE CacheType OPTIONAL)
Definition: contmem.c:574
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
VOID NTAPI VidResetDisplay(_In_ BOOLEAN SetMode)
Definition: console.c:25
#define ULONG_PTR
Definition: config.h:101
#define PAGE_SIZE
Definition: env_spec_w32.h:49
static ULONG ScreenHeight
Definition: bootvid.c:36
NTSTATUS FindBootDisplay(_Out_ PPHYSICAL_ADDRESS VideoRamAddress, _Out_ PULONG VideoRamSize, _Out_ PCM_FRAMEBUF_DEVICE_DATA VideoConfigData, _Out_opt_ PCM_MONITOR_DEVICE_DATA MonitorConfigData, _Out_opt_ PINTERFACE_TYPE Interface, _Out_opt_ PULONG BusNumber)
Retrieves configuration data for the boot-time (POST) display controller and monitor peripheral.
Definition: framebuf.c:564
BOOLEAN NTAPI BootTranslateBusAddress(_In_ INTERFACE_TYPE InterfaceType, _In_ ULONG BusNumber, _In_ PHYSICAL_ADDRESS BusAddress, _Inout_ PULONG AddressSpace, _Out_ PPHYSICAL_ADDRESS TranslatedAddress)
Wrapper around HalTranslateBusAddress() and HALPRIVATEDISPATCH->HalFindBusAddressTranslation().
Definition: framebuf.c:677
Status
Definition: gdiplustypes.h:25
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:193
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
ULONG_PTR FrameBuffer
Definition: xboxvideo.c:29
#define ASSERT(a)
Definition: mode.c:44
#define min(a, b)
Definition: monoChain.cc:55
enum _INTERFACE_TYPE INTERFACE_TYPE
ReactOS Framebuffer-specific video device configuration data.
Definition: framebuf.h:35
ULONG BitsPerPixel
Pixel depth.
Definition: framebuf.h:51
ULONG PixelsPerScanLine
Pitch/stride in pixels.
Definition: framebuf.h:50
ULONG_PTR VramAddress
Definition: uefivid.c:20
ULONG VramSize
Definition: uefivid.c:21
LONGLONG QuadPart
Definition: typedefs.h:114
ULONG LowPart
Definition: typedefs.h:106
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2275
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2274
#define ROUND_TO_PAGES(Size)
@ MmNonCached
Definition: mmtypes.h:129
@ MmFrameBufferCached
Definition: mmtypes.h:125

◆ VidScreenToBufferBlt()

VOID NTAPI VidScreenToBufferBlt ( _Out_writes_bytes_all_(Delta *Height) PUCHAR  Buffer,
_In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  Width,
_In_ ULONG  Height,
_In_ ULONG  Delta 
)

Definition at line 507 of file bootvid.c.

514{
515 ULONG x, y;
516
517 /* Clear the destination buffer */
518 RtlZeroMemory(Buffer, Delta * Height);
519
520 /* Start the outer Y height loop */
521 for (y = 0; y < Height; ++y)
522 {
523 /* Set current scanline */
524 PUCHAR Back = BB_PIXEL(Left, Top + y);
525 PUCHAR Buf = Buffer + y * Delta;
526
527 /* Start the X inner loop */
528 for (x = 0; x < Width; x += sizeof(USHORT))
529 {
530 /* Read the current value */
531 *Buf = (*Back++ & 0xF) << 4;
532 *Buf |= *Back++ & 0xF;
533 Buf++;
534 }
535 }
536}
Definition: bufpool.h:45
unsigned short USHORT
Definition: pedump.c:61
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88

◆ VidSolidColorFill()

VOID NTAPI VidSolidColorFill ( _In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  Right,
_In_ ULONG  Bottom,
_In_ UCHAR  Color 
)

Definition at line 477 of file bootvid.c.

483{
484 for (; Top <= Bottom; ++Top)
485 {
486 PUCHAR Back = BB_PIXEL(Left, Top);
487 // NOTE: Assumes 32bpp
488 PULONG Frame = (PULONG)FB_PIXEL(Left, Top);
489 PULONG Pixel = Frame;
490 for (ULONG L = Left; L <= Right; ++L)
491 {
492 *Back++ = Color;
493 for (ULONG j = VidpXScale; j > 0; --j)
494 *Pixel++ = CachedPalette[Color];
495 }
496 Pixel = Frame;
497 for (ULONG i = VidpYScale-1; i > 0; --i)
498 {
499 Pixel = (PULONG)((ULONG_PTR)Pixel + BytesPerScanLine);
500 RtlCopyMemory(Pixel, Frame, VidpXScale * (Right - Left + 1) * BytesPerPixel);
501 }
502 }
503}
static LPHIST_ENTRY Bottom
Definition: history.c:54
#define L(x)
Definition: resources.c:13

Variable Documentation

◆ BackBuffer

◆ BackBufferSize

SIZE_T BackBufferSize
static

Definition at line 39 of file bootvid.c.

Referenced by ResetDisplay(), and VidInitialize().

◆ BytesPerPixel

◆ BytesPerScanLine

ULONG BytesPerScanLine
static

◆ CachedPalette

RGBQUAD CachedPalette[BV_MAX_COLORS]
static

◆ FrameBufferSize

ULONG FrameBufferSize
static

Definition at line 35 of file bootvid.c.

Referenced by ResetDisplay(), and VidInitialize().

◆ FrameBufferStart

ULONG_PTR FrameBufferStart = 0
static

◆ PanH

ULONG PanH
static

Definition at line 48 of file bootvid.c.

Referenced by ApplyPalette(), and VidInitialize().

◆ PanV

ULONG PanV
static

Definition at line 48 of file bootvid.c.

Referenced by ApplyPalette(), and VidInitialize().

◆ ScreenHeight

ULONG ScreenHeight
static

Definition at line 36 of file bootvid.c.

Referenced by VidInitialize().

◆ ScreenWidth

ULONG ScreenWidth
static

Definition at line 36 of file bootvid.c.

Referenced by ApplyPalette(), NvGetBytesPerPixel(), and VidInitialize().

◆ VidpXScale

USHORT VidpXScale = 1
static

◆ VidpYScale

USHORT VidpYScale = 1
static