POK(kernelpart)
/home/jaouen/pok_official/pok/trunk/kernel/include/core/partition.h
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 
00023 #ifndef __POK_PARTITION_H__
00024 #define __POK_PARTITION_H__
00025 
00026 #ifdef POK_NEEDS_PARTITIONS
00027 
00028 #include <types.h>
00029 #include <errno.h>
00030 #include <core/error.h>
00031 #include <core/thread.h>
00032 #include <core/sched.h>
00033 
00034 
00039 typedef enum
00040 {
00041    POK_PARTITION_MODE_INIT_COLD = 1, 
00043    POK_PARTITION_MODE_INIT_WARM = 2, 
00045    POK_PARTITION_MODE_NORMAL    = 3, 
00049    POK_PARTITION_MODE_IDLE      = 4, 
00050    POK_PARTITION_MODE_RESTART   = 5, 
00051    POK_PARTITION_MODE_STOPPED   = 6, 
00052 }pok_partition_mode_t;
00053 
00054 typedef enum
00055 {
00056   NORMAL_START          = 0,
00057   PARTITION_RESTART     = 1,
00058   HM_MODULE_RESTART     = 2,
00059   HM_PARTITION_RESTART  = 3
00060 }pok_start_condition_t;
00061 
00062 
00067 typedef struct
00068 {
00069    uint32_t              base_addr;    
00070    uint32_t              base_vaddr;   
00074    uint32_t              size;         
00076    const char            *name;        
00078    uint32_t              nthreads;     
00080    uint8_t               priority;     
00081    uint32_t              period;       
00083    pok_sched_t           sched;       
00085    uint32_t (*sched_func)(uint32_t low, uint32_t high,uint32_t prev_thread, uint32_t cur_thread); 
00087    uint64_t              activation;                    
00088    uint32_t              prev_thread;           
00089    uint32_t              current_thread;                
00091    uint32_t               thread_index_low;    
00092    uint32_t               thread_index_high;   
00093    uint32_t               thread_index;        
00095 #if defined(POK_NEEDS_LOCKOBJECTS) || defined(POK_NEEDS_ERROR_HANDLING)
00096    uint8_t               lockobj_index_low;   
00097    uint8_t               lockobj_index_high;  
00098    uint8_t               nlockobjs;           
00099 #endif
00100 
00101 #ifdef POK_NEEDS_SCHED_HFPPS
00102    uint64_t             payback; 
00103 #endif /* POK_NEEDS_SCHED_HFPPS */
00104 
00105 #ifdef POK_NEEDS_ERROR_HANDLING
00106    uint32_t             thread_error;         
00107    pok_error_status_t   error_status;        
00108 #endif
00109    uint32_t             thread_main;          
00110    uint32_t             thread_main_entry;    
00111    pok_partition_mode_t mode;                 
00113 #ifdef POK_NEEDS_IO
00114   uint16_t              io_min;                        
00115   uint16_t              io_max;                        
00116 #endif
00117 
00118   uint32_t              lock_level;
00119   pok_start_condition_t start_condition;
00120 } pok_partition_t;
00121 
00122 extern pok_partition_t pok_partitions[POK_CONFIG_NB_PARTITIONS];
00123 
00129 #define POK_CURRENT_PARTITION pok_partitions[POK_SCHED_CURRENT_PARTITION]
00130 
00135 #define POK_CHECK_PTR_IN_PARTITION(pid,ptr) (\
00136                                              ((((uint32_t)ptr)>=pok_partitions[pid].base_addr)&& \
00137                                              (((uint32_t)ptr)<=(pok_partitions[pid].base_addr+pok_partitions[pid].size)))?1:0\
00138                                              )
00139 
00143 pok_ret_t pok_partition_init();
00144 
00145 pok_ret_t pok_partition_set_mode (const uint8_t pid, const pok_partition_mode_t mode);
00146 pok_ret_t pok_partition_set_mode_current (const pok_partition_mode_t mode);
00147 
00148 
00149 pok_ret_t pok_partition_stop_thread (const uint32_t tid);
00150 
00151 void pok_partition_reinit (const uint8_t);
00152 
00153 void pok_partition_setup_main_thread (const uint8_t);
00154 
00155 void pok_partition_setup_scheduler (const uint8_t pid);
00156 
00157 pok_ret_t pok_partition_restart_thread (const uint32_t tid);
00158 
00159 pok_ret_t pok_current_partition_get_id (uint8_t *id);
00160 
00161 pok_ret_t pok_current_partition_get_period (uint64_t *period);
00162 
00163 pok_ret_t pok_current_partition_get_duration (uint64_t *duration);
00164 
00165 pok_ret_t pok_current_partition_get_operating_mode (pok_partition_mode_t *op_mode);
00166 
00167 pok_ret_t pok_current_partition_get_lock_level (uint32_t *lock_level);
00168 
00169 pok_ret_t pok_current_partition_get_start_condition (pok_start_condition_t *start_condition);
00170 
00171 #endif /* __POK_NEEDS_PARTITIONS */
00172 
00173 #endif /* __POK_PARTITION_H__ */