[BACK]Return to consinit.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / x86 / x86

Annotation of src/sys/arch/x86/x86/consinit.c, Revision 1.30

1.30    ! christos    1: /*     $NetBSD: consinit.c,v 1.29 2019/05/24 14:28:48 nonaka Exp $     */
1.1       fvdl        2:
                      3: /*
                      4:  * Copyright (c) 1998
                      5:  *     Matthias Drochner.  All rights reserved.
                      6:  *
                      7:  * Redistribution and use in source and binary forms, with or without
                      8:  * modification, are permitted provided that the following conditions
                      9:  * are met:
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  * 2. Redistributions in binary form must reproduce the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer in the
                     14:  *    documentation and/or other materials provided with the distribution.
                     15:  *
                     16:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     17:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     18:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     19:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     20:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     21:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     22:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     23:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     24:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     25:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     26:  *
                     27:  */
                     28:
                     29: #include <sys/cdefs.h>
1.30    ! christos   30: __KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.29 2019/05/24 14:28:48 nonaka Exp $");
1.1       fvdl       31:
                     32: #include "opt_kgdb.h"
1.25      msaitoh    33: #include "opt_puc.h"
1.1       fvdl       34:
                     35: #include <sys/param.h>
                     36: #include <sys/systm.h>
                     37: #include <sys/device.h>
1.22      dyoung     38: #include <sys/bus.h>
1.29      nonaka     39: #include <sys/cpu.h>
1.1       fvdl       40: #include <machine/bootinfo.h>
1.17      jmcneill   41: #include <arch/x86/include/genfb_machdep.h>
1.1       fvdl       42:
1.28      is         43: #include <dev/cons.h>
                     44:
                     45: #include "nullcons.h"
1.16      jmcneill   46: #include "genfb.h"
1.1       fvdl       47: #include "vga.h"
                     48: #include "ega.h"
                     49: #include "pcdisplay.h"
1.25      msaitoh    50: #include "com_puc.h"
1.1       fvdl       51: #if (NVGA > 0) || (NEGA > 0) || (NPCDISPLAY > 0)
                     52: #include <dev/ic/mc6845reg.h>
                     53: #include <dev/ic/pcdisplayvar.h>
                     54: #if (NVGA > 0)
                     55: #include <dev/ic/vgareg.h>
                     56: #include <dev/ic/vgavar.h>
                     57: #endif
                     58: #if (NEGA > 0)
                     59: #include <dev/isa/egavar.h>
                     60: #endif
                     61: #if (NPCDISPLAY > 0)
                     62: #include <dev/isa/pcdisplayvar.h>
                     63: #endif
                     64: #endif
                     65:
                     66: #include "pckbc.h"
                     67: #if (NPCKBC > 0)
                     68: #include <dev/isa/isareg.h>
                     69: #include <dev/ic/i8042reg.h>
                     70: #include <dev/ic/pckbcvar.h>
1.4       bjh21      71: #include <dev/pckbport/pckbportvar.h>
1.1       fvdl       72: #endif
                     73: #include "pckbd.h" /* for pckbc_machdep_cnattach */
                     74:
1.16      jmcneill   75: #if (NGENFB > 0)
                     76: #include <dev/wsfb/genfbvar.h>
                     77: #endif
                     78:
1.1       fvdl       79: #include "com.h"
                     80: #if (NCOM > 0)
                     81: #include <sys/termios.h>
                     82: #include <dev/ic/comreg.h>
                     83: #include <dev/ic/comvar.h>
                     84: #endif
1.25      msaitoh    85: #if (NCOM_PUC > 0)
                     86: #include <dev/pci/puccn.h>
                     87: #endif
1.1       fvdl       88:
                     89: #include "ukbd.h"
                     90: #if (NUKBD > 0)
                     91: #include <dev/usb/ukbdvar.h>
                     92: #endif
                     93:
1.29      nonaka     94: #ifndef XEN
1.30    ! christos   95: #if NHVKBD > 0
1.29      nonaka     96: #include "hvkbd.h"
                     97: #include <dev/hyperv/hvkbdvar.h>
                     98: #endif
                     99: #endif
                    100:
1.1       fvdl      101: #ifndef CONSDEVNAME
                    102: #define CONSDEVNAME "pc"
                    103: #endif
                    104:
                    105: #if (NCOM > 0)
                    106: #ifndef CONADDR
                    107: #define CONADDR 0x3f8
                    108: #endif
                    109: #ifndef CONSPEED
                    110: #define CONSPEED TTYDEF_SPEED
                    111: #endif
                    112: #ifndef CONMODE
                    113: #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
                    114: #endif
                    115: int comcnmode = CONMODE;
                    116: #endif /* NCOM */
                    117:
                    118: const struct btinfo_console default_consinfo = {
                    119:        {0, 0},
                    120:        CONSDEVNAME,
                    121: #if (NCOM > 0)
                    122:        CONADDR, CONSPEED
                    123: #else
                    124:        0, 0
                    125: #endif
                    126: };
                    127:
                    128: #ifdef KGDB
                    129: #ifndef KGDB_DEVNAME
                    130: #define KGDB_DEVNAME "com"
                    131: #endif
                    132: const char kgdb_devname[] = KGDB_DEVNAME;
                    133:
                    134: #if (NCOM > 0)
                    135: #ifndef KGDB_DEVADDR
                    136: #define KGDB_DEVADDR 0x3f8
                    137: #endif
                    138: int comkgdbaddr = KGDB_DEVADDR;
                    139: #ifndef KGDB_DEVRATE
                    140: #define KGDB_DEVRATE TTYDEF_SPEED
                    141: #endif
                    142: int comkgdbrate = KGDB_DEVRATE;
                    143: #ifndef KGDB_DEVMODE
                    144: #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
                    145: #endif
                    146: int comkgdbmode = KGDB_DEVMODE;
                    147: #endif /* NCOM */
                    148:
                    149: #endif /* KGDB */
                    150:
                    151: /*
                    152:  * consinit:
                    153:  * initialize the system console.
                    154:  * XXX - shouldn't deal with this initted thing, but then,
                    155:  * it shouldn't be called from init386 either.
                    156:  */
                    157: void
1.19      cegger    158: consinit(void)
1.1       fvdl      159: {
                    160:        const struct btinfo_console *consinfo;
1.27      martin    161: #if (NGENFB > 0)
1.16      jmcneill  162:        const struct btinfo_framebuffer *fbinfo;
1.27      martin    163: #endif
1.1       fvdl      164:        static int initted;
1.26      taca      165: #if (NCOM > 0)
1.25      msaitoh   166:        int rv;
1.26      taca      167: #endif
1.1       fvdl      168:
                    169:        if (initted)
                    170:                return;
                    171:        initted = 1;
                    172:
                    173: #ifndef CONS_OVERRIDE
                    174:        consinfo = lookup_bootinfo(BTINFO_CONSOLE);
                    175:        if (!consinfo)
                    176: #endif
                    177:                consinfo = &default_consinfo;
                    178:
1.27      martin    179: #if (NGENFB > 0)
1.16      jmcneill  180:        fbinfo = lookup_bootinfo(BTINFO_FRAMEBUFFER);
1.27      martin    181: #endif
1.16      jmcneill  182:
1.1       fvdl      183:        if (!strcmp(consinfo->devname, "pc")) {
1.6       augustss  184:                int error;
1.16      jmcneill  185: #if (NGENFB > 0)
                    186:                if (fbinfo && fbinfo->physaddr > 0) {
1.17      jmcneill  187:                        if (x86_genfb_cnattach() == -1) {
                    188:                                initted = 0;    /* defer */
                    189:                                return;
                    190:                        }
1.16      jmcneill  191:                        genfb_cnattach();
                    192:                        goto dokbd;
1.17      jmcneill  193:                }
                    194:                genfb_disable();
1.16      jmcneill  195: #endif
1.1       fvdl      196: #if (NVGA > 0)
1.21      dyoung    197:                if (!vga_cnattach(x86_bus_space_io, x86_bus_space_mem,
1.1       fvdl      198:                                  -1, 1))
                    199:                        goto dokbd;
                    200: #endif
                    201: #if (NEGA > 0)
1.21      dyoung    202:                if (!ega_cnattach(x86_bus_space_io, x86_bus_space_mem))
1.1       fvdl      203:                        goto dokbd;
                    204: #endif
                    205: #if (NPCDISPLAY > 0)
1.21      dyoung    206:                if (!pcdisplay_cnattach(x86_bus_space_io, x86_bus_space_mem))
1.1       fvdl      207:                        goto dokbd;
                    208: #endif
                    209:                if (0) goto dokbd; /* XXX stupid gcc */
                    210: dokbd:
1.7       augustss  211:                error = ENODEV;
1.1       fvdl      212: #if (NPCKBC > 0)
1.21      dyoung    213:                error = pckbc_cnattach(x86_bus_space_io, IO_KBD, KBCMDP,
1.24      jdc       214:                    PCKBC_KBD_SLOT, 0);
1.1       fvdl      215: #endif
1.29      nonaka    216: #if (NHVKBD > 0)
                    217:                if (error && vm_guest == VM_GUEST_HV)
                    218:                        error = hvkbd_cnattach();
                    219: #endif
1.5       augustss  220: #if (NUKBD > 0)
                    221:                if (error)
1.7       augustss  222:                        error = ukbd_cnattach();
1.1       fvdl      223: #endif
1.7       augustss  224:                if (error)
                    225:                        printf("WARNING: no console keyboard, error=%d\n",
                    226:                               error);
1.1       fvdl      227:                return;
                    228:        }
                    229: #if (NCOM > 0)
                    230:        if (!strcmp(consinfo->devname, "com")) {
1.9       jmmv      231:                int addr = consinfo->addr;
                    232:                int speed = consinfo->speed;
1.1       fvdl      233:
1.25      msaitoh   234: #if (NCOM_PUC > 0) && defined(PUC_CNAUTO)
                    235:                puc_cnprobe(NULL);
                    236:                rv = puc_cninit(NULL);
                    237:                if (rv == 0)
                    238:                        return;
                    239: #endif
                    240:
1.9       jmmv      241:                if (addr == 0)
                    242:                        addr = CONADDR;
                    243:                if (speed == 0)
                    244:                        speed = CONSPEED;
                    245:
1.25      msaitoh   246:                rv = comcnattach(x86_bus_space_io, addr, speed,
                    247:                                 COM_FREQ, COM_TYPE_NORMAL, comcnmode);
                    248:                if (rv != 0)
1.1       fvdl      249:                        panic("can't init serial console @%x", consinfo->addr);
                    250:                return;
                    251:        }
                    252: #endif
1.28      is        253: #if (NNULLCONS > 0)
                    254:        if (!strcmp(consinfo->devname, "nullcons")) {
                    255:                void nullcninit(struct consdev *cn);
                    256:
                    257:                nullcninit(0);
                    258:                return;
                    259:        }
                    260: #endif
1.1       fvdl      261:        panic("invalid console device %s", consinfo->devname);
                    262: }
                    263:
                    264: #ifdef KGDB
                    265: void
1.20      cegger    266: kgdb_port_init(void)
1.1       fvdl      267: {
                    268: #if (NCOM > 0)
                    269:        if(!strcmp(kgdb_devname, "com")) {
1.21      dyoung    270:                com_kgdb_attach(x86_bus_space_io, comkgdbaddr, comkgdbrate,
                    271:                    COM_FREQ, COM_TYPE_NORMAL, comkgdbmode);
1.1       fvdl      272:        }
                    273: #endif
                    274: }
                    275: #endif

CVSweb <webmaster@jp.NetBSD.org>