https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2a77e359e42b099ed081a…
commit 2a77e359e42b099ed081a453bec1bc81eab00685
Author: Stanislav Motylkov <x86corez(a)gmail.com>
AuthorDate: Wed Aug 26 16:58:01 2020 +0300
Commit: Stanislav Motylkov <x86corez(a)gmail.com>
CommitDate: Wed Aug 26 16:58:01 2020 +0300
[XBOX] Move NV2A XGPU definitions into header file
TODO: helper functions should be also moved. CORE-16216
---
boot/freeldr/freeldr/arch/i386/xbox/xboxmem.c | 5 ++--
boot/freeldr/freeldr/arch/i386/xbox/xboxvideo.c | 11 +++++----
boot/freeldr/freeldr/include/arch/i386/machxbox.h | 11 +--------
drivers/base/bootvid/CMakeLists.txt | 2 +-
drivers/base/bootvid/i386/xbox/bootvid.c | 4 +++-
drivers/base/bootvid/i386/xbox/{nv2a.h => xbox.h} | 15 +++---------
drivers/base/bootvid/precomp.h | 2 +-
sdk/include/reactos/drivers/xbox/xgpu.h | 28 +++++++++++++++++++++++
win32ss/drivers/miniport/xboxvmp/xboxvmp.c | 6 +++--
win32ss/drivers/miniport/xboxvmp/xboxvmp.h | 8 -------
10 files changed, 50 insertions(+), 42 deletions(-)
diff --git a/boot/freeldr/freeldr/arch/i386/xbox/xboxmem.c
b/boot/freeldr/freeldr/arch/i386/xbox/xboxmem.c
index 57a88ecf4a8..1990199d70b 100644
--- a/boot/freeldr/freeldr/arch/i386/xbox/xboxmem.c
+++ b/boot/freeldr/freeldr/arch/i386/xbox/xboxmem.c
@@ -27,6 +27,7 @@ DBG_DEFAULT_CHANNEL(MEMORY);
static ULONG InstalledMemoryMb = 0;
static ULONG AvailableMemoryMb = 0;
extern multiboot_info_t * MultibootInfoPtr;
+extern ULONG NvBase;
extern PVOID FrameBuffer;
extern ULONG FrameBufferSize;
@@ -60,8 +61,8 @@ XboxMemInit(VOID)
PVOID MembaseTop = (PVOID)(64 * 1024 * 1024);
PVOID MembaseLow = (PVOID)0;
- WRITE_REGISTER_ULONG((PULONG)NV2A_FB_CFG0, 0x03070103);
- WRITE_REGISTER_ULONG((PULONG)(NV2A_FB_CFG0 + 4), 0x11448000);
+ WRITE_REGISTER_ULONG((PULONG)(NvBase + NV2A_FB_CFG0), 0x03070103);
+ WRITE_REGISTER_ULONG((PULONG)(NvBase + NV2A_FB_CFG0 + 4), 0x11448000);
/* Prep hardware for 128 Mb */
WRITE_PORT_ULONG((PULONG)0xCF8, CONFIG_CMD(0, 0, 0x84));
diff --git a/boot/freeldr/freeldr/arch/i386/xbox/xboxvideo.c
b/boot/freeldr/freeldr/arch/i386/xbox/xboxvideo.c
index 0d6e3b2c70b..435ad2a59aa 100644
--- a/boot/freeldr/freeldr/arch/i386/xbox/xboxvideo.c
+++ b/boot/freeldr/freeldr/arch/i386/xbox/xboxvideo.c
@@ -24,6 +24,7 @@
#include <debug.h>
DBG_DEFAULT_CHANNEL(UI);
+ULONG NvBase = 0xFD000000;
PVOID FrameBuffer;
ULONG FrameBufferSize;
static ULONG ScreenWidth;
@@ -142,8 +143,8 @@ XboxVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
UCHAR
NvGetCrtc(UCHAR Index)
{
- WRITE_REGISTER_UCHAR(NV2A_CRTC_REGISTER_INDEX, Index);
- return READ_REGISTER_UCHAR(NV2A_CRTC_REGISTER_VALUE);
+ WRITE_REGISTER_UCHAR(NvBase + NV2A_CRTC_REGISTER_INDEX, Index);
+ return READ_REGISTER_UCHAR(NvBase + NV2A_CRTC_REGISTER_VALUE);
}
ULONG
@@ -193,7 +194,7 @@ VOID
XboxVideoInit(VOID)
{
/* Reuse framebuffer that was set up by firmware */
- FrameBuffer = (PVOID)READ_REGISTER_ULONG(NV2A_CRTC_FRAMEBUFFER_START);
+ FrameBuffer = (PVOID)READ_REGISTER_ULONG(NvBase + NV2A_CRTC_FRAMEBUFFER_START);
/* Verify that framebuffer address is page-aligned */
ASSERT((ULONG_PTR)FrameBuffer % PAGE_SIZE == 0);
@@ -205,8 +206,8 @@ XboxVideoInit(VOID)
WARN("Could not detect framebuffer memory size, fallback to 4 MB\n");
}
- ScreenWidth = READ_REGISTER_ULONG(NV2A_RAMDAC_FP_HVALID_END) + 1;
- ScreenHeight = READ_REGISTER_ULONG(NV2A_RAMDAC_FP_VVALID_END) + 1;
+ ScreenWidth = READ_REGISTER_ULONG(NvBase + NV2A_RAMDAC_FP_HVALID_END) + 1;
+ ScreenHeight = READ_REGISTER_ULONG(NvBase + NV2A_RAMDAC_FP_VVALID_END) + 1;
/* Get BPP directly from NV2A CRTC (magic constants are from Cromwell) */
BytesPerPixel = 8 * (((NvGetCrtc(0x19) & 0xE0) << 3) | (NvGetCrtc(0x13) &
0xFF)) / ScreenWidth;
if (BytesPerPixel == 4)
diff --git a/boot/freeldr/freeldr/include/arch/i386/machxbox.h
b/boot/freeldr/freeldr/include/arch/i386/machxbox.h
index 0ba3033ad06..5b21d8515e9 100644
--- a/boot/freeldr/freeldr/include/arch/i386/machxbox.h
+++ b/boot/freeldr/freeldr/include/arch/i386/machxbox.h
@@ -22,16 +22,7 @@
#include "mm.h"
#endif
-#define NV2A_CONTROL_OFFSET 0xFD000000
-#define NV2A_FB_OFFSET (0x100000 + NV2A_CONTROL_OFFSET)
-#define NV2A_FB_CFG0 (0x200 + NV2A_FB_OFFSET)
-#define NV2A_CRTC_OFFSET (0x600000 + NV2A_CONTROL_OFFSET)
-#define NV2A_CRTC_FRAMEBUFFER_START (0x800 + NV2A_CRTC_OFFSET)
-#define NV2A_CRTC_REGISTER_INDEX (0x13D4 + NV2A_CRTC_OFFSET)
-#define NV2A_CRTC_REGISTER_VALUE (0x13D5 + NV2A_CRTC_OFFSET)
-#define NV2A_RAMDAC_OFFSET (0x680000 + NV2A_CONTROL_OFFSET)
-#define NV2A_RAMDAC_FP_HVALID_END (0x838 + NV2A_RAMDAC_OFFSET)
-#define NV2A_RAMDAC_FP_VVALID_END (0x818 + NV2A_RAMDAC_OFFSET)
+#include <drivers/xbox/xgpu.h>
extern UCHAR BitmapFont8x16[256 * 16];
diff --git a/drivers/base/bootvid/CMakeLists.txt b/drivers/base/bootvid/CMakeLists.txt
index d9f1819478b..6900b31fb33 100644
--- a/drivers/base/bootvid/CMakeLists.txt
+++ b/drivers/base/bootvid/CMakeLists.txt
@@ -8,7 +8,7 @@ if((ARCH STREQUAL "i386") OR (ARCH STREQUAL "amd64"))
i386/pc98/bootvid.c)
elseif(SARCH STREQUAL "xbox")
list(APPEND SOURCE
- i386/xbox/nv2a.h
+ i386/xbox/xbox.h
i386/xbox/bootvid.c)
else()
list(APPEND SOURCE
diff --git a/drivers/base/bootvid/i386/xbox/bootvid.c
b/drivers/base/bootvid/i386/xbox/bootvid.c
index 61e94a44d08..d81dec1dbdc 100644
--- a/drivers/base/bootvid/i386/xbox/bootvid.c
+++ b/drivers/base/bootvid/i386/xbox/bootvid.c
@@ -11,6 +11,8 @@
#include <debug.h>
+#include <drivers/xbox/xgpu.h>
+
/* GLOBALS ********************************************************************/
static ULONG_PTR FrameBufferStart = 0;
@@ -129,7 +131,7 @@ VidInitialize(
return FALSE;
}
- ULONG_PTR FrameBuffer = READ_REGISTER_ULONG((PULONG)(ControlStart +
NV2A_CONTROL_FRAMEBUFFER_ADDRESS_OFFSET));
+ ULONG_PTR FrameBuffer = READ_REGISTER_ULONG((PULONG)(ControlStart +
NV2A_CRTC_FRAMEBUFFER_START));
FrameBufferWidth = READ_REGISTER_ULONG((PULONG)(ControlStart +
NV2A_RAMDAC_FP_HVALID_END)) + 1;
FrameBufferHeight = READ_REGISTER_ULONG((PULONG)(ControlStart +
NV2A_RAMDAC_FP_VVALID_END)) + 1;
diff --git a/drivers/base/bootvid/i386/xbox/nv2a.h
b/drivers/base/bootvid/i386/xbox/xbox.h
similarity index 67%
rename from drivers/base/bootvid/i386/xbox/nv2a.h
rename to drivers/base/bootvid/i386/xbox/xbox.h
index e7581fee646..a189a5b07d7 100644
--- a/drivers/base/bootvid/i386/xbox/nv2a.h
+++ b/drivers/base/bootvid/i386/xbox/xbox.h
@@ -7,20 +7,11 @@
* Copyright 2020 Stanislav Motylkov (x86corez(a)gmail.com)
*/
-#ifndef _BOOTVID_NV2A_H_
-#define _BOOTVID_NV2A_H_
+#ifndef _BOOTVID_XBOX_H_
+#define _BOOTVID_XBOX_H_
#pragma once
-/* FIXME: obtain fb size from firmware somehow (Cromwell reserves high 4 MB of RAM) */
-#define NV2A_VIDEO_MEMORY_SIZE (4 * 1024 * 1024)
-
-#define NV2A_CONTROL_FRAMEBUFFER_ADDRESS_OFFSET 0x600800
-#define NV2A_CRTC_REGISTER_INDEX 0x6013D4
-#define NV2A_CRTC_REGISTER_VALUE 0x6013D5
-#define NV2A_RAMDAC_FP_HVALID_END 0x680838
-#define NV2A_RAMDAC_FP_VVALID_END 0x680818
-
#define BB_OFFSET(x, y) ((y) * SCREEN_WIDTH + (x))
#define FB_OFFSET(x, y) (((PanV + (y)) * FrameBufferWidth + PanH + (x)) *
BytesPerPixel)
@@ -60,4 +51,4 @@ DisplayCharacter(
_In_ ULONG TextColor,
_In_ ULONG BackColor);
-#endif /* _BOOTVID_NV2A_H_ */
+#endif /* _BOOTVID_XBOX_H_ */
diff --git a/drivers/base/bootvid/precomp.h b/drivers/base/bootvid/precomp.h
index bf11f82473b..c3c40a397be 100644
--- a/drivers/base/bootvid/precomp.h
+++ b/drivers/base/bootvid/precomp.h
@@ -10,7 +10,7 @@
#if defined(SARCH_PC98)
#include "i386/pc98/pc98.h"
#elif defined(SARCH_XBOX)
-#include "i386/xbox/nv2a.h"
+#include "i386/xbox/xbox.h"
#else
#include "i386/pc/vga.h"
#include "i386/pc/pc.h"
diff --git a/sdk/include/reactos/drivers/xbox/xgpu.h
b/sdk/include/reactos/drivers/xbox/xgpu.h
new file mode 100644
index 00000000000..45184cdb194
--- /dev/null
+++ b/sdk/include/reactos/drivers/xbox/xgpu.h
@@ -0,0 +1,28 @@
+/*
+ * PROJECT: Original Xbox onboard hardware
+ * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later)
+ * PURPOSE: nVidia NV2A (XGPU) header file
+ * COPYRIGHT: Copyright 2020 Stanislav Motylkov (x86corez(a)gmail.com)
+ */
+
+#ifndef _XGPU_H_
+#define _XGPU_H_
+
+#pragma once
+
+/*
+ * Registers and definitions
+ */
+#define NV2A_VIDEO_MEMORY_SIZE (4 * 1024 * 1024) /* FIXME: obtain fb size from firmware
somehow (Cromwell reserves high 4 MB of RAM) */
+
+#define NV2A_FB_OFFSET 0x100000
+#define NV2A_FB_CFG0 (0x200 + NV2A_FB_OFFSET)
+#define NV2A_CRTC_OFFSET 0x600000
+#define NV2A_CRTC_FRAMEBUFFER_START (0x800 + NV2A_CRTC_OFFSET)
+#define NV2A_CRTC_REGISTER_INDEX (0x13D4 + NV2A_CRTC_OFFSET)
+#define NV2A_CRTC_REGISTER_VALUE (0x13D5 + NV2A_CRTC_OFFSET)
+#define NV2A_RAMDAC_OFFSET 0x680000
+#define NV2A_RAMDAC_FP_HVALID_END (0x838 + NV2A_RAMDAC_OFFSET)
+#define NV2A_RAMDAC_FP_VVALID_END (0x818 + NV2A_RAMDAC_OFFSET)
+
+#endif /* _XGPU_H_ */
diff --git a/win32ss/drivers/miniport/xboxvmp/xboxvmp.c
b/win32ss/drivers/miniport/xboxvmp/xboxvmp.c
index a463a5cec3d..3ead664dda1 100644
--- a/win32ss/drivers/miniport/xboxvmp/xboxvmp.c
+++ b/win32ss/drivers/miniport/xboxvmp/xboxvmp.c
@@ -19,6 +19,8 @@
#include <debug.h>
#include <dpfilter.h>
+#include <drivers/xbox/xgpu.h>
+
/* PUBLIC AND PRIVATE FUNCTIONS ***********************************************/
ULONG
@@ -393,7 +395,7 @@ XboxVmpMapVideoMemory(
StatusBlock->Information = sizeof(VIDEO_MEMORY_INFORMATION);
/* Reuse framebuffer that was set up by firmware */
- FrameBuffer.QuadPart =
READ_REGISTER_ULONG((ULONG_PTR)DeviceExtension->VirtControlStart +
NV2A_CONTROL_FRAMEBUFFER_ADDRESS_OFFSET);
+ FrameBuffer.QuadPart =
READ_REGISTER_ULONG((ULONG_PTR)DeviceExtension->VirtControlStart +
NV2A_CRTC_FRAMEBUFFER_START);
/* Framebuffer address offset value is coming from the GPU within
* memory mapped I/O address space, so we're comparing only low
* 28 bits of the address within actual RAM address space */
@@ -423,7 +425,7 @@ XboxVmpMapVideoMemory(
MapInformation->FrameBufferLength = MapInformation->VideoRamLength;
/* Tell the nVidia controller about the framebuffer */
- WRITE_REGISTER_ULONG((ULONG_PTR)DeviceExtension->VirtControlStart +
NV2A_CONTROL_FRAMEBUFFER_ADDRESS_OFFSET, FrameBuffer.u.LowPart);
+ WRITE_REGISTER_ULONG((ULONG_PTR)DeviceExtension->VirtControlStart +
NV2A_CRTC_FRAMEBUFFER_START, FrameBuffer.u.LowPart);
INFO_(IHVVIDEO, "Mapped 0x%x bytes of phys mem at 0x%lx to virt addr
0x%p\n",
MapInformation->VideoRamLength, FrameBuffer.u.LowPart,
MapInformation->VideoRamBase);
diff --git a/win32ss/drivers/miniport/xboxvmp/xboxvmp.h
b/win32ss/drivers/miniport/xboxvmp/xboxvmp.h
index 6a27df5366b..ca4436e4208 100644
--- a/win32ss/drivers/miniport/xboxvmp/xboxvmp.h
+++ b/win32ss/drivers/miniport/xboxvmp/xboxvmp.h
@@ -23,14 +23,6 @@
#include "ioaccess.h"
#include "video.h"
-#define NV2A_VIDEO_MEMORY_SIZE (4 * 1024 * 1024)
-
-#define NV2A_CONTROL_FRAMEBUFFER_ADDRESS_OFFSET 0x600800
-#define NV2A_CRTC_REGISTER_INDEX 0x6013D4
-#define NV2A_CRTC_REGISTER_VALUE 0x6013D5
-#define NV2A_RAMDAC_FP_HVALID_END 0x680838
-#define NV2A_RAMDAC_FP_VVALID_END 0x680818
-
typedef struct
{
PHYSICAL_ADDRESS PhysControlStart;