/* * consinit: * initialize the system console. */ void consinit() { struct consdev *cp; static int initted; if (initted) return; initted = 1; cp = NULL; #if (NVGA > 0) /* The font built into the VGA ROM is broken: all the characters * above the 127th do not match the standard set expected by the * console. E.g. boxes drawn using the ACS are incorrect. */ vga_no_builtinfont = 1; #endif if (!comconsole) { #if (NVGA > 0) || (NIGSFB_OFBUS > 0) #if (NIGSFB_OFBUS > 0) if (!igsfb_ofbus_cnattach(&isa_io_bs_tag, &isa_mem_bs_tag)) { #if (NPCKBC > 0) pckbc_cnattach(&isa_io_bs_tag, IO_KBD, KBCMDP, PCKBC_KBD_SLOT); #endif /* NPCKBC */ return; } #endif /* NIGSFB_OFBUS */ #if (NVGA_OFBUS > 0) if (!vga_ofbus_cnattach(&isa_io_bs_tag, &isa_mem_bs_tag)) { #if (NPCKBC > 0) pckbc_cnattach(&isa_io_bs_tag, IO_KBD, KBCMDP, PCKBC_KBD_SLOT); #endif /* NPCKBC */ return; } #endif /* NVGA_OFBUS */ #else /* NVGA */ #if (NOFCONS > 0) cp = &ofcons; ofcons_cnprobe(cp); if (cp->cn_pri == CN_INTERNAL) { ofcons_cninit(cp); cn_tab = cp; return; } #endif /* NOFCONS */ #endif /* NVGA */ } #if (NCOM > 0) if (comcnattach(&isa_io_bs_tag, CONADDR, CONSPEED, COM_FREQ, COM_TYPE_NORMAL, comcnmode)) panic("can't init serial console"); #endif }
/* * console initialization */ void c_isa_cons_init(void) { if (!com_console) { #if NVGA_ISA > 0 if (vga_isa_cnattach(&arc_bus_io, &arc_bus_mem) == 0) { #if NPCKBC > 0 pckbc_cnattach(&arc_bus_io, IO_KBD, KBCMDP, PCKBC_KBD_SLOT, 0); return; #endif } #endif #if NPC_ISA > 0 if (pccons_isa_cnattach(&arc_bus_io, &arc_bus_mem) == 0) return; #endif } #if NCOM > 0 if (com_console_address == 0) com_console_address = IO_COM1; comcnattach(&arc_bus_io, com_console_address, com_console_speed, com_freq, COM_TYPE_NORMAL, com_console_mode); #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) { 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 dec_kn300_cons_init() { struct ctb *ctb; struct mcpcia_config *ccp; extern struct mcpcia_config mcpcia_console_configuration; ccp = &mcpcia_console_configuration; /* It's already initialized. */ ctb = (struct ctb *)(((char *)hwrpb) + hwrpb->rpb_ctb_off); switch (ctb->ctb_term_type) { case CTB_PRINTERPORT: /* serial console ... */ /* * Delay to allow PROM putchars to complete. * FIFO depth * character time, * character time = (1000000 / (defaultrate / 10)) */ DELAY(160000000 / comcnrate); if (comcnattach(&ccp->cc_iot, 0x3f8, comcnrate, COM_FREQ, COM_TYPE_NORMAL, (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8)) { panic("can't init serial console"); } break; case CTB_GRAPHICS: #if NPCKBD > 0 /* display console ... */ /* XXX */ (void) pckbc_cnattach(&ccp->cc_iot, IO_KBD, KBCMDP, PCKBC_KBD_SLOT); if (CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot) == CTB_TURBOSLOT_TYPE_ISA) isa_display_console(&ccp->cc_iot, &ccp->cc_memt); else pci_display_console(&ccp->cc_iot, &ccp->cc_memt, &ccp->cc_pc, CTB_TURBOSLOT_BUS(ctb->ctb_turboslot), CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot), 0); #else panic("not configured to use display && keyboard console"); #endif break; default: printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type); printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot); panic("consinit: unknown console type %ld", ctb->ctb_term_type); } #ifdef KGDB /* Attach the KGDB device. */ alpha_kgdb_init(kgdb_devlist, &ccp->cc_iot); #endif /* KGDB */ }
void wscninit(struct consdev *cp) { static int initted; if (initted) return; initted = 1; #if NSMFB > 0 { extern int smfb_cnattach(void); if (smfb_cnattach() != 0) return; } #endif #if NPCKBC > 0 { extern struct mips_bus_space bonito_pci_io_space_tag; if (!pckbc_cnattach(&bonito_pci_io_space_tag, IO_KBD, KBCMDP, PCKBC_KBD_SLOT, 0 /* PCKBC_CANT_TRANSLATE */)) return; } #endif }
static void dec_2100_a50_cons_init() { struct ctb *ctb; struct apecs_config *acp; extern struct apecs_config apecs_configuration; acp = &apecs_configuration; apecs_init(acp, 0); ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off); switch (ctb->ctb_term_type) { case CTB_PRINTERPORT: /* serial console ... */ /* XXX */ { /* * Delay to allow PROM putchars to complete. * FIFO depth * character time, * character time = (1000000 / (defaultrate / 10)) */ DELAY(160000000 / comcnrate); if(comcnattach(&acp->ac_iot, 0x3f8, comcnrate, COM_FREQ, (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8)) panic("can't init serial console"); break; } case CTB_GRAPHICS: #if NPCKBD > 0 /* display console ... */ /* XXX */ (void) pckbc_cnattach(&acp->ac_iot, IO_KBD, KBCMDP, PCKBC_KBD_SLOT); if (CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot) == CTB_TURBOSLOT_TYPE_ISA) isa_display_console(&acp->ac_iot, &acp->ac_memt); else pci_display_console(&acp->ac_iot, &acp->ac_memt, &acp->ac_pc, CTB_TURBOSLOT_BUS(ctb->ctb_turboslot), CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot), 0); #else panic("not configured to use display && keyboard console"); #endif break; default: printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type); printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot); panic("consinit: unknown console type %ld", ctb->ctb_term_type); } }
/* * consinit: * initialize the system console. * XXX - shouldn't deal with this initted thing, but then, * it shouldn't be called from init_x86_64 either. */ void consinit() { const struct btinfo_console *consinfo; static int initted; if (initted) return; initted = 1; #ifndef CONS_OVERRIDE consinfo = lookup_bootinfo(BTINFO_CONSOLE); if (!consinfo) #endif consinfo = &default_consinfo; #if (NPC > 0) || (NVGA > 0) || (NEGA > 0) || (NPCDISPLAY > 0) if (!strcmp(consinfo->devname, "pc")) { #if (NVGA > 0) if (!vga_cnattach(X86_64_BUS_SPACE_IO, X86_64_BUS_SPACE_MEM, -1, 1)) goto dokbd; #endif #if (NEGA > 0) if (!ega_cnattach(X86_64_BUS_SPACE_IO, X86_64_BUS_SPACE_MEM)) goto dokbd; #endif #if (NPCDISPLAY > 0) if (!pcdisplay_cnattach(X86_64_BUS_SPACE_IO, X86_64_BUS_SPACE_MEM)) goto dokbd; #endif #if (NPC > 0) pccnattach(); #endif if (0) goto dokbd; /* XXX stupid gcc */ dokbd: #if (NPCKBC > 0) pckbc_cnattach(X86_64_BUS_SPACE_IO, IO_KBD, KBCMDP, PCKBC_KBD_SLOT); #endif return; } #endif /* PC | VT | VGA | PCDISPLAY */ #if (NCOM > 0) if (!strcmp(consinfo->devname, "com")) { bus_space_tag_t tag = X86_64_BUS_SPACE_IO; if (comcnattach(tag, consinfo->addr, consinfo->speed, COM_FREQ, comcnmode)) panic("can't init serial console @%x", consinfo->addr); return; } #endif panic("invalid console device %s", consinfo->devname); }
void consinit() { const char *consdev; /* Ask ARCS what it is using for console output. */ consdev = ARCBIOS->GetEnvironmentVariable("ConsoleOut"); if (consdev == NULL) { printf("WARNING: ConsoleOut environment variable not set\n"); return; } switch (mach_type) { case MACH_SGI_IP12: case MACH_SGI_IP20: case MACH_SGI_IP22: if (gio_video_init(consdev) || zs_serial_init(consdev)) return; break; case MACH_SGI_IP32: if (mace_serial_init(consdev)) return; #if (NCRMFB > 0) if (crmfb_probe()) { #if notyet #if (NPCKBC > 0) /* XXX Hardcoded iotag, MACE address XXX */ pckbc_cnattach(SGIMIPS_BUS_SPACE_NORMAL, MACE_BASE + 0x320000, 8, PCKBC_KBD_SLOT); #endif #endif return; } #else panic("this ip32 kernel does not contain framebuffer support."); #endif break; default: panic("consinit(): unknown machine type IP%d\n", mach_type); break; } printf("Using ARCS for console I/O.\n"); }
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 int gio_video_init(const char *consdev) { #if (NGIO > 0) if (strcmp(consdev, "video()") == 0) { /* * XXX Assumes that if output is video() * input must be keyboard(). */ if (gio_cnattach() != 0) return (0); switch(mach_type) { case MACH_SGI_IP12: case MACH_SGI_IP20: #if (NZSKBD > 0) /* XXX Hardcoded unit, channel */ zskbd_cnattach(0, 0); #endif break; case MACH_SGI_IP22: #if (NPCKBC > 0) /* XXX Hardcoded iotag, HPC address XXX */ pckbc_cnattach(SGIMIPS_BUS_SPACE_HPC, HPC_BASE_ADDRESS_0 + HPC3_PBUS_CH6_DEVREGS + IOC_KB_REGS, KBCMDP, PCKBC_KBD_SLOT); #endif break; } return (1); } #endif return (0); }
static void dec_2100_a500_cons_init(void) { struct ctb *ctb; uint64_t ctbslot; struct ttwoga_config *tcp; ctb = (struct ctb *)(((char *)hwrpb) + hwrpb->rpb_ctb_off); ctbslot = ctb->ctb_turboslot; tcp = ttwoga_init(0, 0); switch (ctb->ctb_term_type) { case CTB_PRINTERPORT: /* serial console ... */ assert(CTB_TURBOSLOT_HOSE(ctbslot) == 0); /* XXX */ { /* * Delay to allow PROM putchars to complete. * FIFO depth * character time, * character time = (1000000 / (defaultrate / 10)) */ DELAY(160000000 / comcnrate); if(comcnattach(&tcp->tc_iot, 0x3f8, comcnrate, COM_FREQ, COM_TYPE_NORMAL, (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8)) panic("can't init serial console"); break; } case CTB_GRAPHICS: #if NPCKBD > 0 /* display console ... */ /* XXX */ (void) pckbc_cnattach(&tcp->tc_iot, IO_KBD, KBCMDP, PCKBC_KBD_SLOT, 0); switch (CTB_TURBOSLOT_TYPE(ctbslot)) { case CTB_TURBOSLOT_TYPE_ISA: /* * XXX The following is apparently necessary for an * XXX ISA VGA card, but what happens with real EISA * XXX VGA cards? */ case CTB_TURBOSLOT_TYPE_EISA: isa_display_console(&tcp->tc_iot, &tcp->tc_memt); break; case CTB_TURBOSLOT_TYPE_PCI: /* The display PCI might be different */ tcp = ttwoga_init(0, CTB_TURBOSLOT_HOSE(ctbslot)); pci_display_console(&tcp->tc_iot, &tcp->tc_memt, &tcp->tc_pc, CTB_TURBOSLOT_BUS(ctbslot), CTB_TURBOSLOT_SLOT(ctbslot), 0); break; default: printf("type = 0x%lx, hose = 0x%lx, bus = 0x%lx, " "slot = 0x%lx\n", CTB_TURBOSLOT_TYPE(ctbslot), CTB_TURBOSLOT_HOSE(ctbslot), CTB_TURBOSLOT_BUS(ctbslot), CTB_TURBOSLOT_SLOT(ctbslot)); panic("unknown display console type"); } #else panic("not configured to use display && keyboard console"); #endif break; default: printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type); printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot); panic("consinit: unknown console type %ld", ctb->ctb_term_type); } #ifdef KGDB /* Attach the KGDB device. */ alpha_kgdb_init(kgdb_devlist, &tcp->tc_iot); #endif /* KGDB */ }
void consinit(void) { static int consinit_called = 0; const char *console = CONSDEVNAME; if (consinit_called != 0) return; consinit_called = 1; #ifdef DIAGNOSTIC printf("consinit(\"%s\")\n", console); #endif #if NISA > 0 /* Initialise the ISA subsystem early ... */ isa_footbridge_init(DC21285_PCI_IO_VBASE, DC21285_PCI_ISA_MEM_VBASE); #endif if (strncmp(console, "igsfb", 5) == 0) { #if NIGSFB > 0 int res; footbridge_pci_bs_tag_init(); /* * XXX: uwe: special case mapping for the igsfb memory space. * * The problem with this is that when footbridge is * attached during normal autoconfiguration the bus * space tags will be reinited and these hooks lost. * However, since igsfb(4) don't unmap memory during * normal operation, this is ok. But if the igsfb is * configured but is not a console, we waste 16M of * kernel VA space. */ footbridge_pci_mem_bs_tag.bs_map = nw_footbridge_mem_bs_map; footbridge_pci_mem_bs_tag.bs_unmap = nw_footbridge_mem_bs_unmap; igsfb_pci_cnattach(&footbridge_pci_io_bs_tag, &footbridge_pci_mem_bs_tag, &footbridge_pci_chipset, 0, 8, 0); #if NPCKBC > 0 res = pckbc_cnattach(&isa_io_bs_tag, IO_KBD, KBCMDP, PCKBC_KBD_SLOT, 0); if (res) printf("pckbc_cnattach: %d!\n", res); #endif #else panic("igsfb console not configured"); #endif /* NIGSFB */ } else { #ifdef DIAGNOSTIC if (strncmp(console, "com", 3) != 0) { printf("consinit: unknown CONSDEVNAME=\"%s\"," " falling back to \"com\"\n", console); } #endif #if NCOM > 0 if (comcnattach(&isa_io_bs_tag, CONCOMADDR, comcnspeed, COM_FREQ, COM_TYPE_NORMAL, comcnmode)) panic("can't init serial console @%x", CONCOMADDR); #else panic("serial console @%x not configured", CONCOMADDR); #endif } }
static void dec_eb164_cons_init() { struct ctb *ctb; struct cia_config *ccp; extern struct cia_config cia_configuration; ccp = &cia_configuration; cia_init(ccp, 0); ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off); switch (ctb->ctb_term_type) { case CTB_PRINTERPORT: /* serial console ... */ /* XXX */ { /* * Delay to allow PROM putchars to complete. * FIFO depth * character time, * character time = (1000000 / (defaultrate / 10)) */ DELAY(160000000 / comcnrate); if(comcnattach(&ccp->cc_iot, 0x3f8, comcnrate, COM_FREQ, (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8)) panic("can't init serial console"); break; } case CTB_GRAPHICS: #if NPCKBD > 0 /* display console ... */ /* XXX */ (void) pckbc_cnattach(&ccp->cc_iot, IO_KBD, KBCMDP, 0); /* * On at least LX164, SRM reports an isa video board * as a pci slot with 0xff as the bus and slot numbers. * Since these values are not plausible from a pci point * of view, it is safe to check for them. */ if (CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot) == CTB_TURBOSLOT_TYPE_ISA || (CTB_TURBOSLOT_BUS(ctb->ctb_turboslot) == 0xff && CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot) == 0xff)) isa_display_console(&ccp->cc_iot, &ccp->cc_memt); else pci_display_console(&ccp->cc_iot, &ccp->cc_memt, &ccp->cc_pc, CTB_TURBOSLOT_BUS(ctb->ctb_turboslot), CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot), 0); #else panic("not configured to use display && keyboard console"); #endif break; default: printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type); printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot); panic("consinit: unknown console type %ld", ctb->ctb_term_type); } }
static void dec_6600_cons_init() { struct ctb *ctb; u_int64_t ctbslot; struct tsp_config *tsp; ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off); ctbslot = ctb->ctb_turboslot; /* Console hose defaults to hose 0. */ tsp_console_hose = 0; tsp = tsp_init(0, tsp_console_hose); switch (ctb->ctb_term_type) { case CTB_PRINTERPORT: /* serial console ... */ /* XXX */ { /* * Delay to allow PROM putchars to complete. * FIFO depth * character time, * character time = (1000000 / (defaultrate / 10)) */ DELAY(160000000 / comcnrate); if(comcnattach(&tsp->pc_iot, 0x3f8, comcnrate, COM_FREQ, (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8)) panic("can't init serial console"); break; } case CTB_GRAPHICS: #if NPCKBD > 0 /* display console ... */ /* XXX */ (void) pckbc_cnattach(&tsp->pc_iot, IO_KBD, KBCMDP, 0); if (CTB_TURBOSLOT_TYPE(ctbslot) == CTB_TURBOSLOT_TYPE_ISA) isa_display_console(&tsp->pc_iot, &tsp->pc_memt); else { /* The display PCI might be different */ tsp_console_hose = CTB_TURBOSLOT_HOSE(ctbslot); tsp = tsp_init(0, tsp_console_hose); pci_display_console(&tsp->pc_iot, &tsp->pc_memt, &tsp->pc_pc, CTB_TURBOSLOT_BUS(ctbslot), CTB_TURBOSLOT_SLOT(ctbslot), 0); } #else panic("not configured to use display && keyboard console"); #endif break; default: printf("ctb_term_type = 0x%lx ctb_turboslot = 0x%lx" " hose = %ld\n", (unsigned long)ctb->ctb_term_type, (unsigned long)ctbslot, (unsigned long)CTB_TURBOSLOT_HOSE(ctbslot)); panic("consinit: unknown console type %lu", (unsigned long)ctb->ctb_term_type); } }
void dec_1000a_cons_init() { struct ctb *ctb; struct cia_config *ccp; struct apecs_config *acp; extern struct cia_config cia_configuration; extern struct apecs_config apecs_configuration; bus_space_tag_t iot, memt; struct alpha_pci_chipset *pcichipset; if(strcmp(platform.iobus, "cia") == 0) { ccp = &cia_configuration; cia_init(ccp, 0); iot = &ccp->cc_iot; memt = &ccp->cc_memt; pcichipset = &ccp->cc_pc; } else { acp = &apecs_configuration; apecs_init(acp, 0); iot = &acp->ac_iot; memt = &acp->ac_memt; pcichipset = &acp->ac_pc; } ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off); switch (ctb->ctb_term_type) { case CTB_PRINTERPORT: /* serial console ... */ /* XXX */ { /* * Delay to allow PROM putchars to complete. * FIFO depth * character time, * character time = (1000000 / (defaultrate / 10)) */ DELAY(160000000 / comcnrate); if(comcnattach(iot, 0x3f8, comcnrate, COM_FREQ, (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8)) panic("can't init serial console"); break; } case CTB_GRAPHICS: #if NPCKBD > 0 /* display console ... */ /* XXX */ (void) pckbc_cnattach(iot, IO_KBD, KBCMDP, PCKBC_KBD_SLOT); /* * AlphaServer 1000s have a firmware bug whereby the * built-in ISA VGA is reported incorrectly -- ctb_turboslot * is mostly 0. */ switch (CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot)) { case CTB_TURBOSLOT_TYPE_PCI: pci_display_console(iot, memt, pcichipset, CTB_TURBOSLOT_BUS(ctb->ctb_turboslot), CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot), 0); break; default: isa_display_console(iot, memt); break; } #else panic("not configured to use display && keyboard console"); #endif break; default: printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type); printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot); panic("consinit: unknown console type %ld", ctb->ctb_term_type); } #ifdef KGDB /* Attach the KGDB device. */ alpha_kgdb_init(kgdb_devlist, iot); #endif /* KGDB */ }
static void pckbc_js_attach_common(struct pckbc_js_softc *jsc, bus_space_tag_t iot, bus_addr_t ioaddr, int intr, int isconsole) { struct pckbc_softc *sc = (struct pckbc_softc *)jsc; struct pckbc_internal *t; jsc->jsc_pckbc.intr_establish = pckbc_js_intr_establish; jsc->jsc_intr = intr; jsc->jsc_establised = 0; if (isconsole) { int status; status = pckbc_cnattach(iot, ioaddr, KBCMDP, PCKBC_KBD_SLOT, 0); if (status == 0) aprint_normal(": cnattach ok"); else aprint_error(": cnattach %d", status); } if (pckbc_is_console(iot, ioaddr)) { t = &pckbc_consdata; pckbc_console_attached = 1; } else { bus_space_handle_t ioh_d, ioh_c; if (bus_space_map(iot, ioaddr + KBDATAP, 1, 0, &ioh_d) != 0) { aprint_error(": unable to map data register\n"); return; } if (bus_space_map(iot, ioaddr + KBCMDP, 1, 0, &ioh_c) != 0) { bus_space_unmap(iot, ioh_d, 1); aprint_error(": unable to map cmd register\n"); return; } t = malloc(sizeof(struct pckbc_internal), M_DEVBUF, M_WAITOK); memset(t, 0, sizeof(struct pckbc_internal)); t->t_iot = iot; t->t_ioh_d = ioh_d; t->t_ioh_c = ioh_c; t->t_addr = ioaddr; t->t_cmdbyte = KC8_CPU; /* initial command: enable ports */ callout_init(&t->t_cleanup, 0); (void) pckbc_poll_data1(t, PCKBC_KBD_SLOT); /* flush */ if (pckbc_send_cmd(iot, ioh_c, KBC_SELFTEST) == 0) aprint_error(": unable to request self test"); else { int response; response = pckbc_poll_data1(t, PCKBC_KBD_SLOT); if (response == 0x55) aprint_normal(": selftest ok"); else aprint_error(": selftest failed (0x%02x)", response); } } /* crosslink */ t->t_sc = sc; sc->id = t; /* finish off the attach */ aprint_normal("\n"); pckbc_attach(sc); }
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); }
/* * consinit * Initialize system console. */ void consinit(void) { struct btinfo_console *consinfo; static int initted = 0; #if (NGTEN > 0) struct prep_pci_chipset pc; #endif if (initted) return; initted = 1; consinfo = (struct btinfo_console *)lookup_bootinfo(BTINFO_CONSOLE); if (!consinfo) panic("not found console information in bootinfo"); #if (NPFB > 0) if (!strcmp(consinfo->devname, "fb")) { pfb_cnattach(consinfo->addr); #if (NPCKBC > 0) pckbc_cnattach(&genppc_isa_io_space_tag, IO_KBD, KBCMDP, PCKBC_KBD_SLOT); #endif return; } #endif #if (NVGA > 0) || (NGTEN > 0) if (!strcmp(consinfo->devname, "vga")) { #if (NGTEN > 0) prep_pci_get_chipset_tag(&pc); #endif #if (NGTEN > 0) if (!gten_cnattach(&pc, &prep_mem_space_tag)) goto dokbd; #endif #if (NVGA > 0) if (!vga_cnattach(&prep_io_space_tag, &prep_mem_space_tag, -1, 1)) goto dokbd; #endif dokbd: #if (NPCKBC > 0) pckbc_cnattach(&genppc_isa_io_space_tag, IO_KBD, KBCMDP, PCKBC_KBD_SLOT); #endif return; } #endif /* VGA | GTEN */ #if (NCOM > 0) if (!strcmp(consinfo->devname, "com")) { bus_space_tag_t tag = &genppc_isa_io_space_tag; if(comcnattach(tag, consinfo->addr, consinfo->speed, COM_FREQ, COM_TYPE_NORMAL, ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8))) panic("can't init serial console"); return; } #endif panic("invalid console device %s", consinfo->devname); }