PS2SDK
PS2 Homebrew Libraries
libosd.c
Go to the documentation of this file.
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Licenced under Academic Free License version 2.0
7 # Review ps2sdk README & LICENSE files for further details.
8 */
9 
19 #include <kernel.h>
20 #include <syscallnr.h>
21 #include <osd_config.h>
22 
23 extern unsigned char osdsrc[];
24 extern unsigned int size_osdsrc;
25 
26 struct SyscallData
27 {
28  int syscall_num;
29  void *function;
30 };
31 
32 static struct SyscallData SyscallPatchEntries[] = {
33  {0x5A,
34  &kCopy},
35  {0x5B,
36  (void *)0x80074000},
37  { // This uses the Setup (aka "SetSyscall") syscall to patch the kernel. The address is relative to the start of the syscall table, and is in units of 32-bit pointers (4 bytes).
38  0xFFFFC402, // 0x80011F80+(-15358*4)=0x80002F88, where 0x80011F80 is the start of the syscall table.
39  NULL},
40 };
41 
42 __attribute__((weak))
43 void InitExecPS2(void)
44 {
45  if (PatchIsNeeded()) {
46  unsigned int i;
47 
48  setup(SyscallPatchEntries[0].syscall_num, SyscallPatchEntries[0].function);
49  Copy((unsigned int *)0x80074000, (unsigned int *)osdsrc, size_osdsrc);
50 
51  FlushCache(0);
52  FlushCache(2);
53  setup(SyscallPatchEntries[1].syscall_num, SyscallPatchEntries[1].function);
54 
55  for (i = 2; i < 3; i++) {
56  setup(SyscallPatchEntries[i].syscall_num, GetEntryAddress(SyscallPatchEntries[i].syscall_num));
57  }
58  }
59 }
kernel.h
SyscallData
Definition: alarm.c:22
syscallnr.h
__attribute__
Definition: gif_registers.h:38
osd_config.h