Fixed a few warnings.
[tangerine.git] / arch / ppc-sam440 / kernel / syscall.c
blob789aa250c64f044a7a5effc11ee9960231d5f66a
1 #include <asm/amcc440.h>
2 #include "kernel_intern.h"
3 #include "syscall.h"
5 extern char * __text_start;
6 extern char * __text_end;
8 void __attribute__((noreturn)) syscall_handler(regs_t *ctx, uint8_t exception, void *self)
10 struct KernelBase *KernelBase = getKernelBase();
12 // D(bug("[KRN] SysCall handler. context @ %p SC=%d\n", ctx, ctx->gpr[3]));
14 if ((char*)ctx->srr0 < &__text_start || (char*)ctx->srr0 >= &__text_end)
16 D(bug("[KRN] ERROR ERROR! SysCall issued directly outside kernel.resource!!!!!\n"));
17 core_LeaveInterrupt(ctx);
20 switch (ctx->gpr[3])
22 case SC_CLI:
23 ctx->srr1 &= ~MSR_EE;
24 break;
26 case SC_STI:
27 ctx->srr1 |= MSR_EE;
28 break;
30 case SC_SUPERSTATE:
31 ctx->srr1 &= ~MSR_PR;
32 break;
34 case SC_ISSUPERSTATE:
35 if (ctx->srr1 & MSR_PR)
36 ctx->gpr[3] = 0;
37 else
38 ctx->gpr[3] = 1;
39 break;
41 case SC_CAUSE:
43 struct ExecBase *SysBase = getSysBase();
44 if (SysBase)
45 core_Cause(SysBase);
47 break;
49 case SC_DISPATCH:
50 core_Dispatch(ctx);
51 break;
53 case SC_SWITCH:
54 core_Switch(ctx);
55 break;
57 case SC_SCHEDULE:
58 core_Schedule(ctx);
59 break;
61 case SC_INVALIDATED:
63 char *start = (char*)((IPTR)ctx->gpr[4] & 0xffffffe0);
64 char *end = (char*)(((IPTR)ctx->gpr[4] + ctx->gpr[5] + 31) & 0xffffffe0);
65 char *ptr;
67 for (ptr = start; ptr < end; ptr +=32)
69 asm volatile("dcbi 0,%0"::"r"(ptr));
71 asm volatile("sync");
75 core_LeaveInterrupt(ctx);