summaryrefslogtreecommitdiff
path: root/sys/arch/sgi/localbus
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2007-06-21 20:17:13 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2007-06-21 20:17:13 +0000
commitb03519f8c6e8caccda6520217fb3537d1d063c4a (patch)
tree3ffa85787ef7a55040b36a3c7d5394a637c2162a /sys/arch/sgi/localbus
parent499eb788d359fe4e2415e514679969123e8dd6d2 (diff)
Extent sgi bus_dma to cope with different views of memory: non-contiguous
for the cpu, contiguous from different bases for devices. This allows memory above 256MB to be used with bus_dma (and we had really been lucky with the first few large-memory builds). Information about memory accesses taken from Linux.
Diffstat (limited to 'sys/arch/sgi/localbus')
-rw-r--r--sys/arch/sgi/localbus/crimebus.h5
-rw-r--r--sys/arch/sgi/localbus/macebus.c31
2 files changed, 33 insertions, 3 deletions
diff --git a/sys/arch/sgi/localbus/crimebus.h b/sys/arch/sgi/localbus/crimebus.h
index 8eb35227c9b..67f7f7b4719 100644
--- a/sys/arch/sgi/localbus/crimebus.h
+++ b/sys/arch/sgi/localbus/crimebus.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: crimebus.h,v 1.5 2007/05/03 19:34:00 miod Exp $ */
+/* $OpenBSD: crimebus.h,v 1.6 2007/06/21 20:17:12 miod Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se).
@@ -100,6 +100,9 @@
#define CRIME_MEM_BANK_128MB 0x100
#define CRIME_MAX_BANKS 8
+#define CRIME_MEMORY_OFFSET 0x40000000 /* 1GB */
+#define CRIME_MEMORY_MASK 0x3fffffff
+
#define CRIME_MEM_ERROR_STAT 0x0250
#define CRIME_MEM_ERROR_ADDR 0x0258
diff --git a/sys/arch/sgi/localbus/macebus.c b/sys/arch/sgi/localbus/macebus.c
index 93e50b71b8e..555275d380d 100644
--- a/sys/arch/sgi/localbus/macebus.c
+++ b/sys/arch/sgi/localbus/macebus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: macebus.c,v 1.24 2007/06/20 20:47:34 miod Exp $ */
+/* $OpenBSD: macebus.c,v 1.25 2007/06/21 20:17:12 miod Exp $ */
/*
* Copyright (c) 2000-2004 Opsycon AB (www.opsycon.se)
@@ -69,6 +69,9 @@ void macebus_do_pending_int(int);
intrmask_t macebus_iointr(intrmask_t, struct trap_frame *);
intrmask_t macebus_aux(intrmask_t, struct trap_frame *);
+bus_addr_t macebus_pa_to_device(paddr_t);
+paddr_t macebus_device_to_pa(bus_addr_t);
+
int maceticks; /* Time tracker for special events */
struct cfattach macebus_ca = {
@@ -121,7 +124,9 @@ struct machine_bus_dma_tag mace_bus_dma_tag = {
_dmamem_map,
_dmamem_unmap,
_dmamem_mmap,
- NULL
+ macebus_pa_to_device,
+ macebus_device_to_pa,
+ CRIME_MEMORY_MASK
};
/*
@@ -430,6 +435,28 @@ mace_space_region(bus_space_tag_t t, bus_space_handle_t bsh,
}
/*
+ * Macebus bus_dma helpers.
+ * Mace accesses memory contiguously at 0x40000000 onwards.
+ */
+
+bus_addr_t
+macebus_pa_to_device(paddr_t pa)
+{
+ return (pa | CRIME_MEMORY_OFFSET);
+}
+
+paddr_t
+macebus_device_to_pa(bus_addr_t addr)
+{
+ paddr_t pa = (paddr_t)addr & CRIME_MEMORY_MASK;
+
+ if (pa >= 256 * 1024 * 1024)
+ pa |= CRIME_MEMORY_OFFSET;
+
+ return (pa);
+}
+
+/*
* Macebus interrupt handler driver.
*/