blob: 2c7790d73287ae7818f4585534630c3a51ae857b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#include <psx.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
extern int __bss_start[];
extern int __bss_end[];
extern void *__ctor_list;
extern void *__ctor_end;
// Function to call static constructors (for C++, etc.)
static void call_ctors(void)
{
dprintf("Calling static constructors...\n");
void **p = &__ctor_end - 1;
for(--p; *p != NULL && (int)*p != -1 && p > &__ctor_list; p--)
{
dprintf("Constructor address = %x\n", (unsigned int)*p);
(*(void (**)())p)();
}
dprintf("Finished calling static constructors\n");
}
void psxsdk_setup()
{
printf("Initializing PSXSDK... \n");
dprintf("Clearing BSS space...\n");
// Clear BSS space
memset(__bss_start, 0, (ptrdiff_t)__bss_end - (ptrdiff_t)__bss_start);
dprintf("BSS space cleared.\n");
// Call static constructors
call_ctors();
}
|