From ec6501d115839bede08dbfd06900f2fe6f373d3e Mon Sep 17 00:00:00 2001 From: Mitchell Waite Date: Wed, 3 Dec 2025 00:35:05 -0500 Subject: [PATCH 1/2] add function to query the system RAM size --- libxenon/drivers/xb360/xb360.c | 12 ++++++++++++ libxenon/drivers/xb360/xb360.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/libxenon/drivers/xb360/xb360.c b/libxenon/drivers/xb360/xb360.c index 23bb9017..03329ef1 100644 --- a/libxenon/drivers/xb360/xb360.c +++ b/libxenon/drivers/xb360/xb360.c @@ -660,3 +660,15 @@ unsigned int xenon_get_kv_offset() return ret; return 0; } + +unsigned int xenon_get_ram_size() +{ + unsigned int hostRegisterE104 = 0; + + // 0xE1040000 is the host bridge register where HWINIT stores a little endian uint32 + // representing the amount of memory (in bytes) installed on the system. CB_B looks + // here to determine whether or not to throw panic 0xAF (UNSUPPORTED_RAM_SIZE) + memcpy(&hostRegisterE104, (const void*)(0x80000200E1040000ULL), sizeof(hostRegisterE104)); + + return __builtin_bswap32(hostRegisterE104); +} diff --git a/libxenon/drivers/xb360/xb360.h b/libxenon/drivers/xb360/xb360.h index 16c749a4..8fc09174 100644 --- a/libxenon/drivers/xb360/xb360.h +++ b/libxenon/drivers/xb360/xb360.h @@ -119,6 +119,8 @@ unsigned int xenon_get_DVE(); unsigned int xenon_get_PCIBridgeRevisionID(); unsigned int xenon_get_CPU_PVR(); unsigned int xenon_get_XenosID(); +unsigned int xenon_get_ram_size(); + int xenon_get_console_type(void); int xenon_get_logical_nand_data(void* buf, unsigned int offset, unsigned int len); From d7d1454735e57a78a86f4050a00512f2e87afa43 Mon Sep 17 00:00:00 2001 From: Mitchell Waite Date: Wed, 3 Dec 2025 19:41:52 -0500 Subject: [PATCH 2/2] simplify function --- libxenon/drivers/xb360/xb360.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libxenon/drivers/xb360/xb360.c b/libxenon/drivers/xb360/xb360.c index 03329ef1..a82de1c0 100644 --- a/libxenon/drivers/xb360/xb360.c +++ b/libxenon/drivers/xb360/xb360.c @@ -663,12 +663,8 @@ unsigned int xenon_get_kv_offset() unsigned int xenon_get_ram_size() { - unsigned int hostRegisterE104 = 0; - // 0xE1040000 is the host bridge register where HWINIT stores a little endian uint32 // representing the amount of memory (in bytes) installed on the system. CB_B looks // here to determine whether or not to throw panic 0xAF (UNSUPPORTED_RAM_SIZE) - memcpy(&hostRegisterE104, (const void*)(0x80000200E1040000ULL), sizeof(hostRegisterE104)); - - return __builtin_bswap32(hostRegisterE104); -} + return __builtin_bswap32(*(unsigned int *)0xE1040000); +} \ No newline at end of file