コード例 #1
0
ファイル: DevicePCI.cpp プロジェクト: AmirAbrams/haiku
void
DevicePCI::InitFromAttributes()
{
	// Process the attributes
	fClassBaseId = atoi(fAttributeMap[B_DEVICE_TYPE].String());
	fClassSubId = atoi(fAttributeMap[B_DEVICE_SUB_TYPE].String());
	fClassApiId = atoi(fAttributeMap[B_DEVICE_INTERFACE].String());
	fVendorId = atoi(fAttributeMap[B_DEVICE_VENDOR_ID].String());
	fDeviceId = atoi(fAttributeMap[B_DEVICE_ID].String());

	// Looks better in Hex, so rewrite
	fAttributeMap[B_DEVICE_TYPE] = ToHex(fClassBaseId);
	fAttributeMap[B_DEVICE_SUB_TYPE] = ToHex(fClassSubId);
	fAttributeMap[B_DEVICE_INTERFACE] = ToHex(fClassApiId);
	fAttributeMap[B_DEVICE_VENDOR_ID] = ToHex(fVendorId);
	fAttributeMap[B_DEVICE_ID] = ToHex(fDeviceId);

	// Fetch ClassInfo	
	char classInfo[64];
	get_class_info(fClassBaseId, fClassSubId, fClassApiId, classInfo,
		sizeof(classInfo));
	
	// Fetch ManufacturerName
	BString ManufacturerName;
	const char *venShort;
	const char *venFull;
	get_vendor_info(fVendorId, &venShort, &venFull);
	if (!venShort && !venFull) {
		ManufacturerName << B_TRANSLATE("Unknown");
	} else if (venShort && venFull) {
		ManufacturerName << venFull << "(" << venShort << ")";
	} else {
		ManufacturerName << (venShort ? venShort : venFull);
	}
	
	// Fetch DeviceName
	BString DeviceName;
	const char *devShort;
	const char *devFull;
	get_device_info(fVendorId, fDeviceId, fSubsystemVendorId, fSubSystemId,
		&devShort, &devFull);
	if (!devShort && !devFull) {
		DeviceName << B_TRANSLATE("Unknown");
	} else if (devShort && devFull) {
		DeviceName << devFull << "(" << devShort << ")";
	} else {
		DeviceName << (devShort ? devShort : devFull);
	}
	
	SetAttribute(B_TRANSLATE("Device name"), DeviceName);
	SetAttribute(B_TRANSLATE("Manufacturer"), ManufacturerName);
	SetAttribute(B_TRANSLATE("Driver used"), B_TRANSLATE("Not implemented"));
	SetAttribute(B_TRANSLATE("Device paths"), B_TRANSLATE("Not implemented"));
	SetAttribute(B_TRANSLATE("Class info"), classInfo);
	fCategory = (Category)fClassBaseId;
	BString outlineName;
	outlineName << ManufacturerName << " " << DeviceName;
	SetText(outlineName.String());
}
コード例 #2
0
ファイル: listdev.c プロジェクト: AmirAbrams/haiku
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;
}
コード例 #3
0
static void
print_info_basic(const pci_info *info, bool verbose)
{
	int domain;
	uint8 bus;

	__pci_resolve_virtual_bus(info->bus, &domain, &bus);

	TRACE(("PCI: [dom %d, bus %2d] bus %3d, device %2d, function %2d: vendor %04x, device %04x, revision %02x\n",
			domain, bus, info->bus /* virtual bus*/,
			info->device, info->function, info->vendor_id, info->device_id, info->revision));
	TRACE(("PCI:   class_base %02x, class_function %02x, class_api %02x\n",
			info->class_base, info->class_sub, info->class_api));

	if (verbose) {
#if USE_PCI_HEADER
		const char *venShort;
		const char *venFull;
		get_vendor_info(info->vendor_id, &venShort, &venFull);
		if (!venShort && !venFull) {
			TRACE(("PCI:   vendor %04x: Unknown\n", info->vendor_id));
		} else if (venShort && venFull) {
			TRACE(("PCI:   vendor %04x: %s - %s\n", info->vendor_id, venShort, venFull));
		} else {
			TRACE(("PCI:   vendor %04x: %s\n", info->vendor_id, venShort ? venShort : venFull));
		}
		const char *devShort;
		const char *devFull;
		get_device_info(info->vendor_id, info->device_id, info->u.h0.subsystem_vendor_id, info->u.h0.subsystem_id,
			&devShort, &devFull);
		if (!devShort && !devFull) {
			TRACE(("PCI:   device %04x: Unknown\n", info->device_id));
		} else if (devShort && devFull) {
			TRACE(("PCI:   device %04x: %s (%s)\n", info->device_id, devShort, devFull));
		} else {
			TRACE(("PCI:   device %04x: %s\n", info->device_id, devShort ? devShort : devFull));
		}
		char classInfo[64];
		get_class_info(info->class_base, info->class_sub, info->class_api, classInfo, sizeof(classInfo));
		TRACE(("PCI:   info: %s\n", classInfo));
#endif
	}
	TRACE(("PCI:   line_size %02x, latency %02x, header_type %02x, BIST %02x\n",
			info->line_size, info->latency, info->header_type, info->bist));

	switch (info->header_type & PCI_header_type_mask) {
		case PCI_header_type_generic:
			print_generic_info(info, verbose);
			break;
		case PCI_header_type_PCI_to_PCI_bridge:
			print_pci2pci_bridge_info(info, verbose);
			break;
		case PCI_header_type_cardbus:
			print_pci2cardbus_bridge_info(info, verbose);
			break;
		default:
			TRACE(("PCI:   unknown header type\n"));
	}

	print_capabilities(info);
}
コード例 #4
0
ファイル: basic.cpp プロジェクト: bachir151/feelpp
/** Output to stream. This performs double dispatch on the dynamic type of
 *  *this and the dynamic type of the supplied print context.
 *  @param c print context object that describes the output formatting
 *  @param level value that is used to identify the precedence or indentation
 *               level for placing parentheses and formatting */
void basic::print(const print_context & c, unsigned level) const
{
    print_dispatch(get_class_info(), c, level);
}