summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2006-06-25 07:44:55 +0000
committerBrad Smith <brad@cvs.openbsd.org>2006-06-25 07:44:55 +0000
commitbf1a2f7e3abcfa73e535aee6d2f2ea5ab6254823 (patch)
tree1db6852c98bebcd72bf85766129b09d8d78f214c /sys
parent0694b73a7a808a264fc311d9e757c669337c140d (diff)
reorganize the code to be more sane.
ok toby@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/i386/pci/pci_machdep.c150
1 files changed, 46 insertions, 104 deletions
diff --git a/sys/arch/i386/pci/pci_machdep.c b/sys/arch/i386/pci/pci_machdep.c
index 15d8a88e842..b7690fb9d66 100644
--- a/sys/arch/i386/pci/pci_machdep.c
+++ b/sys/arch/i386/pci/pci_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_machdep.c,v 1.32 2006/06/02 19:39:49 pascoe Exp $ */
+/* $OpenBSD: pci_machdep.c,v 1.33 2006/06/25 07:44:54 brad Exp $ */
/* $NetBSD: pci_machdep.c,v 1.28 1997/06/06 23:29:17 thorpej Exp $ */
/*-
@@ -207,41 +207,27 @@ pci_make_tag(pc, bus, device, function)
{
pcitag_t tag;
-#ifndef PCI_CONF_MODE
switch (pci_mode) {
case 1:
- goto mode1;
+ if (bus >= 256 || device >= 32 || function >= 8)
+ panic("pci_make_tag: bad request");
+
+ tag.mode1 = PCI_MODE1_ENABLE |
+ (bus << 16) | (device << 11) | (function << 8);
+ break;
case 2:
- goto mode2;
+ if (bus >= 256 || device >= 16 || function >= 8)
+ panic("pci_make_tag: bad request");
+
+ tag.mode2.port = 0xc000 | (device << 8);
+ tag.mode2.enable = 0xf0 | (function << 1);
+ tag.mode2.forward = bus;
+ break;
default:
panic("pci_make_tag: mode not configured");
}
-#endif
-
-#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 1)
-#ifndef PCI_CONF_MODE
-mode1:
-#endif
- if (bus >= 256 || device >= 32 || function >= 8)
- panic("pci_make_tag: bad request");
-
- tag.mode1 = PCI_MODE1_ENABLE |
- (bus << 16) | (device << 11) | (function << 8);
- return tag;
-#endif
-
-#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 2)
-#ifndef PCI_CONF_MODE
-mode2:
-#endif
- if (bus >= 256 || device >= 16 || function >= 8)
- panic("pci_make_tag: bad request");
- tag.mode2.port = 0xc000 | (device << 8);
- tag.mode2.enable = 0xf0 | (function << 1);
- tag.mode2.forward = bus;
return tag;
-#endif
}
void
@@ -251,41 +237,26 @@ pci_decompose_tag(pc, tag, bp, dp, fp)
int *bp, *dp, *fp;
{
-#ifndef PCI_CONF_MODE
switch (pci_mode) {
case 1:
- goto mode1;
+ if (bp != NULL)
+ *bp = (tag.mode1 >> 16) & 0xff;
+ if (dp != NULL)
+ *dp = (tag.mode1 >> 11) & 0x1f;
+ if (fp != NULL)
+ *fp = (tag.mode1 >> 8) & 0x7;
+ break;
case 2:
- goto mode2;
+ if (bp != NULL)
+ *bp = tag.mode2.forward & 0xff;
+ if (dp != NULL)
+ *dp = (tag.mode2.port >> 8) & 0xf;
+ if (fp != NULL)
+ *fp = (tag.mode2.enable >> 1) & 0x7;
+ break;
default:
panic("pci_decompose_tag: mode not configured");
}
-#endif
-
-#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 1)
-#ifndef PCI_CONF_MODE
-mode1:
-#endif
- if (bp != NULL)
- *bp = (tag.mode1 >> 16) & 0xff;
- if (dp != NULL)
- *dp = (tag.mode1 >> 11) & 0x1f;
- if (fp != NULL)
- *fp = (tag.mode1 >> 8) & 0x7;
- return;
-#endif
-
-#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 2)
-#ifndef PCI_CONF_MODE
-mode2:
-#endif
- if (bp != NULL)
- *bp = tag.mode2.forward & 0xff;
- if (dp != NULL)
- *dp = (tag.mode2.port >> 8) & 0xf;
- if (fp != NULL)
- *fp = (tag.mode2.enable >> 1) & 0x7;
-#endif
}
pcireg_t
@@ -296,37 +267,23 @@ pci_conf_read(pc, tag, reg)
{
pcireg_t data;
-#ifndef PCI_CONF_MODE
switch (pci_mode) {
case 1:
- goto mode1;
+ outl(PCI_MODE1_ADDRESS_REG, tag.mode1 | reg);
+ data = inl(PCI_MODE1_DATA_REG);
+ outl(PCI_MODE1_ADDRESS_REG, 0);
+ break;
case 2:
- goto mode2;
+ outb(PCI_MODE2_ENABLE_REG, tag.mode2.enable);
+ outb(PCI_MODE2_FORWARD_REG, tag.mode2.forward);
+ data = inl(tag.mode2.port | reg);
+ outb(PCI_MODE2_ENABLE_REG, 0);
+ break;
default:
panic("pci_conf_read: mode not configured");
}
-#endif
-#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 1)
-#ifndef PCI_CONF_MODE
-mode1:
-#endif
- outl(PCI_MODE1_ADDRESS_REG, tag.mode1 | reg);
- data = inl(PCI_MODE1_DATA_REG);
- outl(PCI_MODE1_ADDRESS_REG, 0);
return data;
-#endif
-
-#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 2)
-#ifndef PCI_CONF_MODE
-mode2:
-#endif
- outb(PCI_MODE2_ENABLE_REG, tag.mode2.enable);
- outb(PCI_MODE2_FORWARD_REG, tag.mode2.forward);
- data = inl(tag.mode2.port | reg);
- outb(PCI_MODE2_ENABLE_REG, 0);
- return data;
-#endif
}
void
@@ -337,36 +294,21 @@ pci_conf_write(pc, tag, reg, data)
pcireg_t data;
{
-#ifndef PCI_CONF_MODE
switch (pci_mode) {
case 1:
- goto mode1;
+ outl(PCI_MODE1_ADDRESS_REG, tag.mode1 | reg);
+ outl(PCI_MODE1_DATA_REG, data);
+ outl(PCI_MODE1_ADDRESS_REG, 0);
+ break;
case 2:
- goto mode2;
+ outb(PCI_MODE2_ENABLE_REG, tag.mode2.enable);
+ outb(PCI_MODE2_FORWARD_REG, tag.mode2.forward);
+ outl(tag.mode2.port | reg, data);
+ outb(PCI_MODE2_ENABLE_REG, 0);
+ break;
default:
panic("pci_conf_write: mode not configured");
}
-#endif
-
-#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 1)
-#ifndef PCI_CONF_MODE
-mode1:
-#endif
- outl(PCI_MODE1_ADDRESS_REG, tag.mode1 | reg);
- outl(PCI_MODE1_DATA_REG, data);
- outl(PCI_MODE1_ADDRESS_REG, 0);
- return;
-#endif
-
-#if !defined(PCI_CONF_MODE) || (PCI_CONF_MODE == 2)
-#ifndef PCI_CONF_MODE
-mode2:
-#endif
- outb(PCI_MODE2_ENABLE_REG, tag.mode2.enable);
- outb(PCI_MODE2_FORWARD_REG, tag.mode2.forward);
- outl(tag.mode2.port | reg, data);
- outb(PCI_MODE2_ENABLE_REG, 0);
-#endif
}
int