1 /*******************************************************************
3 ** Forth Inspired Command Language
4 ** Author: John Sadler (john_sadler@alum.mit.edu)
5 ** Created: 16 Oct 1997
6 ** Implementations of FICL external interface functions...
8 *******************************************************************/
18 #include <machine/cpufunc.h>
24 ******************* FreeBSD P O R T B E G I N S H E R E ******************** Michael Smith
27 #if PORTABLE_LONGMULDIV == 0
28 DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y)
33 qx = (u_int64_t)x * (u_int64_t) y;
35 q.hi = (u_int32_t)( qx >> 32 );
36 q.lo = (u_int32_t)( qx & 0xFFFFFFFFL);
41 UNSQR ficlLongDiv(DPUNS q, FICL_UNS y)
47 qx = (qh << 32) | q.lo;
56 void ficlTextOut(FICL_VM *pVM, char *msg, int fNewline)
61 putchar((unsigned char)*(msg++));
68 void *ficlMalloc (size_t size)
73 void *ficlRealloc (void *p, size_t size)
75 return realloc(p, size);
78 void ficlFree (void *p)
86 * Store a byte to I/O port number port#
89 ficlOutb(FICL_VM *pVM)
94 port=stackPopUNS(pVM->pStack);
95 c=(u_char)stackPopINT(pVM->pStack);
101 * Fetch a byte from I/O port number port#
104 ficlInb(FICL_VM *pVM)
109 port=stackPopUNS(pVM->pStack);
111 stackPushINT(pVM->pStack,c);
115 * Glue function to add the appropriate forth words to access x86 special cpu
118 static void ficlCompileCpufunc(FICL_SYSTEM *pSys)
120 FICL_DICT *dp = pSys->dp;
123 dictAppendWord(dp, "outb", ficlOutb, FW_DEFAULT);
124 dictAppendWord(dp, "inb", ficlInb, FW_DEFAULT);
127 FICL_COMPILE_SET(ficlCompileCpufunc);
132 ** Stub function for dictionary access control - does nothing
133 ** by default, user can redefine to guarantee exclusive dict
134 ** access to a single thread for updates. All dict update code
135 ** is guaranteed to be bracketed as follows:
136 ** ficlLockDictionary(TRUE);
137 ** <code that updates dictionary>
138 ** ficlLockDictionary(FALSE);
140 ** Returns zero if successful, nonzero if unable to acquire lock
141 ** befor timeout (optional - could also block forever)
144 int ficlLockDictionary(short fLock)
149 #endif /* FICL_MULTITHREAD */