Return status for PCI methods '{enable,disable}_{io,busmaster}'.

Reviewed by:	imp
This commit is contained in:
mdodd 2003-04-16 03:15:08 +00:00
parent b70cb804f5
commit c0d9a22c37
4 changed files with 65 additions and 25 deletions

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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);

View File

@ -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));
}
/*