Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Unified Diff: lib/lib_smbios.c

Issue 6628052: Supports SPD in VPD partition. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vpd.git@master
Patch Set: refine the logic to next structure table. refine type 241 parameters. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/lib/vpd_tables.h ('k') | vpd.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/lib_smbios.c
diff --git a/lib/lib_smbios.c b/lib/lib_smbios.c
index 8dcf283b98856d3e4c1ab220a655ac147f6de5d1..53e63c99e08959eb6290fbe83887a48b36d6dc7a 100644
--- a/lib/lib_smbios.c
+++ b/lib/lib_smbios.c
@@ -209,14 +209,14 @@ int vpd_append_type241(uint16_t handle, uint8_t **buf,
}
if (desc) {
- data->description = 2;
+ data->description = string_index;
string_index++;
sprintf(string_ptr, "%s%c", desc, '\0');
string_ptr += strlen(desc) + 1;
}
- data->major_version = 0;
- data->minor_version = 1;
+ data->major_version = 2;
+ data->minor_version = 0;
if (variant) {
data->variant = string_index;
@@ -241,6 +241,37 @@ vpd_create_type241_fail:
return -1;
}
+/**
+ * vpd_type241_size - return the size of type 241 structure table.
+ *
+ * Type 241 structure contains 3 variant length of string at end of table.
+ * It is non-trival to get the length by sizeof(vpd_table_binary_blob_pointer).
+ * This function can help by adding 3 strlen(NULL-terminated string).
+ *
+ * @header: pointer to the start address of this structure table.
+ *
+ * returns total size of this structure table.
+ * returns <0 to indicate failure
+ */
+int vpd_type241_size(struct vpd_header *header) {
+ uint8_t *ptr = ((uint8_t*)header) + header->length;
+ int length = sizeof(struct vpd_header) +
+ sizeof(struct vpd_table_binary_blob_pointer);
+ int i;
+
+ /* Sanity check */
+ if (header->type != VPD_TYPE_BINARY_BLOB_POINTER) return -1;
+
+ for (i = 0; i < 3; ++i) {
+ int len = strlen(ptr) + 1;
+ length += len;
+ ptr += len;
+ }
+ length++; /* Additional null(0) to indicate end of set.
+ * Refer to SMBIOS spec 3.1.3 Text Strings. */
+ return length;
+}
+
void vpd_free_table(void *data)
{
uint8_t *foo = data;
« no previous file with comments | « include/lib/vpd_tables.h ('k') | vpd.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698