/*
 *	KRoC kernel C macro scheduler definitions
 *	Copyright (C) 1995, 1996, 1997 D.J. Beckett, D.C. Wood
 *	Copyright (C) 1998 Jim Moores
 *	Modifications (C) 2002 Fred Barnes
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation; either version 2 of the License, or
 *	(at your option) any later version.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/*
 * (C) Copyright 1995,1996,1997 D.J. Beckett <D.J.Beckett@ukc.ac.uk>
 *                              D.C. Wood <D.C.Wood@ukc.ac.uk>
 * Completely rewritten for C kernel:
 * (C) Copyright 1998           Jim Moores <jm40@ukc.ac.uk>
 * University of Kent at Canterbury
 */

#ifndef __SCHED_CONSTS_H
#define __SCHED_CONSTS_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

/* This file is included in assembler files so may not always be able
   to use the new ANSI C ## operator in the C pre-processor */

#ifdef __STDC__
#  define CAT(a,b) a ## b
#else
#  define _IDENT(a) a
#  define CAT(a,b) _IDENT(a)b
#endif

/* #define HAVE_C_LEADING_UNDERSCORE */

#ifdef HAVE_C_LEADING_UNDERSCORE
#  define MAKENAME(n) CAT(_,n)
#else
#  define MAKENAME(n) n
#endif

/*       Constants      */

#define false 0
#define true  1
#define Flush 255

/*      Constants used in transputer instructions */

#define MostNeg 0x80000000

/* That all important constant on the transputer (was MinInt) */
#define NotProcess_p 0

/* ALT flag states */
#define Enabling_p NotProcess_p+1
#define Waiting_p NotProcess_p+2
#define Ready_p NotProcess_p+3
#define TimeSet_p NotProcess_p+1
#define TimeNotSet_p NotProcess_p+2

/* Workspace offsets used by kernel */
/* note that in the assembler version these were all multiplied by the */
/* wordsize, we are using the array access operators so we don't need to */
#define Temp 0
#define Iptr -1
#define Link -2
#ifdef PROCESS_PRIORITY
	/* extra slot for process priority / process group */
	#define Priority -3
	#define Pointer -4
	#define State -4
	#define TLink -5
	#define Time_f -6

	#define MAX_PRIORITY_LEVELS 32
	#define PRIORITY_MASK 0x0000001f
	#define PGROUP_MASK 0x00ffffe0
	#define PGROUP_SHIFT 5
#else
	#define Pointer -3
	#define State -3
	#define TLink -4
	#define Time_f -5
#endif	/* !PROCESS_PRIORITY */

#ifdef PROCESS_PRIORITY
#define SavedPriority 2
#endif
/* wanted to prevent clash between field and the type 'Time' */
#define Count 1
#define IptrSucc 0
#define NoneSelected_o MostNeg /* should be 0 really */

#define KERNEL_RUN                      /* Allow position-independent calls */
#define IMPOSSIBLE			/* Check for impossible errors */
#undef  T9000                           /* Not fully implemented */
#undef  VPTR                            /* Under development */

#define WSH			2	/* workspace shift (bytes -> words) */

/* top-level process definitions, as generated by tranx86 */
#define TLP_NULL		0x00
#define TLP_KYB			0x01
#define TLP_SCR			0x02
#define TLP_KYBSCR		0x03
#define TLP_ERR			0x04
#define TLP_KYBERR		0x05
#define TLP_SCRERR		0x06
#define TLP_KYBSCRERR		0x07
#define TLP_FSTS		0x41
#define TLP_FSTSMEM		0x42
#define TLP_FSTSSIZEDMEM	0x43
#define TLP_SHAREDKYB		0x08
#define TLP_SHAREDSCR		0x10
#define TLP_SHAREDERR		0x20
#define TLP_SHAREDMASK		0x38

#define TLP_FORK_BARRIER	0x100
#define TLP_FORK_NOWAIT		0x200
#define TLP_EXT_NOWAIT		0x400
#define TLP_MPP_BARRIER		0x800
#define TLP_PRINT_MEMSTATS	0x1000
#define TLP_CTTD		0x2000

#define TLP_EFLAGMASK		0x3f00


#endif	/* !__SCHED_CONSTS_H */

