ReactOS 0.4.16-dev-1998-g617f3bd
xboxvideo.c File Reference
#include <freeldr.h>
#include "../../vgafont.h"
#include <debug.h>
Include dependency graph for xboxvideo.c:

Go to the source code of this file.

Macros

#define TOP_BOTTOM_LINES   0
 
#define FB_SIZE_MB   4
 
#define MAKE_COLOR(Red, Green, Blue)   (0xff000000 | (((Red) & 0xff) << 16) | (((Green) & 0xff) << 8) | ((Blue) & 0xff))
 

Functions

 DBG_DEFAULT_CHANNEL (UI)
 
static VOID XboxVideoOutputChar (UCHAR Char, unsigned X, unsigned Y, ULONG FgColor, ULONG BgColor)
 
static ULONG XboxVideoAttrToSingleColor (UCHAR Attr)
 
static VOID XboxVideoAttrToColors (UCHAR Attr, ULONG *FgColor, ULONG *BgColor)
 
static VOID XboxVideoClearScreenColor (ULONG Color, BOOLEAN FullScreen)
 
VOID XboxVideoScrollUp (VOID)
 
VOID XboxVideoClearScreen (UCHAR Attr)
 
VOID XboxVideoPutChar (int Ch, UCHAR Attr, unsigned X, unsigned Y)
 
UCHAR NvGetCrtc (UCHAR Index)
 
ULONG XboxGetFramebufferSize (PVOID Offset)
 
VOID XboxVideoInit (VOID)
 
VIDEODISPLAYMODE XboxVideoSetDisplayMode (PCSTR DisplayMode, BOOLEAN Init)
 
VOID XboxVideoGetDisplaySize (PULONG Width, PULONG Height, PULONG Depth)
 
ULONG XboxVideoGetBufferSize (VOID)
 
VOID XboxVideoGetFontsFromFirmware (PULONG RomFontPointers)
 
VOID XboxVideoSetTextCursorPosition (UCHAR X, UCHAR Y)
 
VOID XboxVideoHideShowTextCursor (BOOLEAN Show)
 
VOID XboxVideoCopyOffScreenBufferToVRAM (PVOID Buffer)
 
BOOLEAN XboxVideoIsPaletteFixed (VOID)
 
VOID XboxVideoSetPaletteColor (UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
 
VOID XboxVideoGetPaletteColor (UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
 
VOID XboxVideoSync (VOID)
 
VOID XboxVideoPrepareForReactOS (VOID)
 

Variables

ULONG NvBase = 0xFD000000
 
PVOID FrameBuffer
 
ULONG FrameBufferSize
 
static ULONG ScreenWidth
 
static ULONG ScreenHeight
 
static ULONG BytesPerPixel
 
static ULONG Delta
 
multiboot_info_tMultibootInfoPtr
 
UCHAR MachDefaultTextColor = COLOR_GRAY
 

Macro Definition Documentation

◆ FB_SIZE_MB

#define FB_SIZE_MB   4

Definition at line 41 of file xboxvideo.c.

◆ MAKE_COLOR

#define MAKE_COLOR (   Red,
  Green,
  Blue 
)    (0xff000000 | (((Red) & 0xff) << 16) | (((Green) & 0xff) << 8) | ((Blue) & 0xff))

Definition at line 43 of file xboxvideo.c.

◆ TOP_BOTTOM_LINES

#define TOP_BOTTOM_LINES   0

Definition at line 39 of file xboxvideo.c.

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UI  )

◆ NvGetCrtc()

UCHAR NvGetCrtc ( UCHAR  Index)

Definition at line 144 of file xboxvideo.c.

145{
148}
_In_ WDFCOLLECTION _In_ ULONG Index
ULONG NvBase
Definition: xboxvideo.c:28
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)
#define NV2A_CRTC_REGISTER_INDEX
Definition: xgpu.h:22
#define NV2A_CRTC_REGISTER_VALUE
Definition: xgpu.h:23

Referenced by XboxVideoInit().

◆ XboxGetFramebufferSize()

ULONG XboxGetFramebufferSize ( PVOID  Offset)

Definition at line 151 of file xboxvideo.c.

152{
154 INT Count, i;
155
156 if (!MultibootInfoPtr)
157 {
158 return 0;
159 }
160
162 {
163 return 0;
164 }
165
167
168 if (!MemoryMap ||
171 {
172 return 0;
173 }
174
176 for (i = 0; i < Count; i++, MemoryMap++)
177 {
178 TRACE("i = %d, base_addr_low = 0x%p, MemoryMap->length_low = 0x%p\n", i, MemoryMap->base_addr_low, MemoryMap->length_low);
179
180 /* Framebuffer address offset value is coming from the GPU within
181 * memory mapped I/O address space, so we're comparing only low
182 * 28 bits of the address within actual RAM address space */
183 if (MemoryMap->base_addr_low == ((ULONG)Offset & 0x0FFFFFFF) && MemoryMap->base_addr_high == 0)
184 {
185 TRACE("Video memory found\n");
186 return MemoryMap->length_low;
187 }
188 }
189 ERR("Video memory not found!\n");
190 return 0;
191}
#define ERR(fmt,...)
Definition: precomp.h:57
BIOS_MEMORY_MAP MemoryMap[32]
Definition: loader.c:11
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
if(dx< 0)
Definition: linetemp.h:194
#define MB_INFO_FLAG_MEMORY_MAP
Definition: multiboot.h:50
struct memory_map memory_map_t
int Count
Definition: noreturn.cpp:7
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long mmap_addr
Definition: multiboot.h:109
unsigned long mmap_length
Definition: multiboot.h:108
unsigned long flags
Definition: multiboot.h:96
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
multiboot_info_t * MultibootInfoPtr

Referenced by XboxVideoInit().

◆ XboxVideoAttrToColors()

static VOID XboxVideoAttrToColors ( UCHAR  Attr,
ULONG FgColor,
ULONG BgColor 
)
static

Definition at line 83 of file xboxvideo.c.

84{
85 *FgColor = XboxVideoAttrToSingleColor(Attr & 0xf);
86 *BgColor = XboxVideoAttrToSingleColor((Attr >> 4) & 0xf);
87}
static ULONG XboxVideoAttrToSingleColor(UCHAR Attr)
Definition: xboxvideo.c:70

Referenced by XboxVideoClearScreen(), XboxVideoPutChar(), and XboxVideoScrollUp().

◆ XboxVideoAttrToSingleColor()

static ULONG XboxVideoAttrToSingleColor ( UCHAR  Attr)
static

Definition at line 70 of file xboxvideo.c.

71{
73
74 Intensity = (0 == (Attr & 0x08) ? 127 : 255);
75
76 return 0xff000000 |
77 (0 == (Attr & 0x04) ? 0 : (Intensity << 16)) |
78 (0 == (Attr & 0x02) ? 0 : (Intensity << 8)) |
79 (0 == (Attr & 0x01) ? 0 : Intensity);
80}
static WORD Intensity(RGBQUAD clr)
Definition: msrle32.c:44
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by XboxVideoAttrToColors().

◆ XboxVideoClearScreen()

VOID XboxVideoClearScreen ( UCHAR  Attr)

Definition at line 124 of file xboxvideo.c.

125{
126 ULONG FgColor, BgColor;
127
128 XboxVideoAttrToColors(Attr, &FgColor, &BgColor);
129
131}
#define FALSE
Definition: types.h:117
static VOID XboxVideoClearScreenColor(ULONG Color, BOOLEAN FullScreen)
Definition: xboxvideo.c:90
static VOID XboxVideoAttrToColors(UCHAR Attr, ULONG *FgColor, ULONG *BgColor)
Definition: xboxvideo.c:83

Referenced by MachInit().

◆ XboxVideoClearScreenColor()

static VOID XboxVideoClearScreenColor ( ULONG  Color,
BOOLEAN  FullScreen 
)
static

Definition at line 90 of file xboxvideo.c.

91{
92 ULONG Line, Col;
93 PULONG p;
94
95 for (Line = 0; Line < ScreenHeight - (FullScreen ? 0 : 2 * TOP_BOTTOM_LINES); Line++)
96 {
97 p = (PULONG) ((char *) FrameBuffer + (Line + (FullScreen ? 0 : TOP_BOTTOM_LINES)) * Delta);
98 for (Col = 0; Col < ScreenWidth; Col++)
99 {
100 *p++ = Color;
101 }
102 }
103}
GLfloat GLfloat p
Definition: glext.h:8902
Definition: ncftp.h:79
uint32_t * PULONG
Definition: typedefs.h:59
static ULONG ScreenWidth
Definition: xboxvideo.c:31
static ULONG Delta
Definition: xboxvideo.c:34
#define TOP_BOTTOM_LINES
Definition: xboxvideo.c:39
static ULONG ScreenHeight
Definition: xboxvideo.c:32
PVOID FrameBuffer
Definition: xboxvideo.c:29

Referenced by XboxVideoClearScreen(), XboxVideoInit(), and XboxVideoPrepareForReactOS().

◆ XboxVideoCopyOffScreenBufferToVRAM()

VOID XboxVideoCopyOffScreenBufferToVRAM ( PVOID  Buffer)

Definition at line 273 of file xboxvideo.c.

274{
275 PUCHAR OffScreenBuffer = (PUCHAR) Buffer;
276 ULONG Col, Line;
277
278 for (Line = 0; Line < (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT; Line++)
279 {
280 for (Col = 0; Col < ScreenWidth / CHAR_WIDTH; Col++)
281 {
282 XboxVideoPutChar(OffScreenBuffer[0], OffScreenBuffer[1], Col, Line);
283 OffScreenBuffer += 2;
284 }
285 }
286}
Definition: bufpool.h:45
unsigned char * PUCHAR
Definition: typedefs.h:53
#define CHAR_WIDTH
Definition: vgafont.h:10
#define CHAR_HEIGHT
Definition: vgafont.h:11
VOID XboxVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: xboxvideo.c:134

Referenced by MachInit().

◆ XboxVideoGetBufferSize()

ULONG XboxVideoGetBufferSize ( VOID  )

Definition at line 249 of file xboxvideo.c.

250{
252}

Referenced by MachInit().

◆ XboxVideoGetDisplaySize()

VOID XboxVideoGetDisplaySize ( PULONG  Width,
PULONG  Height,
PULONG  Depth 
)

Definition at line 241 of file xboxvideo.c.

242{
245 *Depth = 0;
246}
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:819

Referenced by MachInit(), and XboxConsPutChar().

◆ XboxVideoGetFontsFromFirmware()

VOID XboxVideoGetFontsFromFirmware ( PULONG  RomFontPointers)

Definition at line 255 of file xboxvideo.c.

256{
257 TRACE("XboxVideoGetFontsFromFirmware(): UNIMPLEMENTED\n");
258}

Referenced by MachInit().

◆ XboxVideoGetPaletteColor()

VOID XboxVideoGetPaletteColor ( UCHAR  Color,
UCHAR Red,
UCHAR Green,
UCHAR Blue 
)

Definition at line 301 of file xboxvideo.c.

302{
303 /* Not supported */
304}

Referenced by MachInit().

◆ XboxVideoHideShowTextCursor()

VOID XboxVideoHideShowTextCursor ( BOOLEAN  Show)

Definition at line 267 of file xboxvideo.c.

268{
269 /* We don't have a cursor yet */
270}

Referenced by MachInit(), and XboxVideoPrepareForReactOS().

◆ XboxVideoInit()

VOID XboxVideoInit ( VOID  )

Definition at line 194 of file xboxvideo.c.

195{
196 /* Reuse framebuffer that was set up by firmware */
198 /* Verify that framebuffer address is page-aligned */
200
201 /* Obtain framebuffer memory size from multiboot memory map */
203 {
204 /* Fallback to Cromwell standard which reserves high 4 MB of RAM */
205 FrameBufferSize = 4 * 1024 * 1024;
206 WARN("Could not detect framebuffer memory size, fallback to 4 MB\n");
207 }
208
211 /* Get BPP directly from NV2A CRTC (magic constants are from Cromwell) */
212 BytesPerPixel = 8 * (((NvGetCrtc(0x19) & 0xE0) << 3) | (NvGetCrtc(0x13) & 0xFF)) / ScreenWidth;
213 if (BytesPerPixel == 4)
214 {
215 ASSERT((NvGetCrtc(0x28) & 0xF) == BytesPerPixel - 1);
216 }
217 else
218 {
219 ASSERT((NvGetCrtc(0x28) & 0xF) == BytesPerPixel);
220 }
221 Delta = (ScreenWidth * BytesPerPixel + 3) & ~ 0x3;
222
223 /* Verify screen resolution */
224 ASSERT(ScreenWidth > 1);
225 ASSERT(ScreenHeight > 1);
226 ASSERT(BytesPerPixel >= 1 && BytesPerPixel <= 4);
227 /* Verify that screen fits framebuffer size */
229
231}
#define READ_REGISTER_ULONG(r)
Definition: arm.h:26
#define WARN(fmt,...)
Definition: precomp.h:61
#define TRUE
Definition: types.h:120
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define ASSERT(a)
Definition: mode.c:44
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
ULONG FrameBufferSize
Definition: xboxvideo.c:30
ULONG XboxGetFramebufferSize(PVOID Offset)
Definition: xboxvideo.c:151
#define MAKE_COLOR(Red, Green, Blue)
Definition: xboxvideo.c:43
static ULONG BytesPerPixel
Definition: xboxvideo.c:33
UCHAR NvGetCrtc(UCHAR Index)
Definition: xboxvideo.c:144
#define NV2A_CRTC_FRAMEBUFFER_START
Definition: xgpu.h:21
#define NV2A_RAMDAC_FP_VVALID_END
Definition: xgpu.h:26
#define NV2A_RAMDAC_FP_HVALID_END
Definition: xgpu.h:25

Referenced by MachInit().

◆ XboxVideoIsPaletteFixed()

BOOLEAN XboxVideoIsPaletteFixed ( VOID  )

Definition at line 289 of file xboxvideo.c.

290{
291 return FALSE;
292}

Referenced by MachInit().

◆ XboxVideoOutputChar()

static VOID XboxVideoOutputChar ( UCHAR  Char,
unsigned  X,
unsigned  Y,
ULONG  FgColor,
ULONG  BgColor 
)
static

Definition at line 46 of file xboxvideo.c.

47{
48 const UCHAR* FontPtr;
49 PULONG Pixel;
50 UCHAR Mask;
51 unsigned Line;
52 unsigned Col;
53
54 FontPtr = BitmapFont8x16 + Char * CHAR_HEIGHT;
55 Pixel = (PULONG) ((char *) FrameBuffer + (Y * CHAR_HEIGHT + TOP_BOTTOM_LINES) * Delta
57 for (Line = 0; Line < CHAR_HEIGHT; Line++)
58 {
59 Mask = 0x80;
60 for (Col = 0; Col < CHAR_WIDTH; Col++)
61 {
62 Pixel[Col] = (0 != (FontPtr[Line] & Mask) ? FgColor : BgColor);
63 Mask = Mask >> 1;
64 }
65 Pixel = (PULONG) ((char *) Pixel + Delta);
66 }
67}
#define Y(I)
unsigned int Mask
Definition: fpcontrol.c:82
const UCHAR BitmapFont8x16[256 *CHAR_HEIGHT]
Definition: vgafont.c:13

Referenced by XboxVideoPutChar().

◆ XboxVideoPrepareForReactOS()

VOID XboxVideoPrepareForReactOS ( VOID  )

Definition at line 313 of file xboxvideo.c.

314{
317}
VOID XboxVideoHideShowTextCursor(BOOLEAN Show)
Definition: xboxvideo.c:267

Referenced by XboxPrepareForReactOS().

◆ XboxVideoPutChar()

VOID XboxVideoPutChar ( int  Ch,
UCHAR  Attr,
unsigned  X,
unsigned  Y 
)

Definition at line 134 of file xboxvideo.c.

135{
136 ULONG FgColor, BgColor;
137
138 XboxVideoAttrToColors(Attr, &FgColor, &BgColor);
139
140 XboxVideoOutputChar(Ch, X, Y, FgColor, BgColor);
141}
#define Ch(x, y, z)
Definition: sha2.c:141
static VOID XboxVideoOutputChar(UCHAR Char, unsigned X, unsigned Y, ULONG FgColor, ULONG BgColor)
Definition: xboxvideo.c:46

Referenced by MachInit(), XboxConsPutChar(), and XboxVideoCopyOffScreenBufferToVRAM().

◆ XboxVideoScrollUp()

VOID XboxVideoScrollUp ( VOID  )

Definition at line 106 of file xboxvideo.c.

107{
108 ULONG BgColor, Dummy;
109 ULONG PixelCount = ScreenWidth * CHAR_HEIGHT *
110 (((ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT) - 1);
113
115
116 while (PixelCount--)
117 *Dst++ = *Src++;
118
119 for (PixelCount = 0; PixelCount < ScreenWidth * CHAR_HEIGHT; PixelCount++)
120 *Dst++ = BgColor;
121}
#define ATTR(cFore, cBack)
Definition: ui.h:323
#define COLOR_WHITE
Definition: ui.h:344
#define COLOR_BLACK
Definition: ui.h:328
#define Dst
Definition: mesh.h:153

Referenced by XboxConsPutChar().

◆ XboxVideoSetDisplayMode()

VIDEODISPLAYMODE XboxVideoSetDisplayMode ( PCSTR  DisplayMode,
BOOLEAN  Init 
)

Definition at line 234 of file xboxvideo.c.

235{
236 /* We only have one mode, semi-text */
237 return VideoTextMode;
238}
@ VideoTextMode
Definition: machine.h:35

Referenced by MachInit().

◆ XboxVideoSetPaletteColor()

VOID XboxVideoSetPaletteColor ( UCHAR  Color,
UCHAR  Red,
UCHAR  Green,
UCHAR  Blue 
)

Definition at line 295 of file xboxvideo.c.

296{
297 /* Not supported */
298}

Referenced by MachInit().

◆ XboxVideoSetTextCursorPosition()

VOID XboxVideoSetTextCursorPosition ( UCHAR  X,
UCHAR  Y 
)

Definition at line 261 of file xboxvideo.c.

262{
263 /* We don't have a cursor yet */
264}

Referenced by MachInit().

◆ XboxVideoSync()

VOID XboxVideoSync ( VOID  )

Definition at line 307 of file xboxvideo.c.

308{
309 /* Not supported */
310}

Referenced by MachInit().

Variable Documentation

◆ BytesPerPixel

ULONG BytesPerPixel
static

◆ Delta

◆ FrameBuffer

PVOID FrameBuffer

◆ FrameBufferSize

◆ MachDefaultTextColor

UCHAR MachDefaultTextColor = COLOR_GRAY

Definition at line 37 of file xboxvideo.c.

◆ MultibootInfoPtr

multiboot_info_t* MultibootInfoPtr
extern

Referenced by XboxGetFramebufferSize().

◆ NvBase

ULONG NvBase = 0xFD000000

Definition at line 28 of file xboxvideo.c.

Referenced by NvGetCrtc(), XboxMemInit(), and XboxVideoInit().

◆ ScreenHeight

◆ ScreenWidth