aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMatthew N. Dodd <mdodd@FreeBSD.org>2003-04-16 03:15:08 +0000
committerMatthew N. Dodd <mdodd@FreeBSD.org>2003-04-16 03:15:08 +0000
commitc047e5b1a9d3c13f345a17a28dbb2569ad68d123 (patch)
treecf23c71c7e34af0cfac5b28b2ffe945c0e186ffe /sys
parent9dc7076193d52c5eaaa7fd0820ebc0956291541b (diff)
downloadsrc-c047e5b1a9d3c13f345a17a28dbb2569ad68d123.tar.gz
src-c047e5b1a9d3c13f345a17a28dbb2569ad68d123.zip
Return status for PCI methods '{enable,disable}_{io,busmaster}'.
Reviewed by: imp
Notes
Notes: svn path=/head/; revision=113544
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/pci.c58
-rw-r--r--sys/dev/pci/pci_if.m8
-rw-r--r--sys/dev/pci/pci_private.h8
-rw-r--r--sys/dev/pci/pcivar.h16
4 files changed, 65 insertions, 25 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index 51fe63b9440f..372a08278c1a 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -568,42 +568,81 @@ pci_clear_command_bit(device_t dev, device_t child, u_int16_t bit)
PCI_WRITE_CONFIG(dev, child, PCIR_COMMAND, command, 2);
}
-void
+int
pci_enable_busmaster_method(device_t dev, device_t child)
{
pci_set_command_bit(dev, child, PCIM_CMD_BUSMASTEREN);
+ return (0);
}
-void
+int
pci_disable_busmaster_method(device_t dev, device_t child)
{
pci_clear_command_bit(dev, child, PCIM_CMD_BUSMASTEREN);
+ return (0);
}
-void
+int
pci_enable_io_method(device_t dev, device_t child, int space)
{
+ u_int16_t command;
+ u_int16_t bit;
+ char *error;
+
+ bit = 0;
+ error = NULL;
+
switch(space) {
case SYS_RES_IOPORT:
- pci_set_command_bit(dev, child, PCIM_CMD_PORTEN);
+ bit = PCIM_CMD_PORTEN;
+ error = "port";
break;
case SYS_RES_MEMORY:
- pci_set_command_bit(dev, child, PCIM_CMD_MEMEN);
+ bit = PCIM_CMD_MEMEN;
+ error = "memory";
+ break;
+ default:
+ return (EINVAL);
break;
}
+ pci_set_command_bit(dev, child, bit);
+ command = PCI_READ_CONFIG(dev, child, PCIR_COMMAND, 2);
+ if (command & bit)
+ return (0);
+ device_printf(child, "failed to enable %s mapping!\n", error);
+ return (ENXIO);
}
-void
+int
pci_disable_io_method(device_t dev, device_t child, int space)
{
+ u_int16_t command;
+ u_int16_t bit;
+ char *error;
+
+ bit = 0;
+ error = NULL;
+
switch(space) {
case SYS_RES_IOPORT:
- pci_clear_command_bit(dev, child, PCIM_CMD_PORTEN);
+ bit = PCIM_CMD_PORTEN;
+ error = "port";
break;
case SYS_RES_MEMORY:
- pci_clear_command_bit(dev, child, PCIM_CMD_MEMEN);
+ bit = PCIM_CMD_MEMEN;
+ error = "memory";
+ break;
+ default:
+ return (EINVAL);
break;
}
+ pci_clear_command_bit(dev, child, bit);
+ command = PCI_READ_CONFIG(dev, child, PCIR_COMMAND, 2);
+ if (command & bit) {
+ device_printf(child, "failed to disable %s mapping!\n", error);
+ return (ENXIO);
+ }
+ return (0);
}
/*
@@ -1326,7 +1365,8 @@ pci_alloc_resource(device_t dev, device_t child, int type, int *rid,
* Enable the I/O mode. We should also be allocating
* resources too. XXX
*/
- PCI_ENABLE_IO(dev, child, type);
+ if (PCI_ENABLE_IO(dev, child, type))
+ return (NULL);
break;
}
}
diff --git a/sys/dev/pci/pci_if.m b/sys/dev/pci/pci_if.m
index 8dab04e33554..bd1956507d68 100644
--- a/sys/dev/pci/pci_if.m
+++ b/sys/dev/pci/pci_if.m
@@ -56,23 +56,23 @@ METHOD int set_powerstate {
int state;
};
-METHOD void enable_busmaster {
+METHOD int enable_busmaster {
device_t dev;
device_t child;
};
-METHOD void disable_busmaster {
+METHOD int disable_busmaster {
device_t dev;
device_t child;
};
-METHOD void enable_io {
+METHOD int enable_io {
device_t dev;
device_t child;
int space;
};
-METHOD void disable_io {
+METHOD int disable_io {
device_t dev;
device_t child;
int space;
diff --git a/sys/dev/pci/pci_private.h b/sys/dev/pci/pci_private.h
index 10649975f145..f0387d068fe5 100644
--- a/sys/dev/pci/pci_private.h
+++ b/sys/dev/pci/pci_private.h
@@ -54,10 +54,10 @@ u_int32_t pci_read_config_method(device_t dev, device_t child,
int reg, int width);
void pci_write_config_method(device_t dev, device_t child,
int reg, u_int32_t val, int width);
-void pci_enable_busmaster_method(device_t dev, device_t child);
-void pci_disable_busmaster_method(device_t dev, device_t child);
-void pci_enable_io_method(device_t dev, device_t child, int space);
-void pci_disable_io_method(device_t dev, device_t child, int space);
+int pci_enable_busmaster_method(device_t dev, device_t child);
+int pci_disable_busmaster_method(device_t dev, device_t child);
+int pci_enable_io_method(device_t dev, device_t child, int space);
+int pci_disable_io_method(device_t dev, device_t child, int space);
struct resource *pci_alloc_resource(device_t dev, device_t child,
int type, int *rid, u_long start, u_long end, u_long count,
u_int flags);
diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h
index 45df9e4f58c2..53ad3a0355f3 100644
--- a/sys/dev/pci/pcivar.h
+++ b/sys/dev/pci/pcivar.h
@@ -249,28 +249,28 @@ PCIB_ACCESSOR(bus, BUS, u_int32_t)
* These should be used in preference to manually manipulating
* configuration space.
*/
-static __inline void
+static __inline int
pci_enable_busmaster(device_t dev)
{
- PCI_ENABLE_BUSMASTER(device_get_parent(dev), dev);
+ return(PCI_ENABLE_BUSMASTER(device_get_parent(dev), dev));
}
-static __inline void
+static __inline int
pci_disable_busmaster(device_t dev)
{
- PCI_DISABLE_BUSMASTER(device_get_parent(dev), dev);
+ return(PCI_DISABLE_BUSMASTER(device_get_parent(dev), dev));
}
-static __inline void
+static __inline int
pci_enable_io(device_t dev, int space)
{
- PCI_ENABLE_IO(device_get_parent(dev), dev, space);
+ return(PCI_ENABLE_IO(device_get_parent(dev), dev, space));
}
-static __inline void
+static __inline int
pci_disable_io(device_t dev, int space)
{
- PCI_DISABLE_IO(device_get_parent(dev), dev, space);
+ return(PCI_DISABLE_IO(device_get_parent(dev), dev, space));
}
/*