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* nosMemAlloc(UINT_t size);
00293 
00302 NANOEXT void  nosMemFree(void *p);
00303 
00304 
00305 #if DOX!=0 || NOSCFG_FEATURE_REALLOC != 0
00306 
00322 NANOEXT void *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 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 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  c_nos_keyinput(UVAR_t key);
00455 
00465 NANOEXT char  nosKeyGet(void);
00466 
00476 NANOEXT UVAR_t  nosKeyPressed(void);
00477 
00478 #endif  /* NOSCFG_FEATURE_CONIN */
00479 
00480 
00481 #if DOX!=0 || NOSCFG_FEATURE_CONOUT != 0
00482 
00503 NANOEXT UVAR_t  p_putchar(char c); 
00504 #endif
00505 
00506 
00507 #if DOX!=0 || NOSCFG_CONOUT_HANDSHAKE != 0
00508 
00529 NANOEXT void  c_nos_putcharReady(void);
00530 #endif
00531 
00532 
00533 #if DOX!=0 || NOSCFG_FEATURE_CONOUT != 0
00534 
00543 NANOEXT void  nosPrintChar(char c);
00544 
00554 NANOEXT void  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 n_printFormattedN(const char *fmt, NOSARG_t args);
00573 
00574 #if DOX
00575 
00590 NANOEXT void 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 nosSPrintf1(char *buf, const char *fmt, arg a1);
00660 
00661 #else /* DOX!=0 */
00662 
00663 NANOEXT void n_sprintFormattedN(char *buf, const char *fmt, NOSARG_t args);
00664 
00665 #define nosSPrintf1(buf, fmt, a1)  \
00666   do { \
00667     NOSARG_t args[1]; args[0] = (NOSARG_t)(a1); \
00668     n_sprintFormattedN(buf, fmt, args); \
00669   } while(0);
00670 
00671 #define nosSPrintf2(buf, fmt, a1, a2)  \
00672   do { \
00673     NOSARG_t args[2]; args[0] = (NOSARG_t)(a1); \
00674     args[1] = (NOSARG_t)(a2); \
00675     n_sprintFormattedN(buf, fmt, args); \
00676   } while(0);
00677 
00678 #define nosSPrintf3(buf, fmt, a1, a2, a3)  \
00679   do { \
00680     NOSARG_t args[3]; args[0] = (NOSARG_t)(a1); \
00681     args[1] = (NOSARG_t)(a2); args[2] = (NOSARG_t)(a3); \
00682     n_sprintFormattedN(buf, fmt, args); \
00683   } while(0);
00684 
00685 #define nosSPrintf4(buf, fmt, a1, a2, a3, a4)  \
00686   do { \
00687     NOSARG_t args[4]; \
00688     args[0] = (NOSARG_t)(a1); args[1] = (NOSARG_t)(a2); \
00689     args[2] = (NOSARG_t)(a3); args[3] = (NOSARG_t)(a4); \
00690     n_sprintFormattedN(buf, fmt, args); \
00691   } while(0);
00692 
00693 #define nosSPrintf5(buf, fmt, a1, a2, a3, a4, a5)  \
00694   do { \
00695     NOSARG_t args[5]; args[0] = (NOSARG_t)(a1); \
00696     args[1] = (NOSARG_t)(a2); args[2] = (NOSARG_t)(a3); \
00697     args[3] = (NOSARG_t)(a4); args[4] = (NOSARG_t)(a5); \
00698     n_sprintFormattedN(buf, fmt, args); \
00699   } while(0);
00700 
00701 #define nosSPrintf6(buf, fmt, a1, a2, a3, a4, a5, a6)  \
00702   do { \
00703     NOSARG_t args[6]; \
00704     args[0] = (NOSARG_t)(a1); args[1] = (NOSARG_t)(a2); \
00705     args[2] = (NOSARG_t)(a3); args[3] = (NOSARG_t)(a4); \
00706     args[4] = (NOSARG_t)(a5); args[5] = (NOSARG_t)(a6); \
00707     n_sprintFormattedN(buf, fmt, args); \
00708   } while(0);
00709 
00710 #endif /* DOX!=0 */
00711 #endif /* NOSCFG_FEATURE_SPRINTF */
00712 #undef NANOEXT
00713 
00717 /*---------------------------------------------------------------------------
00718  *  BOTTOM HALFS
00719  *-------------------------------------------------------------------------*/
00720 
00739 #ifdef _N_BHALF_C
00740 #define NANOEXT
00741 #else
00742 #define NANOEXT extern
00743 #endif
00744 
00745 #if DOX!=0 || NOSCFG_FEATURE_BOTTOMHALF != 0
00746 
00765 NANOEXT VAR_t  nosBottomHalfRegister(UVAR_t number, NOSBHFUNC_t func,
00766                                      void *arg);
00767 
00777 #define nosBottomHalfUnregister(number) \
00778           nosBottomHalfRegister(number, NULL, NULL)
00779 
00792 NANOEXT void nosBottomHalfStart(UVAR_t number);
00793 
00794 #endif /* NOSCFG_FEATURE_BOTTOMHALF */
00795 #undef NANOEXT
00796 
00800 /*---------------------------------------------------------------------------
00801  *  REGISTRY
00802  *-------------------------------------------------------------------------*/
00803 
00824 #ifdef _N_REG_C
00825 #define NANOEXT
00826 #else
00827 #define NANOEXT extern
00828 #endif
00829 
00830 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
00831 
00833 typedef void*  NOSGENERICHANDLE_t;
00834 
00837 typedef void*  NOSREGQHANDLE_t;
00838 
00839 /* Generic registry key value type.
00840    It is on the developer how he uses the type. */
00841 typedef union {
00842   void*       voidptr; 
00843   int         integer; 
00844 } KEYVALUE_t;
00845 
00847 typedef enum {
00848   REGTYPE_TASK = 0,    
00849 #if DOX!=0 || NOSCFG_FEATURE_SEMAPHORES != 0
00850   REGTYPE_SEMAPHORE,   
00851 #endif
00852 #if DOX!=0 || NOSCFG_FEATURE_MUTEXES != 0
00853   REGTYPE_MUTEX,       
00854 #endif
00855 #if DOX!=0 || NOSCFG_FEATURE_FLAGS != 0
00856   REGTYPE_FLAG,        
00857 #endif
00858 #if DOX!=0 || NOSCFG_FEATURE_TIMER != 0
00859   REGTYPE_TIMER,       
00860 #endif
00861 #if DOX!=0 || NOSCFG_FEATURE_USERREG != 0
00862   REGTYPE_USER,        
00863 #endif
00864   REGTYPE_SEARCHALL    
00866 } NOSREGTYPE_t;
00867 #define MIN_REGTYPE  REGTYPE_TASK
00868 #define MAX_REGTYPE  (REGTYPE_SEARCHALL-1)
00869 
00870 
00886 NANOEXT NOSGENERICHANDLE_t  nosGetHandleByName(
00887                                  NOSREGTYPE_t objtype, const char *objname);
00888 
00889 
00909 NANOEXT VAR_t nosGetNameByHandle(NOSGENERICHANDLE_t handle,
00910                                  char *buffer, VAR_t bufsize,
00911                                  NOSREGTYPE_t what);
00912 
00913 #if DOX!=0  ||  NOSCFG_FEATURE_USERREG != 0
00914 
00931 NANOEXT VAR_t nosRegSet(const char *keyname, KEYVALUE_t keyvalue);
00932 
00946 NANOEXT VAR_t nosRegGet(const char *keyname, KEYVALUE_t *keyvalue);
00947 
00956 NANOEXT VAR_t nosRegDel(const char *keyname);
00957 #endif
00958 
00959 #if DOX!=0 || NOSCFG_FEATURE_REGQUERY != 0
00960 
00980 NANOEXT NOSREGQHANDLE_t  nosRegQueryBegin(NOSREGTYPE_t type);
00981 
01001 NANOEXT VAR_t nosRegQueryElem(NOSREGQHANDLE_t qh, NOSGENERICHANDLE_t *genh,
01002                               char* namebuf, VAR_t bufsize);
01003 
01014 NANOEXT void nosRegQueryEnd(NOSREGQHANDLE_t qh);
01015 #endif
01016 
01017 #endif /* NOSCFG_FEATURE_REGISTRY */
01018 #undef NANOEXT
01019 
01023 /*---------------------------------------------------------------------------
01024  *  CPU USAGE
01025  *-------------------------------------------------------------------------*/
01026 
01027 #if (DOX!=0) || (NOSCFG_FEATURE_CPUUSAGE != 0)
01028 
01042 UVAR_t nosCpuUsage(void);
01043 #endif
01044 
01048 /*---------------------------------------------------------------------------
01049  *  ABSTRACTED FUNCTIONS
01050  *-------------------------------------------------------------------------*/
01051 
01052 #ifdef _N_CORE_C
01053 #define NANOEXT
01054 #else
01055 #define NANOEXT extern
01056 #endif
01057 
01075 typedef  POSTASK_t  NOSTASK_t;
01076 
01077 
01078 #if (DOX!=0) || (NOSCFG_FEATURE_TASKCREATE != 0)
01079 
01102 NANOEXT NOSTASK_t nosTaskCreate(POSTASKFUNC_t funcptr, void *funcarg,
01103                                 VAR_t priority, UINT_t stacksize,
01104                                 const char* name);
01105 
01106 
01107 #if (DOX!=0) || (POSCFG_FEATURE_YIELD != 0)
01108 
01118 #if DOX
01119 NANOEXT void nosTaskYield(void);
01120 #else
01121 #define nosTaskYield()  posTaskYield()
01122 #endif
01123 #endif
01124 
01125 #if (DOX!=0) || (POSCFG_FEATURE_SLEEP != 0)
01126 
01142 #if DOX
01143 NANOEXT void nosTaskSleep(UINT_t ticks);
01144 #else
01145 #define nosTaskSleep(ticks)  posTaskSleep(ticks)
01146 #endif
01147 #endif
01148 
01149 #if (DOX!=0) || (POSCFG_FEATURE_EXIT != 0)
01150 
01159 #if DOX
01160 NANOEXT void nosTaskExit(void);
01161 #else
01162 #define nosTaskExit()  posTaskExit()
01163 #endif
01164 #endif
01165 
01166 #if (DOX!=0) || (POSCFG_FEATURE_GETTASK != 0)
01167 
01177 #if DOX
01178 NANOEXT NOSTASK_t nosTaskGetCurrent(void);
01179 #else
01180 #define nosTaskGetCurrent()  (NOSTASK_t)posTaskGetCurrent()
01181 #endif
01182 #endif
01183 
01184 #if (DOX!=0) || (POSCFG_FEATURE_TASKUNUSED != 0)
01185 
01200 #if DOX
01201 NANOEXT VAR_t nosTaskUnused(NOSTASK_t taskhandle);
01202 #else
01203 #define nosTaskUnused(th)  posTaskUnused((POSTASK_t)(th))
01204 #endif
01205 #endif
01206 
01207 #if (DOX!=0) || (POSCFG_FEATURE_SETPRIORITY != 0)
01208 
01223 #if DOX
01224 NANOEXT VAR_t nosTaskSetPriority(NOSTASK_t taskhandle, VAR_t priority);
01225 #else
01226 #define nosTaskSetPriority(th, prio) posTaskSetPriority((POSTASK_t)(th),prio)
01227 #endif
01228 #endif
01229 
01230 #if (DOX!=0) || (POSCFG_FEATURE_GETPRIORITY != 0)
01231 
01242 #if DOX
01243 NANOEXT VAR_t nosTaskGetPriority(NOSTASK_t taskhandle);
01244 #else
01245 #define nosTaskGetPriority(th)  posTaskGetPriority((POSTASK_t)(th))
01246 #endif
01247 #endif
01248 
01249 #if (DOX!=0) || (POSCFG_FEATURE_INHIBITSCHED != 0)
01250 
01263 #if DOX
01264 NANOEXT void nosTaskSchedLock(void);
01265 #else
01266 #define nosTaskSchedLock()  posTaskSchedLock()
01267 #endif
01268 
01280 #if DOX
01281 NANOEXT void nosTaskSchedUnlock(void);
01282 #else
01283 #define nosTaskSchedUnlock()  posTaskSchedUnlock()
01284 #endif
01285 #endif
01286 
01287 #if (DOX!=0) || (POSCFG_TASKCB_USERSPACE > 0)
01288 
01298 #if DOX
01299 NANOEXT void* nosTaskGetUserspace(void);
01300 #else
01301 #define nosTaskGetUserspace()  posTaskGetUserspace()
01302 #endif
01303 #endif
01304 
01305 #if (DOX!=0) || (POSCFG_FEATURE_IDLETASKHOOK != 0)
01306 
01307 typedef POSIDLEFUNC_t NOSIDLEFUNC_t;
01328 #if DOX
01329 NANOEXT NOSIDLEFUNC_t nosInstallIdleTaskHook(NOSIDLEFUNC_t idlefunc);
01330 #else
01331 #define nosInstallIdleTaskHook(ifunc)  posInstallIdleTaskHook(ifunc)
01332 #endif
01333 #endif
01334 
01335 #endif
01336 
01344 #if DOX!=0 || NOSCFG_FEATURE_SEMAPHORES != 0
01345 
01347 typedef  POSSEMA_t  NOSSEMA_t;
01348 
01373 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
01374 NANOEXT NOSSEMA_t nosSemaCreate(INT_t initcount, UVAR_t options,
01375                                 const char *name);
01376 #else
01377 #define nosSemaCreate(i, o, n)  (NOSSEMA_t) posSemaCreate(i);
01378 #endif
01379 
01380 #if DOX!=0 || POSCFG_FEATURE_SEMADESTROY != 0
01381 
01393 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
01394 NANOEXT void nosSemaDestroy(NOSSEMA_t sema);
01395 #else
01396 #define nosSemaDestroy(sema)  posSemaDestroy((POSSEMA_t)(sema))
01397 #endif
01398 #endif
01399 
01400 #if DOX
01401 
01414 NANOEXT  VAR_t nosSemaSignal(NOSSEMA_t sema);
01415 #else
01416 #define nosSemaSignal(sem)  posSemaSignal((POSSEMA_t)(sem))
01417 #endif
01418 
01419 #if DOX
01420 
01434 NANOEXT VAR_t nosSemaGet(NOSSEMA_t sema);
01435 #else
01436 #define nosSemaGet(sem)  posSemaGet((POSSEMA_t)(sem))
01437 #endif
01438 
01439 #if DOX
01440 
01462 NANOEXT VAR_t nosSemaWait(NOSSEMA_t sema, UINT_t timeoutticks);
01463 #else
01464 #if POSCFG_FEATURE_SEMAWAIT
01465 #define nosSemaWait(sem, to)  posSemaWait((POSSEMA_t)(sem), to)
01466 #endif
01467 #endif
01468 
01469 #endif /* POSCFG_FEATURE_SEMAPHORES */
01470 
01478 #if DOX!=0 || NOSCFG_FEATURE_MUTEXES != 0
01479 
01481 typedef  POSMUTEX_t  NOSMUTEX_t;
01482 
01504 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
01505 NANOEXT NOSMUTEX_t nosMutexCreate(UVAR_t options, const char *name);
01506 #else
01507 #define nosMutexCreate(opt, name)  (NOSMUTEX_t) posMutexCreate()
01508 #endif
01509 
01510 #if DOX!=0 || POSCFG_FEATURE_MUTEXDESTROY != 0
01511 
01523 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
01524 NANOEXT void nosMutexDestroy(NOSMUTEX_t mutex);
01525 #else
01526 #define nosMutexDestroy(mutex)  posMutexDestroy((POSMUTEX_t)(mutex))
01527 #endif
01528 #endif
01529 
01530 #if DOX!=0 || POSCFG_FEATURE_MUTEXTRYLOCK != 0
01531 
01548 #if DOX
01549 NANOEXT VAR_t nosMutexTryLock(NOSMUTEX_t mutex);
01550 #else
01551 #define nosMutexTryLock(mutex)  posMutexTryLock((POSMUTEX_t)(mutex))
01552 #endif
01553 #endif
01554 
01569 #if DOX
01570 NANOEXT VAR_t nosMutexLock(NOSMUTEX_t mutex);
01571 #else
01572 #define nosMutexLock(mutex)  posMutexLock((POSMUTEX_t)(mutex))
01573 #endif
01574 
01587 #if DOX
01588 NANOEXT VAR_t nosMutexUnlock(NOSMUTEX_t mutex);
01589 #else
01590 #define nosMutexUnlock(mutex)  posMutexUnlock((POSMUTEX_t)(mutex))
01591 #endif
01592 
01593 #endif /* NOSCFG_FEATURE_MUTEXES */
01594 
01604 #if DOX!=0 || NOSCFG_FEATURE_MSGBOXES != 0
01605 
01627 NANOEXT void* nosMessageAlloc(UINT_t msgSize);
01628 
01638 NANOEXT void nosMessageFree(void *buf);
01639 
01652 NANOEXT VAR_t nosMessageSend(void *buf, NOSTASK_t taskhandle);
01653 
01668 #if DOX
01669 NANOEXT void* nosMessageGet(void);
01670 #else
01671 #define  nosMessageGet()  posMessageGet()
01672 #endif
01673 
01674 #if DOX!=0 || POSCFG_FEATURE_MSGWAIT != 0
01675 
01699 #if DOX
01700 NANOEXT void* nosMessageWait(UINT_t timeoutticks);
01701 #else
01702 #define nosMessageWait(to)  posMessageWait(to)
01703 #endif
01704 #endif
01705 
01720 #if DOX
01721 NANOEXT VAR_t nosMessageAvailable(void);
01722 #else
01723 #define nosMessageAvailable()  posMessageAvailable()
01724 #endif
01725 
01726 #endif  /* NOSCFG_FEATURE_MSGBOXES */
01727 
01736 #if DOX!=0 || NOSCFG_FEATURE_FLAGS != 0
01737 
01739 typedef  POSFLAG_t  NOSFLAG_t;
01740 
01765 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
01766 NANOEXT NOSFLAG_t nosFlagCreate(const char* name);
01767 #else
01768 #define nosFlagCreate(name)  (NOSFLAG_t) posFlagCreate()
01769 #endif
01770 
01771 #if DOX!=0 || POSCFG_FEATURE_FLAGDESTROY != 0
01772 
01784 #if (DOX!=0) || (NOSCFG_FEATURE_REGISTRY != 0)
01785 NANOEXT void nosFlagDestroy(NOSFLAG_t flg);
01786 #else
01787 #define nosFlagDestroy(flg)  posFlagDestroy((POSFLAG_t)(flg))
01788 #endif
01789 #endif
01790 
01805 #if DOX
01806 NANOEXT VAR_t nosFlagSet(NOSFLAG_t flg, UVAR_t flgnum);
01807 #else
01808 #define nosFlagSet(flg, num)  posFlagSet((POSFLAG_t)(flg), num)
01809 #endif
01810 
01827 #if DOX
01828 NANOEXT VAR_t nosFlagGet(NOSFLAG_t flg, UVAR_t mode);
01829 #else
01830 #define nosFlagGet(flg, mode)  posFlagGet((POSFLAG_t)(flg), mode)
01831 #endif
01832 
01833 #if DOX!=0 || POSCFG_FEATURE_FLAGWAIT != 0
01834 
01855 #if DOX
01856 NANOEXT VAR_t nosFlagWait(NOSFLAG_t flg, UINT_t timeoutticks);
01857 #else
01858 #define nosFlagWait(flg, to)  posFlagWait((POSFLAG_t)(flg), to)
01859 #endif
01860 #endif
01861 
01862 #define NOSFLAG_MODE_GETSINGLE  POSFLAG_MODE_GETSINGLE
01863 #define NOSFLAG_MODE_GETMASK    POSFLAG_MODE_GETMASK
01864 
01865 #endif /* NOSCFG_FEATURE_FLAGS */
01866 
01879 #if DOX!=0 || NOSCFG_FEATURE_TIMER != 0
01880 
01882 typedef  POSTIMER_t  NOSTIMER_t;
01883 
01906 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
01907 NANOEXT NOSTIMER_t  nosTimerCreate(const char *name);
01908 #else
01909 #define nosTimerCreate(name)  (NOSTIMER_t) posTimerCreate()
01910 #endif
01911 
01931 #if DOX
01932 NANOEXT VAR_t nosTimerSet(NOSTIMER_t tmr, NOSSEMA_t sema,
01933                           UINT_t waitticks, UINT_t periodticks);
01934 #else
01935 #define nosTimerSet(t, s, w, p) \
01936           posTimerSet((POSTIMER_t)(t), (POSSEMA_t)(s), w, p)
01937 #endif
01938 
01952 #if DOX
01953 NANOEXT VAR_t nosTimerStart(NOSTIMER_t tmr);
01954 #else
01955 #define nosTimerStart(tmr)  posTimerStart((POSTIMER_t)(tmr))
01956 #endif
01957 
01970 #if DOX
01971 NANOEXT VAR_t nosTimerStop(NOSTIMER_t tmr);
01972 #else
01973 #define nosTimerStop(tmr)  posTimerStop((POSTIMER_t)(tmr))
01974 #endif
01975 
01976 #if DOX!=0 || POSCFG_FEATURE_TIMERDESTROY != 0
01977 
01989 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
01990 NANOEXT void nosTimerDestroy(NOSTIMER_t tmr);
01991 #else
01992 #define nosTimerDestroy(tmr)  posTimerDestroy((POSTIMER_t)(tmr))
01993 #endif
01994 #endif
01995 
01996 #if DOX!=0 || POSCFG_FEATURE_TIMERFIRED != 0
01997 
02011 #if DOX
02012 NANOEXT VAR_t nosTimerFired(NOSTIMER_t tmr);
02013 #else
02014 #define nosTimerFired(tmr)  posTimerFired((POSTIMER_t)(tmr))
02015 #endif
02016 #endif
02017 
02018 #endif /* NOSCFG_FEATURE_TIMER */
02019 
02021 #undef NANOEXT
02022 
02026 /*---------------------------------------------------------------------------
02027  *  INITIALIZATION
02028  *-------------------------------------------------------------------------*/
02029 
02035 #ifdef _N_CORE_C
02036 #define NANOEXT
02037 #else
02038 #define NANOEXT extern
02039 #endif
02040 
02061 NANOEXT void  nosInit(POSTASKFUNC_t firstfunc, void *funcarg, VAR_t priority,
02062                       UINT_t taskStackSize, UINT_t idleStackSize);
02063 
02064 #ifndef _N_CORE_C
02065 #ifndef _POSCORE_C
02066 #define posInit _Please_use_nosInit_instead_of_posInit_
02067 #endif
02068 #endif
02069 #undef NANOEXT
02070 
02072 #endif /* _POS_NANO_H */
02073 

Generated on Mon May 1 11:07:42 2006 for pico]OS by  doxygen 1.4.6-NO