femtoos_headers/femtoos_globals.h

Go to the documentation of this file.
00001 /*
00002  * Femto OS v 0.91 - Copyright (C) 2008-2009 Ruud Vlaming
00003  *
00004  * This file is part of the Femto OS distribution.
00005  *
00006  * This program is free software: you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation, version 3 of the License.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  *
00018  * Please note that, due to the GPLv3 license, for application of this
00019  * work and/or combined work in embedded systems special obligations apply.
00020  * If these are not to you liking, please know the Femto OS is dual
00021  * licensed. A commercial license and support are available.
00022  * See http://www.femtoos.org/ for details.
00023  */
00024 
00025 #ifndef FEMTOOS_GLOBALS_H
00026 #define FEMTOOS_GLOBALS_H
00027 
00028 /* DISCUSSION
00029  * Unfortunately we must include here some hardware dependent files. avr/io.h could
00030  * probably be moved to port.h, but this does not hold true for the avr/pgmspace.h.
00031  * Therefore we kept them together. The point is, storage in flash is not so hardware
00032  * independent as it may seem. Thus, if you want to port this OS, this is one point
00033  * to look at.
00034  */
00035 
00036 #include  <avr/io.h>
00037 
00038 /* These includes are not compatible with assembler language. But since we need the
00039  * globals in the startup code, we must explicitly exclude them here.
00040  */
00041 #ifndef __ASSEMBLER__
00042   #include  <avr/pgmspace.h>
00043   #include  <string.h>
00044 #endif
00045 
00049 #define SystemID   "FemtoOS 0.91"
00050 
00054 #define true       1
00055 #define false      0
00056 
00057 
00058 /* DISCUSSION
00059  * We don't use primitive data types in the code anywhere. All types are related
00060  * to the types below. We compile with the option -mint8, otherwise gcc promotes
00061  * a lot of 8 bit operations to 16 bit. Although this is standard behavior, and
00062  * can be suppressed with the right casts, to my opinion this has been the wrong
00063  * choice. C is a machine language and should respect the true lengths of the
00064  * defined variables. Note that it seems that GCC does not honor the bit lengths
00065  * defined; so why are the present anyway? With -mint8 int32_t becomes a 16 bit
00066  * integer. Why? This is totally confusing.
00067  */
00068 #define Tchar      unsigned char
00069 #define Tbool      Tuint08
00070 #define Taddress   Tchar *
00071 #define Tbyte      uint8_t
00072 #define Tword      uint16_t
00073 #define Tsint08    int8_t
00074 #define Tuint08    uint8_t
00075 #define Tsint16    int16_t
00076 #define Tuint16    uint16_t
00077 #define Tdouble    double
00078 #define Tenum      uint8_t
00079 
00080 
00089 #define defDelayTimeMax        0xFEFF
00090 
00098 #define defDelayTimeZero       0x0000
00099 
00106 #define defLockBlockInfinite   0x0000
00107 
00115 #define defLockDoNotBlock      0x0001
00116 
00126 #define defStackInitByte       0x00
00127 
00140 #define defCurrentTaskNumber   0x80
00141 
00154 #define defCurrentTaskName     defCurrentTaskName
00155 
00163 #define defFromFileStart        0x00
00164 
00173 #define defFromFileEnd          0xFF
00174 
00183 #define defUntilFileEnd         0xFF
00184 
00193 #define defReadOnly             0x01
00194 
00203 #define defReadWrite            0x00
00204 
00211 #define defAllEvents            0xFF
00212 
00225 #define    defRestartSuspended  0x00
00226 
00240 #define    defRestartSleeping   0x40
00241 
00252 #define    defRestartDefault    0x80
00253 
00254 
00260 #define    defRestartShared     0x80
00261 
00271 #define    defRestartRunning    0xC0
00272 
00273 
00281 #define    defSuspendNow        0x01
00282 
00290 #define    defSuspendCheck      0x02
00291 
00298 #define    defSuspendClear      0x04
00299 
00300 
00327 #define  errUnused_0x00                   0x00
00328 
00346 #define  errInsufficientCapabilities      0x01
00347 
00351 #define  errUnused_0x02                   0x02
00352 
00363 #define  errTaskStackWillOverflow         0x03
00364 
00389 #define  errTaskIllegalRegisterUse        0x04
00390 
00402 #define  errTaskTakesTooLong              0x05
00403 
00414 #define  errTaskNestingOverflowed         0x06
00415 
00426 #define  errTaskNestingUnderflowed        0x07
00427 
00436 #define  errTaskNestingPresent            0x08
00437 
00441 #define errUnused_0x09                    0x09
00442 
00451 #define  errTaskHoldsNoSlots              0x0A
00452 
00462 #define  errSlotDoubleUsed                0x0B
00463 
00474 #define  errQueuOverrun                   0x0C
00475 
00486 #define  errQueuUnderrun                  0x0D
00487 
00497 #define  errTaskPriorityTooHigh            0x0E
00498 
00511 #define  errTaskDelayTooLong              0x0F
00512 
00525 #define  errTaskDelayTooShort             0x10
00526 
00536 #define  errSlotZeroUsed                  0x11
00537 
00546 #define  errSlotTypeMismatch              0x12
00547 
00556 #define  errSlotTwins                     0x13
00557 
00567 #define  errIllegalDominantState          0x14
00568 
00579 #define  errQueuWriteLimit                0x15
00580 
00591 #define  errQueuReadLimit                 0x16
00592 
00602 #define  errSlotDecreaseFail              0x17
00603 
00613 #define  errSlotIncreaseFail              0x18
00614 
00624 #define  errFileOpenMode                  0x19
00625 
00636 #define  errFileInvalidFileNumber         0x1A
00637 
00647 #define  errFileOutOfRange                0x1B
00648 
00658 #define  errFileClosedMode                0x1C
00659 
00671 #define  errFileWrongMode                 0x1D
00672 
00681 #define  errInvalidRestartMode            0x1E
00682 
00691 #define  errInvalidSuspendMode            0x1F
00692 
00693 
00701 #define  fatInternalError                 0x20
00702 
00712 #define  fatOsStackUnderMinimum           0x21
00713 
00723 #define  fatOsStackOverflowed             0x22
00724 
00734 #define  fatIllegalEvent                  0x23
00735 
00746 #define  fatTaskStackOverflowed           0x24
00747 
00757 #define  fatIsrStackOverflowed            0x25
00758 
00769 #define  fatOsTickRateTooHigh             0x26
00770 
00780 #define  fatTaskSubtickOverflow           0x27
00781 
00792 #define  fatTaskIllegalTaskNumber         0x28
00793 
00797 #define  fatUnused_0x29                   0x29
00798 
00807 #define  fatIllegalCallfromISR            0x2A
00808 
00812 #define  fatUnused_0x2B                   0x2B
00813 
00817 #define  fatUnused_0x2C                   0x2C
00818 
00822 #define  fatUnused_0x2D                   0x2D
00823 
00827 #define  fatUnused_0x2E                   0x2E
00828 
00832 #define  fatUnused_0x2F                   0x2F
00833 
00834 
00838 #define  traceNull                                    0x00  /* Nullbyte is not used, and may used as separation byte.           */
00839 #define  traceMarker                                  0x01  /* Mark a special point in the tracing.                             */
00840 #define  traceUserByteMessage                         0x02  /* Used to pass a payload information byte                          */
00841 #define  traceUserWordMessage                         0x03  /* Used to pass a payload information word                          */
00842 #define  traceTaskStart                               0x10  /* switched to the task number 0x00 - 0x0F by 0x10 - 0x1F           */
00843 #define  traceOsStart                                 0x20  /* switched to the OS                                               */
00844 #define  traceIdleStart                               0x21  /* switched to the idle task                                        */
00845 #define  traceSleepStart                              0x22  /* switched to low power sleep                                      */
00846 #define  traceTickInterrupt                           0x23  /* a tick interrupt has occurred                                    */
00847 #define  traceWatchdog                                0x24  /* the watchdog barked, see following TaskInit for number           */
00848 #define  traceLockAcquire                             0x25  /* the slot is free and the task may continue                       */
00849 #define  traceLockReject                              0x26  /* the slot has been taken and the task will be blocked             */
00850 #define  traceReset                                   0x27  /* a reset occurred                                                 */
00851 #define  traceISR                                     0x28  /* switched to one of 8 interrupts 0x28 -- 0x2F, define yourself.   */
00852 #define  traceSlotLock                                0x30  /* lock a slot, 2 bytes:   (0x30 | tasknumber), (slot1<<4 | slot2)  */
00853 #define  traceSlotUnlock                              0x40  /* unlock a slot, 2 bytes: (0x40 | tasknumber), (slot1<<4 | slot2)  */
00854 #define  traceFireEvent                               0x50  /* Fire of event number 0..7 given by 0x50 ... 0.57                 */
00855 #define  traceWatermarks                              0x58  /* Watermarks of stacks of OS, ISR and tasks                        */
00856 #define  traceUnused                                  0x59  /* Unused                                                           */
00857 #define  traceREGISTERLEAK_5A                         0x5A  /* If this event occurs, you probably have a register leak          */
00858 #define  traceBurnLock                                0x5B  /* File system not ready for burning                                */
00859 #define  traceBurnFree                                0x5C  /* File system ready for burning                                    */
00860 #define  traceCreateContext                           0x5D  /* construction of a context                                        */
00861 #define  traceLoadInfo                                0x5E  /* Load info on Os, Idle, ISR + tasks, multibyte message            */
00862 #define  traceOsTime                                  0x5F  /* Continuous average load of the Os, 3 byte message                */
00863 #define  traceTaskInit                                0x60  /* Initialized task number 0x00 - 0x0F by 0x60 - 0x6F               */
00864 #define  traceTaskRelease                             0x70  /* A blocked (Sync,File,Event) task may continue 0x70..0x7F         */
00865 #define  traceAPIcallBase                             0x80  /* 0x80 -- 0xCF api called (max 80 functions's)                     */
00866 #define  traceAPIcall1                                0x90  /* See below for definitions                                        */
00867 #define  traceAPIcall2                                0xA0  /*                                                                  */
00868 #define  traceAPIcall3                                0xB0  /*                                                                  */
00869 #define  traceAPIcall4                                0xC0  /*                                                                  */
00870 #define  traceErrorBase                               0xD0  /* 0xD0 -- 0xFF error situation (max 48 error's)                    */
00871 #define  traceError1                                  0xE0  /* See above for definitions                                        */
00872 #define  traceError2                                  0xF0  /*                                                                  */
00873 
00877 #define  callIdSystem                                 0x00  
00878 #define  callIdTaskYield                              0x01  
00879 #define  callIdTaskWaitForEvent                       0x02  
00880 #define  callIdTaskDelayFromNow                       0x03  
00881 #define  callIdTaskDelayFromWake                      0x04  
00882 #define  callIdTaskSuspend                            0x05  
00883 #define  callIdTaskSleep                              0x06  
00884 #define  callIdTaskSleepAll                           0x07  
00885 #define  callIdTaskRecreate                           0x08  
00886 #define  callIdTaskFeedWatchdog                       0x09  
00887 #define  callIdTaskKillWatchdog                       0x0A  
00888 #define  callIdTaskRestart                            0x0B  
00889 #define  callIdTaskTerminate                          0x0C  
00890 #define  callIdTaskEnableGlobalInterrupts             0x0D  
00891 #define  callIdTaskDisableGlobalInterrupts            0x0E  
00892 #define  callIdTaskEnableTickInterrupts               0x0F  
00893 #define  callIdTaskDisableTickInterrupts              0x10  
00894 #define  callIdTaskEnableSwitchTask                   0x11  
00895 #define  callIdTaskDisableSwitchTask                  0x12  
00896 #define  callIdTaskEnterGlobalCritical                0x13  
00897 #define  callIdTaskExitGlobalCritical                 0x14  
00898 #define  callIdTaskEnterTickCritical                  0x15  
00899 #define  callIdTaskExitTickCritical                   0x16  
00900 #define  callIdTaskEnterSwitchCritical                0x17  
00901 #define  callIdTaskExitSwitchCritical                 0x18  
00902 #define  callIdTaskFileOpen                           0x19  
00903 #define  callIdTaskFileClose                          0x1A  
00904 #define  callIdTaskFileFormat                         0x1B  
00905 #define  callIdTaskFileGetSize                        0x1C  
00906 #define  callIdTaskFileSetSize                        0x1D  
00907 #define  callIdTaskFileReadByte                       0x1E  
00908 #define  callIdTaskFileWriteByte                      0x1F  
00909 #define  callIdTaskFileAppendByte                     0x20  
00910 #define  callIdTaskFileReadPipe                       0x21  
00911 #define  callIdTaskFileWritePipe                      0x22  
00912 #define  callIdTaskFileReadBuffer                     0x23  
00913 #define  callIdTaskFileWriteBuffer                    0x24  
00914 #define  callIdREGISTERLEAK_A5                        0x25  
00915 #define  callIdTaskWaitForTasks                       0x26  
00916 #define  callIdTaskSyncRequest                        0x27  
00917 #define  callIdTaskSyncRelease                        0x28  
00918 #define  callIdTaskMemMalloc                          0x29  
00919 #define  callIdTaskMemFree                            0x2A  
00920 #define  callIdTaskMemDefrag                          0x2B  
00921 #define  callIdTaskMemPointer                         0x2C  
00922 #define  callIdTaskReserved1                          0x2D  
00923 #define  callIdTaskReserved2                          0x2E  
00924 #define  callIdTaskReserved3                          0x2F  
00925 #define  callIdTaskReserved4                          0x30  
00926 #define  callIdTaskReserved5                          0x31  
00927 #define  callIdTaskReserved6                          0x32  
00928 #define  callIdGenSuspend                             0x33  
00929 #define  callIdGenResume                              0x34  
00930 #define  callIdGenSetPriority                         0x35  
00931 #define  callIdGenGetPriority                         0x36  
00932 #define  callIdGenGetTickCount                        0x37  
00933 #define  callIdGenGetLastWakeTime                     0x38  
00934 #define  callIdGenGetTaskname                         0x39  
00935 #define  callIdGenFireEventSet                        0x3A  
00936 #define  callIdGenReboot                              0x3B  
00937 #define  callIdGenLogTask                             0x3C  
00938 #define  callIdGenLogOs                               0x3D  
00939 #define  callIdGenWaitRelease                         0x3E  
00940 #define  callIdGenQueuWrite                           0x3F  
00941 #define  callIdGenQueuRead                            0x40  
00942 #define  callIdGenQueuPeek                            0x41  
00943 #define  callIdGenQueuReadable                        0x42  
00944 #define  callIdGenQueuWriteable                       0x43  
00945 #define  callIdGenQueuFull                            0x44  
00946 #define  callIdGenQueuEmpty                           0x45  
00947 #define  callIdGenQueuClear                           0x46  
00948 #define  callIdGenAddtoTickCount                      0x47  
00949 #define  callIdGenPassFlashString                     0x48  
00950 #define  callIdGenCountEventBlocks                    0x49  
00951 #define  callIdGenReserved1                           0x4A  
00952 #define  callIdGenReserved2                           0x4B  
00953 #define  callIdGenReserved3                           0x4C  
00954 #define  callIdGenReserved4                           0x4D  
00955 #define  callIdGenReserved5                           0x4E  
00956 #define  callIdGenReserved6                           0x4F  
00961 #define  callIdTaskStackCheck                         ----  
00962 #define  callIdGenPipeInt16                           ----  
00963 #define  callIdGenTraceByteInfo                       ----  
00964 #define  callIdGenTraceWordInfo                       ----  
00965 #define  callIdGenTraceMarker                         ----  
00966 #define  callIdTaskMutexRequestOnName                 0x27  
00967 #define  callIdTaskMutexReleaseOnName                 0x27  
00968 #define  callIdTaskQueuWriteRequestOnName             0x27  
00969 #define  callIdTaskQueuReadRequestOnName              0x27  
00970 #define  callIdTaskQueuReleaseOnName                  0x28  
00971 #define  callIdTaskSyncReleaseOnName                  0x28  
00972 #define  callIdTaskSyncWriteWriteRequestOnName        0x27  
00973 #define  callIdTaskSyncWriteReadRequestOnName         0x27  
00974 #define  callIdTaskSyncReadWriteRequestOnName         0x27  
00975 #define  callIdTaskSyncReadReadRequestOnName          0x27  
00976 #define  callIdTaskWaitForOtherTask                   0x26  
00977 #define  callIdIsrBegin                               ----  
00978 #define  callIdIsrEndReturn                           ----  
00979 #define  callIdIsrEndYield                            ----  
00980 #define  callIdIsrEnter                               ----  
00981 #define  callIdIsrExit                                ----  
00982 #define  callIdIsrStackCheck                          ----  
00983 #define  callIdIsrStartLoad                           ----  
00984 #define  callIdIsrStopLoad                            ----  
00985 #define  callIdIsrFireEvent                           ----  
00986 #define  callIdGenFireEvent                           ----  
00987 #define  callIdTaskFileClear                          0x1D  
00988 #define  callIdTaskFileDirectRead                     ----  
00989 #define  callIdTaskFileDirectWrite                    ----  
00998 #define  defResponseOK                                0x01  /* datalength: 0   */
00999 #define  defResponseUnknownCommand                    0x02  /* datalength: 0   */
01000 #define  defResponseError                             0x03  /* datalength: 0   */
01001 #define  defResponseInvalidTask                       0x04  /* datalength: 0   */
01002 #define  defResponseInvalidPriority                   0x05  /* datalength: 0   */
01003 #define  defResponseFemtoOs                           0x10  /* datalength: 12  */
01004 #define  defResponseLogTask                           0x11  /* datalength: 16  */
01005 #define  defResponseLogOs                             0x12  /* datalength: 10  */
01006 #define  defResponseTickCount                         0x13  /* datalength: 2   */
01007 #define  defResponseDump                              0x14  /* datalength: 2   */
01008 #define  defResponseUptime                            0x15  /* datalength: 5   */
01009 #define  defResponseFile                              0x16  /* datalength: x   */
01010 #define  defResponseInvalidFileNumber                 0x17  /* datalength: x   */
01011 
01012 #define  defRequestFemtoOs                            0x90  /* datalength: 0   */
01013 #define  defRequestProcessList                        0x91  /* datalength: 0   */
01014 #define  defRequestTickCount                          0x93  /* datalength: 0   */
01015 #define  defRequestReboot                             0x94  /* datalength: 0   */
01016 #define  defRequestSuspend                            0x95  /* datalength: 1   */
01017 #define  defRequestResume                             0x96  /* datalength: 1   */
01018 #define  defRequestTerminate                          0x97  /* datalength: 1   */
01019 #define  defRequestPriority                           0x98  /* datalength: 2   */
01020 #define  defRequestRecreate                           0x99  /* datalength: 2   */
01021 #define  defRequestDump                               0x9A  /* datalength: 2   */
01022 #define  defRequestStore                              0x9B  /* datalength: x   */
01023 #define  defRequestRecall                             0x9C  /* datalength: x   */
01024 #define  defRequestUptime                             0x9D  /* datalength: 0   */
01025 #define  defRequestTest                               0x9E  /* datalength: 1  */
01026 
01027 #define defDumpRAM                                    0x01
01028 #define defDumpEEPROM                                 0x02
01029 #define defDumpFLASH                                  0x03
01030 
01031 #endif /* FEMTOOS_GLOBALS_H */

Generated on Fri Oct 16 00:05:21 2009 for FemtoOS by  doxygen 1.5.2