Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amiga Add preliminary support for the Individual Co...



details:   https://anonhg.NetBSD.org/src/rev/5196c5f99a98
branches:  trunk
changeset: 325386:5196c5f99a98
user:      rkujawa <rkujawa%NetBSD.org@localhost>
date:      Sun Dec 22 02:21:51 2013 +0000

description:
Add preliminary support for the Individual Computers ACA500 in the form of acahf
driver. If ACA500 is equipped with supported accelerator with MMU, it allows
running NetBSD on an Amiga 500.

Since ACA is not autoconf-aware, and the probe procedure does not exist yet, the
driver is activated with the ACA500_SUPPORT kernel option. The acahf driver
is commented out in the GENERIC kernel for now (at least until it stops being
very experimental and hackish).

When it comes to ACA-specific hardware, for now the boot CF slot works. Support for everything else is incoming...

diffstat:

 sys/arch/amiga/amiga/amiga_bus_simple_0x4000.c |   38 +++++
 sys/arch/amiga/amiga/autoconf.c                |   10 +-
 sys/arch/amiga/conf/GENERIC.in                 |    8 +-
 sys/arch/amiga/conf/files.amiga                |   16 ++-
 sys/arch/amiga/dev/acafh.c                     |  185 +++++++++++++++++++++++++
 sys/arch/amiga/dev/acafhreg.h                  |   62 ++++++++
 sys/arch/amiga/dev/acafhvar.h                  |   52 +++++++
 sys/arch/amiga/dev/wdc_acafh.c                 |  176 +++++++++++++++++++++++
 sys/arch/amiga/include/bus.h                   |    3 +-
 9 files changed, 544 insertions(+), 6 deletions(-)

diffs (truncated from 661 to 300 lines):

diff -r e6acbd8b9a02 -r 5196c5f99a98 sys/arch/amiga/amiga/amiga_bus_simple_0x4000.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/amiga/amiga/amiga_bus_simple_0x4000.c    Sun Dec 22 02:21:51 2013 +0000
@@ -0,0 +1,38 @@
+/* $NetBSD: amiga_bus_simple_0x4000.c,v 1.1 2013/12/22 02:21:51 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Ignatios Souvatzis.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(1, "$NetBSD: amiga_bus_simple_0x4000.c,v 1.1 2013/12/22 02:21:51 rkujawa Exp $");
+
+#define AMIGA_SIMPLE_BUS_STRIDE 0x4000         /* 1 byte per 0x4000 bytes */
+#define AMIGA_SIMPLE_BUS_WORD_METHODS
+
+#include "simple_busfuncs.c"
diff -r e6acbd8b9a02 -r 5196c5f99a98 sys/arch/amiga/amiga/autoconf.c
--- a/sys/arch/amiga/amiga/autoconf.c   Sun Dec 22 01:18:28 2013 +0000
+++ b/sys/arch/amiga/amiga/autoconf.c   Sun Dec 22 02:21:51 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.114 2012/10/27 17:17:26 chs Exp $       */
+/*     $NetBSD: autoconf.c,v 1.115 2013/12/22 02:21:51 rkujawa Exp $   */
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.114 2012/10/27 17:17:26 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.115 2013/12/22 02:21:51 rkujawa Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -53,6 +53,8 @@
 #include <amiga/pci/p5pbvar.h>
 #endif /* P5PB_CONSOLE */
 
+#include "opt_acafh.h"
+
 static void findroot(void);
 void mbattach(device_t, device_t, void *);
 int mbprint(void *, const char *);
@@ -300,6 +302,10 @@
 #endif
                config_found(self, __UNCONST("aucc"), simple_devprint);
 
+#ifdef ACA500_SUPPORT
+       config_found(self, __UNCONST("acafh"), simple_devprint);
+#endif
+
        config_found(self, __UNCONST("zbus"), simple_devprint);
 }
 
diff -r e6acbd8b9a02 -r 5196c5f99a98 sys/arch/amiga/conf/GENERIC.in
--- a/sys/arch/amiga/conf/GENERIC.in    Sun Dec 22 01:18:28 2013 +0000
+++ b/sys/arch/amiga/conf/GENERIC.in    Sun Dec 22 02:21:51 2013 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC.in,v 1.120 2013/10/04 15:13:51 rkujawa Exp $
+# $NetBSD: GENERIC.in,v 1.121 2013/12/22 02:21:51 rkujawa Exp $
 #
 ##
 # GENERIC machine description file
@@ -52,7 +52,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.120 $"
+#ident                 "GENERIC-$Revision: 1.121 $"
 
 m4_ifdef(`INSTALL_CONFIGURATION', `m4_dnl
 makeoptions    COPTS="-Os"
@@ -515,6 +515,10 @@
 empsc0         at zbus0                # Emplant scsi
 scsibus*       at empsc0
 
+#acafh0                at mainbus0             # Individual Computers ACA500
+#options       ACA500_SUPPORT
+#wdc*          at acafhbus?
+
 wdc0           at mainbus0             # A4000 & A1200 IDE bus
 wdc*           at zbus0                # Buddha / Catweasel
 #efa0          at mainbus0             # ELBOX FastATA 1200 Mk-III/Mk-IV 
diff -r e6acbd8b9a02 -r 5196c5f99a98 sys/arch/amiga/conf/files.amiga
--- a/sys/arch/amiga/conf/files.amiga   Sun Dec 22 01:18:28 2013 +0000
+++ b/sys/arch/amiga/conf/files.amiga   Sun Dec 22 02:21:51 2013 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.amiga,v 1.171 2013/08/08 21:23:51 rkujawa Exp $
+#      $NetBSD: files.amiga,v 1.172 2013/12/22 02:21:51 rkujawa Exp $
 
 # maxpartitions must be first item in files.${ARCH}.newconf
 maxpartitions 16                       # NOTE THAT AMIGA IS SPECIAL!
@@ -34,6 +34,8 @@
 
 defflag opt_p5pb.h             P5PB_DEBUG P5PB_CONSOLE
 
+defflag opt_acafh.h            ACA500_SUPPORT
+
 defparam                       IOBZCLOCK
 
 device mainbus {}
@@ -58,6 +60,9 @@
 define amibus_b800
 file   arch/amiga/amiga/amiga_bus_simple_0x800.c       amibus_b800
 
+define amibus_b4000
+file   arch/amiga/amiga/amiga_bus_simple_0x4000.c      amibus_b4000
+
 define  amibus_empb
 file   arch/amiga/pci/empb_bsm.c       amibus_empb
 
@@ -579,6 +584,15 @@
 attach slhci at zbus with slhci_zbus
 file   arch/amiga/dev/slhci_zbus.c     slhci_zbus
 
+define acafhbus {}
+
+device acafh: acafhbus, amibus_b4000
+attach acafh at mainbus 
+file   arch/amiga/dev/acafh.c          acafh needs-flag
+
+attach wdc at acafhbus with wdc_acafh
+file   arch/amiga/dev/wdc_acafh.c      wdc_acafh & acafh 
+
 include "arch/amiga/clockport/files.clockport"
 
 include        "arch/amiga/conf/majors.amiga"
diff -r e6acbd8b9a02 -r 5196c5f99a98 sys/arch/amiga/dev/acafh.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/amiga/dev/acafh.c        Sun Dec 22 02:21:51 2013 +0000
@@ -0,0 +1,185 @@
+/*     $NetBSD: acafh.c,v 1.1 2013/12/22 02:21:51 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Radoslaw Kujawa.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: acafh.c,v 1.1 2013/12/22 02:21:51 rkujawa Exp $");
+
+/*
+ * Individual Computers ACA500 driver. 
+ */
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+
+#include <uvm/uvm.h>
+
+#include <machine/cpu.h>
+
+#include <amiga/amiga/device.h>
+#include <amiga/amiga/isr.h>
+
+#include <amiga/dev/zbusvar.h>
+#include <amiga/dev/acafhvar.h>
+#include <amiga/dev/acafhreg.h>
+
+int    acafh_match(device_t, cfdata_t , void *);
+void   acafh_attach(device_t, device_t, void *);
+static int acafh_print(void *, const char *);
+static uint8_t acafh_reg_read(struct acafh_softc *, uint8_t);
+static uint8_t acafh_revision(struct acafh_softc *);
+
+CFATTACH_DECL_NEW(acafh, sizeof(struct acafh_softc),
+    acafh_match, acafh_attach, NULL, NULL);
+
+int
+acafh_match(device_t parent, cfdata_t cf, void *aux)
+{
+       if (matchname(aux, "acafh") == 0)
+               return(0);
+       return(1);
+}
+
+void
+acafh_attach(device_t parent, device_t self, void *aux)
+{
+       struct acafh_softc *sc;
+       vaddr_t aca_vbase;
+       int i;
+       struct acafhbus_attach_args aaa_wdc;
+
+       sc = device_private(self);
+       sc->sc_dev = self;
+
+       /* XXX: we should be sure to prepare enough kva during early init... */
+       aca_vbase = uvm_km_alloc(kernel_map,
+           ACAFH_END - ACAFH_BASE, 0, UVM_KMF_VAONLY | UVM_KMF_NOWAIT);
+
+       if (aca_vbase == 0) {
+               aprint_error_dev(sc->sc_dev, 
+                   "failed allocating virtual memory\n");
+               return;
+       }
+
+       for (i = ACAFH_BASE; i < ACAFH_END; i += PAGE_SIZE)
+               pmap_enter(vm_map_pmap(kernel_map),
+                       i - ACAFH_BASE + aca_vbase, i,
+                          VM_PROT_READ | VM_PROT_WRITE, true);
+               pmap_update(vm_map_pmap(kernel_map));
+
+       aca_vbase += ACAFH_FIRST_REG_OFF;
+
+       sc->sc_aca_bst.base = (bus_addr_t) aca_vbase;
+       sc->sc_aca_bst.absm = &amiga_bus_stride_1;
+/*     sc->sc_aca_bst.absm = &amiga_bus_stride_0x4000; */
+       sc->sc_aca_iot = &sc->sc_aca_bst;
+
+       bus_space_map(sc->sc_aca_iot, 0, 0xF, 0, &sc->sc_aca_ioh);
+
+#ifdef ACAFH_DEBUG
+       aprint_normal_dev(sc->sc_dev, 
+           "ACA500 registers mapped to pa %x (va %x)\n",
+           kvtop((void*)sc->sc_aca_ioh), sc->sc_aca_bst.base);
+       aprint_normal_dev(sc->sc_dev, "AUX intr enable %x\n", 
+           acafh_reg_read(sc, ACAFH_MEMPROBE_AUXIRQ));
+#endif /* ACAFH_DEBUG */
+
+       aprint_normal(": Individual Computers ACA500 (rev %x)\n",
+           acafh_revision(sc));
+
+       aprint_normal_dev(sc->sc_dev, "CF cards present: ");
+       if (acafh_reg_read(sc, ACAFH_CF_DETECT_BOOT)) {
+               aprint_normal("BOOT "); 
+       }
+       if (acafh_reg_read(sc, ACAFH_CF_DETECT_AUX)) {
+               aprint_normal("AUX ");  
+       }
+       aprint_normal("\n");
+
+       aaa_wdc.aaa_base = (bus_addr_t) 0xDA0000 + 2;
+       strcpy(aaa_wdc.aaa_name, "wdc_acafh");
+       config_found_ia(sc->sc_dev, "acafhbus", &aaa_wdc, acafh_print);
+}
+
+uint8_t
+acafh_cf_intr_status(struct acafh_softc *sc, uint8_t slot) 
+{
+       uint8_t status;
+
+       if (slot == 0) {
+               status = acafh_reg_read(sc, ACAFH_CF_IRQ_BOOT);
+       } else {
+               status = acafh_reg_read(sc, ACAFH_CF_IRQ_AUX);



Home | Main Index | Thread Index | Old Index