4 * Created on: Aug 28, 2008
8 #include <asm/mpc5200b.h>
9 #include <aros/kernel.h>
10 #include <utility/tagitem.h>
11 #include "kernel_intern.h"
14 extern char * __text_start
;
15 extern char * __text_end
;
16 extern struct TagItem
*BootMsg
;
18 void __attribute__((noreturn
)) syscall_handler(regs_t
*ctx
, uint8_t exception
, void *self
)
20 struct KernelBase
*KernelBase
= getKernelBase();
23 //D(bug("[KRN] SysCall handler. context @ %p SC=%d\n", ctx, ctx->gpr[3]));
25 if ((char*)ctx
->srr0
< &__text_start
|| (char*)ctx
->srr0
>= &__text_end
)
27 D(bug("[KRN] ERROR ERROR! SysCall issued directly outside kernel.resource!!!!!\n"));
28 core_LeaveInterrupt(ctx
);
42 ctx
->gpr
[3] = ctx
->srr1
;
47 if (ctx
->srr1
& MSR_PR
)
55 // struct ExecBase *SysBase = getSysBase();
57 // core_Cause(SysBase);
75 ctx
->gpr
[3] = core_Rtas(ctx
->gpr
[4], ctx
->gpr
[5], ctx
->gpr
[6]);
80 char *start
= (char*)((IPTR
)ctx
->gpr
[4] & 0xffffffe0);
81 char *end
= (char*)(((IPTR
)ctx
->gpr
[4] + ctx
->gpr
[5] + 31) & 0xffffffe0);
84 for (ptr
= start
; ptr
< end
; ptr
+=32)
86 asm volatile("dcbi 0,%0"::"r"(ptr
));
94 uint64_t newtbu
= mftbu() + 132000000/4;
95 D(bug("[KRN] REBOOT..."));
96 while(newtbu
> mftbu());
98 newtbu
= mftbu() + 132000000/4;
99 while(newtbu
> mftbu());
101 newtbu
= mftbu() + 132000000/4;
102 while(newtbu
> mftbu());
104 newtbu
= mftbu() + 132000000/4;
105 while(newtbu
> mftbu());
108 void (*restart
)(struct TagItem
*) = krnGetTagData(KRN_KernelBase
, NULL
, BootMsg
);
115 core_ExitInterrupt(ctx
);
117 core_LeaveInterrupt(ctx
);
120 static void __attribute__((used
)) __rtas_entry_template()
122 asm volatile(".globl core_Rtas; .type core_Rtas,@function\n"
123 "core_Rtas: stwu %r1, -64(%r1)\n" /* Create proper stack frame */
124 " mflr %r0\n" /* Store the link pointer */
126 " stw %r1,8(%r1)\n" /* Store the stack pointer for virtual space */
127 " stw %r3,12(%r1)\n" /* Store the rtas call structure */
128 " stw %r4,16(%r1)\n" /* Store the rtas base */
129 " stw %r5,20(%r1)\n" /* Store the entry address */
132 " lis %r0,virt2phys@ha\n" /* VirtualToPhysical function */
133 " ori %r0, %r0, virt2phys@l\n"
136 " lis %r3,1f@ha\n" /* Get the return point from rtas */
137 " ori %r3, %r3, 1f@l\n"
140 " mr %r3, %r1\n" /* Convert the stack to physical address */
144 " mtsprg2 %r3\n" /* And store it in sprg2 */
152 " rlwinm %r0,%r0,0,28,25\n"
157 " mfsprg2 %r5\n" /* We're back. Get the stack frame */
158 " lwz %r4,24(%r5)\n" /* Old msr */
160 " lwz %r4,68(%r5)\n" /* Old link pointer */
162 " addi %r1, %r1, 64\n"
163 " sync; isync; rfi\n"