/* * 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); }
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); }
static int openfirmware_getchar(void) { unsigned char ch = '\0'; int l; while ((l = OF_read(prom_stdin(), &ch, 1)) != 1) if (l != -2 && l != 0) return -1; return ch; }
int prom_cngetc(dev_t dev) { unsigned char ch = '\0'; int l; #ifdef DDB static int nplus = 0; #endif while ((l = prom_read(prom_stdin(), &ch, 1)) != 1) /* void */; #ifdef DDB if (ch == '+') { if (nplus++ > 3) Debugger(); } else nplus = 0; #endif if (ch == '\r') ch = '\n'; return ch; }
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); }
int pconsprobe(void) { switch (prom_version()) { #ifdef PROM_OLDMON case PROM_OLDMON: case PROM_OBP_V0: return 1; #endif /* PROM_OLDMON */ #ifdef PROM_OBP_V2 case PROM_OBP_V2: case PROM_OBP_V3: case PROM_OPENFIRM: return prom_stdin() && prom_stdout(); #endif /* PROM_OBP_V2 */ default: break; } return 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 }
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"); } }