POK(kernelpart)
/home/jaouen/pok_official/pok/trunk/kernel/core/debug.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 julien on Thu Jan 15 23:34:13 2009 
00015  */
00016 
00017 
00018 #ifdef POK_NEEDS_DEBUG
00019 
00020 #include <arch.h>
00021 #include <errno.h>
00022 #include <core/debug.h>
00023 #include <core/cons.h>
00024 #include <core/sched.h>
00025 #include <core/thread.h>
00026 #include <core/partition.h>
00027 
00028 int debug_strlen (const char* str)
00029 {
00030   int           i = 0;
00031 
00032   while (*str != '\0')
00033   {
00034     str++;
00035     i++;
00036   }
00037   return i;
00038 }
00039 
00040 void pok_debug_print_current_state ()
00041 {
00042    uint32_t i;
00043    printf ("\nCurrent state\n");
00044    printf ("-------------\n");
00045    printf ("Kernel thread        : %d\n", KERNEL_THREAD);
00046    printf ("Idle thread          : %d\n", IDLE_THREAD);
00047 #ifdef POK_NEEDS_PARTITIONS
00048    printf ("Current partition    : %d\n", POK_SCHED_CURRENT_PARTITION);
00049    printf ("Thread index         : %d\n", POK_CURRENT_PARTITION.thread_index);
00050    printf ("Thread low           : %d\n", POK_CURRENT_PARTITION.thread_index_low);
00051    printf ("Thread high          : %d\n", POK_CURRENT_PARTITION.thread_index_high);
00052    printf ("Thread capacity      : %d\n", POK_CURRENT_PARTITION.nthreads);
00053    printf ("Base addr            : 0x%x\n", POK_CURRENT_PARTITION.base_addr);
00054    printf ("Base vaddr           : 0x%x\n", POK_CURRENT_PARTITION.base_vaddr);
00055    printf ("Size                 : %d\n", POK_CURRENT_PARTITION.size);
00056    printf ("Current thread       : %d\n", POK_CURRENT_PARTITION.current_thread);
00057    printf ("Prev current thread  : %d\n", POK_CURRENT_PARTITION.prev_thread);
00058    printf ("Main thread          : %d\n", POK_CURRENT_PARTITION.thread_main);
00059    printf ("Main thread entry    : 0x%x\n", POK_CURRENT_PARTITION.thread_main_entry);
00060    printf ("Partition threads sp :");
00061    for (i = POK_CURRENT_PARTITION.thread_index_low ; i < POK_CURRENT_PARTITION.thread_index_low + POK_CURRENT_PARTITION.thread_index ; i++)
00062    {
00063       printf (" 0x%x", pok_threads[i].sp);
00064    }
00065    printf ("\n");
00066    printf ("-------------\n");
00067 #endif
00068    printf ("Current thread    : %d\n", POK_SCHED_CURRENT_THREAD);
00069    printf ("Period            : %d\n", POK_CURRENT_THREAD.period);
00070    printf ("Deadline          : %d\n", POK_CURRENT_THREAD.deadline);
00071    printf ("Partition         : %d\n", POK_CURRENT_THREAD.partition);
00072    printf ("sp                : 0x%x\n", POK_CURRENT_THREAD.sp);
00073    printf ("init_stack_addr   : 0x%x\n", POK_CURRENT_THREAD.init_stack_addr);
00074    printf ("entry             : 0x%x\n", POK_CURRENT_THREAD.entry);
00075 }
00076 
00077 void pok_fatal (const char* message)
00078 {
00079   pok_write ("FATAL ERROR: \n", 13);
00080   pok_write (message , debug_strlen(message));
00081 
00082   POK_DEBUG_PRINT_CURRENT_STATE
00083   pok_arch_idle ();
00084 }
00085 
00086 #endif /* POK_CONFIG_NEEDS_DEBUG */