POK(kernelpart)
/home/jaouen/pok_official/pok/trunk/kernel/arch/sparc/traps.c
Go to the documentation of this file.
00001 /*
00002  *                               POK header
00003  *
00004  * The following file is a part of the POK project. Any modification should
00005  * made according to the POK licence. You CANNOT use this file or a part of
00006  * this file is this part of a file for your own project
00007  *
00008  * For more information on the POK licence, please see our LICENCE FILE
00009  *
00010  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
00011  *
00012  *                                      Copyright (c) 2007-2009 POK team
00013  *
00014  * Created by peter on Fri Nov  6 21:20:14 2009
00015  */
00016 
00023 #include <types.h>
00024 #include <errno.h>
00025 #include <libc.h>
00026 #include <core/debug.h>
00027 
00028 #include "thread.h"
00029 #include "traps.h"
00030 
00034 sparc_traps_handler pok_sparc_isr[256];
00035 
00040 pok_ret_t traps_init(void)
00041 {
00042   memset((unsigned char *)pok_sparc_isr, 0x0, sizeof (pok_sparc_isr));
00043   return POK_ERRNO_OK;
00044 }
00045 
00053 void trap_handler(unsigned int pc,
00054                   unsigned int npc,
00055                   unsigned int psr,
00056                   unsigned int trap_nb,
00057                   unsigned int restore_counter,
00058                   unsigned int stack_pointer)
00059 {
00060   (void)restore_counter;
00061 
00062   pok_arch_sp = stack_pointer;
00063 
00064   if (pok_sparc_isr[trap_nb] != NULL)
00065   {
00066     pok_sparc_isr[trap_nb]();
00067   }
00068   else
00069   {
00070 #ifdef POK_NEEDS_DEBUG
00071     printf ("[KERNEL] [ERROR] Unhandled trap: 0x%x %%PSR=%x %%PC=%x %%nPC=%x %%sp=0x%x\n", trap_nb, psr, pc, npc, stack_pointer);
00072     printf("%%psr : impl:0x%x ver:%x nzvc:%u%u%u%u EC:%u EF:%u PIL:0x%x S:%u PS:%u ET:%u CWP:%u\n\r",
00073            (psr >> 28) & 0xF, (psr >> 24) & 0xF,
00074            (psr >> 23) & 0x1, (psr >> 22) & 0x1c, (psr >> 21) & 0x1, (psr >> 20) & 0x1,
00075            (psr >> 23) & 0x1, (psr >> 12) & 0x1, (psr >> 8) & 0xF, (psr >> 7) & 0x1, (psr >> 6) & 0x1,
00076            (psr >> 5) & 0x1, psr & 0xF);
00077 #else
00078     (void)psr;
00079     (void)npc;
00080     (void)pc;
00081 #endif
00082     POK_FATAL ("Unhandled trap");
00083   }
00084   return;
00085 }