| 1 | /**************************************************************************** |
|---|
| 2 | * Copyright (C) 2004, 2005, 2006 v2lin Team <http://v2lin.sf.net> |
|---|
| 3 | * Copyright (C) 2000,2001 Monta Vista Software Inc. |
|---|
| 4 | * |
|---|
| 5 | * This file is part of the v2lin Library. |
|---|
| 6 | * VxWorks is a registered trademark of Wind River Systems, Inc. |
|---|
| 7 | * |
|---|
| 8 | * Initial implementation Gary S. Robertson, 2000, 2001. |
|---|
| 9 | * Contributed by Andrew Skiba, skibochka@sourceforge.net, 2004. |
|---|
| 10 | * Contributed by Mike Kemelmakher, mike@ubxess.com, 2005. |
|---|
| 11 | * Contributed by Constantine Shulyupin, conan.sh@gmail.com, 2006. |
|---|
| 12 | * |
|---|
| 13 | * The v2lin library is free software; you can redistribute it and/or |
|---|
| 14 | * modify it under the terms of the GNU Lesser General Public |
|---|
| 15 | * License as published by the Free Software Foundation; either |
|---|
| 16 | * version 2.1 of the License, or (at your option) any later version. |
|---|
| 17 | * |
|---|
| 18 | * The v2lin Library is distributed in the hope that it will be useful, |
|---|
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 21 | * Lesser General Public License for more details. |
|---|
| 22 | * |
|---|
| 23 | ****************************************************************************/ |
|---|
| 24 | |
|---|
| 25 | #ifndef __VXW_HDRS_H |
|---|
| 26 | #define __VXW_HDRS_H |
|---|
| 27 | |
|---|
| 28 | #include <sys/types.h> |
|---|
| 29 | #include "vxw_defs.h" |
|---|
| 30 | #include "v2lpthread.h" |
|---|
| 31 | |
|---|
| 32 | __BEGIN_DECLS; |
|---|
| 33 | |
|---|
| 34 | /* |
|---|
| 35 | ** Object Compatibility data types |
|---|
| 36 | ** |
|---|
| 37 | ** These data types are defined here to provide source code compatibility with |
|---|
| 38 | ** existing vxWorks code. NOTE that they do not necessarily correspond to the |
|---|
| 39 | ** actual Wind River definitions for the defined types, nor to the actual |
|---|
| 40 | ** types of the objects they reference as defined in the v2pthreads |
|---|
| 41 | ** environment. THIS MAY CAUSE LINKER ERRORS IF TYPE-SAFE LINKAGE IS USED! |
|---|
| 42 | ** It works okay with standard ANSII C-style linkage, however. |
|---|
| 43 | */ |
|---|
| 44 | |
|---|
| 45 | /***************************************************************************** |
|---|
| 46 | ** Control block for v2pthread watchdog timer |
|---|
| 47 | ** |
|---|
| 48 | ** These watchdog timers provide a means of executing delayed or cyclic |
|---|
| 49 | ** functions. They are inherently 'one-shot' timers. For cyclic operation, |
|---|
| 50 | ** the timeout handler function must call wdStart to restart the timer. |
|---|
| 51 | ** In the v2pthreads environment, these timers execute from the |
|---|
| 52 | ** context of the system exception task rather tha the timer interrupt. |
|---|
| 53 | *****************************************************************************/ |
|---|
| 54 | typedef struct v2pt_mqueue * MSG_Q_ID; |
|---|
| 55 | typedef struct v2lsem *SEM_ID; |
|---|
| 56 | typedef struct v2pt_wdog *WDOG_ID; |
|---|
| 57 | typedef int SEM_B_STATE; |
|---|
| 58 | //typedef void *FUNCPTR; |
|---|
| 59 | typedef int (*FUNCPTR) (int, int, int, int, int, int, int, int, int, int); |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | // This function must be called ASAP in main() |
|---|
| 63 | extern int v2lin_init(void); |
|---|
| 64 | |
|---|
| 65 | /* |
|---|
| 66 | ** Round-Robin Scheduling Control |
|---|
| 67 | ** |
|---|
| 68 | ** The following three functions are unique to v2pthreads. |
|---|
| 69 | ** They are used to manipulate a global system setting which affects all |
|---|
| 70 | ** tasks spawned or initialized after the round-robin control call is made. |
|---|
| 71 | ** They have no effect on tasks spawned or initialized prior to the call. |
|---|
| 72 | ** Round-Robin scheduling causes tasks at the same priority level to be |
|---|
| 73 | ** scheduled on a 'time-sliced' basis within that priority level, so that |
|---|
| 74 | ** all tasks at a given priority level get an equal opportunity to execute. |
|---|
| 75 | ** Round-robin scheduling is TURNED OFF by default. |
|---|
| 76 | */ |
|---|
| 77 | |
|---|
| 78 | extern void disableRoundRobin(void); |
|---|
| 79 | extern void enableRoundRobin(void); |
|---|
| 80 | extern BOOL roundRobinIsEnabled(void); |
|---|
| 81 | extern STATUS kernelTimeSlice(int ticks_per_quantum); |
|---|
| 82 | |
|---|
| 83 | /* |
|---|
| 84 | ** taskLib Function Prototypes |
|---|
| 85 | */ |
|---|
| 86 | |
|---|
| 87 | #if TO_BE_DELETED |
|---|
| 88 | extern int taskSpawn(char *name, int pri, int opts, int stksize, FUNCPTR entry, int arg1, |
|---|
| 89 | int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, |
|---|
| 90 | int arg9, int arg10); |
|---|
| 91 | |
|---|
| 92 | extern STATUS taskInit(WIND_TCB * task, char *name, int pri, |
|---|
| 93 | int opts, char *pstack, int stksize, FUNCPTR entry, int arg1, int arg2, |
|---|
| 94 | int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, |
|---|
| 95 | int arg10); |
|---|
| 96 | |
|---|
| 97 | STATUS taskActivate(int taskId); |
|---|
| 98 | STATUS taskDelete(int taskId); |
|---|
| 99 | STATUS taskDeleteForce(int taskId); |
|---|
| 100 | STATUS taskSuspend(int taskId); |
|---|
| 101 | STATUS taskResume(int taskId); |
|---|
| 102 | STATUS taskRestart(int taskId); |
|---|
| 103 | STATUS taskPrioritySet(int taskId, int priority); |
|---|
| 104 | STATUS taskPriorityGet(int taskId, int *priority); |
|---|
| 105 | STATUS taskLock(void); |
|---|
| 106 | STATUS taskUnlock(void); |
|---|
| 107 | STATUS taskSafe(void); |
|---|
| 108 | STATUS taskUnsafe(void); |
|---|
| 109 | STATUS taskDelay(int ticks_to_wait); |
|---|
| 110 | char *taskName(int taskId); |
|---|
| 111 | int taskNameToId(char *task_name); |
|---|
| 112 | STATUS taskIdVerify(int taskId); |
|---|
| 113 | int taskIdSelf(void); |
|---|
| 114 | int taskIdDefault(int taskId); |
|---|
| 115 | BOOL taskIsReady(int taskId); |
|---|
| 116 | BOOL taskIsSuspended(int taskId); |
|---|
| 117 | WIND_TCB *taskTcb(int taskId); |
|---|
| 118 | int taskIdListGet(int list[], int maxIds); |
|---|
| 119 | #endif |
|---|
| 120 | |
|---|
| 121 | /* |
|---|
| 122 | ** msgQLib Function Prototypes |
|---|
| 123 | */ |
|---|
| 124 | extern MSG_Q_ID msgQCreate(int max_msgs, int msglen, int opt); |
|---|
| 125 | extern STATUS msgQDelete(MSG_Q_ID queue); |
|---|
| 126 | extern STATUS msgQSend(MSG_Q_ID queue, char *msg, uint msglen, int wait, int pri); |
|---|
| 127 | extern int msgQReceive(MSG_Q_ID queue, char *msgbuf, uint buflen, int max_wait); |
|---|
| 128 | extern int msgQNumMsgs(MSG_Q_ID queue); |
|---|
| 129 | |
|---|
| 130 | /* |
|---|
| 131 | ** semLib Function Prototypes |
|---|
| 132 | */ |
|---|
| 133 | extern STATUS semGive(SEM_ID semaphore); |
|---|
| 134 | extern STATUS semTake(SEM_ID semaphore, int max_wait); |
|---|
| 135 | extern STATUS semFlush(SEM_ID semaphore); |
|---|
| 136 | extern STATUS semDelete(SEM_ID semaphore); |
|---|
| 137 | extern SEM_ID semBCreate(int opt, SEM_B_STATE initial_state); |
|---|
| 138 | extern SEM_ID semCCreate(int opt, int initial_count); |
|---|
| 139 | extern SEM_ID semMCreate(int opt); |
|---|
| 140 | extern STATUS semMGiveForce(SEM_ID semaphore); |
|---|
| 141 | |
|---|
| 142 | /* |
|---|
| 143 | ** wdLib Function Prototypes |
|---|
| 144 | */ |
|---|
| 145 | extern STATUS wdCancel(WDOG_ID wdId); |
|---|
| 146 | extern WDOG_ID wdCreate(void); |
|---|
| 147 | extern STATUS wdDelete(WDOG_ID wdId); |
|---|
| 148 | extern STATUS wdStart(WDOG_ID wdId, int delay, void (*f) (int), int parm); |
|---|
| 149 | |
|---|
| 150 | // additinal utility functions |
|---|
| 151 | |
|---|
| 152 | int semList(FILE * out, int mem); |
|---|
| 153 | int taskList(FILE * out, int mem); |
|---|
| 154 | int msgQList(FILE * out,int mem); |
|---|
| 155 | int wdogShow(FILE * out); |
|---|
| 156 | char * VxWorksError(STATUS status); |
|---|
| 157 | |
|---|
| 158 | __END_DECLS; |
|---|
| 159 | #endif // __VXW_HDRS_H |
|---|