Example #1
0
void
left_parse_string(fcode_env_t *env)
{
	char sep, *cptr, *lstr, *rstr;
	int len, llen, rlen;

	CHECK_DEPTH(env, 3, "left-parse-string");
	sep = (char)POP(DS);
	if (TOS == 0) {
		two_dup(env);
		return;
	}
	lstr = pop_a_string(env, &llen);
	len = 0;
	cptr = NULL;
	while (len < llen) {
		if (lstr[len] == sep) {
			cptr = lstr+len;
			break;
		}
		len++;
	}
	if (cptr != NULL) {
		rstr = cptr+1;
		rlen = lstr + llen - rstr;
		llen = len;
	} else {
		rlen = 0;
		rstr = lstr;
	}
	PUSH(DS, (fstack_t)rstr);
	PUSH(DS, rlen);
	PUSH(DS, (fstack_t)lstr);
	PUSH(DS, llen);
}
Example #2
0
static void
do_decode_unit(fcode_env_t *env)
{
	uint32_t	hi;
	long long	lo;
	unsigned int	portid, lsb, ch;
	char		*buf;

	CHECK_DEPTH(env, 2, "jupiter:decode-unit");

	buf = pop_a_string(env, NULL);
	if (sscanf(buf, "%x,%llx", &portid, &lo) != 2) {
		if (sscanf(buf, "%x", &portid) != 1) {
			throw_from_fclib(env, 1, "jupiter:decode_unit:%s",
			    buf);
		}
		lo = 0;
	}

	lsb = OPL_IO_PORTID_TO_LSB(portid);
	ch  = OPL_PORTID_TO_CHANNEL(portid);
	hi  = OPL_ADDR_HI(lsb, ch);

	debug_msg(DEBUG_REG_ACCESS,
	    "jupiter:decode_unit ( '%s' ) -> %x %llx\n", buf, hi, lo);

	PUSH(DS, (fstack_t)lo);
	PUSH(DS, (fstack_t)hi);
}
Example #3
0
static void
set_error_log(fcode_env_t *env)
{
	char *fname;
	FILE *fp;

	parse_word(env);
	fname = pop_a_string(env, NULL);
	if (fname != NULL) {
		if ((fp = fopen(fname, "a")) == NULL) {
			log_perror(MSG_ERROR, "Can't open '%s'\n", fname);
			return;
		}
		if (error_log_fp)
			fclose(error_log_fp);
		if (error_log_name)
			FREE(error_log_name);
		error_log_fp = fp;
		error_log_name = STRDUP(fname);
		error_log_flags = MSG_FATAL|MSG_ERROR|MSG_WARN|MSG_INFO|
		    MSG_DEBUG|MSG_FC_DEBUG;
	} else if (error_log_name)
		log_message(MSG_INFO, "%s\n", error_log_name);
	else
		log_message(MSG_INFO, "NULL\n");
}
Example #4
0
static void
do_get_hwd_va(fcode_env_t *env)
{
	private_data_t	*pdp = DEVICE_PRIVATE(env);
	char		*service = "get-hwd-va";
	char		*buf;
	uint32_t	portid = 0;
	int		ch;
	int		error;
	fc_cell_t	status;
	void		*hwd_va;

	CHECK_DEPTH(env, 2, "jupiter:get-hwd-va");

	/* Get a portid with string format */
	buf = pop_a_string(env, NULL);

	/* Convert to the integer from the string */
	if (sscanf(buf, "%x", &portid) != 1) {
		throw_from_fclib(env, 1, "jupiter:%s: invalid portid",
		    service);
	}

	ch = OPL_PORTID_TO_CHANNEL(portid);
	if (!OPL_VALID_CHANNEL(ch)) {
		throw_from_fclib(env, 1, "jupiter:%s: invalid poritd",
		    service);
		hwd_va = 0;
		goto out;
	}

	if (ch == OPL_CMU_CHANNEL) {
		hwd_va = (void *)&hwd_va_cmu;
	} else {
		hwd_va = (void *)&hwd_va_pci;
	}

	/*
	 * Get the virtual address of hwd specified with portid.
	 */
	error = fc_run_priv(pdp->common, service, 2, 1,
	    fc_uint32_t2cell(portid), fc_ptr2cell(hwd_va), &status);

	if (error || !status)
		throw_from_fclib(env, 1, "jupiter:%s: failed\n", service);

out:
	PUSH(DS, (fstack_t)hwd_va);
}
Example #5
0
/*
 * (is-user-word)  ( name-str name-len xt -- )
 */
void
is_user_word(fcode_env_t *env)
{
	fstack_t xt;
	char *name;
	int len;

	CHECK_DEPTH(env, 3, "(is-user-word)");
	xt = POP(DS);
	name = pop_a_string(env, &len);
	header(env, name, len, 0);
	COMPILE_TOKEN(&do_alias);
	COMPILE_TOKEN(xt);
	expose_acf(env, name);
}
Example #6
0
void
parse_two_int(fcode_env_t *env)
{
	uint_t lo, hi;
	char *str;
	int len;

	CHECK_DEPTH(env, 2, "parse-2int");
	lo = 0;
	hi = 0;
	str = pop_a_string(env, &len);
	if (len) {
		if (sscanf(str, "%x,%x", &hi, &lo) != 2) {
			throw_from_fclib(env, 1, "parse_2int");
		}
	}
	PUSH(DS, lo);
	PUSH(DS, hi);
}