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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#include <cstdlib>
#include <dolphin/dolphin.h>
#include <dolphin/os.h>
#include "__os.h"
__declspec(section ".ctors") extern void (* _ctors[])();
__declspec(section ".dtors") extern void (* _dtors[])();
static void __init_cpp(void);
static void __fini_cpp(void);
__declspec(section ".init") asm void __init_hardware(void)
{ // clang-format off
nofralloc
mfmsr r0
ori r0,r0,MSR_FP
mtmsr r0
mflr r31
bl __OSPSInit
bl __OSFPRInit
bl __OSCacheInit
mtlr r31
blr
}
__declspec(section ".init") asm void __flush_cache(void *address, unsigned int size)
{ // clang-format off
nofralloc
lis r5, 0xffff
ori r5, r5, 0xfff1
and r5, r5, r3
subf r3, r5, r3
add r4, r4, r3
rept:
dcbst 0,r5
sync
icbi 0,r5
addic r5,r5,0x8
subic. r4,r4,0x8
bge rept
isync
blr
}
void __init_user(void) {
__init_cpp();
}
static void __init_cpp(void) {
void (* * constructor)();
/*
* call static initializers
*/
for (constructor = _ctors; *constructor; constructor++) {
(*constructor)();
}
}
static void __fini_cpp(void) {
void (* * destructor)();
/*
* call destructors
*/
for (destructor = _dtors; *destructor; destructor++) {
(*destructor)();
}
}
DECL_WEAK
void abort(void) {
_ExitProcess();
}
DECL_WEAK
void exit(int status) {
__fini_cpp();
_ExitProcess();
}
void _ExitProcess(void) {
PPCHalt();
}
|