mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
[XBOX] Move NV2A XGPU definitions into header file
TODO: helper functions should be also moved. CORE-16216
This commit is contained in:
parent
f420f2e5df
commit
2a77e359e4
10 changed files with 50 additions and 42 deletions
|
@ -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));
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -7,20 +7,11 @@
|
|||
* Copyright 2020 Stanislav Motylkov (x86corez@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_ */
|
|
@ -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"
|
||||
|
|
28
sdk/include/reactos/drivers/xbox/xgpu.h
Normal file
28
sdk/include/reactos/drivers/xbox/xgpu.h
Normal file
|
@ -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@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_ */
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue