Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/amiga Implement the probe procedure for ACA500. Now...



details:   https://anonhg.NetBSD.org/src/rev/867266815102
branches:  trunk
changeset: 325493:867266815102
user:      rkujawa <rkujawa%NetBSD.org@localhost>
date:      Thu Dec 26 20:38:11 2013 +0000

description:
Implement the probe procedure for ACA500. Now the user just needs acafh0
compiled in his kernel and it all should(tm) work.

Due to lack of obio in amiga port, the probe is called directly from mbattach().
This is going to change with the introduction of obio for all non-autoconfig
expansions.

diffstat:

 sys/arch/amiga/amiga/autoconf.c |  15 +++++--
 sys/arch/amiga/conf/GENERIC.in  |  11 ++---
 sys/arch/amiga/conf/files.amiga |   6 +--
 sys/arch/amiga/dev/acafh.c      |  76 +++++++++++++++++++++++++++++++++++++++-
 sys/arch/amiga/dev/acafhreg.h   |   6 ++-
 sys/arch/amiga/dev/acafhvar.h   |   4 +-
 6 files changed, 98 insertions(+), 20 deletions(-)

diffs (264 lines):

diff -r 330e402c6cc5 -r 867266815102 sys/arch/amiga/amiga/autoconf.c
--- a/sys/arch/amiga/amiga/autoconf.c   Thu Dec 26 20:19:17 2013 +0000
+++ b/sys/arch/amiga/amiga/autoconf.c   Thu Dec 26 20:38:11 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.115 2013/12/22 02:21:51 rkujawa Exp $   */
+/*     $NetBSD: autoconf.c,v 1.116 2013/12/26 20:38:11 rkujawa Exp $   */
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.115 2013/12/22 02:21:51 rkujawa Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.116 2013/12/26 20:38:11 rkujawa Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -53,7 +53,10 @@
 #include <amiga/pci/p5pbvar.h>
 #endif /* P5PB_CONSOLE */
 
-#include "opt_acafh.h"
+#include "acafh.h"
+#if NACAFH > 0
+#include <amiga/dev/acafhvar.h>
+#endif /* NACAFH > 0 */
 
 static void findroot(void);
 void mbattach(device_t, device_t, void *);
@@ -302,8 +305,10 @@
 #endif
                config_found(self, __UNCONST("aucc"), simple_devprint);
 
-#ifdef ACA500_SUPPORT
-       config_found(self, __UNCONST("acafh"), simple_devprint);
+#if NACAFH > 0
+       if (!is_a600() && !is_a1200() && !is_a3000() && !is_a4000())
+               if (acafh_mbattach_probe() == true)
+                       config_found(self, __UNCONST("acafh"), simple_devprint);
 #endif
 
        config_found(self, __UNCONST("zbus"), simple_devprint);
diff -r 330e402c6cc5 -r 867266815102 sys/arch/amiga/conf/GENERIC.in
--- a/sys/arch/amiga/conf/GENERIC.in    Thu Dec 26 20:19:17 2013 +0000
+++ b/sys/arch/amiga/conf/GENERIC.in    Thu Dec 26 20:38:11 2013 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC.in,v 1.122 2013/12/22 23:02:38 rkujawa Exp $
+# $NetBSD: GENERIC.in,v 1.123 2013/12/26 20:38:11 rkujawa Exp $
 #
 ##
 # GENERIC machine description file
@@ -52,7 +52,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.122 $"
+#ident                 "GENERIC-$Revision: 1.123 $"
 
 m4_ifdef(`INSTALL_CONFIGURATION', `m4_dnl
 makeoptions    COPTS="-Os"
@@ -516,10 +516,9 @@
 empsc0         at zbus0                # Emplant scsi
 scsibus*       at empsc0
 
-#acafh0                at mainbus0             # Individual Computers ACA500
-#options       ACA500_SUPPORT
-#wdc*          at acafhbus?            # CF slots on ACA500
-#gencp*                at acafhbus?            # clockport on ACA500
+acafh0         at mainbus0             # Individual Computers ACA500
+wdc*           at acafhbus?            # CF slots on ACA500
+gencp*         at acafhbus?            # clockport on ACA500
 
 wdc0           at mainbus0             # A4000 & A1200 IDE bus
 wdc*           at zbus0                # Buddha / Catweasel
diff -r 330e402c6cc5 -r 867266815102 sys/arch/amiga/conf/files.amiga
--- a/sys/arch/amiga/conf/files.amiga   Thu Dec 26 20:19:17 2013 +0000
+++ b/sys/arch/amiga/conf/files.amiga   Thu Dec 26 20:38:11 2013 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.amiga,v 1.172 2013/12/22 02:21:51 rkujawa Exp $
+#      $NetBSD: files.amiga,v 1.173 2013/12/26 20:38:11 rkujawa Exp $
 
 # maxpartitions must be first item in files.${ARCH}.newconf
 maxpartitions 16                       # NOTE THAT AMIGA IS SPECIAL!
@@ -34,8 +34,6 @@
 
 defflag opt_p5pb.h             P5PB_DEBUG P5PB_CONSOLE
 
-defflag opt_acafh.h            ACA500_SUPPORT
-
 defparam                       IOBZCLOCK
 
 device mainbus {}
@@ -588,7 +586,7 @@
 
 device acafh: acafhbus, amibus_b4000
 attach acafh at mainbus 
-file   arch/amiga/dev/acafh.c          acafh needs-flag
+file   arch/amiga/dev/acafh.c          acafh needs-count 
 
 attach wdc at acafhbus with wdc_acafh
 file   arch/amiga/dev/wdc_acafh.c      wdc_acafh & acafh 
diff -r 330e402c6cc5 -r 867266815102 sys/arch/amiga/dev/acafh.c
--- a/sys/arch/amiga/dev/acafh.c        Thu Dec 26 20:19:17 2013 +0000
+++ b/sys/arch/amiga/dev/acafh.c        Thu Dec 26 20:38:11 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acafh.c,v 1.2 2013/12/22 23:02:38 rkujawa Exp $ */
+/*     $NetBSD: acafh.c,v 1.3 2013/12/26 20:38:11 rkujawa Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acafh.c,v 1.2 2013/12/22 23:02:38 rkujawa Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acafh.c,v 1.3 2013/12/26 20:38:11 rkujawa Exp $");
 
 /*
  * Individual Computers ACA500 driver. 
@@ -42,6 +42,7 @@
 #include <sys/socket.h>
 #include <sys/systm.h>
 #include <sys/bus.h>
+#include <sys/types.h>
 
 #include <uvm/uvm.h>
 
@@ -63,6 +64,69 @@
 CFATTACH_DECL_NEW(acafh, sizeof(struct acafh_softc),
     acafh_match, acafh_attach, NULL, NULL);
 
+/*
+ * Since ACA500 is not an AutoConfig board and current amiga port infrastructure
+ * does not have typical obio attachment, we need to hack in the probe procedure
+ * into mbattach(). This is supposed to be a temporary solution.
+ */
+bool
+acafh_mbattach_probe(void)
+{
+       vaddr_t aca_rom_vbase;
+       struct bus_space_tag aca_rom_bst;
+       bus_space_tag_t aca_rom_t;
+       bus_space_handle_t aca_rom_h;
+       uint32_t aca_id;
+       bool rv;
+
+       rv = false;
+
+#ifdef ACAFH_DEBUG
+       aprint_normal("acafh: probing for ACA500\n");
+#endif /* ACAFH_DEBUG */
+
+       /* 
+        * Allocate VA to hold one mapped page, which we will use
+        * to access the beginning of ACA500 flash. 
+        */
+       aca_rom_vbase = uvm_km_alloc(kernel_map,
+           PAGE_SIZE, 0, UVM_KMF_VAONLY | UVM_KMF_NOWAIT);
+
+       /* Create the physical to virtual mapping. */
+       pmap_enter(vm_map_pmap(kernel_map), aca_rom_vbase, ACAFH_ROM_BASE,
+           VM_PROT_READ, PMAP_NOCACHE);
+       pmap_update(vm_map_pmap(kernel_map));
+
+       aca_rom_bst.base = (bus_addr_t) aca_rom_vbase;
+        aca_rom_bst.absm = &amiga_bus_stride_1;
+       aca_rom_t = &aca_rom_bst;
+       bus_space_map(aca_rom_t, 0, PAGE_SIZE, 0, &aca_rom_h);
+
+       /* Read out the ID. */
+       aca_id = bus_space_read_4(aca_rom_t, aca_rom_h, ACAFH_ROM_ID_OFFSET);
+#ifdef ACAFH_DEBUG
+       aprint_normal("acafh: probe read %x from ACA ROM offset %x\n", aca_id, 
+           ACAFH_ROM_ID_OFFSET);
+#endif /* ACAFH_DEBUG */
+
+       if (aca_id == ACAFH_ROM_ID_VALUE)
+               rv = true;
+       else
+               rv = false;
+
+#ifdef ACAFH_DEBUG
+       aprint_normal("acafh: clean up after probe\n");
+#endif /* ACAFH_DEBUG */
+
+       pmap_remove(vm_map_pmap(kernel_map), aca_rom_vbase, aca_rom_vbase + PAGE_SIZE);
+        pmap_update(vm_map_pmap(kernel_map));
+
+       uvm_km_free(kernel_map, aca_rom_vbase, PAGE_SIZE, 
+           UVM_KMF_VAONLY | UVM_KMF_NOWAIT);
+
+       return rv;
+}
+
 int
 acafh_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -83,7 +147,10 @@
        sc = device_private(self);
        sc->sc_dev = self;
 
-       /* XXX: we should be sure to prepare enough kva during early init... */
+       /* 
+        * Allocate enough kernel memory.
+        * 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);
 
@@ -93,6 +160,9 @@
                return;
        }
 
+       /* 
+        * Map the ACA500 registers into kernel virutal space.
+        */
        for (i = ACAFH_BASE; i < ACAFH_END; i += PAGE_SIZE)
                pmap_enter(vm_map_pmap(kernel_map),
                        i - ACAFH_BASE + aca_vbase, i,
diff -r 330e402c6cc5 -r 867266815102 sys/arch/amiga/dev/acafhreg.h
--- a/sys/arch/amiga/dev/acafhreg.h     Thu Dec 26 20:19:17 2013 +0000
+++ b/sys/arch/amiga/dev/acafhreg.h     Thu Dec 26 20:38:11 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acafhreg.h,v 1.2 2013/12/22 23:02:38 rkujawa Exp $ */
+/*     $NetBSD: acafhreg.h,v 1.3 2013/12/26 20:38:11 rkujawa Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -59,5 +59,9 @@
 #define ACAFH_POWERUP                  0xD
 #define ACAFH_C0WIPE                   0xE
 
+#define ACAFH_ROM_BASE         0xA00000
+#define ACAFH_ROM_ID_OFFSET            0xDC
+#define ACAFH_ROM_ID_VALUE             0x0ACA0500
+
 #endif /* _AMIGA_ACAFHREG_H_ */
 
diff -r 330e402c6cc5 -r 867266815102 sys/arch/amiga/dev/acafhvar.h
--- a/sys/arch/amiga/dev/acafhvar.h     Thu Dec 26 20:19:17 2013 +0000
+++ b/sys/arch/amiga/dev/acafhvar.h     Thu Dec 26 20:38:11 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acafhvar.h,v 1.2 2013/12/22 23:02:38 rkujawa Exp $ */
+/*     $NetBSD: acafhvar.h,v 1.3 2013/12/26 20:38:11 rkujawa Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,6 +32,7 @@
 #ifndef _AMIGA_ACAFHVAR_H_
 
 #include <sys/bus.h>
+#include <sys/types.h>
 
 struct acafh_softc {
        device_t sc_dev;
@@ -46,6 +47,7 @@
        bus_addr_t      aaa_pbase; /* physical base address */
 };
 
+bool acafh_mbattach_probe(void);
 uint8_t acafh_cf_intr_status(struct acafh_softc *, uint8_t);
 
 #endif /* _AMIGA_ACAFHVAR_H_ */



Home | Main Index | Thread Index | Old Index