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

Side by Side Diff: firmware/lib/vboot_kernel.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/lib/vboot_firmware.c ('k') | firmware/stub/utility_stub.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 * Functions for loading a kernel from disk. 5 * Functions for loading a kernel from disk.
6 * (Firmware portion) 6 * (Firmware portion)
7 */ 7 */
8 8
9 #include "vboot_kernel.h" 9 #include "vboot_kernel.h"
10 10
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 int good_partition_key_block_valid = 0; 134 int good_partition_key_block_valid = 0;
135 uint32_t tpm_version = 0; 135 uint32_t tpm_version = 0;
136 uint64_t lowest_version = LOWEST_TPM_VERSION; 136 uint64_t lowest_version = LOWEST_TPM_VERSION;
137 int rec_switch, dev_switch; 137 int rec_switch, dev_switch;
138 BootMode boot_mode; 138 BootMode boot_mode;
139 uint32_t test_err = 0; 139 uint32_t test_err = 0;
140 uint32_t status; 140 uint32_t status;
141 141
142 int retval = LOAD_KERNEL_RECOVERY; 142 int retval = LOAD_KERNEL_RECOVERY;
143 int recovery = VBNV_RECOVERY_RO_UNSPECIFIED; 143 int recovery = VBNV_RECOVERY_RO_UNSPECIFIED;
144 uint64_t timer_enter = VbGetTimer();
144 145
145 /* Setup NV storage */ 146 /* Setup NV storage */
146 VbNvSetup(vnc); 147 VbNvSetup(vnc);
147 148
148 /* Sanity Checks */ 149 /* Sanity Checks */
149 if (!params || 150 if (!params ||
150 !params->bytes_per_lba || 151 !params->bytes_per_lba ||
151 !params->ending_lba || 152 !params->ending_lba ||
152 !params->kernel_buffer || 153 !params->kernel_buffer ||
153 !params->kernel_buffer_size) { 154 !params->kernel_buffer_size) {
154 VBDEBUG(("LoadKernel() called with invalid params\n")); 155 VBDEBUG(("LoadKernel() called with invalid params\n"));
155 goto LoadKernelExit; 156 goto LoadKernelExit;
156 } 157 }
157 158
159 /* Clear output params in case we fail */
160 params->partition_number = 0;
161 params->bootloader_address = 0;
162 params->bootloader_size = 0;
163
158 /* Handle test errors */ 164 /* Handle test errors */
159 VbNvGet(vnc, VBNV_TEST_ERROR_FUNC, &test_err); 165 VbNvGet(vnc, VBNV_TEST_ERROR_FUNC, &test_err);
160 if (VBNV_TEST_ERROR_LOAD_KERNEL == test_err) { 166 if (VBNV_TEST_ERROR_LOAD_KERNEL == test_err) {
161 /* Get error code */ 167 /* Get error code */
162 VbNvGet(vnc, VBNV_TEST_ERROR_NUM, &test_err); 168 VbNvGet(vnc, VBNV_TEST_ERROR_NUM, &test_err);
163 /* Clear test params so we don't repeat the error */ 169 /* Clear test params so we don't repeat the error */
164 VbNvSet(vnc, VBNV_TEST_ERROR_FUNC, 0); 170 VbNvSet(vnc, VBNV_TEST_ERROR_FUNC, 0);
165 VbNvSet(vnc, VBNV_TEST_ERROR_NUM, 0); 171 VbNvSet(vnc, VBNV_TEST_ERROR_NUM, 0);
166 /* Handle error codes */ 172 /* Handle error codes */
167 switch (test_err) { 173 switch (test_err) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 recovery = VBNV_RECOVERY_RW_DEV_MISMATCH; 205 recovery = VBNV_RECOVERY_RW_DEV_MISMATCH;
200 goto LoadKernelExit; 206 goto LoadKernelExit;
201 } 207 }
202 boot_mode = kBootDev; 208 boot_mode = kBootDev;
203 } else { 209 } else {
204 /* Normal firmware */ 210 /* Normal firmware */
205 boot_mode = kBootNormal; 211 boot_mode = kBootNormal;
206 dev_switch = 0; /* Always do a fully verified boot */ 212 dev_switch = 0; /* Always do a fully verified boot */
207 } 213 }
208 214
209 /* Clear output params in case we fail */
210 params->partition_number = 0;
211 params->bootloader_address = 0;
212 params->bootloader_size = 0;
213
214 if (kBootRecovery == boot_mode) { 215 if (kBootRecovery == boot_mode) {
215 /* Initialize the shared data structure, since LoadFirmware() didn't do it 216 /* Initialize the shared data structure, since LoadFirmware() didn't do it
216 * for us. */ 217 * for us. */
217 if (0 != VbSharedDataInit(shared, params->shared_data_size)) { 218 if (0 != VbSharedDataInit(shared, params->shared_data_size)) {
218 /* Error initializing the shared data, but we can keep going. We just 219 /* Error initializing the shared data, but we can keep going. We just
219 * can't use the shared data. */ 220 * can't use the shared data. */
220 VBDEBUG(("Shared data init error\n")); 221 VBDEBUG(("Shared data init error\n"));
221 params->shared_data_size = 0; 222 params->shared_data_size = 0;
222 shared = NULL; 223 shared = NULL;
223 } 224 }
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 LoadKernelExit: 550 LoadKernelExit:
550 551
551 /* Save whether the good partition's key block was fully verified */ 552 /* Save whether the good partition's key block was fully verified */
552 VbNvSet(vnc, VBNV_FW_VERIFIED_KERNEL_KEY, good_partition_key_block_valid); 553 VbNvSet(vnc, VBNV_FW_VERIFIED_KERNEL_KEY, good_partition_key_block_valid);
553 554
554 /* Store recovery request, if any, then tear down non-volatile storage */ 555 /* Store recovery request, if any, then tear down non-volatile storage */
555 VbNvSet(vnc, VBNV_RECOVERY_REQUEST, LOAD_KERNEL_RECOVERY == retval ? 556 VbNvSet(vnc, VBNV_RECOVERY_REQUEST, LOAD_KERNEL_RECOVERY == retval ?
556 recovery : VBNV_RECOVERY_NOT_REQUESTED); 557 recovery : VBNV_RECOVERY_NOT_REQUESTED);
557 VbNvTeardown(vnc); 558 VbNvTeardown(vnc);
558 559
559 /* Store how much shared data we used, if any */ 560 if (shared) {
560 if (shared) 561 /* Save timer values */
562 shared->timer_load_kernel_enter = timer_enter;
563 shared->timer_load_kernel_exit = VbGetTimer();
564 /* Store how much shared data we used, if any */
561 params->shared_data_size = shared->data_used; 565 params->shared_data_size = shared->data_used;
566 }
562 567
563 return retval; 568 return retval;
564 } 569 }
OLDNEW
« no previous file with comments | « firmware/lib/vboot_firmware.c ('k') | firmware/stub/utility_stub.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698