void device_node::Dump(int32 level) { put_level(level); kprintf("(%" B_PRId32 ") @%p \"%s\" (ref %" B_PRId32 ", init %" B_PRId32 ", module %p, data %p)\n", level, this, ModuleName(), fRefCount, fInitialized, DriverModule(), DriverData()); AttributeList::Iterator attribute = Attributes().GetIterator(); while (attribute.HasNext()) { dump_attribute(attribute.Next(), level); } DeviceList::Iterator deviceIterator = fDevices.GetIterator(); while (deviceIterator.HasNext()) { Device* device = deviceIterator.Next(); put_level(level); kprintf("device: %s, %p\n", device->ModuleName(), device->Data()); } NodeList::ConstIterator iterator = Children().GetIterator(); while (iterator.HasNext()) { iterator.Next()->Dump(level + 1); } }
static void dump_attribute(struct device_attr_info *attr, int32 level) { if (attr == NULL) return; put_level(level); printf("\"%s\" : ", attr->name); switch (attr->type) { case B_STRING_TYPE: printf("string : \"%s\"", attr->value.string); break; case B_UINT8_TYPE: printf("uint8 : %" B_PRIu8 " (%#" B_PRIx8 ")", attr->value.ui8, attr->value.ui8); break; case B_UINT16_TYPE: printf("uint16 : %" B_PRIu16 " (%#" B_PRIx16 ")", attr->value.ui16, attr->value.ui16); break; case B_UINT32_TYPE: printf("uint32 : %" B_PRIu32 " (%#" B_PRIx32 ")", attr->value.ui32, attr->value.ui32); break; case B_UINT64_TYPE: printf("uint64 : %" B_PRIu64 " (%#" B_PRIx64 ")", attr->value.ui64, attr->value.ui64); break; default: printf("raw data"); } printf("\n"); }
static void dump_device(device_node_cookie *node, uint8 level) { char data[256]; struct device_attr_info attr; attr.cookie = 0; attr.node_cookie = *node; attr.value.raw.data = data; attr.value.raw.length = sizeof(data); put_level(level); printf("(%d)\n", level); while (dm_get_next_attr(&attr) == B_OK) { dump_attribute(&attr, level); } }
static int32 display_device(device_node_cookie *node, uint8 level) { uint8 new_level = level; char data[256]; struct device_attr_info attr; // BUS attributes char device_bus[64]; uint8 scsi_path_id = 255; int bus = 0; // PCI attributes uint8 pci_class_base_id = 0; uint8 pci_class_sub_id = 0; uint8 pci_class_api_id = 0; uint16 pci_vendor_id = 0; uint16 pci_device_id = 0; uint16 pci_subsystem_vendor_id = 0; uint16 pci_subsystem_id = 0; // SCSI attributes uint8 scsi_target_lun = 0; uint8 scsi_target_id = 0; uint8 scsi_type = 255; char scsi_vendor[64]; char scsi_product[64]; const char *venShort; const char *venFull; const char *devShort; const char *devFull; attr.cookie = 0; attr.node_cookie = *node; attr.value.raw.data = data; attr.value.raw.length = sizeof(data); while (dm_get_next_attr(&attr) == B_OK) { if (!strcmp(attr.name, B_DEVICE_BUS) && attr.type == B_STRING_TYPE) { strlcpy(device_bus, attr.value.string, 64); } else if (!strcmp(attr.name, "scsi/path_id") && attr.type == B_UINT8_TYPE) { scsi_path_id = attr.value.ui8; } else if (!strcmp(attr.name, B_DEVICE_TYPE) && attr.type == B_UINT16_TYPE) pci_class_base_id = attr.value.ui8; else if (!strcmp(attr.name, B_DEVICE_SUB_TYPE) && attr.type == B_UINT16_TYPE) pci_class_sub_id = attr.value.ui8; else if (!strcmp(attr.name, B_DEVICE_INTERFACE) && attr.type == B_UINT16_TYPE) pci_class_api_id = attr.value.ui8; else if (!strcmp(attr.name, B_DEVICE_VENDOR_ID) && attr.type == B_UINT16_TYPE) pci_vendor_id = attr.value.ui16; else if (!strcmp(attr.name, B_DEVICE_ID) && attr.type == B_UINT16_TYPE) pci_device_id = attr.value.ui16; else if (!strcmp(attr.name, SCSI_DEVICE_TARGET_LUN_ITEM) && attr.type == B_UINT8_TYPE) scsi_target_lun = attr.value.ui8; else if (!strcmp(attr.name, SCSI_DEVICE_TARGET_ID_ITEM) && attr.type == B_UINT8_TYPE) scsi_target_id = attr.value.ui8; else if (!strcmp(attr.name, SCSI_DEVICE_TYPE_ITEM) && attr.type == B_UINT8_TYPE) scsi_type = attr.value.ui8; else if (!strcmp(attr.name, SCSI_DEVICE_VENDOR_ITEM) && attr.type == B_STRING_TYPE) strlcpy(scsi_vendor, attr.value.string, 64); else if (!strcmp(attr.name, SCSI_DEVICE_PRODUCT_ITEM) && attr.type == B_STRING_TYPE) strlcpy(scsi_product, attr.value.string, 64); if (!strcmp(device_bus, "isa")) bus = BUS_ISA; else if (!strcmp(device_bus, "pci")) bus = BUS_PCI; else if (scsi_path_id < 255) bus = BUS_SCSI; /*else if (!strcmp(attr.name, PCI_DEVICE_SUBVENDOR_ID_ITEM) && attr.type == B_UINT16_TYPE) pci_subsystem_vendor_id = attr.value.ui16; else if (!strcmp(attr.name, PCI_DEVICE_SUBSYSTEM_ID_ITEM) && attr.type == B_UINT16_TYPE) pci_subsystem_id = attr.value.ui16;*/ attr.value.raw.data = data; attr.value.raw.length = sizeof(data); } switch (bus) { case BUS_ISA: new_level = level + 1; break; case BUS_PCI: printf("\n"); { char classInfo[64]; get_class_info(pci_class_base_id, pci_class_sub_id, pci_class_api_id, classInfo, 64); put_level(level); printf("device %s [%x|%x|%x]\n", classInfo, pci_class_base_id, pci_class_sub_id, pci_class_api_id); } put_level(level); printf(" "); get_vendor_info(pci_vendor_id, &venShort, &venFull); if (!venShort && !venFull) { printf("vendor %04x: Unknown\n", pci_vendor_id); } else if (venShort && venFull) { printf("vendor %04x: %s - %s\n", pci_vendor_id, venShort, venFull); } else { printf("vendor %04x: %s\n", pci_vendor_id, venShort ? venShort : venFull); } put_level(level); printf(" "); get_device_info(pci_vendor_id, pci_device_id, pci_subsystem_vendor_id, pci_subsystem_id, &devShort, &devFull); if (!devShort && !devFull) { printf("device %04x: Unknown\n", pci_device_id); } else if (devShort && devFull) { printf("device %04x: %s (%s)\n", pci_device_id, devShort, devFull); } else { printf("device %04x: %s\n", pci_device_id, devShort ? devShort : devFull); } new_level = level + 1; break; case BUS_SCSI: if (scsi_type == 255) break; put_level(level); printf(" device [%x|%x]\n", scsi_target_id, scsi_target_lun); put_level(level); printf(" vendor %15s\tmodel %15s\ttype %s\n", scsi_vendor, scsi_product, get_scsi_device_type(scsi_type)); new_level = level + 1; break; } return new_level; }