From 9a278532bc1b3e7e0ffeba9a5505736819f85719 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sat, 9 Mar 2013 02:10:48 +0000 Subject: First steps towards alphabook1 support; from netbsd miod did not disagree. --- sys/arch/alpha/alpha/cpuconf.c | 11 +- sys/arch/alpha/alpha/dec_alphabook1.c | 245 ++++++++++++++++++++++++++++++++++ sys/arch/alpha/conf/GENERIC | 8 +- sys/arch/alpha/conf/files.alpha | 22 ++- sys/arch/alpha/pci/pci_alphabook1.c | 195 +++++++++++++++++++++++++++ sys/arch/alpha/pci/pci_alphabook1.h | 30 +++++ 6 files changed, 503 insertions(+), 8 deletions(-) create mode 100644 sys/arch/alpha/alpha/dec_alphabook1.c create mode 100644 sys/arch/alpha/pci/pci_alphabook1.c create mode 100644 sys/arch/alpha/pci/pci_alphabook1.h (limited to 'sys/arch/alpha') diff --git a/sys/arch/alpha/alpha/cpuconf.c b/sys/arch/alpha/alpha/cpuconf.c index 5434c0950f1..7094ff9713c 100644 --- a/sys/arch/alpha/alpha/cpuconf.c +++ b/sys/arch/alpha/alpha/cpuconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpuconf.c,v 1.13 2009/10/02 18:01:47 miod Exp $ */ +/* $OpenBSD: cpuconf.c,v 1.14 2013/03/09 02:10:47 deraadt Exp $ */ /* $NetBSD: cpuconf.c,v 1.27 2000/06/26 02:42:04 enami Exp $ */ /*- @@ -140,6 +140,12 @@ extern void dec_6600_init(void); #define dec_6600_init platform_not_configured #endif +#ifdef DEC_ALPHABOOK1 +extern void dec_alphabook1_init(void); +#else +#define dec_alphabook1_init platform_not_configured +#endif + #ifdef API_UP1000 extern void api_up1000_init(void); #else @@ -163,8 +169,7 @@ static const struct cpuinit cpuinit[] = { cpu_init(ST_DEC_KN20AA, dec_kn20aa_init, "DEC_KN20AA"), cpu_init(ST_DEC_1000, dec_1000_init, "DEC_1000"), cpu_notsupp(ST_EB66, "DEC_EB66"), - cpu_init(ST_EB64P, dec_eb64plus_init, "DEC_EB64PLUS"), - cpu_notsupp(ST_ALPHABOOK1, "DEC_ALPHABOOK1"), + cpu_init(ST_ALPHABOOK1, dec_alphabook1_init, "DEC_ALPHABOOK1"), cpu_init(ST_DEC_4100, dec_kn300_init, "DEC_KN300"), cpu_notsupp(ST_DEC_EV45_PBP, "EV45 Passive Backplane Board"), cpu_notsupp(ST_DEC_2100A_A500, "DEC_2100A_A500"), diff --git a/sys/arch/alpha/alpha/dec_alphabook1.c b/sys/arch/alpha/alpha/dec_alphabook1.c new file mode 100644 index 00000000000..08dc496b098 --- /dev/null +++ b/sys/arch/alpha/alpha/dec_alphabook1.c @@ -0,0 +1,245 @@ +/* $NetBSD: dec_alphabook1.c,v 1.27 2012/10/13 17:58:54 jdc Exp $ */ + +/* + * Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ +/* + * Additional Copyright (c) 1997 by Matthew Jacob for NASA/Ames Research Center + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "pckbd.h" + +#ifndef CONSPEED +#define CONSPEED TTYDEF_SPEED +#endif +static int comcnrate = CONSPEED; + +void dec_alphabook1_init(void); +static void dec_alphabook1_cons_init(void); +static void dec_alphabook1_device_register(struct device *, void *); + +const struct alpha_variation_table dec_alphabook1_variations[] = { + { 0, "AlphaBook" }, + { 0, NULL }, +}; + +void +dec_alphabook1_init(void) +{ + uint64_t variation; + + platform.family = "AlphaBook"; + + if ((platform.model = alpha_dsr_sysname()) == NULL) { + variation = hwrpb->rpb_variation & SV_ST_MASK; + if ((platform.model = alpha_variation_name(variation, + dec_alphabook1_variations)) == NULL) + platform.model = alpha_unknown_sysname(); + } + + platform.iobus = "lca"; + platform.cons_init = dec_alphabook1_cons_init; + platform.device_register = dec_alphabook1_device_register; +} + +static void +dec_alphabook1_cons_init(void) +{ + struct ctb *ctb; + struct lca_config *lcp; + extern struct lca_config lca_configuration; + + lcp = &lca_configuration; + lca_init(lcp, 0); + + ctb = (struct ctb *)(((char *)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(&lcp->lc_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(&lcp->lc_iot, IO_KBD, KBCMDP, 0); + + if (CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot) == + CTB_TURBOSLOT_TYPE_ISA) + isa_display_console(&lcp->lc_iot, &lcp->lc_memt); + else + pci_display_console(&lcp->lc_iot, &lcp->lc_memt, + &lcp->lc_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_alphabook1_device_register(struct device *dev, void *aux) +{ + static int found, initted, diskboot, netboot; + static struct device *pcidev, *ctrlrdev; + struct bootdev_data *b = bootdev_data; + struct device *parent = dev->dv_parent; + struct cfdata *cf = dev->dv_cfdata; + struct cfdriver *cd = cf->cf_driver; + + if (found) + return; + + if (!initted) { + diskboot = (strncasecmp(b->protocol, "SCSI", 4) == 0); + netboot = (strncasecmp(b->protocol, "BOOTP", 5) == 0) || + (strncasecmp(b->protocol, "MOP", 3) == 0); +#if 0 + printf("diskboot = %d, netboot = %d\n", diskboot, netboot); +#endif + initted =1; + } + + if (pcidev == NULL) { + if (strcmp(cd->cd_name, "pci")) + return; + else { + struct pcibus_attach_args *pba = aux; + + if ((b->slot / 1000) != pba->pba_bus) + return; + + pcidev = dev; +#if 0 + printf("\npcidev = %s\n", device_xname(dev)); +#endif + return; + } + } + + if (ctrlrdev == NULL) { + if (parent != pcidev) + return; + else { + struct pci_attach_args *pa = aux; + int slot; + + slot = pa->pa_bus * 1000 + pa->pa_function * 100 + + pa->pa_device; + if (b->slot != slot) + return; + + if (netboot) { + booted_device = dev; +#if 0 + printf("\nbooted_device = %s\n", device_xname(dev)); +#endif + found = 1; + } else { + ctrlrdev = dev; +#if 0 + printf("\nctrlrdev = %s\n", device_xname(dev)); +#endif + } + return; + } + } + + if (!diskboot) + return; + + if (!strcmp(cd->cd_name, "sd") || !strcmp(cd->cd_name, "st") || + !strcmp(cd->cd_name, "cd")) { + struct scsi_attach_args *sa = aux; + struct scsi_link *periph = sa->sa_sc_link; + int unit; + + if (parent->dv_parent != ctrlrdev) + return; + + unit = periph->target * 100 + periph->lun; + if (b->unit != unit) + return; + + /* we've found it! */ + booted_device = dev; +#if 0 + printf("\nbooted_device = %s\n", device_xname(dev)); +#endif + found = 1; + } +} diff --git a/sys/arch/alpha/conf/GENERIC b/sys/arch/alpha/conf/GENERIC index bd372fec491..b9b8dc165cd 100644 --- a/sys/arch/alpha/conf/GENERIC +++ b/sys/arch/alpha/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.228 2012/09/27 14:01:35 jsg Exp $ +# $OpenBSD: GENERIC,v 1.229 2013/03/09 02:10:47 deraadt Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -19,6 +19,7 @@ option DEC_3000_300 # Pelican etc: 3000/300* option DEC_2100_A50 # Avanti etc: AlphaStation 400, 200, etc. option DEC_KN20AA # KN20AA: AlphaStation 600 option DEC_KN300 # KN300: AlphaServer 4100 and 1200 +option DEC_ALPHABOOK1 # AlphaBook1: Tadpole/DEC AlphaBook option DEC_AXPPCI_33 # NoName: AXPpci33, etc. option DEC_EB164 # EB164: AlphaPC 164 option DEC_EB64PLUS # EB64+: AlphaPC 64, etc. @@ -337,6 +338,11 @@ ep* at isapnp? # 3C509 ethernet cards #wss* at isa? port 0x530 irq 9 drq 0 # Windows Sound System lc0 at isa? port 0x200 # DEC EtherWorks lc1 at isa? port 0x280 # DEC EtherWorks +pcic0 at isa? port 0x3e0 iomem 0xd0000 iosiz 0x10000 +pcic1 at isa? port 0x3e2 iomem 0xcc000 iosiz 0x10000 + +pcmcia* at pcic? controller ? socket ? +ep* at pcmcia? function ? # 3Com 3c589 and 3c562 Eth. cy0 at isa? iomem 0xd4000 irq 12 # ISA cyclom card fdc0 at isa? port 0x3f0 irq 6 drq 2 # floppy controller diff --git a/sys/arch/alpha/conf/files.alpha b/sys/arch/alpha/conf/files.alpha index 7c416d1157e..7e14dd39e42 100644 --- a/sys/arch/alpha/conf/files.alpha +++ b/sys/arch/alpha/conf/files.alpha @@ -1,4 +1,4 @@ -# $OpenBSD: files.alpha,v 1.93 2011/11/15 22:27:52 deraadt Exp $ +# $OpenBSD: files.alpha,v 1.94 2013/03/09 02:10:47 deraadt Exp $ # $NetBSD: files.alpha,v 1.32 1996/11/25 04:03:21 cgd Exp $ # # alpha-specific configuration info @@ -126,13 +126,25 @@ file arch/alpha/tc/scc.c scc needs-count include "dev/atapiscsi/files.atapiscsi" include "dev/ata/files.ata" -# XXX Dummy bus needed for some multi-homed devices specified in files.isa -define pcmcia {} - include "dev/pci/files.pci" # XXX some ISA devs are 'at pci' too. include "dev/isa/files.isa" major {wd = 0} +device pcic: pcmciabus +file dev/ic/i82365.c pcic + +# PCIC pcmcia controller on ISA bus. +attach pcic at isa with pcic_isa +file dev/isa/i82365_isa.c pcic_isa + +# Code common to ISA and ISAPnP attachments +file dev/isa/i82365_isasubr.c pcic_isa | pcic_isapnp | pcic_pci + +# +# Machine-independent PCMCIA drivers +# +include "dev/pcmcia/files.pcmcia" + # # ISA Bus devices # @@ -242,6 +254,7 @@ file arch/alpha/pci/pci_550.c dec_550 file arch/alpha/pci/pci_1000a.c dec_1000a file arch/alpha/pci/pci_1000.c dec_1000 file arch/alpha/pci/pci_6600.c dec_6600 +file arch/alpha/pci/pci_alphabook1.c dec_alphabook1 file arch/alpha/pci/pci_up1000.c api_up1000 # @@ -327,6 +340,7 @@ file arch/alpha/alpha/dec_eb64plus.c dec_eb64plus needs-flag file arch/alpha/alpha/dec_kn20aa.c dec_kn20aa needs-flag file arch/alpha/alpha/dec_kn300.c dec_kn300 needs-flag file arch/alpha/alpha/dec_550.c dec_550 needs-flag +file arch/alpha/alpha/dec_alphabook1.c dec_alphabook1 needs-flag file arch/alpha/alpha/dec_1000a.c dec_1000 | dec_1000a needs-flag file arch/alpha/alpha/dec_6600.c dec_6600 needs-flag file arch/alpha/alpha/api_up1000.c api_up1000 needs-flag diff --git a/sys/arch/alpha/pci/pci_alphabook1.c b/sys/arch/alpha/pci/pci_alphabook1.c new file mode 100644 index 00000000000..7a036db50d8 --- /dev/null +++ b/sys/arch/alpha/pci/pci_alphabook1.c @@ -0,0 +1,195 @@ +/* $NetBSD: pci_alphabook1.c,v 1.16 2012/02/06 02:14:15 matt Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (c) 1995, 1996 Carnegie-Mellon University. + * All rights reserved. + * + * Authors: Jeffrey Hsu and Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include "sio.h" + +int dec_alphabook1_intr_map(struct pci_attach_args *, + pci_intr_handle_t *); +const char *dec_alphabook1_intr_string(void *, pci_intr_handle_t); +int dec_alphabook1_intr_line(void *, pci_intr_handle_t); +void *dec_alphabook1_intr_establish(void *, pci_intr_handle_t, + int, int (*func)(void *), void *, const char *); +void dec_alphabook1_intr_disestablish(void *, void *); + +#define LCA_SIO_DEVICE 7 /* XXX */ + +void +pci_alphabook1_pickintr(struct lca_config *lcp) +{ + bus_space_tag_t iot = &lcp->lc_iot; + pci_chipset_tag_t pc = &lcp->lc_pc; + pcireg_t sioclass; + int sioII; + + /* XXX MAGIC NUMBER */ + sioclass = pci_conf_read(pc, pci_make_tag(pc, 0, LCA_SIO_DEVICE, 0), + PCI_CLASS_REG); + sioII = (sioclass & 0xff) >= 3; + + if (!sioII) + printf("WARNING: SIO NOT SIO II... NO BETS...\n"); + + pc->pc_intr_v = lcp; + pc->pc_intr_map = dec_alphabook1_intr_map; + pc->pc_intr_string = dec_alphabook1_intr_string; + pc->pc_intr_line = dec_alphabook1_intr_line; + pc->pc_intr_establish = dec_alphabook1_intr_establish; + pc->pc_intr_disestablish = dec_alphabook1_intr_disestablish; + + /* Not supported on AlphaBook. */ + pc->pc_pciide_compat_intr_establish = NULL; + +#if NSIO + sio_intr_setup(pc, iot); +#else + panic("pci_alphabook1_pickintr: no I/O interrupt handler (no sio)"); +#endif +} + +int +dec_alphabook1_intr_map(struct pci_attach_args *pa, + pci_intr_handle_t *ihp) +{ + pcitag_t bustag = pa->pa_intrtag; + int buspin = pa->pa_intrpin; + pci_chipset_tag_t pc = pa->pa_pc; + int device, irq; + + if (buspin == 0) { + /* No IRQ used. */ + return 1; + } + if (buspin > 4) { + printf("dec_alphabook1_intr_map: bad interrupt pin %d\n", + buspin); + return 1; + } + + pci_decompose_tag(pc, bustag, NULL, &device, NULL); + + /* + * There is only one interrupting PCI device on the AlphaBook: an + * NCR SCSI at device 6. Devices 7 and 8 are the SIO and a + * Cirrus PD6729 PCMCIA controller. There are no option slots + * available. + * + * NOTE! Apparently, there was a later AlphaBook which uses + * a different interrupt scheme, and has a built-in Tulip Ethernet + * interface! We do not handle that here! + */ + + switch (device) { + case 6: /* NCR SCSI */ + irq = 14; + break; + + default: + printf("dec_alphabook1_intr_map: weird device number %d\n", + device); + return 1; + } + + *ihp = irq; + return (0); +} + +const char * +dec_alphabook1_intr_string(void *lcv, pci_intr_handle_t ih) +{ + return sio_intr_string(NULL /*XXX*/, ih); +} + +int +dec_alphabook1_intr_line(void *lcv, pci_intr_handle_t ih) +{ + return sio_intr_line(NULL /*XXX*/, ih); +} + +void * +dec_alphabook1_intr_establish(void *lcv, pci_intr_handle_t ih, + int level, int (*func)(void *), void *arg, const char *name) +{ + return sio_intr_establish(NULL /*XXX*/, ih, IST_LEVEL, level, func, + arg, name); +} + +void +dec_alphabook1_intr_disestablish(void *lcv, void *cookie) +{ + sio_intr_disestablish(NULL /*XXX*/, cookie); +} diff --git a/sys/arch/alpha/pci/pci_alphabook1.h b/sys/arch/alpha/pci/pci_alphabook1.h new file mode 100644 index 00000000000..d5a093c0eab --- /dev/null +++ b/sys/arch/alpha/pci/pci_alphabook1.h @@ -0,0 +1,30 @@ +/* $NetBSD: pci_alphabook1.h,v 1.2 2009/03/14 14:45:53 dsl Exp $ */ + +/* + * Copyright (c) 1995, 1996 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +void pci_alphabook1_pickintr(struct lca_config *); -- cgit v1.2.3