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