ReactOS 0.4.16-dev-2104-gb84fa49
bootvid.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Boot Video Driver for ARM devices
3 * LICENSE: BSD - See COPYING.ARM in root directory
4 * PURPOSE: Main file
5 * COPYRIGHT: Copyright 2008 ReactOS Portable Systems Group <ros.arm@reactos.org>
6 */
7
8#include "precomp.h"
9
10#define NDEBUG
11#include <debug.h>
12
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
31
32/* PRIVATE FUNCTIONS *********************************************************/
33
38{
40
41 /* Extract color components */
45
46 /* Build the 16-bit color mask */
47 return ((Red & 0x1F) << 11) | ((Green & 0x1F) << 6) | ((Blue & 0x1F));
48}
49
51VOID
53 _In_ ULONG Left,
56{
57 PUSHORT PixelPosition;
58
59 /* Calculate the pixel position */
60 PixelPosition = &VgaArmBase[Left + (Top * SCREEN_WIDTH)];
61
62 /* Set our color */
64}
65
66VOID
68 _In_ CHAR Character,
69 _In_ ULONG Left,
71 _In_ ULONG TextColor,
72 _In_ ULONG BackColor)
73{
74 const UCHAR* FontChar;
75 ULONG i, j, XOffset;
76
77 /* Get the font line for this character */
78 FontChar = &VidpFontData[Character * BOOTCHAR_HEIGHT - Top];
79
80 /* Loop each pixel height */
81 for (i = BOOTCHAR_HEIGHT; i > 0; --i)
82 {
83 /* Loop each pixel width */
84 XOffset = Left;
85 for (j = (1 << 7); j > 0; j >>= 1)
86 {
87 /* Check if we should draw this pixel */
88 if (FontChar[Top] & (UCHAR)j)
89 {
90 /* We do, use the given Text Color */
91 SetPixel(XOffset, Top, (UCHAR)TextColor);
92 }
93 else if (BackColor < BV_COLOR_NONE)
94 {
95 /*
96 * This is a background pixel. We're drawing it
97 * unless it's transparent.
98 */
99 SetPixel(XOffset, Top, (UCHAR)BackColor);
100 }
101
102 /* Increase X Offset */
103 XOffset++;
104 }
105
106 /* Move to the next Y ordinate */
107 Top++;
108 }
109}
110
111VOID
113 _In_ ULONG Scroll)
114{
116 PUSHORT SourceOffset, DestOffset;
117 PUSHORT i, j;
118
119 /* Set memory positions of the scroll */
121 DestOffset = &SourceOffset[Scroll * (SCREEN_WIDTH / 8)];
122
123 /* Start loop */
125 {
126 /* Set number of bytes to loop and start offset */
128 j = SourceOffset;
129
130 /* Check if this is part of the scroll region */
131 if (Offset <= (VidpScrollRegion.Right >> 3))
132 {
133 /* Update position */
134 i = (PUSHORT)(DestOffset - SourceOffset);
135
136 /* Loop the X axis */
137 do
138 {
139 /* Write value in the new position so that we can do the scroll */
141
142 /* Move to the next memory location to write to */
143 j++;
144
145 /* Move to the next byte in the region */
146 Offset++;
147
148 /* Make sure we don't go past the scroll region */
149 } while (Offset <= (VidpScrollRegion.Right >> 3));
150 }
151
152 /* Move to the next line */
153 SourceOffset += (SCREEN_WIDTH / 8);
154 DestOffset += (SCREEN_WIDTH / 8);
155 }
156}
157
158VOID
160 _In_ ULONG CurrentTop,
161 _In_ ULONG TopDelta,
162 _In_ BOOLEAN Restore)
163{
164 PUSHORT Position1, Position2;
165 ULONG Count;
166
167 /* Calculate the position in memory for the row */
168 if (Restore)
169 {
170 /* Restore the row by copying back the contents saved off-screen */
171 Position1 = &VgaArmBase[CurrentTop * (SCREEN_WIDTH / 8)];
172 Position2 = &VgaArmBase[SCREEN_HEIGHT * (SCREEN_WIDTH / 8)];
173 }
174 else
175 {
176 /* Preserve the row by saving its contents off-screen */
177 Position1 = &VgaArmBase[SCREEN_HEIGHT * (SCREEN_WIDTH / 8)];
178 Position2 = &VgaArmBase[CurrentTop * (SCREEN_WIDTH / 8)];
179 }
180
181 /* Set the count and loop every pixel */
182 Count = TopDelta * (SCREEN_WIDTH / 8);
183 while (Count--)
184 {
185 /* Write the data back on the other position */
186 WRITE_REGISTER_USHORT(Position1, READ_REGISTER_USHORT(Position2));
187
188 /* Increase both positions */
189 Position1++;
190 Position2++;
191 }
192}
193
194VOID
196{
197 //
198 // Set framebuffer address
199 //
202
203 //
204 // Initialize timings to 640x480
205 //
208
209 //
210 // Enable the LCD Display
211 //
217}
218
219VOID
221 _In_reads_(Count) const ULONG* Table,
223{
225}
226
227/* PUBLIC FUNCTIONS **********************************************************/
228
230NTAPI
232 _In_ BOOLEAN SetMode)
233{
234 DPRINT1("bv-arm v0.1\n");
235
236 //
237 // Allocate framebuffer
238 // 600kb works out to 640x480@16bpp
239 //
242 if (!VgaArmBase) return FALSE;
243
244 //
245 // Get physical address
246 //
248 if (!VgaPhysical.QuadPart) return FALSE;
249 DPRINT1("[BV-ARM] Frame Buffer @ 0x%p 0p%p\n", VgaArmBase, VgaPhysical.LowPart);
250
251 //
252 // Setup the display
253 //
255
256 //
257 // We are done!
258 //
259 return TRUE;
260}
261
262VOID
264 _In_ BOOLEAN SetMode)
265{
266 /* Re-initialize the display */
268
269 /* Re-initialize the palette and fill the screen black */
272}
273
274VOID
275NTAPI
277{
279 while (TRUE);
280}
281
282VOID
283NTAPI
286 _In_ ULONG Left,
287 _In_ ULONG Top,
290 _In_ ULONG Delta)
291{
293 while (TRUE);
294}
295
296VOID
297NTAPI
299 _In_ ULONG Left,
300 _In_ ULONG Top,
301 _In_ ULONG Right,
304{
305 int y, x;
306
307 //
308 // Loop along the Y-axis
309 //
310 for (y = Top; y <= Bottom; y++)
311 {
312 //
313 // Loop along the X-axis
314 //
315 for (x = Left; x <= Right; x++)
316 {
317 //
318 // Draw the pixel
319 //
320 SetPixel(x, y, Color);
321 }
322 }
323}
unsigned char BOOLEAN
#define PL110_LCDCONTROL
Definition: bootvid.c:27
#define LCDCONTROL_LCDBPP(x)
Definition: bootvid.c:19
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: bootvid.c:284
#define PL110_LCDTIMING1
Definition: bootvid.c:23
VOID PreserveRow(_In_ ULONG CurrentTop, _In_ ULONG TopDelta, _In_ BOOLEAN Restore)
Definition: bootvid.c:159
VOID NTAPI VidSolidColorFill(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ UCHAR Color)
Definition: bootvid.c:298
#define PL110_LCDUPBASE
Definition: bootvid.c:25
#define PL110_LCDTIMING0
Definition: bootvid.c:22
#define LCDTIMING0_PPL(x)
Definition: bootvid.c:15
VOID NTAPI VidCleanUp(VOID)
Definition: bootvid.c:276
#define LCDCONTROL_LCDPWR
Definition: bootvid.c:17
#define LCDCONTROL_LCDEN
Definition: bootvid.c:18
VOID ResetDisplay(_In_ BOOLEAN SetMode)
Definition: bootvid.c:263
#define LCDCONTROL_LCDTFT
Definition: bootvid.c:20
FORCEINLINE VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: bootvid.c:52
VOID InitPaletteWithTable(_In_reads_(Count) const ULONG *Table, _In_ ULONG Count)
Definition: bootvid.c:220
#define LCDTIMING1_LPP(x)
Definition: bootvid.c:16
static PHYSICAL_ADDRESS VgaPhysical
Definition: bootvid.c:30
VOID DisplayCharacter(_In_ CHAR Character, _In_ ULONG Left, _In_ ULONG Top, _In_ ULONG TextColor, _In_ ULONG BackColor)
Definition: bootvid.c:67
VOID DoScroll(_In_ ULONG Scroll)
Definition: bootvid.c:112
#define PL110_LCDLPBASE
Definition: bootvid.c:26
FORCEINLINE USHORT VidpBuildColor(_In_ UCHAR Color)
Definition: bootvid.c:36
VOID VidpInitializeDisplay(VOID)
Definition: bootvid.c:195
BOOLEAN NTAPI VidInitialize(_In_ BOOLEAN SetMode)
Definition: bootvid.c:231
static PUSHORT VgaArmBase
Definition: bootvid.c:29
#define WRITE_REGISTER_USHORT(r, v)
Definition: arm.h:14
#define READ_REGISTER_USHORT(r)
Definition: arm.h:13
#define WRITE_REGISTER_ULONG(r, v)
Definition: arm.h:11
#define DPRINT1
Definition: precomp.h:8
static LPHIST_ENTRY Bottom
Definition: history.c:54
static LPHIST_ENTRY Top
Definition: history.c:53
@ Green
Definition: bl.h:199
@ Red
Definition: bl.h:201
@ Blue
Definition: bl.h:198
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
Definition: bufpool.h:45
PVOID NTAPI MmAllocateContiguousMemory(IN SIZE_T NumberOfBytes, IN PHYSICAL_ADDRESS HighestAcceptableAddress)
Definition: contmem.c:626
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
const RGBQUAD VidpDefaultPalette[BV_MAX_COLORS]
Definition: common.c:19
URECT VidpScrollRegion
Definition: console.c:17
#define GetBValue(quad)
Definition: precomp.h:82
#define GetGValue(quad)
Definition: precomp.h:81
#define GetRValue(quad)
Definition: precomp.h:80
#define BOOTCHAR_HEIGHT
Definition: precomp.h:35
#define InitializePalette()
Definition: precomp.h:84
const UCHAR VidpFontData[256 *BOOTCHAR_HEIGHT]
Definition: fontdata.c:16
ASMGENDATA Table[]
Definition: genincdata.c:61
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
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 _In_reads_(s)
Definition: no_sal2.h:168
#define _In_
Definition: no_sal2.h:158
#define _Out_writes_bytes_all_(s)
Definition: no_sal2.h:194
int Count
Definition: noreturn.cpp:7
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress(IN PVOID Address)
Definition: stubs.c:685
#define SCREEN_WIDTH
Definition: pc98video.c:24
#define SCREEN_HEIGHT
Definition: pc98video.c:25
unsigned short USHORT
Definition: pedump.c:61
#define BV_COLOR_NONE
Definition: display.h:31
#define BV_COLOR_BLACK
Definition: display.h:15
ULONG Right
Definition: precomp.h:64
ULONG Top
Definition: precomp.h:63
ULONG Bottom
Definition: precomp.h:65
ULONG Left
Definition: precomp.h:62
#define NTAPI
Definition: typedefs.h:36
uint16_t * PUSHORT
Definition: typedefs.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:65
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
ULONG LowPart
Definition: typedefs.h:106
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
_Must_inspect_result_ _In_ WDFMEMORY _In_ size_t SourceOffset
Definition: wdfmemory.h:320
#define FORCEINLINE
Definition: wdftypes.h:67
unsigned char UCHAR
Definition: xmlstorage.h:181
char CHAR
Definition: xmlstorage.h:175