POK(kernelpart)
/home/jaouen/pok_official/pok/trunk/kernel/arch/ppc/arch.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 
00024 #include <types.h>
00025 #include <errno.h>
00026 #include <core/partition.h>
00027 #include "msr.h"
00028 
00029 extern void pok_arch_space_init (void);
00030 
00031 static inline unsigned int get_msr (void)
00032 {
00033   unsigned int res;
00034   asm ("mfmsr %0\n" : "=r" (res));
00035   return res;
00036 }
00037 
00038 static inline void set_msr (unsigned int val)
00039 {
00040   asm volatile ("mtmsr %0\n" : : "r" (val));
00041 }
00042 
00043 pok_ret_t pok_arch_init ()
00044 {
00045   set_msr (MSR_IP);
00046 #if POK_NEEDS_PARTITIONS
00047   pok_arch_space_init();
00048 #endif
00049 
00050   return (POK_ERRNO_OK);
00051 }
00052 
00053 pok_ret_t pok_arch_preempt_disable()
00054 {
00055   unsigned int msr;
00056 
00057   msr = get_msr();
00058   msr &= ~MSR_EE;
00059   set_msr(msr);
00060   return (POK_ERRNO_OK);
00061 }
00062 
00063 pok_ret_t pok_arch_preempt_enable()
00064 {
00065   unsigned int msr;
00066 
00067   msr = get_msr();
00068   msr |= MSR_EE;
00069   set_msr(msr);
00070 
00071   return (POK_ERRNO_OK);
00072 }
00073 
00074 pok_ret_t pok_arch_idle()
00075 {
00076    while (1)
00077    {
00078    }
00079 
00080    return (POK_ERRNO_OK);       
00081 }
00082 
00083 pok_ret_t pok_arch_event_register (uint8_t vector, void (*handler)(void))
00084 {
00085   (void) vector;
00086   (void) handler;
00087 
00088   return (POK_ERRNO_OK);
00089 }
00090 
00091 
00092 uint32_t    pok_thread_stack_addr   (const uint8_t    partition_id,
00093                                      const uint32_t   local_thread_id)
00094 {
00095    return pok_partitions[partition_id].size - 16 - (local_thread_id * POK_USER_STACK_SIZE);
00096 }
00097 
00098