sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
rom0_info.c
Go to the documentation of this file.
1
/*
2
# _____ ___ ____ ___ ____
3
# ____| | ____| | | |____|
4
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5
#-----------------------------------------------------------------------
6
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7
# Licenced under Academic Free License version 2.0
8
# Review ps2sdk README & LICENSE files for further details.
9
*/
10
16
17
#include <
rom0_info.h
>
18
19
#include <
iopheap.h
>
20
#include <
string.h
>
21
#include <sifrpc.h>
22
#include <
kernel.h
>
23
#include <
syscallnr.h
>
24
25
struct
rom0_info_data
26
{
28
char
m_romver
[14];
29
};
30
31
extern
struct
rom0_info_data
g_rom0_info_data;
32
33
struct
rom0_info_data
g_rom0_info_data;
34
35
void
SetupRomInfo(
void
)
36
{
37
void
*iop_addr;
38
SifRpcReceiveData_t rdata;
39
u8 buf[64]
__attribute__
((__aligned__(64)));
40
41
/* ROMVER needs to be read from the IOP due to PPCIOP region patching. */
42
/* only read in the romname the first time */
43
if
(g_rom0_info_data.m_romver[0])
44
return
;
45
46
/* SYSMEM allocates in units of 256. */
47
if
(!(iop_addr = SifAllocIopHeap(256)))
48
return
;
49
50
/* ROMVER is known to be 16 bytes. */
51
if
(SifLoadIopHeap(
"rom:ROMVER"
, iop_addr) < 0)
52
{
53
SifFreeIopHeap(iop_addr);
54
return
;
55
}
56
SyncDCache(buf, buf +
sizeof
(buf));
57
if
(sceSifGetOtherData(&rdata, iop_addr, buf,
sizeof
(buf), 0) < 0)
58
{
59
SifFreeIopHeap(iop_addr);
60
return
;
61
}
62
memcpy(g_rom0_info_data.m_romver, UNCACHED_SEG(buf),
sizeof
(g_rom0_info_data.m_romver));
63
64
SifFreeIopHeap(iop_addr);
65
}
66
67
char
*
GetRomName
(
char
*romname)
68
{
69
SetupRomInfo();
70
/* Explicitly copy 14 bytes to the buffer, without NULL terminator */
71
memcpy(romname, g_rom0_info_data.m_romver,
sizeof
(g_rom0_info_data.m_romver));
72
return
romname;
73
}
74
75
int
IsDESRMachine
(
void
)
76
{
77
/* Use the existence of ExecPSX syscall as the determination. */
78
return
GetSyscallHandler
(__NR_ExecPSX) ? 1 : 0;
79
}
80
81
int
IsT10K
(
void
)
82
{
83
SetupRomInfo();
84
return
(g_rom0_info_data.m_romver[4] ==
'T'
&& g_rom0_info_data.m_romver[5] !=
'Z'
) ? 1 : 0;
85
}
iopheap.h
kernel.h
GetSyscallHandler
void * GetSyscallHandler(int syscall_no)
Definition
getkernel.c:39
rom0_info.h
GetRomName
char * GetRomName(char *romname)
Definition
rom0_info.c:67
IsDESRMachine
int IsDESRMachine(void)
Definition
rom0_info.c:75
IsT10K
int IsT10K(void)
Definition
rom0_info.c:81
string.h
__attribute__
Definition
gif_registers.h:40
rom0_info_data
Definition
rom0_info.c:26
rom0_info_data::m_romver
char m_romver[14]
Definition
rom0_info.c:28
syscallnr.h
core
kernel
src
rom0_info.c
Generated by
1.18.0