xref: /titanic_50/usr/src/lib/efcode/jupiter/jupiter.c (revision 25cf1a301a396c38e8adf52c15f537b80d2483f7)
1*25cf1a30Sjl139090 /*
2*25cf1a30Sjl139090  * CDDL HEADER START
3*25cf1a30Sjl139090  *
4*25cf1a30Sjl139090  * The contents of this file are subject to the terms of the
5*25cf1a30Sjl139090  * Common Development and Distribution License (the "License").
6*25cf1a30Sjl139090  * You may not use this file except in compliance with the License.
7*25cf1a30Sjl139090  *
8*25cf1a30Sjl139090  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*25cf1a30Sjl139090  * or http://www.opensolaris.org/os/licensing.
10*25cf1a30Sjl139090  * See the License for the specific language governing permissions
11*25cf1a30Sjl139090  * and limitations under the License.
12*25cf1a30Sjl139090  *
13*25cf1a30Sjl139090  * When distributing Covered Code, include this CDDL HEADER in each
14*25cf1a30Sjl139090  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*25cf1a30Sjl139090  * If applicable, add the following below this CDDL HEADER, with the
16*25cf1a30Sjl139090  * fields enclosed by brackets "[]" replaced with your own identifying
17*25cf1a30Sjl139090  * information: Portions Copyright [yyyy] [name of copyright owner]
18*25cf1a30Sjl139090  *
19*25cf1a30Sjl139090  * CDDL HEADER END
20*25cf1a30Sjl139090  */
21*25cf1a30Sjl139090 /*
22*25cf1a30Sjl139090  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23*25cf1a30Sjl139090  * Use is subject to license terms.
24*25cf1a30Sjl139090  */
25*25cf1a30Sjl139090 
26*25cf1a30Sjl139090 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27*25cf1a30Sjl139090 
28*25cf1a30Sjl139090 #include <stdio.h>
29*25cf1a30Sjl139090 #include <stdlib.h>
30*25cf1a30Sjl139090 #include <strings.h>
31*25cf1a30Sjl139090 
32*25cf1a30Sjl139090 #include <fcode/private.h>
33*25cf1a30Sjl139090 #include <fcode/log.h>
34*25cf1a30Sjl139090 
35*25cf1a30Sjl139090 #include <fcdriver/fcdriver.h>
36*25cf1a30Sjl139090 
37*25cf1a30Sjl139090 #include <sys/opl_cfg.h>
38*25cf1a30Sjl139090 
39*25cf1a30Sjl139090 /* VA for HardWare Descriptor */
40*25cf1a30Sjl139090 static	hwd_cmu_chan_t	hwd_va_cmu;
41*25cf1a30Sjl139090 static	hwd_leaf_t	hwd_va_pci;
42*25cf1a30Sjl139090 
43*25cf1a30Sjl139090 /* Macro to get I/O portid */
44*25cf1a30Sjl139090 #define	DO_GET_IO_PORTID(env, lo, hi, portid)	\
45*25cf1a30Sjl139090 	PUSH(DS, lo);				\
46*25cf1a30Sjl139090 	PUSH(DS, hi);				\
47*25cf1a30Sjl139090 	do_get_io_portid(env);			\
48*25cf1a30Sjl139090 	portid = (uint32_t)POP(DS)
49*25cf1a30Sjl139090 
50*25cf1a30Sjl139090 fstack_t
51*25cf1a30Sjl139090 mem_map_in(fcode_env_t *env, fstack_t hi, fstack_t lo, fstack_t len)
52*25cf1a30Sjl139090 {
53*25cf1a30Sjl139090 	private_data_t	*pdp = DEVICE_PRIVATE(env);
54*25cf1a30Sjl139090 	fc_cell_t	virt;
55*25cf1a30Sjl139090 	fstack_t	mcookie = NULL;
56*25cf1a30Sjl139090 	char		*service = "map-in";
57*25cf1a30Sjl139090 	int		error;
58*25cf1a30Sjl139090 	int		offset = 0;
59*25cf1a30Sjl139090 
60*25cf1a30Sjl139090 	/*
61*25cf1a30Sjl139090 	 * The calculation of the offset, lo and len are left here
62*25cf1a30Sjl139090 	 * due to historical precedence.
63*25cf1a30Sjl139090 	 */
64*25cf1a30Sjl139090 
65*25cf1a30Sjl139090 	offset = lo & PAGEOFFSET;
66*25cf1a30Sjl139090 	lo &= PAGEMASK;
67*25cf1a30Sjl139090 	len = (len + offset + PAGEOFFSET) & PAGEMASK;
68*25cf1a30Sjl139090 
69*25cf1a30Sjl139090 	error = fc_run_priv(pdp->common, service, 3, 1, fc_size2cell(len),
70*25cf1a30Sjl139090 	    fc_uint32_t2cell(hi), fc_uint32_t2cell(lo), &virt);
71*25cf1a30Sjl139090 
72*25cf1a30Sjl139090 	if (error)
73*25cf1a30Sjl139090 		throw_from_fclib(env, 1, "jupiter:%s: failed\n", service);
74*25cf1a30Sjl139090 
75*25cf1a30Sjl139090 	mcookie = mapping_to_mcookie(virt, len, NULL, NULL);
76*25cf1a30Sjl139090 
77*25cf1a30Sjl139090 	if (mcookie == NULL)
78*25cf1a30Sjl139090 		throw_from_fclib(env, 1,
79*25cf1a30Sjl139090 		    "jupiter:%s: mapping_to_mcookie failed\n", service);
80*25cf1a30Sjl139090 
81*25cf1a30Sjl139090 	mcookie += offset;
82*25cf1a30Sjl139090 
83*25cf1a30Sjl139090 	debug_msg(DEBUG_REG_ACCESS, "jupiter:%s: %llx -> %x\n", service,
84*25cf1a30Sjl139090 	    (long long)virt, (uint32_t)mcookie);
85*25cf1a30Sjl139090 
86*25cf1a30Sjl139090 	return (mcookie);
87*25cf1a30Sjl139090 }
88*25cf1a30Sjl139090 
89*25cf1a30Sjl139090 static void
90*25cf1a30Sjl139090 mem_map_out(fcode_env_t *env, fstack_t mcookie, fstack_t len)
91*25cf1a30Sjl139090 {
92*25cf1a30Sjl139090 	private_data_t	*pdp = DEVICE_PRIVATE(env);
93*25cf1a30Sjl139090 	fc_cell_t	virt;
94*25cf1a30Sjl139090 	char		*service = "map-out";
95*25cf1a30Sjl139090 	int		error;
96*25cf1a30Sjl139090 	int		offset;
97*25cf1a30Sjl139090 
98*25cf1a30Sjl139090 	/*
99*25cf1a30Sjl139090 	 * The calculation of the offset, lo and len are left here
100*25cf1a30Sjl139090 	 * due to historical precedence.
101*25cf1a30Sjl139090 	 */
102*25cf1a30Sjl139090 
103*25cf1a30Sjl139090 	offset = mcookie & PAGEOFFSET;
104*25cf1a30Sjl139090 	mcookie &= PAGEMASK;
105*25cf1a30Sjl139090 	len = (len + offset + PAGEOFFSET) & PAGEMASK;
106*25cf1a30Sjl139090 
107*25cf1a30Sjl139090 	if (!is_mcookie(mcookie)) {
108*25cf1a30Sjl139090 		log_message(MSG_ERROR, "jupiter:%s: %x not an mcookie!\n",
109*25cf1a30Sjl139090 		    service, (int)mcookie);
110*25cf1a30Sjl139090 		virt = mcookie;
111*25cf1a30Sjl139090 	} else {
112*25cf1a30Sjl139090 		virt = mcookie_to_addr(mcookie);
113*25cf1a30Sjl139090 		debug_msg(DEBUG_REG_ACCESS, "jupiter:%s: %x -> %llx\n",
114*25cf1a30Sjl139090 		    service, (int)mcookie, (long long)virt);
115*25cf1a30Sjl139090 		delete_mapping(mcookie);
116*25cf1a30Sjl139090 	}
117*25cf1a30Sjl139090 
118*25cf1a30Sjl139090 	error = fc_run_priv(pdp->common, service, 2, 0,
119*25cf1a30Sjl139090 	    fc_size2cell(len), virt);
120*25cf1a30Sjl139090 	if (error)
121*25cf1a30Sjl139090 		log_message(MSG_ERROR, "jupiter:%s: failed\n", service);
122*25cf1a30Sjl139090 }
123*25cf1a30Sjl139090 
124*25cf1a30Sjl139090 static void
125*25cf1a30Sjl139090 do_map_in(fcode_env_t *env)
126*25cf1a30Sjl139090 {
127*25cf1a30Sjl139090 	fstack_t	phi, plo, len, addr;
128*25cf1a30Sjl139090 
129*25cf1a30Sjl139090 	CHECK_DEPTH(env, 3, "jupiter:map-in");
130*25cf1a30Sjl139090 	len = POP(DS);
131*25cf1a30Sjl139090 	phi = POP(DS);
132*25cf1a30Sjl139090 	plo = POP(DS);
133*25cf1a30Sjl139090 	addr = mem_map_in(env, phi, plo, len);
134*25cf1a30Sjl139090 	PUSH(DS, addr);
135*25cf1a30Sjl139090 }
136*25cf1a30Sjl139090 
137*25cf1a30Sjl139090 static void
138*25cf1a30Sjl139090 do_map_out(fcode_env_t *env)
139*25cf1a30Sjl139090 {
140*25cf1a30Sjl139090 	fstack_t	addr, len;
141*25cf1a30Sjl139090 
142*25cf1a30Sjl139090 	CHECK_DEPTH(env, 2, "jupiter:map-out");
143*25cf1a30Sjl139090 	len = POP(DS);
144*25cf1a30Sjl139090 	addr = POP(DS);
145*25cf1a30Sjl139090 	mem_map_out(env, addr, len);
146*25cf1a30Sjl139090 }
147*25cf1a30Sjl139090 
148*25cf1a30Sjl139090 static void
149*25cf1a30Sjl139090 do_get_io_portid(fcode_env_t *env)
150*25cf1a30Sjl139090 {
151*25cf1a30Sjl139090 	fstack_t	phi, plo;
152*25cf1a30Sjl139090 	unsigned int	portid, lsb, ch, leaf;
153*25cf1a30Sjl139090 
154*25cf1a30Sjl139090 	CHECK_DEPTH(env, 2, "jupiter:get-portid");
155*25cf1a30Sjl139090 
156*25cf1a30Sjl139090 	phi = POP(DS);
157*25cf1a30Sjl139090 	plo = POP(DS);
158*25cf1a30Sjl139090 
159*25cf1a30Sjl139090 	lsb  = OPL_ADDR_TO_LSB(phi);
160*25cf1a30Sjl139090 	ch   = OPL_ADDR_TO_CHANNEL(phi);
161*25cf1a30Sjl139090 	leaf = OPL_ADDR_TO_LEAF(phi, plo);
162*25cf1a30Sjl139090 
163*25cf1a30Sjl139090 	portid = OPL_IO_PORTID(lsb, ch, leaf);
164*25cf1a30Sjl139090 
165*25cf1a30Sjl139090 	debug_msg(DEBUG_REG_ACCESS, "jupiter:get-portid ( %x %x ) -> %x\n",
166*25cf1a30Sjl139090 	    (int)phi, (int)plo, (int)portid);
167*25cf1a30Sjl139090 	PUSH(DS, portid);
168*25cf1a30Sjl139090 }
169*25cf1a30Sjl139090 
170*25cf1a30Sjl139090 static void
171*25cf1a30Sjl139090 do_encode_unit(fcode_env_t *env)
172*25cf1a30Sjl139090 {
173*25cf1a30Sjl139090 	char		enc_buf[64];
174*25cf1a30Sjl139090 	fstack_t	hi, lo;
175*25cf1a30Sjl139090 	uint32_t	id;
176*25cf1a30Sjl139090 	long long	off;
177*25cf1a30Sjl139090 
178*25cf1a30Sjl139090 	CHECK_DEPTH(env, 2, "jupiter:encode-unit");
179*25cf1a30Sjl139090 
180*25cf1a30Sjl139090 	hi = POP(DS);
181*25cf1a30Sjl139090 	lo = POP(DS);
182*25cf1a30Sjl139090 	off = (long long)(((hi & 0x1F) << 32) | lo);
183*25cf1a30Sjl139090 
184*25cf1a30Sjl139090 	/* Convert physical address to portid */
185*25cf1a30Sjl139090 	DO_GET_IO_PORTID(env, lo, hi, id);
186*25cf1a30Sjl139090 
187*25cf1a30Sjl139090 	if (off) {
188*25cf1a30Sjl139090 		(void) sprintf(enc_buf, "%x,%llx", id, off);
189*25cf1a30Sjl139090 	} else {
190*25cf1a30Sjl139090 		(void) sprintf(enc_buf, "%x", id);
191*25cf1a30Sjl139090 	}
192*25cf1a30Sjl139090 
193*25cf1a30Sjl139090 	debug_msg(DEBUG_REG_ACCESS, "jupiter:encode_unit ( %x %x ) -> '%s'\n",
194*25cf1a30Sjl139090 	    (uint32_t)hi, (uint32_t)lo, enc_buf);
195*25cf1a30Sjl139090 
196*25cf1a30Sjl139090 	push_a_string(env, STRDUP(enc_buf));
197*25cf1a30Sjl139090 }
198*25cf1a30Sjl139090 
199*25cf1a30Sjl139090 static void
200*25cf1a30Sjl139090 do_decode_unit(fcode_env_t *env)
201*25cf1a30Sjl139090 {
202*25cf1a30Sjl139090 	uint32_t	hi;
203*25cf1a30Sjl139090 	long long	lo;
204*25cf1a30Sjl139090 	unsigned int	portid, lsb, ch;
205*25cf1a30Sjl139090 	char		*buf;
206*25cf1a30Sjl139090 
207*25cf1a30Sjl139090 	CHECK_DEPTH(env, 2, "jupiter:decode-unit");
208*25cf1a30Sjl139090 
209*25cf1a30Sjl139090 	buf = pop_a_string(env, NULL);
210*25cf1a30Sjl139090 	if (sscanf(buf, "%x,%llx", &portid, &lo) != 2) {
211*25cf1a30Sjl139090 		if (sscanf(buf, "%x", &portid) != 1) {
212*25cf1a30Sjl139090 			throw_from_fclib(env, 1, "jupiter:decode_unit:%s",
213*25cf1a30Sjl139090 			    buf);
214*25cf1a30Sjl139090 		}
215*25cf1a30Sjl139090 		lo = 0;
216*25cf1a30Sjl139090 	}
217*25cf1a30Sjl139090 
218*25cf1a30Sjl139090 	lsb = OPL_IO_PORTID_TO_LSB(portid);
219*25cf1a30Sjl139090 	ch  = OPL_PORTID_TO_CHANNEL(portid);
220*25cf1a30Sjl139090 	hi  = OPL_ADDR_HI(lsb, ch);
221*25cf1a30Sjl139090 
222*25cf1a30Sjl139090 	debug_msg(DEBUG_REG_ACCESS,
223*25cf1a30Sjl139090 	    "jupiter:decode_unit ( '%s' ) -> %x %llx\n", buf, hi, lo);
224*25cf1a30Sjl139090 
225*25cf1a30Sjl139090 	PUSH(DS, (fstack_t)lo);
226*25cf1a30Sjl139090 	PUSH(DS, (fstack_t)hi);
227*25cf1a30Sjl139090 }
228*25cf1a30Sjl139090 
229*25cf1a30Sjl139090 static void
230*25cf1a30Sjl139090 do_device_id(fcode_env_t *env)
231*25cf1a30Sjl139090 {
232*25cf1a30Sjl139090 	common_data_t	*cdp = COMMON_PRIVATE(env);
233*25cf1a30Sjl139090 	char		*buf = NULL;
234*25cf1a30Sjl139090 	uint32_t	hi;
235*25cf1a30Sjl139090 	long long	lo;
236*25cf1a30Sjl139090 	uint32_t	portid, ch, leaf;
237*25cf1a30Sjl139090 
238*25cf1a30Sjl139090 	CHECK_DEPTH(env, 2, "jupiter:device-id");
239*25cf1a30Sjl139090 
240*25cf1a30Sjl139090 	hi = POP(DS);
241*25cf1a30Sjl139090 	lo = POP(DS);
242*25cf1a30Sjl139090 
243*25cf1a30Sjl139090 	portid = 0;
244*25cf1a30Sjl139090 	if (cdp && cdp->fc.unit_address &&
245*25cf1a30Sjl139090 	    ((buf = strdup(cdp->fc.unit_address)) != NULL)) {
246*25cf1a30Sjl139090 		/*
247*25cf1a30Sjl139090 		 * Get portid number from unit_address
248*25cf1a30Sjl139090 		 * Because of no leaf information in physical address
249*25cf1a30Sjl139090 		 */
250*25cf1a30Sjl139090 		if (sscanf(buf, "%x,%llx", &portid, &lo) != 2) {
251*25cf1a30Sjl139090 			if (sscanf(buf, "%x", &portid) != 1) {
252*25cf1a30Sjl139090 				throw_from_fclib(env, 1,
253*25cf1a30Sjl139090 				    "jupiter:do_device_id: invalid %s", buf);
254*25cf1a30Sjl139090 			}
255*25cf1a30Sjl139090 		}
256*25cf1a30Sjl139090 	} else {
257*25cf1a30Sjl139090 		/*
258*25cf1a30Sjl139090 		 * Non existence unit_address case.
259*25cf1a30Sjl139090 		 * Convert physical address to portid.
260*25cf1a30Sjl139090 		 */
261*25cf1a30Sjl139090 		throw_from_fclib(env, 1,
262*25cf1a30Sjl139090 		    "jupiter:do_device_id: failed unit address");
263*25cf1a30Sjl139090 		DO_GET_IO_PORTID(env, lo, hi, portid);
264*25cf1a30Sjl139090 	}
265*25cf1a30Sjl139090 
266*25cf1a30Sjl139090 	debug_msg(DEBUG_FIND_FCODE,
267*25cf1a30Sjl139090 	    "jupiter:do_device_id:(%x,%llx)\n", portid, lo);
268*25cf1a30Sjl139090 
269*25cf1a30Sjl139090 	/* Pick up each ID from portid */
270*25cf1a30Sjl139090 	ch   = OPL_PORTID_TO_CHANNEL(portid);
271*25cf1a30Sjl139090 	leaf = OPL_PORTID_TO_LEAF(portid);
272*25cf1a30Sjl139090 
273*25cf1a30Sjl139090 	if (ch == OPL_CMU_CHANNEL) {
274*25cf1a30Sjl139090 		/*
275*25cf1a30Sjl139090 		 * CMU-CH: PCICMU CHANNEL
276*25cf1a30Sjl139090 		 */
277*25cf1a30Sjl139090 		debug_msg(DEBUG_FIND_FCODE,
278*25cf1a30Sjl139090 		    "jupiter:do_device_id:cmu-ch\n");
279*25cf1a30Sjl139090 		push_a_string(env, "cmu-ch");
280*25cf1a30Sjl139090 	} else if (OPL_OBERON_CHANNEL(ch) && OPL_VALID_LEAF(leaf)) {
281*25cf1a30Sjl139090 		/*
282*25cf1a30Sjl139090 		 * PCI-CH: Oberon Leaves CHANNEL
283*25cf1a30Sjl139090 		 */
284*25cf1a30Sjl139090 		if (leaf) {
285*25cf1a30Sjl139090 			/* Leaf B */
286*25cf1a30Sjl139090 			debug_msg(DEBUG_FIND_FCODE,
287*25cf1a30Sjl139090 			    "jupiter:do_device_id:jup-oberon-pci1\n");
288*25cf1a30Sjl139090 			push_a_string(env, "jup-oberon-pci1");
289*25cf1a30Sjl139090 		} else {
290*25cf1a30Sjl139090 			/* Leaf A */
291*25cf1a30Sjl139090 			debug_msg(DEBUG_FIND_FCODE,
292*25cf1a30Sjl139090 			    "jupiter:do_device_id:jup-oberon-pci0\n");
293*25cf1a30Sjl139090 			push_a_string(env, "jup-oberon-pci0");
294*25cf1a30Sjl139090 		}
295*25cf1a30Sjl139090 	} else {
296*25cf1a30Sjl139090 		/* Not matched to any channels */
297*25cf1a30Sjl139090 		throw_from_fclib(env, 1,
298*25cf1a30Sjl139090 		    "jupiter:do_device_id: invalid portid %x", portid);
299*25cf1a30Sjl139090 		push_a_string(env, "");
300*25cf1a30Sjl139090 	}
301*25cf1a30Sjl139090 
302*25cf1a30Sjl139090 	/* Free the duplicated buf */
303*25cf1a30Sjl139090 	if (buf != NULL)
304*25cf1a30Sjl139090 		free(buf);
305*25cf1a30Sjl139090 }
306*25cf1a30Sjl139090 
307*25cf1a30Sjl139090 static void
308*25cf1a30Sjl139090 do_get_hwd_va(fcode_env_t *env)
309*25cf1a30Sjl139090 {
310*25cf1a30Sjl139090 	private_data_t	*pdp = DEVICE_PRIVATE(env);
311*25cf1a30Sjl139090 	char		*service = "get-hwd-va";
312*25cf1a30Sjl139090 	char		*buf;
313*25cf1a30Sjl139090 	uint32_t	portid = 0;
314*25cf1a30Sjl139090 	int		ch;
315*25cf1a30Sjl139090 	int		error;
316*25cf1a30Sjl139090 	fc_cell_t	status;
317*25cf1a30Sjl139090 	void		*hwd_va;
318*25cf1a30Sjl139090 
319*25cf1a30Sjl139090 	CHECK_DEPTH(env, 2, "jupiter:get-hwd-va");
320*25cf1a30Sjl139090 
321*25cf1a30Sjl139090 	/* Get a portid with string format */
322*25cf1a30Sjl139090 	buf = pop_a_string(env, NULL);
323*25cf1a30Sjl139090 
324*25cf1a30Sjl139090 	/* Convert to the integer from the string */
325*25cf1a30Sjl139090 	if (sscanf(buf, "%x", &portid) != 1) {
326*25cf1a30Sjl139090 		throw_from_fclib(env, 1, "jupiter:%s: invalid portid",
327*25cf1a30Sjl139090 		    service);
328*25cf1a30Sjl139090 	}
329*25cf1a30Sjl139090 
330*25cf1a30Sjl139090 	ch = OPL_PORTID_TO_CHANNEL(portid);
331*25cf1a30Sjl139090 	if (!OPL_VALID_CHANNEL(ch)) {
332*25cf1a30Sjl139090 		throw_from_fclib(env, 1, "jupiter:%s: invalid poritd",
333*25cf1a30Sjl139090 		    service);
334*25cf1a30Sjl139090 		hwd_va = 0;
335*25cf1a30Sjl139090 		goto out;
336*25cf1a30Sjl139090 	}
337*25cf1a30Sjl139090 
338*25cf1a30Sjl139090 	if (ch == OPL_CMU_CHANNEL) {
339*25cf1a30Sjl139090 		hwd_va = (void *)&hwd_va_cmu;
340*25cf1a30Sjl139090 	} else {
341*25cf1a30Sjl139090 		hwd_va = (void *)&hwd_va_pci;
342*25cf1a30Sjl139090 	}
343*25cf1a30Sjl139090 
344*25cf1a30Sjl139090 	/*
345*25cf1a30Sjl139090 	 * Get the virtual address of hwd specified with portid.
346*25cf1a30Sjl139090 	 */
347*25cf1a30Sjl139090 	error = fc_run_priv(pdp->common, service, 2, 1,
348*25cf1a30Sjl139090 	    fc_uint32_t2cell(portid), fc_ptr2cell(hwd_va), &status);
349*25cf1a30Sjl139090 
350*25cf1a30Sjl139090 	if (error || !status)
351*25cf1a30Sjl139090 		throw_from_fclib(env, 1, "jupiter:%s: failed\n", service);
352*25cf1a30Sjl139090 
353*25cf1a30Sjl139090 out:
354*25cf1a30Sjl139090 	PUSH(DS, (fstack_t)hwd_va);
355*25cf1a30Sjl139090 }
356*25cf1a30Sjl139090 
357*25cf1a30Sjl139090 static void
358*25cf1a30Sjl139090 do_get_intrp_name(fcode_env_t *env)
359*25cf1a30Sjl139090 {
360*25cf1a30Sjl139090 	/*
361*25cf1a30Sjl139090 	 * Just pass the "eFCode" string.
362*25cf1a30Sjl139090 	 */
363*25cf1a30Sjl139090 
364*25cf1a30Sjl139090 	debug_msg(DEBUG_FIND_FCODE,
365*25cf1a30Sjl139090 	    "jupiter: do_get_intrp_name: eFCode\n");
366*25cf1a30Sjl139090 
367*25cf1a30Sjl139090 	push_a_string(env, "eFCode");
368*25cf1a30Sjl139090 }
369*25cf1a30Sjl139090 
370*25cf1a30Sjl139090 static void
371*25cf1a30Sjl139090 do_master_interrupt(fcode_env_t *env)
372*25cf1a30Sjl139090 {
373*25cf1a30Sjl139090 	int	portid;
374*25cf1a30Sjl139090 	token_t	xt;
375*25cf1a30Sjl139090 
376*25cf1a30Sjl139090 	CHECK_DEPTH(env, 2, "jupiter:master-interrput");
377*25cf1a30Sjl139090 	portid	= POP(DS);
378*25cf1a30Sjl139090 	xt	= POP(DS);
379*25cf1a30Sjl139090 
380*25cf1a30Sjl139090 	PUSH(DS, FALSE);
381*25cf1a30Sjl139090 	debug_msg(DEBUG_REG_ACCESS,
382*25cf1a30Sjl139090 	    "jupiter:master-interrupt ( %x %x ) -> %x\n",
383*25cf1a30Sjl139090 	    portid, xt, (int)FALSE);
384*25cf1a30Sjl139090 }
385*25cf1a30Sjl139090 
386*25cf1a30Sjl139090 static void
387*25cf1a30Sjl139090 do_register_vector_entry(fcode_env_t *env)
388*25cf1a30Sjl139090 {
389*25cf1a30Sjl139090 	int	ign, ino, level;
390*25cf1a30Sjl139090 
391*25cf1a30Sjl139090 	CHECK_DEPTH(env, 3, "jupiter:register-vector-entry");
392*25cf1a30Sjl139090 	ign   = POP(DS);
393*25cf1a30Sjl139090 	ino   = POP(DS);
394*25cf1a30Sjl139090 	level = POP(DS);
395*25cf1a30Sjl139090 
396*25cf1a30Sjl139090 	PUSH(DS, FALSE);
397*25cf1a30Sjl139090 	debug_msg(DEBUG_REG_ACCESS,
398*25cf1a30Sjl139090 	    "jupiter:register-vector-entry ( %x %x %x ) -> %x\n",
399*25cf1a30Sjl139090 	    ign, ino, level, (int)FALSE);
400*25cf1a30Sjl139090 }
401*25cf1a30Sjl139090 
402*25cf1a30Sjl139090 static void
403*25cf1a30Sjl139090 do_get_interrupt_target(fcode_env_t *env)
404*25cf1a30Sjl139090 {
405*25cf1a30Sjl139090 	int	mid = -1;
406*25cf1a30Sjl139090 
407*25cf1a30Sjl139090 	PUSH(DS, mid);
408*25cf1a30Sjl139090 	debug_msg(DEBUG_REG_ACCESS,
409*25cf1a30Sjl139090 		"jupiter:get-interrupt-target ( ) -> %x\n", mid);
410*25cf1a30Sjl139090 }
411*25cf1a30Sjl139090 
412*25cf1a30Sjl139090 
413*25cf1a30Sjl139090 #pragma init(_init)
414*25cf1a30Sjl139090 
415*25cf1a30Sjl139090 static void
416*25cf1a30Sjl139090 _init(void)
417*25cf1a30Sjl139090 {
418*25cf1a30Sjl139090 	fcode_env_t *env = initial_env;
419*25cf1a30Sjl139090 
420*25cf1a30Sjl139090 	ASSERT(env);
421*25cf1a30Sjl139090 	ASSERT(env->current_device);
422*25cf1a30Sjl139090 	NOTICE;
423*25cf1a30Sjl139090 
424*25cf1a30Sjl139090 	create_int_prop(env, "#address-cells", 2);
425*25cf1a30Sjl139090 
426*25cf1a30Sjl139090 	FORTH(0,	"map-in",		do_map_in);
427*25cf1a30Sjl139090 	FORTH(0,	"map-out",		do_map_out);
428*25cf1a30Sjl139090 	FORTH(0,	"get-portid",		do_get_io_portid);
429*25cf1a30Sjl139090 	FORTH(0,	"decode-unit",		do_decode_unit);
430*25cf1a30Sjl139090 	FORTH(0,	"encode-unit",		do_encode_unit);
431*25cf1a30Sjl139090 	FORTH(0,	"device-id",		do_device_id);
432*25cf1a30Sjl139090 	FORTH(0,	"get-hwd-va",		do_get_hwd_va);
433*25cf1a30Sjl139090 	FORTH(0,	"get-fcinterp-name",	do_get_intrp_name);
434*25cf1a30Sjl139090 	FORTH(0,	"master-interrupt",	do_master_interrupt);
435*25cf1a30Sjl139090 	FORTH(0,	"register-vector-entry", do_register_vector_entry);
436*25cf1a30Sjl139090 	FORTH(0,	"get-interrupt-target",	do_get_interrupt_target);
437*25cf1a30Sjl139090 }
438