00001 /*************************************************************************** 00002 * $Id: proc.h 212 2008-09-28 17:19:19Z merdmann $ 00003 * 00004 * Wed Dec 5 07:07:57 2007 00005 * Copyright 2007 Michael Erdmann 00006 * Email: michael.erdmann@snafu.de 00007 ****************************************************************************/ 00008 00009 /* 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00023 */ 00024 00086 #include "typedefs.h" 00087 #include "mkernel_config.h" 00088 00089 #ifndef PROC_H 00090 #define PROC_H 00091 00092 /* process states. */ 00093 00095 #define PROC_FREE 0 00096 00100 #define PROC_COMPUTING 1 00101 00107 #define PROC_TERMINATE 2 00108 00115 #define PROC_WAIT_TIMER 3 00116 00121 #define PROC_WAIT_EVENT 4 00122 00124 #define PROC_WAIT_RESOURCE 5 00125 00127 #define PROC_SUSPENDED 6 00128 00129 00133 #define PROC_NOT_EXIST 8 00134 00136 typedef byte t_task_id; 00137 00139 typedef t_task_id TaskType; 00140 typedef TaskType* TaskRefType; 00141 00143 #define LOW_PRIORITY 1 00144 #define NORMAL_PRIORITY 2 00145 #define HIGH_PRIORITY 3 00146 00148 #define DADDR __near byte* 00149 00151 typedef void (*t_task_code)(void*); 00152 00154 #define FULL 1 00155 00156 #define NON 0 00157 00162 typedef struct { 00163 byte max_activations; 00164 byte priority; 00165 byte schedule; 00166 t_task_code entry; 00167 POINTER tos; 00168 } t_task_descriptor; 00169 00170 00171 00176 typedef struct { 00177 POINTER stack; 00178 byte state; 00179 byte prio; 00180 unsigned event; 00181 unsigned mask; 00182 DADDR wait_addr; 00183 byte activations; 00185 t_task_descriptor *descriptor; 00186 } t_tcb; 00187 00188 00192 #define ANY_TASK 100 00193 #define NULL_TASK_ID 101 00194 00195 extern t_tcb _TCB[]; 00196 extern const int _os_max_tcb; 00197 00202 #define STACK_SIZE_KERNEL 150 00203 00204 extern void Schedule( void ); 00205 extern void _os_yield(void); /* see yield.i */ 00206 00207 00211 typedef void* TASK_ARGUMENT; 00212 00213 /* 00214 * This method is used by the system generator to create a task 00215 * instance. 00216 */ 00217 StatusType _os_task_create( t_task_id id, t_task_descriptor *descr ); 00218 00225 StatusType _os_task_switch( t_task_id id ); 00226 00227 extern POINTER _os_kernel_stack; 00228 extern t_tcb *_os_current_task; 00229 extern byte _os_mode; /* will be set by the interrupt handlers */ 00230 00231 #endif
1.4.6