kernel/eka/personality/example/personality.h
changeset 0 a41df078684a
child 66 2cf30fbd310c
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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;
       
    44 #endif
       
    45 
       
    46 #ifdef __cplusplus
       
    47 extern "C" {
       
    48 #endif
       
    49 
       
    50 /* Return codes */
       
    51 #define	OK					0
       
    52 #define BAD_TASK_ID			(-100)
       
    53 #define BAD_PRIORITY		(-101)
       
    54 #define TIMED_OUT			(-102)
       
    55 #define TIMER_IN_USE		(-103)
       
    56 #define BAD_ENTRY_POINT		(-104)
       
    57 #define BAD_STACK_SIZE		(-105)
       
    58 #define	OUT_OF_MEMORY		(-106)
       
    59 #define BAD_TIMER_ID		(-107)
       
    60 #define BAD_TIME_INTERVAL	(-108)
       
    61 #define BAD_SEM_ID			(-109)
       
    62 
       
    63 
       
    64 /* Task priority range */
       
    65 #define	MIN_TASK_PRIORITY	0
       
    66 #define	MAX_TASK_PRIORITY	255
       
    67 
       
    68 /* Task stack size */
       
    69 #define MIN_STACK_SIZE		256
       
    70 
       
    71 /* Special task IDs */
       
    72 #define TASK_ID_ISR			(-1)
       
    73 #define TASK_ID_UNKNOWN		(-2)		/* non-personality layer thread */
       
    74 
       
    75 /* Time values */
       
    76 #define	NO_WAIT				0			/* Never block */
       
    77 #define	WAIT_FOREVER		(-1)		/* Never time out */
       
    78 
       
    79 /* Special message IDs */
       
    80 #define	MSG_ID_TIMEOUT		0x80000000
       
    81 
       
    82 typedef void (*task_entry)(void);
       
    83 
       
    84 /* Information required to create a task */
       
    85 typedef struct _taskinfo
       
    86 	{
       
    87 	task_entry	entry_pt;
       
    88 	int			priority;
       
    89 	size_t		stack_size;
       
    90 	short		task_id;
       
    91 	short		auto_start;
       
    92 	} taskinfo;
       
    93 
       
    94 /* Externally supplied table of tasks which will be created at boot time */
       
    95 extern const taskinfo task_list[];
       
    96 
       
    97 /* Memory pool creation info */
       
    98 typedef struct _poolinfo
       
    99 	{
       
   100 	size_t		block_size;
       
   101 	unsigned	block_count;
       
   102 	} poolinfo;
       
   103 
       
   104 /* Externally supplied list of memory pools which will be created at boot time */
       
   105 extern const poolinfo pool_list[];
       
   106 
       
   107 /* Message header */
       
   108 typedef struct _msghdr
       
   109 	{
       
   110 	struct _msghdr*	next;
       
   111 	int				msg_id;
       
   112 	int				sending_task_id;
       
   113 	} msghdr;
       
   114 
       
   115 
       
   116 /* Timers */
       
   117 extern const int timer_count;
       
   118 
       
   119 typedef struct _timer_msg
       
   120 	{
       
   121 	msghdr			header;
       
   122 	void*			cookie;
       
   123 	unsigned		count;
       
   124 	} timer_msg;
       
   125 
       
   126 /* Semaphores */
       
   127 extern const int semaphore_count;
       
   128 
       
   129 
       
   130 /* Task APIs */
       
   131 extern int suspend_task(int id);						/* call from any thread */
       
   132 extern int resume_task(int id);							/* call from any thread */
       
   133 extern int get_task_priority(int id);					/* call from any thread */
       
   134 extern int set_task_priority(int id, int priority);		/* call from any thread */
       
   135 extern int current_task_id(void);						/* call from any thread or ISR */
       
   136 extern void disable_preemption(void);					/* call from any thread */
       
   137 extern void enable_preemption(void);					/* call from any thread */
       
   138 extern int disable_interrupts(void);					/* call from any thread */
       
   139 extern void restore_interrupts(int level);				/* call from any thread */
       
   140 
       
   141 /* Memory management */
       
   142 extern void* alloc_mem_block(size_t size);				/* call from any thread or ISR */
       
   143 extern void free_mem_block(void* block);				/* call from any thread or ISR */
       
   144 
       
   145 /* Messages */
       
   146 extern int send_msg(int task_id, msghdr* msg);			/* call from any thread or ISR */
       
   147 extern int recv_msg(msghdr** msgptr, int time_ticks);	/* call only from personality layer thread */
       
   148 
       
   149 /* Timer APIs */
       
   150 extern unsigned tick_count(void);						/* call from any thread or ISR */
       
   151 extern void delay(int time_interval);					/* call from any thread */
       
   152 extern int start_one_shot_timer(int timer_id, int task_id, int time_ticks, void* cookie);	/* call from any thread or ISR */
       
   153 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 */
       
   154 extern int stop_timer(int timer_id);					/* call from any thread or ISR */
       
   155 
       
   156 /* Semaphore APIs */
       
   157 extern int semaphore_wait(int sem_id, int time_ticks);	/* call only from personality layer thread */
       
   158 extern int semaphore_signal(int sem_id);				/* call from any thread or ISR */
       
   159 
       
   160 /* Initialisation */
       
   161 extern void init_personality(void);						/* call from extension entry point */
       
   162 
       
   163 /* Communication with EPOC */
       
   164 extern void send_to_epoc(msghdr* msgptr);
       
   165 
       
   166 #ifdef __cplusplus
       
   167 }
       
   168 #endif
       
   169 #endif