forked from pciutils/pciutils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ls-caps-vendor.c
82 lines (70 loc) · 1.61 KB
/
ls-caps-vendor.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* The PCI Utilities -- Show Vendor-specific Capabilities
*
* Copyright (c) 2014 Gerd Hoffmann <[email protected]>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include <stdio.h>
#include <string.h>
#include "lspci.h"
static int
show_vendor_caps_virtio(struct device *d, int where, int cap)
{
int length = BITS(cap, 0, 8);
int type = BITS(cap, 8, 8);
char *tname;
if (length < 16)
return 0;
if (!config_fetch(d, where, length))
return 0;
switch (type)
{
case 1:
tname = "CommonCfg";
break;
case 2:
tname = "Notify";
break;
case 3:
tname = "ISR";
break;
case 4:
tname = "DeviceCfg";
break;
default:
tname = "<unknown>";
break;
}
printf("VirtIO: %s\n", tname);
if (verbose < 2)
return 1;
printf("\t\tBAR=%d offset=%08x size=%08x",
get_conf_byte(d, where + 4),
get_conf_long(d, where + 8),
get_conf_long(d, where + 12));
if (type == 2 && length >= 20)
printf(" multiplier=%08x", get_conf_long(d, where+16));
printf("\n");
return 1;
}
static int
do_show_vendor_caps(struct device *d, int where, int cap)
{
switch (get_conf_word(d, PCI_VENDOR_ID))
{
case 0x1af4: /* Red Hat */
if (get_conf_word(d, PCI_DEVICE_ID) >= 0x1000 &&
get_conf_word(d, PCI_DEVICE_ID) <= 0x107f)
return show_vendor_caps_virtio(d, where, cap);
break;
}
return 0;
}
void
show_vendor_caps(struct device *d, int where, int cap)
{
printf("Vendor Specific Information: ");
if (!do_show_vendor_caps(d, where, cap))
printf("Len=%02x <?>\n", BITS(cap, 0, 8));
}