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

Side by Side Diff: firmware/lib/vboot_firmware.c

Issue 6672068: Added timing data to VbSharedData. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: 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 | « firmware/include/vboot_struct.h ('k') | firmware/lib/vboot_kernel.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 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 * 4 *
5 * High-level firmware API for loading and verifying rewritable firmware. 5 * High-level firmware API for loading and verifying rewritable firmware.
6 * (Firmware portion) 6 * (Firmware portion)
7 */ 7 */
8 8
9 #include "gbb_header.h" 9 #include "gbb_header.h"
10 #include "load_firmware_fw.h" 10 #include "load_firmware_fw.h"
(...skipping 18 matching lines...) Expand all
29 VbLoadFirmwareInternal* lfi = 29 VbLoadFirmwareInternal* lfi =
30 (VbLoadFirmwareInternal*)params->load_firmware_internal; 30 (VbLoadFirmwareInternal*)params->load_firmware_internal;
31 31
32 DigestUpdate(&lfi->body_digest_context, data, size); 32 DigestUpdate(&lfi->body_digest_context, data, size);
33 lfi->body_size_accum += size; 33 lfi->body_size_accum += size;
34 } 34 }
35 35
36 36
37 int LoadFirmwareSetup(void) { 37 int LoadFirmwareSetup(void) {
38 /* TODO: handle test errors (requires passing in VbNvContext) */ 38 /* TODO: handle test errors (requires passing in VbNvContext) */
39 /* TODO: record timer values (requires passing in VbSharedData) */
39 /* TODO: start initializing the TPM */ 40 /* TODO: start initializing the TPM */
40 return LOAD_FIRMWARE_SUCCESS; 41 return LOAD_FIRMWARE_SUCCESS;
41 } 42 }
42 43
43 44
44 int LoadFirmware(LoadFirmwareParams* params) { 45 int LoadFirmware(LoadFirmwareParams* params) {
45 VbSharedDataHeader* shared = (VbSharedDataHeader*)params->shared_data_blob; 46 VbSharedDataHeader* shared = (VbSharedDataHeader*)params->shared_data_blob;
46 GoogleBinaryBlockHeader* gbb = (GoogleBinaryBlockHeader*)params->gbb_data; 47 GoogleBinaryBlockHeader* gbb = (GoogleBinaryBlockHeader*)params->gbb_data;
47 VbPublicKey* root_key; 48 VbPublicKey* root_key;
48 VbLoadFirmwareInternal* lfi; 49 VbLoadFirmwareInternal* lfi;
(...skipping 20 matching lines...) Expand all
69 70
70 /* Setup NV storage */ 71 /* Setup NV storage */
71 VbNvSetup(vnc); 72 VbNvSetup(vnc);
72 73
73 /* Initialize shared data structure. */ 74 /* Initialize shared data structure. */
74 if (0 != VbSharedDataInit(shared, params->shared_data_size)) { 75 if (0 != VbSharedDataInit(shared, params->shared_data_size)) {
75 VBDEBUG(("Shared data init error\n")); 76 VBDEBUG(("Shared data init error\n"));
76 recovery = VBNV_RECOVERY_RO_SHARED_DATA; 77 recovery = VBNV_RECOVERY_RO_SHARED_DATA;
77 goto LoadFirmwareExit; 78 goto LoadFirmwareExit;
78 } 79 }
80 shared->timer_load_firmware_enter = VbGetTimer();
79 81
80 /* Handle test errors */ 82 /* Handle test errors */
81 VbNvGet(vnc, VBNV_TEST_ERROR_FUNC, &test_err); 83 VbNvGet(vnc, VBNV_TEST_ERROR_FUNC, &test_err);
82 if (VBNV_TEST_ERROR_LOAD_FIRMWARE == test_err) { 84 if (VBNV_TEST_ERROR_LOAD_FIRMWARE == test_err) {
83 /* Get error code */ 85 /* Get error code */
84 VbNvGet(vnc, VBNV_TEST_ERROR_NUM, &test_err); 86 VbNvGet(vnc, VBNV_TEST_ERROR_NUM, &test_err);
85 /* Clear test params so we don't repeat the error */ 87 /* Clear test params so we don't repeat the error */
86 VbNvSet(vnc, VBNV_TEST_ERROR_FUNC, 0); 88 VbNvSet(vnc, VBNV_TEST_ERROR_FUNC, 0);
87 VbNvSet(vnc, VBNV_TEST_ERROR_NUM, 0); 89 VbNvSet(vnc, VBNV_TEST_ERROR_NUM, 0);
88 /* Handle error codes */ 90 /* Handle error codes */
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 VBDEBUG(("Alas, no good firmware.\n")); 347 VBDEBUG(("Alas, no good firmware.\n"));
346 recovery = VBNV_RECOVERY_RO_INVALID_RW; 348 recovery = VBNV_RECOVERY_RO_INVALID_RW;
347 } 349 }
348 350
349 LoadFirmwareExit: 351 LoadFirmwareExit:
350 /* Store recovery request, if any, then tear down non-volatile storage */ 352 /* Store recovery request, if any, then tear down non-volatile storage */
351 VbNvSet(vnc, VBNV_RECOVERY_REQUEST, LOAD_FIRMWARE_RECOVERY == retval ? 353 VbNvSet(vnc, VBNV_RECOVERY_REQUEST, LOAD_FIRMWARE_RECOVERY == retval ?
352 recovery : VBNV_RECOVERY_NOT_REQUESTED); 354 recovery : VBNV_RECOVERY_NOT_REQUESTED);
353 VbNvTeardown(vnc); 355 VbNvTeardown(vnc);
354 356
357 shared->timer_load_firmware_exit = VbGetTimer();
358
355 /* Note that we don't reduce params->shared_data_size to shared->data_used, 359 /* Note that we don't reduce params->shared_data_size to shared->data_used,
356 * since we want to leave space for LoadKernel() to add to the shared data 360 * since we want to leave space for LoadKernel() to add to the shared data
357 * buffer. */ 361 * buffer. */
358 362
359 return retval; 363 return retval;
360 } 364 }
361 365
362 366
363 int S3Resume(void) { 367 int S3Resume(void) {
364 368
365 /* TODO: handle test errors (requires passing in VbNvContext) */ 369 /* TODO: handle test errors (requires passing in VbNvContext) */
366 370
367 /* Resume the TPM */ 371 /* Resume the TPM */
368 uint32_t status = RollbackS3Resume(); 372 uint32_t status = RollbackS3Resume();
369 373
370 /* If we can't resume, just do a full reboot. No need to go to recovery 374 /* If we can't resume, just do a full reboot. No need to go to recovery
371 * mode here, since if the TPM is really broken we'll catch it on the 375 * mode here, since if the TPM is really broken we'll catch it on the
372 * next boot. */ 376 * next boot. */
373 if (status == TPM_SUCCESS) 377 if (status == TPM_SUCCESS)
374 return LOAD_FIRMWARE_SUCCESS; 378 return LOAD_FIRMWARE_SUCCESS;
375 else 379 else
376 return LOAD_FIRMWARE_REBOOT; 380 return LOAD_FIRMWARE_REBOOT;
377 } 381 }
OLDNEW
« no previous file with comments | « firmware/include/vboot_struct.h ('k') | firmware/lib/vboot_kernel.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698