xref: /titanic_51/usr/src/lib/efcode/include/fcode/engine.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright (c) 2000 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_FCODE_ENGINE_H
28*7c478bd9Sstevel@tonic-gate #define	_FCODE_ENGINE_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
35*7c478bd9Sstevel@tonic-gate extern "C" {
36*7c478bd9Sstevel@tonic-gate #endif
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #define	MAX_ORDER	32
39*7c478bd9Sstevel@tonic-gate #define	CONVERT_HANDLES
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #ifdef BIGSTACK
42*7c478bd9Sstevel@tonic-gate typedef long long		fstack_t;
43*7c478bd9Sstevel@tonic-gate typedef unsigned long long	ufstack_t;
44*7c478bd9Sstevel@tonic-gate #else
45*7c478bd9Sstevel@tonic-gate typedef long			fstack_t;
46*7c478bd9Sstevel@tonic-gate typedef unsigned long		ufstack_t;
47*7c478bd9Sstevel@tonic-gate #endif
48*7c478bd9Sstevel@tonic-gate typedef long			*acf_t;		/* pointer to execution token */
49*7c478bd9Sstevel@tonic-gate typedef long			token_t;	/* sizeof a forth token */
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate /* x@, x! type */
52*7c478bd9Sstevel@tonic-gate typedef uint64_t		u_xforth_t;
53*7c478bd9Sstevel@tonic-gate typedef int64_t			s_xforth_t;
54*7c478bd9Sstevel@tonic-gate typedef uint64_t		xforth_t;
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate /* l@, l! type */
57*7c478bd9Sstevel@tonic-gate typedef uint32_t		u_lforth_t;
58*7c478bd9Sstevel@tonic-gate typedef int32_t			s_lforth_t;
59*7c478bd9Sstevel@tonic-gate typedef uint32_t		lforth_t;
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate /* w@, w! type */
62*7c478bd9Sstevel@tonic-gate typedef uint16_t		u_wforth_t;
63*7c478bd9Sstevel@tonic-gate typedef int16_t			s_wforth_t;
64*7c478bd9Sstevel@tonic-gate typedef uint16_t		wforth_t;
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate /* Double type */
67*7c478bd9Sstevel@tonic-gate typedef uint64_t		u_dforth_t;
68*7c478bd9Sstevel@tonic-gate typedef int64_t			s_dforth_t;
69*7c478bd9Sstevel@tonic-gate typedef	uint64_t		dforth_t;
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate /* Variable/Value/Constant type */
72*7c478bd9Sstevel@tonic-gate typedef token_t			variable_t;
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate typedef struct PROPERTY {
75*7c478bd9Sstevel@tonic-gate 	char		*name;
76*7c478bd9Sstevel@tonic-gate 	uchar_t		*data;
77*7c478bd9Sstevel@tonic-gate 	int		size;
78*7c478bd9Sstevel@tonic-gate 	struct PROPERTY *next;
79*7c478bd9Sstevel@tonic-gate } prop_t;
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate typedef struct RESOURCE {
82*7c478bd9Sstevel@tonic-gate 	struct RESOURCE *next;
83*7c478bd9Sstevel@tonic-gate 	void		*data;
84*7c478bd9Sstevel@tonic-gate } fc_resource_t;
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate #define	INIT_DATA	0
87*7c478bd9Sstevel@tonic-gate #define	UINIT_DATA	1
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate typedef struct FCODE_ENV fcode_env_t;
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate typedef struct DEVICE_VECTOR {
92*7c478bd9Sstevel@tonic-gate 	/*
93*7c478bd9Sstevel@tonic-gate 	 * If there is private data associated with a node this vector
94*7c478bd9Sstevel@tonic-gate 	 * table contains the routines that will be called to augment the
95*7c478bd9Sstevel@tonic-gate 	 * device.
96*7c478bd9Sstevel@tonic-gate 	 * These two routines allow the interpreter to use a different
97*7c478bd9Sstevel@tonic-gate 	 *
98*7c478bd9Sstevel@tonic-gate 	 * Interface Note:
99*7c478bd9Sstevel@tonic-gate 	 * Any routine installed here is assumed to have the standard forth
100*7c478bd9Sstevel@tonic-gate 	 * call state. It must be a void function call taking a forth execution
101*7c478bd9Sstevel@tonic-gate 	 * environment, returning any data on the stack. In general the
102*7c478bd9Sstevel@tonic-gate 	 * vector call should have the same semantics as the original routine
103*7c478bd9Sstevel@tonic-gate 	 * it is replacing. (see get_prop as an example).
104*7c478bd9Sstevel@tonic-gate 	 *
105*7c478bd9Sstevel@tonic-gate 	 * The caller has the responsibility of converting the resulting data
106*7c478bd9Sstevel@tonic-gate 	 * back to a form it requires.
107*7c478bd9Sstevel@tonic-gate 	 *
108*7c478bd9Sstevel@tonic-gate 	 */
109*7c478bd9Sstevel@tonic-gate 	void		(*get_package_prop)(fcode_env_t *);
110*7c478bd9Sstevel@tonic-gate 	void		(*get_inherited_prop)(fcode_env_t *);
111*7c478bd9Sstevel@tonic-gate } device_vector_t;
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate typedef struct DEVICE device_t;
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate #define	MAX_MY_ADDR	4
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate struct DEVICE {
118*7c478bd9Sstevel@tonic-gate 	device_t	*parent;
119*7c478bd9Sstevel@tonic-gate 	device_t	*child;
120*7c478bd9Sstevel@tonic-gate 	device_t	*peer;
121*7c478bd9Sstevel@tonic-gate 	prop_t		*properties;
122*7c478bd9Sstevel@tonic-gate 	token_t		*vocabulary;
123*7c478bd9Sstevel@tonic-gate 	fstack_t	parent_adr_cells;
124*7c478bd9Sstevel@tonic-gate 	fstack_t	my_space;
125*7c478bd9Sstevel@tonic-gate 	fstack_t	my_addr[MAX_MY_ADDR];
126*7c478bd9Sstevel@tonic-gate 	fstack_t	frame_buffer_adr;
127*7c478bd9Sstevel@tonic-gate 	int		data_size[2];
128*7c478bd9Sstevel@tonic-gate 	token_t		*init_data;		/* initialised instance data */
129*7c478bd9Sstevel@tonic-gate 	void		*private;		/* app private data */
130*7c478bd9Sstevel@tonic-gate 	device_vector_t	vectors;
131*7c478bd9Sstevel@tonic-gate };
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate typedef struct INSTANCE  {
134*7c478bd9Sstevel@tonic-gate 	struct INSTANCE *parent;
135*7c478bd9Sstevel@tonic-gate 	device_t	*device;
136*7c478bd9Sstevel@tonic-gate 	/*
137*7c478bd9Sstevel@tonic-gate 	 * These are copies of the same structures from the device definition
138*7c478bd9Sstevel@tonic-gate 	 * however changes here will be thrown away when the instance is
139*7c478bd9Sstevel@tonic-gate 	 * destroyed.
140*7c478bd9Sstevel@tonic-gate 	 */
141*7c478bd9Sstevel@tonic-gate 	char		*my_args;
142*7c478bd9Sstevel@tonic-gate 	int		my_args_len;
143*7c478bd9Sstevel@tonic-gate 	fstack_t	my_space;
144*7c478bd9Sstevel@tonic-gate 	fstack_t	my_addr[MAX_MY_ADDR];
145*7c478bd9Sstevel@tonic-gate 	fstack_t	frame_buffer_adr;
146*7c478bd9Sstevel@tonic-gate 	token_t		*data[2];
147*7c478bd9Sstevel@tonic-gate } instance_t;
148*7c478bd9Sstevel@tonic-gate 
149*7c478bd9Sstevel@tonic-gate typedef struct FCODE_TOKEN {
150*7c478bd9Sstevel@tonic-gate 	ulong_t		flags;
151*7c478bd9Sstevel@tonic-gate 	char		*name;
152*7c478bd9Sstevel@tonic-gate 	acf_t		apf;	/* pointer to acf in dictionary */
153*7c478bd9Sstevel@tonic-gate #ifdef DEBUG
154*7c478bd9Sstevel@tonic-gate 	int		usage;
155*7c478bd9Sstevel@tonic-gate #endif
156*7c478bd9Sstevel@tonic-gate } fcode_token;
157*7c478bd9Sstevel@tonic-gate 
158*7c478bd9Sstevel@tonic-gate typedef struct {
159*7c478bd9Sstevel@tonic-gate 	char		*buffer;
160*7c478bd9Sstevel@tonic-gate 	char		*scanptr;
161*7c478bd9Sstevel@tonic-gate 	int		maxlen;
162*7c478bd9Sstevel@tonic-gate 	int		separator;
163*7c478bd9Sstevel@tonic-gate } input_typ;
164*7c478bd9Sstevel@tonic-gate 
165*7c478bd9Sstevel@tonic-gate typedef struct ERROR_FRAME {
166*7c478bd9Sstevel@tonic-gate 	struct ERROR_FRAME *next;
167*7c478bd9Sstevel@tonic-gate 	fstack_t	*ds;
168*7c478bd9Sstevel@tonic-gate 	fstack_t	*rs;
169*7c478bd9Sstevel@tonic-gate 	instance_t	*myself;
170*7c478bd9Sstevel@tonic-gate 	token_t		*ip;
171*7c478bd9Sstevel@tonic-gate 	fstack_t	code;
172*7c478bd9Sstevel@tonic-gate } error_frame;
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate struct FCODE_ENV  {
175*7c478bd9Sstevel@tonic-gate 	fcode_token	*table;		 /* token table */
176*7c478bd9Sstevel@tonic-gate 	uchar_t		*base;		 /* dictionary base */
177*7c478bd9Sstevel@tonic-gate 	uchar_t		*here;		 /* current dp */
178*7c478bd9Sstevel@tonic-gate 	char		*name;		 /* last name */
179*7c478bd9Sstevel@tonic-gate 	long		level;		 /* level */
180*7c478bd9Sstevel@tonic-gate 	token_t		*ip;		 /* instruction pointer */
181*7c478bd9Sstevel@tonic-gate 	token_t		*wa;		 /* word address */
182*7c478bd9Sstevel@tonic-gate 	fstack_t	*ds0;		 /* base of dats stack */
183*7c478bd9Sstevel@tonic-gate 	fstack_t	*rs0;		 /* base of return stack */
184*7c478bd9Sstevel@tonic-gate 	fstack_t	*ds;		 /* data stack base */
185*7c478bd9Sstevel@tonic-gate 	fstack_t	*rs;		 /* return stack base */
186*7c478bd9Sstevel@tonic-gate 	variable_t	num_base;	 /* current base */
187*7c478bd9Sstevel@tonic-gate 	token_t		*current;	 /* current voc */
188*7c478bd9Sstevel@tonic-gate 	long		order_depth;
189*7c478bd9Sstevel@tonic-gate 	token_t		**order;	 /* Voc. search order */
190*7c478bd9Sstevel@tonic-gate 	token_t		*lastlink;	 /* last forth def */
191*7c478bd9Sstevel@tonic-gate 	token_t		*forth_voc_link; /* Storage location for 'forth' voc */
192*7c478bd9Sstevel@tonic-gate 	int		last_token;	 /* last defined token */
193*7c478bd9Sstevel@tonic-gate 	device_t	*root_node;	 /* root node */
194*7c478bd9Sstevel@tonic-gate 	device_t	*attachment_pt;
195*7c478bd9Sstevel@tonic-gate 	device_t	*current_device; /*  */
196*7c478bd9Sstevel@tonic-gate 	instance_t	*my_self;	 /* pointer to my data */
197*7c478bd9Sstevel@tonic-gate 	int		offset_incr;	 /* size of FCODE token offsets */
198*7c478bd9Sstevel@tonic-gate 	error_frame	*catch_frame;
199*7c478bd9Sstevel@tonic-gate 	uchar_t		*fcode_buffer;	 /* pointer to fcode buffer */
200*7c478bd9Sstevel@tonic-gate 	uchar_t		*fcode_ptr;	 /* pointer into fcode buffer */
201*7c478bd9Sstevel@tonic-gate 	uchar_t		*last_fcode_ptr; /* pointer to last fcode fetched */
202*7c478bd9Sstevel@tonic-gate 	fstack_t	last_fcode;	 /* last fcode# executed */
203*7c478bd9Sstevel@tonic-gate 	fstack_t	last_error;	 /* last throw code executed */
204*7c478bd9Sstevel@tonic-gate 	int		fcode_incr;	 /* space between bytecodes */
205*7c478bd9Sstevel@tonic-gate 	int		interpretting;
206*7c478bd9Sstevel@tonic-gate 	variable_t	state;		 /* compile or run? */
207*7c478bd9Sstevel@tonic-gate 	int		fcode_debug;
208*7c478bd9Sstevel@tonic-gate 	int		diagnostic_mode;
209*7c478bd9Sstevel@tonic-gate 	fstack_t	instance_mode;
210*7c478bd9Sstevel@tonic-gate 	int		interactive;	 /* DEBUG, interact variable */
211*7c478bd9Sstevel@tonic-gate 	int		num_actions;
212*7c478bd9Sstevel@tonic-gate 	int		action_count;
213*7c478bd9Sstevel@tonic-gate 	token_t		*action_ptr;
214*7c478bd9Sstevel@tonic-gate 	int		strict_fcode;
215*7c478bd9Sstevel@tonic-gate 	fstack_t	control;	 /* control VM behaviour */
216*7c478bd9Sstevel@tonic-gate 	input_typ	*input;		 /* input buffer pointer */
217*7c478bd9Sstevel@tonic-gate 	variable_t	span;
218*7c478bd9Sstevel@tonic-gate 	char		*picturebufpos;	 /* pictured string buffer position */
219*7c478bd9Sstevel@tonic-gate 	char		*picturebuf;	 /* pictured string buffer */
220*7c478bd9Sstevel@tonic-gate 	int		picturebuflen;	 /* pictured string buffer length */
221*7c478bd9Sstevel@tonic-gate 	variable_t	output_column;	 /* output column# (#out) */
222*7c478bd9Sstevel@tonic-gate 	variable_t	output_line;	 /* output line# (#line) */
223*7c478bd9Sstevel@tonic-gate #ifdef CONVERT_HANDLES
224*7c478bd9Sstevel@tonic-gate 	device_t	*(*convert_phandle)(fcode_env_t *, fstack_t);
225*7c478bd9Sstevel@tonic-gate 	fstack_t	(*revert_phandle)(fcode_env_t *, device_t *);
226*7c478bd9Sstevel@tonic-gate 	void		(*allocate_phandle)(fcode_env_t *);
227*7c478bd9Sstevel@tonic-gate #endif
228*7c478bd9Sstevel@tonic-gate 	fc_resource_t	*propbufs;
229*7c478bd9Sstevel@tonic-gate 	void		*private;	 /* private data ptr for app use. */
230*7c478bd9Sstevel@tonic-gate };
231*7c478bd9Sstevel@tonic-gate 
232*7c478bd9Sstevel@tonic-gate #define	MAX_FCODE	0xfff		/* max no. of Fcode entries in table */
233*7c478bd9Sstevel@tonic-gate 
234*7c478bd9Sstevel@tonic-gate 
235*7c478bd9Sstevel@tonic-gate typedef unsigned char flag_t;
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate #define	DS		(env->ds)
238*7c478bd9Sstevel@tonic-gate #define	RS		(env->rs)
239*7c478bd9Sstevel@tonic-gate #define	TOS		*DS
240*7c478bd9Sstevel@tonic-gate #define	IP		(env->ip)
241*7c478bd9Sstevel@tonic-gate #define	WA		(env->wa)
242*7c478bd9Sstevel@tonic-gate #define	DEPTH		(DS-env->ds0)
243*7c478bd9Sstevel@tonic-gate #define	CURRENT		(env->current)
244*7c478bd9Sstevel@tonic-gate #define	ORDER		(env->order)
245*7c478bd9Sstevel@tonic-gate #define	BASE		(env->base)
246*7c478bd9Sstevel@tonic-gate #define	HERE		(env->here)
247*7c478bd9Sstevel@tonic-gate #define	CONTEXT		env->order[env->order_depth]
248*7c478bd9Sstevel@tonic-gate #define	MYSELF		(env->my_self)
249*7c478bd9Sstevel@tonic-gate 
250*7c478bd9Sstevel@tonic-gate #ifdef FCODE_INTERNAL
251*7c478bd9Sstevel@tonic-gate #include <fcode/proto.h>
252*7c478bd9Sstevel@tonic-gate #endif
253*7c478bd9Sstevel@tonic-gate #include <fcode/public.h>
254*7c478bd9Sstevel@tonic-gate 
255*7c478bd9Sstevel@tonic-gate #define	SIGN_SHIFT	((8*(sizeof (fstack_t)))-1)
256*7c478bd9Sstevel@tonic-gate #define	SIGN_BIT	(((ufstack_t)1)<<SIGN_SHIFT)
257*7c478bd9Sstevel@tonic-gate 
258*7c478bd9Sstevel@tonic-gate /*
259*7c478bd9Sstevel@tonic-gate  * Note that sizeof (token_t) MUST equal sizeof (token_t *).  If it doesn't,
260*7c478bd9Sstevel@tonic-gate  * many things will break.
261*7c478bd9Sstevel@tonic-gate  */
262*7c478bd9Sstevel@tonic-gate #define	_ALIGN(x, y)		(((long)(x)) & ~(sizeof (y)-1))
263*7c478bd9Sstevel@tonic-gate #define	TOKEN_ROUNDUP(x)	_ALIGN((x + ((sizeof (token_t)-1))), token_t)
264*7c478bd9Sstevel@tonic-gate 
265*7c478bd9Sstevel@tonic-gate #define	min(x, y)	((x) < (y) ? (x) : (y))
266*7c478bd9Sstevel@tonic-gate #define	max(x, y)	((x) > (y) ? (x) : (y))
267*7c478bd9Sstevel@tonic-gate 
268*7c478bd9Sstevel@tonic-gate /* values for flag_t */
269*7c478bd9Sstevel@tonic-gate #define	ANSI_WORD		0x01
270*7c478bd9Sstevel@tonic-gate #define	P1275_WORD		0x02
271*7c478bd9Sstevel@tonic-gate #define	FLAG_NONAME		0x04
272*7c478bd9Sstevel@tonic-gate #define	IMMEDIATE		0x08
273*7c478bd9Sstevel@tonic-gate #define	FLAG_VALUE		0x10
274*7c478bd9Sstevel@tonic-gate #define	FLAG_DEBUG		0x20
275*7c478bd9Sstevel@tonic-gate #define	DEFINER			(FLAG_NONAME|IMMEDIATE)
276*7c478bd9Sstevel@tonic-gate 
277*7c478bd9Sstevel@tonic-gate #define	FORTH(fl, nm, fnc)	define_word(env, fl, nm, fnc);
278*7c478bd9Sstevel@tonic-gate 
279*7c478bd9Sstevel@tonic-gate #define	LINK_TO_ACF(x)		(((token_t *)(x))+1)
280*7c478bd9Sstevel@tonic-gate #define	LINK_TO_FLAGS(x)	(((flag_t *)(x))-1)
281*7c478bd9Sstevel@tonic-gate #define	ACF_TO_LINK(x)		(((token_t *)(x))-1)
282*7c478bd9Sstevel@tonic-gate #define	ACF_TO_BODY(x)		(((acf_t)(x))+1)
283*7c478bd9Sstevel@tonic-gate #define	BODY_TO_LINK(x)		(((acf_t)(x))-1)
284*7c478bd9Sstevel@tonic-gate #define	BODY_TO_FLAGS(x)	(((flag_t *)(BODY_TO_LINK(x))) - 1)
285*7c478bd9Sstevel@tonic-gate #define	EXPOSE_ACF		*((acf_t)env->current) = \
286*7c478bd9Sstevel@tonic-gate 				    (token_t)(env->lastlink)
287*7c478bd9Sstevel@tonic-gate 
288*7c478bd9Sstevel@tonic-gate #define	COMPILE_TOKEN(x)	PUSH(DS, (fstack_t)(x)); compile_comma(env);
289*7c478bd9Sstevel@tonic-gate #define	CHECK_DEPTH(env, x, w)	if ((x) > (env->ds - env->ds0)) \
290*7c478bd9Sstevel@tonic-gate     forth_abort(env, "%s: stack underflow\n", w);
291*7c478bd9Sstevel@tonic-gate #define	CHECK_RETURN_DEPTH(env, x, w)	if ((x) > (env->rs - env->rs0)) \
292*7c478bd9Sstevel@tonic-gate     forth_abort(env, "%s: return stack underflow\n", w);
293*7c478bd9Sstevel@tonic-gate 
294*7c478bd9Sstevel@tonic-gate #define	FCRP_NOERROR		0x80000000	/* fc_run_priv: no err msg. */
295*7c478bd9Sstevel@tonic-gate 
296*7c478bd9Sstevel@tonic-gate #ifdef CONVERT_HANDLES
297*7c478bd9Sstevel@tonic-gate #define	CONVERT_PHANDLE(e, x, y)	x = env->convert_phandle(e, y)
298*7c478bd9Sstevel@tonic-gate #define	REVERT_PHANDLE(e, x, y)	x = env->revert_phandle(e, y)
299*7c478bd9Sstevel@tonic-gate #define	ALLOCATE_PHANDLE(e)	env->allocate_phandle(e)
300*7c478bd9Sstevel@tonic-gate #else
301*7c478bd9Sstevel@tonic-gate #define	CONVERT_PHANDLE(e, x, y)	x = (device_t *)(y)
302*7c478bd9Sstevel@tonic-gate #define	REVERT_PHANDLE(e, x, y)	x = (fstack_t)(y)
303*7c478bd9Sstevel@tonic-gate #define	ALLOCATE_PHANDLE(e)
304*7c478bd9Sstevel@tonic-gate #endif
305*7c478bd9Sstevel@tonic-gate 
306*7c478bd9Sstevel@tonic-gate extern fcode_env_t *env;
307*7c478bd9Sstevel@tonic-gate extern int dict_size;
308*7c478bd9Sstevel@tonic-gate extern int in_forth_abort;
309*7c478bd9Sstevel@tonic-gate extern int stack_size;
310*7c478bd9Sstevel@tonic-gate extern token_t value_defines[][3];
311*7c478bd9Sstevel@tonic-gate extern void (*bbranch_ptrs[3])(fcode_env_t *);
312*7c478bd9Sstevel@tonic-gate extern void (*blit_ptr)(fcode_env_t *);
313*7c478bd9Sstevel@tonic-gate extern void (*create_ptr)(fcode_env_t *);
314*7c478bd9Sstevel@tonic-gate extern void (*do_bdo_ptr)(fcode_env_t *);
315*7c478bd9Sstevel@tonic-gate extern void (*do_bqdo_ptr)(fcode_env_t *);
316*7c478bd9Sstevel@tonic-gate extern void (*do_leave_ptr)(fcode_env_t *);
317*7c478bd9Sstevel@tonic-gate extern void (*do_loop_ptr)(fcode_env_t *);
318*7c478bd9Sstevel@tonic-gate extern void (*do_ploop_ptr)(fcode_env_t *);
319*7c478bd9Sstevel@tonic-gate extern void (*does_ptr)(fcode_env_t *);
320*7c478bd9Sstevel@tonic-gate extern void (*quote_ptr)(fcode_env_t *);
321*7c478bd9Sstevel@tonic-gate extern void (*quote_ptr)(fcode_env_t *);
322*7c478bd9Sstevel@tonic-gate extern void (*semi_ptr)(fcode_env_t *);
323*7c478bd9Sstevel@tonic-gate extern void (*tlit_ptr)(fcode_env_t *);
324*7c478bd9Sstevel@tonic-gate extern void (*to_ptr)(fcode_env_t *);
325*7c478bd9Sstevel@tonic-gate extern void (*to_ptr)(fcode_env_t *);
326*7c478bd9Sstevel@tonic-gate 
327*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
328*7c478bd9Sstevel@tonic-gate }
329*7c478bd9Sstevel@tonic-gate #endif
330*7c478bd9Sstevel@tonic-gate 
331*7c478bd9Sstevel@tonic-gate #endif /* _FCODE_ENGINE_H */
332