X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ls-vpd.c;h=92627e4f403f81e7bec5f1ad854daa9613dbcf5f;hb=bd853ef840a9c479ad36fadbe4d36ef1ca447aed;hp=413dcfd605b1be4d56cac83c40af26fea4836585;hpb=01f4caed678b44938e62b23d0582491b5c40b76c;p=pciutils.git diff --git a/ls-vpd.c b/ls-vpd.c index 413dcfd..92627e4 100644 --- a/ls-vpd.c +++ b/ls-vpd.c @@ -10,6 +10,7 @@ */ #include +#include #include "lspci.h" @@ -33,7 +34,7 @@ static const struct vpd_item { } vpd_items[] = { { 'C','P', F_BINARY, "Extended capability" }, { 'E','C', F_TEXT, "Engineering changes" }, - { 'M','N', F_BINARY, "Manufacture ID" }, + { 'M','N', F_TEXT, "Manufacture ID" }, { 'P','N', F_TEXT, "Part number" }, { 'R','V', F_RESVD, "Reserved" }, { 'R','W', F_RDWR, "Read-write area" }, @@ -41,7 +42,14 @@ static const struct vpd_item { { 'Y','A', F_TEXT, "Asset tag" }, { 'V', 0 , F_TEXT, "Vendor specific" }, { 'Y', 0 , F_TEXT, "System specific" }, - { 0, 0 , F_BINARY, NULL } + /* Non-standard extensions */ + { 'C','C', F_TEXT, "CCIN" }, + { 'F','C', F_TEXT, "Feature code" }, + { 'F','N', F_TEXT, "FRU" }, + { 'N','A', F_TEXT, "Network address" }, + { 'R','M', F_TEXT, "Firmware version" }, + { 'Z', 0 , F_TEXT, "Product specific" }, + { 0, 0 , F_BINARY, "Unknown" } }; static void @@ -52,6 +60,8 @@ print_vpd_string(const byte *buf, word len) byte ch = *buf++; if (ch == '\\') printf("\\\\"); + else if (!ch && !len) + ; /* Cards with null-terminated strings have been observed */ else if (ch < 32 || ch == 127) printf("\\x%02x", ch); else @@ -147,27 +157,22 @@ cap_vpd(struct device *d) { word read_len; const struct vpd_item *item; - struct vpd_item unknown_item; + byte id[2], id1, id2; if (!read_vpd(d, res_addr + part_pos, buf, 3, &csum)) break; part_pos += 3; + memcpy(id, buf, 2); + id1 = id[0]; + id2 = id[1]; part_len = buf[2]; if (part_len > res_len - part_pos) break; /* Is this item known? */ - for (item=vpd_items; item->id1 && item->id1 != buf[0] || - item->id2 && item->id2 != buf[1]; item++) + for (item=vpd_items; item->id1 && item->id1 != id1 || + item->id2 && item->id2 != id2; item++) ; - if (!item->id1 && !item->id2) - { - unknown_item.id1 = buf[0]; - unknown_item.id2 = buf[1]; - unknown_item.format = F_BINARY; - unknown_item.name = "Unknown"; - item = &unknown_item; - } /* Only read the first byte of the RV field because the * remaining bytes are not included in the checksum. */ @@ -175,7 +180,9 @@ cap_vpd(struct device *d) if (!read_vpd(d, res_addr + part_pos, buf, read_len, &csum)) break; - printf("\t\t\t[%c%c] %s: ", item->id1, item->id2, item->name); + printf("\t\t\t["); + print_vpd_string(id, 2); + printf("] %s: ", item->name); switch (item->format) { @@ -200,9 +207,9 @@ cap_vpd(struct device *d) break; default: - printf("\t\tUnknown %s resource type %02x\n", + printf("\t\tUnknown %s resource type %02x, will not decode more.\n", (tag & 0x80) ? "large" : "small", tag & ~0x80); - break; + return; } res_addr += res_len;