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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/lib/vpd_tables.h ('k') | vpd.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2010 Google Inc. All Rights Reserved. 2 * Copyright 2010 Google Inc. All Rights Reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License 5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2 6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version. 7 * of the License, or (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 data->struct_minor_version = 0; 202 data->struct_minor_version = 0;
203 203
204 if (vendor) { 204 if (vendor) {
205 data->vendor = string_index; 205 data->vendor = string_index;
206 string_index++; 206 string_index++;
207 sprintf(string_ptr, "%s%c", vendor, '\0'); 207 sprintf(string_ptr, "%s%c", vendor, '\0');
208 string_ptr += strlen(vendor) + 1; 208 string_ptr += strlen(vendor) + 1;
209 } 209 }
210 210
211 if (desc) { 211 if (desc) {
212 data->description = 2; 212 data->description = string_index;
213 string_index++; 213 string_index++;
214 sprintf(string_ptr, "%s%c", desc, '\0'); 214 sprintf(string_ptr, "%s%c", desc, '\0');
215 string_ptr += strlen(desc) + 1; 215 string_ptr += strlen(desc) + 1;
216 } 216 }
217 217
218 data->major_version = 0; 218 data->major_version = 2;
219 data->minor_version = 1; 219 data->minor_version = 0;
220 220
221 if (variant) { 221 if (variant) {
222 data->variant = string_index; 222 data->variant = string_index;
223 string_index++; 223 string_index++;
224 sprintf(string_ptr, "%s%c", variant, '\0'); 224 sprintf(string_ptr, "%s%c", variant, '\0');
225 string_ptr += strlen(variant) + 1; 225 string_ptr += strlen(variant) + 1;
226 } 226 }
227 227
228 memset(&data->reserved[0], 0, 5); 228 memset(&data->reserved[0], 0, 5);
229 229
230 if (uuid_parse(uuid, &data->uuid[0]) < 0) { 230 if (uuid_parse(uuid, &data->uuid[0]) < 0) {
231 fprintf(stderr, "invalid UUID \"%s\" specified\n", uuid); 231 fprintf(stderr, "invalid UUID \"%s\" specified\n", uuid);
232 goto vpd_create_type241_fail; 232 goto vpd_create_type241_fail;
233 } 233 }
234 234
235 data->offset = offset; 235 data->offset = offset;
236 data->size = size; 236 data->size = size;
237 237
238 return total_len; 238 return total_len;
239 239
240 vpd_create_type241_fail: 240 vpd_create_type241_fail:
241 return -1; 241 return -1;
242 } 242 }
243 243
244 /**
245 * vpd_type241_size - return the size of type 241 structure table.
246 *
247 * Type 241 structure contains 3 variant length of string at end of table.
248 * It is non-trival to get the length by sizeof(vpd_table_binary_blob_pointer).
249 * This function can help by adding 3 strlen(NULL-terminated string).
250 *
251 * @header: pointer to the start address of this structure table.
252 *
253 * returns total size of this structure table.
254 * returns <0 to indicate failure
255 */
256 int vpd_type241_size(struct vpd_header *header) {
257 uint8_t *ptr = ((uint8_t*)header) + header->length;
258 int length = sizeof(struct vpd_header) +
259 sizeof(struct vpd_table_binary_blob_pointer);
260 int i;
261
262 /* Sanity check */
263 if (header->type != VPD_TYPE_BINARY_BLOB_POINTER) return -1;
264
265 for (i = 0; i < 3; ++i) {
266 int len = strlen(ptr) + 1;
267 length += len;
268 ptr += len;
269 }
270 length++; /* Additional null(0) to indicate end of set.
271 * Refer to SMBIOS spec 3.1.3 Text Strings. */
272 return length;
273 }
274
244 void vpd_free_table(void *data) 275 void vpd_free_table(void *data)
245 { 276 {
246 uint8_t *foo = data; 277 uint8_t *foo = data;
247 278
248 /* clean-up is trivially simple, for now... */ 279 /* clean-up is trivially simple, for now... */
249 free(foo); 280 free(foo);
250 } 281 }
OLDNEW
« 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