summaryrefslogtreecommitdiff
path: root/sys/arch/loongson/dev
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2010-03-02 20:53:13 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2010-03-02 20:53:13 +0000
commitfee7c835db0ae03612bc4f849d091cf2b74a7b1f (patch)
tree9dea0bbec4d5c341e78c42f8fb9dcff2ad126fc4 /sys/arch/loongson/dev
parentc0caaf8eae67609e0faa86c87a30c8f55194d5cc (diff)
Actually prefer PCIHI mappings to PCILO mappings, as the early console code
attempts to map resources without bothering to know their size. I should probably be more careful and do the BAR dance to get the BAR size, but then at this point we are reusing mappings set up by PMON, and it's ok to trust it. This would only have ever become an issue with a framebuffer larger than 64MB mapped at PCIHI with a PCILO mapping overlapping the first few 64MB anyway.
Diffstat (limited to 'sys/arch/loongson/dev')
-rw-r--r--sys/arch/loongson/dev/bonito.c68
1 files changed, 36 insertions, 32 deletions
diff --git a/sys/arch/loongson/dev/bonito.c b/sys/arch/loongson/dev/bonito.c
index 83b52cab3dd..58c716b5eed 100644
--- a/sys/arch/loongson/dev/bonito.c
+++ b/sys/arch/loongson/dev/bonito.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bonito.c,v 1.12 2010/02/28 21:35:41 miod Exp $ */
+/* $OpenBSD: bonito.c,v 1.13 2010/03/02 20:53:12 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 $ */
@@ -1157,6 +1157,41 @@ bonito_mem_map(bus_space_tag_t t, bus_addr_t offs, bus_size_t size, int flags,
int is2f, pcilo_window;
/*
+ * Try a PCIHI mapping first.
+ */
+
+ /* may be used before curcpu() points to valid data */
+ if ((cp0_get_prid() & 0xffff) ==
+ ((MIPS_LOONGSON2 << 8) | (0x2f - 0x2c)))
+ is2f = 1;
+ else
+ is2f = 0;
+
+ if (is2f) {
+ if (offs >= LS2F_PCIHI_BASE && end <= LS2F_PCIHI_TOP) {
+ *bshp = t->bus_base + offs;
+ return 0;
+ }
+ } else {
+ /* PCI1.5 */
+ if (offs >= BONITO_PCIHI_BASE && end <= BONITO_PCIHI_TOP) {
+ *bshp = t->bus_base + offs;
+ return 0;
+ }
+
+ /* PCI2 */
+ w = pcimap & BONITO_PCIMAP_PCIMAP_2 ? 0x80000000UL : 0;
+ if (offs >= w && end < (w + 0x80000000UL)) {
+ *bshp = t->bus_base + 0x80000000UL + (offs - w);
+ return 0;
+ }
+ }
+
+ /*
+ * No luck, try a PCILO mapping.
+ */
+
+ /*
* Decode PCIMAP, and figure out what PCILO mappings are
* possible.
*/
@@ -1203,37 +1238,6 @@ bonito_mem_map(bus_space_tag_t t, bus_addr_t offs, bus_size_t size, int flags,
return 0;
}
- /*
- * No luck, try a PCIHI mapping.
- */
-
- /* may be used before curcpu() points to valid data */
- if ((cp0_get_prid() & 0xffff) ==
- ((MIPS_LOONGSON2 << 8) | (0x2f - 0x2c)))
- is2f = 1;
- else
- is2f = 0;
-
- if (is2f) {
- if (offs >= LS2F_PCIHI_BASE && end <= LS2F_PCIHI_TOP) {
- *bshp = t->bus_base + offs;
- return 0;
- }
- } else {
- /* PCI1.5 */
- if (offs >= BONITO_PCIHI_BASE && end <= BONITO_PCIHI_TOP) {
- *bshp = t->bus_base + offs;
- return 0;
- }
-
- /* PCI2 */
- w = pcimap & BONITO_PCIMAP_PCIMAP_2 ? 0x80000000UL : 0;
- if (offs >= w && end < (w + 0x80000000UL)) {
- *bshp = t->bus_base + 0x80000000UL + (offs - w);
- return 0;
- }
- }
-
return EINVAL;
}