示例#1
0
static void
do_encode_unit(fcode_env_t *env)
{
	char		enc_buf[64];
	fstack_t	hi, lo;
	uint32_t	id;
	long long	off;

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

	hi = POP(DS);
	lo = POP(DS);
	off = (long long)(((hi & 0x1F) << 32) | lo);

	/* Convert physical address to portid */
	DO_GET_IO_PORTID(env, lo, hi, id);

	if (off) {
		(void) sprintf(enc_buf, "%x,%llx", id, off);
	} else {
		(void) sprintf(enc_buf, "%x", id);
	}

	debug_msg(DEBUG_REG_ACCESS, "jupiter:encode_unit ( %x %x ) -> '%s'\n",
	    (uint32_t)hi, (uint32_t)lo, enc_buf);

	push_a_string(env, STRDUP(enc_buf));
}
示例#2
0
/*
 * 'mac-address' - complicated by 'local-mac-address' stuff.
 */
static void
mac_address(fcode_env_t *env)
{
    fstack_t d;

    if (mac_addr_is_valid) {
        push_mac_address(env);
        return;
    }

    /*
     * From here, we essentially re-implement OBP's 'mac-address' word.
     * on some platforms, this may need to be re-implemented.
     */
    local_mac_address(env);
    d = POP(DS);
    if (d) {
        push_a_string(env, "local-mac-address");
        get_inherited_prop(env);
        d = POP(DS);
        if (d == FALSE && TOS == 6)
            return;
        two_drop(env);
    }
    local_ether_addr(env);
}
示例#3
0
static void
do_get_intrp_name(fcode_env_t *env)
{
	/*
	 * Just pass the "eFCode" string.
	 */

	debug_msg(DEBUG_FIND_FCODE,
	    "jupiter: do_get_intrp_name: eFCode\n");

	push_a_string(env, "eFCode");
}
示例#4
0
Int32_t cuda_getDeviceProps (void)
    {
    int ndevices, sort;
    char *props;

    int status = getDeviceProps(&ndevices, &props);
    if (DeviceProps_Success != status)
	return status;

    for (sort = 0; sort < ndevices; sort++) 
	{
	int length = strlen(props);
	push_a_string(length, props);
	props += 1 + length;
	}

    return status;
    }
示例#5
0
static void
do_device_id(fcode_env_t *env)
{
	common_data_t	*cdp = COMMON_PRIVATE(env);
	char		*buf = NULL;
	uint32_t	hi;
	long long	lo;
	uint32_t	portid, ch, leaf;

	CHECK_DEPTH(env, 2, "jupiter:device-id");

	hi = POP(DS);
	lo = POP(DS);

	portid = 0;
	if (cdp && cdp->fc.unit_address &&
	    ((buf = strdup(cdp->fc.unit_address)) != NULL)) {
		/*
		 * Get portid number from unit_address
		 * Because of no leaf information in physical address
		 */
		if (sscanf(buf, "%x,%llx", &portid, &lo) != 2) {
			if (sscanf(buf, "%x", &portid) != 1) {
				throw_from_fclib(env, 1,
				    "jupiter:do_device_id: invalid %s", buf);
			}
		}
	} else {
		/*
		 * Non existence unit_address case.
		 * Convert physical address to portid.
		 */
		throw_from_fclib(env, 1,
		    "jupiter:do_device_id: failed unit address");
		DO_GET_IO_PORTID(env, lo, hi, portid);
	}

	debug_msg(DEBUG_FIND_FCODE,
	    "jupiter:do_device_id:(%x,%llx)\n", portid, lo);

	/* Pick up each ID from portid */
	ch   = OPL_PORTID_TO_CHANNEL(portid);
	leaf = OPL_PORTID_TO_LEAF(portid);

	if (ch == OPL_CMU_CHANNEL) {
		/*
		 * CMU-CH: PCICMU CHANNEL
		 */
		debug_msg(DEBUG_FIND_FCODE,
		    "jupiter:do_device_id:cmu-ch\n");
		push_a_string(env, "cmu-ch");
	} else if (OPL_OBERON_CHANNEL(ch) && OPL_VALID_LEAF(leaf)) {
		/*
		 * PCI-CH: Oberon Leaves CHANNEL
		 */
		if (leaf) {
			/* Leaf B */
			debug_msg(DEBUG_FIND_FCODE,
			    "jupiter:do_device_id:jup-oberon-pci1\n");
			push_a_string(env, "jup-oberon-pci1");
		} else {
			/* Leaf A */
			debug_msg(DEBUG_FIND_FCODE,
			    "jupiter:do_device_id:jup-oberon-pci0\n");
			push_a_string(env, "jup-oberon-pci0");
		}
	} else {
		/* Not matched to any channels */
		throw_from_fclib(env, 1,
		    "jupiter:do_device_id: invalid portid %x", portid);
		push_a_string(env, "");
	}

	/* Free the duplicated buf */
	if (buf != NULL)
		free(buf);
}