reworked device identification, calmed down debug output

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19863 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Marcus Overhagen
2007-01-18 22:44:11 +00:00
parent 57205205ed
commit ef6a7a6308
2 changed files with 29 additions and 46 deletions
+9 -23
View File
@@ -11,8 +11,8 @@
#include <bus/ide/ide_adapter.h> #include <bus/ide/ide_adapter.h>
#include <block_io.h> #include <block_io.h>
#define TRACE(a...) dprintf("ahci " a) #define TRACE(a...) dprintf("ahci: " a)
#define FLOW(a...) dprintf("ahci " a) #define FLOW(a...) dprintf("ahci: " a)
#define DRIVER_PRETTY_NAME "AHCI SATA" #define DRIVER_PRETTY_NAME "AHCI SATA"
@@ -120,11 +120,9 @@ controller_supports(device_node_handle parent, bool *_noConnection)
char *bus; char *bus;
uint16 vendor_id; uint16 vendor_id;
uint16 device_id; uint16 device_id;
uint16 base_class; uint8 base_class;
uint16 sub_class; uint8 sub_class;
uint16 class_api; uint8 class_api;
FLOW("controller_supports\n");
// get the bus (should be PCI) // get the bus (should be PCI)
if (dm->get_attr_string(parent, B_DRIVER_BUS, &bus, false) != B_OK) if (dm->get_attr_string(parent, B_DRIVER_BUS, &bus, false) != B_OK)
@@ -142,24 +140,12 @@ controller_supports(device_node_handle parent, bool *_noConnection)
|| dm->get_attr_uint8(parent, PCI_DEVICE_API_ID_ITEM, &class_api, false) != B_OK) || dm->get_attr_uint8(parent, PCI_DEVICE_API_ID_ITEM, &class_api, false) != B_OK)
return B_ERROR; return B_ERROR;
FLOW("controller_supports: checking vendor 0x%04x, device 0x%04x, base 0x%02x, sub 0x%02x, api 0x%02x\n", if (base_class != PCI_mass_storage || sub_class != PCI_sata || class_api != PCI_sata_ahci)
vendor_id, device_id, base_class, sub_class, class_api); return 0.0f;
#define ID(v,d) (((v)<< 16) | (d)) TRACE("controller found! vendor 0x%04x, device 0x%04x\n", vendor_id, device_id);
switch (ID(vendor_id,device_id)) {
case ID(0x197b, 0x2363): // JMicron
TRACE("controller_supports success, exact match\n");
return 0.8;
default:
break;
}
if (base_class == PCI_mass_storage && sub_class == PCI_sata && class_api == PCI_sata_ahci) { return 0.8f;
TRACE("controller_supports success, class match\n");
return 0.6;
}
return 0.0;
} }
@@ -11,8 +11,8 @@
#include <bus/ide/ide_adapter.h> #include <bus/ide/ide_adapter.h>
#include <block_io.h> #include <block_io.h>
#define TRACE(a...) dprintf("si-3112 " a) #define TRACE(a...) dprintf("si-3112: " a)
#define FLOW(a...) dprintf("si-3112 " a) #define FLOW(a...) dprintf("si-3112: " a)
#define DRIVER_PRETTY_NAME "Silicon Image SATA" #define DRIVER_PRETTY_NAME "Silicon Image SATA"
@@ -118,40 +118,37 @@ static float
controller_supports(device_node_handle parent, bool *_noConnection) controller_supports(device_node_handle parent, bool *_noConnection)
{ {
char *bus; char *bus;
uint16 vendorID; uint16 vendor_id;
uint16 deviceID; uint16 device_id;
FLOW("controller_supports\n");
// get the bus (should be PCI) // get the bus (should be PCI)
if (dm->get_attr_string(parent, B_DRIVER_BUS, &bus, false) if (dm->get_attr_string(parent, B_DRIVER_BUS, &bus, false) != B_OK)
!= B_OK) { return B_ERROR;
if (strcmp(bus, "pci") != 0) {
free(bus);
return B_ERROR; return B_ERROR;
} }
free(bus);
// get vendor and device ID // get vendor and device ID
if (dm->get_attr_uint16(parent, PCI_DEVICE_VENDOR_ID_ITEM, if (dm->get_attr_uint16(parent, PCI_DEVICE_VENDOR_ID_ITEM, &vendor_id, false) != B_OK
&vendorID, false) != B_OK || dm->get_attr_uint16(parent, PCI_DEVICE_DEVICE_ID_ITEM, &device_id, false) != B_OK) {
|| dm->get_attr_uint16(parent, PCI_DEVICE_DEVICE_ID_ITEM,
&deviceID, false) != B_OK) {
free(bus);
return B_ERROR; return B_ERROR;
} }
FLOW("controller_supports: checking 0x%04x 0x%04x\n", vendorID, deviceID);
// check, whether bus, vendor and device ID match #define ID(v,d) (((v)<< 16) | (d))
if (strcmp(bus, "pci") != 0 switch (ID(vendor_id, device_id)) {
|| (vendorID != 0x1095) case ID(0x1095, 0x3112):
|| (deviceID != 0x3112 && deviceID != 0x3114)) { case ID(0x1095, 0x3114):
free(bus); break;
return 0.0; default:
return 0.0f;
} }
TRACE("controller_supports success\n"); TRACE("controller found! vendor 0x%04x, device 0x%04x\n", vendor_id, device_id);
free(bus); return 0.8f;
return 0.6;
} }