pos_nano.h

Go to the documentation of this file.
00001 /*
00002  *  Copyright (c) 2004-2006, Dennis Kuschel.
00003  *  All rights reserved. 
00004  *
00005  *  Redistribution and use in source and binary forms, with or without
00006  *  modification, are permitted provided that the following conditions
00007  *  are met:
00008  *
00009  *   1. Redistributions of source code must retain the above copyright
00010  *      notice, this list of conditions and the following disclaimer.
00011  *   2. Redistributions in binary form must reproduce the above copyright
00012  *      notice, this list of conditions and the following disclaimer in the
00013  *      documentation and/or other materials provided with the distribution.
00014  *   3. The name of the author may not be used to endorse or promote
00015  *      products derived from this software without specific prior written
00016  *      permission. 
00017  *
00018  *  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
00019  *  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00020  *  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021  *  ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
00022  *  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00023  *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00024  *  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00025  *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00026  *  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
00028  *  OF THE POSSIBILITY OF SUCH DAMAGE.
00029  *
00030  */
00031 
00032 
00044 #ifndef _POS_NANO_H
00045 #define _POS_NANO_H
00046 
00047 #ifndef DOX
00048 #define DOX  0
00049 #endif
00050 
00051 
00052 
00053 /*---------------------------------------------------------------------------
00054  *  NANO LAYER INSTALLATION
00055  *-------------------------------------------------------------------------*/
00056 
00057 /* include configuration files */
00058 #ifndef _PICOOS_H
00059 #include <port.h>
00060 #include <poscfg.h>
00061 #endif
00062 #include <noscfg.h>
00063 
00064 
00065 #ifndef NOSCFG_FEATURE_REGISTRY
00066 #define NOSCFG_FEATURE_REGISTRY  0
00067 #endif
00068 
00069 #if POSCFG_TASKSTACKTYPE==0
00070 #define NOS_NEEDTASKEXITHOOK
00071 #else
00072 #if NOSCFG_FEATURE_REGISTRY!=0
00073 #define NOS_NEEDTASKEXITHOOK
00074 #endif
00075 #endif
00076 
00077 #ifdef NOS_NEEDTASKEXITHOOK
00078 
00079 /* define hook */
00080 #ifdef POSCFG_TASKEXIT_HOOK
00081 #undef POSCFG_TASKEXIT_HOOK
00082 #endif
00083 #define POSCFG_TASKEXIT_HOOK  1
00084 
00085 /* set additional task data for the nano layer */
00086 #define NOS_TASKDATA  void *nosstkroot;
00087 
00088 #endif /* NOS_NEEDTASKEXITHOOK */
00089 
00090 /* include pico]OS header if not yet done */
00091 #ifndef _PICOOS_H
00092 #include <picoos.h>
00093 #endif
00094 
00095 
00096 
00097 /*---------------------------------------------------------------------------
00098  *  CONFIGURATION
00099  *-------------------------------------------------------------------------*/
00100 
00101 #ifndef NOSCFG_FEATURE_MEMALLOC
00102 #error  NOSCFG_FEATURE_MEMALLOC not defined
00103 #endif
00104 #ifndef NOSCFG_FEATURE_CONIN
00105 #error  NOSCFG_FEATURE_CONIN not defined
00106 #endif
00107 #ifndef NOSCFG_FEATURE_CONOUT
00108 #error  NOSCFG_FEATURE_CONOUT not defined
00109 #endif
00110 #ifndef NOSCFG_CONOUT_HANDSHAKE
00111 #error  NOSCFG_CONOUT_HANDSHAKE not defined
00112 #endif
00113 #ifndef NOSCFG_CONOUT_FIFOSIZE
00114 #error  NOSCFG_CONOUT_FIFOSIZE not defined
00115 #endif
00116 #ifndef NOSCFG_FEATURE_PRINTF
00117 #error  NOSCFG_FEATURE_PRINTF not defined
00118 #endif
00119 #ifndef NOSCFG_FEATURE_SPRINTF
00120 #error  NOSCFG_FEATURE_SPRINTF not defined
00121 #endif
00122 #ifndef NOSCFG_FEATURE_TASKCREATE
00123 #error  NOSCFG_FEATURE_TASKCREATE not defined
00124 #endif
00125 #ifndef NOSCFG_DEFAULT_STACKSIZE
00126 #error  NOSCFG_DEFAULT_STACKSIZE not defined in the port configuration file
00127 #endif
00128 #ifndef NOSCFG_STACK_GROWS_UP
00129 #error  NOSCFG_STACK_GROWS_UP not defined in the port configuration file
00130 #endif
00131 #ifndef NOSCFG_MEM_MANAGE_MODE
00132 #error  NOSCFG_MEM_MANAGE_MODE not defined
00133 #endif
00134 #ifndef NOSCFG_FEATURE_MEMSET
00135 #error  NOSCFG_FEATURE_MEMSET not defined
00136 #endif
00137 #ifndef NOSCFG_FEATURE_MEMCOPY
00138 #error  NOSCFG_FEATURE_MEMCOPY not defined
00139 #endif
00140 #ifndef NOSCFG_STKMEM_RESERVE
00141 #error  NOSCFG_STKMEM_RESERVE not defined
00142 #endif
00143 #if NOSCFG_MEM_MANAGER_TYPE == 2
00144 #ifndef NOSCFG_MEM_USER_MALLOC
00145 #error  NOSCFG_MEM_USER_MALLOC not defined
00146 #endif
00147 #ifndef NOSCFG_MEM_USER_FREE
00148 #error  NOSCFG_MEM_USER_FREE not defined
00149 #endif
00150 #endif
00151 #ifndef NOSCFG_FEATURE_BOTTOMHALF
00152 #error  NOSCFG_FEATURE_BOTTOMHALF not defined
00153 #endif
00154 #if NOSCFG_FEATURE_BOTTOMHALF != 0
00155 #ifndef NOS_MAX_BOTTOMHALFS
00156 #error  NOS_MAX_BOTTOMHALFS not defined
00157 #endif
00158 #if (NOS_MAX_BOTTOMHALFS == 0) || (NOS_MAX_BOTTOMHALFS > MVAR_BITS)
00159 #error NOS_MAX_BOTTOMHALFS must be in the range 1 .. MVAR_BITS
00160 #endif
00161 #endif
00162 #ifndef NOSCFG_FEATURE_CPUUSAGE
00163 #error  NOSCFG_FEATURE_CPUUSAGE not defined
00164 #endif
00165 
00166 #if NOSCFG_FEATURE_REGISTRY
00167 #ifndef NOSCFG_FEATURE_REGQUERY
00168 #error  NOSCFG_FEATURE_REGQUERY
00169 #endif
00170 #ifndef NOSCFG_FEATURE_USERREG
00171 #error  NOSCFG_FEATURE_USERREG
00172 #endif
00173 #ifndef NOS_MAX_REGKEYLEN
00174 #error  NOS_MAX_REGKEYLEN
00175 #endif
00176 #if NOS_MAX_REGKEYLEN < 4
00177 #error NOS_MAX_REGKEYLEN must be at least 4
00178 #endif
00179 #ifndef NOS_REGKEY_PREALLOC
00180 #error  NOS_REGKEY_PREALLOC
00181 #endif
00182 #else /* NOSCFG_FEATURE_REGISTRY */
00183 #ifdef NOSCFG_FEATURE_USERREG
00184 #undef NOSCFG_FEATURE_USERREG
00185 #endif
00186 #define NOSCFG_FEATURE_USERREG 0
00187 #ifdef NOSCFG_FEATURE_REGQUERY
00188 #undef NOSCFG_FEATURE_REGQUERY
00189 #endif
00190 #define NOSCFG_FEATURE_REGQUERY 0
00191 #endif  /* NOSCFG_FEATURE_REGISTRY */
00192 
00193 #ifndef NOSCFG_FEATURE_SEMAPHORES
00194 #define NOSCFG_FEATURE_SEMAPHORES  0
00195 #endif
00196 
00197 #if NOSCFG_FEATURE_SEMAPHORES != 0  &&  POSCFG_FEATURE_SEMAPHORES == 0
00198 #error NOSCFG_FEATURE_SEMAPHORES enabled, but pico]OS semaphores disabled
00199 #endif
00200 
00201 #ifndef NOSCFG_FEATURE_MUTEXES
00202 #define NOSCFG_FEATURE_MUTEXES  0
00203 #endif
00204 #if NOSCFG_FEATURE_MUTEXES != 0  &&  POSCFG_FEATURE_MUTEXES == 0
00205 #error NOSCFG_FEATURE_MUTEXES enabled, but pico]OS mutexes disabled
00206 #endif
00207 
00208 #ifndef NOSCFG_FEATURE_MSGBOXES
00209 #define NOSCFG_FEATURE_MSGBOXES  0
00210 #endif
00211 #if NOSCFG_FEATURE_MSGBOXES != 0  &&  POSCFG_FEATURE_MSGBOXES == 0
00212 #error NOSCFG_FEATURE_MSGBOXES enabled, but pico]OS message boxes disabled
00213 #endif
00214 
00215 #ifndef NOSCFG_FEATURE_FLAGS
00216 #define NOSCFG_FEATURE_FLAGS  0
00217 #endif
00218 #if NOSCFG_FEATURE_FLAGS != 0  &&  POSCFG_FEATURE_FLAGS == 0
00219 #error NOSCFG_FEATURE_FLAGS enabled, but pico]OS flag functions disabled
00220 #endif
00221 
00222 #ifndef NOSCFG_FEATURE_TIMER
00223 #define NOSCFG_FEATURE_TIMER  0
00224 #endif
00225 #if NOSCFG_FEATURE_TIMER != 0  &&  POSCFG_FEATURE_TIMER == 0
00226 #error NOSCFG_FEATURE_TIMER enabled, but pico]OS timer functions disabled
00227 #endif
00228 
00229 #ifndef NOSCFG_MEM_OVWR_STANDARD
00230 #define NOSCFG_MEM_OVWR_STANDARD  1
00231 #endif
00232 #ifndef NOSCFG_FEATURE_REALLOC
00233 #define NOSCFG_FEATURE_REALLOC    0
00234 #endif
00235 
00236 
00237 
00238 /*---------------------------------------------------------------------------
00239  *  DATA TYPES
00240  *-------------------------------------------------------------------------*/
00241 
00242 #if DOX!=0 || NOSCFG_FEATURE_BOTTOMHALF != 0
00243 
00250 typedef void (*NOSBHFUNC_t)(void* arg, UVAR_t bh);
00251 #endif
00252 
00253 
00254 
00255 /*---------------------------------------------------------------------------
00256  *  MEMORY MANAGEMENT
00257  *-------------------------------------------------------------------------*/
00258 
00271 #ifdef _N_MEM_C
00272 #define NANOEXT
00273 #else
00274 #define NANOEXT extern
00275 #endif
00276 
00277 #if DOX!=0 || NOSCFG_FEATURE_MEMALLOC != 0
00278 
00292 NANOEXT void* POSCALL nosMemAlloc(UINT_t size);
00293 
00302 NANOEXT void POSCALL nosMemFree(void *p);
00303 
00304 
00305 #if DOX!=0 || NOSCFG_FEATURE_REALLOC != 0
00306 
00322 NANOEXT void POSCALL *nosMemRealloc(void *memblock, UINT_t size);
00323 #endif
00324 
00325 /* overwrite standard memory allocation functions */
00326 #ifndef NANOINTERNAL
00327 #if NOSCFG_MEM_OVWR_STANDARD != 0
00328 #ifdef malloc
00329 #undef malloc
00330 #endif
00331 #ifdef calloc
00332 #undef calloc
00333 #endif
00334 #ifdef free
00335 #undef free
00336 #endif
00337 #define malloc  nosMemAlloc
00338 #define calloc  (not_supported)
00339 #define free    nosMemFree
00340 #endif /* NOSCFG_MEM_OVWR_STANDARD */
00341 #else /* NANOINTERNAL */
00342 /* internal malloc/free, used by OS core and platform ports */
00343 #if NOSCFG_MEM_MANAGER_TYPE == 0
00344 #define NOS_MEM_ALLOC(x)   malloc((size_t)(x))
00345 #define NOS_MEM_FREE(x)    free(x)
00346 #elif   NOSCFG_MEM_MANAGER_TYPE == 1
00347 void*   nos_malloc(UINT_t size);
00348 void    nos_free(void *mp);
00349 #define NOS_MEM_ALLOC(x)   nos_malloc(x)
00350 #define NOS_MEM_FREE(x)    nos_free(x)
00351 #elif   NOSCFG_MEM_MANAGER_TYPE == 2
00352 #define NOS_MEM_ALLOC(x)   NOSCFG_MEM_USER_MALLOC(x)
00353 #define NOS_MEM_FREE(x)    NOSCFG_MEM_USER_FREE(x)
00354 #endif
00355 #endif /* NANOINTERNAL */
00356 
00357 #endif /* NOSCFG_FEATURE_MEMALLOC */
00358 
00359 #if DOX!=0 || NOSCFG_FEATURE_MEMSET != 0
00360 
00372 NANOEXT void POSCALL nosMemSet(void *buf, char val, UINT_t count);
00373 
00374 #if NOSCFG_MEM_OVWR_STANDARD != 0
00375 #ifdef memset
00376 #undef memset
00377 #endif
00378 #define memset  nosMemSet
00379 #endif
00380 
00381 #endif /* NOSCFG_FEATURE_MEMSET */
00382 
00383 #if DOX!=0 || NOSCFG_FEATURE_MEMCOPY != 0
00384 
00396 NANOEXT void POSCALL nosMemCopy(void *dst, void *src, UINT_t count);
00397 
00398 #if NOSCFG_MEM_OVWR_STANDARD != 0
00399 #ifdef memcpy
00400 #undef memcpy
00401 #endif
00402 #define memcpy  nosMemCopy
00403 #endif
00404 
00405 #endif /* NOSCFG_FEATURE_MEMCOPY */
00406 #undef NANOEXT
00407 
00411 /*---------------------------------------------------------------------------
00412  *  CONSOLE INPUT / OUTPUT
00413  *-------------------------------------------------------------------------*/
00414 
00435 #ifdef _N_CONIO_C
00436 #define NANOEXT
00437 #else
00438 #define NANOEXT extern
00439 #endif
00440 
00441 #if DOX!=0 || NOSCFG_FEATURE_CONIN != 0
00442 
00454 NANOEXT void POSCALL c_nos_keyinput(UVAR_t key);
00455 
00465 NANOEXT char POSCALL nosKeyGet(void);
00466 
00476 NANOEXT UVAR_t POSCALL nosKeyPressed(void);
00477 
00478 #endif  /* NOSCFG_FEATURE_CONIN */
00479 
00480 
00481 #if DOX!=0 || NOSCFG_FEATURE_CONOUT != 0
00482 
00503 NANOEXT UVAR_t POSCALL p_putchar(char c); 
00504 #endif
00505 
00506 
00507 #if DOX!=0 || NOSCFG_CONOUT_HANDSHAKE != 0
00508 
00529 NANOEXT void POSCALL c_nos_putcharReady(void);
00530 #endif
00531 
00532 
00533 #if DOX!=0 || NOSCFG_FEATURE_CONOUT != 0
00534 
00543 NANOEXT void POSCALL nosPrintChar(char c);
00544 
00554 NANOEXT void POSCALL nosPrint(const char *s);
00555 
00556 #endif
00557 
00558 #if NOSCFG_FEATURE_CONOUT == 0
00559 #if NOSCFG_FEATURE_PRINTF != 0
00560 #undef  NOSCFG_FEATURE_PRINTF
00561 #define NOSCFG_FEATURE_PRINTF  0
00562 #endif
00563 #endif
00564 
00565 #if NOSCFG_FEATURE_PRINTF != 0 || NOSCFG_FEATURE_SPRINTF != 0
00566 typedef void* NOSARG_t;
00567 #endif
00568 
00569 
00570 #if DOX!=0 || ((NOSCFG_FEATURE_CONOUT != 0)&&(NOSCFG_FEATURE_PRINTF != 0))
00571 
00572 NANOEXT void POSCALL n_printFormattedN(const char *fmt, NOSARG_t args);
00573 
00574 #if DOX
00575 
00590 NANOEXT void POSCALL nosPrintf1(const char *fmt, arg a1);
00591 
00592 #else /* DOX!=0 */
00593 #define nosPrintf1(fmt, a1)  \
00594   do { \
00595     NOSARG_t args[1]; args[0] = (NOSARG_t)(a1); \
00596     n_printFormattedN(fmt, args); \
00597   } while(0);
00598 
00599 #define nosPrintf2(fmt, a1, a2)  \
00600   do { \
00601     NOSARG_t args[2]; args[0] = (NOSARG_t)(a1); \
00602     args[1] = (NOSARG_t)(a2); \
00603     n_printFormattedN(fmt, args); \
00604   } while(0);
00605 
00606 #define nosPrintf3(fmt, a1, a2, a3)  \
00607   do { \
00608     NOSARG_t args[3]; args[0] = (NOSARG_t)(a1); \
00609     args[1] = (NOSARG_t)(a2); args[2] = (NOSARG_t)(a3); \
00610     n_printFormattedN(fmt, args); \
00611   } while(0);
00612 
00613 #define nosPrintf4(fmt, a1, a2, a3, a4)  \
00614   do { \
00615     NOSARG_t args[4]; \
00616     args[0] = (NOSARG_t)(a1); args[1] = (NOSARG_t)(a2); \
00617     args[2] = (NOSARG_t)(a3); args[3] = (NOSARG_t)(a4); \
00618     n_printFormattedN(fmt, args); \
00619   } while(0);
00620 
00621 #define nosPrintf5(fmt, a1, a2, a3, a4, a5)  \
00622   do { \
00623     NOSARG_t args[5]; args[0] = (NOSARG_t)(a1); \
00624     args[1] = (NOSARG_t)(a2); args[2] = (NOSARG_t)(a3); \
00625     args[3] = (NOSARG_t)(a4); args[4] = (NOSARG_t)(a5); \
00626     n_printFormattedN(fmt, args); \
00627   } while(0);
00628 
00629 #define nosPrintf6(fmt, a1, a2, a3, a4, a5, a6)  \
00630   do { \
00631     NOSARG_t args[6]; \
00632     args[0] = (NOSARG_t)(a1); args[1] = (NOSARG_t)(a2); \
00633     args[2] = (NOSARG_t)(a3); args[3] = (NOSARG_t)(a4); \
00634     args[4] = (NOSARG_t)(a5); args[5] = (NOSARG_t)(a6); \
00635     n_printFormattedN(fmt, args); \
00636   } while(0);
00637 
00638 #endif /* DOX!=0 */
00639 #endif /* NOSCFG_FEATURE_PRINTF */
00640 
00641 
00642 #if DOX!=0 || NOSCFG_FEATURE_SPRINTF != 0
00643 #if DOX
00644 
00659 NANOEXT void POSCALL nosSPrintf1(char *buf, const char *fmt, arg a1);
00660 
00661 #else /* DOX!=0 */
00662 
00663 NANOEXT void POSCALL n_sprintFormattedN(char *buf, const char *fmt,
00664                                         NOSARG_t args);
00665 
00666 #define nosSPrintf1(buf, fmt, a1)  \
00667   do { \
00668     NOSARG_t args[1]; args[0] = (NOSARG_t)(a1); \
00669     n_sprintFormattedN(buf, fmt, args); \
00670   } while(0);
00671 
00672 #define nosSPrintf2(buf, fmt, a1, a2)  \
00673   do { \
00674     NOSARG_t args[2]; args[0] = (NOSARG_t)(a1); \
00675     args[1] = (NOSARG_t)(a2); \
00676     n_sprintFormattedN(buf, fmt, args); \
00677   } while(0);
00678 
00679 #define nosSPrintf3(buf, fmt, a1, a2, a3)  \
00680   do { \
00681     NOSARG_t args[3]; args[0] = (NOSARG_t)(a1); \
00682     args[1] = (NOSARG_t)(a2); args[2] = (NOSARG_t)(a3); \
00683     n_sprintFormattedN(buf, fmt, args); \
00684   } while(0);
00685 
00686 #define nosSPrintf4(buf, fmt, a1, a2, a3, a4)  \
00687   do { \
00688     NOSARG_t args[4]; \
00689     args[0] = (NOSARG_t)(a1); args[1] = (NOSARG_t)(a2); \
00690     args[2] = (NOSARG_t)(a3); args[3] = (NOSARG_t)(a4); \
00691     n_sprintFormattedN(buf, fmt, args); \
00692   } while(0);
00693 
00694 #define nosSPrintf5(buf, fmt, a1, a2, a3, a4, a5)  \
00695   do { \
00696     NOSARG_t args[5]; args[0] = (NOSARG_t)(a1); \
00697     args[1] = (NOSARG_t)(a2); args[2] = (NOSARG_t)(a3); \
00698     args[3] = (NOSARG_t)(a4); args[4] = (NOSARG_t)(a5); \
00699     n_sprintFormattedN(buf, fmt, args); \
00700   } while(0);
00701 
00702 #define nosSPrintf6(buf, fmt, a1, a2, a3, a4, a5, a6)  \
00703   do { \
00704     NOSARG_t args[6]; \
00705     args[0] = (NOSARG_t)(a1); args[1] = (NOSARG_t)(a2); \
00706     args[2] = (NOSARG_t)(a3); args[3] = (NOSARG_t)(a4); \
00707     args[4] = (NOSARG_t)(a5); args[5] = (NOSARG_t)(a6); \
00708     n_sprintFormattedN(buf, fmt, args); \
00709   } while(0);
00710 
00711 #endif /* DOX!=0 */
00712 #endif /* NOSCFG_FEATURE_SPRINTF */
00713 #undef NANOEXT
00714 
00718 /*---------------------------------------------------------------------------
00719  *  BOTTOM HALFS
00720  *-------------------------------------------------------------------------*/
00721 
00740 #ifdef _N_BHALF_C
00741 #define NANOEXT
00742 #else
00743 #define NANOEXT extern
00744 #endif
00745 
00746 #if DOX!=0 || NOSCFG_FEATURE_BOTTOMHALF != 0
00747 
00766 NANOEXT VAR_t POSCALL nosBottomHalfRegister(UVAR_t number, NOSBHFUNC_t func,
00767                                             void *arg);
00768 
00778 #define nosBottomHalfUnregister(number) \
00779           nosBottomHalfRegister(number, NULL, NULL)
00780 
00793 NANOEXT void POSCALL nosBottomHalfStart(UVAR_t number);
00794 
00795 #endif /* NOSCFG_FEATURE_BOTTOMHALF */
00796 #undef NANOEXT
00797 
00801 /*---------------------------------------------------------------------------
00802  *  REGISTRY
00803  *-------------------------------------------------------------------------*/
00804 
00825 #ifdef _N_REG_C
00826 #define NANOEXT
00827 #else
00828 #define NANOEXT extern
00829 #endif
00830 
00831 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
00832 
00834 typedef void*  NOSGENERICHANDLE_t;
00835 
00838 typedef void*  NOSREGQHANDLE_t;
00839 
00840 /* Generic registry key value type.
00841    It is on the developer how he uses the type. */
00842 typedef union {
00843   void*       voidptr; 
00844   int         integer; 
00845 } KEYVALUE_t;
00846 
00848 typedef enum {
00849   REGTYPE_TASK = 0,    
00850 #if DOX!=0 || NOSCFG_FEATURE_SEMAPHORES != 0
00851   REGTYPE_SEMAPHORE,   
00852 #endif
00853 #if DOX!=0 || NOSCFG_FEATURE_MUTEXES != 0
00854   REGTYPE_MUTEX,       
00855 #endif
00856 #if DOX!=0 || NOSCFG_FEATURE_FLAGS != 0
00857   REGTYPE_FLAG,        
00858 #endif
00859 #if DOX!=0 || NOSCFG_FEATURE_TIMER != 0
00860   REGTYPE_TIMER,       
00861 #endif
00862 #if DOX!=0 || NOSCFG_FEATURE_USERREG != 0
00863   REGTYPE_USER,        
00864 #endif
00865   REGTYPE_SEARCHALL    
00867 } NOSREGTYPE_t;
00868 #define MIN_REGTYPE  REGTYPE_TASK
00869 #define MAX_REGTYPE  (REGTYPE_SEARCHALL-1)
00870 
00871 
00887 NANOEXT NOSGENERICHANDLE_t POSCALL nosGetHandleByName(
00888                                  NOSREGTYPE_t objtype, const char *objname);
00889 
00890 
00910 NANOEXT VAR_t POSCALL nosGetNameByHandle(NOSGENERICHANDLE_t handle,
00911                                          char *buffer, VAR_t bufsize,
00912                                          NOSREGTYPE_t what);
00913 
00914 #if DOX!=0  ||  NOSCFG_FEATURE_USERREG != 0
00915 
00932 NANOEXT VAR_t POSCALL nosRegSet(const char *keyname, KEYVALUE_t keyvalue);
00933 
00947 NANOEXT VAR_t POSCALL nosRegGet(const char *keyname, KEYVALUE_t *keyvalue);
00948 
00957 NANOEXT VAR_t POSCALL nosRegDel(const char *keyname);
00958 #endif
00959 
00960 #if DOX!=0 || NOSCFG_FEATURE_REGQUERY != 0
00961 
00981 NANOEXT NOSREGQHANDLE_t POSCALL nosRegQueryBegin(NOSREGTYPE_t type);
00982 
01002 NANOEXT VAR_t POSCALL nosRegQueryElem(NOSREGQHANDLE_t qh,
01003                                       NOSGENERICHANDLE_t *genh,
01004                                       char* namebuf, VAR_t bufsize);
01005 
01016 NANOEXT void POSCALL nosRegQueryEnd(NOSREGQHANDLE_t qh);
01017 #endif
01018 
01019 #endif /* NOSCFG_FEATURE_REGISTRY */
01020 #undef NANOEXT
01021 
01025 /*---------------------------------------------------------------------------
01026  *  CPU USAGE
01027  *-------------------------------------------------------------------------*/
01028 
01029 #if (DOX!=0) || (NOSCFG_FEATURE_CPUUSAGE != 0)
01030 
01044 UVAR_t POSCALL nosCpuUsage(void);
01045 #endif
01046 
01050 /*---------------------------------------------------------------------------
01051  *  ABSTRACTED FUNCTIONS
01052  *-------------------------------------------------------------------------*/
01053 
01054 #ifdef _N_CORE_C
01055 #define NANOEXT
01056 #else
01057 #define NANOEXT extern
01058 #endif
01059 
01077 typedef  POSTASK_t  NOSTASK_t;
01078 
01079 
01080 #if (DOX!=0) || (NOSCFG_FEATURE_TASKCREATE != 0)
01081 
01104 NANOEXT NOSTASK_t POSCALL nosTaskCreate(POSTASKFUNC_t funcptr,
01105                                         void *funcarg,
01106                                         VAR_t priority,
01107                                         UINT_t stacksize,
01108                                         const char* name);
01109 
01110 
01111 #if (DOX!=0) || (POSCFG_FEATURE_YIELD != 0)
01112 
01122 #if DOX
01123 NANOEXT void POSCALL nosTaskYield(void);
01124 #else
01125 #define nosTaskYield()  posTaskYield()
01126 #endif
01127 #endif
01128 
01129 #if (DOX!=0) || (POSCFG_FEATURE_SLEEP != 0)
01130 
01146 #if DOX
01147 NANOEXT void POSCALL nosTaskSleep(UINT_t ticks);
01148 #else
01149 #define nosTaskSleep(ticks)  posTaskSleep(ticks)
01150 #endif
01151 #endif
01152 
01153 #if (DOX!=0) || (POSCFG_FEATURE_EXIT != 0)
01154 
01163 #if DOX
01164 NANOEXT void POSCALL nosTaskExit(void);
01165 #else
01166 #define nosTaskExit()  posTaskExit()
01167 #endif
01168 #endif
01169 
01170 #if (DOX!=0) || (POSCFG_FEATURE_GETTASK != 0)
01171 
01181 #if DOX
01182 NANOEXT NOSTASK_t POSCALL nosTaskGetCurrent(void);
01183 #else
01184 #define nosTaskGetCurrent()  (NOSTASK_t)posTaskGetCurrent()
01185 #endif
01186 #endif
01187 
01188 #if (DOX!=0) || (POSCFG_FEATURE_TASKUNUSED != 0)
01189 
01204 #if DOX
01205 NANOEXT VAR_t POSCALL nosTaskUnused(NOSTASK_t taskhandle);
01206 #else
01207 #define nosTaskUnused(th)  posTaskUnused((POSTASK_t)(th))
01208 #endif
01209 #endif
01210 
01211 #if (DOX!=0) || (POSCFG_FEATURE_SETPRIORITY != 0)
01212 
01227 #if DOX
01228 NANOEXT VAR_t POSCALL nosTaskSetPriority(NOSTASK_t taskhandle,
01229                                          VAR_t priority);
01230 #else
01231 #define nosTaskSetPriority(th, prio) posTaskSetPriority((POSTASK_t)(th),prio)
01232 #endif
01233 #endif
01234 
01235 #if (DOX!=0) || (POSCFG_FEATURE_GETPRIORITY != 0)
01236 
01247 #if DOX
01248 NANOEXT VAR_t POSCALL nosTaskGetPriority(NOSTASK_t taskhandle);
01249 #else
01250 #define nosTaskGetPriority(th)  posTaskGetPriority((POSTASK_t)(th))
01251 #endif
01252 #endif
01253 
01254 #if (DOX!=0) || (POSCFG_FEATURE_INHIBITSCHED != 0)
01255 
01268 #if DOX
01269 NANOEXT void POSCALL nosTaskSchedLock(void);
01270 #else
01271 #define nosTaskSchedLock()  posTaskSchedLock()
01272 #endif
01273 
01285 #if DOX
01286 NANOEXT void POSCALL nosTaskSchedUnlock(void);
01287 #else
01288 #define nosTaskSchedUnlock()  posTaskSchedUnlock()
01289 #endif
01290 #endif
01291 
01292 #if (DOX!=0) || (POSCFG_TASKCB_USERSPACE > 0)
01293 
01303 #if DOX
01304 NANOEXT void* POSCALL nosTaskGetUserspace(void);
01305 #else
01306 #define nosTaskGetUserspace()  posTaskGetUserspace()
01307 #endif
01308 #endif
01309 
01310 #if (DOX!=0) || (POSCFG_FEATURE_IDLETASKHOOK != 0)
01311 
01312 typedef POSIDLEFUNC_t NOSIDLEFUNC_t;
01333 #if DOX
01334 NANOEXT NOSIDLEFUNC_t POSCALL nosInstallIdleTaskHook(NOSIDLEFUNC_t idlefunc);
01335 #else
01336 #define nosInstallIdleTaskHook(ifunc)  posInstallIdleTaskHook(ifunc)
01337 #endif
01338 #endif
01339 
01340 #endif
01341 
01349 #if DOX!=0 || NOSCFG_FEATURE_SEMAPHORES != 0
01350 
01352 typedef  POSSEMA_t  NOSSEMA_t;
01353 
01378 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
01379 NANOEXT NOSSEMA_t POSCALL nosSemaCreate(INT_t initcount, UVAR_t options,
01380                                         const char *name);
01381 #else
01382 #define nosSemaCreate(i, o, n)  (NOSSEMA_t) posSemaCreate(i);
01383 #endif
01384 
01385 #if DOX!=0 || POSCFG_FEATURE_SEMADESTROY != 0
01386 
01398 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
01399 NANOEXT void POSCALL nosSemaDestroy(NOSSEMA_t sema);
01400 #else
01401 #define nosSemaDestroy(sema)  posSemaDestroy((POSSEMA_t)(sema))
01402 #endif
01403 #endif
01404 
01405 #if DOX
01406 
01419 NANOEXT VAR_t POSCALL nosSemaSignal(NOSSEMA_t sema);
01420 #else
01421 #define nosSemaSignal(sem)  posSemaSignal((POSSEMA_t)(sem))
01422 #endif
01423 
01424 #if DOX
01425 
01439 NANOEXT VAR_t POSCALL nosSemaGet(NOSSEMA_t sema);
01440 #else
01441 #define nosSemaGet(sem)  posSemaGet((POSSEMA_t)(sem))
01442 #endif
01443 
01444 #if DOX
01445 
01467 NANOEXT VAR_t POSCALL nosSemaWait(NOSSEMA_t sema, UINT_t timeoutticks);
01468 #else
01469 #if POSCFG_FEATURE_SEMAWAIT
01470 #define nosSemaWait(sem, to)  posSemaWait((POSSEMA_t)(sem), to)
01471 #endif
01472 #endif
01473 
01474 #endif /* POSCFG_FEATURE_SEMAPHORES */
01475 
01483 #if DOX!=0 || NOSCFG_FEATURE_MUTEXES != 0
01484 
01486 typedef  POSMUTEX_t  NOSMUTEX_t;
01487 
01509 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
01510 NANOEXT NOSMUTEX_t POSCALL nosMutexCreate(UVAR_t options, const char *name);
01511 #else
01512 #define nosMutexCreate(opt, name)  (NOSMUTEX_t) posMutexCreate()
01513 #endif
01514 
01515 #if DOX!=0 || POSCFG_FEATURE_MUTEXDESTROY != 0
01516 
01528 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
01529 NANOEXT void POSCALL nosMutexDestroy(NOSMUTEX_t mutex);
01530 #else
01531 #define nosMutexDestroy(mutex)  posMutexDestroy((POSMUTEX_t)(mutex))
01532 #endif
01533 #endif
01534 
01535 #if DOX!=0 || POSCFG_FEATURE_MUTEXTRYLOCK != 0
01536 
01553 #if DOX
01554 NANOEXT VAR_t POSCALL nosMutexTryLock(NOSMUTEX_t mutex);
01555 #else
01556 #define nosMutexTryLock(mutex)  posMutexTryLock((POSMUTEX_t)(mutex))
01557 #endif
01558 #endif
01559 
01574 #if DOX
01575 NANOEXT VAR_t POSCALL nosMutexLock(NOSMUTEX_t mutex);
01576 #else
01577 #define nosMutexLock(mutex)  posMutexLock((POSMUTEX_t)(mutex))
01578 #endif
01579 
01592 #if DOX
01593 NANOEXT VAR_t POSCALL nosMutexUnlock(NOSMUTEX_t mutex);
01594 #else
01595 #define nosMutexUnlock(mutex)  posMutexUnlock((POSMUTEX_t)(mutex))
01596 #endif
01597 
01598 #endif /* NOSCFG_FEATURE_MUTEXES */
01599 
01609 #if DOX!=0 || NOSCFG_FEATURE_MSGBOXES != 0
01610 
01632 NANOEXT void* POSCALL nosMessageAlloc(UINT_t msgSize);
01633 
01643 NANOEXT void POSCALL nosMessageFree(void *buf);
01644 
01657 NANOEXT VAR_t POSCALL nosMessageSend(void *buf, NOSTASK_t taskhandle);
01658 
01673 #if DOX
01674 NANOEXT void* POSCALL nosMessageGet(void);
01675 #else
01676 #define  nosMessageGet()  posMessageGet()
01677 #endif
01678 
01679 #if DOX!=0 || POSCFG_FEATURE_MSGWAIT != 0
01680 
01704 #if DOX
01705 NANOEXT void* POSCALL nosMessageWait(UINT_t timeoutticks);
01706 #else
01707 #define nosMessageWait(to)  posMessageWait(to)
01708 #endif
01709 #endif
01710 
01725 #if DOX
01726 NANOEXT VAR_t POSCALL nosMessageAvailable(void);
01727 #else
01728 #define nosMessageAvailable()  posMessageAvailable()
01729 #endif
01730 
01731 #endif  /* NOSCFG_FEATURE_MSGBOXES */
01732 
01741 #if DOX!=0 || NOSCFG_FEATURE_FLAGS != 0
01742 
01744 typedef  POSFLAG_t  NOSFLAG_t;
01745 
01770 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
01771 NANOEXT NOSFLAG_t POSCALL nosFlagCreate(const char* name);
01772 #else
01773 #define nosFlagCreate(name)  (NOSFLAG_t) posFlagCreate()
01774 #endif
01775 
01776 #if DOX!=0 || POSCFG_FEATURE_FLAGDESTROY != 0
01777 
01789 #if (DOX!=0) || (NOSCFG_FEATURE_REGISTRY != 0)
01790 NANOEXT void POSCALL nosFlagDestroy(NOSFLAG_t flg);
01791 #else
01792 #define nosFlagDestroy(flg)  posFlagDestroy((POSFLAG_t)(flg))
01793 #endif
01794 #endif
01795 
01810 #if DOX
01811 NANOEXT VAR_t POSCALL nosFlagSet(NOSFLAG_t flg, UVAR_t flgnum);
01812 #else
01813 #define nosFlagSet(flg, num)  posFlagSet((POSFLAG_t)(flg), num)
01814 #endif
01815 
01832 #if DOX
01833 NANOEXT VAR_t POSCALL nosFlagGet(NOSFLAG_t flg, UVAR_t mode);
01834 #else
01835 #define nosFlagGet(flg, mode)  posFlagGet((POSFLAG_t)(flg), mode)
01836 #endif
01837 
01838 #if DOX!=0 || POSCFG_FEATURE_FLAGWAIT != 0
01839 
01860 #if DOX
01861 NANOEXT VAR_t POSCALL nosFlagWait(NOSFLAG_t flg, UINT_t timeoutticks);
01862 #else
01863 #define nosFlagWait(flg, to)  posFlagWait((POSFLAG_t)(flg), to)
01864 #endif
01865 #endif
01866 
01867 #define NOSFLAG_MODE_GETSINGLE  POSFLAG_MODE_GETSINGLE
01868 #define NOSFLAG_MODE_GETMASK    POSFLAG_MODE_GETMASK
01869 
01870 #endif /* NOSCFG_FEATURE_FLAGS */
01871 
01884 #if DOX!=0 || NOSCFG_FEATURE_TIMER != 0
01885 
01887 typedef  POSTIMER_t  NOSTIMER_t;
01888 
01911 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
01912 NANOEXT NOSTIMER_t POSCALL nosTimerCreate(const char *name);
01913 #else
01914 #define nosTimerCreate(name)  (NOSTIMER_t) posTimerCreate()
01915 #endif
01916 
01936 #if DOX
01937 NANOEXT VAR_t POSCALL nosTimerSet(NOSTIMER_t tmr, NOSSEMA_t sema,
01938                                   UINT_t waitticks, UINT_t periodticks);
01939 #else
01940 #define nosTimerSet(t, s, w, p) \
01941           posTimerSet((POSTIMER_t)(t), (POSSEMA_t)(s), w, p)
01942 #endif
01943 
01957 #if DOX
01958 NANOEXT VAR_t POSCALL nosTimerStart(NOSTIMER_t tmr);
01959 #else
01960 #define nosTimerStart(tmr)  posTimerStart((POSTIMER_t)(tmr))
01961 #endif
01962 
01975 #if DOX
01976 NANOEXT VAR_t POSCALL nosTimerStop(NOSTIMER_t tmr);
01977 #else
01978 #define nosTimerStop(tmr)  posTimerStop((POSTIMER_t)(tmr))
01979 #endif
01980 
01981 #if DOX!=0 || POSCFG_FEATURE_TIMERDESTROY != 0
01982 
01994 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
01995 NANOEXT void POSCALL nosTimerDestroy(NOSTIMER_t tmr);
01996 #else
01997 #define nosTimerDestroy(tmr)  posTimerDestroy((POSTIMER_t)(tmr))
01998 #endif
01999 #endif
02000 
02001 #if DOX!=0 || POSCFG_FEATURE_TIMERFIRED != 0
02002 
02016 #if DOX
02017 NANOEXT VAR_t POSCALL nosTimerFired(NOSTIMER_t tmr);
02018 #else
02019 #define nosTimerFired(tmr)  posTimerFired((POSTIMER_t)(tmr))
02020 #endif
02021 #endif
02022 
02023 #endif /* NOSCFG_FEATURE_TIMER */
02024 
02026 #undef NANOEXT
02027 
02031 /*---------------------------------------------------------------------------
02032  *  INITIALIZATION
02033  *-------------------------------------------------------------------------*/
02034 
02040 #ifdef _N_CORE_C
02041 #define NANOEXT
02042 #else
02043 #define NANOEXT extern
02044 #endif
02045 
02066 NANOEXT void POSCALL nosInit(POSTASKFUNC_t firstfunc,
02067                              void *funcarg, VAR_t priority,
02068                              UINT_t taskStackSize, UINT_t idleStackSize);
02069 
02070 #ifndef _N_CORE_C
02071 #ifndef _POSCORE_C
02072 #define posInit _Please_use_nosInit_instead_of_posInit_
02073 #endif
02074 #endif
02075 #undef NANOEXT
02076 
02078 #endif /* _POS_NANO_H */
02079 

Generated on Sat Dec 8 14:53:02 2007 for pico]OS by  doxygen 1.5.4