POK(kernelpart)
/home/jaouen/pok_official/pok/trunk/kernel/arch/x86/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 <errno.h>
00025 #include <core/partition.h>
00026 
00027 #include "event.h"
00028 #include "gdt.h"
00029 
00030 pok_ret_t pok_arch_init ()
00031 {
00032   pok_gdt_init ();
00033   pok_event_init ();
00034 
00035   return (POK_ERRNO_OK);
00036 }
00037 
00038 pok_ret_t pok_arch_preempt_disable()
00039 {
00040   asm ("cli");
00041   return (POK_ERRNO_OK);
00042 }
00043 
00044 pok_ret_t pok_arch_preempt_enable()
00045 {
00046   asm ("sti");
00047   return (POK_ERRNO_OK);
00048 }
00049 
00050 pok_ret_t pok_arch_idle()
00051 {
00052    while (1)
00053    {
00054       asm ("hlt");
00055    }
00056 
00057    return (POK_ERRNO_OK);       
00058 }
00059 
00060 pok_ret_t pok_arch_event_register  (uint8_t vector,
00061                                     void (*handler)(void))
00062 {
00063    pok_idt_set_gate (vector,
00064                      GDT_CORE_CODE_SEGMENT << 3,
00065                      (uint32_t)handler,
00066                      IDTE_TRAP,
00067                      3);
00068 
00069    return (POK_ERRNO_OK);
00070 }
00071 
00072 uint32_t    pok_thread_stack_addr   (const uint8_t    partition_id,
00073                                      const uint32_t   local_thread_id)
00074 {
00075    return pok_partitions[partition_id].size - 4 - (local_thread_id * POK_USER_STACK_SIZE);
00076 }
00077