static int
opattach(dev_info_t *dip, ddi_attach_cmd_t cmd)
{
	switch (cmd) {

	case DDI_ATTACH:
		if (prom_is_openprom()) {
			options_nodeid = prom_optionsnode();
		} else {
			options_nodeid = OBP_BADNODE;
		}

		opdip = dip;

		if (ddi_create_minor_node(dip, "openprom", S_IFCHR,
		    0, DDI_PSEUDO, NULL) == DDI_FAILURE) {
			return (DDI_FAILURE);
		}

		return (DDI_SUCCESS);

	default:
		return (DDI_FAILURE);
	}
}
static int
cpr_get_options_node(pnode_t *nodep)
{
	*nodep = prom_optionsnode();
	if (*nodep == OBP_NONODE || *nodep == OBP_BADNODE) {
		cpr_err(CE_WARN, "cannot get \"options\" node");
		return (ENOENT);
	}

	return (0);
}
Beispiel #3
0
/*
 * Here we use the "screen-#columns" and "screen-#rows" settings of
 * PROM to help us decide the console size and cursor position. The
 * actual sizes of PROM's TEM and the console might be different with
 * those "screen-#.." settings, in cases that they are too big to
 * accommodate.
 */
void
prom_get_tem_size(size_t *height, size_t *width)
{
	char buf[MAXPATHLEN];
	char name[16];
	pnode_t node;
	int len;

	if ((node = prom_optionsnode()) == OBP_BADNODE)
		return;

	(void) prom_strcpy(name, "screen-#rows");
	if ((len = prom_getproplen(node, (caddr_t)name)) > 0) {
		(void) prom_getprop(node, (caddr_t)name, (caddr_t)buf);
		*height = prom_atol(buf, len);
	}

	(void) prom_strcpy(name, "screen-#columns");
	if ((len = prom_getproplen(node, (caddr_t)name)) > 0) {
		(void) prom_getprop(node, (caddr_t)name, (caddr_t)buf);
		*width = prom_atol(buf, len);
	}
}