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