/* * consinit: * initialize the system console. * XXX - shouldn't deal with this initted thing, but then, * it shouldn't be called from init386 either. */ void consinit(void) { static int initted = 0; union xen_cmdline_parseinfo xcp; if (initted) { return; } initted = 1; xen_parse_cmdline(XEN_PARSE_CONSOLE, &xcp); #if (NVGA > 0) if (xendomain_is_privileged()) { #ifdef CONS_OVERRIDE if (strcmp(default_consinfo.devname, "tty0") == 0 || strcmp(default_consinfo.devname, "pc") == 0) { #else if (strcmp(xcp.xcp_console, "tty0") == 0 || /* linux name */ strcmp(xcp.xcp_console, "pc") == 0) { /* NetBSD name */ #endif /* CONS_OVERRIDE */ int error; vga_cnattach(x86_bus_space_io, x86_bus_space_mem, -1, 1); error = ENODEV; #if (NPCKBC > 0) error = pckbc_cnattach(x86_bus_space_io, IO_KBD, KBCMDP, PCKBC_KBD_SLOT, 0); #endif #if (NUKBD > 0) if (error) error = ukbd_cnattach(); #endif if (error) printf("WARNING: no console keyboard, " "error=%d\n", error); return; } } #endif /* NVGA */ #if NXENCONS > 0 xenconscn_attach(); return; #endif /* NXENCONS */ panic("consinit: no console"); } #ifdef KGDB void kgdb_port_init(void) { #if (NCOM > 0) if(!strcmp(kgdb_devname, "com")) { bus_space_tag_t tag = x86_bus_space_io; com_kgdb_attach(tag, comkgdbaddr, comkgdbrate, COM_FREQ, COM_TYPE_NORMAL, comkgdbmode); } #endif }
void consinit(void) { bus_space_tag_t bst = &awin_a4x_bs_tag; #if NCOM > 0 bus_space_handle_t bh; #endif static int consinit_called = 0; if (consinit_called != 0) return; consinit_called = 1; #if NCOM > 0 if (bus_space_map(bst, conaddr, AWIN_UART_SIZE, 0, &bh)) panic("Serial console can not be mapped."); if (comcnattach(bst, conaddr, conspeed, AWIN_UART_FREQ, COM_TYPE_NORMAL, conmode)) panic("Serial console can not be initialized."); bus_space_unmap(bst, bh, AWIN_UART_SIZE); #else #error only COM console is supported #if NUKBD > 0 ukbd_cnattach(); /* allow USB keyboard to become console */ #endif #endif }
/* * This function replaces sys/dev/cninit.c * Determine which device is the console using * the PROM "input source" and "output sink". */ void consinit() { register int chosen; char buffer[128]; extern int stdinnode, fbnode; char *consname = "unknown"; DBPRINT(("consinit()\r\n")); if (cn_tab != &consdev_prom) return; DBPRINT(("setting up stdin\r\n")); chosen = OF_finddevice("/chosen"); OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)); DBPRINT(("stdin instance = %x\r\n", stdin)); if ((stdinnode = OF_instance_to_package(stdin)) == 0) { printf("WARNING: no PROM stdin\n"); } #if NUKBD > 0 else { if (OF_getprop(stdinnode, "compatible", buffer, sizeof(buffer)) != -1 && strncmp("usb", buffer, 3) == 0) ukbd_cnattach(); } #endif DBPRINT(("setting up stdout\r\n")); OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)); DBPRINT(("stdout instance = %x\r\n", stdout)); if ((fbnode = OF_instance_to_package(stdout)) == 0) printf("WARNING: no PROM stdout\n"); DBPRINT(("stdout package = %x\r\n", fbnode)); if (stdinnode && (OF_getproplen(stdinnode,"keyboard") >= 0)) { consname = "keyboard/display"; } else if (fbnode && (OF_instance_to_path(stdin, buffer, sizeof(buffer)) >= 0)) { consname = buffer; } printf("console is %s\n", consname); /* Initialize PROM console */ (*cn_tab->cn_probe)(cn_tab); (*cn_tab->cn_init)(cn_tab); }
/* * 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); }
void wscninit(struct consdev *cp) { static int initted; if (initted) return; initted = 1; if (!vga_cnattach(&sys_config.pci_io[0], &sys_config.pci_mem[0], WSDISPLAY_TYPE_PCIVGA, 1)) { ukbd_cnattach(); } return; }
void wscn_input_init(int pass) { if (pass != 0) { #if NWSKBD > 0 wskbd_cndetach(); #endif } #if (NPCKBC > 0) if (pass == 0 && pckbc_cnattach(X86_BUS_SPACE_IO, IO_KBD, KBCMDP, 0) == 0) return; #endif #if (NUKBD > 0) if (ukbd_cnattach() == 0) return; #endif }
static void cninit_kd(void) { int kstdin, node; char name[16]; #if (NAKBD > 0) || (NADBKBD > 0) int akbd; #endif #if NUKBD > 0 struct usb_kbd_ihandles *ukbds; int ukbd; #endif /* * Attach the console output now (so we can see debugging messages, * if any). */ #if NWSDISPLAY > 0 rascons_cnattach(); #endif /* * We must determine which keyboard type we have. */ if (OF_getprop(chosen, "stdin", &kstdin, sizeof(kstdin)) != sizeof(kstdin)) { printf("WARNING: no `stdin' property in /chosen\n"); return; } node = OF_instance_to_package(kstdin); memset(name, 0, sizeof(name)); OF_getprop(node, "name", name, sizeof(name)); if (strcmp(name, "keyboard") != 0) { printf("WARNING: stdin is not a keyboard: %s\n", name); return; } memset(name, 0, sizeof(name)); OF_getprop(OF_parent(node), "name", name, sizeof(name)); #if NAKBD > 0 if (strcmp(name, "adb") == 0) { printf("console keyboard type: ADB\n"); akbd_cnattach(); goto kbd_found; } #endif #if NADBKBD > 0 if (strcmp(name, "adb") == 0) { printf("console keyboard type: ADB\n"); adbkbd_cnattach(); goto kbd_found; } #endif #if NPCKBC > 0 if (strcmp(name, "isa") == 0) { printf("console keyboard type: PC Keyboard\n"); pckbc_cnattach(&genppc_isa_io_space_tag, IO_KBD, KBCMDP, PCKBC_KBD_SLOT, 0); goto kbd_found; } #endif /* * It is not obviously an ADB/PC keyboard. Could be USB, * or ADB on some firmware versions (e.g.: iBook G4) * This is not enough, we have a few more problems: * * (1) The stupid Macintosh firmware uses a * `psuedo-hid' (no typo) or `pseudo-hid', * which apparently merges all keyboards * input into a single input stream. * Because of this, we can't actually * determine which controller or keyboard * is really the console keyboard! * * (2) Even if we could, the keyboard can be USB, * and this requires a lot of the kernel to * be running in order for it to work. * * (3) If the keyboard is behind isa, we don't have enough * kernel setup to use it yet, so punt to the ofroutines. * * So, what we do is this: * * (1) First check for OpenFirmware implementation * that will not let us distinguish between * USB and ADB. In that situation, try attaching * anything as we can, and hope things get better * at autoconfiguration time. * * (2) Assume the keyboard is USB. * Tell the ukbd driver that it is the console. * At autoconfiguration time, it will attach the * first USB keyboard instance as the console * keyboard. * * (3) Until then, so that we have _something_, we * use the OpenFirmware I/O facilities to read * the keyboard. */ /* * stdin is /pseudo-hid/keyboard. There is no * `adb-kbd-ihandle or `usb-kbd-ihandles methods * available. Try attaching as ADB. * But only if ADB support is actually present. * * XXX This must be called before pmap_bootstrap(). */ if (strcmp(name, "pseudo-hid") == 0) { int adb_node; adb_node = OF_finddevice("/pci/mac-io/via-pmu/adb"); if (adb_node > 0) { printf("ADB support found\n"); #if NAKBD > 0 akbd_cnattach(); #endif #if NADBKBD > 0 adbkbd_cnattach(); #endif } else { /* must be USB */ printf("No ADB support present, assuming USB " "keyboard\n"); #if NUKBD > 0 ukbd_cnattach(); #endif } goto kbd_found; } /* * stdin is /psuedo-hid/keyboard. Test `adb-kbd-ihandle and * `usb-kbd-ihandles to figure out the real keyboard(s). * * XXX This must be called before pmap_bootstrap(). */ #if NUKBD > 0 if (OF_call_method("`usb-kbd-ihandles", stdin, 0, 1, &ukbds) >= 0 && ukbds != NULL && ukbds->ihandle != 0 && OF_instance_to_package(ukbds->ihandle) != -1) { printf("usb-kbd-ihandles matches\n"); printf("console keyboard type: USB\n"); ukbd_cnattach(); goto kbd_found; } /* Try old method name. */ if (OF_call_method("`usb-kbd-ihandle", kstdin, 0, 1, &ukbd) >= 0 && ukbd != 0 && OF_instance_to_package(ukbd) != -1) { printf("usb-kbd-ihandle matches\n"); printf("console keyboard type: USB\n"); kstdin = ukbd; ukbd_cnattach(); goto kbd_found; } #endif #if (NAKBD > 0) || (NADBKBD > 0) if (OF_call_method("`adb-kbd-ihandle", kstdin, 0, 1, &akbd) >= 0 && akbd != 0 && OF_instance_to_package(akbd) != -1) { printf("adb-kbd-ihandle matches\n"); printf("console keyboard type: ADB\n"); kstdin = akbd; #if NAKBD > 0 akbd_cnattach(); #endif #if NADBKBD > 0 adbkbd_cnattach(); #endif goto kbd_found; } #endif #if NUKBD > 0 /* * XXX Old firmware does not have `usb-kbd-ihandles method. Assume * XXX USB keyboard anyway. */ printf("defaulting to USB..."); printf("console keyboard type: USB\n"); ukbd_cnattach(); goto kbd_found; #endif /* * No keyboard is found. Just return. */ printf("no console keyboard\n"); return; kbd_found:; #if NAKBD + NUKBD + NADBKBD + NPCKBC > 0 /* * XXX This is a little gross, but we don't get to call * XXX wskbd_cnattach() twice. */ ofkbd_ihandle = kstdin; #if NWSDISPLAY > 0 wsdisplay_set_cons_kbd(ofkbd_cngetc, NULL, NULL); #endif #endif }
/* * consinit: * initialize the system console. * XXX - shouldn't deal with this initted thing, but then, * it shouldn't be called from init386 either. */ void consinit(void) { const struct btinfo_console *consinfo; #if (NGENFB > 0) const struct btinfo_framebuffer *fbinfo; #endif static int initted; #if (NCOM > 0) int rv; #endif if (initted) return; initted = 1; #ifndef CONS_OVERRIDE consinfo = lookup_bootinfo(BTINFO_CONSOLE); if (!consinfo) #endif consinfo = &default_consinfo; #if (NGENFB > 0) fbinfo = lookup_bootinfo(BTINFO_FRAMEBUFFER); #endif if (!strcmp(consinfo->devname, "pc")) { int error; #if (NGENFB > 0) if (fbinfo && fbinfo->physaddr > 0) { if (x86_genfb_cnattach() == -1) { initted = 0; /* defer */ return; } genfb_cnattach(); goto dokbd; } genfb_disable(); #endif #if (NVGA > 0) if (!vga_cnattach(x86_bus_space_io, x86_bus_space_mem, -1, 1)) goto dokbd; #endif #if (NEGA > 0) if (!ega_cnattach(x86_bus_space_io, x86_bus_space_mem)) goto dokbd; #endif #if (NPCDISPLAY > 0) if (!pcdisplay_cnattach(x86_bus_space_io, x86_bus_space_mem)) goto dokbd; #endif if (0) goto dokbd; /* XXX stupid gcc */ dokbd: error = ENODEV; #if (NPCKBC > 0) error = pckbc_cnattach(x86_bus_space_io, IO_KBD, KBCMDP, PCKBC_KBD_SLOT, 0); #endif #if (NUKBD > 0) if (error) error = ukbd_cnattach(); #endif if (error) printf("WARNING: no console keyboard, error=%d\n", error); return; } #if (NCOM > 0) if (!strcmp(consinfo->devname, "com")) { int addr = consinfo->addr; int speed = consinfo->speed; #if (NCOM_PUC > 0) && defined(PUC_CNAUTO) puc_cnprobe(NULL); rv = puc_cninit(NULL); if (rv == 0) return; #endif if (addr == 0) addr = CONADDR; if (speed == 0) speed = CONSPEED; rv = comcnattach(x86_bus_space_io, addr, speed, COM_FREQ, COM_TYPE_NORMAL, comcnmode); if (rv != 0) panic("can't init serial console @%x", consinfo->addr); return; } #endif panic("invalid console device %s", consinfo->devname); }