ReactOS 0.4.16-dev-2104-gb84fa49
xboxvideo.c File Reference
#include <freeldr.h>
#include "../../vidfb.h"
#include <debug.h>
Include dependency graph for xboxvideo.c:

Go to the source code of this file.

Macros

#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)
 
VOID XboxVideoClearScreen (UCHAR Attr)
 
VOID XboxVideoPutChar (int Ch, UCHAR Attr, unsigned X, unsigned Y)
 
static UCHAR NvGetCrtc (UCHAR Index)
 
static ULONG XboxGetFramebufferSize (_In_ ULONG_PTR 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
 
ULONG_PTR FrameBuffer
 
ULONG FrameBufferSize
 
multiboot_info_tMultibootInfoPtr
 

Macro Definition Documentation

◆ FB_SIZE_MB

#define FB_SIZE_MB   4

Definition at line 32 of file xboxvideo.c.

◆ MAKE_COLOR

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

Definition at line 34 of file xboxvideo.c.

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UI  )

◆ NvGetCrtc()

static UCHAR NvGetCrtc ( UCHAR  Index)
static

Definition at line 49 of file xboxvideo.c.

50{
53}
_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()

static ULONG XboxGetFramebufferSize ( _In_ ULONG_PTR  Offset)
static

Definition at line 56 of file xboxvideo.c.

58{
60 INT Count, i;
61
63 return 0;
64
66 return 0;
67
69
70 if (!MemoryMap ||
73 {
74 return 0;
75 }
76
78 for (i = 0; i < Count; i++, MemoryMap++)
79 {
80 TRACE("i = %d, base_addr_low = 0x%p, MemoryMap->length_low = 0x%p\n", i, MemoryMap->base_addr_low, MemoryMap->length_low);
81
82 /* Framebuffer address offset value is coming from the GPU within
83 * memory mapped I/O address space, so we're comparing only low
84 * 28 bits of the address within actual RAM address space */
85 if (MemoryMap->base_addr_low == (Offset & 0x0FFFFFFF) && MemoryMap->base_addr_high == 0)
86 {
87 TRACE("Video memory found\n");
88 return MemoryMap->length_low;
89 }
90 }
91 ERR("Video memory not found!\n");
92 return 0;
93}
#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
multiboot_info_t * MultibootInfoPtr

Referenced by XboxVideoInit().

◆ XboxVideoClearScreen()

VOID XboxVideoClearScreen ( UCHAR  Attr)

Definition at line 37 of file xboxvideo.c.

38{
40}
VOID FbConsClearScreen(_In_ UCHAR Attr)
Definition: vidfb.c:377

Referenced by MachInit().

◆ XboxVideoCopyOffScreenBufferToVRAM()

VOID XboxVideoCopyOffScreenBufferToVRAM ( PVOID  Buffer)

Definition at line 181 of file xboxvideo.c.

182{
184}
Definition: bufpool.h:45
VOID FbConsCopyOffScreenBufferToVRAM(_In_ PVOID Buffer)
Copies a full text-mode CGA-style character buffer rectangle to the console.
Definition: vidfb.c:456

Referenced by MachInit().

◆ XboxVideoGetBufferSize()

ULONG XboxVideoGetBufferSize ( VOID  )

Definition at line 157 of file xboxvideo.c.

158{
159 return FbConsGetBufferSize();
160}
ULONG FbConsGetBufferSize(VOID)
Returns the size in bytes, of a full text-mode CGA-style character buffer rectangle that can fill the...
Definition: vidfb.c:445

Referenced by MachInit().

◆ XboxVideoGetDisplaySize()

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

Definition at line 151 of file xboxvideo.c.

152{
154}
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
VOID FbConsGetDisplaySize(_Out_ PULONG Width, _Out_ PULONG Height, _Out_ PULONG Depth)
Returns the width and height in number of CGA characters/attributes, of a full text-mode CGA-style ch...
Definition: vidfb.c:426
_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 163 of file xboxvideo.c.

164{
165 TRACE("XboxVideoGetFontsFromFirmware(): UNIMPLEMENTED\n");
166}

Referenced by MachInit().

◆ XboxVideoGetPaletteColor()

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

Definition at line 199 of file xboxvideo.c.

200{
201 /* Not supported */
202}

Referenced by MachInit().

◆ XboxVideoHideShowTextCursor()

VOID XboxVideoHideShowTextCursor ( BOOLEAN  Show)

Definition at line 175 of file xboxvideo.c.

176{
177 /* We don't have a cursor yet */
178}

Referenced by MachInit(), and XboxVideoPrepareForReactOS().

◆ XboxVideoInit()

VOID XboxVideoInit ( VOID  )

Definition at line 96 of file xboxvideo.c.

97{
101
102 /* Reuse framebuffer that was set up by firmware */
104 /* Verify that framebuffer address is page-aligned */
106
107 /* Obtain framebuffer memory size from multiboot memory map */
109 {
110 /* Fallback to Cromwell standard which reserves high 4 MB of RAM */
111 FrameBufferSize = 4 * 1024 * 1024;
112 WARN("Could not detect framebuffer memory size, fallback to 4 MB\n");
113 }
114
117
118 /* Get BPP directly from NV2A CRTC (magic constants are from Cromwell) */
119 BytesPerPixel = 8 * (((NvGetCrtc(0x19) & 0xE0) << 3) | (NvGetCrtc(0x13) & 0xFF)) / ScreenWidth;
120 if (BytesPerPixel == 4)
121 ASSERT((NvGetCrtc(0x28) & 0xF) == BytesPerPixel - 1);
122 else
123 ASSERT((NvGetCrtc(0x28) & 0xF) == BytesPerPixel);
124
125 /* Verify screen resolution */
126 ASSERT(ScreenWidth > 1);
127 ASSERT(ScreenHeight > 1);
128 ASSERT(BytesPerPixel >= 1 && BytesPerPixel <= 4);
129 /* Verify that screen fits framebuffer size */
131
136 ScreenWidth, // PixelsPerScanLine
137 BytesPerPixel * 8,
138 NULL);
139
141}
#define READ_REGISTER_ULONG(r)
Definition: arm.h:10
#define WARN(fmt,...)
Definition: precomp.h:61
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define ULONG_PTR
Definition: config.h:101
#define PAGE_SIZE
Definition: env_spec_w32.h:49
static UCHAR BytesPerPixel
Definition: bootvid.c:23
#define ASSERT(a)
Definition: mode.c:44
static ULONG ScreenWidth
Definition: pcvideo.c:116
static ULONG ScreenHeight
Definition: pcvideo.c:117
uint32_t ULONG
Definition: typedefs.h:59
VOID VidFbClearScreenColor(_In_ UINT32 Color, _In_ BOOLEAN FullScreen)
Definition: vidfb.c:194
BOOLEAN VidFbInitializeVideo(_In_ ULONG_PTR BaseAddress, _In_ ULONG BufferSize, _In_ UINT32 ScreenWidth, _In_ UINT32 ScreenHeight, _In_ UINT32 PixelsPerScanLine, _In_ UINT32 BitsPerPixel, _In_opt_ PPIXEL_BITMASK PixelMasks)
Initializes internal framebuffer information based on the given parameters.
Definition: vidfb.c:97
ULONG FrameBufferSize
Definition: xboxvideo.c:30
static UCHAR NvGetCrtc(UCHAR Index)
Definition: xboxvideo.c:49
static ULONG XboxGetFramebufferSize(_In_ ULONG_PTR Offset)
Definition: xboxvideo.c:56
ULONG_PTR FrameBuffer
Definition: xboxvideo.c:29
#define MAKE_COLOR(Red, Green, Blue)
Definition: xboxvideo.c:34
#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 187 of file xboxvideo.c.

188{
189 return FALSE;
190}
#define FALSE
Definition: types.h:117

Referenced by MachInit().

◆ XboxVideoPrepareForReactOS()

VOID XboxVideoPrepareForReactOS ( VOID  )

Definition at line 211 of file xboxvideo.c.

212{
215}
VOID XboxVideoHideShowTextCursor(BOOLEAN Show)
Definition: xboxvideo.c:175

Referenced by XboxPrepareForReactOS().

◆ XboxVideoPutChar()

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

Definition at line 43 of file xboxvideo.c.

44{
45 FbConsPutChar(Ch, Attr, X, Y);
46}
#define Y(I)
#define Ch(x, y, z)
Definition: sha2.c:141
VOID FbConsPutChar(_In_ UCHAR Char, _In_ UCHAR Attr, _In_ ULONG Column, _In_ ULONG Row)
Displays a character with specific text attributes at a given position.
Definition: vidfb.c:409

Referenced by MachInit(), and XboxConsPutChar().

◆ XboxVideoSetDisplayMode()

VIDEODISPLAYMODE XboxVideoSetDisplayMode ( PCSTR  DisplayMode,
BOOLEAN  Init 
)

Definition at line 144 of file xboxvideo.c.

145{
146 /* We only have one mode, semi-text */
147 return VideoTextMode;
148}
@ VideoTextMode
Definition: machine.h:35

Referenced by MachInit().

◆ XboxVideoSetPaletteColor()

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

Definition at line 193 of file xboxvideo.c.

194{
195 /* Not supported */
196}

Referenced by MachInit().

◆ XboxVideoSetTextCursorPosition()

VOID XboxVideoSetTextCursorPosition ( UCHAR  X,
UCHAR  Y 
)

Definition at line 169 of file xboxvideo.c.

170{
171 /* We don't have a cursor yet */
172}

Referenced by MachInit().

◆ XboxVideoSync()

VOID XboxVideoSync ( VOID  )

Definition at line 205 of file xboxvideo.c.

206{
207 /* Not supported */
208}

Referenced by MachInit().

Variable Documentation

◆ FrameBuffer

ULONG_PTR FrameBuffer

Definition at line 29 of file xboxvideo.c.

Referenced by XboxVideoInit().

◆ FrameBufferSize

◆ 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().