Moved masking of PCI ressource bits into a single place.
Improved debug output and error reporting for I/O and interrupts resources. Init of ISA IDE or PCI IDE driver can now be seen in debug output, too. Verified that both still work with Vmware git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23142 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#define debug_level_info 2
|
||||
|
||||
#define DEBUG_MSG_PREFIX "IDE ISA -- "
|
||||
#define TRACE dprintf
|
||||
|
||||
#include "wrapper.h"
|
||||
|
||||
@@ -262,6 +263,8 @@ init_channel(device_node_handle node, ide_channel ide_channel, channel_info **co
|
||||
uint8 irq;
|
||||
status_t res;
|
||||
|
||||
TRACE("ISA-IDE: channel init\n");
|
||||
|
||||
// get device data
|
||||
if (pnp->get_attr_uint16(node, IDE_ISA_COMMAND_BLOCK_BASE, &command_block_base, false) != B_OK
|
||||
|| pnp->get_attr_uint16(node, IDE_ISA_CONTROL_BLOCK_BASE, &control_block_base, false) != B_OK
|
||||
@@ -277,6 +280,9 @@ init_channel(device_node_handle node, ide_channel ide_channel, channel_info **co
|
||||
goto err0;
|
||||
}
|
||||
|
||||
TRACE("ISA-IDE: channel init, resources %#x %#x %d\n",
|
||||
command_block_base, control_block_base, irq);
|
||||
|
||||
channel->isa = isa;
|
||||
channel->node = node;
|
||||
channel->lost = false;
|
||||
@@ -289,7 +295,7 @@ init_channel(device_node_handle node, ide_channel ide_channel, channel_info **co
|
||||
inthand, channel, 0);
|
||||
|
||||
if (res < 0) {
|
||||
SHOW_ERROR( 0, "couldn't install irq handler @%d", irq);
|
||||
TRACE("ISA-IDE: couldn't install irq handler for int %d\n", irq);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -313,6 +319,9 @@ static status_t
|
||||
uninit_channel(void *channel_cookie)
|
||||
{
|
||||
channel_info *channel = channel_cookie;
|
||||
|
||||
TRACE("ISA-IDE: channel uninit\n");
|
||||
|
||||
// disable IRQs
|
||||
write_device_control(channel, ide_devctrl_bit3 | ide_devctrl_nien);
|
||||
|
||||
@@ -365,6 +374,9 @@ publish_channel(device_node_handle parent, io_resource_handle *resources,
|
||||
|
||||
SHOW_FLOW0(2, "");
|
||||
|
||||
TRACE("ISA-IDE: publishing %s, resources %#x %#x %d\n",
|
||||
name, command_block_base, control_block_base, intnum);
|
||||
|
||||
return pnp->register_device(parent, attrs, resources, &node);
|
||||
}
|
||||
|
||||
@@ -386,8 +398,11 @@ probe_channel(device_node_handle parent,
|
||||
|
||||
// we aren't upset if io-ports are in use already - only
|
||||
// the PCI IDE driver can own them, and if it does, we exit silently
|
||||
if (pnp->acquire_io_resources(resources, resource_handles) != B_OK)
|
||||
if (pnp->acquire_io_resources(resources, resource_handles) != B_OK) {
|
||||
TRACE("ISA-IDE: can't acquire resources %#x and %#x\n",
|
||||
command_block_base, control_block_base);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// we assume that every modern PC has an IDE controller, so no
|
||||
// further testing is done (well - I don't really know how to detect the
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
#include "wrapper.h"
|
||||
|
||||
#define TRACE dprintf
|
||||
|
||||
|
||||
static ide_for_controller_interface *ide;
|
||||
static device_manager_info *pnp;
|
||||
@@ -330,6 +332,8 @@ ide_adapter_init_channel(device_node_handle node, ide_channel ide_channel,
|
||||
uint8 is_primary;
|
||||
status_t res;
|
||||
|
||||
TRACE("PCI-IDE: init channel...\n");
|
||||
|
||||
// get device data
|
||||
if (pnp->get_attr_uint16(node, IDE_ADAPTER_COMMAND_BLOCK_BASE, &command_block_base, false) != B_OK
|
||||
|| pnp->get_attr_uint16(node, IDE_ADAPTER_CONTROL_BLOCK_BASE, &control_block_base, false) != B_OK
|
||||
@@ -380,6 +384,7 @@ ide_adapter_init_channel(device_node_handle node, ide_channel ide_channel,
|
||||
goto err3;
|
||||
}
|
||||
|
||||
TRACE("PCI-IDE: init channel done\n");
|
||||
// enable interrupts so the channel is ready to run
|
||||
ide_adapter_write_device_control(channel, ide_devctrl_bit3);
|
||||
|
||||
@@ -484,25 +489,31 @@ ide_adapter_detect_channel(pci_device_module_info *pci, pci_device pci_device,
|
||||
command_block_base = 0x1f0;
|
||||
control_block_base = 0x3f6;
|
||||
intnum = 14;
|
||||
TRACE("PCI-IDE: Controller in legacy mode: cmd %#x, ctrl %#x, irq %d\n",
|
||||
command_block_base, control_block_base, intnum);
|
||||
} else if (supports_compatibility_mode
|
||||
&& !is_primary && (api & IDE_API_PRIMARY_NATIVE) == 0) {
|
||||
command_block_base = 0x170;
|
||||
control_block_base = 0x376;
|
||||
intnum = 15;
|
||||
TRACE("PCI-IDE: Controller in legacy mode: cmd %#x, ctrl %#x, irq %d\n",
|
||||
command_block_base, control_block_base, intnum);
|
||||
} else {
|
||||
if ((command_block_base & PCI_address_space) != PCI_address_space
|
||||
|| (control_block_base & PCI_address_space) != PCI_address_space) {
|
||||
SHOW_ERROR0( 2, "Command/Control Block base is not configured" );
|
||||
if (command_block_base == 0 || control_block_base == 0) {
|
||||
TRACE("PCI-IDE: Command/Control Block base is not configured\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
if (intnum == 0 || intnum == 0xff) {
|
||||
TRACE("PCI-IDE: Interrupt is not configured\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
command_block_base &= ~PCI_address_space;
|
||||
control_block_base &= ~PCI_address_space;
|
||||
|
||||
// historically, they start at 3f6h/376h, but PCI spec requires registers
|
||||
// to be aligned at 4 bytes, so only 3f4h/374h can be specified; thus
|
||||
// PCI IDE defines that control block starts at offset 2
|
||||
control_block_base += 2;
|
||||
TRACE("PCI-IDE: Controller in native mode: cmd %#x, ctrl %#x, irq %d\n",
|
||||
command_block_base, control_block_base, intnum);
|
||||
}
|
||||
|
||||
if (supports_compatibility_mode) {
|
||||
@@ -516,13 +527,15 @@ ide_adapter_detect_channel(pci_device_module_info *pci, pci_device pci_device,
|
||||
// better were to use a controller lock, but this had to be done in the IDE
|
||||
// bus manager, and I don't see any reason to add extra code for old
|
||||
// simplex controllers
|
||||
SHOW_INFO0( 2, "Simplex controller - disabling DMA of secondary channel" );
|
||||
TRACE("PCI-IDE: Simplex controller - disabling DMA of secondary channel\n");
|
||||
controller_can_dma = false;
|
||||
}
|
||||
}
|
||||
|
||||
bus_master_base += is_primary ? 0 : 8;
|
||||
|
||||
TRACE("PCI-IDE: bus master base %#x\n", bus_master_base);
|
||||
|
||||
{
|
||||
// allocate channel's I/O resources
|
||||
io_resource resources[3] = {
|
||||
@@ -532,7 +545,8 @@ ide_adapter_detect_channel(pci_device_module_info *pci, pci_device pci_device,
|
||||
};
|
||||
|
||||
if (pnp->acquire_io_resources(resources, resource_handles) != B_OK) {
|
||||
SHOW_ERROR( 2, "Couldn't acquire channel resources %d and %d\n", command_block_base, control_block_base);
|
||||
TRACE("PCI-IDE: Couldn't acquire channel resources %#x and %#x\n",
|
||||
command_block_base, control_block_base);
|
||||
return B_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -658,10 +672,10 @@ ide_adapter_detect_controller(pci_device_module_info *pci, pci_device pci_device
|
||||
|
||||
SHOW_FLOW0( 3, "" );
|
||||
|
||||
if ((bus_master_base & PCI_address_space) != 1)
|
||||
return B_OK;
|
||||
|
||||
bus_master_base &= ~PCI_address_space;
|
||||
if (bus_master_base == 0) {
|
||||
TRACE("PCI-IDE: Controller detection failed! bus master base not configured\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
{
|
||||
io_resource resources[2] = {
|
||||
@@ -670,7 +684,7 @@ ide_adapter_detect_controller(pci_device_module_info *pci, pci_device pci_device
|
||||
};
|
||||
|
||||
if (pnp->acquire_io_resources(resources, resource_handles) != B_OK) {
|
||||
SHOW_ERROR( 2, "Couldn't acquire controller resource %d\n", bus_master_base);
|
||||
TRACE("PCI-IDE: Couldn't acquire controller resource %#x\n", bus_master_base);
|
||||
return B_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -708,6 +722,12 @@ ide_adapter_probe_controller(device_node_handle parent, const char *controller_d
|
||||
bus_master_base = pci->read_pci_config(device, PCI_base_registers + 16, 4);
|
||||
intnum = pci->read_pci_config(device, PCI_interrupt_line, 1);
|
||||
|
||||
command_block_base[0] &= ~PCI_address_space;
|
||||
control_block_base[0] &= ~PCI_address_space;
|
||||
command_block_base[1] &= ~PCI_address_space;
|
||||
control_block_base[1] &= ~PCI_address_space;
|
||||
bus_master_base &= ~PCI_address_space;
|
||||
|
||||
res = ide_adapter_detect_controller(pci, device, parent, bus_master_base,
|
||||
controller_driver, controller_driver_type, controller_name, can_dma,
|
||||
can_cq, dma_alignment, dma_boundary, max_sg_block_size, &controller_node);
|
||||
@@ -716,8 +736,6 @@ ide_adapter_probe_controller(device_node_handle parent, const char *controller_d
|
||||
if (res != B_OK || controller_node == NULL)
|
||||
goto err;
|
||||
|
||||
bus_master_base &= ~PCI_address_space;
|
||||
|
||||
// ignore errors during registration of channels - could be a simple rescan collision
|
||||
ide_adapter_detect_channel(pci, device, controller_node, channel_module_name,
|
||||
can_dma, command_block_base[0], control_block_base[0], bus_master_base,
|
||||
|
||||
Reference in New Issue
Block a user