/* typedef.h - typedef definitions */ /* * RTXC Quadros Version 1.0 * Copyright (c) 1999-2003 * Quadros Systems, Inc. * ALL RIGHTS RESERVED * * THE INFORMATION HEREIN IS CONFIDENTIAL AND PROPRIETARY. * UNAUTHORIZED DISCLOSURE OR DISTRIBUTION IS PROHIBITED. */ #ifndef _TYPEDEF_H /* { */ #define _TYPEDEF_H #pragma enumsalwaysint on /* force 32-bit enums for speed */ typedef unsigned char MAU; typedef unsigned long PPL_TYPE; typedef long STK_ALIGNTYPE; #define SIZEOF_STK_ALIGNTYPE sizeof(STK_ALIGNTYPE) #ifdef HAS_TaskStatistics /* { */ #define STACK_FILL 0xFFFF #define FILLNUM STACK_FILL&0xFFFF #else #define STACK_FILL 0x0 #define FILLNUM STACK_FILL&0xFFFF #endif /* } HAS_TaskStatistics */ typedef unsigned long KOBJECT; /* other object types inherited from KOBJECT */ #ifdef HAS_RTXCss /* { */ typedef KOBJECT LEVEL; typedef KOBJECT THREAD; #endif /* } HAS_RTXCss */ typedef KOBJECT PIPE; typedef KOBJECT EVNTSRC; typedef KOBJECT COUNTER; typedef KOBJECT ALARM; typedef KOBJECT EXCPTN; /* internal use only */ typedef int TLEVEL; /* actual level # - not a level handle */ typedef int TORDER; /* thread order 1=MSB, ... */ typedef int KORDER; /* kernel "call" order - internal use */ typedef unsigned int ksize_t; /* our version of size_t */ typedef unsigned int KCOUNT; /* statistics fields, #blocks/part, */ /* queue entry size, etc. */ typedef int KATTR; /* class+obj attr - need at least 15 bits */ typedef int KATTRMASK; /* class+obj attr - need at least 15 bits */ /* provide time_t iff missing from compiler */ #if !defined(_TIME_T) && !defined(__time_t_defined) /* { */ #define _TIME_T typedef unsigned long time_t; /* usually seconds since Jan 1, 1970 */ #endif /* } _TIME_T */ /* maximum alarm length limited by largest possible value of type TICKS */ #define TICKS_ARE_LONG /* choose TICKS_ARE_SHORT, *_ARE_LONG, or *_ARE_LONGLONG */ #ifdef TICKS_ARE_SHORT /* { */ /* next lines for 16-bit TICKS range */ typedef unsigned short TICKS; typedef signed short SIGNEDTICKS; #endif /* } TICKS_ARE_SHORT */ #ifdef TICKS_ARE_LONG /* { */ /* next lines for 32-bit TICKS range */ typedef unsigned long TICKS; typedef signed long SIGNEDTICKS; #endif /* } TICKS_ARE_LONG */ #ifdef TICKS_ARE_LONGLONG /* { */ /* next lines for 64-bit TICKS range */ /* code qualified 08-jan-03 with MW v3.2.2; but KA does not present correctly */ typedef unsigned long long TICKS; typedef signed long long SIGNEDTICKS; #endif /* } TICKS_ARE_LONGLONG */ #ifdef HAS_Threads /* { */ typedef unsigned int GATEKEY; #endif /* } HAS_Threads */ typedef KCOUNT QWIDTH; /* width of queue */ typedef KCOUNT QDEPTH; /* depth of queue */ typedef KCOUNT QCOUNT; /* internal use queue index */ typedef unsigned int KMODULUS; #define NUMORDERS (31) /* 31 - highly recommended */ #define NUMLEVELS (31) /* 31 - highly recommended */ #if (NUMORDERS<8) /* { */ #error INVALID NUMBER OF ORDERS typedef unsigned char OMASK; #define VAL_OMASK (1 << NUMORDERS) #elif NUMORDERS < 16 #error INVALID NUMBER OF ORDERS typedef unsigned short OMASK; #define VAL_OMASK (1u << NUMORDERS) #elif NUMORDERS < 32 typedef unsigned long OMASK; #define VAL_OMASK (1u << NUMORDERS) #elif NUMORDERS < 64 // NOW SUPPORTED VIA FUNCTION-BASED FINDFIRSTBIT - BUT SLOW... //#error INVALID NUMBER OF ORDERS //#error MAX NUMBER OF ORDERS EXCEEDED (31) typedef unsigned long long OMASK; #define VAL_OMASK (1ull << NUMORDERS) #else #error MAX NUMBER OF ORDERS EXCEEDED (63) #endif /* } (NUMORDERS<8) */ #define ZRO_OMASK (0) #if (NUMLEVELS<8) /* { */ #error INVALID NUMBER OF LEVELS typedef unsigned char LMASK; #define VAL_LMASK (1u << NUMLEVELS) #elif NUMLEVELS < 16 #error INVALID NUMBER OF LEVELS typedef unsigned short LMASK; #define VAL_LMASK (1u << NUMLEVELS) #elif NUMLEVELS < 32 typedef unsigned long LMASK; #define VAL_LMASK (1ul << NUMLEVELS) #elif NUMLEVELS < 64 #error INVALID NUMBER OF LEVELS #error MAX NUMBER OF LEVELS EXCEEDED (31) typedef unsigned long long LMASK; #define VAL_LMASK (1ull << NUMLEVELS) #else #error MAX NUMBER OF LEVELS EXCEEDED (63) #endif /* } (NUMLEVELS<8) */ #define ZRO_LMASK (0) #define NUMCALLS (31) /* no need for various sizes */ typedef unsigned long KMASK; #define ZRO_KMASK (0) #define OSETBIT(x,y) x |= (VAL_OMASK >> (y)) #define OCLRBIT(x,y) x &= ~(VAL_OMASK >> (y)) #define MAKE_OMASK(y) (OMASK)(VAL_OMASK >> (y)) #define LSETBIT(x,y) x |= (VAL_LMASK >> (y)) #define LCLRBIT(x,y) x &= ~(VAL_LMASK >> (y)) #define MAKE_LMASK(y) (LMASK)(VAL_LMASK >> (y)) #define VAL_KMASK (1u << NUMCALLS) #define MAKE_KMASK(y) (KMASK)(VAL_KMASK >> (y)) /* classic method - REQUIRED */ #define KSETBIT(x,y) x |= (VAL_KMASK >> (y)) #define KCLRBIT(x,y) x &= ~(VAL_KMASK >> (y)) /* commonly used special RTXC object names */ #ifndef NULL /* { */ #define NULL ((void *)0) /* generic use */ #endif /* } NULL */ #define NULLNAME ((char *)0) #define NULLTASK ((TASK)0) /* for internal use only */ #ifndef NULLSEMA /* { */ #define NULLSEMA ((SEMA)0) #endif /* } NULLSEMA */ #define SELFTASK ((TASK)0) #define SELFTHREAD ((THREAD)0) #define TIMEBASE ((COUNTER)0) typedef unsigned int TSTATE; /* task status */ /* queue event conditions */ typedef enum _qevent { QNE = 1, /* Not Empty */ QNF = 2 /* Not Full */ } QEVENT; /* PutQueueData conditions */ #define Q_NOW_FULL 0x20 /* not reported to user */ #define Q_WAS_EMPTY QNE /* GetQueueData conditions */ #define Q_NOW_EMPTY 0x10 /* not reported to user */ #define Q_WAS_FULL QNF #define Q_NO_CONDITION 0x00 /* mailbox event conditions */ typedef unsigned char MEVENT; #define MNE QNE /* Mailbox Not Empty */ typedef enum _msg_priority { NORMAL_MSG = 1, /* Normal message */ URGENT_MSG = 2 /* Urgent message */ } MSG_PRIORITY; /* partition event conditions */ typedef unsigned char PEVENT; #define PNE QNE /* Partition Not Empty */ /* alarm events */ typedef unsigned char AEVENT; #define AE QNE /* Alarm Expired */ #define AA QNF /* Alarm Aborted */ /* RTXC task state information */ #define READY 0x0000u /* task is runnable */ #define INACTIVE_BLOCK 0x0800u /* task not yet executed, or terminated */ #define MUTEX_WAIT 0x0400u /* mutex (testmutx) */ #define QUEUE_WAIT 0x0200u /* queue ([put|get]queue) */ #define PARTITION_WAIT 0x0100u /* partition (allocblk) */ #define MAILBOX_WAIT 0x0080u /* mailbox (receivemsg) */ #define ALARM_WAIT 0x0040u /* alarm (testalarm) */ #define SEMAPHORE_WAIT 0x0020u /* semaphore (testsema) */ #define PIPE_WAIT 0x0010u /* pipe (getpipebuf) */ #define SLEEP_BLOCK 0x0008u /* sleep */ #define ACK_BLOCK 0x0004u /* acknowledge (sendmsg/testack) */ #define ABORT_BLOCK 0x0002u /* aborted (aborttask) */ #define SUSPEND_BLOCK 0x0001u /* suspended (suspendtask) */ /* envelope state (internal use only) */ #define ENV_MBOX 0 #define ENV_READ 1 #define HIGHEST_PRIORITY ((PRIORITY)0) #define LOWEST_PRIORITY ((PRIORITY)126) #define NULLTASK_PRIORITY (LOWEST_PRIORITY+1) /* lowest priority supported */ /* tasks run at NULLTASK_PRIORITY-1 and up */ #define NOT_INVERTED_PRIORITY (HIGHEST_PRIORITY) /* indicates non-inverted */ /* a task at HIGHEST_PRIORITY cannot be inverted by definition */ /* provides unique priority that indicates task not inverted */ /* * RTXC Kernel Class types */ typedef enum _kclass { /* NOTE: RTXCss classes listed first */ #ifdef HAS_Threads /* { */ LEVEL_KCLASS = 0, THREAD_KCLASS = 1, #endif /* } HAS_Threads */ #ifdef HAS_EventSources /* { */ EVNTSRC_KCLASS = 2, #endif /* } HAS_EventSources */ #ifdef HAS_Counters /* { */ COUNTER_KCLASS = 3, #endif /* } HAS_Counters */ #ifdef HAS_Alarms /* { */ ALARM_KCLASS = 4, #endif /* } HAS_Alarms */ #ifdef HAS_Pipes /* { */ PIPE_KCLASS = 5, #endif /* } HAS_Pipes */ #ifdef HAS_Exceptions /* { */ EXCPTN_KCLASS = 6, #endif /* } HAS_Exceptions */ #ifdef HAS_Tasks /* { */ TASK_KCLASS = 7, #endif /* } HAS_Tasks */ #ifdef HAS_Semaphores /* { */ SEMA_KCLASS = 8, #endif /* } HAS_Semaphores */ #ifdef HAS_Mailboxes /* { */ MBOX_KCLASS = 9, #endif /* } HAS_Mailboxes */ #ifdef HAS_Partitions /* { */ PART_KCLASS = 10, #endif /* } HAS_Partitions */ #ifdef HAS_Queues /* { */ QUEUE_KCLASS = 11, #endif /* } HAS_Queues */ #ifdef HAS_Mutexes /* { */ MUTX_KCLASS = 12, #endif /* } HAS_Mutexes */ SPECIAL_KCLASS = 13, /* pseudo-class */ NUM_KCLASSES = 13, /* used for sizing pocdt[] array */ NUM_FAA_KCLASSES = 7 /* used for sizing pFAA[] array */ } KCLASS; typedef enum _kaction { NOACTION = 0, SCHEDULETHREAD = 1, DECRTHREADGATE = 2, /* IS_RESUMETASK yet not implemented */ RESUMETASK = 3 } KACTION; typedef KACTION ALARMACTION; typedef KACTION PIPEACTION; typedef enum _kzone { ZONE_ONE = 1, ZONE_TWO = 2, ZONE_THREE = 3 } KZONE; /* state of ALARMs - internal use only */ typedef enum _alarmstate { ALARM_INACTIVE = 0, /* alarm inactive (initial condition) */ ALARM_ACTIVE = 1, /* alarm counting down */ ALARM_DONE = 2, /* alarm done */ ALARM_EXPIRED = 4, /* alarm already expired */ ALARM_KILLED = 8, /* alarm killed */ ALARM_ABORTED = 10, /* alarm aborted */ ALARM_CANCELED = 20 /* alarm canceled */ } ALARMSTATE; typedef enum _pipecond { PUTFULL = 0, /* Put Full Buffer Condition */ PUTEMPTY = 1 /* Put Empty Buffer Condition */ } PIPECOND; /* kernel class-wide attributes */ #define K_ATTR_Task 0x0001 #define K_ATTR_Semaphore 0x0002 #define K_ATTR_Mailbox 0x0004 #define K_ATTR_Partition 0x0008 #define K_ATTR_Queue 0x0010 #define K_ATTR_Mutex 0x0020 #define K_ATTR_EventSource 0x0040 #define K_ATTR_Counter 0x0080 #define K_ATTR_Alarm 0x0100 #define K_ATTR_Exception 0x0200 #define K_ATTR_Thread 0x0400 #define K_ATTR_Pipe 0x0800 #define K_ATTR_Level 0x1000 /* class-wide attributes common to ALL classes */ #define K_ATTR_STATISTICS 0x4000 /* statistics */ #define ATTR_DYNAMICS 0x0001 /* dynamic objects */ #define ATTR_STATIC_NAMES 0x0002 /* static names */ /* class-wide attributes (possibly) common to multiple classes */ #define ATTR_SEMAPHORES 0x0004 /* task mbox part queue mutex alarm */ #define ATTR_STATISTICS 0x0008 /* sema mbox part queue mutex exception */ #define ATTR_END_ACTIONS 0x0010 /* pipes/alarms - not used */ #define ATTR_PRIORITY_INVERSION 0x0020 /* task object attributes */ #define ATTR_TICKSLICE 0x0040 /* task */ /* thread object attributes */ #define ATTR_ENVIRONMENT_ARGUMENTS 0x0080 /* thread */ #define ATTR_ARGUMENTS 0x0100 /* task/thread */ #define ATTR_GATES 0x0200 /* thread */ /* hidden class-wide attribute */ #define ATTR_NOTOBJ0ADJ 0x1000 /* task - zero adjust attribute for class use */ /* object-wide attributes common to all objects */ #define K_ATTR_INITIALIZED 0x0001 /* object initialized */ /* object-wide attributes common to multiple classes */ #define ATTR_FIFO_ORDER 0x0002 /* mbox part queue mutex sema */ /* level object attributes */ #define ATTR_LEVEL_PRIORITY 0x0000 #define ATTR_LEVEL_ROUNDROBIN 0x0010 /* object level - level */ #define ATTR_LEVEL_FIFO 0x0020 /* NOT IMPLEMENTED */ /* semaphore object attributes specific to a class (overloaded) */ #define ATTR_MULTIPLE_WAITERS 0x0010 /* object-level - sema (SINGLE/GANG) */ /* mutex object attributes */ #define ATTR_INVERSION 0x0010 /* object-level - mutex */ /* event source object attribute */ #define ATTR_EVNTSRC_DISABLE 0x0010 /* object-level- source */ /* counter object attribute */ #define ATTR_COUNTER_TIMEBASE 0x0010 /* object level - counter */ #define ATTR_COUNTER_TICKSLICE 0x0020 #define ATTR_COUNTER_DISABLE 0x0040 /* object level trace attributes */ #define ATTR_TRACE_ACTOR 0x0100 #define ATTR_TRACE_OBJECT 0x0200 /************************************/ /* high level attribute definitions */ /************************************/ #define TASK_ATTR_SEMAPHORES ATTR_SEMAPHORES #define SEMAPHORE_ATTR_STATISTICS ATTR_STATISTICS #define MAILBOX_ATTR_SEMAPHORES ATTR_SEMAPHORES #define MAILBOX_ATTR_STATISTICS ATTR_STATISTICS #define PARTITION_ATTR_SEMAPHORES ATTR_SEMAPHORES #define PARTITION_ATTR_STATISTICS ATTR_STATISTICS #define QUEUE_ATTR_SEMAPHORES ATTR_SEMAPHORES #define QUEUE_ATTR_STATISTICS ATTR_STATISTICS #define MUTEX_ATTR_SEMAPHORES ATTR_SEMAPHORES #define MUTEX_ATTR_STATISTICS ATTR_STATISTICS #define ALARM_ATTR_SEMAPHORES ATTR_SEMAPHORES #define PIPE_ATTR_SEMAPHORES ATTR_SEMAPHORES #define THREAD_ATTR_STATISTICS ATTR_STATISTICS #pragma enumsalwaysint reset /* reset enums size to IDE setting */ #endif /* } _TYPEDEF_H */ /* end of file - typedef.h */