ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
exit.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 
15 #include "kernel.h"
16 #include "string.h"
17 
18 extern char **_kExecArg;
19 const char *SetArg(const char *filename, int argc, char *argv[]);
20 
21 #ifdef F__exit_internals
22 char **_kExecArg;
23 #endif
24 
25 #ifdef F_SetArg
26 struct SyscallData{
27  int syscall;
28  void *function;
29 };
30 
31 struct SyscallData SysEntry = {
32  0x5A,
33  &kCopyBytes
34 };
35 
36 #define SETARG_MAX_ARGS 15
37 
38 const char *SetArg(const char *filename, int argc, char *argv[])
39 {
40  const char *filenameOut;
41  char *ptr;
42  int len, i;
43 
44  ptr = (char*)(_kExecArg + 16);
45  filenameOut = ptr;
47  argc = (argc > SETARG_MAX_ARGS) ? SETARG_MAX_ARGS : argc;
48  Copy(&_kExecArg[0], &ptr, 4);
49  len = strlen(filename) + 1;
50  Copy(ptr, filename, len);
51  ptr += len;
52 
53  for(i = 0; i < argc; i++)
54  {
55  Copy(&_kExecArg[1+i], &ptr, 4);
56  len = strlen(argv[i]) + 1;
57  Copy(ptr, argv[i], len);
58  ptr += len;
59  }
60 
61  return filenameOut;
62 }
63 #endif
64 
65 #ifdef F_Exit
66 void Exit(s32 exit_code)
67 {
69  _Exit(exit_code);
70 }
71 #endif
72 
73 #ifdef F_ExecPS2
74 s32 ExecPS2(void *entry, void *gp, int num_args, char *args[])
75 {
76  SetArg("", num_args, args);
78  return _ExecPS2(entry, gp, num_args, &_kExecArg[1]);
79 }
80 #endif
81 
82 #ifdef F_LoadExecPS2
83 void LoadExecPS2(const char *filename, s32 num_args, char *args[])
84 {
85  const char *pFilename;
86 
87  pFilename = SetArg(filename, num_args, args);
89  _LoadExecPS2(pFilename, num_args, &_kExecArg[1]);
90 }
91 #endif
92 
93 #ifdef F_ExecOSD
94 void ExecOSD(int num_args, char *args[])
95 {
96  SetArg("", num_args, args);
98  _ExecOSD(num_args, &_kExecArg[1]);
99 }
100 #endif
static const struct SyscallData SysEntry[]
Definition: alarm.c:26
#define gp
Definition: as_reg_compat.h:84
char ** _kExecArg
Definition: tlbsrc.c:27
const char * SetArg(const char *filename, int argc, char *argv[])
void TerminateLibrary(void)
void Exit(s32 exit_code)
int Copy(void *dest, const void *src, int size)
void _Exit(s32 exit_code)
void _LoadExecPS2(const char *filename, s32 num_args, char *args[])
s32 _ExecPS2(void *entry, void *gp, int num_args, char *args[])
s32 ExecPS2(void *entry, void *gp, int num_args, char *args[])
void ExecOSD(int num_args, char *args[])
void setup(int syscall_num, void *handler)
int kCopyBytes(void *dest, const void *src, int size)
void LoadExecPS2(const char *filename, s32 num_args, char *args[])
void _ExecOSD(int num_args, char *args[])
int syscall
Definition: alarm.c:22
void * function
Definition: alarm.c:23
signed int s32
Definition: tamtypes.h:58