author | mikek |
Tue, 15 Jun 2010 19:10:20 +0100 | |
branch | GCC_SURGE |
changeset 156 | 12b6722e7753 |
parent 104 | 466a0df5c15a |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* e32\personality\example\personality.h |
|
16 |
* External interface header file for example RTOS personality. |
|
17 |
* This will be included by the real time application source files. |
|
18 |
* |
|
19 |
* WARNING: This file contains some APIs which are internal and are subject |
|
20 |
* to change without notice. Such APIs should therefore not be used |
|
21 |
* outside the Kernel and Hardware Services package. |
|
22 |
*/ |
|
23 |
||
24 |
||
25 |
||
26 |
/** |
|
27 |
@file |
|
28 |
@internalComponent |
|
29 |
*/ |
|
30 |
||
31 |
#ifndef __PERSONALITY_H__ |
|
32 |
#define __PERSONALITY_H__ |
|
33 |
||
34 |
// should be separate C function |
|
35 |
#define kprintf Kern::Printf |
|
36 |
#define assert(x) __NK_ASSERT_ALWAYS(x) |
|
37 |
||
38 |
#if defined(__GCC32__) |
|
39 |
typedef unsigned long size_t; |
|
40 |
#elif defined(__CW32__) |
|
41 |
typedef unsigned int size_t; |
|
42 |
#elif defined(__ARMCC__) |
|
43 |
typedef unsigned int size_t; |
|
104
466a0df5c15a
RVCT 4.0 support, gcce fixes (Bug 2283)
Chetan Kapoor <chetank@symbian.org>
parents:
0
diff
changeset
|
44 |
#elif defined(__GCCE__) |
466a0df5c15a
RVCT 4.0 support, gcce fixes (Bug 2283)
Chetan Kapoor <chetank@symbian.org>
parents:
0
diff
changeset
|
45 |
typedef unsigned int size_t; |
0 | 46 |
#endif |
47 |
||
48 |
#ifdef __cplusplus |
|
49 |
extern "C" { |
|
50 |
#endif |
|
51 |
||
52 |
/* Return codes */ |
|
53 |
#define OK 0 |
|
54 |
#define BAD_TASK_ID (-100) |
|
55 |
#define BAD_PRIORITY (-101) |
|
56 |
#define TIMED_OUT (-102) |
|
57 |
#define TIMER_IN_USE (-103) |
|
58 |
#define BAD_ENTRY_POINT (-104) |
|
59 |
#define BAD_STACK_SIZE (-105) |
|
60 |
#define OUT_OF_MEMORY (-106) |
|
61 |
#define BAD_TIMER_ID (-107) |
|
62 |
#define BAD_TIME_INTERVAL (-108) |
|
63 |
#define BAD_SEM_ID (-109) |
|
64 |
||
65 |
||
66 |
/* Task priority range */ |
|
67 |
#define MIN_TASK_PRIORITY 0 |
|
68 |
#define MAX_TASK_PRIORITY 255 |
|
69 |
||
70 |
/* Task stack size */ |
|
71 |
#define MIN_STACK_SIZE 256 |
|
72 |
||
73 |
/* Special task IDs */ |
|
74 |
#define TASK_ID_ISR (-1) |
|
75 |
#define TASK_ID_UNKNOWN (-2) /* non-personality layer thread */ |
|
76 |
||
77 |
/* Time values */ |
|
78 |
#define NO_WAIT 0 /* Never block */ |
|
79 |
#define WAIT_FOREVER (-1) /* Never time out */ |
|
80 |
||
81 |
/* Special message IDs */ |
|
82 |
#define MSG_ID_TIMEOUT 0x80000000 |
|
83 |
||
84 |
typedef void (*task_entry)(void); |
|
85 |
||
86 |
/* Information required to create a task */ |
|
87 |
typedef struct _taskinfo |
|
88 |
{ |
|
89 |
task_entry entry_pt; |
|
90 |
int priority; |
|
91 |
size_t stack_size; |
|
92 |
short task_id; |
|
93 |
short auto_start; |
|
94 |
} taskinfo; |
|
95 |
||
96 |
/* Externally supplied table of tasks which will be created at boot time */ |
|
97 |
extern const taskinfo task_list[]; |
|
98 |
||
99 |
/* Memory pool creation info */ |
|
100 |
typedef struct _poolinfo |
|
101 |
{ |
|
102 |
size_t block_size; |
|
103 |
unsigned block_count; |
|
104 |
} poolinfo; |
|
105 |
||
106 |
/* Externally supplied list of memory pools which will be created at boot time */ |
|
107 |
extern const poolinfo pool_list[]; |
|
108 |
||
109 |
/* Message header */ |
|
110 |
typedef struct _msghdr |
|
111 |
{ |
|
112 |
struct _msghdr* next; |
|
113 |
int msg_id; |
|
114 |
int sending_task_id; |
|
115 |
} msghdr; |
|
116 |
||
117 |
||
118 |
/* Timers */ |
|
119 |
extern const int timer_count; |
|
120 |
||
121 |
typedef struct _timer_msg |
|
122 |
{ |
|
123 |
msghdr header; |
|
124 |
void* cookie; |
|
125 |
unsigned count; |
|
126 |
} timer_msg; |
|
127 |
||
128 |
/* Semaphores */ |
|
129 |
extern const int semaphore_count; |
|
130 |
||
131 |
||
132 |
/* Task APIs */ |
|
133 |
extern int suspend_task(int id); /* call from any thread */ |
|
134 |
extern int resume_task(int id); /* call from any thread */ |
|
135 |
extern int get_task_priority(int id); /* call from any thread */ |
|
136 |
extern int set_task_priority(int id, int priority); /* call from any thread */ |
|
137 |
extern int current_task_id(void); /* call from any thread or ISR */ |
|
138 |
extern void disable_preemption(void); /* call from any thread */ |
|
139 |
extern void enable_preemption(void); /* call from any thread */ |
|
140 |
extern int disable_interrupts(void); /* call from any thread */ |
|
141 |
extern void restore_interrupts(int level); /* call from any thread */ |
|
142 |
||
143 |
/* Memory management */ |
|
144 |
extern void* alloc_mem_block(size_t size); /* call from any thread or ISR */ |
|
145 |
extern void free_mem_block(void* block); /* call from any thread or ISR */ |
|
146 |
||
147 |
/* Messages */ |
|
148 |
extern int send_msg(int task_id, msghdr* msg); /* call from any thread or ISR */ |
|
149 |
extern int recv_msg(msghdr** msgptr, int time_ticks); /* call only from personality layer thread */ |
|
150 |
||
151 |
/* Timer APIs */ |
|
152 |
extern unsigned tick_count(void); /* call from any thread or ISR */ |
|
153 |
extern void delay(int time_interval); /* call from any thread */ |
|
154 |
extern int start_one_shot_timer(int timer_id, int task_id, int time_ticks, void* cookie); /* call from any thread or ISR */ |
|
155 |
extern int start_periodic_timer(int timer_id, int task_id, int initial_time_ticks, int period_ticks, void* cookie); /* call from any thread or ISR */ |
|
156 |
extern int stop_timer(int timer_id); /* call from any thread or ISR */ |
|
157 |
||
158 |
/* Semaphore APIs */ |
|
159 |
extern int semaphore_wait(int sem_id, int time_ticks); /* call only from personality layer thread */ |
|
160 |
extern int semaphore_signal(int sem_id); /* call from any thread or ISR */ |
|
161 |
||
162 |
/* Initialisation */ |
|
163 |
extern void init_personality(void); /* call from extension entry point */ |
|
164 |
||
165 |
/* Communication with EPOC */ |
|
166 |
extern void send_to_epoc(msghdr* msgptr); |
|
167 |
||
168 |
#ifdef __cplusplus |
|
169 |
} |
|
170 |
#endif |
|
171 |
#endif |