Ejemplo n.º 1
0
/*
 * This function replaces sys/dev/cninit.c
 * Determine which device is the console using
 * the PROM "input source" and "output sink".
 */
void
consinit(void)
{
	char buffer[128];
	const char *consname = "unknown";

	DBPRINT(("consinit()\r\n"));

	if (cn_tab != &consdev_prom)
		return;

	if ((prom_stdin_node = prom_instance_to_package(prom_stdin())) == 0) {
		printf("WARNING: no PROM stdin\n");
	}
	DBPRINT(("stdin node = %x\r\n", prom_stdin_node));

	if ((prom_stdout_node = prom_instance_to_package(prom_stdout())) == 0)
		printf("WARNING: no PROM stdout\n");
	DBPRINT(("stdout package = %x\r\n", prom_stdout_node));

	DBPRINT(("buffer @ %p\r\n", buffer));

	if (prom_stdin_node != 0 &&
	    (prom_getproplen(prom_stdin_node, "keyboard") >= 0)) {
#if NUKBD > 0
		if ((OF_instance_to_path(prom_stdin(), buffer, sizeof(buffer)) >= 0) &&
		    (strstr(buffer, "/usb@") != NULL)) {
			/*
		 	* If we have a USB keyboard, it will show up as (e.g.)
		 	*   /pci@1f,0/usb@c,3/keyboard@1	(Blade 100)
		 	*/
			consname = "usb-keyboard/display";
			ukbd_cnattach();
		} else
#endif
			consname = "sun-keyboard/display";
	} else if (prom_stdin_node != 0 &&
		   (OF_instance_to_path(prom_stdin(), buffer, sizeof(buffer)) >= 0)) {
		consname = buffer;
	}
	DBPRINT(("console is %s\n", consname));
#ifndef DEBUG
	(void)consname;
#endif

	/* Initialize PROM console */
	(*cn_tab->cn_probe)(cn_tab);
	(*cn_tab->cn_init)(cn_tab);
}
Ejemplo n.º 2
0
static void
pckbc_ebus_attach(device_t parent, device_t self, void *aux)
{
	struct pckbc_js_softc *jsc = device_private(self);
	struct ebus_attach_args *ea = aux;
	bus_space_tag_t iot;
	bus_addr_t ioaddr;
	int intr;
	int stdin_node,	node;
	int isconsole;

	jsc->jsc_pckbc.sc_dv = self;
	iot = ea->ea_bustag;
	ioaddr = EBUS_ADDR_FROM_REG(&ea->ea_reg[0]);
	intr = ea->ea_nintr ? ea->ea_intr[0] : /* line */ 0;

	/* search children of "8042" node for stdin (keyboard) */
	stdin_node = prom_instance_to_package(prom_stdin());
	isconsole = 0;

	for (node = prom_firstchild(ea->ea_node);
	     node != 0; node = prom_nextsibling(node))
		if (node == stdin_node) {
			isconsole = 1;
			break;
		}

	pckbc_js_attach_common(jsc, iot, ioaddr, intr, isconsole);
}
Ejemplo n.º 3
0
int
netif_open(void *machdep_hint)
{
    struct of_dev *op = machdep_hint;
    struct iodesc *io;
    int fd, error;
    char addr[32];

#ifdef	NETIF_DEBUG
    printf("netif_open...");
#endif
    /* find a free socket */
    io = sockets;
    if (io->io_netif) {
#ifdef	NETIF_DEBUG
        printf("device busy\n");
#endif
        errno = ENFILE;
        return -1;
    }
    bzero(io, sizeof *io);

    netif_of.nif_devdata = op;
    io->io_netif = &netif_of;

    /* Put our ethernet address in io->myea */
    _prom_getprop(prom_instance_to_package(op->handle),
                  "mac-address", io->myea, sizeof io->myea);

#ifdef	NETIF_DEBUG
    printf("OK\n");
#endif
    return 0;
}
Ejemplo n.º 4
0
static void
igsfb_pci_attach(device_t parent, device_t self, void *aux)
{
	struct igsfb_softc *sc = device_private(self);
	struct pci_attach_args *pa = aux;
	int isconsole;

	sc->sc_dev = self;

	pci_aprint_devinfo(pa, NULL);

#if defined(__sparc__) && !defined(KRUPS_FORCE_SERIAL_CONSOLE)
	/* XXX: this doesn't belong here */
	if (PCITAG_NODE(pa->pa_tag) == prom_instance_to_package(prom_stdout()))
	{
		int b, d, f;

		pci_decompose_tag(pa->pa_pc, pa->pa_tag, &b, &d, &f);
		igsfb_pci_cnattach(pa->pa_iot, pa->pa_memt, pa->pa_pc, b,d,f);
	}
#endif

	isconsole = 0;
	if (igsfb_pci_is_console(pa->pa_pc, pa->pa_tag)) {
		sc->sc_dc = &igsfb_console_dc;
		isconsole = 1;
	} else {
		sc->sc_dc = malloc(sizeof(struct igsfb_devconfig),
				   M_DEVBUF, M_NOWAIT | M_ZERO);
		if (sc->sc_dc == NULL)
			panic("unable to allocate igsfb_devconfig");
		if (igsfb_pci_map_regs(sc->sc_dc,
			    pa->pa_iot, pa->pa_memt, pa->pa_pc,
			    pa->pa_tag, PCI_PRODUCT(pa->pa_id)) != 0)
		{
			printf("unable to map device registers\n");
			free(sc->sc_dc, M_DEVBUF);
			sc->sc_dc = NULL;
			return;
		}

		igsfb_enable(sc->sc_dc->dc_iot, sc->sc_dc->dc_iobase,
			     sc->sc_dc->dc_ioflags);
	}

	igsfb_attach_subr(sc, isconsole);
}
Ejemplo n.º 5
0
static void
com_ebus_attach(device_t parent, device_t self, void *aux)
{
	struct com_ebus_softc *ebsc = device_private(self);
	struct com_softc *sc = &ebsc->ebsc_com;
	struct ebus_attach_args *ea = aux;
	bus_space_tag_t iot;
	bus_space_handle_t ioh;
	bus_addr_t iobase;

	sc->sc_dev = self;
	iot = ea->ea_bustag;
	iobase = EBUS_ADDR_FROM_REG(&ea->ea_reg[0]);
	sc->sc_frequency = COM_FREQ;
	sc->sc_hwflags = COM_HW_NO_TXPRELOAD;

	/*
	 * XXX: It would be nice to be able to split console input and
	 * output to different devices.  For now switch to serial
	 * console if PROM stdin is on serial (so that we can use DDB).
	 */
	if (prom_instance_to_package(prom_stdin()) == ea->ea_node)
		comcnattach(iot, iobase, B9600, sc->sc_frequency,
		    COM_TYPE_NORMAL, (CLOCAL | CREAD | CS8));

	if (!com_is_console(iot, iobase, &ioh)
	    && bus_space_map(iot, iobase, ea->ea_reg[0].size,
			     0, &ioh) != 0)
	{
		aprint_error(": unable to map device registers\n");
		return;
	}

	COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase);

	com_attach_subr(sc);

	if (ea->ea_nintr != 0)
		(void)bus_intr_establish(iot, ea->ea_intr[0], IPL_SERIAL,
					 comintr, sc);
}
Ejemplo n.º 6
0
void
consinit(void)
{
#if 0
	int inSource, outSink;
#endif

	switch (prom_version()) {
#if 0
	case PROM_OLDMON:
	case PROM_OBP_V0:
		/* The stdio handles identify the device type */
		inSource = prom_stdin();
		outSink  = prom_stdout();
		break;
	// XXXMRG  should these just set prom_stdin_node / prom_stdout_node?
#endif

	case PROM_OBP_V2:
	case PROM_OBP_V3:
	case PROM_OPENFIRM:

		/* Save PROM arguments for device matching */
		prom_get_device_args("stdin-path", prom_stdin_args,
				     sizeof(prom_stdin_args));
		prom_get_device_args("stdout-path", prom_stdout_args,
				    sizeof(prom_stdout_args));

		/*
		 * Translate the STDIO package instance (`ihandle') -- that
		 * the PROM has already opened for us -- to a device tree
		 * node (i.e. a `phandle').
		 */

		prom_stdin_node = prom_instance_to_package(prom_stdin());
		if (prom_stdin_node == 0)
			printf("consinit: cannot convert stdin ihandle\n");

		prom_stdout_node = prom_instance_to_package(prom_stdout());
		if (prom_stdout_node == 0) {
			printf("consinit: cannot convert stdout ihandle\n");
			break;
		}

		break;

	default:
		break;
	}

	/* Wire up /dev/console */
	cn_tab->cn_dev = makedev(cdevsw_lookup_major(&kd_cdevsw), 0);
	cn_tab->cn_pri = CN_INTERNAL;

	/* Set up initial PROM input channel for /dev/console */
	cons_attach_input(&prom_cons_channel, cn_tab);

#ifdef	KGDB
	zs_kgdb_init();	/* XXX */
#endif
}
Ejemplo n.º 7
0
static void
com_obio_attach(device_t parent, device_t self, void *aux)
{
	struct com_obio_softc *osc = device_private(self);
	struct com_softc *sc = &osc->osc_com;
	union obio_attach_args *uoba = aux;
	struct sbus_attach_args *sa = &uoba->uoba_sbus;
	bus_space_handle_t ioh;
	bus_space_tag_t iot;
	bus_addr_t iobase;

	sc->sc_dev = self;

	if (strcmp("modem", sa->sa_name) == 0) {
		osc->osc_tadpole = 1;
	}

	/*
	 * We're living on an obio that looks like an sbus slot.
	 */
	iot = sa->sa_bustag;
	iobase = sa->sa_offset;
	sc->sc_frequency = COM_FREQ;

	/*
	 * XXX: It would be nice to be able to split console input and
	 * output to different devices.  For now switch to serial
	 * console if PROM stdin is on serial (so that we can use DDB).
	 */
	if (prom_instance_to_package(prom_stdin()) == sa->sa_node)
		comcnattach(iot, iobase, B9600, sc->sc_frequency,
		    COM_TYPE_NORMAL, (CLOCAL | CREAD | CS8));

	if (!com_is_console(iot, iobase, &ioh) &&
	    sbus_bus_map(iot, sa->sa_slot, iobase, sa->sa_size,
			 BUS_SPACE_MAP_LINEAR, &ioh) != 0) {
		aprint_error(": can't map registers\n");
		return;
	}

	COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase);

	if (osc->osc_tadpole) {
		*AUXIO4M_REG |= (AUXIO4M_LED|AUXIO4M_LTE);
		do {
			DELAY(100);
		} while (!com_probe_subr(&sc->sc_regs));
#if 0
		printf("modem: attach: lcr=0x%02x iir=0x%02x\n",
			bus_space_read_1(sc->sc_regs.iot, sc->sc_regs.ioh, 3),
			bus_space_read_1(sc->sc_regs.iot, sc->sc_regs.ioh, 2));
#endif
	}

	com_attach_subr(sc);

	if (sa->sa_nintr != 0) {
		(void)bus_intr_establish(sc->sc_regs.cr_iot, sa->sa_pri,
		    IPL_SERIAL, comintr, sc);
		evcnt_attach_dynamic(&osc->osc_intrcnt, EVCNT_TYPE_INTR, NULL,
		    device_xname(self), "intr");
	}

	if (!pmf_device_register1(self, com_suspend, com_resume, com_cleanup)) {
		aprint_error_dev(self, "could not establish shutdown hook");
	}
}