aboutsummaryrefslogtreecommitdiffstats
path: root/os/common/abstractions/nasa_osal/include/osapi-os-core.h
blob: 8c9b13a78c3f8c8da586fd854c9fd238bb004cd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
/*
** File: osapi-os-core.h
**
**      Copyright (c) 2004-2006, United States government as represented by the 
**      administrator of the National Aeronautics Space Administration.  
**      All rights reserved. This software was created at NASAs Goddard 
**      Space Flight Center pursuant to government contracts.
**
**      This is governed by the NASA Open Source Agreement and may be used, 
**      distributed and modified only pursuant to the terms of that agreement.
**
** Author:  Ezra Yeheksli -Code 582/Raytheon
**
** Purpose: Contains functions prototype definitions and variables declarations
**          for the OS Abstraction Layer, Core OS module
**
** $Revision: 1.8 $ 
**
** $Date: 2013/07/25 10:02:00GMT-05:00 $
**
** $Log: osapi-os-core.h  $
** Revision 1.8 2013/07/25 10:02:00GMT-05:00 acudmore 
** removed circular include "osapi.h"
** Revision 1.7 2012/04/11 09:30:48GMT-05:00 acudmore 
** Added OS_printf_enable and OS_printf_disable
** Revision 1.6 2010/11/12 12:00:17EST acudmore 
** replaced copyright character with (c) and added open source notice where needed.
** Revision 1.5 2010/11/10 15:33:14EST acudmore 
** Updated IntAttachHandler prototype
** Revision 1.4 2010/03/08 12:06:28EST acudmore 
** added function pointer type to get rid of warnings
** Revision 1.3 2010/02/01 12:37:15EST acudmore 
** added return code to OS API init
** Revision 1.2 2009/08/04 10:49:09EDT acudmore 
**   
*/

#ifndef _osapi_core_
#define _osapi_core_

#include <stdarg.h>   /* for va_list */

/*difines constants for OS_BinSemCreate for state of semaphore  */
#define OS_SEM_FULL     1
#define OS_SEM_EMPTY    0

/* #define for enabling floating point operations on a task*/
#define OS_FP_ENABLED 1

/*  tables for the properties of objects */

/*tasks */
typedef struct
{
    char name [OS_MAX_API_NAME];
    uint32 creator;
    uint32 stack_size;
    uint32 priority;
    uint32 OStask_id;
}OS_task_prop_t;
    
/* queues */
typedef struct
{
    char name [OS_MAX_API_NAME];
    uint32 creator;
}OS_queue_prop_t;

/* Binary Semaphores */
typedef struct
{                     
    char name [OS_MAX_API_NAME];
    uint32 creator;
    int32  value;
}OS_bin_sem_prop_t;

/* Counting Semaphores */
typedef struct
{                     
    char name [OS_MAX_API_NAME];
    uint32 creator;
    int32 value;
}OS_count_sem_prop_t;

/* Mutexes */
typedef struct
{
    char name [OS_MAX_API_NAME];
    uint32 creator;
}OS_mut_sem_prop_t;


/* struct for OS_GetLocalTime() */

typedef struct 
{ 
    uint32 seconds; 
    uint32 microsecs;
}OS_time_t; 

/* heap info */
typedef struct
{
    uint32 free_bytes;
    uint32 free_blocks;
    uint32 largest_free_block;
}OS_heap_prop_t;


/* This typedef is for the OS_GetErrorName function, to ensure
 * everyone is making an array of the same length */

typedef char os_err_name_t[35];

/*
** These typedefs are for the task entry point
*/
typedef void osal_task;
typedef osal_task ((*osal_task_entry)(void));

/*
** Exported Functions
*/

/*
** Initialization of API
*/
int32 OS_API_Init (void);


/*
** Task API
*/

int32 OS_TaskCreate            (uint32 *task_id, const char *task_name, 
                                osal_task_entry function_pointer,
                                const uint32 *stack_pointer, 
                                uint32 stack_size,
                                uint32 priority, uint32 flags);

int32 OS_TaskDelete            (uint32 task_id); 
void OS_TaskExit               (void);
int32 OS_TaskInstallDeleteHandler(void *function_pointer);
int32 OS_TaskDelay             (uint32 millisecond);
int32 OS_TaskSetPriority       (uint32 task_id, uint32 new_priority);
int32 OS_TaskRegister          (void);
uint32 OS_TaskGetId            (void);
int32 OS_TaskGetIdByName       (uint32 *task_id, const char *task_name);
int32 OS_TaskGetInfo           (uint32 task_id, OS_task_prop_t *task_prop);          

/*
** Message Queue API
*/

/*
** Queue Create now has the Queue ID returned to the caller.
*/
int32 OS_QueueCreate           (uint32 *queue_id, const char *queue_name,
                                uint32 queue_depth, uint32 data_size, uint32 flags);
int32 OS_QueueDelete           (uint32 queue_id);
int32 OS_QueueGet              (uint32 queue_id, void *data, uint32 size, 
                                uint32 *size_copied, int32 timeout);
int32 OS_QueuePut              (uint32 queue_id, void *data, uint32 size, 
                                uint32 flags);
int32 OS_QueueGetIdByName      (uint32 *queue_id, const char *queue_name);
int32 OS_QueueGetInfo          (uint32 queue_id, OS_queue_prop_t *queue_prop);

/*
** Semaphore API
*/

int32 OS_BinSemCreate          (uint32 *sem_id, const char *sem_name, 
                                uint32 sem_initial_value, uint32 options);
int32 OS_BinSemFlush            (uint32 sem_id);
int32 OS_BinSemGive            (uint32 sem_id);
int32 OS_BinSemTake            (uint32 sem_id);
int32 OS_BinSemTimedWait       (uint32 sem_id, uint32 msecs);
int32 OS_BinSemDelete          (uint32 sem_id);
int32 OS_BinSemGetIdByName     (uint32 *sem_id, const char *sem_name);
int32 OS_BinSemGetInfo         (uint32 sem_id, OS_bin_sem_prop_t *bin_prop);

int32 OS_CountSemCreate          (uint32 *sem_id, const char *sem_name, 
                                uint32 sem_initial_value, uint32 options);
int32 OS_CountSemGive            (uint32 sem_id);
int32 OS_CountSemTake            (uint32 sem_id);
int32 OS_CountSemTimedWait       (uint32 sem_id, uint32 msecs);
int32 OS_CountSemDelete          (uint32 sem_id);
int32 OS_CountSemGetIdByName     (uint32 *sem_id, const char *sem_name);
int32 OS_CountSemGetInfo         (uint32 sem_id, OS_count_sem_prop_t *count_prop);

/*
** Mutex API
*/

int32 OS_MutSemCreate           (uint32 *sem_id, const char *sem_name, uint32 options);
int32 OS_MutSemGive             (uint32 sem_id);
int32 OS_MutSemTake             (uint32 sem_id);
int32 OS_MutSemDelete           (uint32 sem_id);  
int32 OS_MutSemGetIdByName      (uint32 *sem_id, const char *sem_name); 
int32 OS_MutSemGetInfo          (uint32 sem_id, OS_mut_sem_prop_t *mut_prop);

/*
** OS Time/Tick related API
*/

int32 OS_Milli2Ticks           (uint32 milli_seconds);
int32 OS_Tick2Micros           (void);
int32  OS_GetLocalTime         (OS_time_t *time_struct);
int32  OS_SetLocalTime         (OS_time_t *time_struct);  

/*
** Exception API
*/

int32 OS_ExcAttachHandler      (uint32 ExceptionNumber, 
                                void (*ExceptionHandler)(uint32, uint32 *,uint32), 
                                int32 parameter);
int32 OS_ExcEnable             (int32 ExceptionNumber);
int32 OS_ExcDisable            (int32 ExceptionNumber);

/*
** Floating Point Unit API
*/

int32 OS_FPUExcAttachHandler   (uint32 ExceptionNumber, void * ExceptionHandler ,
                                 int32 parameter);
int32 OS_FPUExcEnable          (int32 ExceptionNumber);
int32 OS_FPUExcDisable         (int32 ExceptionNumber);
int32 OS_FPUExcSetMask         (uint32 mask);
int32 OS_FPUExcGetMask         (uint32 *mask);

/*
** Interrupt API
*/
int32 OS_IntAttachHandler  (uint32 InterruptNumber, osal_task_entry InterruptHandler, int32 parameter);
int32 OS_IntUnlock         (int32 IntLevel);
int32 OS_IntLock           (void);

int32 OS_IntEnable         (int32 Level);
int32 OS_IntDisable        (int32 Level);

int32 OS_IntSetMask        (uint32 mask);
int32 OS_IntGetMask        (uint32 *mask);
int32 OS_IntAck             (int32 InterruptNumber);

/*
** Shared memory API 
*/
int32 OS_ShMemInit          (void);
int32 OS_ShMemCreate        (uint32 *Id, uint32 NBytes, char* SegName);
int32 OS_ShMemSemTake       (uint32 Id);
int32 OS_ShMemSemGive       (uint32 Id);
int32 OS_ShMemAttach        (uint32 * Address, uint32 Id);
int32 OS_ShMemGetIdByName   (uint32 *ShMemId, const char *SegName );

/*
** Heap API
*/
int32 OS_HeapGetInfo       (OS_heap_prop_t *heap_prop);

/*
** API for useful debugging function
*/
int32 OS_GetErrorName      (int32 error_num, os_err_name_t* err_name);


/* 
** Abstraction for printf statements 
*/
void OS_printf( const char *string, ...);
void OS_printf_disable(void);
void OS_printf_enable(void);

#endif