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