mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 02:05:01 +00:00
Added timing data to VbSharedData.
Change-Id: I8d52765227fd3355431bebc77dfbe0106c889eca BUG=chrome-os-partner:2748 TEST=compiles; will be porting to H2C next Review URL: http://codereview.chromium.org/6672068
This commit is contained in:
@@ -96,4 +96,18 @@ int SafeMemcmp(const void* s1, const void* s2, size_t n);
|
|||||||
#define memset _do_not_use_standard_memset
|
#define memset _do_not_use_standard_memset
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Read a high-resolution timer. */
|
||||||
|
uint64_t VbGetTimer(void);
|
||||||
|
|
||||||
|
/* Return the maximum frequency for the high-resolution timer, in Hz.
|
||||||
|
*
|
||||||
|
* Note that this call MUST be fast; the implementation must not
|
||||||
|
* attempt to actually measure the frequency. This function need only
|
||||||
|
* return an upper bound for the timer frequency, so that minimum
|
||||||
|
* delays can be established. For example, if the same BIOS can run
|
||||||
|
* on CPUs where the timer frequency varies between 1.2GHz and 1.8GHz,
|
||||||
|
* return 1800000000 (or even 2000000000). */
|
||||||
|
uint64_t VbGetTimerMaxFreq(void);
|
||||||
|
|
||||||
|
|
||||||
#endif /* VBOOT_REFERENCE_UTILITY_H_ */
|
#endif /* VBOOT_REFERENCE_UTILITY_H_ */
|
||||||
|
|||||||
@@ -157,10 +157,20 @@ typedef struct VbSharedDataHeader {
|
|||||||
VbPublicKey kernel_subkey; /* Kernel subkey, from firmware */
|
VbPublicKey kernel_subkey; /* Kernel subkey, from firmware */
|
||||||
uint64_t kernel_subkey_data_offset; /* Offset of kernel subkey data from
|
uint64_t kernel_subkey_data_offset; /* Offset of kernel subkey data from
|
||||||
* start of this struct */
|
* start of this struct */
|
||||||
uint64_t kernel_subkey_data_size; /* Offset of kernel subkey data */
|
uint64_t kernel_subkey_data_size; /* Size of kernel subkey data */
|
||||||
|
|
||||||
uint64_t flags; /* Flags */
|
uint64_t flags; /* Flags */
|
||||||
|
|
||||||
|
/* Timer values from VbGetTimer(). Unused values are set to 0. If a
|
||||||
|
* function is called mutiple times, these are the times from the
|
||||||
|
* most recent call. */
|
||||||
|
uint64_t timer_load_firmware_start_enter; /* LoadFirmwareStart() - enter */
|
||||||
|
uint64_t timer_load_firmware_start_exit; /* LoadFirmwareStart() - exit */
|
||||||
|
uint64_t timer_load_firmware_enter; /* LoadFirmware() - enter */
|
||||||
|
uint64_t timer_load_firmware_exit; /* LoadFirmware() - exit */
|
||||||
|
uint64_t timer_load_kernel_enter; /* LoadKernel() - enter */
|
||||||
|
uint64_t timer_load_kernel_exit; /* LoadKernel() - exit */
|
||||||
|
|
||||||
/* After read-only firmware which uses version 1 is released, any additional
|
/* After read-only firmware which uses version 1 is released, any additional
|
||||||
* fields must be added below, and the struct version must be increased.
|
* fields must be added below, and the struct version must be increased.
|
||||||
* Before reading/writing those fields, make sure that the struct being
|
* Before reading/writing those fields, make sure that the struct being
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ void UpdateFirmwareBodyHash(LoadFirmwareParams* params,
|
|||||||
|
|
||||||
int LoadFirmwareSetup(void) {
|
int LoadFirmwareSetup(void) {
|
||||||
/* TODO: handle test errors (requires passing in VbNvContext) */
|
/* TODO: handle test errors (requires passing in VbNvContext) */
|
||||||
|
/* TODO: record timer values (requires passing in VbSharedData) */
|
||||||
/* TODO: start initializing the TPM */
|
/* TODO: start initializing the TPM */
|
||||||
return LOAD_FIRMWARE_SUCCESS;
|
return LOAD_FIRMWARE_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -76,6 +77,7 @@ int LoadFirmware(LoadFirmwareParams* params) {
|
|||||||
recovery = VBNV_RECOVERY_RO_SHARED_DATA;
|
recovery = VBNV_RECOVERY_RO_SHARED_DATA;
|
||||||
goto LoadFirmwareExit;
|
goto LoadFirmwareExit;
|
||||||
}
|
}
|
||||||
|
shared->timer_load_firmware_enter = VbGetTimer();
|
||||||
|
|
||||||
/* Handle test errors */
|
/* Handle test errors */
|
||||||
VbNvGet(vnc, VBNV_TEST_ERROR_FUNC, &test_err);
|
VbNvGet(vnc, VBNV_TEST_ERROR_FUNC, &test_err);
|
||||||
@@ -352,6 +354,8 @@ LoadFirmwareExit:
|
|||||||
recovery : VBNV_RECOVERY_NOT_REQUESTED);
|
recovery : VBNV_RECOVERY_NOT_REQUESTED);
|
||||||
VbNvTeardown(vnc);
|
VbNvTeardown(vnc);
|
||||||
|
|
||||||
|
shared->timer_load_firmware_exit = VbGetTimer();
|
||||||
|
|
||||||
/* Note that we don't reduce params->shared_data_size to shared->data_used,
|
/* Note that we don't reduce params->shared_data_size to shared->data_used,
|
||||||
* since we want to leave space for LoadKernel() to add to the shared data
|
* since we want to leave space for LoadKernel() to add to the shared data
|
||||||
* buffer. */
|
* buffer. */
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ int LoadKernel(LoadKernelParams* params) {
|
|||||||
|
|
||||||
int retval = LOAD_KERNEL_RECOVERY;
|
int retval = LOAD_KERNEL_RECOVERY;
|
||||||
int recovery = VBNV_RECOVERY_RO_UNSPECIFIED;
|
int recovery = VBNV_RECOVERY_RO_UNSPECIFIED;
|
||||||
|
uint64_t timer_enter = VbGetTimer();
|
||||||
|
|
||||||
/* Setup NV storage */
|
/* Setup NV storage */
|
||||||
VbNvSetup(vnc);
|
VbNvSetup(vnc);
|
||||||
@@ -155,6 +156,11 @@ int LoadKernel(LoadKernelParams* params) {
|
|||||||
goto LoadKernelExit;
|
goto LoadKernelExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Clear output params in case we fail */
|
||||||
|
params->partition_number = 0;
|
||||||
|
params->bootloader_address = 0;
|
||||||
|
params->bootloader_size = 0;
|
||||||
|
|
||||||
/* Handle test errors */
|
/* Handle test errors */
|
||||||
VbNvGet(vnc, VBNV_TEST_ERROR_FUNC, &test_err);
|
VbNvGet(vnc, VBNV_TEST_ERROR_FUNC, &test_err);
|
||||||
if (VBNV_TEST_ERROR_LOAD_KERNEL == test_err) {
|
if (VBNV_TEST_ERROR_LOAD_KERNEL == test_err) {
|
||||||
@@ -206,11 +212,6 @@ int LoadKernel(LoadKernelParams* params) {
|
|||||||
dev_switch = 0; /* Always do a fully verified boot */
|
dev_switch = 0; /* Always do a fully verified boot */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear output params in case we fail */
|
|
||||||
params->partition_number = 0;
|
|
||||||
params->bootloader_address = 0;
|
|
||||||
params->bootloader_size = 0;
|
|
||||||
|
|
||||||
if (kBootRecovery == boot_mode) {
|
if (kBootRecovery == boot_mode) {
|
||||||
/* Initialize the shared data structure, since LoadFirmware() didn't do it
|
/* Initialize the shared data structure, since LoadFirmware() didn't do it
|
||||||
* for us. */
|
* for us. */
|
||||||
@@ -556,9 +557,13 @@ LoadKernelExit:
|
|||||||
recovery : VBNV_RECOVERY_NOT_REQUESTED);
|
recovery : VBNV_RECOVERY_NOT_REQUESTED);
|
||||||
VbNvTeardown(vnc);
|
VbNvTeardown(vnc);
|
||||||
|
|
||||||
/* Store how much shared data we used, if any */
|
if (shared) {
|
||||||
if (shared)
|
/* Save timer values */
|
||||||
|
shared->timer_load_kernel_enter = timer_enter;
|
||||||
|
shared->timer_load_kernel_exit = VbGetTimer();
|
||||||
|
/* Store how much shared data we used, if any */
|
||||||
params->shared_data_size = shared->data_used;
|
params->shared_data_size = shared->data_used;
|
||||||
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
|
/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*
|
*
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
void error(const char *format, ...) {
|
void error(const char *format, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -51,3 +52,13 @@ int Memcmp(const void* src1, const void* src2, size_t n) {
|
|||||||
void* Memcpy(void* dest, const void* src, uint64_t n) {
|
void* Memcpy(void* dest, const void* src, uint64_t n) {
|
||||||
return memcpy(dest, src, (size_t)n);
|
return memcpy(dest, src, (size_t)n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t VbGetTimer(void) {
|
||||||
|
struct timeval tv;
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
return (uint64_t)tv.tv_sec * 1000000 + (uint64_t)tv.tv_usec;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t VbGetTimerMaxFreq(void) {
|
||||||
|
return UINT64_C(1000000);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user