summaryrefslogtreecommitdiff
path: root/usr/src/lib/efcode/include/fcode
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/efcode/include/fcode')
-rw-r--r--usr/src/lib/efcode/include/fcode/debug.h75
-rw-r--r--usr/src/lib/efcode/include/fcode/engine.h331
-rw-r--r--usr/src/lib/efcode/include/fcode/log.h60
-rw-r--r--usr/src/lib/efcode/include/fcode/private.h147
-rw-r--r--usr/src/lib/efcode/include/fcode/proto.h448
-rw-r--r--usr/src/lib/efcode/include/fcode/public.h59
6 files changed, 1120 insertions, 0 deletions
diff --git a/usr/src/lib/efcode/include/fcode/debug.h b/usr/src/lib/efcode/include/fcode/debug.h
new file mode 100644
index 0000000000..450844618c
--- /dev/null
+++ b/usr/src/lib/efcode/include/fcode/debug.h
@@ -0,0 +1,75 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 1999 by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#ifndef _FCODE_DEBUG_H
+#define _FCODE_DEBUG_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define DEBUG_CONTEXT 0x00000001
+#define DEBUG_BYTELOAD_DS 0x00000002
+#define DEBUG_BYTELOAD_RS 0x00000004
+#define DEBUG_BYTELOAD_TOKENS 0x00000008
+#define DEBUG_NEW_TOKEN 0x00000010
+#define DEBUG_EXEC_TRACE 0x00000020
+#define DEBUG_EXEC_SHOW_VITALS 0x00000040
+#define DEBUG_EXEC_DUMP_DS 0x00000080
+#define DEBUG_EXEC_DUMP_RS 0x00000100
+#define DEBUG_COMMA 0x00000200
+#define DEBUG_HEADER 0x00000400
+#define DEBUG_EXIT_WORDS 0x00000800
+#define DEBUG_EXIT_DUMP 0x00001000
+#define DEBUG_DUMP_TOKENS 0x00002000
+#define DEBUG_COLON 0x00004000
+#define DEBUG_NEXT_VITALS 0x00008000
+#define DEBUG_UPLOAD 0x00010000
+#define DEBUG_VOC_FIND 0x00020000
+#define DEBUG_DUMP_DICT_TOKENS 0x00040000
+#define DEBUG_TOKEN_USAGE 0x00080000
+#define DEBUG_DUMP_TOKEN_TABLE 0x00100000
+#define DEBUG_SHOW_STACK 0x00200000
+#define DEBUG_SHOW_RS 0x00400000
+#define DEBUG_TRACING 0x00800000
+#define DEBUG_TRACE_STACK 0x01000000
+#define DEBUG_CALL_METHOD 0x02000000
+#define DEBUG_ACTIONS 0x04000000
+#define DEBUG_STEPPING 0x08000000
+#define DEBUG_REG_ACCESS 0x10000000
+#define DEBUG_ADDR_ABUSE 0x20000000
+#define DEBUG_FIND_FCODE 0x40000000
+
+#define DEBUG_ANY 0xffffffff
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _FCODE_DEBUG_H */
diff --git a/usr/src/lib/efcode/include/fcode/engine.h b/usr/src/lib/efcode/include/fcode/engine.h
new file mode 100644
index 0000000000..06e5ef2767
--- /dev/null
+++ b/usr/src/lib/efcode/include/fcode/engine.h
@@ -0,0 +1,331 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2000 by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#ifndef _FCODE_ENGINE_H
+#define _FCODE_ENGINE_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MAX_ORDER 32
+#define CONVERT_HANDLES
+
+#ifdef BIGSTACK
+typedef long long fstack_t;
+typedef unsigned long long ufstack_t;
+#else
+typedef long fstack_t;
+typedef unsigned long ufstack_t;
+#endif
+typedef long *acf_t; /* pointer to execution token */
+typedef long token_t; /* sizeof a forth token */
+
+/* x@, x! type */
+typedef uint64_t u_xforth_t;
+typedef int64_t s_xforth_t;
+typedef uint64_t xforth_t;
+
+/* l@, l! type */
+typedef uint32_t u_lforth_t;
+typedef int32_t s_lforth_t;
+typedef uint32_t lforth_t;
+
+/* w@, w! type */
+typedef uint16_t u_wforth_t;
+typedef int16_t s_wforth_t;
+typedef uint16_t wforth_t;
+
+/* Double type */
+typedef uint64_t u_dforth_t;
+typedef int64_t s_dforth_t;
+typedef uint64_t dforth_t;
+
+/* Variable/Value/Constant type */
+typedef token_t variable_t;
+
+typedef struct PROPERTY {
+ char *name;
+ uchar_t *data;
+ int size;
+ struct PROPERTY *next;
+} prop_t;
+
+typedef struct RESOURCE {
+ struct RESOURCE *next;
+ void *data;
+} fc_resource_t;
+
+#define INIT_DATA 0
+#define UINIT_DATA 1
+
+typedef struct FCODE_ENV fcode_env_t;
+
+typedef struct DEVICE_VECTOR {
+ /*
+ * If there is private data associated with a node this vector
+ * table contains the routines that will be called to augment the
+ * device.
+ * These two routines allow the interpreter to use a different
+ *
+ * Interface Note:
+ * Any routine installed here is assumed to have the standard forth
+ * call state. It must be a void function call taking a forth execution
+ * environment, returning any data on the stack. In general the
+ * vector call should have the same semantics as the original routine
+ * it is replacing. (see get_prop as an example).
+ *
+ * The caller has the responsibility of converting the resulting data
+ * back to a form it requires.
+ *
+ */
+ void (*get_package_prop)(fcode_env_t *);
+ void (*get_inherited_prop)(fcode_env_t *);
+} device_vector_t;
+
+typedef struct DEVICE device_t;
+
+#define MAX_MY_ADDR 4
+
+struct DEVICE {
+ device_t *parent;
+ device_t *child;
+ device_t *peer;
+ prop_t *properties;
+ token_t *vocabulary;
+ fstack_t parent_adr_cells;
+ fstack_t my_space;
+ fstack_t my_addr[MAX_MY_ADDR];
+ fstack_t frame_buffer_adr;
+ int data_size[2];
+ token_t *init_data; /* initialised instance data */
+ void *private; /* app private data */
+ device_vector_t vectors;
+};
+
+typedef struct INSTANCE {
+ struct INSTANCE *parent;
+ device_t *device;
+ /*
+ * These are copies of the same structures from the device definition
+ * however changes here will be thrown away when the instance is
+ * destroyed.
+ */
+ char *my_args;
+ int my_args_len;
+ fstack_t my_space;
+ fstack_t my_addr[MAX_MY_ADDR];
+ fstack_t frame_buffer_adr;
+ token_t *data[2];
+} instance_t;
+
+typedef struct FCODE_TOKEN {
+ ulong_t flags;
+ char *name;
+ acf_t apf; /* pointer to acf in dictionary */
+#ifdef DEBUG
+ int usage;
+#endif
+} fcode_token;
+
+typedef struct {
+ char *buffer;
+ char *scanptr;
+ int maxlen;
+ int separator;
+} input_typ;
+
+typedef struct ERROR_FRAME {
+ struct ERROR_FRAME *next;
+ fstack_t *ds;
+ fstack_t *rs;
+ instance_t *myself;
+ token_t *ip;
+ fstack_t code;
+} error_frame;
+
+struct FCODE_ENV {
+ fcode_token *table; /* token table */
+ uchar_t *base; /* dictionary base */
+ uchar_t *here; /* current dp */
+ char *name; /* last name */
+ long level; /* level */
+ token_t *ip; /* instruction pointer */
+ token_t *wa; /* word address */
+ fstack_t *ds0; /* base of dats stack */
+ fstack_t *rs0; /* base of return stack */
+ fstack_t *ds; /* data stack base */
+ fstack_t *rs; /* return stack base */
+ variable_t num_base; /* current base */
+ token_t *current; /* current voc */
+ long order_depth;
+ token_t **order; /* Voc. search order */
+ token_t *lastlink; /* last forth def */
+ token_t *forth_voc_link; /* Storage location for 'forth' voc */
+ int last_token; /* last defined token */
+ device_t *root_node; /* root node */
+ device_t *attachment_pt;
+ device_t *current_device; /* */
+ instance_t *my_self; /* pointer to my data */
+ int offset_incr; /* size of FCODE token offsets */
+ error_frame *catch_frame;
+ uchar_t *fcode_buffer; /* pointer to fcode buffer */
+ uchar_t *fcode_ptr; /* pointer into fcode buffer */
+ uchar_t *last_fcode_ptr; /* pointer to last fcode fetched */
+ fstack_t last_fcode; /* last fcode# executed */
+ fstack_t last_error; /* last throw code executed */
+ int fcode_incr; /* space between bytecodes */
+ int interpretting;
+ variable_t state; /* compile or run? */
+ int fcode_debug;
+ int diagnostic_mode;
+ fstack_t instance_mode;
+ int interactive; /* DEBUG, interact variable */
+ int num_actions;
+ int action_count;
+ token_t *action_ptr;
+ int strict_fcode;
+ fstack_t control; /* control VM behaviour */
+ input_typ *input; /* input buffer pointer */
+ variable_t span;
+ char *picturebufpos; /* pictured string buffer position */
+ char *picturebuf; /* pictured string buffer */
+ int picturebuflen; /* pictured string buffer length */
+ variable_t output_column; /* output column# (#out) */
+ variable_t output_line; /* output line# (#line) */
+#ifdef CONVERT_HANDLES
+ device_t *(*convert_phandle)(fcode_env_t *, fstack_t);
+ fstack_t (*revert_phandle)(fcode_env_t *, device_t *);
+ void (*allocate_phandle)(fcode_env_t *);
+#endif
+ fc_resource_t *propbufs;
+ void *private; /* private data ptr for app use. */
+};
+
+#define MAX_FCODE 0xfff /* max no. of Fcode entries in table */
+
+
+typedef unsigned char flag_t;
+
+#define DS (env->ds)
+#define RS (env->rs)
+#define TOS *DS
+#define IP (env->ip)
+#define WA (env->wa)
+#define DEPTH (DS-env->ds0)
+#define CURRENT (env->current)
+#define ORDER (env->order)
+#define BASE (env->base)
+#define HERE (env->here)
+#define CONTEXT env->order[env->order_depth]
+#define MYSELF (env->my_self)
+
+#ifdef FCODE_INTERNAL
+#include <fcode/proto.h>
+#endif
+#include <fcode/public.h>
+
+#define SIGN_SHIFT ((8*(sizeof (fstack_t)))-1)
+#define SIGN_BIT (((ufstack_t)1)<<SIGN_SHIFT)
+
+/*
+ * Note that sizeof (token_t) MUST equal sizeof (token_t *). If it doesn't,
+ * many things will break.
+ */
+#define _ALIGN(x, y) (((long)(x)) & ~(sizeof (y)-1))
+#define TOKEN_ROUNDUP(x) _ALIGN((x + ((sizeof (token_t)-1))), token_t)
+
+#define min(x, y) ((x) < (y) ? (x) : (y))
+#define max(x, y) ((x) > (y) ? (x) : (y))
+
+/* values for flag_t */
+#define ANSI_WORD 0x01
+#define P1275_WORD 0x02
+#define FLAG_NONAME 0x04
+#define IMMEDIATE 0x08
+#define FLAG_VALUE 0x10
+#define FLAG_DEBUG 0x20
+#define DEFINER (FLAG_NONAME|IMMEDIATE)
+
+#define FORTH(fl, nm, fnc) define_word(env, fl, nm, fnc);
+
+#define LINK_TO_ACF(x) (((token_t *)(x))+1)
+#define LINK_TO_FLAGS(x) (((flag_t *)(x))-1)
+#define ACF_TO_LINK(x) (((token_t *)(x))-1)
+#define ACF_TO_BODY(x) (((acf_t)(x))+1)
+#define BODY_TO_LINK(x) (((acf_t)(x))-1)
+#define BODY_TO_FLAGS(x) (((flag_t *)(BODY_TO_LINK(x))) - 1)
+#define EXPOSE_ACF *((acf_t)env->current) = \
+ (token_t)(env->lastlink)
+
+#define COMPILE_TOKEN(x) PUSH(DS, (fstack_t)(x)); compile_comma(env);
+#define CHECK_DEPTH(env, x, w) if ((x) > (env->ds - env->ds0)) \
+ forth_abort(env, "%s: stack underflow\n", w);
+#define CHECK_RETURN_DEPTH(env, x, w) if ((x) > (env->rs - env->rs0)) \
+ forth_abort(env, "%s: return stack underflow\n", w);
+
+#define FCRP_NOERROR 0x80000000 /* fc_run_priv: no err msg. */
+
+#ifdef CONVERT_HANDLES
+#define CONVERT_PHANDLE(e, x, y) x = env->convert_phandle(e, y)
+#define REVERT_PHANDLE(e, x, y) x = env->revert_phandle(e, y)
+#define ALLOCATE_PHANDLE(e) env->allocate_phandle(e)
+#else
+#define CONVERT_PHANDLE(e, x, y) x = (device_t *)(y)
+#define REVERT_PHANDLE(e, x, y) x = (fstack_t)(y)
+#define ALLOCATE_PHANDLE(e)
+#endif
+
+extern fcode_env_t *env;
+extern int dict_size;
+extern int in_forth_abort;
+extern int stack_size;
+extern token_t value_defines[][3];
+extern void (*bbranch_ptrs[3])(fcode_env_t *);
+extern void (*blit_ptr)(fcode_env_t *);
+extern void (*create_ptr)(fcode_env_t *);
+extern void (*do_bdo_ptr)(fcode_env_t *);
+extern void (*do_bqdo_ptr)(fcode_env_t *);
+extern void (*do_leave_ptr)(fcode_env_t *);
+extern void (*do_loop_ptr)(fcode_env_t *);
+extern void (*do_ploop_ptr)(fcode_env_t *);
+extern void (*does_ptr)(fcode_env_t *);
+extern void (*quote_ptr)(fcode_env_t *);
+extern void (*quote_ptr)(fcode_env_t *);
+extern void (*semi_ptr)(fcode_env_t *);
+extern void (*tlit_ptr)(fcode_env_t *);
+extern void (*to_ptr)(fcode_env_t *);
+extern void (*to_ptr)(fcode_env_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _FCODE_ENGINE_H */
diff --git a/usr/src/lib/efcode/include/fcode/log.h b/usr/src/lib/efcode/include/fcode/log.h
new file mode 100644
index 0000000000..866739fb1c
--- /dev/null
+++ b/usr/src/lib/efcode/include/fcode/log.h
@@ -0,0 +1,60 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _FCODE_LOG_H
+#define _FCODE_LOG_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Internal Message Levels */
+#define MSG_FATAL 0x01 /* Fatal Error -> LOG_ERR */
+#define MSG_ERROR 0x02 /* Error -> LOG_ERR */
+#define MSG_WARN 0x04 /* Warning -> LOG_WARN */
+#define MSG_NOTE 0x08 /* Notice -> LOG_NOTICE */
+#define MSG_INFO 0x10 /* Informational -> LOG_INFO */
+#define MSG_DEBUG 0x20 /* Debug -> LOG_DEBUG */
+#define MSG_FC_DEBUG 0x40 /* Fcode (Noisy) Debug -> LOG_DEBUG */
+#define MSG_EMIT 0x80 /* Fcode Emit -> LOG_DEBUG */
+
+void log_message(int, char *, ...);
+void log_perror(int, char *, ...);
+void debug_msg(int, char *, ...);
+void open_syslog_log(char *, int);
+void open_error_log(char *, int);
+void log_emit(char);
+void set_daemon_log_flag(int);
+void set_min_syslog_level(int);
+int parse_msg_flags(char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _FCODE_LOG_H */
diff --git a/usr/src/lib/efcode/include/fcode/private.h b/usr/src/lib/efcode/include/fcode/private.h
new file mode 100644
index 0000000000..1a5834483b
--- /dev/null
+++ b/usr/src/lib/efcode/include/fcode/private.h
@@ -0,0 +1,147 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2000 by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#ifndef _FCODE_PRIVATE_H
+#define _FCODE_PRIVATE_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#ifdef DEBUG
+#include <fcode/debug.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+long get_interpreter_debug_level(void);
+void set_interpreter_debug_level(long lvl);
+
+#define DPRINTF(x, y) if (get_interpreter_debug_level() & (DEBUG_##x))\
+ printf y
+#define DEBUGF(x, y) if (get_interpreter_debug_level() & (DEBUG_##x))\
+ { y; }
+#else
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define DPRINTF(x, y)
+#define DEBUGF(x, y)
+#endif
+
+#define PUSH(sp, n) *(++sp) = (n)
+#define POP(sp) *(sp--)
+
+#define ERROR(x) printf x
+
+#define MALLOC(x) safe_malloc((x), __FILE__, __LINE__)
+#define REALLOC(x, n) safe_realloc((x), (n), __FILE__, __LINE__)
+#define STRDUP(x) safe_strdup((x), __FILE__, __LINE__)
+#define FREE(x) safe_free((x), __FILE__, __LINE__)
+
+#include <fcode/engine.h>
+
+extern fcode_env_t *initial_env;
+extern int fcode_impl_count;
+
+#define SET_TOKEN(t, f, n, a) \
+ env->table[t].flags = f; \
+ env->table[t].name = n; \
+ env->table[t].apf = a;
+
+#define FCODE(token, fl, nm, fnc) \
+ fcode_impl_count++; \
+ env->table[token].flags = fl; \
+ do_code(env, token, nm, fnc);
+
+#define ANSI(tk, t, nm, fnc) FCODE(tk, (ANSI_WORD|P1275_WORD|t), nm, fnc)
+#define P1275(tk, t, nm, fnc) FCODE(tk, (P1275_WORD|t), nm, fnc)
+
+#ifdef DEBUG
+#define ASSERT(x) if (!(x)) printf("%s:%d: ASSERT FAILED!!\n",\
+ __FILE__, __LINE__);
+#ifdef NOTICE
+#undef NOTICE
+#define NOTICE printf("%s:%d: _init called\n", __FILE__, __LINE__)
+#else
+#define NOTICE
+#endif
+#else
+#define ASSERT(x)
+#define NOTICE
+#endif
+
+void fc_abort(fcode_env_t *, char *type);
+
+#define TODO fc_abort(env, "TODO")
+#define FATAL ERROR(("%s:%d: MANGLED FCODE!! Fatal Error\n",\
+ __FILE__, __LINE__)))
+
+#ifndef USE_INTERRUPTS
+#define CHECK_INTERRUPT
+#define COMPLETE_INTERRUPT
+#else
+#define CHECK_INTERRUPT check_interrupt()
+#define COMPLETE_INTERRUPT complete_interrupt()
+#endif
+
+/* dforth_t manimpulations */
+#define MAKE_DFORTH(hi, lo) ((((u_dforth_t)(hi) << 32)) | \
+ (((u_dforth_t)(lo)) & 0xffffffff))
+#define DFORTH_LO(df) (((u_dforth_t)(df)) & 0xffffffff)
+#define DFORTH_HI(df) ((((u_dforth_t)(df)) >> 32) & 0xffffffff)
+
+#define TRUE (-1)
+#define FALSE (0)
+
+
+instance_t *open_instance_chain(fcode_env_t *, device_t *, int);
+void close_instance_chain(fcode_env_t *, instance_t *, int);
+void activate_device(fcode_env_t *, device_t *);
+void deactivate_device(fcode_env_t *, device_t *);
+
+void install_handlers(fcode_env_t *);
+void set_defer_actions(fcode_env_t *, int);
+void throw_from_fclib(fcode_env_t *, fstack_t, char *, ...);
+int get_default_intprop(fcode_env_t *, char *, device_t *, int);
+uint_t get_number_of_parent_address_cells(fcode_env_t *);
+char *get_package_name(fcode_env_t *, device_t *);
+
+token_t *get_instance_address(fcode_env_t *);
+fc_resource_t *find_resource(fc_resource_t **, void *,
+ int (c)(void *, void *));
+void *add_resource(fc_resource_t **, void *, int (c)(void *, void *));
+void free_resource(fc_resource_t **, void *, int (c)(void *, void *));
+void set_temporary_compile(fcode_env_t *);
+void temporary_execute(fcode_env_t *);
+prop_t *lookup_package_property(fcode_env_t *, char *, device_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _FCODE_PRIVATE_H */
diff --git a/usr/src/lib/efcode/include/fcode/proto.h b/usr/src/lib/efcode/include/fcode/proto.h
new file mode 100644
index 0000000000..84a7490cf4
--- /dev/null
+++ b/usr/src/lib/efcode/include/fcode/proto.h
@@ -0,0 +1,448 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2000-2003 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _FCODE_PROTO_H
+#define _FCODE_PROTO_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define FNPROTO(x) void x(fcode_env_t *)
+
+FNPROTO(bdo);
+FNPROTO(bqdo);
+
+FNPROTO(literal);
+void branch_common(fcode_env_t *, short, fstack_t, int);
+FNPROTO(zero);
+FNPROTO(bloop);
+FNPROTO(bplusloop);
+FNPROTO(loop_i);
+FNPROTO(loop_j);
+FNPROTO(bleave);
+FNPROTO(execute);
+FNPROTO(add);
+FNPROTO(subtract);
+FNPROTO(multiply);
+FNPROTO(slash_mod);
+FNPROTO(uslash_mod);
+FNPROTO(divide);
+FNPROTO(mod);
+FNPROTO(and);
+FNPROTO(or);
+FNPROTO(xor);
+FNPROTO(invert);
+FNPROTO(lshift);
+FNPROTO(rshift);
+FNPROTO(rshifta);
+FNPROTO(negate);
+FNPROTO(f_abs);
+FNPROTO(f_min);
+FNPROTO(f_max);
+FNPROTO(to_r);
+FNPROTO(from_r);
+FNPROTO(rfetch);
+FNPROTO(f_exit);
+FNPROTO(zero_equals);
+FNPROTO(zero_not_equals);
+FNPROTO(zero_less);
+FNPROTO(zero_less_equals);
+FNPROTO(zero_greater);
+FNPROTO(zero_greater_equals);
+FNPROTO(less);
+FNPROTO(greater);
+FNPROTO(equals);
+FNPROTO(not_equals);
+FNPROTO(unsign_greater);
+FNPROTO(unsign_less_equals);
+FNPROTO(unsign_less);
+FNPROTO(unsign_greater_equals);
+FNPROTO(greater_equals);
+FNPROTO(less_equals);
+FNPROTO(between);
+FNPROTO(within);
+FNPROTO(drop);
+FNPROTO(f_dup);
+FNPROTO(over);
+FNPROTO(swap);
+FNPROTO(rot);
+FNPROTO(minus_rot);
+FNPROTO(tuck);
+FNPROTO(nip);
+FNPROTO(pick);
+FNPROTO(roll);
+FNPROTO(qdup);
+FNPROTO(depth);
+FNPROTO(two_drop);
+FNPROTO(two_dup);
+FNPROTO(two_over);
+FNPROTO(two_swap);
+FNPROTO(two_rot);
+FNPROTO(two_slash);
+FNPROTO(utwo_slash);
+FNPROTO(two_times);
+FNPROTO(slash_c);
+FNPROTO(slash_w);
+FNPROTO(slash_l);
+FNPROTO(slash_n);
+FNPROTO(ca_plus);
+FNPROTO(wa_plus);
+FNPROTO(la_plus);
+FNPROTO(na_plus);
+FNPROTO(c1_plus);
+FNPROTO(w1_plus);
+FNPROTO(l1_plus);
+FNPROTO(cell_plus);
+FNPROTO(do_chars);
+FNPROTO(slash_w_times);
+FNPROTO(slash_l_times);
+FNPROTO(cells);
+FNPROTO(do_off);
+FNPROTO(do_on);
+FNPROTO(fetch);
+FNPROTO(lfetch);
+FNPROTO(wfetch);
+FNPROTO(swfetch);
+FNPROTO(cfetch);
+FNPROTO(store);
+FNPROTO(lstore);
+FNPROTO(wstore);
+FNPROTO(cstore);
+
+FNPROTO(noop);
+FNPROTO(lwsplit);
+FNPROTO(wljoin);
+FNPROTO(lbsplit);
+FNPROTO(bljoin);
+FNPROTO(wbflip);
+FNPROTO(upper_case);
+FNPROTO(lower_case);
+FNPROTO(pack_str);
+FNPROTO(count_str);
+FNPROTO(to_body);
+FNPROTO(to_acf);
+FNPROTO(bcase);
+FNPROTO(bendcase);
+
+FNPROTO(span);
+
+FNPROTO(expect);
+
+FNPROTO(emit);
+FNPROTO(type);
+
+FNPROTO(fc_crlf);
+
+FNPROTO(base);
+FNPROTO(dollar_number);
+FNPROTO(digit);
+
+FNPROTO(do_constant);
+FNPROTO(do_defer);
+FNPROTO(do_crash);
+FNPROTO(do_field);
+FNPROTO(idefer_exec);
+
+FNPROTO(set_args);
+
+void make_common_access(fcode_env_t *, char *, int, int, int,
+ void (*acf_i)(fcode_env_t *), void (*acf_s)(fcode_env_t *),
+ void (*set_a)(fcode_env_t *, int));
+
+FNPROTO(do_create);
+
+FNPROTO(instance);
+FNPROTO(semi);
+
+FNPROTO(dollar_find);
+acf_t voc_find(fcode_env_t *env);
+
+FNPROTO(evaluate);
+
+FNPROTO(ccomma);
+FNPROTO(wcomma);
+FNPROTO(lcomma);
+FNPROTO(comma);
+FNPROTO(state);
+FNPROTO(compile_comma);
+
+FNPROTO(here);
+FNPROTO(aligned);
+FNPROTO(wbsplit);
+FNPROTO(bwjoin);
+FNPROTO(bmark);
+FNPROTO(bresolve);
+
+FNPROTO(f_error);
+FNPROTO(fc_unimplemented);
+FNPROTO(fc_obsolete);
+FNPROTO(fc_historical);
+
+FNPROTO(myspace);
+FNPROTO(property);
+FNPROTO(encode_int);
+FNPROTO(encode_plus);
+FNPROTO(encode_phys);
+FNPROTO(encode_string);
+FNPROTO(encode_bytes);
+FNPROTO(model_prop);
+FNPROTO(device_type);
+FNPROTO(new_device);
+
+FNPROTO(finish_device);
+
+FNPROTO(device_name);
+
+FNPROTO(lwflip);
+FNPROTO(lbflip);
+
+FNPROTO(child_node);
+FNPROTO(peer_node);
+
+FNPROTO(byte_load);
+
+uchar_t next_bytecode(fcode_env_t *);
+ushort_t get_short(fcode_env_t *);
+uint_t get_int(fcode_env_t *);
+
+char *get_name(long *);
+FNPROTO(words);
+void header(fcode_env_t *, char *, int, flag_t);
+void do_code(fcode_env_t *, int, char *, FNPROTO((*)));
+void push_string(fcode_env_t *, char *, int);
+
+FNPROTO(verify_usage);
+FNPROTO(dump_dictionary);
+void print_stack_element(fcode_env_t *, fstack_t);
+void dump_data_stack(fcode_env_t *, int);
+void dump_return_stack(fcode_env_t *, int);
+char *acf_lookup(fcode_env_t *, acf_t);
+char *acf_to_name(fcode_env_t *, acf_t);
+int within_dictionary(fcode_env_t *, void *);
+char *acf_backup_search(fcode_env_t *, acf_t);
+void dump_forth_environment(fcode_env_t *);
+void forth_abort(fcode_env_t *, char *, ...);
+void forth_perror(fcode_env_t *, char *, ...);
+void return_to_interact(fcode_env_t *);
+char *get_path(fcode_env_t *, device_t *);
+char *search_for_fcode_file(fcode_env_t *, char *);
+int current_debug_state(fcode_env_t *);
+int debug_flags_to_mask(char *);
+int do_exec_debug(fcode_env_t *, void *);
+int name_is_debugged(fcode_env_t *, char *);
+prop_t *find_property(device_t *, char *);
+void buffer_init(fcode_env_t *env);
+void check_for_debug_entry(fcode_env_t *);
+void check_for_debug_exit(fcode_env_t *);
+void check_semi_debug_exit(fcode_env_t *);
+void check_vitals(fcode_env_t *);
+void clear_debug_state(fcode_env_t *, int);
+void debug_set_level(fcode_env_t *, int);
+void define_actions(fcode_env_t *env, int n, token_t *array);
+void do_alias(fcode_env_t *);
+void do_bbranch(fcode_env_t *env);
+void do_bdo(fcode_env_t *);
+void do_bleave(fcode_env_t *env);
+void do_bloop(fcode_env_t *env);
+void do_bofbranch(fcode_env_t *env);
+void do_bploop(fcode_env_t *env);
+void do_bqbranch(fcode_env_t *env);
+void do_bqdo(fcode_env_t *env);
+void do_creator(fcode_env_t *env);
+void do_default_action(fcode_env_t *env);
+void do_emit(fcode_env_t *, uchar_t);
+void do_literal(fcode_env_t *);
+void dump_comma(fcode_env_t *, char *);
+void dump_words(fcode_env_t *);
+void fevaluate(fcode_env_t *);
+void ibuffer_init(fcode_env_t *env);
+void install_builtin_nodes(fcode_env_t *);
+void install_does(fcode_env_t *);
+void install_openprom_nodes(fcode_env_t *);
+void install_package_nodes(fcode_env_t *);
+void internal_env_addr(fcode_env_t *env);
+void internal_env_fetch(fcode_env_t *env);
+void internal_env_store(fcode_env_t *env);
+void key(fcode_env_t *);
+void keyquestion(fcode_env_t *);
+void make_a_node(fcode_env_t *, char *, int);
+void output_data_stack(fcode_env_t *, int);
+void output_return_stack(fcode_env_t *, int, int);
+void output_step_message(fcode_env_t *);
+void output_vitals(fcode_env_t *);
+void print_property(fcode_env_t *, prop_t *, char *);
+void read_line(fcode_env_t *);
+void run_daemon(fcode_env_t *);
+void run_fcode_from_file(fcode_env_t *, char *, int);
+void tick_literal(fcode_env_t *);
+void unbug(fcode_env_t *);
+void xbflip(fcode_env_t *);
+void xfetch(fcode_env_t *);
+void xlflip(fcode_env_t *);
+void xstore(fcode_env_t *);
+void expose_acf(fcode_env_t *, char *);
+
+FNPROTO(do_semi);
+FNPROTO(do_colon);
+FNPROTO(do_next);
+void do_run(fcode_env_t *, int);
+
+void *safe_malloc(size_t, char *, int);
+void *safe_realloc(void *, size_t, char *, int);
+char *safe_strdup(char *, char *, int);
+void safe_free(void *, char *, int);
+
+FNPROTO(do_forth);
+FNPROTO(do_current);
+FNPROTO(do_context);
+FNPROTO(do_definitions);
+FNPROTO(do_interact);
+FNPROTO(do_resume);
+FNPROTO(do_vocab);
+FNPROTO(create);
+FNPROTO(colon);
+FNPROTO(does);
+FNPROTO(recursive);
+FNPROTO(do_if);
+FNPROTO(do_else);
+FNPROTO(do_then);
+FNPROTO(parse_word);
+FNPROTO(do_quote);
+FNPROTO(run_quote);
+
+FNPROTO(do_order);
+FNPROTO(do_also);
+FNPROTO(do_previous);
+
+FNPROTO(find_package);
+FNPROTO(open_package);
+FNPROTO(close_package);
+FNPROTO(find_method);
+FNPROTO(dollar_call_parent);
+FNPROTO(my_parent);
+FNPROTO(my_unit);
+FNPROTO(ihandle_to_phandle);
+FNPROTO(dollar_call_method);
+FNPROTO(dollar_open_package);
+
+FNPROTO(call_environment_method);
+
+FNPROTO(f_abort);
+FNPROTO(catch);
+FNPROTO(throw);
+
+FNPROTO(get_my_property);
+FNPROTO(decode_int);
+FNPROTO(decode_string);
+FNPROTO(get_inherited_prop);
+FNPROTO(delete_property);
+FNPROTO(get_package_property);
+void get_environment_property(fcode_env_t *env, int);
+
+FNPROTO(root_node);
+FNPROTO(current_device);
+FNPROTO(dot_properties);
+FNPROTO(pwd);
+FNPROTO(do_ls);
+FNPROTO(do_cd);
+FNPROTO(do_select_dev);
+FNPROTO(do_unselect_dev);
+FNPROTO(device_end);
+FNPROTO(value);
+FNPROTO(buffer_colon);
+FNPROTO(variable);
+FNPROTO(constant);
+FNPROTO(actions);
+FNPROTO(use_actions);
+FNPROTO(action_colon);
+FNPROTO(perform_action);
+FNPROTO(do_tick);
+FNPROTO(bracket_tick);
+FNPROTO(defer);
+FNPROTO(bye);
+FNPROTO(dump_device);
+FNPROTO(dump_instance);
+FNPROTO(compile_string);
+FNPROTO(parse_two_int);
+
+token_t *alloc_instance_data(fcode_env_t *, int, int, int *);
+FNPROTO(fetch_instance_data);
+FNPROTO(set_instance_data);
+FNPROTO(address_instance_data);
+FNPROTO(instance_variable);
+FNPROTO(decode_phys);
+
+void install_actions(fcode_env_t *env, token_t *table);
+void set_value_actions(fcode_env_t *env, int);
+void set_internal_value_actions(fcode_env_t *env);
+void set_buffer_actions(fcode_env_t *env, int);
+
+void system_message(fcode_env_t *env, char *msg);
+
+void check_interrupt(void);
+void complete_interrupt(void);
+
+FNPROTO(do_set_action);
+void push_a_string(fcode_env_t *, char *);
+char *pop_a_string(fcode_env_t *, int *);
+char *pop_a_duped_string(fcode_env_t *, int *);
+char *parse_a_string(fcode_env_t *, int *);
+void push_double(fcode_env_t *, dforth_t);
+dforth_t pop_double(fcode_env_t *);
+dforth_t peek_double(fcode_env_t *);
+void push_xforth(fcode_env_t *, xforth_t);
+xforth_t pop_xforth(fcode_env_t *);
+xforth_t peek_xforth(fcode_env_t *);
+void create_prop(fcode_env_t *, char *);
+void create_int_prop(fcode_env_t *, char *, int);
+void create_string_prop(fcode_env_t *, char *, char *);
+void make_builtin_hooks(fcode_env_t *, char *);
+fstack_t mapping_to_mcookie(uint64_t, size_t, uint64_t, size_t);
+void delete_mapping(fstack_t);
+int is_mcookie(fstack_t);
+uint64_t mcookie_to_addr(fstack_t);
+fstack_t mcookie_to_rlen(fstack_t);
+fstack_t mcookie_to_rvirt(fstack_t);
+void set_here(fcode_env_t *, uchar_t *, char *);
+int call_my_parent(fcode_env_t *, char *);
+FILE *get_dump_fd(fcode_env_t *);
+
+void load_file(fcode_env_t *);
+void token_roundup(fcode_env_t *, char *);
+
+#ifdef DEBUG
+void do_fclib_trace(fcode_env_t *, void *);
+int do_fclib_step(fcode_env_t *);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _FCODE_PROTO_H */
diff --git a/usr/src/lib/efcode/include/fcode/public.h b/usr/src/lib/efcode/include/fcode/public.h
new file mode 100644
index 0000000000..98ec6b2219
--- /dev/null
+++ b/usr/src/lib/efcode/include/fcode/public.h
@@ -0,0 +1,59 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2000 by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#ifndef _FCODE_PUBLIC_H
+#define _FCODE_PUBLIC_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * these are the public interfaces to the fcode interpretter
+ */
+
+void define_word(fcode_env_t *, int, char *, void (*)(fcode_env_t *));
+void push_ds(fcode_env_t *, fstack_t);
+void push_rs(fcode_env_t *, fstack_t);
+fstack_t pop_ds(fcode_env_t *);
+fstack_t pop_rs(fcode_env_t *);
+
+void run_fcode(fcode_env_t *, uchar_t *, int);
+void destroy_environment(fcode_env_t *);
+void begin_package(fcode_env_t *);
+void end_package(fcode_env_t *);
+fcode_env_t *clone_environment(fcode_env_t *, void *);
+
+void set_interpreter_debug_level(long);
+long get_interpreter_debug_level(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _FCODE_PUBLIC_H */