/*ARGSUSED*/
int
sbdp_test_suspend(sbdp_handle_t *hp)
{
	sbdp_sr_handle_t	*srh;
	int			err;

	SBDP_DBG_QR("%s...\n", "sbdp_test_suspend");

	srh = sbdp_get_sr_handle();

	srh->sr_flags = hp->h_flags;

	if ((err = sbdp_suspend(srh)) == DDI_SUCCESS) {
		sbdp_resume(srh);
	} else {
		SBDP_DBG_MISC("sbdp_suspend() failed, err = 0x%x\n", err);
	}
	sbdp_release_sr_handle(srh);

	return (0);
}
Esempio n. 2
0
int
sbdp_get_unit_num(sbdp_handle_t *hp, dev_info_t *dip)
{
	int		unit = -1;
	int		portid;
	processorid_t	cpuid;
	sbd_comp_type_t	type;
	char		dev_type[OBP_MAXPROPNAME];
	int		i;
	pnode_t		nodeid;
	static fn_t	f = "sbdp_get_unit_num";

	SBDP_DBG_FUNC("%s\n", f);

	if (dip == NULL)
		return (-1);

	nodeid = ddi_get_nodeid(dip);

	if (sbdp_is_node_bad(nodeid))
		return (-1);

	if (prom_getprop(nodeid, "device_type", (caddr_t)dev_type) < 0) {
		SBDP_DBG_MISC("%s: couldn't get device_type\n", f);
		return (-1);
	}

	for (i = 0; SBDP_CT(i) != SBD_COMP_UNKNOWN; i++) {
		if (strcmp(dev_type, SBDP_OTYPE(i)) != 0)
			continue;
		type = SBDP_CT(i);
	}

	switch (type) {
	case SBD_COMP_CPU:
		if ((cpuid = sbdp_get_cpuid(hp, dip)) != -1) {
			unit = SG_CPUID_TO_CPU_UNIT(cpuid);
		}
		break;
	case SBD_COMP_MEM:
		unit = 0;
		break;
	case SBD_COMP_IO: {
		regspace_t	regs[3];
		int		len = 0;

		/*
		 * Check to see if this is a cpci node
		 * cpci nodes are assign unit nums of 5 for now
		 * So they don't conflict with the pci unit nums
		 */

		if (strcmp(dev_type, "sghsc") == 0) {
			SBDP_DBG_MISC("it is a sghsc\n");
			return (4);
		}

		if (prom_getprop(nodeid, "portid", (caddr_t)&portid) <= 0) {
			SBDP_DBG_MISC("%s: couldn't get portid\n", f);
			return (-1);
		}

		len = prom_getproplen(nodeid, "reg");
		if (len <= 0) {
			SBDP_DBG_MISC("%s: couldn't get length\n", f);
			return (-1);
		}

		if (prom_getprop(nodeid, "reg", (caddr_t)regs) < 0) {
			SBDP_DBG_MISC("%s: couldn't get registers\n", f);
			return (-1);
		}

		if ((portid % 2) != 0)
			if ((regs[0].regspec_addr_lo & 0x700000) ==
			    0x700000)
				unit = 0;
			else
				unit = 1;
		else
			if ((regs[0].regspec_addr_lo & 0x700000) ==
			    0x700000)
				unit = 2;
			else
				unit = 3;

		SBDP_DBG_MISC("unit is %d\n", unit);
		break;
	}
	default:
		break;

	}

	return (unit);
}