xref: /freebsd/stand/ficl/x86/sysdep.c (revision a3557ef0)
1 /* $FreeBSD$ */
2 
3 #ifndef TESTMAIN
4 #include <machine/cpufunc.h>
5 
6 /*
7  * outb ( port# c -- )
8  * Store a byte to I/O port number port#
9  */
10 void
11 ficlOutb(FICL_VM *pVM)
12 {
13 	u_char c;
14 	uint32_t port;
15 
16 	port=stackPopUNS(pVM->pStack);
17 	c=(u_char)stackPopINT(pVM->pStack);
18 	outb(port,c);
19 }
20 
21 /*
22  * inb ( port# -- c )
23  * Fetch a byte from I/O port number port#
24  */
25 void
26 ficlInb(FICL_VM *pVM)
27 {
28 	u_char c;
29 	uint32_t port;
30 
31 	port=stackPopUNS(pVM->pStack);
32 	c=inb(port);
33 	stackPushINT(pVM->pStack,c);
34 }
35 
36 /*
37  * Glue function to add the appropriate forth words to access x86 special cpu
38  * functionality.
39  */
40 static void ficlCompileCpufunc(FICL_SYSTEM *pSys)
41 {
42     FICL_DICT *dp = pSys->dp;
43     assert (dp);
44 
45     dictAppendWord(dp, "outb",      ficlOutb,       FW_DEFAULT);
46     dictAppendWord(dp, "inb",       ficlInb,        FW_DEFAULT);
47 }
48 
49 FICL_COMPILE_SET(ficlCompileCpufunc);
50 
51 #endif
52