POK(kernelpart)
debug.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 julien on Thu Jan 15 23:34:13 2009
15  */
16 
17 
18 #ifdef POK_NEEDS_DEBUG
19 
20 #include <arch.h>
21 #include <errno.h>
22 #include <core/debug.h>
23 #include <core/cons.h>
24 #include <core/sched.h>
25 #include <core/thread.h>
26 #include <core/partition.h>
27 
28 int debug_strlen (const char* str)
29 {
30  int i = 0;
31 
32  while (*str != '\0')
33  {
34  str++;
35  i++;
36  }
37  return i;
38 }
39 
40 void pok_debug_print_current_state ()
41 {
42  uint32_t i;
43  printf ("\nCurrent state\n");
44  printf ("-------------\n");
45  printf ("Kernel thread : %d\n", KERNEL_THREAD);
46  printf ("Idle thread : %d\n", IDLE_THREAD);
47 #ifdef POK_NEEDS_PARTITIONS
48  printf ("Current partition : %d\n", POK_SCHED_CURRENT_PARTITION);
49  printf ("Thread index : %d\n", POK_CURRENT_PARTITION.thread_index);
50  printf ("Thread low : %d\n", POK_CURRENT_PARTITION.thread_index_low);
51  printf ("Thread high : %d\n", POK_CURRENT_PARTITION.thread_index_high);
52  printf ("Thread capacity : %d\n", POK_CURRENT_PARTITION.nthreads);
53  printf ("Base addr : 0x%x\n", POK_CURRENT_PARTITION.base_addr);
54  printf ("Base vaddr : 0x%x\n", POK_CURRENT_PARTITION.base_vaddr);
55  printf ("Size : %d\n", POK_CURRENT_PARTITION.size);
56  printf ("Current thread : %d\n", POK_CURRENT_PARTITION.current_thread);
57  printf ("Prev current thread : %d\n", POK_CURRENT_PARTITION.prev_current_thread);
58  printf ("Main thread : %d\n", POK_CURRENT_PARTITION.thread_main);
59  printf ("Main thread entry : 0x%x\n", POK_CURRENT_PARTITION.thread_main_entry);
60  printf ("Partition threads sp :");
61  for (i = POK_CURRENT_PARTITION.thread_index_low ; i < POK_CURRENT_PARTITION.thread_index_low + POK_CURRENT_PARTITION.thread_index ; i++)
62  {
63  printf (" 0x%x", pok_threads[i].sp);
64  }
65  printf ("\n");
66  printf ("-------------\n");
67 #endif
68  printf ("Current thread : %d\n", POK_SCHED_CURRENT_THREAD);
69  printf ("Period : %d\n", POK_CURRENT_THREAD.period);
70  printf ("Deadline : %d\n", POK_CURRENT_THREAD.deadline);
71  printf ("Partition : %d\n", POK_CURRENT_THREAD.partition);
72  printf ("sp : 0x%x\n", POK_CURRENT_THREAD.sp);
73  printf ("init_stack_addr : 0x%x\n", POK_CURRENT_THREAD.init_stack_addr);
74  printf ("entry : 0x%x\n", POK_CURRENT_THREAD.entry);
75 }
76 
77 void pok_fatal (const char* message)
78 {
79  pok_write ("FATAL ERROR: \n", 13);
80  pok_write (message , debug_strlen(message));
81 
83  pok_arch_idle ();
84 }
85 
86 #endif /* POK_CONFIG_NEEDS_DEBUG */