diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2010-01-22 21:45:27 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2010-01-22 21:45:27 +0000 |
commit | 290dbbfd0c42edad053dfe7884638dde38591649 (patch) | |
tree | fb7db8f48b46ecf6d709735ca8d0aba8aeeed408 /sys/arch/loongson | |
parent | 0a04a3641864197a6cc4f59db098ac2d541b6b9e (diff) |
Move is_memory_range() from mips64 mem.c to a per-architecture location; this
allows /dev/kmem to access the 256MB alias of the low memory on loongson, which
in turns makes procmap(8) happy.
Diffstat (limited to 'sys/arch/loongson')
-rw-r--r-- | sys/arch/loongson/dev/bonito.c | 6 | ||||
-rw-r--r-- | sys/arch/loongson/loongson/loongson2_machdep.c | 70 |
2 files changed, 55 insertions, 21 deletions
diff --git a/sys/arch/loongson/dev/bonito.c b/sys/arch/loongson/dev/bonito.c index e8b614c1e05..9d46d4ad68b 100644 --- a/sys/arch/loongson/dev/bonito.c +++ b/sys/arch/loongson/dev/bonito.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bonito.c,v 1.1 2009/12/25 22:09:45 miod Exp $ */ +/* $OpenBSD: bonito.c,v 1.2 2010/01/22 21:45:22 miod Exp $ */ /* $NetBSD: bonito_mainbus.c,v 1.11 2008/04/28 20:23:10 martin Exp $ */ /* $NetBSD: bonito_pci.c,v 1.5 2008/04/28 20:23:28 martin Exp $ */ @@ -300,13 +300,13 @@ bonito_attach(struct device *parent, struct device *self, void *aux) bus_addr_t bonito_pa_to_device(paddr_t pa) { - return pa; + return pa ^ loongson_dma_base; } paddr_t bonito_device_to_pa(bus_addr_t addr) { - return addr; + return addr ^ loongson_dma_base; } int diff --git a/sys/arch/loongson/loongson/loongson2_machdep.c b/sys/arch/loongson/loongson/loongson2_machdep.c index 67a26098d2a..541ef74c63e 100644 --- a/sys/arch/loongson/loongson/loongson2_machdep.c +++ b/sys/arch/loongson/loongson/loongson2_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: loongson2_machdep.c,v 1.1 2009/12/25 22:04:21 miod Exp $ */ +/* $OpenBSD: loongson2_machdep.c,v 1.2 2010/01/22 21:45:24 miod Exp $ */ /* * Copyright (c) 2009 Miodrag Vallat. @@ -30,6 +30,7 @@ extern struct phys_mem_desc mem_layout[MAXMEMSEGS]; +boolean_t is_memory_range(paddr_t, psize_t, psize_t); void loongson2e_setup(u_long, u_long); void loongson2f_setup(u_long, u_long); @@ -42,23 +43,6 @@ paddr_t loongson_dma_base = 0; * Setup memory mappings for Loongson 2E processors. */ -void -loongson2e_setup(u_long memlo, u_long memhi) -{ - memlo = atop(memlo << 20); - memhi = atop(memhi << 20); - physmem = memlo + memhi; - - /* - * Only register the first 256MB of memory. - * This will be hopefully be revisited once we get our hands - * on Loongson 2E-based hardware... - */ - - mem_layout[0].mem_first_page = 1; /* do NOT stomp on exception area */ - mem_layout[0].mem_last_page = memlo; -} - /* * Canonical crossbow assignments on Loongson 2F based designs. * Might need to move to a per-design header file in the future. @@ -84,6 +68,25 @@ loongson2e_setup(u_long memlo, u_long memhi) #define PCI_DDR_SIZE DDR_PHYSICAL_SIZE #define PCI_DDR_WINDOW_BASE DDR_PHYSICAL_BASE +void +loongson2e_setup(u_long memlo, u_long memhi) +{ + memlo = atop(memlo << 20); + memhi = atop(memhi << 20); + physmem = memlo + memhi; + + /* + * Only register the first 256MB of memory. + * This will be hopefully be revisited once we get our hands + * on Loongson 2E-based hardware... + */ + + mem_layout[0].mem_first_page = 1; /* do NOT stomp on exception area */ + mem_layout[0].mem_last_page = memlo; + + loongson_dma_base = PCI_DDR_BASE; +} + /* * Setup memory mappings for Loongson 2F processors. */ @@ -160,3 +163,34 @@ loongson2f_setup(u_long memlo, u_long memhi) *awrreg = DDR_PHYSICAL_BASE | MASTER_CPU; (void)*awrreg; } + +boolean_t +is_memory_range(paddr_t pa, psize_t len, psize_t limit) +{ + struct phys_mem_desc *seg; + uint64_t fp, lp; + int i; + + fp = atop(pa); + lp = atop(round_page(pa + len)); + + if (limit != 0 && lp > atop(limit)) + return FALSE; + + /* + * Allow access to the low 256MB aliased region on 2F systems. + */ + if (/* curcpu()->ci_hw.type == MIPS_LOONGSON2 && */ + (curcpu()->ci_hw.c0prid & 0xff) == 0x2f - 0x2c) { + if (pa < 0x10000000) { + fp += atop(DDR_WINDOW_BASE); + lp += atop(DDR_WINDOW_BASE); + } + } + + for (i = 0, seg = mem_layout; i < MAXMEMSEGS; i++, seg++) + if (fp >= seg->mem_first_page && lp <= seg->mem_last_page) + return TRUE; + + return FALSE; +} |