sl@0: /* sl@0: * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * e32\personality\example\personality.h sl@0: * External interface header file for example RTOS personality. sl@0: * This will be included by the real time application source files. sl@0: * sl@0: * WARNING: This file contains some APIs which are internal and are subject sl@0: * to change without notice. Such APIs should therefore not be used sl@0: * outside the Kernel and Hardware Services package. sl@0: */ sl@0: sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #ifndef __PERSONALITY_H__ sl@0: #define __PERSONALITY_H__ sl@0: sl@0: // should be separate C function sl@0: #define kprintf Kern::Printf sl@0: #define assert(x) __NK_ASSERT_ALWAYS(x) sl@0: sl@0: #if defined(__GCC32__) sl@0: typedef unsigned long size_t; sl@0: #elif defined(__CW32__) sl@0: typedef unsigned int size_t; sl@0: #elif defined(__ARMCC__) sl@0: typedef unsigned int size_t; sl@0: #endif sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" { sl@0: #endif sl@0: sl@0: /* Return codes */ sl@0: #define OK 0 sl@0: #define BAD_TASK_ID (-100) sl@0: #define BAD_PRIORITY (-101) sl@0: #define TIMED_OUT (-102) sl@0: #define TIMER_IN_USE (-103) sl@0: #define BAD_ENTRY_POINT (-104) sl@0: #define BAD_STACK_SIZE (-105) sl@0: #define OUT_OF_MEMORY (-106) sl@0: #define BAD_TIMER_ID (-107) sl@0: #define BAD_TIME_INTERVAL (-108) sl@0: #define BAD_SEM_ID (-109) sl@0: sl@0: sl@0: /* Task priority range */ sl@0: #define MIN_TASK_PRIORITY 0 sl@0: #define MAX_TASK_PRIORITY 255 sl@0: sl@0: /* Task stack size */ sl@0: #define MIN_STACK_SIZE 256 sl@0: sl@0: /* Special task IDs */ sl@0: #define TASK_ID_ISR (-1) sl@0: #define TASK_ID_UNKNOWN (-2) /* non-personality layer thread */ sl@0: sl@0: /* Time values */ sl@0: #define NO_WAIT 0 /* Never block */ sl@0: #define WAIT_FOREVER (-1) /* Never time out */ sl@0: sl@0: /* Special message IDs */ sl@0: #define MSG_ID_TIMEOUT 0x80000000 sl@0: sl@0: typedef void (*task_entry)(void); sl@0: sl@0: /* Information required to create a task */ sl@0: typedef struct _taskinfo sl@0: { sl@0: task_entry entry_pt; sl@0: int priority; sl@0: size_t stack_size; sl@0: short task_id; sl@0: short auto_start; sl@0: } taskinfo; sl@0: sl@0: /* Externally supplied table of tasks which will be created at boot time */ sl@0: extern const taskinfo task_list[]; sl@0: sl@0: /* Memory pool creation info */ sl@0: typedef struct _poolinfo sl@0: { sl@0: size_t block_size; sl@0: unsigned block_count; sl@0: } poolinfo; sl@0: sl@0: /* Externally supplied list of memory pools which will be created at boot time */ sl@0: extern const poolinfo pool_list[]; sl@0: sl@0: /* Message header */ sl@0: typedef struct _msghdr sl@0: { sl@0: struct _msghdr* next; sl@0: int msg_id; sl@0: int sending_task_id; sl@0: } msghdr; sl@0: sl@0: sl@0: /* Timers */ sl@0: extern const int timer_count; sl@0: sl@0: typedef struct _timer_msg sl@0: { sl@0: msghdr header; sl@0: void* cookie; sl@0: unsigned count; sl@0: } timer_msg; sl@0: sl@0: /* Semaphores */ sl@0: extern const int semaphore_count; sl@0: sl@0: sl@0: /* Task APIs */ sl@0: extern int suspend_task(int id); /* call from any thread */ sl@0: extern int resume_task(int id); /* call from any thread */ sl@0: extern int get_task_priority(int id); /* call from any thread */ sl@0: extern int set_task_priority(int id, int priority); /* call from any thread */ sl@0: extern int current_task_id(void); /* call from any thread or ISR */ sl@0: extern void disable_preemption(void); /* call from any thread */ sl@0: extern void enable_preemption(void); /* call from any thread */ sl@0: extern int disable_interrupts(void); /* call from any thread */ sl@0: extern void restore_interrupts(int level); /* call from any thread */ sl@0: sl@0: /* Memory management */ sl@0: extern void* alloc_mem_block(size_t size); /* call from any thread or ISR */ sl@0: extern void free_mem_block(void* block); /* call from any thread or ISR */ sl@0: sl@0: /* Messages */ sl@0: extern int send_msg(int task_id, msghdr* msg); /* call from any thread or ISR */ sl@0: extern int recv_msg(msghdr** msgptr, int time_ticks); /* call only from personality layer thread */ sl@0: sl@0: /* Timer APIs */ sl@0: extern unsigned tick_count(void); /* call from any thread or ISR */ sl@0: extern void delay(int time_interval); /* call from any thread */ sl@0: extern int start_one_shot_timer(int timer_id, int task_id, int time_ticks, void* cookie); /* call from any thread or ISR */ sl@0: 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 */ sl@0: extern int stop_timer(int timer_id); /* call from any thread or ISR */ sl@0: sl@0: /* Semaphore APIs */ sl@0: extern int semaphore_wait(int sem_id, int time_ticks); /* call only from personality layer thread */ sl@0: extern int semaphore_signal(int sem_id); /* call from any thread or ISR */ sl@0: sl@0: /* Initialisation */ sl@0: extern void init_personality(void); /* call from extension entry point */ sl@0: sl@0: /* Communication with EPOC */ sl@0: extern void send_to_epoc(msghdr* msgptr); sl@0: sl@0: #ifdef __cplusplus sl@0: } sl@0: #endif sl@0: #endif