ReactOS 0.4.16-dev-2104-gb84fa49
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;
32#define FB_SIZE_MB 4
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 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}
142
145{
146 /* We only have one mode, semi-text */
147 return VideoTextMode;
148}
149
150VOID
152{
154}
155
156ULONG
158{
159 return FbConsGetBufferSize();
160}
161
162VOID
164{
165 TRACE("XboxVideoGetFontsFromFirmware(): UNIMPLEMENTED\n");
166}
167
168VOID
170{
171 /* We don't have a cursor yet */
172}
173
174VOID
176{
177 /* We don't have a cursor yet */
178}
179
180VOID
182{
184}
185
188{
189 return FALSE;
190}
191
192VOID
194{
195 /* Not supported */
196}
197
198VOID
200{
201 /* Not supported */
202}
203
204VOID
206{
207 /* Not supported */
208}
209
210VOID
212{
215}
216
217/* EOF */
unsigned char BOOLEAN
#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
@ Green
Definition: bl.h:199
@ Red
Definition: bl.h:201
@ Blue
Definition: bl.h:198
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
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
static UCHAR BytesPerPixel
Definition: bootvid.c:23
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
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:377
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
VOID VidFbClearScreenColor(_In_ UINT32 Color, _In_ BOOLEAN FullScreen)
Definition: vidfb.c:194
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
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
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
VOID FbConsCopyOffScreenBufferToVRAM(_In_ PVOID Buffer)
Copies a full text-mode CGA-style character buffer rectangle to the console.
Definition: vidfb.c:456
_In_ WDFCOLLECTION _In_ ULONG Index
VOID XboxVideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
Definition: xboxvideo.c:199
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:211
multiboot_info_t * MultibootInfoPtr
VOID XboxVideoSetTextCursorPosition(UCHAR X, UCHAR Y)
Definition: xboxvideo.c:169
VOID XboxVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
Definition: xboxvideo.c:193
VOID XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
Definition: xboxvideo.c:181
VOID XboxVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
Definition: xboxvideo.c:151
ULONG XboxVideoGetBufferSize(VOID)
Definition: xboxvideo.c:157
static UCHAR NvGetCrtc(UCHAR Index)
Definition: xboxvideo.c:49
ULONG NvBase
Definition: xboxvideo.c:28
VOID XboxVideoSync(VOID)
Definition: xboxvideo.c:205
VOID XboxVideoHideShowTextCursor(BOOLEAN Show)
Definition: xboxvideo.c:175
BOOLEAN XboxVideoIsPaletteFixed(VOID)
Definition: xboxvideo.c:187
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:144
VOID XboxVideoGetFontsFromFirmware(PULONG RomFontPointers)
Definition: xboxvideo.c:163
_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