ReactOS 0.4.16-dev-2284-g3529151
xboxvideo.c
Go to the documentation of this file.
1/*
2 * FreeLoader
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Note: much of this code was based on knowledge and/or code developed
19 * by the Xbox Linux group: http://www.xbox-linux.org
20 */
21
22#include <freeldr.h>
23#include "../../vidfb.h"
24
25#include <debug.h>
27
28ULONG NvBase = 0xFD000000;
33
34#define MAKE_COLOR(Red, Green, Blue) (0xff000000 | (((Red) & 0xff) << 16) | (((Green) & 0xff) << 8) | ((Blue) & 0xff))
35
36VOID
38{
40}
41
42VOID
43XboxVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
44{
45 FbConsPutChar(Ch, Attr, X, Y);
46}
47
48static UCHAR
50{
53}
54
55static ULONG
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}
94
95VOID
97{
101
102 /* Reuse the framebuffer that was set up by firmware */
104 TRACE("XBOX framebuffer at 0x%p\n", FrameBuffer);
105 /* Verify that the framebuffer address is page-aligned */
107
108 /* Obtain framebuffer memory size from the multiboot memory map */
110 {
111 /* Fallback to Cromwell standard which reserves high 4 MB of RAM */
112 FrameBufferSize = 4 * 1024 * 1024; // See FB_SIZE
113 WARN("Could not detect framebuffer memory size, fallback to 4 MB\n");
114 }
115
118
119 /* Get BPP directly from NV2A CRTC (magic constants are from Cromwell) */
120 BytesPerPixel = 8 * (((NvGetCrtc(0x19) & 0xE0) << 3) | (NvGetCrtc(0x13) & 0xFF)) / ScreenWidth;
121 if (BytesPerPixel == 4)
122 ASSERT((NvGetCrtc(0x28) & 0xF) == BytesPerPixel - 1);
123 else
124 ASSERT((NvGetCrtc(0x28) & 0xF) == BytesPerPixel);
125
126 /* Verify screen resolution */
127 ASSERT(ScreenWidth > 1);
128 ASSERT(ScreenHeight > 1);
129 ASSERT(BytesPerPixel >= 1 && BytesPerPixel <= 4);
130 /* Verify that screen fits framebuffer size */
132
139 BytesPerPixel * 8,
140 NULL))
141 {
142 ERR("Couldn't initialize video framebuffer\n");
143 return;
144 }
145
147}
148
151{
152 /* We only have one mode, semi-text */
153 return VideoTextMode;
154}
155
156VOID
158{
160}
161
162ULONG
164{
165 return FbConsGetBufferSize();
166}
167
168VOID
170{
171 TRACE("XboxVideoGetFontsFromFirmware(): UNIMPLEMENTED\n");
172}
173
174VOID
176{
177 /* We don't have a cursor yet */
178}
179
180VOID
182{
183 /* We don't have a cursor yet */
184}
185
186VOID
188{
190}
191
194{
195 return FALSE;
196}
197
198VOID
200{
201 /* Not supported */
202}
203
204VOID
206{
207 /* Not supported */
208}
209
210VOID
212{
213 /* Not supported */
214}
215
216VOID
218{
221}
222
223/* EOF */
unsigned char BOOLEAN
Definition: actypes.h:127
#define RomFontPointers
Definition: winldr.c:348
#define READ_REGISTER_ULONG(r)
Definition: arm.h:10
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
BIOS_MEMORY_MAP MemoryMap[32]
Definition: loader.c:11
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
@ VideoTextMode
Definition: machine.h:35
enum tagVIDEODISPLAYMODE VIDEODISPLAYMODE
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define Y(I)
#define ULONG_PTR
Definition: config.h:101
#define PAGE_SIZE
Definition: env_spec_w32.h:49
static UCHAR BytesPerPixel
Definition: bootvid.c:37
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 ASSERT(a)
Definition: mode.c:44
#define MB_INFO_FLAG_MEMORY_MAP
Definition: multiboot.h:50
struct memory_map memory_map_t
#define _In_
Definition: no_sal2.h:158
int Count
Definition: noreturn.cpp:7
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
static ULONG ScreenWidth
Definition: pcvideo.c:116
static ULONG ScreenHeight
Definition: pcvideo.c:117
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:119
#define Ch(x, y, z)
Definition: sha2.c:141
#define TRACE(s)
Definition: solgame.cpp:4
Definition: ui.h:200
ReactOS Framebuffer-specific video device configuration data.
Definition: framebuf.h:35
unsigned long mmap_addr
Definition: multiboot.h:109
unsigned long mmap_length
Definition: multiboot.h:108
unsigned long flags
Definition: multiboot.h:96
uint32_t * PULONG
Definition: typedefs.h:59
int32_t INT
Definition: typedefs.h:58
const char * PCSTR
Definition: typedefs.h:52
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
VOID FbConsClearScreen(_In_ UCHAR Attr)
Definition: vidfb.c:413
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:462
VOID VidFbClearScreenColor(_In_ UINT32 Color, _In_ BOOLEAN FullScreen)
Definition: vidfb.c:230
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:481
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:445
VOID FbConsCopyOffScreenBufferToVRAM(_In_ PVOID Buffer)
Copies a full text-mode CGA-style character buffer rectangle to the console.
Definition: vidfb.c:492
BOOLEAN VidFbInitializeVideo(_Out_opt_ PCM_FRAMEBUF_DEVICE_DATA *pFbData, _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:99
_In_ WDFCOLLECTION _In_ ULONG Index
VOID XboxVideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: xboxvideo.c:205
VOID XboxVideoInit(VOID)
Definition: xboxvideo.c:96
ULONG FrameBufferSize
Definition: xboxvideo.c:30
VOID XboxVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: xboxvideo.c:43
VOID XboxVideoPrepareForReactOS(VOID)
Definition: xboxvideo.c:217
multiboot_info_t * MultibootInfoPtr
VOID XboxVideoSetTextCursorPosition(UCHAR X, UCHAR Y)
Definition: xboxvideo.c:175
VOID XboxVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: xboxvideo.c:199
VOID XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
Definition: xboxvideo.c:187
VOID XboxVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
Definition: xboxvideo.c:157
ULONG XboxVideoGetBufferSize(VOID)
Definition: xboxvideo.c:163
static UCHAR NvGetCrtc(UCHAR Index)
Definition: xboxvideo.c:49
PCM_FRAMEBUF_DEVICE_DATA FrameBufferData
Definition: xboxvideo.c:31
ULONG NvBase
Definition: xboxvideo.c:28
VOID XboxVideoSync(VOID)
Definition: xboxvideo.c:211
VOID XboxVideoHideShowTextCursor(BOOLEAN Show)
Definition: xboxvideo.c:181
BOOLEAN XboxVideoIsPaletteFixed(VOID)
Definition: xboxvideo.c:193
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
VOID XboxVideoClearScreen(UCHAR Attr)
Definition: xboxvideo.c:37
VIDEODISPLAYMODE XboxVideoSetDisplayMode(PCSTR DisplayMode, BOOLEAN Init)
Definition: xboxvideo.c:150
VOID XboxVideoGetFontsFromFirmware(PULONG RomFontPointers)
Definition: xboxvideo.c:169
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:819
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)
#define NV2A_CRTC_FRAMEBUFFER_START
Definition: xgpu.h:21
#define NV2A_RAMDAC_FP_VVALID_END
Definition: xgpu.h:26
#define NV2A_CRTC_REGISTER_INDEX
Definition: xgpu.h:22
#define NV2A_CRTC_REGISTER_VALUE
Definition: xgpu.h:23
#define NV2A_RAMDAC_FP_HVALID_END
Definition: xgpu.h:25
unsigned char UCHAR
Definition: xmlstorage.h:181