PS2SDK
PS2 Homebrew Libraries
osdsrc.c
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 
10 #include <syscallnr.h>
11 #include <osd_config.h>
12 
13 #include "osd.h"
14 #include "ExecPS2.h"
15 
17 {
18  unsigned int syscall;
19  void *function;
20 };
21 
22 static const struct SyscallPatchData SyscallPatchData[] = {
23  {__NR_SetOsdConfigParam, &SetOsdConfigParam},
24  {__NR_GetOsdConfigParam, &GetOsdConfigParam},
25  {__NR_SetOsdConfigParam2, &SetOsdConfigParam2},
26  {__NR_GetOsdConfigParam2, &GetOsdConfigParam2},
27  {0xFFFFC402, &ExecPS2Patch},
28 };
29 
30 SystemConfiguration_t SystemConfiguration = {.EEGS = 0x40};
31 
32 int _start(int syscall) __attribute__((section(".start")));
33 
34 int _start(int syscall)
35 {
36  unsigned int i;
37  int result;
38 
39  InitSystemConfig(&SystemConfiguration, 0x26);
40 
41  for (i = 0; i < 5; i++) {
42  if (SyscallPatchData[i].syscall == syscall) {
43  if (syscall == 0xFFFFC402) {
44  result = ((unsigned int)SyscallPatchData[i].function >> 2 & 0x03FFFFFF) | 0x0C000000; // Creates a JAL instruction to the function.
45  } else
46  result = (unsigned int)SyscallPatchData[i].function;
47 
48  return result;
49  }
50  }
51 
52  return 0;
53 }
SystemConfiguration_t
Definition: osd.h:10
__attribute__
typedef __attribute__
Definition: tlbfunc.c:60
SyscallPatchData
Definition: osdsrc.c:16
syscallnr.h
osd_config.h