[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.14

1.14    ! jmcneill    1: /*     $NetBSD: consinit.c,v 1.13 2007/01/05 02:39:50 jmcneill 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.14    ! jmcneill   30: __KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.13 2007/01/05 02:39:50 jmcneill Exp $");
1.1       fvdl       31:
                     32: #include "opt_kgdb.h"
                     33:
                     34: #include <sys/param.h>
                     35: #include <sys/systm.h>
                     36: #include <sys/device.h>
                     37: #include <machine/bus.h>
                     38: #include <machine/bootinfo.h>
                     39:
                     40: #include "vga.h"
                     41: #include "ega.h"
                     42: #include "pcdisplay.h"
                     43: #if (NVGA > 0) || (NEGA > 0) || (NPCDISPLAY > 0)
                     44: #include <dev/ic/mc6845reg.h>
                     45: #include <dev/ic/pcdisplayvar.h>
                     46: #if (NVGA > 0)
                     47: #include <dev/ic/vgareg.h>
                     48: #include <dev/ic/vgavar.h>
                     49: #endif
                     50: #if (NEGA > 0)
                     51: #include <dev/isa/egavar.h>
                     52: #endif
                     53: #if (NPCDISPLAY > 0)
                     54: #include <dev/isa/pcdisplayvar.h>
                     55: #endif
                     56: #endif
                     57:
                     58: #include "pckbc.h"
                     59: #if (NPCKBC > 0)
                     60: #include <dev/isa/isareg.h>
                     61: #include <dev/ic/i8042reg.h>
                     62: #include <dev/ic/pckbcvar.h>
1.4       bjh21      63: #include <dev/pckbport/pckbportvar.h>
1.1       fvdl       64: #endif
                     65: #include "pckbd.h" /* for pckbc_machdep_cnattach */
                     66:
1.2       fvdl       67: #ifndef __x86_64__
1.1       fvdl       68: #include "pc.h"
1.2       fvdl       69: #endif
1.1       fvdl       70: #if (NPC > 0)
                     71: #include <machine/pccons.h>
                     72: #endif
                     73:
1.10      jmcneill   74: #ifdef __i386__
                     75: #include "vesafb.h"
                     76: #if (NVESAFB > 0)
                     77: #include <arch/i386/bios/vesafbvar.h>
                     78: #endif
                     79: #endif
                     80:
1.13      jmcneill   81: #ifdef __i386__
                     82: #include "xboxfb.h"
                     83: #if (NXBOXFB > 0)
                     84: #include <machine/xbox.h>
                     85: #endif
                     86: #endif
                     87:
1.1       fvdl       88: #include "com.h"
                     89: #if (NCOM > 0)
                     90: #include <sys/termios.h>
                     91: #include <dev/ic/comreg.h>
                     92: #include <dev/ic/comvar.h>
                     93: #endif
                     94:
                     95: #include "ukbd.h"
                     96: #if (NUKBD > 0)
                     97: #include <dev/usb/ukbdvar.h>
                     98: #endif
                     99:
                    100: #ifndef CONSDEVNAME
                    101: #define CONSDEVNAME "pc"
                    102: #endif
                    103:
                    104: #if (NCOM > 0)
                    105: #ifndef CONADDR
                    106: #define CONADDR 0x3f8
                    107: #endif
                    108: #ifndef CONSPEED
                    109: #define CONSPEED TTYDEF_SPEED
                    110: #endif
                    111: #ifndef CONMODE
                    112: #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
                    113: #endif
                    114: int comcnmode = CONMODE;
                    115: #endif /* NCOM */
                    116:
                    117: const struct btinfo_console default_consinfo = {
                    118:        {0, 0},
                    119:        CONSDEVNAME,
                    120: #if (NCOM > 0)
                    121:        CONADDR, CONSPEED
                    122: #else
                    123:        0, 0
                    124: #endif
                    125: };
                    126:
                    127: #ifdef KGDB
                    128: #ifndef KGDB_DEVNAME
                    129: #define KGDB_DEVNAME "com"
                    130: #endif
                    131: const char kgdb_devname[] = KGDB_DEVNAME;
                    132:
                    133: #if (NCOM > 0)
                    134: #ifndef KGDB_DEVADDR
                    135: #define KGDB_DEVADDR 0x3f8
                    136: #endif
                    137: int comkgdbaddr = KGDB_DEVADDR;
                    138: #ifndef KGDB_DEVRATE
                    139: #define KGDB_DEVRATE TTYDEF_SPEED
                    140: #endif
                    141: int comkgdbrate = KGDB_DEVRATE;
                    142: #ifndef KGDB_DEVMODE
                    143: #define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
                    144: #endif
                    145: int comkgdbmode = KGDB_DEVMODE;
                    146: #endif /* NCOM */
                    147:
                    148: #endif /* KGDB */
                    149:
                    150: /*
                    151:  * consinit:
                    152:  * initialize the system console.
                    153:  * XXX - shouldn't deal with this initted thing, but then,
                    154:  * it shouldn't be called from init386 either.
                    155:  */
                    156: void
                    157: consinit()
                    158: {
                    159:        const struct btinfo_console *consinfo;
                    160:        static int initted;
                    161:
                    162:        if (initted)
                    163:                return;
                    164:        initted = 1;
                    165:
                    166: #ifndef CONS_OVERRIDE
                    167:        consinfo = lookup_bootinfo(BTINFO_CONSOLE);
                    168:        if (!consinfo)
                    169: #endif
                    170:                consinfo = &default_consinfo;
                    171:
1.13      jmcneill  172: #if (NPC > 0) || (NVGA > 0) || (NEGA > 0) || (NPCDISPLAY > 0) || (NVESAFB > 0) || (NXBOXFB > 0)
1.1       fvdl      173:        if (!strcmp(consinfo->devname, "pc")) {
1.6       augustss  174:                int error;
1.10      jmcneill  175: #if (NVESAFB > 0)
                    176:                if (!vesafb_cnattach())
                    177:                        goto dokbd;
                    178: #endif
1.13      jmcneill  179: #if (NXBOXFB > 0)
1.14    ! jmcneill  180:                switch (xboxfb_cnattach()) {
        !           181:                case 0:
1.13      jmcneill  182:                        goto dokbd;
1.14    ! jmcneill  183:                case 1:
        !           184:                        break;
        !           185:                case -1:
        !           186:                        /* defer initialization until later */
        !           187:                        initted = 0;
        !           188:                        return;
        !           189:                }
1.13      jmcneill  190: #endif
1.1       fvdl      191: #if (NVGA > 0)
                    192:                if (!vga_cnattach(X86_BUS_SPACE_IO, X86_BUS_SPACE_MEM,
                    193:                                  -1, 1))
                    194:                        goto dokbd;
                    195: #endif
                    196: #if (NEGA > 0)
                    197:                if (!ega_cnattach(X86_BUS_SPACE_IO, X86_BUS_SPACE_MEM))
                    198:                        goto dokbd;
                    199: #endif
                    200: #if (NPCDISPLAY > 0)
                    201:                if (!pcdisplay_cnattach(X86_BUS_SPACE_IO, X86_BUS_SPACE_MEM))
                    202:                        goto dokbd;
                    203: #endif
                    204: #if (NPC > 0)
                    205:                pccnattach();
                    206: #endif
                    207:                if (0) goto dokbd; /* XXX stupid gcc */
                    208: dokbd:
1.7       augustss  209:                error = ENODEV;
1.1       fvdl      210: #if (NPCKBC > 0)
1.5       augustss  211:                error = pckbc_cnattach(X86_BUS_SPACE_IO, IO_KBD, KBCMDP,
1.1       fvdl      212:                    PCKBC_KBD_SLOT);
                    213: #endif
1.5       augustss  214: #if (NUKBD > 0)
                    215:                if (error)
1.7       augustss  216:                        error = ukbd_cnattach();
1.1       fvdl      217: #endif
1.7       augustss  218:                if (error)
                    219:                        printf("WARNING: no console keyboard, error=%d\n",
                    220:                               error);
1.1       fvdl      221:                return;
                    222:        }
1.13      jmcneill  223: #endif /* PC | VT | VGA | PCDISPLAY | VESAFB | XBOXFB */
1.1       fvdl      224: #if (NCOM > 0)
                    225:        if (!strcmp(consinfo->devname, "com")) {
                    226:                bus_space_tag_t tag = X86_BUS_SPACE_IO;
1.9       jmmv      227:                int addr = consinfo->addr;
                    228:                int speed = consinfo->speed;
1.1       fvdl      229:
1.9       jmmv      230:                if (addr == 0)
                    231:                        addr = CONADDR;
                    232:                if (speed == 0)
                    233:                        speed = CONSPEED;
                    234:
                    235:                if (comcnattach(tag, addr, speed,
1.3       thorpej   236:                                COM_FREQ, COM_TYPE_NORMAL, comcnmode))
1.1       fvdl      237:                        panic("can't init serial console @%x", consinfo->addr);
                    238:
                    239:                return;
                    240:        }
                    241: #endif
                    242:        panic("invalid console device %s", consinfo->devname);
                    243: }
                    244:
                    245: #if (NPCKBC > 0) && (NPCKBD == 0)
                    246: /*
                    247:  * glue code to support old console code with the
                    248:  * mi keyboard controller driver
                    249:  */
                    250: int
1.4       bjh21     251: pckbport_machdep_cnattach(kbctag, kbcslot)
                    252:        pckbport_tag_t kbctag;
                    253:        pckbport_slot_t kbcslot;
1.1       fvdl      254: {
                    255: #if (NPC > 0) && (NPCCONSKBD > 0)
                    256:        return (pcconskbd_cnattach(kbctag, kbcslot));
                    257: #else
                    258:        return (ENXIO);
                    259: #endif
                    260: }
                    261: #endif
                    262:
                    263: #ifdef KGDB
                    264: void
                    265: kgdb_port_init()
                    266: {
                    267: #if (NCOM > 0)
                    268:        if(!strcmp(kgdb_devname, "com")) {
                    269:                bus_space_tag_t tag = X86_BUS_SPACE_IO;
                    270:
                    271:                com_kgdb_attach(tag, comkgdbaddr, comkgdbrate, COM_FREQ,
1.3       thorpej   272:                    COM_TYPE_NORMAL, comkgdbmode);
1.1       fvdl      273:        }
                    274: #endif
                    275: }
                    276: #endif

CVSweb <webmaster@jp.NetBSD.org>