POK(kernelpart)
traps.c
Go to the documentation of this file.
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by peter on Fri Nov 6 21:20:14 2009
15  */
16 
23 #include <types.h>
24 #include <errno.h>
25 #include <libc.h>
26 #include <core/debug.h>
27 
28 #include "thread.h"
29 #include "traps.h"
30 
35 
41 {
42  memset((unsigned char *)pok_sparc_isr, 0x0, sizeof (pok_sparc_isr));
43  return POK_ERRNO_OK;
44 }
45 
53 void trap_handler(unsigned int pc,
54  unsigned int npc,
55  unsigned int psr,
56  unsigned int trap_nb,
57  unsigned int restore_counter,
58  unsigned int stack_pointer)
59 {
60  (void)restore_counter;
61 
62  pok_arch_sp = stack_pointer;
63 
64  if (pok_sparc_isr[trap_nb] != NULL)
65  {
66  pok_sparc_isr[trap_nb]();
67  }
68  else
69  {
70 #ifdef POK_NEEDS_DEBUG
71  printf ("[KERNEL] [ERROR] Unhandled trap: 0x%x %%PSR=%x %%PC=%x %%nPC=%x %%sp=0x%x\n", trap_nb, psr, pc, npc, stack_pointer);
72  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",
73  (psr >> 28) & 0xF, (psr >> 24) & 0xF,
74  (psr >> 23) & 0x1, (psr >> 22) & 0x1c, (psr >> 21) & 0x1, (psr >> 20) & 0x1,
75  (psr >> 23) & 0x1, (psr >> 12) & 0x1, (psr >> 8) & 0xF, (psr >> 7) & 0x1, (psr >> 6) & 0x1,
76  (psr >> 5) & 0x1, psr & 0xF);
77 #else
78  (void)psr;
79  (void)npc;
80  (void)pc;
81 #endif
82  POK_FATAL ("Unhandled trap");
83  }
84  return;
85 }