tr_types.h

Go to the documentation of this file.
00001 /** @file
00002  * @brief  TiROS default values */
00003 #ifndef _TiROS_TYPES_H_
00004 #define _TiROS_TYPES_H_
00005 
00006 /* Author: Ratish J. Punnoose, 2006
00007  * This file is part of TiROS, the Tickless Real-Time Operating System.
00008  * Copyright(c) 2006, 2007: Ratish J. Punnoose.
00009  * Copyright(c) 2006 Sandia Corporation. Under the terms of Contract
00010  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
00011  * certain rights in this software. 
00012  * 
00013  * TiROS is free software; you can redistribute it and/or modify it under
00014  * the terms of the GNU General Public License as published by the Free
00015  * Software Foundation; either version 2 or (at your option) any later version.
00016  *
00017  * TiROS is distributed in the hope that it will be useful, but WITHOUT ANY
00018  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
00019  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00020  * for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License along
00023  * with TiROS; if not, write to the Free Software Foundation, Inc.,
00024  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00025  *
00026  * As a special exception, if other files instantiate templates or use macros
00027  * or inline functions from this file, or you compile this file and link it
00028  * with other works to produce a work based on this file, this file does not
00029  * by itself cause the resulting work to be covered by the GNU General Public
00030  * License. However the source code for this file must still be made available
00031  * in accordance with section (3) of the GNU General Public License.
00032  *
00033  * This exception does not invalidate any other reasons why a work based on
00034  * this file might be covered by the GNU General Public License.
00035  *
00036  */
00037  
00038 
00039 
00040 #include "tr_port.h"
00041 
00042 
00043 #ifndef TIROS_MAX_ISR_NESTING  
00044 #define TIROS_MAX_ISR_NESTING  1
00045 #endif
00046 
00047 #ifndef TIROS_MAX_MUTEXES
00048 #define TIROS_MAX_MUTEXES      255
00049 #endif
00050 
00051 
00052 
00053 #ifndef TIROS_ENABLE_MUTEX
00054 #define TIROS_ENABLE_MUTEX      1
00055 #endif
00056 
00057 #ifndef TIROS_ALLOW_SLEEP_W_MUTEX 
00058 #define TIROS_ALLOW_SLEEP_W_MUTEX 1
00059 #endif
00060 
00061 #ifndef TIROS_ENABLE_CSEM
00062 #define TIROS_ENABLE_CSEM       1
00063 #endif
00064 
00065 #ifndef TIROS_ENABLE_MSGQ
00066 #define TIROS_ENABLE_MSGQ       1
00067 #endif
00068 
00069 #ifndef TIROS_ENABLE_EFLAG
00070 #define TIROS_ENABLE_EFLAG      1
00071 #endif
00072 
00073 
00074 /** If no priority sort scheduler selection is made, select the
00075     default. */
00076 #ifndef TIROS_PRIO_SORT_METHOD
00077 #define TIROS_PRIO_SORT_METHOD  1
00078 #endif
00079 
00080 /** This can be overridden to increase the number of supported tasks
00081  *   beyond 255 */
00082 #ifndef TIROS_PORT_DEFINED_PID_T
00083 typedef uint8_t  tid_t;
00084 #endif
00085 
00086 
00087 
00088 
00089 #if (TIROS_PRIO_SORT_METHOD == 1)
00090 /** For the default scheduler, the process list is maintained by
00091  *  keeping the head of the list */
00092 typedef tid_t plist_t;
00093 #else
00094 #error "TIROS_PRIO_SORT has illegal value in configuration."
00095 #endif
00096 
00097 
00098 
00099 
00100 
00101 /** Mutex structure */
00102 typedef struct mutex {
00103         plist_t waitlist;
00104         tid_t owner;
00105 #ifndef TIROS_PRIO_INHERIT_PROTOCOL
00106         tid_t prio_ceiling;
00107 #endif
00108 } mutex_t;
00109 
00110 
00111 
00112 
00113 #ifndef TIROS_USER_DEFINED_CSEMVAL_T
00114 /* A custom type can be defined for csemval_t. Also CSEMVAL_MAX must
00115  * be defined along with it.  Note that csemval_t must be a signed
00116  * integer type. */
00117 typedef int8_t csemval_t;
00118 #endif
00119 
00120 #ifndef TIROS_CSEMVAL_MAX
00121 #define TIROS_CSEMVAL_MAX 127
00122 #endif
00123 
00124 
00125 /** Counting semaphore structure */
00126 typedef struct csem {
00127         plist_t waitlist;
00128         csemval_t count;
00129         csemval_t max_count;
00130 } csem_t;
00131 
00132 
00133 
00134 #ifndef TIROS_USER_DEFINED_MQ_T
00135 /* A custom type for the message queue indexing can be specified by
00136  * the user.  This will allow for message queues greater than the
00137  * default.   */
00138 typedef tid_t  mqind_t;
00139 #endif
00140 
00141 
00142 /** Message queue structure */
00143 typedef struct msgQ {
00144         struct { plist_t waitlist; } readers;
00145         mqind_t head;
00146         mqind_t currlen;
00147         mqind_t maxlen;
00148 
00149 #if (TIROS_C90_COMPATIBLE == 1)
00150         /* C standard C90, ISO C++ does not support zero-length, or 
00151          * variable length arrays. */
00152         osptr_t msgs[1];
00153 #elif defined (__GNUC__)
00154         /* In GCC zero length arrays are allowed.  They are useful in
00155          * this manner as the last element of a structure which is really
00156          * a header for a variable-length object */
00157         osptr_t msgs[0];
00158 #else
00159         /* In C standard C99, a flexible array member can be described
00160          * as  before but without the 0.  Technically the sizeof operator
00161          * may not be applied, but most compilers support this and the
00162          * sizeof operator applied to a flexible array member returns
00163          * zero, which is what is desired. */
00164         osptr_t msgs[];
00165 
00166 #endif  /* defined GNUC */
00167 } msgQ_t;
00168 
00169 
00170 
00171 
00172 #ifndef TIROS_USER_DEFINED_FLAG_T
00173 typedef osword_t flag_t;
00174 #endif
00175 
00176 /** Event Flag structure */
00177 typedef struct eflag {
00178         plist_t waitlist;
00179         flag_t status;
00180 } eflag_t;
00181 
00182 
00183 
00184 
00185 #endif /*  _TiROS_TYPES_H_ */

TiROS User Manual: Last Updated on Fri Jul 20 10:52:23 2007