Module Name: src
Committed By: rkujawa
Date: Thu Dec 26 20:38:11 UTC 2013
Modified Files:
src/sys/arch/amiga/amiga: autoconf.c
src/sys/arch/amiga/conf: GENERIC.in files.amiga
src/sys/arch/amiga/dev: acafh.c acafhreg.h acafhvar.h
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/sys/arch/amiga/amiga/autoconf.c
cvs rdiff -u -r1.122 -r1.123 src/sys/arch/amiga/conf/GENERIC.in
cvs rdiff -u -r1.172 -r1.173 src/sys/arch/amiga/conf/files.amiga
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amiga/dev/acafh.c \
src/sys/arch/amiga/dev/acafhreg.h src/sys/arch/amiga/dev/acafhvar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amiga/amiga/autoconf.c
diff -u src/sys/arch/amiga/amiga/autoconf.c:1.115 src/sys/arch/amiga/amiga/autoconf.c:1.116
--- src/sys/arch/amiga/amiga/autoconf.c:1.115 Sun Dec 22 02:21:51 2013
+++ src/sys/arch/amiga/amiga/autoconf.c Thu Dec 26 20:38:11 2013
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
#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 @@ mbattach(device_t parent, device_t self,
#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);
Index: src/sys/arch/amiga/conf/GENERIC.in
diff -u src/sys/arch/amiga/conf/GENERIC.in:1.122 src/sys/arch/amiga/conf/GENERIC.in:1.123
--- src/sys/arch/amiga/conf/GENERIC.in:1.122 Sun Dec 22 23:02:38 2013
+++ src/sys/arch/amiga/conf/GENERIC.in Thu Dec 26 20:38:11 2013
@@ -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 @@ include "arch/amiga/conf/std.amiga"
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 @@ scsibus* at cbiiisc0
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
Index: src/sys/arch/amiga/conf/files.amiga
diff -u src/sys/arch/amiga/conf/files.amiga:1.172 src/sys/arch/amiga/conf/files.amiga:1.173
--- src/sys/arch/amiga/conf/files.amiga:1.172 Sun Dec 22 02:21:51 2013
+++ src/sys/arch/amiga/conf/files.amiga Thu Dec 26 20:38:11 2013
@@ -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 DEVRELOAD
defflag opt_p5pb.h P5PB_DEBUG P5PB_CONSOLE
-defflag opt_acafh.h ACA500_SUPPORT
-
defparam IOBZCLOCK
device mainbus {}
@@ -588,7 +586,7 @@ define acafhbus {}
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
Index: src/sys/arch/amiga/dev/acafh.c
diff -u src/sys/arch/amiga/dev/acafh.c:1.2 src/sys/arch/amiga/dev/acafh.c:1.3
--- src/sys/arch/amiga/dev/acafh.c:1.2 Sun Dec 22 23:02:38 2013
+++ src/sys/arch/amiga/dev/acafh.c Thu Dec 26 20:38:11 2013
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: acafh.c,v 1.
#include <sys/socket.h>
#include <sys/systm.h>
#include <sys/bus.h>
+#include <sys/types.h>
#include <uvm/uvm.h>
@@ -63,6 +64,69 @@ static uint8_t acafh_revision(struct aca
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 @@ acafh_attach(device_t parent, device_t s
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 @@ acafh_attach(device_t parent, device_t s
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,
Index: src/sys/arch/amiga/dev/acafhreg.h
diff -u src/sys/arch/amiga/dev/acafhreg.h:1.2 src/sys/arch/amiga/dev/acafhreg.h:1.3
--- src/sys/arch/amiga/dev/acafhreg.h:1.2 Sun Dec 22 23:02:38 2013
+++ src/sys/arch/amiga/dev/acafhreg.h Thu Dec 26 20:38:11 2013
@@ -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_ */
Index: src/sys/arch/amiga/dev/acafhvar.h
diff -u src/sys/arch/amiga/dev/acafhvar.h:1.2 src/sys/arch/amiga/dev/acafhvar.h:1.3
--- src/sys/arch/amiga/dev/acafhvar.h:1.2 Sun Dec 22 23:02:38 2013
+++ src/sys/arch/amiga/dev/acafhvar.h Thu Dec 26 20:38:11 2013
@@ -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 @@ struct acafhbus_attach_args {
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_ */