POK(kernelpart)
partition.h
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 
23 #ifndef __POK_PARTITION_H__
24 #define __POK_PARTITION_H__
25 
26 #ifdef POK_NEEDS_PARTITIONS
27 
28 #include <types.h>
29 #include <errno.h>
30 #include <core/error.h>
31 #include <core/thread.h>
32 #include <core/sched.h>
33 
34 
39 typedef enum
40 {
41  POK_PARTITION_MODE_INIT_COLD = 1,
43  POK_PARTITION_MODE_INIT_WARM = 2,
45  POK_PARTITION_MODE_NORMAL = 3,
49  POK_PARTITION_MODE_IDLE = 4,
50  POK_PARTITION_MODE_RESTART = 5,
51  POK_PARTITION_MODE_STOPPED = 6,
52 }pok_partition_mode_t;
53 
54 typedef enum
55 {
56  NORMAL_START = 0,
57  PARTITION_RESTART = 1,
58  HM_MODULE_RESTART = 2,
59  HM_PARTITION_RESTART = 3
60 }pok_start_condition_t;
61 
62 
67 typedef struct
68 {
69  uint32_t base_addr;
70  uint32_t base_vaddr;
74  uint32_t size;
76  const char *name;
78  uint32_t nthreads;
80  uint8_t priority;
81  uint32_t period;
83  pok_sched_t sched;
85  uint32_t (*sched_func)(uint32_t low, uint32_t high);
87  uint64_t activation;
88  uint32_t prev_current_thread;
89  uint32_t current_thread;
91  uint32_t thread_index_low;
92  uint32_t thread_index_high;
93  uint32_t thread_index;
95 #if defined(POK_NEEDS_LOCKOBJECTS) || defined(POK_NEEDS_ERROR_HANDLING)
96  uint8_t lockobj_index_low;
97  uint8_t lockobj_index_high;
98  uint8_t nlockobjs;
99 #endif
100 
101 #ifdef POK_NEEDS_SCHED_HFPPS
102  uint64_t payback;
103 #endif /* POK_NEEDS_SCHED_HFPPS */
104 
105 #ifdef POK_NEEDS_ERROR_HANDLING
106  uint32_t thread_error;
107  pok_error_status_t error_status;
108 #endif
109  uint32_t thread_main;
110  uint32_t thread_main_entry;
111  pok_partition_mode_t mode;
113 #ifdef POK_NEEDS_IO
114  uint16_t io_min;
115  uint16_t io_max;
116 #endif
117 
118  uint32_t lock_level;
119  pok_start_condition_t start_condition;
120 } pok_partition_t;
121 
122 extern pok_partition_t pok_partitions[POK_CONFIG_NB_PARTITIONS];
123 
129 #define POK_CURRENT_PARTITION pok_partitions[POK_SCHED_CURRENT_PARTITION]
130 
135 #define POK_CHECK_PTR_IN_PARTITION(pid,ptr) (\
136  ((((uint32_t)ptr)>=pok_partitions[pid].base_addr)&& \
137  (((uint32_t)ptr)<=(pok_partitions[pid].base_addr+pok_partitions[pid].size)))?1:0\
138  )
139 
143 pok_ret_t pok_partition_init();
144 
145 pok_ret_t pok_partition_set_mode (const uint8_t pid, const pok_partition_mode_t mode);
146 pok_ret_t pok_partition_set_mode_current (const pok_partition_mode_t mode);
147 
148 
149 pok_ret_t pok_partition_stop_thread (const uint32_t tid);
150 
151 void pok_partition_reinit (const uint8_t);
152 
153 void pok_partition_setup_main_thread (const uint8_t);
154 
155 void pok_partition_setup_scheduler (const uint8_t pid);
156 
157 pok_ret_t pok_partition_restart_thread (const uint32_t tid);
158 
159 pok_ret_t pok_current_partition_get_id (uint8_t *id);
160 
161 pok_ret_t pok_current_partition_get_period (uint64_t *period);
162 
163 pok_ret_t pok_current_partition_get_duration (uint64_t *duration);
164 
165 pok_ret_t pok_current_partition_get_operating_mode (pok_partition_mode_t *op_mode);
166 
167 pok_ret_t pok_current_partition_get_lock_level (uint32_t *lock_level);
168 
169 pok_ret_t pok_current_partition_get_start_condition (pok_start_condition_t *start_condition);
170 
171 #endif /* __POK_NEEDS_PARTITIONS */
172 
173 #endif /* __POK_PARTITION_H__ */