Loader vs loader efi ficl incompatibility

William william at firstyear.id.au
Tue Nov 4 00:00:42 UTC 2014


> > Are there differences in the ficl interpreter between loader and
> > loader.efi? Is this perhaps a bug?
> 
> The loader only includes inb and outb for i386 (the non-UEFI loader is
> 32-bit for both i386 and amd64):
> 
> #ifdef __i386__
>     dictAppendWord(dp, "outb",      ficlOutb,       FW_DEFAULT);
>     dictAppendWord(dp, "inb",       ficlInb,        FW_DEFAULT);
> #endif
> 
> We'd need to make these available in the 64-bit loader.efi, although
> I'd really like to have MBP support be handled automatically in the
> loader itself.

Hi

I've done some testing and the following patch works to make outb and
inb available on amd64.

The main question and concern is that I'm 

A) Duplicating the code from i386
B) That I am enabling this by commenting out the ifdef. Is there an
__amd64__ ifdef I can use? Or can we make outb / inb platform
independent. I would assume they are coming from machine/cpufunc.h


This of course lets me initially get the mac to boot, and I'm having
some display issues now. These have been posted to the x11 mailing list.

Going forwards you mention making the MBP support part of loader itself.
Where in loader is hardware specific initialisation done? Any pointers
on how to develop this support?


svn diff
Index: amd64/sysdep.c
===================================================================
--- amd64/sysdep.c	(revision 274065)
+++ amd64/sysdep.c	(working copy)
@@ -15,6 +15,7 @@
 #else
 #include <stand.h>
 #endif
+#include <machine/cpufunc.h>
 #include "ficl.h"
 
 /*
@@ -77,8 +78,37 @@
     free(p);
 }
 
+/* 
+ * outb ( port# c -- )
+ * Store a byte to I/O port number port#
+ */
+void
+ficlOutb(FICL_VM *pVM)
+{
+	u_char c;
+	u_int32_t port;
 
+	port=stackPopUNS(pVM->pStack);
+	c=(u_char)stackPopINT(pVM->pStack);
+	outb(port,c);
+}
+
 /*
+ * inb ( port# -- c )
+ * Fetch a byte from I/O port number port#
+ */
+void
+ficlInb(FICL_VM *pVM)
+{
+	u_char c;
+	u_int32_t port;
+
+	port=stackPopUNS(pVM->pStack);
+	c=inb(port);
+	stackPushINT(pVM->pStack,c);
+}
+
+/*
 ** Stub function for dictionary access control - does nothing
 ** by default, user can redefine to guarantee exclusive dict
 ** access to a single thread for updates. All dict update code
Index: ficl.h
===================================================================
--- ficl.h	(revision 274065)
+++ ficl.h	(working copy)
@@ -1113,10 +1113,10 @@
 ** Various FreeBSD goodies
 */
 
-#if defined(__i386__) && !defined(TESTMAIN)
+/* #if defined(__i386__) && !defined(TESTMAIN) -- Is there an __amd64__
I can use here? */
 extern void ficlOutb(FICL_VM *pVM);
 extern void ficlInb(FICL_VM *pVM);
-#endif
+/* #endif */
 
 extern void ficlSetenv(FICL_VM *pVM);
 extern void ficlSetenvq(FICL_VM *pVM);
Index: loader.c
===================================================================
--- loader.c	(revision 274065)
+++ loader.c	(working copy)
@@ -786,10 +786,10 @@
     dictAppendWord(dp, "findfile",  ficlFindfile,   FW_DEFAULT);
     dictAppendWord(dp, "ccall",	    ficlCcall,	    FW_DEFAULT);
 #ifndef TESTMAIN
-#ifdef __i386__
+/* #ifdef __i386__ -- Is there an __amd64__  I can use here? */
     dictAppendWord(dp, "outb",      ficlOutb,       FW_DEFAULT);
     dictAppendWord(dp, "inb",       ficlInb,        FW_DEFAULT);
-#endif
+/* #endif */
 #ifdef HAVE_PNP
     dictAppendWord(dp, "pnpdevices",ficlPnpdevices, FW_DEFAULT);
     dictAppendWord(dp, "pnphandlers",ficlPnphandlers, FW_DEFAULT);




More information about the freebsd-questions mailing list