]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/boot/ficl/alpha/sysdep.h
This commit was generated by cvs2svn to compensate for changes in r47133,
[FreeBSD/FreeBSD.git] / sys / boot / ficl / alpha / sysdep.h
1 /*******************************************************************
2                     s y s d e p . h
3 ** Forth Inspired Command Language
4 ** Author: John Sadler (john_sadler@alum.mit.edu)
5 ** Created: 16 Oct 1997
6 ** Ficl system dependent types and prototypes...
7 **
8 ** Note: Ficl also depends on the use of "assert" when
9 ** FICL_ROBUST is enabled. This may require some consideration
10 ** in firmware systems since assert often
11 ** assumes stderr/stdout.  
12 ** 
13 *******************************************************************/
14 /*
15 ** N O T I C E -- DISCLAIMER OF WARRANTY
16 ** 
17 ** Ficl is freeware. Use it in any way that you like, with
18 ** the understanding that the code is not supported.
19 ** 
20 ** Any third party may reproduce, distribute, or modify the ficl
21 ** software code or any derivative  works thereof without any 
22 ** compensation or license, provided that the author information
23 ** and this disclaimer text are retained in the source code files.
24 ** The ficl software code is provided on an "as is"  basis without
25 ** warranty of any kind, including, without limitation, the implied
26 ** warranties of merchantability and fitness for a particular purpose
27 ** and their equivalents under the laws of any jurisdiction.  
28 ** 
29 ** I am interested in hearing from anyone who uses ficl. If you have
30 ** a problem, a success story, a defect, an enhancement request, or
31 ** if you would like to contribute to the ficl release (yay!), please
32 ** send me email at the address above. 
33 */
34
35 #if !defined (__SYSDEP_H__)
36 #define __SYSDEP_H__ 
37
38 #include <sys/types.h>
39
40 #include <stddef.h> /* size_t, NULL */
41 #include <setjmp.h>
42
43 #include <assert.h>
44
45 #if !defined IGNORE             /* Macro to silence unused param warnings */
46 #define IGNORE(x) &x
47 #endif
48
49
50 /*
51 ** TRUE and FALSE for C boolean operations, and
52 ** portable 32 bit types for CELLs
53 ** 
54 */
55 #if !defined TRUE
56 #define TRUE 1
57 #endif
58 #if !defined FALSE
59 #define FALSE 0
60 #endif
61
62
63 #if !defined INT32
64 #define INT32 int32_t
65 #endif
66
67 #if !defined UNS32
68 #define UNS32 u_int32_t
69 #endif
70
71 #if !defined UNS16
72 #define UNS16 u_int16_t
73 #endif
74
75 #if !defined UNS8
76 #define UNS8 u_int8_t
77 #endif
78
79 #if !defined NULL
80 #define NULL ((void *)0)
81 #endif
82
83 typedef struct
84 {
85     UNS32 hi;
86     UNS32 lo;
87 } UNS64;
88
89 typedef struct
90 {
91     UNS32 quot;
92     UNS32 rem;
93 } UNSQR;
94
95 typedef struct
96 {
97     INT32 hi;
98     INT32 lo;
99 } INT64;
100
101 typedef struct
102 {
103     INT32 quot;
104     INT32 rem;
105 } INTQR;
106
107
108 /*
109 ** Build controls
110 ** FICL_MULTITHREAD enables dictionary mutual exclusion
111 ** wia the ficlLockDictionary system dependent function.
112 */
113 #if !defined FICL_MULTITHREAD
114 #define FICL_MULTITHREAD 0
115 #endif
116
117 /*
118 ** FICL_ROBUST enables bounds checking of stacks and the dictionary.
119 ** This will detect stack over and underflows and dictionary overflows.
120 ** Any exceptional condition will result in an assertion failure.
121 ** (As generated by the ANSI assert macro)
122 ** FICL_ROBUST == 1 --> stack checking in the outer interpreter
123 ** FICL_ROBUST == 2 also enables checking in many primitives
124 */
125
126 #if !defined FICL_ROBUST
127 #define FICL_ROBUST 2
128 #endif
129
130 /*
131 ** FICL_DEFAULT_STACK Specifies the default size (in CELLs) of
132 ** a new virtual machine's stacks, unless overridden at 
133 ** create time.
134 */
135 #if !defined FICL_DEFAULT_STACK
136 #define FICL_DEFAULT_STACK 128
137 #endif
138
139 /*
140 ** FICL_DEFAULT_DICT specifies the number of CELLs to allocate
141 ** for the system dictionary by default. The value
142 ** can be overridden at startup time as well.
143 ** FICL_DEFAULT_ENV specifies the number of cells to allot
144 ** for the environment-query dictionary.
145 */
146 #if !defined FICL_DEFAULT_DICT
147 #define FICL_DEFAULT_DICT 12288
148 #endif
149
150 #if !defined FICL_DEFAULT_ENV
151 #define FICL_DEFAULT_ENV 260
152 #endif
153
154 /*
155 ** FICL_DEFAULT_VOCS specifies the maximum number of wordlists in 
156 ** the dictionary search order. See Forth DPANS sec 16.3.3
157 ** (file://dpans16.htm#16.3.3)
158 */
159 #if !defined FICL_DEFAULT_VOCS
160 #define FICL_DEFAULT_VOCS 16
161 #endif
162
163 /*
164 ** User variables: per-instance variables bound to the VM.
165 ** Kinda like thread-local storage. Could be implemented in a 
166 ** VM private dictionary, but I've chosen the lower overhead
167 ** approach of an array of CELLs instead.
168 */
169 #if !defined FICL_WANT_USER
170 #define FICL_WANT_USER 1
171 #endif
172
173 #if !defined FICL_USER_CELLS
174 #define FICL_USER_CELLS 16
175 #endif
176
177 /* 
178 ** FICL_WANT_LOCALS controls the creation of the LOCALS wordset and
179 ** a private dictionary for local variable compilation.
180 */
181 #if !defined FICL_WANT_LOCALS
182 #define FICL_WANT_LOCALS 1
183 #endif
184
185 /* Max number of local variables per definition */
186 #if !defined FICL_MAX_LOCALS
187 #define FICL_MAX_LOCALS 16
188 #endif
189
190 /*
191 ** FICL_ALIGN is the power of two to which the dictionary
192 ** pointer address must be aligned. This value is usually
193 ** either 1 or 2, depending on the memory architecture
194 ** of the target system; 2 is safe on any 16 or 32 bit
195 ** machine.
196 */
197 #if !defined FICL_ALIGN
198 #define FICL_ALIGN 2
199 #define FICL_ALIGN_ADD ((1 << FICL_ALIGN) - 1)
200 #endif
201
202 /*
203 ** System dependent routines --
204 ** edit the implementations in sysdep.c to be compatible
205 ** with your runtime environment...
206 ** ficlTextOut sends a NULL terminated string to the 
207 **   default output device - used for system error messages
208 ** ficlMalloc and ficlFree have the same semantics as malloc and free
209 **   in standard C
210 ** ficlLongMul multiplies two UNS32s and returns a 64 bit unsigned 
211 **   product
212 ** ficlLongDiv divides an UNS64 by an UNS32 and returns UNS32 quotient
213 **   and remainder
214 */
215 struct vm;
216 void  ficlTextOut(struct vm *pVM, char *msg, int fNewline);
217 void *ficlMalloc (size_t size);
218 void *ficlRealloc (void *p, size_t size);
219 void  ficlFree   (void *p);
220
221 /*
222 ** Stub function for dictionary access control - does nothing
223 ** by default, user can redefine to guarantee exclusive dict
224 ** access to a single thread for updates. All dict update code
225 ** must be bracketed as follows:
226 ** ficlLockDictionary(TRUE);
227 ** <code that updates dictionary>
228 ** ficlLockDictionary(FALSE);
229 **
230 ** Returns zero if successful, nonzero if unable to acquire lock
231 ** before timeout (optional - could also block forever)
232 **
233 ** NOTE: this function must be implemented with lock counting
234 ** semantics: nested calls must behave properly.
235 */
236 #if FICL_MULTITHREAD
237 int ficlLockDictionary(short fLock);
238 #else
239 #define ficlLockDictionary(x) 0 /* ignore */
240 #endif
241
242 /*
243 ** 64 bit integer math support routines: multiply two UNS32s
244 ** to get a 64 bit prodict, & divide the product by an UNS32
245 ** to get an UNS32 quotient and remainder. Much easier in asm
246 ** on a 32 bit CPU than in C, which usually doesn't support 
247 ** the double length result (but it should).
248 */
249 UNS64 ficlLongMul(UNS32 x, UNS32 y);
250 UNSQR ficlLongDiv(UNS64 q, UNS32 y);
251
252 #endif /*__SYSDEP_H__*/