25 |
|
|
26 |
|
|
27 |
|
/* |
28 |
< |
* void *get_toc(void) - Get TOC pointer (small data pointer r13 under Linux) |
28 |
> |
* void *get_sp(void) - Get stack pointer |
29 |
|
*/ |
30 |
|
|
31 |
< |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_toc) |
32 |
< |
C_SYMBOL_NAME(get_toc): |
33 |
< |
mr r3,r13 |
31 |
> |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_sp) |
32 |
> |
C_SYMBOL_NAME(get_sp): |
33 |
> |
mr r3,r1 |
34 |
|
blr |
35 |
|
|
36 |
|
|
37 |
|
/* |
38 |
< |
* void *get_sp(void) - Get stack pointer |
38 |
> |
* void *get_r2(void) - Get r2 |
39 |
|
*/ |
40 |
|
|
41 |
< |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_sp) |
42 |
< |
C_SYMBOL_NAME(get_sp): |
43 |
< |
mr r3,r1 |
41 |
> |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_r2) |
42 |
> |
C_SYMBOL_NAME(get_r2): |
43 |
> |
mr r3,r2 |
44 |
|
blr |
45 |
|
|
46 |
|
|
47 |
|
/* |
48 |
< |
* void set_r2(uint32 val {r3}) - Set r2 |
48 |
> |
* void set_r2(void *val {r3}) - Set r2 |
49 |
|
*/ |
50 |
|
|
51 |
|
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(set_r2) |
55 |
|
|
56 |
|
|
57 |
|
/* |
58 |
+ |
* void *get_r13(void) - Get r13 (small data pointer under Linux) |
59 |
+ |
*/ |
60 |
+ |
|
61 |
+ |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(get_r13) |
62 |
+ |
C_SYMBOL_NAME(get_r13): |
63 |
+ |
mr r3,r13 |
64 |
+ |
blr |
65 |
+ |
|
66 |
+ |
/* |
67 |
+ |
* void set_r13(void *val {r3}) - Set r13 (small data pointer under Linux) |
68 |
+ |
*/ |
69 |
+ |
|
70 |
+ |
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(set_r13) |
71 |
+ |
C_SYMBOL_NAME(set_r13): |
72 |
+ |
mr r13,r3 |
73 |
+ |
blr |
74 |
+ |
|
75 |
+ |
|
76 |
+ |
/* |
77 |
|
* void flush_icache_range(void *start {r3}, void *end {r3}) - Flush D and I cache |
78 |
|
*/ |
79 |
|
|
244 |
|
|
245 |
|
// Restore PowerPC registers |
246 |
|
lwz r1,XLM_EMUL_RETURN_STACK(0) |
247 |
+ |
RESTORE_SYSTEM_R2 |
248 |
|
lmw r13,20(r1) |
249 |
|
lfd f14,20+19*4+0*8(r1) |
250 |
|
lfd f15,20+19*4+1*8(r1) |
381 |
|
stw r0,16(r1) |
382 |
|
stw r2,12(r1) |
383 |
|
stwu r1,-(24+16*4+15*8)(r1) |
384 |
+ |
RESTORE_SYSTEM_R2 |
385 |
|
|
386 |
|
// Save 68k registers (M68kRegisters) |
387 |
|
stw r8,24+0*4(r1) // d[0]..d[7] |
418 |
|
stfd f0,24+16*4+14*8(r1) |
419 |
|
|
420 |
|
// Execute native routine |
421 |
< |
lwz r13,XLM_TOC(0) |
421 |
> |
RESTORE_SYSTEM_R2 |
422 |
> |
RESTORE_SYSTEM_R13 |
423 |
|
addi r3,r1,24 |
424 |
|
mr r4,r24 |
425 |
|
bl C_SYMBOL_NAME(EmulOp) |
595 |
|
ASM_MACRO_END |
596 |
|
|
597 |
|
ASM_MACRO_START epilog |
598 |
< |
lwz r13,XLM_TOC(0) |
598 |
> |
RESTORE_SYSTEM_R2 |
599 |
> |
RESTORE_SYSTEM_R13 |
600 |
|
lwz r0,64+4(r1) |
601 |
|
mtlr r0 |
602 |
|
addi r1,r1,64 |
724 |
|
lwz r2,XLM_RES_LIB_TOC(0) |
725 |
|
mtctr r0 |
726 |
|
bctrl |
727 |
+ |
RESTORE_SYSTEM_R2 |
728 |
|
stw r3,56+8(r1) // Save handle |
729 |
|
|
730 |
|
// Call CheckLoad |
756 |
|
lwz r2,XLM_RES_LIB_TOC(0) |
757 |
|
mtctr r0 |
758 |
|
bctrl |
759 |
+ |
RESTORE_SYSTEM_R2 |
760 |
|
stw r3,56+8(r1) // Save handle |
761 |
|
|
762 |
|
// Call CheckLoad |
788 |
|
lwz r2,XLM_RES_LIB_TOC(0) |
789 |
|
mtctr r0 |
790 |
|
bctrl |
791 |
+ |
RESTORE_SYSTEM_R2 |
792 |
|
stw r3,56+8(r1) // Save handle |
793 |
|
|
794 |
|
// Call CheckLoad |
820 |
|
lwz r2,XLM_RES_LIB_TOC(0) |
821 |
|
mtctr r0 |
822 |
|
bctrl |
823 |
+ |
RESTORE_SYSTEM_R2 |
824 |
|
stw r3,56+8(r1) // Save handle |
825 |
|
|
826 |
|
// Call CheckLoad |
852 |
|
lwz r2,XLM_RES_LIB_TOC(0) |
853 |
|
mtctr r0 |
854 |
|
bctrl |
855 |
+ |
RESTORE_SYSTEM_R2 |
856 |
|
stw r3,56+8(r1) // Save handle |
857 |
|
|
858 |
|
// Call CheckLoad |
916 |
|
// Enter nanokernel |
917 |
|
mtlr r3 |
918 |
|
blr |
919 |
+ |
|
920 |
+ |
|
921 |
+ |
/* |
922 |
+ |
* Glue for glibc with TLS support which clobbers r2 |
923 |
+ |
* |
924 |
+ |
* The following is derived from dietlibc and only provides |
925 |
+ |
* pass-through to kernel syscalls. You also lose asynchronous |
926 |
+ |
* cancellation support. |
927 |
+ |
*/ |
928 |
+ |
|
929 |
+ |
#if defined(__linux__) |
930 |
+ |
#define __NR_getpid 20 |
931 |
+ |
#define __NR__newselect 142 |
932 |
+ |
|
933 |
+ |
#define syscall_weak(name,wsym,sym) \ |
934 |
+ |
.text; \ |
935 |
+ |
.type wsym,@function; \ |
936 |
+ |
.weak wsym; \ |
937 |
+ |
wsym: ; \ |
938 |
+ |
.type sym,@function; \ |
939 |
+ |
.global sym; \ |
940 |
+ |
sym: \ |
941 |
+ |
li 0,__NR_##name; \ |
942 |
+ |
b __unified_syscall |
943 |
+ |
|
944 |
+ |
#define syscall(name,sym) \ |
945 |
+ |
.text; \ |
946 |
+ |
.type sym,@function; \ |
947 |
+ |
.global sym; \ |
948 |
+ |
sym: \ |
949 |
+ |
li 0,__NR_##name; \ |
950 |
+ |
b __unified_syscall |
951 |
+ |
|
952 |
+ |
|
953 |
+ |
.type __unified_syscall,@function |
954 |
+ |
__unified_syscall: |
955 |
+ |
sc |
956 |
+ |
bnslr+ |
957 |
+ |
stwu 1,-16(1) |
958 |
+ |
mflr 0 |
959 |
+ |
stw 0,20(1) |
960 |
+ |
stw 3,12(1) |
961 |
+ |
bl __errno_location |
962 |
+ |
lwz 0,12(1) |
963 |
+ |
stw 0,0(3) |
964 |
+ |
lwz 0,20(1) |
965 |
+ |
mtlr 0 |
966 |
+ |
addi 1,1,16 |
967 |
+ |
blr |
968 |
+ |
|
969 |
+ |
/* name weak symbol symbol */ |
970 |
+ |
syscall( getpid, getpid) |
971 |
+ |
syscall_weak( _newselect, select, __select) |
972 |
+ |
#endif |