summaryrefslogtreecommitdiffstats
path: root/sys/boot
diff options
context:
space:
mode:
authordcs <dcs@FreeBSD.org>2000-09-08 17:03:53 +0000
committerdcs <dcs@FreeBSD.org>2000-09-08 17:03:53 +0000
commite8604ccc3e3dcfaa3f271aa1b8d2302c92f5b2bf (patch)
tree7b01a26096c3c4f3fbb7f39be7d571d2bfc94d5f /sys/boot
parent96bba78abe47f2c895c63531755845e9a265267d (diff)
downloadFreeBSD-src-e8604ccc3e3dcfaa3f271aa1b8d2302c92f5b2bf.zip
FreeBSD-src-e8604ccc3e3dcfaa3f271aa1b8d2302c92f5b2bf.tar.gz
Add the infrastructure necessary to handle PnP from a Forth script.
Also, export the file_findfile() function. Again, this is taken from work in progress but frozen for the time being. Since it works, I'd rather commit and remove any uglyness later than hide it on my tree.
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/ficl/ficl.h4
-rw-r--r--sys/boot/ficl/loader.c95
-rw-r--r--sys/boot/ficl/words.c4
3 files changed, 103 insertions, 0 deletions
diff --git a/sys/boot/ficl/ficl.h b/sys/boot/ficl/ficl.h
index b78fab2..fe041ad 100644
--- a/sys/boot/ficl/ficl.h
+++ b/sys/boot/ficl/ficl.h
@@ -873,6 +873,10 @@ extern void ficlGetenv(FICL_VM *pVM);
extern void ficlUnsetenv(FICL_VM *pVM);
extern void ficlCopyin(FICL_VM *pVM);
extern void ficlCopyout(FICL_VM *pVM);
+extern void ficlFindfile(FICL_VM *pVM);
+extern void ficlPnpdevices(FICL_VM *pVM);
+extern void ficlPnphandlers(FICL_VM *pVM);
+extern void ficlCcall(FICL_VM *pVM);
#endif
#ifdef __cplusplus
diff --git a/sys/boot/ficl/loader.c b/sys/boot/ficl/loader.c
index 1444bbc..34bdb7f 100644
--- a/sys/boot/ficl/loader.c
+++ b/sys/boot/ficl/loader.c
@@ -45,6 +45,10 @@
* unsetenv ( addr n -- )
* copyin ( addr addr' len -- )
* copyout ( addr addr' len -- )
+ * findfile ( name len type len' -- addr )
+ * pnpdevices ( -- addr )
+ * pnphandlers ( -- addr )
+ * ccall ( [[...[p10] p9] ... p1] n addr -- result )
*/
void
@@ -206,3 +210,94 @@ ficlCopyout(FICL_VM *pVM)
return;
}
+void
+ficlFindfile(FICL_VM *pVM)
+{
+ char *name, *type, *namep, *typep;
+ struct preloaded_file* fp;
+ int names, types;
+
+#if FICL_ROBUST > 1
+ vmCheckStack(pVM, 4, 1);
+#endif
+
+ types = stackPopINT(pVM->pStack);
+ typep = (char*) stackPopPtr(pVM->pStack);
+ names = stackPopINT(pVM->pStack);
+ namep = (char*) stackPopPtr(pVM->pStack);
+ name = (char*) ficlMalloc(names+1);
+ if (!name)
+ vmThrowErr(pVM, "Error: out of memory");
+ strncpy(name, namep, names);
+ name[names] = '\0';
+ type = (char*) ficlMalloc(types+1);
+ if (!type)
+ vmThrowErr(pVM, "Error: out of memory");
+ strncpy(type, typep, types);
+ type[types] = '\0';
+
+ fp = file_findfile(name, type);
+ stackPushPtr(pVM->pStack, fp);
+
+ return;
+}
+
+void
+ficlPnpdevices(FICL_VM *pVM)
+{
+ static int pnp_devices_initted = 0;
+#if FICL_ROBUST > 1
+ vmCheckStack(pVM, 0, 1);
+#endif
+
+ if(!pnp_devices_initted) {
+ STAILQ_INIT(&pnp_devices);
+ pnp_devices_initted = 1;
+ }
+
+ stackPushPtr(pVM->pStack, &pnp_devices);
+
+ return;
+}
+
+void
+ficlPnphandlers(FICL_VM *pVM)
+{
+#if FICL_ROBUST > 1
+ vmCheckStack(pVM, 0, 1);
+#endif
+
+ stackPushPtr(pVM->pStack, pnphandlers);
+
+ return;
+}
+
+void
+ficlCcall(FICL_VM *pVM)
+{
+ int (*func)(int, ...);
+ int result, p[10];
+ int nparam, i;
+
+#if FICL_ROBUST > 1
+ vmCheckStack(pVM, 2, 0);
+#endif
+
+ func = stackPopPtr(pVM->pStack);
+ nparam = stackPopINT(pVM->pStack);
+
+#if FICL_ROBUST > 1
+ vmCheckStack(pVM, nparam, 1);
+#endif
+
+ for (i = 0; i < nparam; i++)
+ p[i] = stackPopINT(pVM->pStack);
+
+ result = func(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8],
+ p[9]);
+
+ stackPushINT(pVM->pStack, result);
+
+ return;
+}
+
diff --git a/sys/boot/ficl/words.c b/sys/boot/ficl/words.c
index 621a3f7..0136610 100644
--- a/sys/boot/ficl/words.c
+++ b/sys/boot/ficl/words.c
@@ -4832,6 +4832,10 @@ void ficlCompileCore(FICL_DICT *dp)
dictAppendWord(dp, "unsetenv", ficlUnsetenv, FW_DEFAULT);
dictAppendWord(dp, "copyin", ficlCopyin, FW_DEFAULT);
dictAppendWord(dp, "copyout", ficlCopyout, FW_DEFAULT);
+ dictAppendWord(dp, "findfile", ficlFindfile, FW_DEFAULT);
+ dictAppendWord(dp, "pnpdevices",ficlPnpdevices, FW_DEFAULT);
+ dictAppendWord(dp, "pnphandlers",ficlPnphandlers, FW_DEFAULT);
+ dictAppendWord(dp, "ccall", ficlCcall, FW_DEFAULT);
#endif
#if defined(__i386__)
OpenPOWER on IntegriCloud