mirror of
https://github.com/reactos/reactos.git
synced 2025-04-05 13:11:22 +00:00
[FREELDR] Xbox memory management improvements (#1961)
- Reuse the framebuffer address that was set up by the firmware. - Get rid of XboxMemReserveMemory() and use ReserveMemory() instead. CORE-16216
This commit is contained in:
parent
3fee5d0e1c
commit
034820ca55
3 changed files with 29 additions and 35 deletions
|
@ -26,6 +26,8 @@ DBG_DEFAULT_CHANNEL(MEMORY);
|
|||
|
||||
static ULONG InstalledMemoryMb = 0;
|
||||
static ULONG AvailableMemoryMb = 0;
|
||||
extern PVOID FrameBuffer;
|
||||
extern ULONG FrameBufferSize;
|
||||
|
||||
#define TEST_SIZE 0x200
|
||||
#define TEST_PATTERN1 0xAA
|
||||
|
@ -38,6 +40,14 @@ SetMemory(
|
|||
SIZE_T Size,
|
||||
TYPE_OF_MEMORY MemoryType);
|
||||
|
||||
extern VOID
|
||||
ReserveMemory(
|
||||
PFREELDR_MEMORY_DESCRIPTOR MemoryMap,
|
||||
ULONG_PTR BaseAddress,
|
||||
SIZE_T Size,
|
||||
TYPE_OF_MEMORY MemoryType,
|
||||
PCHAR Usage);
|
||||
|
||||
extern ULONG
|
||||
PcMemFinalizeMemoryMap(
|
||||
PFREELDR_MEMORY_DESCRIPTOR MemoryMap);
|
||||
|
@ -85,7 +95,6 @@ XboxMemInit(VOID)
|
|||
WRITE_PORT_ULONG((ULONG*) 0xcf8, CONFIG_CMD(0, 0, 0x84));
|
||||
WRITE_PORT_ULONG((ULONG*) 0xcfc, InstalledMemoryMb * 1024 * 1024 - 1);
|
||||
|
||||
/* 4 MB video framebuffer is reserved later using XboxMemReserveMemory() */
|
||||
AvailableMemoryMb = InstalledMemoryMb;
|
||||
}
|
||||
|
||||
|
@ -105,37 +114,18 @@ XboxMemGetMemoryMap(ULONG *MemoryMapSize)
|
|||
AvailableMemoryMb * 1024 * 1024,
|
||||
LoaderFree);
|
||||
|
||||
/* Video memory */
|
||||
SetMemory(XboxMemoryMap,
|
||||
AvailableMemoryMb * 1024 * 1024,
|
||||
(InstalledMemoryMb - AvailableMemoryMb) * 1024 * 1024,
|
||||
LoaderFirmwarePermanent);
|
||||
if (FrameBufferSize != 0)
|
||||
{
|
||||
/* Video memory */
|
||||
ReserveMemory(XboxMemoryMap,
|
||||
(ULONG_PTR)FrameBuffer,
|
||||
FrameBufferSize,
|
||||
LoaderFirmwarePermanent,
|
||||
"Video memory");
|
||||
}
|
||||
|
||||
*MemoryMapSize = PcMemFinalizeMemoryMap(XboxMemoryMap);
|
||||
return XboxMemoryMap;
|
||||
}
|
||||
|
||||
PVOID
|
||||
XboxMemReserveMemory(ULONG MbToReserve)
|
||||
{
|
||||
/* This function is used to reserve video framebuffer in XboxVideoInit() */
|
||||
|
||||
if (InstalledMemoryMb == 0)
|
||||
{
|
||||
/* Hmm, seems we're not initialized yet */
|
||||
XboxMemInit();
|
||||
}
|
||||
|
||||
if (MbToReserve > AvailableMemoryMb)
|
||||
{
|
||||
/* Can't satisfy the request */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AvailableMemoryMb -= MbToReserve;
|
||||
|
||||
/* Top of available memory points to the space just reserved */
|
||||
return (PVOID)(AvailableMemoryMb * 1024 * 1024);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
|
||||
DBG_DEFAULT_CHANNEL(UI);
|
||||
|
||||
static PVOID FrameBuffer;
|
||||
PVOID FrameBuffer;
|
||||
ULONG FrameBufferSize;
|
||||
static ULONG ScreenWidth;
|
||||
static ULONG ScreenHeight;
|
||||
static ULONG BytesPerPixel;
|
||||
|
@ -126,8 +127,15 @@ XboxVideoInit(VOID)
|
|||
{
|
||||
ULONG AvMode;
|
||||
|
||||
FrameBuffer = (PVOID)((ULONG) XboxMemReserveMemory(FB_SIZE_MB) | 0xf0000000);
|
||||
/* Reuse framebuffer that was set up by firmware */
|
||||
FrameBuffer = (PVOID)*((PULONG) 0xfd600800);
|
||||
/* Verify that framebuffer address is page-aligned */
|
||||
ASSERT((ULONG_PTR)FrameBuffer % PAGE_SIZE == 0);
|
||||
|
||||
/* FIXME: obtain fb size from firmware somehow (Cromwell reserves high 4 MB of RAM) */
|
||||
FrameBufferSize = 4 * 1024 * 1024;
|
||||
|
||||
/* FIXME: don't use SMBus, obtain current video resolution directly from NV2A */
|
||||
if (I2CTransmitByteGetReturn(0x10, 0x04, &AvMode))
|
||||
{
|
||||
if (1 == AvMode) /* HDTV */
|
||||
|
@ -157,9 +165,6 @@ XboxVideoInit(VOID)
|
|||
Delta = (ScreenWidth * BytesPerPixel + 3) & ~ 0x3;
|
||||
|
||||
XboxVideoClearScreenColor(MAKE_COLOR(0, 0, 0), TRUE);
|
||||
|
||||
/* Tell the nVidia controller about the framebuffer */
|
||||
*((PULONG) 0xfd600800) = (ULONG) FrameBuffer;
|
||||
}
|
||||
|
||||
VIDEODISPLAYMODE
|
||||
|
|
|
@ -63,7 +63,6 @@ VOID XboxVideoPrepareForReactOS(VOID);
|
|||
VOID XboxPrepareForReactOS(VOID);
|
||||
|
||||
VOID XboxMemInit(VOID);
|
||||
PVOID XboxMemReserveMemory(ULONG MbToReserve);
|
||||
PFREELDR_MEMORY_DESCRIPTOR XboxMemGetMemoryMap(ULONG *MemoryMapSize);
|
||||
|
||||
BOOLEAN XboxDiskReadLogicalSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer);
|
||||
|
|
Loading…
Reference in a new issue