Remove loader.4th.8 and references to it.
[dragonfly.git] / sys / boot / ficl / i386 / sysdep.c
1 /*******************************************************************
2 ** s y s d e p . c
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... 
7 **
8 *******************************************************************/
9
10 /*
11  * $FreeBSD: src/sys/boot/ficl/i386/sysdep.c,v 1.7 1999/09/29 04:43:07 dcs Exp $
12  * $DragonFly: src/sys/boot/ficl/i386/sysdep.c,v 1.3 2003/11/10 06:08:33 dillon Exp $
13  */
14
15 #ifdef TESTMAIN
16 #include <stdio.h>
17 #include <stdlib.h>
18 #else
19 #include <stand.h>
20 #ifdef __i386__
21 #include <machine/cpufunc.h>
22 #endif
23 #endif
24 #include "ficl.h"
25
26 /*
27 *******************  FreeBSD  P O R T   B E G I N S   H E R E ******************** Michael Smith
28 */
29
30 #if PORTABLE_LONGMULDIV == 0
31 DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y)
32 {
33     DPUNS q;
34     u_int64_t qx;
35
36     qx = (u_int64_t)x * (u_int64_t) y;
37
38     q.hi = (u_int32_t)( qx >> 32 );
39     q.lo = (u_int32_t)( qx & 0xFFFFFFFFL);
40
41     return q;
42 }
43
44 UNSQR ficlLongDiv(DPUNS q, FICL_UNS y)
45 {
46     UNSQR result;
47     u_int64_t qx, qh;
48
49     qh = q.hi;
50     qx = (qh << 32) | q.lo;
51
52     result.quot = qx / y;
53     result.rem  = qx % y;
54
55     return result;
56 }
57 #endif
58
59 void  ficlTextOut(FICL_VM *pVM, char *msg, int fNewline)
60 {
61     IGNORE(pVM);
62
63     while(*msg != 0)
64         putchar(*(msg++));
65     if (fNewline)
66         putchar('\n');
67
68    return;
69 }
70
71 void *ficlMalloc (size_t size)
72 {
73     return malloc(size);
74 }
75
76 void *ficlRealloc (void *p, size_t size)
77 {
78     return realloc(p, size);
79 }
80
81 void  ficlFree   (void *p)
82 {
83     free(p);
84 }
85
86 #ifndef TESTMAIN
87 #ifdef __i386__
88 /* 
89  * outb ( port# c -- )
90  * Store a byte to I/O port number port#
91  */
92 void
93 ficlOutb(FICL_VM *pVM)
94 {
95         u_char c;
96         u_int32_t port;
97
98         port=stackPopUNS(pVM->pStack);
99         c=(u_char)stackPopINT(pVM->pStack);
100         outb(port,c);
101 }
102
103 /*
104  * inb ( port# -- c )
105  * Fetch a byte from I/O port number port#
106  */
107 void
108 ficlInb(FICL_VM *pVM)
109 {
110         u_char c;
111         u_int32_t port;
112
113         port=stackPopUNS(pVM->pStack);
114         c=inb(port);
115         stackPushINT(pVM->pStack,c);
116 }
117 #endif
118 #endif
119
120 /*
121 ** Stub function for dictionary access control - does nothing
122 ** by default, user can redefine to guarantee exclusive dict
123 ** access to a single thread for updates. All dict update code
124 ** is guaranteed to be bracketed as follows:
125 ** ficlLockDictionary(TRUE);
126 ** <code that updates dictionary>
127 ** ficlLockDictionary(FALSE);
128 **
129 ** Returns zero if successful, nonzero if unable to acquire lock
130 ** befor timeout (optional - could also block forever)
131 */
132 #if FICL_MULTITHREAD
133 int ficlLockDictionary(short fLock)
134 {
135         IGNORE(fLock);
136         return 0;
137 }
138 #endif /* FICL_MULTITHREAD */
139
140