diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-04-10 17:11:28 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-04-10 17:11:28 +0000 |
commit | 828e39dd4175b6cff126784cfef676e999e1de41 (patch) | |
tree | 883ffaa1d452b62ae649f64d5bd0583ba6eb3c16 /sys | |
parent | 2abd8088203a94e8c702a1334365d88b518d0bf1 (diff) |
When deciding whether a sti@pci board is the console, compare all valid BAR
addresses against PAGE0 information, instead than only the BAR mapping
sti region #0; on Visualize FXe, PAGE0 will point to another BAR and we would
not recognize the display as the console device.
Tested on Visualize FX4 (on C240), Visualize EG (on B1000) and Visualize FXe
(on B2000).
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/hppa/dev/sti_pci_machdep.c | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/sys/arch/hppa/dev/sti_pci_machdep.c b/sys/arch/hppa/dev/sti_pci_machdep.c index d90b1fdc55b..169e10c1cbc 100644 --- a/sys/arch/hppa/dev/sti_pci_machdep.c +++ b/sys/arch/hppa/dev/sti_pci_machdep.c @@ -1,7 +1,7 @@ -/* $OpenBSD: sti_pci_machdep.c,v 1.1 2007/01/11 22:06:39 miod Exp $ */ +/* $OpenBSD: sti_pci_machdep.c,v 1.2 2009/04/10 17:11:27 miod Exp $ */ /* - * Copyright (c) 2007 Miodrag Vallat. + * Copyright (c) 2007, 2009 Miodrag Vallat. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -31,5 +31,47 @@ int sti_pci_is_console(struct pci_attach_args *, bus_addr_t *); int sti_pci_is_console(struct pci_attach_args *paa, bus_addr_t *bases) { - return ((hppa_hpa_t)bases[0] == (hppa_hpa_t)PAGE0->mem_cons.pz_hpa); + u_int32_t cf; + bus_addr_t addr; + int bar; + int rc; + + /* + * PAGE0 console information will point to one of our BARs, + * but depending on the particular sti model, this might not + * be the BAR mapping the rom (region #0). + * + * For example, on Visualize FXe, regions #0, #2 and #3 are + * mapped by BAR 0x18, while region #1 is mapped by BAR 0x10, + * which matches PAGE0 console address. + * + * Rather than trying to be smart, reread the region->BAR array + * again, and compare the BAR mapping region #1 against PAGE0 + * values, we simply try all the valid BARs; if any of them + * matches what PAGE0 says, then we are the console, and it + * doesn't matter which BAR matched. + */ + for (bar = PCI_MAPREG_START; bar <= PCI_MAPREG_PPB_END; ) { + cf = pci_conf_read(paa->pa_pc, paa->pa_tag, bar); + + if (PCI_MAPREG_TYPE(cf) == PCI_MAPREG_TYPE_IO) { + rc = pci_io_find(paa->pa_pc, paa->pa_tag, bar, &addr, + NULL); + bar += 4; + } else { + rc = pci_mem_find(paa->pa_pc, paa->pa_tag, bar, &addr, + NULL, NULL); + if (PCI_MAPREG_MEM_TYPE(cf) == + PCI_MAPREG_MEM_TYPE_64BIT) + bar += 8; + else + bar += 4; + } + + if (rc == 0 && + (hppa_hpa_t)addr == (hppa_hpa_t)PAGE0->mem_cons.pz_hpa) + return 1; + } + + return 0; } |