PS2SDK
PS2 Homebrew Libraries
libosd_full.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 
25 #include <kernel.h>
26 #include <syscallnr.h>
27 #include <osd_config.h>
28 
29 extern unsigned char osdsrc[];
30 extern unsigned int size_osdsrc;
31 
32 struct SyscallData
33 {
34  int syscall_num;
35  void *function;
36 };
37 
38 static struct SyscallData SyscallPatchEntries[] = {
39  {0x5A,
40  &kCopy},
41  {0x5B,
42  (void *)0x80074000},
43  { // 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).
44  0xFFFFC402, // 0x80011F80+(-15358*4)=0x80002F88, where 0x80011F80 is the start of the syscall table.
45  NULL},
46  {__NR_SetOsdConfigParam,
47  NULL},
48  {__NR_GetOsdConfigParam,
49  NULL},
50  {__NR_SetOsdConfigParam2,
51  NULL},
52  {__NR_GetOsdConfigParam2,
53  NULL},
54 };
55 
56 void InitOsd(void)
57 {
58  if (PatchIsNeeded()) {
59  unsigned int i;
60 
61  setup(SyscallPatchEntries[0].syscall_num, SyscallPatchEntries[0].function);
62  Copy((unsigned int *)0x80074000, (unsigned int *)osdsrc, size_osdsrc);
63 
64  FlushCache(0);
65  FlushCache(2);
66  setup(SyscallPatchEntries[1].syscall_num, SyscallPatchEntries[1].function);
67 
68  for (i = 2; i < 7; i++) {
69  setup(SyscallPatchEntries[i].syscall_num, GetEntryAddress(SyscallPatchEntries[i].syscall_num));
70  }
71  }
72 }
kernel.h
SyscallData
Definition: alarm.c:22
syscallnr.h
osd_config.h