Redefine microkernel task object identifier type

The opaque task object id type is now a pointer to
the associated task structure, rather than an index
into the microkernel's array of task structures.

This change is a pre-requisite to support for private
task objects, which are defined in source code.

Change-Id: Idb53ea7f8a8a5b7e6477a74273930b08fc77dcfe
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2015-07-21 11:02:59 -07:00 committed by Anas Nashif
commit 1367a98e9e
6 changed files with 36 additions and 24 deletions

View file

@ -102,6 +102,22 @@ struct k_msg {
} extra;
};
/* Task control block */
struct k_proc {
struct k_proc *Forw;
struct k_proc *Back;
kpriority_t Prio;
ktask_t Ident;
uint32_t State;
uint32_t Group;
void (*fstart)(void);
char *workspace;
int worksize;
void (*fabort)(void);
struct k_args *Args;
};
struct _k_mbox_struct {
struct k_args *Writers;
struct k_args *Readers;

View file

@ -49,6 +49,7 @@ extern "C" {
#define USR_GROUP 2 /* TASKGROUP SYS */
#define FPU_GROUP 4 /* TASKGROUP FPU */
extern struct k_proc _k_task_list[];
extern void _task_ioctl(ktask_t, int);
extern void _task_group_ioctl(ktask_group_t, int);

View file

@ -42,7 +42,6 @@
#define OBJ_INDEX(objId) ((uint16_t)objId)
extern struct k_proc _k_task_list[];
extern struct k_tqhd _k_task_priority_list[];
extern int _k_task_count;

View file

@ -145,22 +145,6 @@ struct k_tqhd {
struct k_proc *Tail;
};
/* Task control block */
struct k_proc {
struct k_proc *Forw;
struct k_proc *Back;
kpriority_t Prio;
ktask_t Ident;
uint32_t State;
uint32_t Group;
void (*fstart)(void);
char *workspace;
int worksize;
void (*fabort)(void);
struct k_args *Args;
};
/* Monitor record */
struct k_mrec {

View file

@ -327,7 +327,7 @@ void task_abort_handler_set(void (*func)(void) /* abort handler */
void _k_task_op(struct k_args *A)
{
ktask_t Tid = A->Args.g1.task;
struct k_proc *X = _k_task_list + OBJ_INDEX(Tid);
struct k_proc *X = (struct k_proc *)Tid;
switch (A->Args.g1.opt) {
case TASK_START:
@ -499,7 +499,7 @@ kpriority_t task_priority_get(void)
void _k_task_priority_set(struct k_args *A)
{
ktask_t Tid = A->Args.g1.task;
struct k_proc *X = _k_task_list + OBJ_INDEX(Tid);
struct k_proc *X = (struct k_proc *)Tid;
_k_state_bit_set(X, TF_PRIO);
X->Prio = A->Args.g1.prio;
@ -596,6 +596,8 @@ void task_entry_set(ktask_t task, /* task */
void (*func)(void) /* entry point */
)
{
_k_task_list[OBJ_INDEX(task)].fstart = func;
struct k_proc *X = (struct k_proc *)task;
X->fstart = func;
}

View file

@ -377,7 +377,7 @@ def kernel_main_c_tasks():
kernel_main_c_out("\n" +
"struct k_proc _k_task_list[%d] =\n" % (total_tasks) +
"{\n")
ident = 0x00010000
idx = 0
for task in task_list:
prio = task[1]
entry = task[2]
@ -403,10 +403,10 @@ def kernel_main_c_tasks():
group_bitmask ^= group_dictionary['SYS']
kernel_main_c_out(
" {NULL, NULL, %d, %#010x, " % (prio, ident) +
" {NULL, NULL, %d, (ktask_t)&_k_task_list[%d], " % (prio, idx) +
"0x00000001, %#010x,\n" % (group_bitmask) +
"%s, %s, %d, (taskabortfunction)NULL},\n" % (entry, stack, size))
ident += 1
idx += 1
kernel_main_c_out(" {NULL, NULL, %d, 0x00000000, " % (num_prios - 1) +
"0x00000000, 0x00000000,\n" +
@ -941,10 +941,20 @@ def generate_zephyr_h_obj_ids():
zephyr_h_data += \
"#define %s ((kmbox_t)&_k_mbox_obj_%s)\n\n" % (name, name)
# task object id
idx = 0
kernel_main_c_out("\n")
for task in task_list:
name = task[0];
zephyr_h_data += \
"#define %s ((ktask_t)&_k_task_list[%d])\n" % (name, idx)
idx += 1
# all other object ids
obj_types = [
[task_list, 0],
[pipe_list, 0],
[map_list, 0],
[pool_list, 0],