consinit.c revision 1.3
11.3Slukem/* $NetBSD: consinit.c,v 1.3 2003/07/15 01:37:37 lukem Exp $ */ 21.1Sscw 31.1Sscw/* 41.1Sscw * Copyright (c) 1998 51.1Sscw * Matthias Drochner. All rights reserved. 61.1Sscw * 71.1Sscw * Redistribution and use in source and binary forms, with or without 81.1Sscw * modification, are permitted provided that the following conditions 91.1Sscw * are met: 101.1Sscw * 1. Redistributions of source code must retain the above copyright 111.1Sscw * notice, this list of conditions and the following disclaimer. 121.1Sscw * 2. Redistributions in binary form must reproduce the above copyright 131.1Sscw * notice, this list of conditions and the following disclaimer in the 141.1Sscw * documentation and/or other materials provided with the distribution. 151.1Sscw * 161.1Sscw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 171.1Sscw * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 181.1Sscw * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 191.1Sscw * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 201.1Sscw * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 211.1Sscw * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 221.1Sscw * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 231.1Sscw * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 241.1Sscw * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 251.1Sscw * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 261.1Sscw * 271.1Sscw */ 281.3Slukem 291.3Slukem#include <sys/cdefs.h> 301.3Slukem__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.3 2003/07/15 01:37:37 lukem Exp $"); 311.1Sscw 321.1Sscw#include "opt_kgdb.h" 331.1Sscw 341.1Sscw#include <sys/param.h> 351.1Sscw#include <sys/systm.h> 361.1Sscw#include <sys/device.h> 371.1Sscw#include <machine/bus.h> 381.1Sscw 391.1Sscw#include <powerpc/ibm4xx/ibm405gp.h> 401.1Sscw 411.1Sscw#include "com.h" 421.1Sscw#if (NCOM > 0) 431.1Sscw#include <sys/termios.h> 441.1Sscw#include <dev/ic/comreg.h> 451.1Sscw#include <dev/ic/comvar.h> 461.1Sscw#endif 471.1Sscw 481.1Sscw#include <dev/cons.h> 491.1Sscw 501.1Sscw#ifndef CONSDEVNAME 511.1Sscw#define CONSDEVNAME "com" 521.1Sscw#endif 531.1Sscw 541.1Sscw#if (NCOM > 0) 551.1Sscw#ifndef CONADDR 561.1Sscw#define CONADDR IBM405GP_UART0_BASE 571.1Sscw#endif 581.1Sscw#ifndef CONSPEED 591.1Sscw#define CONSPEED B9600 /* */ 601.1Sscw// #define CONSPEED B115200 /* 9600 is too slow for my taste */ 611.1Sscw#endif 621.1Sscw#ifndef CONMODE 631.1Sscw#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ 641.1Sscw#endif 651.1Sscwint comcnmode = CONMODE; 661.1Sscw#endif /* NCOM */ 671.1Sscw 681.1Sscw#ifdef KGDB 691.1Sscw#ifndef KGDB_DEVNAME 701.1Sscw#define KGDB_DEVNAME "com" 711.1Sscw#endif 721.1Sscwchar kgdb_devname[] = KGDB_DEVNAME; 731.1Sscw 741.1Sscw#if (NCOM > 1) 751.1Sscw#ifndef KGDB_DEVADDR 761.1Sscw#define KGDB_DEVADDR UART1_BASE 771.1Sscw#endif 781.1Sscwint comkgdbaddr = KGDB_DEVADDR; 791.1Sscw 801.1Sscw#ifndef KGDB_DEVRATE 811.1Sscw#define KGDB_DEVRATE CONSPEED 821.1Sscw#endif 831.1Sscwint comkgdbrate = KGDB_DEVRATE; 841.1Sscw 851.1Sscw#ifndef KGDB_DEVMODE 861.1Sscw#define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ 871.1Sscw#endif 881.1Sscwint comkgdbmode = KGDB_DEVMODE; 891.1Sscw 901.1Sscw#endif /* NCOM */ 911.1Sscw 921.1Sscw#endif /* KGDB */ 931.1Sscw 941.1Sscw/* 951.1Sscw * consinit: 961.1Sscw * initialize the system console. 971.1Sscw * XXX - shouldn't deal with this initted thing, but then, 981.1Sscw * it shouldn't be called from initppc either. 991.1Sscw */ 1001.1Sscwvoid 1011.1Sscwconsinit(void) 1021.1Sscw{ 1031.1Sscw static int initted = 0; 1041.1Sscw#if (NCOM > 0) 1051.1Sscw bus_space_tag_t tag; 1061.1Sscw#endif 1071.1Sscw 1081.1Sscw if (initted) 1091.1Sscw return; 1101.1Sscw initted = 1; 1111.1Sscw 1121.1Sscw#if (NCOM > 0) 1131.1Sscw tag = ibm4xx_make_bus_space_tag(0, 0); 1141.1Sscw 1151.1Sscw if (comcnattach(tag, CONADDR, CONSPEED, COM_FREQ*6, 1161.2Sthorpej COM_TYPE_NORMAL, comcnmode)) 1171.1Sscw panic("can't init serial console @%x", CONADDR); 1181.1Sscw else 1191.1Sscw return; 1201.1Sscw#endif 1211.1Sscw panic("console device missing -- serial console not in kernel"); 1221.1Sscw /* Of course, this is moot if there is no console... */ 1231.1Sscw} 1241.1Sscw 1251.1Sscw#ifdef KGDB 1261.1Sscwvoid 1271.1Sscwkgdb_port_init(void) 1281.1Sscw{ 1291.1Sscw#if (NCOM > 0) 1301.1Sscw if(!strcmp(kgdb_devname, "com")) { 1311.1Sscw bus_space_tag_t tag = ibm4xx_make_bus_space_tag(0, 2); 1321.1Sscw com_kgdb_attach(tag, comkgdbaddr, comkgdbrate, COM_FREQ * 6, 1331.2Sthorpej COM_TYPE_NORMAL, comkgdbmode); 1341.1Sscw } 1351.1Sscw#endif 1361.1Sscw} 1371.1Sscw#endif 138