264 #define POS_VER_N 0x0110 265 #define POS_VER_S "1.1.0" 266 #define POS_COPYRIGHT "(c) 2004-2012, Dennis Kuschel\n" \ 267 "(c) 2011-2016, Ari Suutari" 269 #define POS_STARTUPSTRING "pico]OS " POS_VER_S "\n" POS_COPYRIGHT 274 #define NULL ((void*)0) 291 #include <picoos/port.h> 292 #include <picoos/poscfg.h> 305 #error MVAR_t not defined 308 #error MVAR_BITS not defined 310 #ifndef POSCFG_ALIGNMENT 311 #error POSCFG_ALIGNMENT not defined 313 #ifndef POSCFG_MAX_PRIO_LEVEL 314 #error POSCFG_MAX_PRIO_LEVEL not defined 316 #ifndef POSCFG_MAX_TASKS 317 #error POSCFG_MAX_TASKS not defined 319 #ifndef POSCFG_MAX_EVENTS 320 #error POSCFG_MAX_EVENTS not defined 322 #ifndef POSCFG_MAX_MESSAGES 323 #error POSCFG_MAX_MESSAGES not defined 325 #ifndef POSCFG_MAX_TIMER 326 #error POSCFG_MAX_TIMER not defined 328 #ifndef POSCFG_SOFT_MTASK 329 #error POSCFG_SOFT_MTASK not defined 331 #ifndef POSCFG_CTXSW_COMBINE 332 #error POSCFG_CTXSW_COMBINE not defined 334 #ifndef POSCFG_REALTIME_PRIO 335 #error POSCFG_REALTIME_PRIO not defined 337 #ifndef POSCFG_ISR_INTERRUPTABLE 338 #error POSCFG_ISR_INTERRUPTABLE not defined 340 #ifndef POSCFG_ROUNDROBIN 341 #error POSCFG_ROUNDROBIN not defined 343 #ifndef POSCFG_TASKS_PER_PRIO 344 #error POSCFG_TASKS_PER_PRIO not defined 346 #ifndef POSCFG_FASTCODE 347 #error POSCFG_FASTCODE not defined 349 #ifndef POSCFG_SMALLCODE 350 #error POSCFG_SMALLCODE not defined 352 #ifndef POSCFG_ARGCHECK 353 #error POSCFG_ARGCHECK not defined 355 #ifndef POSCFG_MSG_MEMORY 356 #error POSCFG_MSG_MEMORY not defined 358 #ifndef POSCFG_MSG_BUFSIZE 359 #error POSCFG_MSG_BUFSIZE not defined 361 #ifndef POSCFG_DYNAMIC_MEMORY 362 #error POSCFG_DYNAMIC_MEMORY not defined 364 #ifndef POSCFG_DYNAMIC_REFILL 365 #error POSCFG_DYNAMIC_REFILL 367 #if POSCFG_DYNAMIC_MEMORY != 0 368 #ifndef POS_MEM_ALLOC 369 #error POS_MEM_ALLOC not defined 371 #ifndef POS_MEM_ALLOC 372 #error POS_MEM_ALLOC not defined 375 #ifndef POSCFG_CALLINITARCH 376 #error POSCFG_CALLINITARCH not defined 378 #ifndef POSCFG_LOCK_USEFLAGS 379 #error POSCFG_LOCK_USEFLAGS not defined 381 #if POSCFG_LOCK_USEFLAGS != 0 382 #ifndef POSCFG_LOCK_FLAGSTYPE 383 #error POSCFG_LOCK_FLAGSTYPE not defined 386 #ifndef POS_SCHED_LOCK 387 #error POS_SCHED_LOCK not defined 389 #ifndef POS_SCHED_UNLOCK 390 #error POS_SCHED_UNLOCK not defined 393 #error HZ not defined 395 #ifndef POSCFG_TASKSTACKTYPE 396 #error POSCFG_TASKSTACKTYPE not defined 398 #ifndef POS_USERTASKDATA 399 #error POS_USERTASKDATA not defined 401 #ifndef POSCFG_FEATURE_YIELD 402 #error POSCFG_FEATURE_YIELD not defined 404 #ifndef POSCFG_FEATURE_SLEEP 405 #error POSCFG_FEATURE_SLEEP not defined 407 #ifndef POSCFG_FEATURE_EXIT 408 #error POSCFG_FEATURE_EXIT not defined 410 #ifndef POSCFG_FEATURE_GETPRIORITY 411 #error POSCFG_FEATURE_GETPRIORITY not defined 413 #ifndef POSCFG_FEATURE_SETPRIORITY 414 #error POSCFG_FEATURE_SETPRIORITY not defined 416 #ifndef POSCFG_FEATURE_SEMAPHORES 417 #error POSCFG_FEATURE_SEMAPHORES not defined 419 #ifndef POSCFG_FEATURE_SEMADESTROY 420 #error POSCFG_FEATURE_SEMADESTROY not defined 422 #ifndef POSCFG_FEATURE_SEMAWAIT 423 #error POSCFG_FEATURE_SEMAWAIT not defined 425 #ifndef POSCFG_FEATURE_MUTEXES 426 #error POSCFG_FEATURE_MUTEXES not defined 428 #ifndef POSCFG_FEATURE_MUTEXDESTROY 429 #error POSCFG_FEATURE_MUTEXDESTROY not defined 431 #ifndef POSCFG_FEATURE_MUTEXTRYLOCK 432 #error POSCFG_FEATURE_MUTEXTRYLOCK not defined 434 #ifndef POSCFG_FEATURE_GETTASK 435 #error POSCFG_FEATURE_GETTASK not defined 437 #ifndef POSCFG_FEATURE_TASKUNUSED 438 #error POSCFG_FEATURE_TASKUNUSED not defined 440 #ifndef POSCFG_FEATURE_MSGBOXES 441 #error POSCFG_FEATURE_MSGBOXES not defined 443 #ifndef POSCFG_FEATURE_MSGWAIT 444 #error POSCFG_FEATURE_MSGWAIT not defined 446 #ifndef POSCFG_FEATURE_INHIBITSCHED 447 #error POSCFG_FEATURE_INHIBITSCHED not defined 449 #ifndef POSCFG_FEATURE_JIFFIES 450 #error POSCFG_FEATURE_JIFFIES not defined 452 #ifndef POSCFG_FEATURE_TIMER 453 #error POSCFG_FEATURE_TIMER not defined 455 #ifndef POSCFG_FEATURE_TIMERDESTROY 456 #error POSCFG_FEATURE_TIMERDESTROY not defined 458 #ifndef POSCFG_FEATURE_TIMERFIRED 459 #error POSCFG_FEATURE_TIMERFIRED not defined 461 #ifndef POSCFG_FEATURE_FLAGS 462 #error POSCFG_FEATURE_FLAGS not defined 464 #ifndef POSCFG_FEATURE_FLAGDESTROY 465 #error POSCFG_FEATURE_FLAGDESTROY not defined 467 #ifndef POSCFG_FEATURE_FLAGWAIT 468 #error POSCFG_FEATURE_FLAGWAIT not defined 470 #ifndef POSCFG_FEATURE_SOFTINTS 471 #error POSCFG_FEATURE_SOFTINTS not defined 473 #ifndef POSCFG_FEATURE_SOFTINTDEL 474 #error POSCFG_FEATURE_SOFTINTDEL not defined 476 #ifndef POSCFG_SOFTINTERRUPTS 477 #error POSCFG_SOFTINTERRUPTS not defined 479 #ifndef POSCFG_SOFTINTQUEUELEN 480 #error POSCFG_SOFTINTQUEUELEN not defined 483 #ifndef POSCFG_FEATURE_IDLETASKHOOK 484 #error POSCFG_FEATURE_IDLETASKHOOK not defined 486 #ifndef POSCFG_FEATURE_ERRNO 487 #error POSCFG_FEATURE_ERRNO not defined 489 #ifndef POSCFG_FEATURE_ATOMICVAR 490 #error POSCFG_FEATURE_ATOMICVAR not defined 492 #ifndef POSCFG_FEATURE_LISTS 493 #error POSCFG_FEATURE_LISTS not defined 495 #ifndef POSCFG_FEATURE_LISTJOIN 496 #error POSCFG_FEATURE_LISTJOIN not defined 498 #ifndef POSCFG_FEATURE_LISTLEN 499 #define POSCFG_FEATURE_LISTLEN 1 502 #ifndef POSCFG_FEATURE_DEBUGHELP 503 #define POSCFG_FEATURE_DEBUGHELP 0 506 #if POSCFG_FEATURE_DEBUGHELP 507 #define POS_DEBUGHELP 510 #ifndef POSCFG_PORTMUTEX 511 #define POSCFG_PORTMUTEX 0 513 #ifndef POSCFG_INT_EXIT_QUICK 514 #define POSCFG_INT_EXIT_QUICK 0 516 #ifndef POSCFG_FEATURE_POWER 517 #define POSCFG_FEATURE_POWER 0 519 #ifndef POSCFG_POWER_WAKEUP 520 #define POSCFG_POWER_WAKEUP 0 524 #if (POSCFG_DYNAMIC_MEMORY != 0) && (POSCFG_DYNAMIC_REFILL != 0) 525 #define SYS_POSTALLOCATE 1 527 #define SYS_POSTALLOCATE 0 529 #if (MVAR_BITS != 8) && (MVAR_BITS != 16) && (MVAR_BITS != 32) 530 #error MVAR_BITS must be 8, 16 or 32 532 #if POSCFG_MAX_PRIO_LEVEL == 0 533 #error POSCFG_MAX_PRIO_LEVEL must not be zero 535 #if (POSCFG_ROUNDROBIN != 0) && (POSCFG_MAX_PRIO_LEVEL > MVAR_BITS) 536 #error POSCFG_MAX_PRIO_LEVEL must not exceed MVAR_BITS 538 #if (POSCFG_ROUNDROBIN == 0) && (POSCFG_MAX_PRIO_LEVEL > (MVAR_BITS*MVAR_BITS)) 539 #error POSCFG_MAX_PRIO_LEVEL must not exceed (MVAR_BITS * MVAR_BITS) 541 #if (POSCFG_MAX_TASKS < 2) && (SYS_POSTALLOCATE == 0) 542 #error POSCFG_MAX_TASKS is less than 2 544 #if (POSCFG_MAX_TASKS > (POSCFG_TASKS_PER_PRIO * POSCFG_MAX_PRIO_LEVEL)) 545 #error POSCFG_MAX_TASKS is much to big 547 #if (POSCFG_MAX_EVENTS < 1) && (SYS_POSTALLOCATE == 0) 548 #error POSCFG_MAX_EVENTS must be at least 1 550 #if POSCFG_TASKS_PER_PRIO > MVAR_BITS 551 #error POSCFG_TASKS_PER_PRIO can not exceed MVAR_BITS 553 #if (POSCFG_TASKS_PER_PRIO < 2) && (POSCFG_ROUNDROBIN != 0) 554 #error POSCFG_TASKS_PER_PRIO must be at least 2 556 #if (POSCFG_TASKS_PER_PRIO != 1) && (POSCFG_ROUNDROBIN == 0) 557 #error POSCFG_TASKS_PER_PRIO must be 1 when round robin scheduling is disabled 559 #if ((POSCFG_TASKS_PER_PRIO % 3) == 0) || ((POSCFG_TASKS_PER_PRIO % 5) == 0) 560 #error POSCFG_TASKS_PER_PRIO must be 1/2/4/8/16 or 32 562 #if (POSCFG_REALTIME_PRIO >= POSCFG_MAX_PRIO_LEVEL) && (POSCFG_ROUNDROBIN != 0) 563 #error POSCFG_REALTIME_PRIO must be less than POSCFG_MAX_PRIO_LEVEL 565 #if POSCFG_FEATURE_MSGBOXES != 0 566 #if (POSCFG_MAX_MESSAGES < 2) && (SYS_POSTALLOCATE == 0) 567 #error POSCFG_MAX_MESSAGES must be at least 2 569 #if POSCFG_MSG_BUFSIZE < 1 570 #error POSCFG_MSG_BUFSIZE must be at least 1 573 #if (POSCFG_FEATURE_TIMER != 0) 574 #if (POSCFG_MAX_TIMER == 0) && (SYS_POSTALLOCATE == 0) 575 #error POSCFG_MAX_TIMER must be at least 1 578 #if (POSCFG_TASKSTACKTYPE < 0) || (POSCFG_TASKSTACKTYPE > 2) 579 #error POSCFG_TASKSTACKTYPE must be 0, 1 or 2 581 #if POSCFG_ALIGNMENT == 0 582 #undef POSCFG_ALIGNMENT 583 #define POSCFG_ALIGNMENT 1 585 #if ((POSCFG_ALIGNMENT % 3) == 0) || ((POSCFG_ALIGNMENT % 5) == 0) 586 #error POSCFG_ALIGNMENT must be 1/2/4/8/16/32/64/128/256 etc. 589 #if POSCFG_FEATURE_SOFTINTS != 0 590 #if POSCFG_SOFTINTERRUPTS == 0 591 #error POSCFG_SOFTINTERRUPTS must be greater than 0 593 #if POSCFG_SOFTINTQUEUELEN < 2 594 #error POSCFG_SOFTINTQUEUELEN must be at least 2 600 #ifndef POSCFG_TASKCB_USERSPACE 601 #define POSCFG_TASKCB_USERSPACE 0 603 #if POSCFG_FEATURE_SEMAPHORES == 0 604 #undef POSCFG_FEATURE_SEMADESTROY 605 #define POSCFG_FEATURE_SEMADESTROY 0 607 #if POSCFG_FEATURE_FLAGS == 0 608 #undef POSCFG_FEATURE_FLAGDESTROY 609 #define POSCFG_FEATURE_FLAGDESTROY 0 611 #if POSCFG_FEATURE_MUTEXES == 0 612 #undef POSCFG_FEATURE_MUTEXDESTROY 613 #define POSCFG_FEATURE_MUTEXDESTROY 0 615 #if (POSCFG_FEATURE_MUTEXDESTROY != 0) && (POSCFG_FEATURE_SEMADESTROY == 0) 616 #undef POSCFG_FEATURE_SEMADESTROY 617 #define POSCFG_FEATURE_SEMADESTROY 1 620 #if (POSCFG_FEATURE_MSGBOXES != 0) && (SYS_POSTALLOCATE == 0) 621 #define SYS_MSGBOXEVENTS 2 623 #define SYS_MSGBOXEVENTS 0 625 #if (POSCFG_FEATURE_MSGBOXES != 0) && (POSCFG_FEATURE_GETTASK == 0) 626 #undef POSCFG_FEATURE_GETTASK 627 #define POSCFG_FEATURE_GETTASK 1 629 #if (POSCFG_FEATURE_SEMAWAIT != 0) || (POSCFG_FEATURE_MSGWAIT != 0) 630 #define SYS_TASKDOUBLELINK 1 632 #define SYS_TASKDOUBLELINK 0 634 #define SYS_EVENTS_USED \ 635 (POSCFG_FEATURE_MUTEXES | POSCFG_FEATURE_MSGBOXES | \ 636 POSCFG_FEATURE_FLAGS | POSCFG_FEATURE_LISTS) 637 #define SYS_FEATURE_EVENTS (POSCFG_FEATURE_SEMAPHORES | SYS_EVENTS_USED) 638 #define SYS_FEATURE_EVENTFREE (POSCFG_FEATURE_SEMADESTROY | \ 639 POSCFG_FEATURE_MUTEXDESTROY | POSCFG_FEATURE_FLAGDESTROY | \ 640 POSCFG_FEATURE_LISTS) 641 #if (POSCFG_FEATURE_MSGBOXES != 0) && (POSCFG_FEATURE_EXIT != 0) 642 #undef SYS_FEATURE_EVENTFREE 643 #define SYS_FEATURE_EVENTFREE 1 645 #ifndef POSCFG_FEATURE_LARGEJIFFIES 647 #define POSCFG_FEATURE_LARGEJIFFIES 1 649 #define POSCFG_FEATURE_LARGEJIFFIES 0 655 #if POSCFG_FEATURE_SETPRIORITY != 0 656 #define SYS_TASKEVENTLINK 1 658 #define SYS_TASKEVENTLINK 0 671 #define POSFROMEXT extern 673 #define POSEXTERN extern 677 #if POSCFG_ROUNDROBIN == 0 678 #define SYS_TASKTABSIZE_X MVAR_BITS 679 #define SYS_TASKTABSIZE_Y ((POSCFG_MAX_PRIO_LEVEL+MVAR_BITS-1)/MVAR_BITS) 681 #define SYS_TASKTABSIZE_X POSCFG_TASKS_PER_PRIO 682 #define SYS_TASKTABSIZE_Y POSCFG_MAX_PRIO_LEVEL 685 #define SYS_TASKSTATE (POSCFG_FEATURE_TASKUNUSED | POSCFG_FEATURE_MSGBOXES) 687 #if POSCFG_LOCK_USEFLAGS != 0 688 #define POS_LOCKFLAGS POSCFG_LOCK_FLAGSTYPE flags 690 #define POS_LOCKFLAGS do { } while(0) 693 #define POSTASKSTATE_UNUSED 0 694 #define POSTASKSTATE_ZOMBIE 1 695 #define POSTASKSTATE_ACTIVE 2 697 #define INFINITE ((UINT_t)~0) 752 #if (DOX==0) && (HZ <= 1000) 753 #define MS(msec) (((msec)<(1000/HZ)) ? \ 754 ((UINT_t)1) : ((UINT_t)((1L*HZ*(msec))/1000))) 756 #define MS(msec) ((UINT_t)((1L*HZ*(msec))/1000)) 820 #if (DOX!=0) || (POSCFG_FEATURE_LARGEJIFFIES == 0) 847 #if (DOX!=0) ||(POSCFG_FEATURE_IDLETASKHOOK != 0) 852 #if (DOX!=0) ||(POSCFG_FEATURE_POWER != 0) 856 #define POSPOWER_EVENT_SLEEP 0 857 #define POSPOWER_EVENT_WAKEUP 1 892 #if (DOX!=0) || (POSCFG_FEATURE_LISTS != 0) 895 struct POSLIST*
volatile prev;
896 struct POSLIST*
volatile next;
899 #if POSCFG_FEATURE_LISTLEN != 0 904 struct POSLIST*
volatile prev;
905 struct POSLIST*
volatile next;
906 #if POSCFG_FEATURE_LISTLEN != 0 907 struct POSLISTHEAD*
volatile head;
950 #ifndef POSCFG_FBIT_USE_LUTABLE 951 #define POSCFG_FBIT_USE_LUTABLE 0 953 #if (POSCFG_FBIT_USE_LUTABLE > 1) && (POSCFG_ROUNDROBIN == 0) 954 #undef POSCFG_FBIT_USE_LUTABLE 955 #define POSCFG_FBIT_USE_LUTABLE 1 958 #if POSCFG_FBIT_USE_LUTABLE == 1 959 #if POSCFG_ROUNDROBIN == 0 961 extern VAR_t const p_pos_fbittbl[256];
963 #define FINDBIT(x) p_pos_fbittbl[x] 966 #define FINDBIT(x, o) p_pos_findbit(x, o) 968 #elif POSCFG_FBIT_USE_LUTABLE == 2 970 extern VAR_t const p_pos_fbittbl_rr[8][256];
972 #define FINDBIT(x, o) p_pos_fbittbl_rr[o][x] 1035 #if POSCFG_FEATURE_ERRNO != 0 1039 POSEXTERN
VAR_t* _errno_p(
void);
1040 #define errno (*_errno_p()) 1230 #if (DOX!=0) || (POSCFG_ROUNDROBIN == 0) 1232 #define POS_FINDBIT(bf) FINDBIT(bf, 0) 1233 #define POS_FINDBIT_EX(bf, ofs) FINDBIT(bf, 0) 1236 #define POS_FINDBIT(bf) p_pos_findbit(bf) 1237 #define POS_FINDBIT_EX(bf, ofs) p_pos_findbit(bf) 1241 #define POS_FINDBIT(bf) FINDBIT(bf, 0) 1242 #define POS_FINDBIT_EX(bf, ofs) FINDBIT(bf, ofs) 1245 #define POS_FINDBIT(bf) p_pos_findbit(bf, 0) 1246 #define POS_FINDBIT_EX(bf, ofs) p_pos_findbit(bf, ofs) 1275 #if (DOX!=0) || (POSCFG_CALLINITARCH != 0) 1290 #if (DOX!=0) || (POSCFG_TASKSTACKTYPE == 0) 1314 #if (DOX!=0) || (POSCFG_TASKSTACKTYPE == 1) 1363 #if (DOX!=0) || (POSCFG_PORTMUTEX != 0) 1380 #if (DOX!=0) || (POSCFG_TASKSTACKTYPE == 2) 1472 #if (DOX!=0) || POSCFG_INT_EXIT_QUICK == 1 1510 #if (DOX!=0) || POSCFG_INT_EXIT_QUICK == 1 1560 #if (DOX!=0) || POSCFG_FEATURE_TICKLESS == 1 1585 #if (DOX!=0) || POSCFG_FEATURE_POWER == 1 1596 #if (DOX!=0) || POSCFG_POWER_WAKEUP == 1 1609 #if (DOX!=0) || POSCFG_FEATURE_TICKLESS == 1 1646 #if (DOX!=0) || (POSCFG_FEATURE_YIELD != 0) 1658 #if (DOX!=0) || (POSCFG_FEATURE_SLEEP != 0) 1676 #if (DOX!=0) || (POSCFG_TASKSTACKTYPE == 0) 1694 VAR_t priority,
void *stackstart);
1713 void *stackFirstTask,
void *stackIdleTask);
1715 #if (DOX!=0) || (POSCFG_TASKSTACKTYPE == 1) 1757 #if (DOX!=0) || (POSCFG_TASKSTACKTYPE == 2) 1796 #if (DOX!=0) || (POSCFG_FEATURE_EXIT != 0) 1807 #if (DOX!=0) || (POSCFG_FEATURE_GETTASK != 0) 1819 #if (DOX!=0) || (POSCFG_FEATURE_TASKUNUSED != 0) 1836 #if (DOX!=0) || (POSCFG_FEATURE_SETPRIORITY != 0) 1854 #if (DOX!=0) || (POSCFG_FEATURE_GETPRIORITY != 0) 1867 #if (DOX!=0) || (POSCFG_FEATURE_INHIBITSCHED != 0) 1893 #if (DOX!=0) || (POSCFG_TASKCB_USERSPACE > 0) 1905 #if (DOX!=0) || (POSCFG_FEATURE_IDLETASKHOOK != 0) 1936 #if (DOX!=0) || POSCFG_FEATURE_POWER == 1 1976 #if (DOX!=0) || (SYS_FEATURE_EVENTS != 0) 2018 #if (DOX!=0) || (SYS_FEATURE_EVENTFREE != 0) 2044 #if (DOX!=0) || (POSCFG_SMALLCODE == 0) || (POSCFG_FEATURE_SEMAWAIT == 0) 2048 #define posSemaGet(sema) posSemaWait(sema, INFINITE) 2064 #if (DOX!=0) || (POSCFG_FEATURE_SEMAWAIT != 0) 2093 #if (DOX!=0) || (POSCFG_FEATURE_MUTEXES != 0) 2117 #if (DOX!=0) || (POSCFG_FEATURE_MUTEXDESTROY != 0) 2131 #if (DOX!=0) || (POSCFG_FEATURE_MUTEXTRYLOCK != 0) 2181 #if (DOX!=0) || (POSCFG_FEATURE_MSGBOXES != 0) 2204 #if (DOX!=0) || (POSCFG_MSG_MEMORY != 0) 2269 #if (DOX!=0) || (POSCFG_SMALLCODE == 0) || (POSCFG_FEATURE_MSGWAIT == 0) 2273 #define posMessageGet() posMessageWait(INFINITE) 2290 #if (DOX!=0) || (POSCFG_FEATURE_MSGWAIT != 0) 2324 #if (DOX!=0) || (POSCFG_FEATURE_FLAGS != 0) 2347 #if (DOX!=0) || (POSCFG_FEATURE_FLAGDESTROY != 0) 2391 #if (DOX!=0) || (POSCFG_FEATURE_FLAGWAIT != 0) 2414 #define POSFLAG_MODE_GETSINGLE 0 2415 #define POSFLAG_MODE_GETMASK 1 2444 #define HZ (timerticks per second) 2456 #if (DOX!=0) || (POSCFG_FEATURE_JIFFIES != 0) 2457 #if (DOX!=0) || (POSCFG_FEATURE_LARGEJIFFIES == 0) 2460 POSEXTERN
JIF_t POSCALL posGetJiffies(
void);
2461 #define jiffies posGetJiffies() 2474 #define POS_TIMEAFTER(x, y) ((((SJIF_t)(x)) - ((SJIF_t)(y))) >= 0) 2478 #if (DOX!=0) || (POSCFG_FEATURE_TIMER != 0) 2535 #if (DOX!=0) || (POSCFG_FEATURE_TIMERDESTROY != 0) 2548 #if (DOX!=0) || (POSCFG_FEATURE_TIMERFIRED != 0) 2569 #if (DOX!=0) || (POSCFG_FEATURE_SOFTINTS != 0) 2634 #if (DOX!=0) || (POSCFG_FEATURE_SOFTINTDEL != 0) 2656 #if (DOX!=0) || (POSCFG_FEATURE_ATOMICVAR != 0) 2726 #if (DOX!=0) || (POSCFG_FEATURE_LISTS != 0) 2742 #define POSLIST_HEAD 0 2743 #define POSLIST_TAIL 1 2807 #if (DOX!=0) || (POSCFG_FEATURE_LISTJOIN != 0) 2831 #if (DOX!=0) || (POSCFG_FEATURE_LISTLEN != 0) 2881 #define POSLIST_ELEMENT(elem, type, member) 2883 #define POSLIST_ELEMENT(elem, type, member) \ 2884 ((type*)((char*)(elem)-(char*)(&((type*)NULL)->member))) 2890 #define POSLIST_IS_EMPTY(plisthead) \ 2891 ((plisthead)->next == (POSLIST_t*)(plisthead)) 2896 #define POSLIST_NEXT_ENTRY(plist) (plist)->next 2901 #define POSLIST_PREV_ENTRY(plist) (plist)->prev 2906 #define POSLIST_FIRST_ENTRY(plisthead) (plisthead)->next 2911 #define POSLIST_LAST_ENTRY(plisthead) (plisthead)->prev 2916 #define POSLIST_IS_FIRST_ENTRY(element) ((element)->prev==(element)->head) 2921 #define POSLIST_IS_LAST_ENTRY(element) ((element)->next==(element)->head) 2925 #define POSLIST_IS_END(plisthead, element) \ 2926 ((element)==(POSLIST_t*)(plisthead)) 2946 #define POSLIST_FOR_EACH_ENTRY(plisthead, runvar) 2948 #define POSLIST_FOR_EACH_ENTRY(plisthead, runvar) \ 2949 for (runvar = POSLIST_FIRST_ENTRY(plisthead); \ 2950 !POSLIST_IS_END(plisthead, runvar); \ 2951 runvar = POSLIST_NEXT_ENTRY(runvar)) 2976 #define POSLIST_FOREACH_BEGIN(plisthead, runvar, type, listmember) 2978 #define POSLIST_FOREACH_BEGIN(plisthead, runvar, type, listmember) \ 2979 do { POSLIST_t *r, *n; \ 2980 for (r = POSLIST_FIRST_ENTRY(plisthead); \ 2981 !POSLIST_IS_END(plisthead, r); r = n) { \ 2982 n = POSLIST_NEXT_ENTRY(r); \ 2983 runvar = POSLIST_ELEMENT(r, type, listmember); 2993 #define POSLIST_FOREACH_END 2995 #define POSLIST_FOREACH_END \ 3051 #if (DOX!=0) || defined(HAVE_PLATFORM_ASSERT) 3060 #define P_ASSERT(text,x) \ 3061 if (!(x)) POSCALL p_pos_assert((const char*)(text), __FILE__, __LINE__) 3063 #define P_ASSERT(text,x) do { } while(0) 3066 #if (DOX!=0) || defined(POS_DEBUGHELP) 3195 #define POS_SETTASKNAME(taskhandle, taskname) 3216 #define POS_SETEVENTNAME(eventhandle, name) 3219 #define POS_SETTASKNAME(taskhandle, taskname) \ 3220 do { if ((taskhandle) != NULL) (taskhandle)->deb.name = taskname;} while(0) 3221 #define POS_SETEVENTNAME(eventhandle, name) \ 3222 posdeb_setEventName(eventhandle, name) 3223 POSEXTERN
void posdeb_setEventName(
void *event,
const char *
name);
3245 extern struct PICOTASK *picodeb_taskhistory[3];
3280 #define POS_SETTASKNAME(taskhandle, name) do { } while(0) 3281 #define POS_SETEVENTNAME(eventhandle, name) do { } while(0) 3295 #ifdef PICOS_PRIVINCL 3299 POSEXTERN
UVAR_t posShift1lTab_g[8];
3301 #define pos_shift1l(bits) posShift1lTab_g[(UVAR_t)(bits)] 3303 #define pos_shift1l(bits) (((UVAR_t)1)<<(bits)) 3313 #ifdef POSCFG_ENABLE_NANO 3314 #undef POSCFG_ENABLE_NANO 3316 #define POSCFG_ENABLE_NANO 1 3318 #ifndef POSCFG_ENABLE_NANO 3319 #define POSCFG_ENABLE_NANO 0 3322 #if POSCFG_ENABLE_NANO != 0 3325 #include <picoos\pos_nano.h> 3335 #ifndef POSCFG_TASKEXIT_HOOK 3336 #define POSCFG_TASKEXIT_HOOK 0 3343 #ifndef NOS_TASKDATA 3344 #define NOS_TASKDATA 3347 #if POSCFG_TASKEXIT_HOOK != 0 3352 typedef void (*POSTASKEXITFUNC_t)(
POSTASK_t task, texhookevent_t event);
3358 #if POSCFG_TASKCB_USERSPACE > 0 3362 #if POSCFG_TASKEXIT_HOOK != 0 3363 POSTASKEXITFUNC_t exithook;
3366 #if POSCFG_ARGCHECK > 1 3369 #if SYS_TASKDOUBLELINK != 0 3370 struct POSTASK *prev;
3372 struct POSTASK *next;
3374 #if SYS_TASKTABSIZE_Y > 1 3378 #ifndef POS_DEBUGHELP 3381 #if SYS_TASKSTATE != 0 3384 #if POSCFG_FEATURE_ERRNO != 0 3387 #if POSCFG_FEATURE_MSGBOXES != 0 3393 #ifdef POS_DEBUGHELP 3396 #if SYS_TASKEVENTLINK != 0 void(* POSIDLEFUNC_t)(void)
Idle task function pointer.
Definition: picoos.h:849
POSEXTERN void POSCALL posTimerDestroy(POSTIMER_t tmr)
struct POSTIMER * POSTIMER_t
Handle to a timer object.
Definition: picoos.h:885
POSEXTERN VAR_t POSCALL posMessageSend(void *buf, POSTASK_t taskhandle)
POSEXTERN volatile UVAR_t posInInterrupt_g
Global flag variable. This variable is nonzero when the CPU is currently executing an interrupt servi...
Definition: picoos.h:1009
#define POSCFG_ALIGNMENT
Definition: port.h:99
POSEXTERN void POSCALL c_pos_intExit(void)
POSEXTERN void POSCALL posSoftInt(UVAR_t intno, UVAR_t param)
UINT_t timeout
State of the task's timeout counter.
Definition: picoos.h:3168
Definition: picoos.h:3080
struct PICOEVENT PICOEVENT
Event info structure.
VAR_t errno
Unix style error variable. This variable is global for the currently runnig task. ...
Definition: picoos.h:1033
POSEXTERN void POSCALL posTaskExit(void)
POSFROMEXT void POSCALL p_pos_intContextSwitchPending(void)
POSEXTERN void *POSCALL posMessageAlloc(void)
POSEXTERN VAR_t POSCALL posMutexTryLock(POSMUTEX_t mutex)
#define MPTR_t
Definition: port.h:89
POSEXTERN void POSCALL posListRemove(POSLIST_t *listelem)
POSEXTERN POSLIST_t *POSCALL posListGet(POSLISTHEAD_t *listhead, UVAR_t pos, UINT_t timeout)
POSEXTERN void POSCALL posTaskSleep(UINT_t ticks)
const char * name
Name of this task (ASCII string)
Definition: picoos.h:3157
Definition: picoos.h:3076
POSEXTERN VAR_t POSCALL posSemaSignal(POSSEMA_t sema)
POSEXTERN INT_t POSCALL posAtomicAdd(POSATOMIC_t *var, INT_t value)
POSEXTERN INT_t POSCALL posAtomicSub(POSATOMIC_t *var, INT_t value)
POSEXTERN VAR_t POSCALL posTimerStart(POSTIMER_t tmr)
struct PICOEVENT * prev
Pointer to the previous event structure.
Definition: picoos.h:3119
POSFROMEXT void POSCALL p_pos_powerTickResume(void)
POSEXTERN VAR_t POSCALL posTaskUnused(POSTASK_t taskhandle)
Definition: picoos.h:3102
const char * name
Name of this event (ASCII string)
Definition: picoos.h:3130
POSFROMEXT void POSCALL p_pos_initTask(POSTASK_t task, void *stackstart, POSTASKFUNC_t funcptr, void *funcarg)
POSFROMEXT void POSCALL p_pos_freeStack(POSTASK_t task)
struct PICOTASK * picodeb_taskhistory[3]
This array contains the last 3 tasks that run.
POSFROMEXT void POSCALL p_pos_initArch(void)
POSEXTERN void POSCALL posFlagDestroy(POSFLAG_t flg)
POSEXTERN void POSCALL c_pos_intExitQuick(void)
PTASKSTATE
Task states (used for debugging when POSCFG_FEATURE_DEBUGHELP is set to 1)
Definition: picoos.h:3072
POSEXTERN VAR_t POSCALL posMutexLock(POSMUTEX_t mutex)
POSEXTERN void POSCALL posMutexDestroy(POSMUTEX_t mutex)
POSEXTERN POSTASK_t POSCALL posTaskCreate(POSTASKFUNC_t funcptr, void *funcarg, VAR_t priority, void *stackstart)
UVAR_t JIF_t
Timer counter type. Can be UVAR_t or UINT_t.
Definition: picoos.h:828
POSEXTERN POSPOWERCB_t POSCALL posPowerSetCallback(POSPOWERCB_t callback)
struct PICOTASK * next
Pointer to the next task info structure.
Definition: picoos.h:3149
Definition: picoos.h:3088
void * handle
Handle value of the pico]OS event.
Definition: picoos.h:3128
PEVENTTYPE
Event types (used for debugging when POSCFG_FEATURE_DEBUGHELP is set to 1)
Definition: picoos.h:3098
pico]OS configuration file
struct PICOEVENT * picodeb_eventlist
Pointer to the list of all system events.
POSEXTERN volatile POSTASK_t posCurrentTask_g
Global task variable. This variable points to the environment structure of the currently active task...
Definition: picoos.h:990
struct POSMUTEX * POSMUTEX_t
Handle to a mutex object.
Definition: picoos.h:875
POSFROMEXT void POSCALL p_pos_intContextSwitch(void)
POSEXTERN void POSCALL posMessageFree(void *buf)
POSEXTERN POSIDLEFUNC_t POSCALL posInstallIdleTaskHook(POSIDLEFUNC_t idlefunc)
POSEXTERN void POSCALL posTaskSchedUnlock(void)
POSEXTERN VAR_t POSCALL posSemaGet(POSSEMA_t sema)
POSEXTERN void *POSCALL posTaskGetUserspace(void)
POSEXTERN VAR_t POSCALL posTaskSetPriority(POSTASK_t taskhandle, VAR_t priority)
POSEXTERN void POSCALL posPowerDisableSleep(void)
POSEXTERN void POSCALL posSemaDestroy(POSSEMA_t sema)
POSFROMEXT void POSCALL p_pos_lock(void)
pico]OS nano layer main include file
POSEXTERN void POSCALL posTaskSchedLock(void)
POSEXTERN void POSCALL c_pos_timerStep(UVAR_t ticks)
Definition: picoos.h:3085
struct POSFLAG * POSFLAG_t
Handle to a flag object.
Definition: picoos.h:880
Definition: picoos.h:3100
POSEXTERN void POSCALL posListAdd(POSLISTHEAD_t *listhead, UVAR_t pos, POSLIST_t *new)
POSEXTERN POSFLAG_t POSCALL posFlagCreate(void)
POSFROMEXT void POSCALL p_pos_softContextSwitch(void)
POSEXTERN POSTIMER_t POSCALL posTimerCreate(void)
POSFROMEXT void POSCALL p_pos_startFirstContext(void)
void(* POSTASKFUNC_t)(void *arg)
Generic function pointer.
Definition: picoos.h:837
POSEXTERN VAR_t POSCALL posSoftIntDelHandler(UVAR_t intno)
POSEXTERN void POSCALL posListJoin(POSLISTHEAD_t *baselisthead, UVAR_t pos, POSLISTHEAD_t *joinlisthead)
Definition: picoos.h:3077
POSEXTERN VAR_t POSCALL posFlagWait(POSFLAG_t flg, UINT_t timeoutticks)
POSEXTERN void POSCALL posListTerm(POSLISTHEAD_t *listhead)
unsigned MINT_t UINT_t
Unsigned integer.
Definition: picoos.h:802
POSEXTERN void POSCALL c_pos_intEnter(void)
POSEXTERN VAR_t POSCALL posSoftIntSetHandler(UVAR_t intno, POSINTFUNC_t inthandler)
struct POSLIST POSLIST_t
List variable. This variable type is used as running variable of a list or as list link...
Definition: picoos.h:914
POSEXTERN POSTASK_t POSCALL posTaskGetCurrent(void)
POSEXTERN VAR_t POSCALL posSemaWait(POSSEMA_t sema, UINT_t timeoutticks)
POSEXTERN VAR_t POSCALL posMutexUnlock(POSMUTEX_t mutex)
POSEXTERN VAR_t POSCALL posFlagSet(POSFLAG_t flg, UVAR_t flgnum)
struct PICOTASK * picodeb_tasklist
Pointer to the list of active tasks.
struct PICOEVENT * event
Cross-reference to the involved event.
Definition: picoos.h:3166
Definition: picoos.h:3083
signed MVAR_t VAR_t
Signed machine variable type. This variable type is the fastest for the target architecture.
Definition: picoos.h:770
#define MVAR_t
Definition: port.h:71
POSTASKFUNC_t func
First function that ran in the task context.
Definition: picoos.h:3155
POSEXTERN POSSEMA_t POSCALL posSemaCreate(INT_t initcount)
POSFROMEXT void POSCALL p_pos_powerWakeup(void)
#define POSCFG_TASKCB_USERSPACE
Definition: poscfg.h:196
POSEXTERN void POSCALL posPowerEnableSleep(void)
PTASKSTATE state
Current state of the task (see PTASKSTATE for details).
Definition: picoos.h:3160
POSFROMEXT void POSCALL p_pos_powerSleep(void)
struct PICOEVENT * next
Pointer to the next event info structure.
Definition: picoos.h:3117
POSEXTERN void POSCALL posListInit(POSLISTHEAD_t *listhead)
POSEXTERN void POSCALL posTaskYield(void)
struct PICOTASK PICOTASK
Task info structure.
POSEXTERN void *POSCALL posMessageWait(UINT_t timeoutticks)
Definition: picoos.h:3086
Definition: picoos.h:3074
unsigned MVAR_t UVAR_t
Unsigned machine variable type. This variable type is the fastest for the target architecture.
Definition: picoos.h:777
POSEXTERN void POSCALL posAtomicSet(POSATOMIC_t *var, INT_t value)
POSEXTERN void POSCALL posInit(POSTASKFUNC_t firstfunc, void *funcarg, VAR_t priority, void *stackFirstTask, void *stackIdleTask)
POSEXTERN volatile JIF_t jiffies
Global timer variable. The jiffies counter variable is incremented HZ times per second.
Definition: picoos.h:2458
POSEXTERN void *POSCALL posMessageGet(void)
INT_t counter
State of the internal counter of the event (semaphore or mutex), or bitfield of flags (flag event) ...
Definition: picoos.h:3132
POSEXTERN volatile UVAR_t posRunning_g
Global flag variable. This variable is nonzero when the operating system is initialized and running...
Definition: picoos.h:1021
void(* POSINTFUNC_t)(UVAR_t arg)
Software interrupt callback function pointer.
Definition: picoos.h:845
signed MINT_t INT_t
Signed integer.
Definition: picoos.h:791
Task info structure.
Definition: picoos.h:3147
POSFROMEXT UVAR_t POSCALL p_pos_findbit(const UVAR_t bitfield)
VAR_t SJIF_t
Signed type of JIF_t.
Definition: picoos.h:824
struct POSLISTHEAD POSLISTHEAD_t
List variable. This variable defines the head of a list.
Definition: picoos.h:919
struct POSTASK * POSTASK_t
Task environment structure.
Definition: picoos.h:942
Definition: picoos.h:3075
PEVENTTYPE type
Type of the event (semaphore / mutex / flag event, see PEVENTTYPE for details).
Definition: picoos.h:3122
Definition: picoos.h:3078
POSTASK_t handle
Handle value of the pico]OS task.
Definition: picoos.h:3153
struct POSSEMA * POSSEMA_t
Handle to a semaphore object.
Definition: picoos.h:870
POSEXTERN UINT_t POSCALL posListLen(POSLISTHEAD_t *listhead)
POSEXTERN VAR_t POSCALL posTimerSet(POSTIMER_t tmr, POSSEMA_t sema, UINT_t waitticks, UINT_t periodticks)
void(* POSPOWERCB_t)(UVAR_t event)
Power management callback function pointer.
Definition: picoos.h:854
POSFROMEXT void POSCALL p_pos_powerTickSuspend(UVAR_t ticks)
volatile INT_t POSATOMIC_t
Atomic variable.
Definition: picoos.h:890
unsigned MPTR_t MEMPTR_t
Memory pointer type.
Definition: picoos.h:818
POSEXTERN VAR_t POSCALL posTimerFired(POSTIMER_t tmr)
POSEXTERN void POSCALL c_pos_timerInterrupt(void)
struct PICOTASK * prev
Pointer to the previous task structure.
Definition: picoos.h:3151
POSFROMEXT void POSCALL p_pos_unlock(void)
POSEXTERN INT_t POSCALL posAtomicGet(POSATOMIC_t *var)
POSEXTERN VAR_t POSCALL posMessageAvailable(void)
#define POS_USERTASKDATA
Definition: port.h:409
Definition: picoos.h:3089
Event info structure.
Definition: picoos.h:3115
Definition: picoos.h:3101
POSEXTERN VAR_t POSCALL posTimerStop(POSTIMER_t tmr)
Definition: picoos.h:3079
POSEXTERN volatile POSTASK_t posNextTask_g
Global task variable. This variable points to the environment structure of the next task that shall b...
Definition: picoos.h:1000
Definition: picoos.h:3082
POSEXTERN POSMUTEX_t POSCALL posMutexCreate(void)
POSEXTERN UINT_t POSCALL c_pos_nextWakeup(void)
POSEXTERN VAR_t POSCALL posFlagGet(POSFLAG_t flg, UVAR_t mode)
POSEXTERN VAR_t POSCALL posTaskGetPriority(POSTASK_t taskhandle)