pico]OS  1.0.4
pos_nano.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004-2012, Dennis Kuschel.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote
15  * products derived from this software without specific prior written
16  * permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
22  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28  * OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  */
31 
32 
44 #ifndef _POS_NANO_H
45 #define _POS_NANO_H
46 
47 #ifndef DOX
48 #define DOX 0
49 #endif
50 
51 
52 
53 /*---------------------------------------------------------------------------
54  * NANO LAYER INSTALLATION
55  *-------------------------------------------------------------------------*/
56 
57 /* include configuration files */
58 #ifndef _PICOOS_H
59 #include <port.h>
60 #include <poscfg.h>
61 #endif
62 #include <noscfg.h>
63 
64 
65 #ifndef NOSCFG_FEATURE_REGISTRY
66 #define NOSCFG_FEATURE_REGISTRY 0
67 #endif
68 
69 #if POSCFG_TASKSTACKTYPE==0
70 #define NOS_NEEDTASKEXITHOOK
71 #else
72 #if NOSCFG_FEATURE_REGISTRY!=0
73 #define NOS_NEEDTASKEXITHOOK
74 #endif
75 #endif
76 
77 #ifdef NOS_NEEDTASKEXITHOOK
78 
79 /* define hook */
80 #ifdef POSCFG_TASKEXIT_HOOK
81 #undef POSCFG_TASKEXIT_HOOK
82 #endif
83 #define POSCFG_TASKEXIT_HOOK 1
84 
85 /* set additional task data for the nano layer */
86 #define NOS_TASKDATA void *nosstkroot;
87 
88 #endif /* NOS_NEEDTASKEXITHOOK */
89 
90 /* include pico]OS header if not yet done */
91 #ifndef _PICOOS_H
92 #include <picoos.h>
93 #endif
94 
95 
96 
97 /*---------------------------------------------------------------------------
98  * CONFIGURATION
99  *-------------------------------------------------------------------------*/
100 
101 #ifndef NOSCFG_FEATURE_MEMALLOC
102 #error NOSCFG_FEATURE_MEMALLOC not defined
103 #endif
104 #ifndef NOSCFG_FEATURE_CONIN
105 #error NOSCFG_FEATURE_CONIN not defined
106 #endif
107 #ifndef NOSCFG_FEATURE_CONOUT
108 #error NOSCFG_FEATURE_CONOUT not defined
109 #endif
110 #ifndef NOSCFG_CONOUT_HANDSHAKE
111 #error NOSCFG_CONOUT_HANDSHAKE not defined
112 #endif
113 #ifndef NOSCFG_CONOUT_FIFOSIZE
114 #error NOSCFG_CONOUT_FIFOSIZE not defined
115 #endif
116 #ifndef NOSCFG_FEATURE_PRINTF
117 #error NOSCFG_FEATURE_PRINTF not defined
118 #endif
119 #ifndef NOSCFG_FEATURE_SPRINTF
120 #error NOSCFG_FEATURE_SPRINTF not defined
121 #endif
122 #ifndef NOSCFG_FEATURE_TASKCREATE
123 #error NOSCFG_FEATURE_TASKCREATE not defined
124 #endif
125 #ifndef NOSCFG_DEFAULT_STACKSIZE
126 #error NOSCFG_DEFAULT_STACKSIZE not defined in the port configuration file
127 #endif
128 #ifndef NOSCFG_STACK_GROWS_UP
129 #error NOSCFG_STACK_GROWS_UP not defined in the port configuration file
130 #endif
131 #ifndef NOSCFG_MEM_MANAGE_MODE
132 #error NOSCFG_MEM_MANAGE_MODE not defined
133 #endif
134 #ifndef NOSCFG_FEATURE_MEMSET
135 #error NOSCFG_FEATURE_MEMSET not defined
136 #endif
137 #ifndef NOSCFG_FEATURE_MEMCOPY
138 #error NOSCFG_FEATURE_MEMCOPY not defined
139 #endif
140 #ifndef NOSCFG_STKMEM_RESERVE
141 #error NOSCFG_STKMEM_RESERVE not defined
142 #endif
143 #if NOSCFG_MEM_MANAGER_TYPE == 2
144 #ifndef NOSCFG_MEM_USER_MALLOC
145 #error NOSCFG_MEM_USER_MALLOC not defined
146 #endif
147 #ifndef NOSCFG_MEM_USER_FREE
148 #error NOSCFG_MEM_USER_FREE not defined
149 #endif
150 #endif
151 #ifndef NOSCFG_FEATURE_BOTTOMHALF
152 #error NOSCFG_FEATURE_BOTTOMHALF not defined
153 #endif
154 #if NOSCFG_FEATURE_BOTTOMHALF != 0
155 #ifndef NOS_MAX_BOTTOMHALFS
156 #error NOS_MAX_BOTTOMHALFS not defined
157 #endif
158 #if (NOS_MAX_BOTTOMHALFS == 0) || (NOS_MAX_BOTTOMHALFS > MVAR_BITS)
159 #error NOS_MAX_BOTTOMHALFS must be in the range 1 .. MVAR_BITS
160 #endif
161 #endif
162 #ifndef NOSCFG_FEATURE_CPUUSAGE
163 #error NOSCFG_FEATURE_CPUUSAGE not defined
164 #endif
165 
166 #if NOSCFG_FEATURE_REGISTRY
167 #ifndef NOSCFG_FEATURE_REGQUERY
168 #error NOSCFG_FEATURE_REGQUERY
169 #endif
170 #ifndef NOSCFG_FEATURE_USERREG
171 #error NOSCFG_FEATURE_USERREG
172 #endif
173 #ifndef NOS_MAX_REGKEYLEN
174 #error NOS_MAX_REGKEYLEN
175 #endif
176 #if NOS_MAX_REGKEYLEN < 4
177 #error NOS_MAX_REGKEYLEN must be at least 4
178 #endif
179 #ifndef NOS_REGKEY_PREALLOC
180 #error NOS_REGKEY_PREALLOC
181 #endif
182 #else /* NOSCFG_FEATURE_REGISTRY */
183 #ifdef NOSCFG_FEATURE_USERREG
184 #undef NOSCFG_FEATURE_USERREG
185 #endif
186 #define NOSCFG_FEATURE_USERREG 0
187 #ifdef NOSCFG_FEATURE_REGQUERY
188 #undef NOSCFG_FEATURE_REGQUERY
189 #endif
190 #define NOSCFG_FEATURE_REGQUERY 0
191 #endif /* NOSCFG_FEATURE_REGISTRY */
192 
193 #ifndef NOSCFG_FEATURE_SEMAPHORES
194 #define NOSCFG_FEATURE_SEMAPHORES 0
195 #endif
196 
197 #if NOSCFG_FEATURE_SEMAPHORES != 0 && POSCFG_FEATURE_SEMAPHORES == 0
198 #error NOSCFG_FEATURE_SEMAPHORES enabled, but pico]OS semaphores disabled
199 #endif
200 
201 #ifndef NOSCFG_FEATURE_MUTEXES
202 #define NOSCFG_FEATURE_MUTEXES 0
203 #endif
204 #if NOSCFG_FEATURE_MUTEXES != 0 && POSCFG_FEATURE_MUTEXES == 0
205 #error NOSCFG_FEATURE_MUTEXES enabled, but pico]OS mutexes disabled
206 #endif
207 
208 #ifndef NOSCFG_FEATURE_MSGBOXES
209 #define NOSCFG_FEATURE_MSGBOXES 0
210 #endif
211 #if NOSCFG_FEATURE_MSGBOXES != 0 && POSCFG_FEATURE_MSGBOXES == 0
212 #error NOSCFG_FEATURE_MSGBOXES enabled, but pico]OS message boxes disabled
213 #endif
214 
215 #ifndef NOSCFG_FEATURE_FLAGS
216 #define NOSCFG_FEATURE_FLAGS 0
217 #endif
218 #if NOSCFG_FEATURE_FLAGS != 0 && POSCFG_FEATURE_FLAGS == 0
219 #error NOSCFG_FEATURE_FLAGS enabled, but pico]OS flag functions disabled
220 #endif
221 
222 #ifndef NOSCFG_FEATURE_TIMER
223 #define NOSCFG_FEATURE_TIMER 0
224 #endif
225 #if NOSCFG_FEATURE_TIMER != 0 && POSCFG_FEATURE_TIMER == 0
226 #error NOSCFG_FEATURE_TIMER enabled, but pico]OS timer functions disabled
227 #endif
228 
229 #ifndef NOSCFG_MEM_OVWR_STANDARD
230 #define NOSCFG_MEM_OVWR_STANDARD 1
231 #endif
232 #ifndef NOSCFG_FEATURE_REALLOC
233 #define NOSCFG_FEATURE_REALLOC 0
234 #endif
235 
236 
237 
238 /*---------------------------------------------------------------------------
239  * DATA TYPES
240  *-------------------------------------------------------------------------*/
241 
242 #if DOX!=0 || NOSCFG_FEATURE_BOTTOMHALF != 0
243 
250 typedef void (*NOSBHFUNC_t)(void* arg, UVAR_t bh);
251 #endif
252 
253 
254 
255 /*---------------------------------------------------------------------------
256  * MEMORY MANAGEMENT
257  *-------------------------------------------------------------------------*/
258 
271 #ifdef _N_MEM_C
272 #define NANOEXT
273 #else
274 #define NANOEXT extern
275 #endif
276 
277 #if DOX!=0 || NOSCFG_FEATURE_MEMALLOC != 0
278 
292 NANOEXT void* POSCALL nosMemAlloc(UINT_t size);
293 
302 NANOEXT void POSCALL nosMemFree(void *p);
303 
304 
305 #if DOX!=0 || NOSCFG_FEATURE_REALLOC != 0
306 
322 NANOEXT void POSCALL *nosMemRealloc(void *memblock, UINT_t size);
323 #endif
324 
325 /* overwrite standard memory allocation functions */
326 #ifndef NANOINTERNAL
327 #if NOSCFG_MEM_OVWR_STANDARD != 0
328 #ifdef malloc
329 #undef malloc
330 #endif
331 #ifdef calloc
332 #undef calloc
333 #endif
334 #ifdef free
335 #undef free
336 #endif
337 #define malloc nosMemAlloc
338 #define calloc (not_supported)
339 #define free nosMemFree
340 #endif /* NOSCFG_MEM_OVWR_STANDARD */
341 #else /* NANOINTERNAL */
342 /* internal malloc/free, used by OS core and platform ports */
343 #if NOSCFG_MEM_MANAGER_TYPE == 0
344 #define NOS_MEM_ALLOC(x) malloc((size_t)(x))
345 #define NOS_MEM_FREE(x) free(x)
346 #elif NOSCFG_MEM_MANAGER_TYPE == 1
347 void* nos_malloc(UINT_t size);
348 void nos_free(void *mp);
349 #define NOS_MEM_ALLOC(x) nos_malloc(x)
350 #define NOS_MEM_FREE(x) nos_free(x)
351 #elif NOSCFG_MEM_MANAGER_TYPE == 2
352 #define NOS_MEM_ALLOC(x) NOSCFG_MEM_USER_MALLOC(x)
353 #define NOS_MEM_FREE(x) NOSCFG_MEM_USER_FREE(x)
354 #endif
355 #endif /* NANOINTERNAL */
356 
357 #endif /* NOSCFG_FEATURE_MEMALLOC */
358 
359 #if DOX!=0 || NOSCFG_FEATURE_MEMSET != 0
360 
372 NANOEXT void POSCALL nosMemSet(void *buf, char val, UINT_t count);
373 
374 #if NOSCFG_MEM_OVWR_STANDARD != 0
375 #ifdef memset
376 #undef memset
377 #endif
378 #define memset nosMemSet
379 #endif
380 
381 #endif /* NOSCFG_FEATURE_MEMSET */
382 
383 #if DOX!=0 || NOSCFG_FEATURE_MEMCOPY != 0
384 
396 NANOEXT void POSCALL nosMemCopy(void *dst, void *src, UINT_t count);
397 
398 #if NOSCFG_MEM_OVWR_STANDARD != 0
399 #ifdef memcpy
400 #undef memcpy
401 #endif
402 #define memcpy nosMemCopy
403 #endif
404 
405 #endif /* NOSCFG_FEATURE_MEMCOPY */
406 #undef NANOEXT
407 
411 /*---------------------------------------------------------------------------
412  * CONSOLE INPUT / OUTPUT
413  *-------------------------------------------------------------------------*/
414 
435 #ifdef _N_CONIO_C
436 #define NANOEXT
437 #else
438 #define NANOEXT extern
439 #endif
440 
441 #if DOX!=0 || NOSCFG_FEATURE_CONIN != 0
442 
454 NANOEXT void POSCALL c_nos_keyinput(UVAR_t key);
455 
465 NANOEXT char POSCALL nosKeyGet(void);
466 
476 NANOEXT UVAR_t POSCALL nosKeyPressed(void);
477 
478 #endif /* NOSCFG_FEATURE_CONIN */
479 
480 
481 #if DOX!=0 || NOSCFG_FEATURE_CONOUT != 0
482 
503 NANOEXT UVAR_t POSCALL p_putchar(char c);
504 #endif
505 
506 
507 #if DOX!=0 || NOSCFG_CONOUT_HANDSHAKE != 0
508 
529 NANOEXT void POSCALL c_nos_putcharReady(void);
530 #endif
531 
532 
533 #if DOX!=0 || NOSCFG_FEATURE_CONOUT != 0
534 
543 NANOEXT void POSCALL nosPrintChar(char c);
544 
554 NANOEXT void POSCALL nosPrint(const char *s);
555 
556 #endif
557 
558 #if NOSCFG_FEATURE_CONOUT == 0
559 #if NOSCFG_FEATURE_PRINTF != 0
560 #undef NOSCFG_FEATURE_PRINTF
561 #define NOSCFG_FEATURE_PRINTF 0
562 #endif
563 #endif
564 
565 #if NOSCFG_FEATURE_PRINTF != 0 || NOSCFG_FEATURE_SPRINTF != 0
566 typedef void* NOSARG_t;
567 #endif
568 
569 
570 #if DOX!=0 || ((NOSCFG_FEATURE_CONOUT != 0)&&(NOSCFG_FEATURE_PRINTF != 0))
571 
572 NANOEXT void POSCALL n_printFormattedN(const char *fmt, NOSARG_t args);
573 
574 #if DOX
575 
590 NANOEXT void POSCALL nosPrintf1(const char *fmt, arg a1);
591 
592 #else /* DOX!=0 */
593 #define nosPrintf1(fmt, a1) \
594  do { \
595  NOSARG_t args[1]; args[0] = (NOSARG_t)(a1); \
596  n_printFormattedN(fmt, args); \
597  } while(0);
598 
599 #define nosPrintf2(fmt, a1, a2) \
600  do { \
601  NOSARG_t args[2]; args[0] = (NOSARG_t)(a1); \
602  args[1] = (NOSARG_t)(a2); \
603  n_printFormattedN(fmt, args); \
604  } while(0);
605 
606 #define nosPrintf3(fmt, a1, a2, a3) \
607  do { \
608  NOSARG_t args[3]; args[0] = (NOSARG_t)(a1); \
609  args[1] = (NOSARG_t)(a2); args[2] = (NOSARG_t)(a3); \
610  n_printFormattedN(fmt, args); \
611  } while(0);
612 
613 #define nosPrintf4(fmt, a1, a2, a3, a4) \
614  do { \
615  NOSARG_t args[4]; \
616  args[0] = (NOSARG_t)(a1); args[1] = (NOSARG_t)(a2); \
617  args[2] = (NOSARG_t)(a3); args[3] = (NOSARG_t)(a4); \
618  n_printFormattedN(fmt, args); \
619  } while(0);
620 
621 #define nosPrintf5(fmt, a1, a2, a3, a4, a5) \
622  do { \
623  NOSARG_t args[5]; args[0] = (NOSARG_t)(a1); \
624  args[1] = (NOSARG_t)(a2); args[2] = (NOSARG_t)(a3); \
625  args[3] = (NOSARG_t)(a4); args[4] = (NOSARG_t)(a5); \
626  n_printFormattedN(fmt, args); \
627  } while(0);
628 
629 #define nosPrintf6(fmt, a1, a2, a3, a4, a5, a6) \
630  do { \
631  NOSARG_t args[6]; \
632  args[0] = (NOSARG_t)(a1); args[1] = (NOSARG_t)(a2); \
633  args[2] = (NOSARG_t)(a3); args[3] = (NOSARG_t)(a4); \
634  args[4] = (NOSARG_t)(a5); args[5] = (NOSARG_t)(a6); \
635  n_printFormattedN(fmt, args); \
636  } while(0);
637 
638 #endif /* DOX!=0 */
639 #endif /* NOSCFG_FEATURE_PRINTF */
640 
641 
642 #if DOX!=0 || NOSCFG_FEATURE_SPRINTF != 0
643 #if DOX
644 
659 NANOEXT void POSCALL nosSPrintf1(char *buf, const char *fmt, arg a1);
660 
661 #else /* DOX!=0 */
662 
663 NANOEXT void POSCALL n_sprintFormattedN(char *buf, const char *fmt,
664  NOSARG_t args);
665 
666 #define nosSPrintf1(buf, fmt, a1) \
667  do { \
668  NOSARG_t args[1]; args[0] = (NOSARG_t)(a1); \
669  n_sprintFormattedN(buf, fmt, args); \
670  } while(0);
671 
672 #define nosSPrintf2(buf, fmt, a1, a2) \
673  do { \
674  NOSARG_t args[2]; args[0] = (NOSARG_t)(a1); \
675  args[1] = (NOSARG_t)(a2); \
676  n_sprintFormattedN(buf, fmt, args); \
677  } while(0);
678 
679 #define nosSPrintf3(buf, fmt, a1, a2, a3) \
680  do { \
681  NOSARG_t args[3]; args[0] = (NOSARG_t)(a1); \
682  args[1] = (NOSARG_t)(a2); args[2] = (NOSARG_t)(a3); \
683  n_sprintFormattedN(buf, fmt, args); \
684  } while(0);
685 
686 #define nosSPrintf4(buf, fmt, a1, a2, a3, a4) \
687  do { \
688  NOSARG_t args[4]; \
689  args[0] = (NOSARG_t)(a1); args[1] = (NOSARG_t)(a2); \
690  args[2] = (NOSARG_t)(a3); args[3] = (NOSARG_t)(a4); \
691  n_sprintFormattedN(buf, fmt, args); \
692  } while(0);
693 
694 #define nosSPrintf5(buf, fmt, a1, a2, a3, a4, a5) \
695  do { \
696  NOSARG_t args[5]; args[0] = (NOSARG_t)(a1); \
697  args[1] = (NOSARG_t)(a2); args[2] = (NOSARG_t)(a3); \
698  args[3] = (NOSARG_t)(a4); args[4] = (NOSARG_t)(a5); \
699  n_sprintFormattedN(buf, fmt, args); \
700  } while(0);
701 
702 #define nosSPrintf6(buf, fmt, a1, a2, a3, a4, a5, a6) \
703  do { \
704  NOSARG_t args[6]; \
705  args[0] = (NOSARG_t)(a1); args[1] = (NOSARG_t)(a2); \
706  args[2] = (NOSARG_t)(a3); args[3] = (NOSARG_t)(a4); \
707  args[4] = (NOSARG_t)(a5); args[5] = (NOSARG_t)(a6); \
708  n_sprintFormattedN(buf, fmt, args); \
709  } while(0);
710 
711 #endif /* DOX!=0 */
712 #endif /* NOSCFG_FEATURE_SPRINTF */
713 #undef NANOEXT
714 
718 /*---------------------------------------------------------------------------
719  * BOTTOM HALFS
720  *-------------------------------------------------------------------------*/
721 
740 #ifdef _N_BHALF_C
741 #define NANOEXT
742 #else
743 #define NANOEXT extern
744 #endif
745 
746 #if DOX!=0 || NOSCFG_FEATURE_BOTTOMHALF != 0
747 
766 NANOEXT VAR_t POSCALL nosBottomHalfRegister(UVAR_t number, NOSBHFUNC_t func,
767  void *arg);
768 
778 #define nosBottomHalfUnregister(number) \
779  nosBottomHalfRegister(number, NULL, NULL)
780 
793 NANOEXT void POSCALL nosBottomHalfStart(UVAR_t number);
794 
795 #endif /* NOSCFG_FEATURE_BOTTOMHALF */
796 #undef NANOEXT
797 
801 /*---------------------------------------------------------------------------
802  * REGISTRY
803  *-------------------------------------------------------------------------*/
804 
825 #ifdef _N_REG_C
826 #define NANOEXT
827 #else
828 #define NANOEXT extern
829 #endif
830 
831 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
832 
834 typedef void* NOSGENERICHANDLE_t;
835 
838 typedef void* NOSREGQHANDLE_t;
839 
840 /* Generic registry key value type.
841  It is on the developer how he uses the type. */
842 typedef union {
843  void* voidptr;
844  int integer;
845 } KEYVALUE_t;
846 
848 typedef enum {
850 #if DOX!=0 || NOSCFG_FEATURE_SEMAPHORES != 0
852 #endif
853 #if DOX!=0 || NOSCFG_FEATURE_MUTEXES != 0
855 #endif
856 #if DOX!=0 || NOSCFG_FEATURE_FLAGS != 0
858 #endif
859 #if DOX!=0 || NOSCFG_FEATURE_TIMER != 0
861 #endif
862 #if DOX!=0 || NOSCFG_FEATURE_USERREG != 0
864 #endif
867 } NOSREGTYPE_t;
868 #define MIN_REGTYPE REGTYPE_TASK
869 #define MAX_REGTYPE (REGTYPE_SEARCHALL-1)
870 
871 
887 NANOEXT NOSGENERICHANDLE_t POSCALL nosGetHandleByName(
888  NOSREGTYPE_t objtype, const char *objname);
889 
890 
910 NANOEXT VAR_t POSCALL nosGetNameByHandle(NOSGENERICHANDLE_t handle,
911  char *buffer, VAR_t bufsize,
912  NOSREGTYPE_t what);
913 
914 #if DOX!=0 || NOSCFG_FEATURE_USERREG != 0
915 
932 NANOEXT VAR_t POSCALL nosRegSet(const char *keyname, KEYVALUE_t keyvalue);
933 
947 NANOEXT VAR_t POSCALL nosRegGet(const char *keyname, KEYVALUE_t *keyvalue);
948 
957 NANOEXT VAR_t POSCALL nosRegDel(const char *keyname);
958 #endif
959 
960 #if DOX!=0 || NOSCFG_FEATURE_REGQUERY != 0
961 
981 NANOEXT NOSREGQHANDLE_t POSCALL nosRegQueryBegin(NOSREGTYPE_t type);
982 
1002 NANOEXT VAR_t POSCALL nosRegQueryElem(NOSREGQHANDLE_t qh,
1003  NOSGENERICHANDLE_t *genh,
1004  char* namebuf, VAR_t bufsize);
1005 
1016 NANOEXT void POSCALL nosRegQueryEnd(NOSREGQHANDLE_t qh);
1017 #endif
1018 
1019 #endif /* NOSCFG_FEATURE_REGISTRY */
1020 #undef NANOEXT
1021 
1025 /*---------------------------------------------------------------------------
1026  * CPU USAGE
1027  *-------------------------------------------------------------------------*/
1028 
1029 #if (DOX!=0) || (NOSCFG_FEATURE_CPUUSAGE != 0)
1030 
1044 UVAR_t POSCALL nosCpuUsage(void);
1045 #endif
1046 
1050 /*---------------------------------------------------------------------------
1051  * ABSTRACTED FUNCTIONS
1052  *-------------------------------------------------------------------------*/
1053 
1054 #ifdef _N_CORE_C
1055 #define NANOEXT
1056 #else
1057 #define NANOEXT extern
1058 #endif
1059 
1078 
1079 
1080 #if (DOX!=0) || (NOSCFG_FEATURE_TASKCREATE != 0)
1081 
1104 NANOEXT NOSTASK_t POSCALL nosTaskCreate(POSTASKFUNC_t funcptr,
1105  void *funcarg,
1106  VAR_t priority,
1107  UINT_t stacksize,
1108  const char* name);
1109 
1110 
1111 #if (DOX!=0) || (POSCFG_FEATURE_YIELD != 0)
1112 
1122 #if DOX
1123 NANOEXT void POSCALL nosTaskYield(void);
1124 #else
1125 #define nosTaskYield() posTaskYield()
1126 #endif
1127 #endif
1128 
1129 #if (DOX!=0) || (POSCFG_FEATURE_SLEEP != 0)
1130 
1146 #if DOX
1147 NANOEXT void POSCALL nosTaskSleep(UINT_t ticks);
1148 #else
1149 #define nosTaskSleep(ticks) posTaskSleep(ticks)
1150 #endif
1151 #endif
1152 
1153 #if (DOX!=0) || (POSCFG_FEATURE_EXIT != 0)
1154 
1163 #if DOX
1164 NANOEXT void POSCALL nosTaskExit(void);
1165 #else
1166 #define nosTaskExit() posTaskExit()
1167 #endif
1168 #endif
1169 
1170 #if (DOX!=0) || (POSCFG_FEATURE_GETTASK != 0)
1171 
1181 #if DOX
1182 NANOEXT NOSTASK_t POSCALL nosTaskGetCurrent(void);
1183 #else
1184 #define nosTaskGetCurrent() (NOSTASK_t)posTaskGetCurrent()
1185 #endif
1186 #endif
1187 
1188 #if (DOX!=0) || (POSCFG_FEATURE_TASKUNUSED != 0)
1189 
1204 #if DOX
1205 NANOEXT VAR_t POSCALL nosTaskUnused(NOSTASK_t taskhandle);
1206 #else
1207 #define nosTaskUnused(th) posTaskUnused((POSTASK_t)(th))
1208 #endif
1209 #endif
1210 
1211 #if (DOX!=0) || (POSCFG_FEATURE_SETPRIORITY != 0)
1212 
1227 #if DOX
1228 NANOEXT VAR_t POSCALL nosTaskSetPriority(NOSTASK_t taskhandle,
1229  VAR_t priority);
1230 #else
1231 #define nosTaskSetPriority(th, prio) posTaskSetPriority((POSTASK_t)(th),prio)
1232 #endif
1233 #endif
1234 
1235 #if (DOX!=0) || (POSCFG_FEATURE_GETPRIORITY != 0)
1236 
1247 #if DOX
1248 NANOEXT VAR_t POSCALL nosTaskGetPriority(NOSTASK_t taskhandle);
1249 #else
1250 #define nosTaskGetPriority(th) posTaskGetPriority((POSTASK_t)(th))
1251 #endif
1252 #endif
1253 
1254 #if (DOX!=0) || (POSCFG_FEATURE_INHIBITSCHED != 0)
1255 
1268 #if DOX
1269 NANOEXT void POSCALL nosTaskSchedLock(void);
1270 #else
1271 #define nosTaskSchedLock() posTaskSchedLock()
1272 #endif
1273 
1285 #if DOX
1286 NANOEXT void POSCALL nosTaskSchedUnlock(void);
1287 #else
1288 #define nosTaskSchedUnlock() posTaskSchedUnlock()
1289 #endif
1290 #endif
1291 
1292 #if (DOX!=0) || (POSCFG_TASKCB_USERSPACE > 0)
1293 
1303 #if DOX
1304 NANOEXT void* POSCALL nosTaskGetUserspace(void);
1305 #else
1306 #define nosTaskGetUserspace() posTaskGetUserspace()
1307 #endif
1308 #endif
1309 
1310 #if (DOX!=0) || (POSCFG_FEATURE_IDLETASKHOOK != 0)
1311 
1333 #if DOX
1334 NANOEXT NOSIDLEFUNC_t POSCALL nosInstallIdleTaskHook(NOSIDLEFUNC_t idlefunc);
1335 #else
1336 #define nosInstallIdleTaskHook(ifunc) posInstallIdleTaskHook(ifunc)
1337 #endif
1338 #endif
1339 
1340 #endif
1341 
1349 #if DOX!=0 || NOSCFG_FEATURE_SEMAPHORES != 0
1350 
1353 
1378 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
1379 NANOEXT NOSSEMA_t POSCALL nosSemaCreate(INT_t initcount, UVAR_t options,
1380  const char *name);
1381 #else
1382 #define nosSemaCreate(i, o, n) (NOSSEMA_t) posSemaCreate(i);
1383 #endif
1384 
1385 #if DOX!=0 || POSCFG_FEATURE_SEMADESTROY != 0
1386 
1398 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
1399 NANOEXT void POSCALL nosSemaDestroy(NOSSEMA_t sema);
1400 #else
1401 #define nosSemaDestroy(sema) posSemaDestroy((POSSEMA_t)(sema))
1402 #endif
1403 #endif
1404 
1405 #if DOX
1406 
1419 NANOEXT VAR_t POSCALL nosSemaSignal(NOSSEMA_t sema);
1420 #else
1421 #define nosSemaSignal(sem) posSemaSignal((POSSEMA_t)(sem))
1422 #endif
1423 
1424 #if DOX
1425 
1439 NANOEXT VAR_t POSCALL nosSemaGet(NOSSEMA_t sema);
1440 #else
1441 #define nosSemaGet(sem) posSemaGet((POSSEMA_t)(sem))
1442 #endif
1443 
1444 #if DOX
1445 
1467 NANOEXT VAR_t POSCALL nosSemaWait(NOSSEMA_t sema, UINT_t timeoutticks);
1468 #else
1469 #if POSCFG_FEATURE_SEMAWAIT
1470 #define nosSemaWait(sem, to) posSemaWait((POSSEMA_t)(sem), to)
1471 #endif
1472 #endif
1473 
1474 #endif /* POSCFG_FEATURE_SEMAPHORES */
1475 
1483 #if DOX!=0 || NOSCFG_FEATURE_MUTEXES != 0
1484 
1487 
1509 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
1510 NANOEXT NOSMUTEX_t POSCALL nosMutexCreate(UVAR_t options, const char *name);
1511 #else
1512 #define nosMutexCreate(opt, name) (NOSMUTEX_t) posMutexCreate()
1513 #endif
1514 
1515 #if DOX!=0 || POSCFG_FEATURE_MUTEXDESTROY != 0
1516 
1528 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
1529 NANOEXT void POSCALL nosMutexDestroy(NOSMUTEX_t mutex);
1530 #else
1531 #define nosMutexDestroy(mutex) posMutexDestroy((POSMUTEX_t)(mutex))
1532 #endif
1533 #endif
1534 
1535 #if DOX!=0 || POSCFG_FEATURE_MUTEXTRYLOCK != 0
1536 
1553 #if DOX
1554 NANOEXT VAR_t POSCALL nosMutexTryLock(NOSMUTEX_t mutex);
1555 #else
1556 #define nosMutexTryLock(mutex) posMutexTryLock((POSMUTEX_t)(mutex))
1557 #endif
1558 #endif
1559 
1574 #if DOX
1575 NANOEXT VAR_t POSCALL nosMutexLock(NOSMUTEX_t mutex);
1576 #else
1577 #define nosMutexLock(mutex) posMutexLock((POSMUTEX_t)(mutex))
1578 #endif
1579 
1592 #if DOX
1593 NANOEXT VAR_t POSCALL nosMutexUnlock(NOSMUTEX_t mutex);
1594 #else
1595 #define nosMutexUnlock(mutex) posMutexUnlock((POSMUTEX_t)(mutex))
1596 #endif
1597 
1598 #endif /* NOSCFG_FEATURE_MUTEXES */
1599 
1609 #if DOX!=0 || NOSCFG_FEATURE_MSGBOXES != 0
1610 
1632 NANOEXT void* POSCALL nosMessageAlloc(UINT_t msgSize);
1633 
1643 NANOEXT void POSCALL nosMessageFree(void *buf);
1644 
1657 NANOEXT VAR_t POSCALL nosMessageSend(void *buf, NOSTASK_t taskhandle);
1658 
1673 #if DOX
1674 NANOEXT void* POSCALL nosMessageGet(void);
1675 #else
1676 #define nosMessageGet() posMessageGet()
1677 #endif
1678 
1679 #if DOX!=0 || POSCFG_FEATURE_MSGWAIT != 0
1680 
1704 #if DOX
1705 NANOEXT void* POSCALL nosMessageWait(UINT_t timeoutticks);
1706 #else
1707 #define nosMessageWait(to) posMessageWait(to)
1708 #endif
1709 #endif
1710 
1725 #if DOX
1726 NANOEXT VAR_t POSCALL nosMessageAvailable(void);
1727 #else
1728 #define nosMessageAvailable() posMessageAvailable()
1729 #endif
1730 
1731 #endif /* NOSCFG_FEATURE_MSGBOXES */
1732 
1741 #if DOX!=0 || NOSCFG_FEATURE_FLAGS != 0
1742 
1745 
1770 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
1771 NANOEXT NOSFLAG_t POSCALL nosFlagCreate(const char* name);
1772 #else
1773 #define nosFlagCreate(name) (NOSFLAG_t) posFlagCreate()
1774 #endif
1775 
1776 #if DOX!=0 || POSCFG_FEATURE_FLAGDESTROY != 0
1777 
1789 #if (DOX!=0) || (NOSCFG_FEATURE_REGISTRY != 0)
1790 NANOEXT void POSCALL nosFlagDestroy(NOSFLAG_t flg);
1791 #else
1792 #define nosFlagDestroy(flg) posFlagDestroy((POSFLAG_t)(flg))
1793 #endif
1794 #endif
1795 
1810 #if DOX
1811 NANOEXT VAR_t POSCALL nosFlagSet(NOSFLAG_t flg, UVAR_t flgnum);
1812 #else
1813 #define nosFlagSet(flg, num) posFlagSet((POSFLAG_t)(flg), num)
1814 #endif
1815 
1832 #if DOX
1833 NANOEXT VAR_t POSCALL nosFlagGet(NOSFLAG_t flg, UVAR_t mode);
1834 #else
1835 #define nosFlagGet(flg, mode) posFlagGet((POSFLAG_t)(flg), mode)
1836 #endif
1837 
1838 #if DOX!=0 || POSCFG_FEATURE_FLAGWAIT != 0
1839 
1860 #if DOX
1861 NANOEXT VAR_t POSCALL nosFlagWait(NOSFLAG_t flg, UINT_t timeoutticks);
1862 #else
1863 #define nosFlagWait(flg, to) posFlagWait((POSFLAG_t)(flg), to)
1864 #endif
1865 #endif
1866 
1867 #define NOSFLAG_MODE_GETSINGLE POSFLAG_MODE_GETSINGLE
1868 #define NOSFLAG_MODE_GETMASK POSFLAG_MODE_GETMASK
1869 
1870 #endif /* NOSCFG_FEATURE_FLAGS */
1871 
1884 #if DOX!=0 || NOSCFG_FEATURE_TIMER != 0
1885 
1888 
1911 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
1912 NANOEXT NOSTIMER_t POSCALL nosTimerCreate(const char *name);
1913 #else
1914 #define nosTimerCreate(name) (NOSTIMER_t) posTimerCreate()
1915 #endif
1916 
1936 #if DOX
1937 NANOEXT VAR_t POSCALL nosTimerSet(NOSTIMER_t tmr, NOSSEMA_t sema,
1938  UINT_t waitticks, UINT_t periodticks);
1939 #else
1940 #define nosTimerSet(t, s, w, p) \
1941  posTimerSet((POSTIMER_t)(t), (POSSEMA_t)(s), w, p)
1942 #endif
1943 
1957 #if DOX
1958 NANOEXT VAR_t POSCALL nosTimerStart(NOSTIMER_t tmr);
1959 #else
1960 #define nosTimerStart(tmr) posTimerStart((POSTIMER_t)(tmr))
1961 #endif
1962 
1975 #if DOX
1976 NANOEXT VAR_t POSCALL nosTimerStop(NOSTIMER_t tmr);
1977 #else
1978 #define nosTimerStop(tmr) posTimerStop((POSTIMER_t)(tmr))
1979 #endif
1980 
1981 #if DOX!=0 || POSCFG_FEATURE_TIMERDESTROY != 0
1982 
1994 #if DOX!=0 || NOSCFG_FEATURE_REGISTRY != 0
1995 NANOEXT void POSCALL nosTimerDestroy(NOSTIMER_t tmr);
1996 #else
1997 #define nosTimerDestroy(tmr) posTimerDestroy((POSTIMER_t)(tmr))
1998 #endif
1999 #endif
2000 
2001 #if DOX!=0 || POSCFG_FEATURE_TIMERFIRED != 0
2002 
2016 #if DOX
2017 NANOEXT VAR_t POSCALL nosTimerFired(NOSTIMER_t tmr);
2018 #else
2019 #define nosTimerFired(tmr) posTimerFired((POSTIMER_t)(tmr))
2020 #endif
2021 #endif
2022 
2023 #endif /* NOSCFG_FEATURE_TIMER */
2024 
2026 #undef NANOEXT
2027 
2031 /*---------------------------------------------------------------------------
2032  * INITIALIZATION
2033  *-------------------------------------------------------------------------*/
2034 
2040 #ifdef _N_CORE_C
2041 #define NANOEXT
2042 #else
2043 #define NANOEXT extern
2044 #endif
2045 
2066 NANOEXT void POSCALL nosInit(POSTASKFUNC_t firstfunc,
2067  void *funcarg, VAR_t priority,
2068  UINT_t taskStackSize, UINT_t idleStackSize);
2069 
2070 #ifndef _N_CORE_C
2071 #ifndef _POSCORE_C
2072 #define posInit _Please_use_nosInit_instead_of_posInit_
2073 #endif
2074 #endif
2075 #undef NANOEXT
2076 
2078 #endif /* _POS_NANO_H */
2079