Beispiel #1
0
/*
 * Finds the device node with device_type "rtc" and opens it to
 * execute the get-time method
 */
static int
todds1307_setup_prom()
{
    pnode_t todnode;
    char tod1307_devpath[MAXNAMELEN];

    if ((todnode = prom_findnode_bydevtype(prom_rootnode(),
                                           DS1307_DEVICE_TYPE)) == OBP_NONODE)
        return (DDI_FAILURE);

    /*
     * We now have the phandle of the rtc node, we need to open the
     * node and get the ihandle
     */
    if (prom_phandle_to_path(todnode, tod1307_devpath,
                             sizeof (tod1307_devpath)) < 0) {
        cmn_err(CE_WARN, "prom_phandle_to_path failed");
        return (DDI_FAILURE);
    }

    /*
     * Now open the node and store it's ihandle
     */
    if ((todds1307_ihandle = prom_open(tod1307_devpath)) == NULL) {
        cmn_err(CE_WARN, "prom_open failed");
        return (DDI_FAILURE);
    }

    return (DDI_SUCCESS);
}
Beispiel #2
0
/*
 * find cpu node for the boot processor
 *
 * sets globals:
 * 	cb_mid
 */
static pnode_t
get_cpu_node(void)
{
	static char *props[] = { "upa-portid", "portid", NULL };
	pnode_t node;
	char *str, *name, **propp;
	uint_t cpu_id;
	int err;

	str = "get_cpu_node";
	name = "cpu";

	cb_mid = getmid();
	for (node = prom_rootnode(); ; node = prom_nextnode(node)) {
		node = prom_findnode_bydevtype(node, name);
		if (node == OBP_NONODE) {
			prom_printf("\n%s: cant find node for devtype \"%s\"\n",
			    str, name);
			break;
		}

		cpu_id = (uint_t)-1;
		for (propp = props; *propp; propp++) {
			err = get_intprop(node, *propp, &cpu_id);
			CB_VPRINTF(("    cpu node 0x%x, "
			    "prop \"%s\", cpu_id %d\n",
			    node, *propp, (int)cpu_id));
			if (err == 0)
				break;
		}

		if (cpu_id == cb_mid)
			return (node);
	}

	return (OBP_NONODE);
}