2 Copyright © 2008-2014, The AROS Development Team. All rights reserved.
6 #include <asm/mpc5200b.h>
7 #include <aros/kernel.h>
8 #include <utility/tagitem.h>
9 #include "kernel_intern.h"
12 extern char * __text_start
;
13 extern char * __text_end
;
14 extern struct TagItem
*BootMsg
;
16 void __attribute__((noreturn
)) syscall_handler(regs_t
*ctx
, uint8_t exception
, void *self
)
18 struct KernelBase
*KernelBase
= getKernelBase();
21 //D(bug("[KRN] SysCall handler. context @ %p SC=%d\n", ctx, ctx->gpr[3]));
23 if ((char*)ctx
->srr0
< &__text_start
|| (char*)ctx
->srr0
>= &__text_end
)
25 D(bug("[KRN] ERROR ERROR! SysCall issued directly outside kernel.resource!!!!!\n"));
26 core_LeaveInterrupt(ctx
);
40 ctx
->gpr
[3] = ctx
->srr1
;
45 if (ctx
->srr1
& MSR_PR
)
53 // struct ExecBase *SysBase = getSysBase();
55 // core_Cause(SysBase);
73 ctx
->gpr
[3] = core_Rtas(ctx
->gpr
[4], ctx
->gpr
[5], ctx
->gpr
[6]);
78 char *start
= (char*)((IPTR
)ctx
->gpr
[4] & 0xffffffe0);
79 char *end
= (char*)(((IPTR
)ctx
->gpr
[4] + ctx
->gpr
[5] + 31) & 0xffffffe0);
82 for (ptr
= start
; ptr
< end
; ptr
+=32)
84 asm volatile("dcbi 0,%0"::"r"(ptr
));
92 uint64_t newtbu
= mftbu() + 132000000/4;
93 D(bug("[KRN] REBOOT..."));
94 while(newtbu
> mftbu());
96 newtbu
= mftbu() + 132000000/4;
97 while(newtbu
> mftbu());
99 newtbu
= mftbu() + 132000000/4;
100 while(newtbu
> mftbu());
102 newtbu
= mftbu() + 132000000/4;
103 while(newtbu
> mftbu());
106 void (*restart
)(struct TagItem
*) = krnGetTagData(KRN_KernelBase
, NULL
, BootMsg
);
113 core_ExitInterrupt(ctx
);
115 core_LeaveInterrupt(ctx
);
118 static void __attribute__((used
)) __rtas_entry_template()
120 asm volatile(".globl core_Rtas; .type core_Rtas,@function\n"
121 "core_Rtas: stwu %r1, -64(%r1)\n" /* Create proper stack frame */
122 " mflr %r0\n" /* Store the link pointer */
124 " stw %r1,8(%r1)\n" /* Store the stack pointer for virtual space */
125 " stw %r3,12(%r1)\n" /* Store the rtas call structure */
126 " stw %r4,16(%r1)\n" /* Store the rtas base */
127 " stw %r5,20(%r1)\n" /* Store the entry address */
130 " lis %r0,virt2phys@ha\n" /* VirtualToPhysical function */
131 " ori %r0, %r0, virt2phys@l\n"
134 " lis %r3,1f@ha\n" /* Get the return point from rtas */
135 " ori %r3, %r3, 1f@l\n"
138 " mr %r3, %r1\n" /* Convert the stack to physical address */
142 " mtsprg2 %r3\n" /* And store it in sprg2 */
150 " rlwinm %r0,%r0,0,28,25\n"
155 " mfsprg2 %r5\n" /* We're back. Get the stack frame */
156 " lwz %r4,24(%r5)\n" /* Old msr */
158 " lwz %r4,68(%r5)\n" /* Old link pointer */
160 " addi %r1, %r1, 64\n"
161 " sync; isync; rfi\n"