Reformat header files to kernel style

No code changes, just reformatting.

BUG=none
BRANCH=none
TEST=make runtests

Change-Id: Id5bac79545e9803d19b45da160c535f7e06465c6
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42016
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
Randall Spangler
2013-01-24 16:15:35 -08:00
committed by ChromeBot
parent 786a5dca74
commit a2db67d204
10 changed files with 1292 additions and 937 deletions

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2010-2011 The Chromium OS Authors. All rights reserved.
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -40,7 +40,6 @@
* +-----------------------------------------+
* | List of locale names |
* +-----------------------------------------+
*
*/
#ifndef VBOOT_REFERENCE_BMPBLK_HEADER_H_
@@ -60,83 +59,93 @@ __pragma(pack(push, 1)) /* Support packing for MSVC. */
/* BMPBLOCK header, describing how many screen layouts and image infos */
typedef struct BmpBlockHeader {
uint8_t signature[BMPBLOCK_SIGNATURE_SIZE]; /* BMPBLOCK_SIGNATURE $BMP */
uint16_t major_version; /* see BMPBLOCK_MAJOR_VER */
uint16_t minor_version; /* see BMPBLOCK_MINOR_VER */
uint32_t number_of_localizations; /* Number of localizations */
uint32_t number_of_screenlayouts; /* Number of screen layouts in each
* localization */
uint32_t number_of_imageinfos; /* Number of image infos */
uint32_t locale_string_offset; /* Offset of locale-translation string */
uint32_t reserved[2];
/* BMPBLOCK_SIGNATURE $BMP */
uint8_t signature[BMPBLOCK_SIGNATURE_SIZE];
uint16_t major_version; /* see BMPBLOCK_MAJOR_VER */
uint16_t minor_version; /* see BMPBLOCK_MINOR_VER */
uint32_t number_of_localizations; /* Number of localizations */
/* Number of screen layouts in each localization */
uint32_t number_of_screenlayouts;
uint32_t number_of_imageinfos; /* Number of image infos */
/* Offset of locale-translation string */
uint32_t locale_string_offset;
uint32_t reserved[2];
} __attribute__((packed)) BmpBlockHeader;
/* Screen layout, describing how to stack multiple images on screen */
typedef struct ScreenLayout {
struct {
uint32_t x; /* X-offset of the image to be rendered */
uint32_t y; /* Y-offset of the image to be rendered */
uint32_t image_info_offset; /* Offset of image info from start of
* BMPBLOCK. 0 means end of it. */
} images[MAX_IMAGE_IN_LAYOUT]; /* Images contained in the screen. Will be
* rendered from 0 to (number_of_images-1). */
/*
* Images contained in the screen. Will be rendered from 0 to
* (number_of_images-1).
*/
struct {
/* (X,Y) offset of image to be rendered */
uint32_t x;
uint32_t y;
/* Offset of image info from start of BMPBLOCK; 0=end it. */
uint32_t image_info_offset;
} images[MAX_IMAGE_IN_LAYOUT];
} __attribute__((packed)) ScreenLayout;
/* Constants for screen index */
typedef enum ScreenIndex {
SCREEN_DEVELOPER_WARNING = 0,
SCREEN_RECOVERY_REMOVE,
SCREEN_RECOVERY_NO_GOOD,
SCREEN_RECOVERY_INSERT,
SCREEN_RECOVERY_TO_DEV,
SCREEN_DEVELOPER_TO_NORM,
SCREEN_WAIT,
SCREEN_TO_NORM_CONFIRMED,
MAX_VALID_SCREEN_INDEX,
SCREEN_BLANK = ~0UL,
SCREEN_DEVELOPER_WARNING = 0,
SCREEN_RECOVERY_REMOVE,
SCREEN_RECOVERY_NO_GOOD,
SCREEN_RECOVERY_INSERT,
SCREEN_RECOVERY_TO_DEV,
SCREEN_DEVELOPER_TO_NORM,
SCREEN_WAIT,
SCREEN_TO_NORM_CONFIRMED,
MAX_VALID_SCREEN_INDEX,
SCREEN_BLANK = ~0UL,
} ScreenIndex;
/* Image info, describing the information of the image block */
typedef struct ImageInfo {
uint32_t tag; /* Tag it as a special image, like HWID */
uint32_t width; /* Width of the image */
uint32_t height; /* Height of the image */
uint32_t format; /* File format of the image */
uint32_t compression; /* Compression method for the image file */
uint32_t original_size; /* Size of the original uncompressed image */
uint32_t compressed_size; /* Size of the compressed image; if image is not
* compressed, this will be the same as the
* original size. */
uint32_t reserved;
uint32_t tag; /* Tag it as a special image, like HWID */
uint32_t width; /* Width of the image */
uint32_t height; /* Height of the image */
uint32_t format; /* File format of the image */
uint32_t compression; /* Compression method for the image file */
uint32_t original_size; /* Size of the original uncompressed image */
/*
* Size of the compressed image; if image is not compressed, this will
* be the same as the original size.
*/
uint32_t compressed_size;
uint32_t reserved;
/* NOTE: The actual image content (if any) follows immediately. */
} __attribute__((packed)) ImageInfo;
/* Constants for ImageInfo.tag */
typedef enum ImageTag {
TAG_NONE = 0,
TAG_HWID,
TAG_HWID_RTOL, /* "right-to-left", ie, right-justified HWID */
TAG_NONE = 0,
TAG_HWID,
TAG_HWID_RTOL, /* "right-to-left", ie, right-justified HWID */
} ImageTag;
/* Constants for ImageInfo.format */
typedef enum ImageFormat {
FORMAT_INVALID = 0,
FORMAT_BMP,
FORMAT_FONT,
FORMAT_INVALID = 0,
FORMAT_BMP,
FORMAT_FONT,
} ImageFormat;
/* Constants for ImageInfo.compression */
typedef enum Compression {
COMPRESS_NONE = 0,
COMPRESS_EFIv1, /* The x86 BIOS only supports this */
COMPRESS_LZMA1, /* The ARM BIOS supports LZMA1 */
MAX_COMPRESS,
COMPRESS_NONE = 0,
COMPRESS_EFIv1, /* The x86 BIOS only supports this */
COMPRESS_LZMA1, /* The ARM BIOS supports LZMA1 */
MAX_COMPRESS,
} Compression;
/* These magic image names can be used in the .yaml file to indicate that
the ASCII HWID should be displayed. For RENDER_HWID, the image coordinates
specify upper-left corner of the HWID string. For RENDER_HWID_RTOL, they
indicate the upper-right corner (handy for right-to-left languages). */
/*
* These magic image names can be used in the .yaml file to indicate that the
* ASCII HWID should be displayed. For RENDER_HWID, the image coordinates
* specify upper-left corner of the HWID string. For RENDER_HWID_RTOL, they
* indicate the upper-right corner (handy for right-to-left languages).
*/
#define RENDER_HWID "$HWID"
#define RENDER_HWID_RTOL "$HWID.rtol"

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -15,17 +15,18 @@
#define GBB_SIGNATURE "$GBB"
#define GBB_SIGNATURE_SIZE 4
/* GBB version constants.
/*
* GBB version constants.
*
* If the major version is different than the reader can handle, it
* shouldn't attempt to parse the GBB.
* If the major version is different than the reader can handle, it shouldn't
* attempt to parse the GBB.
*
* If the minor version is different, the reader can still parse it.
* If the minor version is greater than expected, new fields were
* added in a way which does not interfere with the old fields. If
* it's less than expected, some of the fields expected by the reader
* aren't initialized, and the reader should return default values for
* those fields. */
* If the minor version is different, the reader can still parse it. If the
* minor version is greater than expected, new fields were added in a way which
* does not interfere with the old fields. If it's less than expected, some of
* the fields expected by the reader aren't initialized, and the reader should
* return default values for those fields.
*/
#define GBB_MAJOR_VER 1
#define GBB_MINOR_VER 1
@@ -35,13 +36,17 @@
/* Flags for .flags field */
/* Reduce the dev screen delay to 2 sec from 30 sec to speedup factory. */
#define GBB_FLAG_DEV_SCREEN_SHORT_DELAY 0x00000001
/* BIOS should load option ROMs from arbitrary PCI devices. We'll never enable
* this ourselves because it executes non-verified code, but if a customer wants
* to void their warranty and set this flag in the read-only flash, they should
* be able to do so. */
/*
* BIOS should load option ROMs from arbitrary PCI devices. We'll never enable
* this ourselves because it executes non-verified code, but if a customer
* wants to void their warranty and set this flag in the read-only flash, they
* should be able to do so.
*/
#define GBB_FLAG_LOAD_OPTION_ROMS 0x00000002
/* The factory flow may need the BIOS to boot a non-ChromeOS kernel if the
* dev-switch is on. This flag allows that. */
/*
* The factory flow may need the BIOS to boot a non-ChromeOS kernel if the
* dev-switch is on. This flag allows that.
*/
#define GBB_FLAG_ENABLE_ALTERNATE_OS 0x00000004
/* Force dev switch on, regardless of physical/keyboard dev switch position. */
#define GBB_FLAG_FORCE_DEV_SWITCH_ON 0x00000008
@@ -60,24 +65,25 @@
extern "C" {
#endif /* __cplusplus */
typedef struct GoogleBinaryBlockHeader {
/* Fields present in version 1.0 */
uint8_t signature[GBB_SIGNATURE_SIZE]; /* GBB_SIGNATURE "$GBB" */
uint16_t major_version; /* See GBB_MAJOR_VER */
uint16_t minor_version; /* See GBB_MINOR_VER */
uint32_t header_size; /* size of GBB header in bytes */
uint32_t flags; /* Flags (see GBB_FLAG_*), should be 0 for 1.0. */
typedef struct GoogleBinaryBlockHeader
{
/* Fields present in version 1.0 */
uint8_t signature[GBB_SIGNATURE_SIZE]; /* GBB_SIGNATURE "$GBB" */
uint16_t major_version; /* See GBB_MAJOR_VER */
uint16_t minor_version; /* See GBB_MINOR_VER */
uint32_t header_size; /* size of GBB header in bytes */
uint32_t flags; /* Flags (see GBB_FLAG_*), should be 0 for 1.0. */
/* Offsets (from start of header) and sizes (in bytes) of components */
uint32_t hwid_offset; /* HWID */
uint32_t hwid_size;
uint32_t rootkey_offset; /* Root key */
uint32_t rootkey_size;
uint32_t bmpfv_offset; /* BMP FV */
uint32_t bmpfv_size;
uint32_t recovery_key_offset; /* Recovery key */
uint32_t recovery_key_size;
uint32_t hwid_offset; /* HWID offset from start of header */
uint32_t hwid_size; /* HWID size in bytes */
uint32_t rootkey_offset; /* Root Key offset from start of header */
uint32_t rootkey_size; /* Root Key size in bytes */
uint32_t bmpfv_offset; /* BMP FV offset from start of header */
uint32_t bmpfv_size; /* BMP FV size in bytes */
uint32_t recovery_key_offset; /* Recovery Key offset from start of header */
uint32_t recovery_key_size; /* Recovery Key size in bytes */
uint8_t pad[80]; /* To match GBB_HEADER_SIZE. Initialize to 0. */
uint8_t pad[80]; /* To match GBB_HEADER_SIZE. Initialize to 0. */
} __attribute__((packed)) GoogleBinaryBlockHeader;
#ifdef __cplusplus

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -14,15 +14,17 @@
#include "vboot_nvstorage.h"
#include "vboot_struct.h"
/* Load the rewritable firmware.
/**
* Load the rewritable firmware.
*
* Pass the common and firmware params from VbSelectFirmware(), and a
* VbNvContext. Caller is responsible for calling VbNvSetup() and
* VbNvTeardown() on the VbNvContext.
*
* Returns VBERROR_SUCCESS if successful. If unsuccessful, sets a recovery
* reason via VbNvStorage and returns an error code. */
int LoadFirmware(VbCommonParams* cparams, VbSelectFirmwareParams* fparams,
VbNvContext* vnc);
* reason via VbNvStorage and returns an error code.
*/
int LoadFirmware(VbCommonParams *cparams, VbSelectFirmwareParams *fparams,
VbNvContext *vnc);
#endif /* VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ */

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -20,63 +20,82 @@
#define BOOT_FLAG_DEVELOPER UINT64_C(0x01)
/* In recovery mode */
#define BOOT_FLAG_RECOVERY UINT64_C(0x02)
/* Skip check of kernel buffer address. Since body load address check is
* omitted; this flag is deprecated and not used anywhere in the codebase. */
#define BOOT_FLAG_SKIP_ADDR_CHECK UINT64_C(0x04)
typedef struct LoadKernelParams {
/* Inputs to LoadKernel() */
void* shared_data_blob; /* Buffer for data shared between
* LoadFirmware() and LoadKernel(). Pass the
* same buffer which was passed to
* LoadFirmware(). */
uint64_t shared_data_size; /* Size of shared data blob buffer, in bytes.
* On output, this will contain the actual
* data size placed into the buffer. */
void* gbb_data; /* Pointer to GBB data */
uint64_t gbb_size; /* Size of GBB data in bytes */
/* Inputs to LoadKernel() */
/*
* Buffer for data shared between LoadFirmware() and LoadKernel().
* Pass the same buffer which was passed to LoadFirmware().
*/
void *shared_data_blob;
/*
* Size of shared data blob buffer, in bytes. On output, this will
* contain the actual data size placed into the buffer.
*/
uint64_t shared_data_size;
/* Pointer to GBB data */
void *gbb_data;
/* Size of GBB data in bytes */
uint64_t gbb_size;
/* Disk handle for current device */
VbExDiskHandle_t disk_handle;
/* Bytes per lba sector on current device */
uint64_t bytes_per_lba;
/* Last addressable lba sector on current device */
uint64_t ending_lba;
/* Destination buffer for kernel (normally at 0x100000) */
void *kernel_buffer;
/* Size of kernel buffer in bytes */
uint64_t kernel_buffer_size;
/* Boot flags */
uint64_t boot_flags;
/*
* Context for NV storage. Caller is responsible for calling
* VbNvSetup() and VbNvTeardown() on the context.
*/
VbNvContext *nv_context;
VbExDiskHandle_t disk_handle; /* Disk handle for current device */
uint64_t bytes_per_lba; /* Bytes per lba sector on current device */
uint64_t ending_lba; /* Last addressable lba sector on current
* device */
void* kernel_buffer; /* Destination buffer for kernel
* (normally at 0x100000) */
uint64_t kernel_buffer_size; /* Size of kernel buffer in bytes */
uint64_t boot_flags; /* Boot flags */
VbNvContext* nv_context; /* Context for NV storage. Caller is
* responsible for calling VbNvSetup() and
* VbNvTeardown() on the context. */
/* Outputs from LoadKernel(); valid only if LoadKernel() returns
* LOAD_KERNEL_SUCCESS */
uint64_t partition_number; /* Partition number to boot on current device
* (1...M) */
uint64_t bootloader_address; /* Address of bootloader image in RAM */
uint64_t bootloader_size; /* Size of bootloader image in bytes */
uint8_t partition_guid[16]; /* UniquePartitionGuid for boot partition */
/*
* Outputs from LoadKernel(); valid only if LoadKernel() returns
* LOAD_KERNEL_SUCCESS
*/
/* Partition number to boot on current device (1...M) */
uint64_t partition_number;
/* Address of bootloader image in RAM */
uint64_t bootloader_address;
/* Size of bootloader image in bytes */
uint64_t bootloader_size;
/* UniquePartitionGuid for boot partition */
uint8_t partition_guid[16];
} LoadKernelParams;
VbError_t LoadKernel(LoadKernelParams* params);
/* Attempts to load the kernel from the current device.
/**
* Attempt to load the kernel from the current device.
*
* Returns VBERROR_SUCCESS if successful. If unsuccessful, sets a recovery
* reason via VbNvStorage and returns an error code. */
* reason via VbNvStorage and returns an error code.
*/
VbError_t LoadKernel(LoadKernelParams *params);
/*
* The bootloader is loaded using the EFI LoadImage() and StartImage() calls.
* Pass this struct via loaded_image->load_options.
*/
typedef struct KernelBootloaderOptions {
/* The bootloader is loaded using the EFI LoadImage() and StartImage()
* calls. Pass this struct via loaded_image->load_options. */
uint64_t drive_number; /* Drive number of boot device (0...N) */
uint64_t partition_number; /* Partition number, as returned from
* LoadKernel() in
* LoadKernelParams.partition_number */
uint64_t original_address; /* Absolute bootloader start adddress,
* as returned from LoadKernel() in
* LoadKernelParams.bootloader_start */
uint8_t partition_guid[16]; /* UniquePartitionGuid for boot partition */
/* Drive number of boot device (0...N) */
uint64_t drive_number;
/*
* Partition number, as returned from LoadKernel() in
* LoadKernelParams.partition_number
*/
uint64_t partition_number;
/*
* Absolute bootloader start adddress, as returned from LoadKernel() in
* LoadKernelParams.bootloader_start
*/
uint64_t original_address;
/* UniquePartitionGuid for boot partition */
uint8_t partition_guid[16];
} KernelBootloaderOptions;
#endif /* VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ */

View File

@@ -1,9 +1,10 @@
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* TPM Lightweight Command Library.
/*
* TPM Lightweight Command Library.
*
* A low-level library for interfacing to TPM hardware or an emulator.
*/
@@ -17,163 +18,200 @@
/*****************************************************************************/
/* Functions implemented in tlcl.c */
/* Call this first. Returns 0 if success, nonzero if error.
/**
* Call this first. Returns 0 if success, nonzero if error.
*/
uint32_t TlclLibInit(void);
/* Call this on shutdown. Returns 0 if success, nonzero if error.
/**
* Call this on shutdown. Returns 0 if success, nonzero if error.
*/
uint32_t TlclLibClose(void);
/* Logs to stdout. Arguments like printf.
/**
* Log to stdout. Arguments like printf.
*/
void TlclLog(char* format, ...);
void TlclLog(char *format, ...);
/* Sets the log level. 0 is quietest.
/**
* Set the log level. 0 is quietest.
*/
void TlclSetLogLevel(int level);
/* Low-level operations */
/* Performs a raw TPM request/response transaction.
/**
* Perform a raw TPM request/response transaction.
*/
uint32_t TlclSendReceive(const uint8_t* request, uint8_t* response,
uint32_t TlclSendReceive(const uint8_t *request, uint8_t *response,
int max_length);
/* Returns the size of a TPM request or response packet.
/**
* Return the size of a TPM request or response packet.
*/
int TlclPacketSize(const uint8_t* packet);
int TlclPacketSize(const uint8_t *packet);
/* Commands */
/* Sends a TPM_Startup(ST_CLEAR). The TPM error code is returned (0
* for success).
/**
* Send a TPM_Startup(ST_CLEAR). The TPM error code is returned (0 for
* success).
*/
uint32_t TlclStartup(void);
/* Save the TPM state. Normally done by the kernel before a suspend, included
/**
* Save the TPM state. Normally done by the kernel before a suspend, included
* here for tests. The TPM error code is returned (0 for success).
*/
uint32_t TlclSaveState(void);
/* Resumes by sending a TPM_Startup(ST_STATE). The TPM error code is returned
/**
* Resume by sending a TPM_Startup(ST_STATE). The TPM error code is returned
* (0 for success).
*/
uint32_t TlclResume(void);
/* Runs the self test. Note---this is synchronous. To run this in parallel
* with other firmware, use ContinueSelfTest. The TPM error code is returned.
/**
* Run the self test.
*
* Note---this is synchronous. To run this in parallel with other firmware,
* use ContinueSelfTest(). The TPM error code is returned.
*/
uint32_t TlclSelfTestFull(void);
/* Runs the self test in the background.
/**
* Run the self test in the background.
*/
uint32_t TlclContinueSelfTest(void);
/* Defines a space with permission [perm]. [index] is the index for the space,
/**
* Define a space with permission [perm]. [index] is the index for the space,
* [size] the usable data size. The TPM error code is returned.
*/
uint32_t TlclDefineSpace(uint32_t index, uint32_t perm, uint32_t size);
/* Writes [length] bytes of [data] to space at [index]. The TPM error code is
/**
* Write [length] bytes of [data] to space at [index]. The TPM error code is
* returned.
*/
uint32_t TlclWrite(uint32_t index, const void* data, uint32_t length);
uint32_t TlclWrite(uint32_t index, const void *data, uint32_t length);
/* Reads [length] bytes from space at [index] into [data]. The TPM error code
/**
* Read [length] bytes from space at [index] into [data]. The TPM error code
* is returned.
*/
uint32_t TlclRead(uint32_t index, void* data, uint32_t length);
uint32_t TlclRead(uint32_t index, void *data, uint32_t length);
/* Reads PCR at [index] into [data]. [length] must be TPM_PCR_DIGEST or
/**
* Read PCR at [index] into [data]. [length] must be TPM_PCR_DIGEST or
* larger. The TPM error code is returned.
*/
uint32_t TlclPCRRead(uint32_t index, void* data, uint32_t length);
uint32_t TlclPCRRead(uint32_t index, void *data, uint32_t length);
/* Write-locks space at [index]. The TPM error code is returned.
/**
* Write-lock space at [index]. The TPM error code is returned.
*/
uint32_t TlclWriteLock(uint32_t index);
/* Read-locks space at [index]. The TPM error code is returned.
/**
* Read-lock space at [index]. The TPM error code is returned.
*/
uint32_t TlclReadLock(uint32_t index);
/* Asserts physical presence in software. The TPM error code is returned.
/**
* Assert physical presence in software. The TPM error code is returned.
*/
uint32_t TlclAssertPhysicalPresence(void);
/* Enables the physical presence command. The TPM error code is returned.
/**
* Enable the physical presence command. The TPM error code is returned.
*/
uint32_t TlclPhysicalPresenceCMDEnable(void);
/* Finalizes the physical presence settings: sofware PP is enabled, hardware PP
/**
* Finalize the physical presence settings: sofware PP is enabled, hardware PP
* is disabled, and the lifetime lock is set. The TPM error code is returned.
*/
uint32_t TlclFinalizePhysicalPresence(void);
/* Turns off physical presence and locks it off until next reboot. The TPM
/**
* Turn off physical presence and locks it off until next reboot. The TPM
* error code is returned.
*/
uint32_t TlclLockPhysicalPresence(void);
/* Sets the nvLocked bit. The TPM error code is returned.
/**
* Set the nvLocked bit. The TPM error code is returned.
*/
uint32_t TlclSetNvLocked(void);
/* Returns 1 if the TPM is owned, 0 otherwise.
/**
* Return 1 if the TPM is owned, 0 otherwise.
*/
int TlclIsOwned(void);
/* Issues a ForceClear. The TPM error code is returned.
/**
* Issue a ForceClear. The TPM error code is returned.
*/
uint32_t TlclForceClear(void);
/* Issues a PhysicalEnable. The TPM error code is returned.
/**
* Issue a PhysicalEnable. The TPM error code is returned.
*/
uint32_t TlclSetEnable(void);
/* Issues a PhysicalDisable. The TPM error code is returned.
/**
* Issue a PhysicalDisable. The TPM error code is returned.
*/
uint32_t TlclClearEnable(void);
/* Issues a SetDeactivated. Pass 0 to activate. Returns result code.
/**
* Issue a SetDeactivated. Pass 0 to activate. Returns result code.
*/
uint32_t TlclSetDeactivated(uint8_t flag);
/* Gets flags of interest. Pointers for flags you aren't interested in may
/**
* Get flags of interest. Pointers for flags you aren't interested in may
* be NULL. The TPM error code is returned.
*/
uint32_t TlclGetFlags(uint8_t* disable, uint8_t* deactivated,
uint8_t* nvlocked);
uint32_t TlclGetFlags(uint8_t *disable, uint8_t *deactivated,
uint8_t *nvlocked);
/* Sets the bGlobalLock flag, which only a reboot can clear. The TPM error
/**
* Set the bGlobalLock flag, which only a reboot can clear. The TPM error
* code is returned.
*/
uint32_t TlclSetGlobalLock(void);
/* Performs a TPM_Extend.
/**
* Perform a TPM_Extend.
*/
uint32_t TlclExtend(int pcr_num, const uint8_t* in_digest, uint8_t* out_digest);
uint32_t TlclExtend(int pcr_num, const uint8_t *in_digest, uint8_t *out_digest);
/* Gets the permission bits for the NVRAM space with |index|.
/**
* Get the permission bits for the NVRAM space with |index|.
*/
uint32_t TlclGetPermissions(uint32_t index, uint32_t* permissions);
uint32_t TlclGetPermissions(uint32_t index, uint32_t *permissions);
/* Gets the entire set of permanent flags.
/**
* Get the entire set of permanent flags.
*/
uint32_t TlclGetPermanentFlags(TPM_PERMANENT_FLAGS* pflags);
uint32_t TlclGetPermanentFlags(TPM_PERMANENT_FLAGS *pflags);
/* Gets the entire set of volatile (ST_CLEAR) flags.
/**
* Get the entire set of volatile (ST_CLEAR) flags.
*/
uint32_t TlclGetSTClearFlags(TPM_STCLEAR_FLAGS* pflags);
uint32_t TlclGetSTClearFlags(TPM_STCLEAR_FLAGS *pflags);
/* Gets ownership flag. The TPM error code is returned.
/**
* Get the ownership flag. The TPM error code is returned.
*/
uint32_t TlclGetOwnership(uint8_t* owned);
uint32_t TlclGetOwnership(uint8_t *owned);
/* Requests [length] bytes from TPM RNG to be stored in [data]. Actual
* number of bytes read is stored in [size]. The TPM error code is returned.
/**
* Request [length] bytes from TPM RNG to be stored in [data]. Actual number of
* bytes read is stored in [size]. The TPM error code is returned.
*/
uint32_t TlclGetRandom(uint8_t* data, uint32_t length, uint32_t* size);
uint32_t TlclGetRandom(uint8_t *data, uint32_t length, uint32_t *size);
#endif /* TPM_LITE_TLCL_H_ */

View File

@@ -1,9 +1,9 @@
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* Some TPM constants and type definitions for standalone compilation for use in
* the firmware
* Some TPM constants and type definitions for standalone compilation for use
* in the firmware
*/
#ifndef VBOOT_REFERENCE_TSS_CONSTANTS_H_
@@ -63,36 +63,36 @@ typedef uint16_t TPM_STRUCTURE_TAG;
typedef struct tdTPM_PERMANENT_FLAGS
{
TPM_STRUCTURE_TAG tag;
TSS_BOOL disable;
TSS_BOOL ownership;
TSS_BOOL deactivated;
TSS_BOOL readPubek;
TSS_BOOL disableOwnerClear;
TSS_BOOL allowMaintenance;
TSS_BOOL physicalPresenceLifetimeLock;
TSS_BOOL physicalPresenceHWEnable;
TSS_BOOL physicalPresenceCMDEnable;
TSS_BOOL CEKPUsed;
TSS_BOOL TPMpost;
TSS_BOOL TPMpostLock;
TSS_BOOL FIPS;
TSS_BOOL Operator;
TSS_BOOL enableRevokeEK;
TSS_BOOL nvLocked;
TSS_BOOL readSRKPub;
TSS_BOOL tpmEstablished;
TSS_BOOL maintenanceDone;
TSS_BOOL disableFullDALogicInfo;
TPM_STRUCTURE_TAG tag;
TSS_BOOL disable;
TSS_BOOL ownership;
TSS_BOOL deactivated;
TSS_BOOL readPubek;
TSS_BOOL disableOwnerClear;
TSS_BOOL allowMaintenance;
TSS_BOOL physicalPresenceLifetimeLock;
TSS_BOOL physicalPresenceHWEnable;
TSS_BOOL physicalPresenceCMDEnable;
TSS_BOOL CEKPUsed;
TSS_BOOL TPMpost;
TSS_BOOL TPMpostLock;
TSS_BOOL FIPS;
TSS_BOOL Operator;
TSS_BOOL enableRevokeEK;
TSS_BOOL nvLocked;
TSS_BOOL readSRKPub;
TSS_BOOL tpmEstablished;
TSS_BOOL maintenanceDone;
TSS_BOOL disableFullDALogicInfo;
} TPM_PERMANENT_FLAGS;
typedef struct tdTPM_STCLEAR_FLAGS{
TPM_STRUCTURE_TAG tag;
TSS_BOOL deactivated;
TSS_BOOL disableForceClear;
TSS_BOOL physicalPresence;
TSS_BOOL physicalPresenceLock;
TSS_BOOL bGlobalLock;
TPM_STRUCTURE_TAG tag;
TSS_BOOL deactivated;
TSS_BOOL disableForceClear;
TSS_BOOL physicalPresence;
TSS_BOOL physicalPresenceLock;
TSS_BOOL bGlobalLock;
} TPM_STCLEAR_FLAGS;
#endif /* VBOOT_REFERENCE_TSS_CONSTANTS_H_ */

View File

@@ -1,9 +1,10 @@
/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Helper functions/wrappers for memory allocations, manipulation and
/*
* Helper functions/wrappers for memory allocations, manipulation and
* comparison.
*/
@@ -20,7 +21,8 @@
#endif
#ifndef VBOOT_PERFORMANCE
/* Define performance macros as nothing. If you enable VBOOT_PERFORMANCE,
/*
* Define performance macros as nothing. If you enable VBOOT_PERFORMANCE,
* you must define these macros in your platform's biosincludes.h.
*
* Intended usage for using a performance counter called 'foo':
@@ -50,56 +52,72 @@
#define VBEASTEREGG 0
#endif
/* Combine [msw] and [lsw] uint16s to a uint32_t with its [msw] and
* [lsw] forming the most and least signficant 16-bit words.
/*
* Combine [msw] and [lsw] uint16s to a uint32_t with its [msw] and [lsw]
* forming the most and least signficant 16-bit words.
*/
#define CombineUint16Pair(msw,lsw) (((uint32_t)(msw) << 16) | \
(((lsw)) & 0xFFFF))
/* Return the minimum of (a) or (b). */
#define Min(a, b) (((a) < (b)) ? (a) : (b))
/* Compare [n] bytes in [src1] and [src2]
* Returns an integer less than, equal to, or greater than zero if the first [n]
* bytes of [src1] is found, respectively, to be less than, to match, or be
/**
* Compare [n] bytes in [src1] and [src2].
*
* Returns an integer less than, equal to, or greater than zero if the first
* [n] bytes of [src1] is found, respectively, to be less than, to match, or be
* greater than the first n bytes of [src2]. */
int Memcmp(const void* src1, const void* src2, size_t n);
int Memcmp(const void *src1, const void *src2, size_t n);
/* Copy [n] bytes from [src] to [dest]. */
void* Memcpy(void* dest, const void* src, uint64_t n);
/**
* Copy [n] bytes from [src] to [dest].
*/
void *Memcpy(void *dest, const void *src, uint64_t n);
/*
* Implementations of the functions below must be built as part of the firmware
* and defined in lib/utility.c.
*/
/* Implementations of the functions below must be built as part of the firmware
* and defined in lib/utility.c */
/**
* Set [n] bytes starting at [s] to [c]. Returns dest.
*/
void *Memset(void *dest, const uint8_t c, uint64_t n);
/* Set [n] bytes starting at [s] to [c]. Returns dest. */
void* Memset(void* dest, const uint8_t c, uint64_t n);
/* Compare [n] bytes starting at [s1] with [s2] and return 0 if they
/**
* Compare [n] bytes starting at [s1] with [s2] and return 0 if they
* match, 1 if they don't. Returns 0 if n=0, since no bytes mismatched.
*
* Time taken to perform the comparison is only dependent on [n] and
* not on the relationship of the match between [s1] and [s2].
*
* Note that unlike Memcmp(), this only indicates inequality, not
* whether s1 is less than or greater than s2.
*/
int SafeMemcmp(const void* s1, const void* s2, size_t n);
int SafeMemcmp(const void *s1, const void *s2, size_t n);
/* Buffer size required to hold the longest possible output of
* Uint64ToString() - that is, Uint64ToString(~0, 2). */
/*
* Buffer size required to hold the longest possible output of Uint64ToString()
* - that is, Uint64ToString(~0, 2).
*/
#define UINT64_TO_STRING_MAX 65
/* Convert a value to a string in the specified radix (2=binary, 10=decimal,
/**
* Convert a value to a string in the specified radix (2=binary, 10=decimal,
* 16=hex) and store it in <buf>, which is <bufsize> chars long. If
* <zero_pad_width>, left-pads the string to at least that width with '0'.
* Returns the length of the stored string, not counting the terminating
* null. */
* Returns the length of the stored string, not counting the terminating null.
*/
uint32_t Uint64ToString(char *buf, uint32_t bufsize, uint64_t value,
uint32_t radix, uint32_t zero_pad_width);
/* Concatenate <src> onto <dest>, which has space for <destlen> characters
/**
* Concatenate <src> onto <dest>, which has space for <destlen> characters
* including the terminating null. Note that <dest> will always be
* null-terminated if <destlen> > 0. Returns the number of characters
* used in <dest>, not counting the terminating null. */
* null-terminated if <destlen> > 0. Returns the number of characters used in
* <dest>, not counting the terminating null.
*/
uint32_t Strncat(char *dest, const char *src, uint32_t destlen);
/* Ensure that only our stub implementations are used, not standard C */

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,9 @@
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Non-volatile storage routines for verified boot.
*/
/* Non-volatile storage routines for verified boot. */
#ifndef VBOOT_REFERENCE_NVSTORAGE_H_
#define VBOOT_REFERENCE_NVSTORAGE_H_
@@ -12,70 +11,88 @@
#define VBNV_BLOCK_SIZE 16 /* Size of NV storage block in bytes */
typedef struct VbNvContext {
/* Raw NV data. Caller must fill this before calling VbNvSetup(). */
uint8_t raw[VBNV_BLOCK_SIZE];
/* Flag indicating whether raw data has changed. Set by VbNvTeardown() if
* the raw data has changed and needs to be stored to the underlying
* non-volatile data store. */
int raw_changed;
/* Internal data for NV storage routines. Caller should not touch
* these fields. */
int regenerate_crc;
/* Raw NV data. Caller must fill this before calling VbNvSetup(). */
uint8_t raw[VBNV_BLOCK_SIZE];
/*
* Flag indicating whether raw data has changed. Set by VbNvTeardown()
* if the raw data has changed and needs to be stored to the underlying
* non-volatile data store.
*/
int raw_changed;
/*
* Internal data for NV storage routines. Caller should not touch
* these fields.
*/
int regenerate_crc;
} VbNvContext;
/* Parameter type for VbNvGet(), VbNvSet(). */
typedef enum VbNvParam {
/* Parameter values have been reset to defaults (flag for firmware).
* 0=clear; 1=set. */
VBNV_FIRMWARE_SETTINGS_RESET = 0,
/* Parameter values have been reset to defaults (flag for kernel).
* 0=clear; 1=set. */
VBNV_KERNEL_SETTINGS_RESET,
/* Request debug reset on next S3->S0 transition. 0=clear; 1=set. */
VBNV_DEBUG_RESET_MODE,
/* Number of times to try booting RW firmware slot B before slot A.
* Valid range: 0-15. */
VBNV_TRY_B_COUNT,
/* Request recovery mode on next boot; see VBNB_RECOVERY_* below for
* currently defined reason codes. 8-bit value. */
VBNV_RECOVERY_REQUEST,
/* Localization index for screen bitmaps displayed by firmware.
* 8-bit value. */
VBNV_LOCALIZATION_INDEX,
/* Field reserved for kernel/user-mode use; 32-bit value. */
VBNV_KERNEL_FIELD,
/* Allow booting from USB in developer mode. 0=no, 1=yes. */
VBNV_DEV_BOOT_USB,
/* Allow booting of legacy OSes in developer mode. 0=no, 1=yes. */
VBNV_DEV_BOOT_LEGACY,
/* Only boot Google-signed images in developer mode. 0=no, 1=yes. */
VBNV_DEV_BOOT_SIGNED_ONLY,
/* Set by userspace to request that RO firmware disable dev-mode on the next
* boot. This is likely only possible if the dev-switch is virtual. */
VBNV_DISABLE_DEV_REQUEST,
/* Set and cleared by vboot to request that the video Option ROM be loaded at
* boot time, so that BIOS screens can be displayed. 0=no, 1=yes. */
VBNV_OPROM_NEEDED,
/* Request that the firmware clear the TPM owner on the next boot. */
VBNV_CLEAR_TPM_OWNER_REQUEST,
/* Flag that TPM owner was cleared on request. */
VBNV_CLEAR_TPM_OWNER_DONE,
/* More details on recovery reason */
VBNV_RECOVERY_SUBCODE,
/*
* Parameter values have been reset to defaults (flag for firmware).
* 0=clear; 1=set.
*/
VBNV_FIRMWARE_SETTINGS_RESET = 0,
/*
* Parameter values have been reset to defaults (flag for kernel).
* 0=clear; 1=set.
*/
VBNV_KERNEL_SETTINGS_RESET,
/* Request debug reset on next S3->S0 transition. 0=clear; 1=set. */
VBNV_DEBUG_RESET_MODE,
/*
* Number of times to try booting RW firmware slot B before slot A.
* Valid range: 0-15.
*/
VBNV_TRY_B_COUNT,
/*
* Request recovery mode on next boot; see VBNB_RECOVERY_* below for
* currently defined reason codes. 8-bit value.
*/
VBNV_RECOVERY_REQUEST,
/*
* Localization index for screen bitmaps displayed by firmware.
* 8-bit value.
*/
VBNV_LOCALIZATION_INDEX,
/* Field reserved for kernel/user-mode use; 32-bit value. */
VBNV_KERNEL_FIELD,
/* Allow booting from USB in developer mode. 0=no, 1=yes. */
VBNV_DEV_BOOT_USB,
/* Allow booting of legacy OSes in developer mode. 0=no, 1=yes. */
VBNV_DEV_BOOT_LEGACY,
/* Only boot Google-signed images in developer mode. 0=no, 1=yes. */
VBNV_DEV_BOOT_SIGNED_ONLY,
/*
* Set by userspace to request that RO firmware disable dev-mode on the
* next boot. This is likely only possible if the dev-switch is
* virtual.
*/
VBNV_DISABLE_DEV_REQUEST,
/*
* Set and cleared by vboot to request that the video Option ROM be
* loaded at boot time, so that BIOS screens can be displayed. 0=no,
* 1=yes.
*/
VBNV_OPROM_NEEDED,
/* Request that the firmware clear the TPM owner on the next boot. */
VBNV_CLEAR_TPM_OWNER_REQUEST,
/* Flag that TPM owner was cleared on request. */
VBNV_CLEAR_TPM_OWNER_DONE,
/* More details on recovery reason */
VBNV_RECOVERY_SUBCODE,
} VbNvParam;
/* Recovery reason codes for VBNV_RECOVERY_REQUEST */
/* Recovery not requested. */
#define VBNV_RECOVERY_NOT_REQUESTED 0x00
/* Recovery requested from legacy utility. (Prior to the NV storage
* spec, recovery mode was a single bitfield; this value is reserved
* so that scripts which wrote 1 to the recovery field are
* distinguishable from scripts whch use the recovery reasons listed
* here. */
/*
* Recovery requested from legacy utility. (Prior to the NV storage spec,
* recovery mode was a single bitfield; this value is reserved so that scripts
* which wrote 1 to the recovery field are distinguishable from scripts whch
* use the recovery reasons listed here.
*/
#define VBNV_RECOVERY_LEGACY 0x01
/* User manually requested recovery via recovery button */
#define VBNV_RECOVERY_RO_MANUAL 0x02
@@ -93,17 +110,23 @@ typedef enum VbNvParam {
#define VBNV_RECOVERY_RO_TEST_LFS 0x08
/* Test error from LoadFirmware() */
#define VBNV_RECOVERY_RO_TEST_LF 0x09
/* RW firmware failed signature check (neither RW firmware slot was valid).
/*
* RW firmware failed signature check (neither RW firmware slot was valid).
* Recovery reason is VBNV_RECOVERY_RO_INVALID_RW_CHECK_MIN + the check value
* for the slot which came closest to validating; see VBSD_LF_CHECK_* in
* vboot_struct.h. */
* vboot_struct.h.
*/
#define VBNV_RECOVERY_RO_INVALID_RW_CHECK_MIN 0x10
#define VBNV_RECOVERY_RO_INVALID_RW_CHECK_MAX 0x1F
/* Firmware boot failure outside of verified boot (RAM init, missing SSD,
* etc.). */
/*
* Firmware boot failure outside of verified boot (RAM init, missing SSD,
* etc.).
*/
#define VBNV_RECOVERY_RO_FIRMWARE 0x20
/* Recovery mode TPM initialization requires a system reboot. The system was
* already in recovery mode for some other reason when this happened. */
/*
* Recovery mode TPM initialization requires a system reboot. The system was
* already in recovery mode for some other reason when this happened.
*/
#define VBNV_RECOVERY_RO_TPM_REBOOT 0x21
/* EC software sync - other error */
#define VBNV_RECOVERY_EC_SOFTWARE_SYNC 0x22
@@ -121,8 +144,10 @@ typedef enum VbNvParam {
#define VBNV_RECOVERY_EC_PROTECT 0x28
/* Unspecified/unknown error in read-only firmware */
#define VBNV_RECOVERY_RO_UNSPECIFIED 0x3F
/* User manually requested recovery by pressing a key at developer
* warning screen */
/*
* User manually requested recovery by pressing a key at developer
* warning screen
*/
#define VBNV_RECOVERY_RW_DEV_SCREEN 0x41
/* No OS kernel detected */
#define VBNV_RECOVERY_RW_NO_OS 0x42
@@ -175,10 +200,11 @@ typedef enum VbNvParam {
/* Unspecified/unknown error in user-mode */
#define VBNV_RECOVERY_US_UNSPECIFIED 0xFF
/* Initialize the NV storage library. This must be called before any
* other functions in this library. Returns 0 if success, non-zero if
* error.
/**
* Initialize the NV storage library.
*
* This must be called before any other functions in this library. Returns 0
* if success, non-zero if error.
*
* Proper calling procedure:
* 1) Allocate a context struct.
@@ -187,14 +213,17 @@ typedef enum VbNvParam {
* 3) Read underlying storage and fill in context->raw.
* 4) Call VbNvSetup().
*
* If you have access to global variables, you may want to wrap all
* that in your own VbNvOpen() function. We don't do that in here
* because there are no global variables in UEFI BIOS during the PEI
* phase (that's also why we have to pass around a context pointer). */
int VbNvSetup(VbNvContext* context);
* If you have access to global variables, you may want to wrap all that in
* your own VbNvOpen() function. We don't do that in here because there are no
* global variables in UEFI BIOS during the PEI phase (that's also why we have
* to pass around a context pointer).
*/
int VbNvSetup(VbNvContext *context);
/* Clean up and flush changes back to the raw data. This must be
* called after other functions in this library. Returns 0 if
/**
* Clean up and flush changes back to the raw data.
*
* This must be called after other functions in this library. Returns 0 if
* success, non-zero if error.
*
* Proper calling procedure:
@@ -204,20 +233,26 @@ int VbNvSetup(VbNvContext* context);
* 4) Free the context struct.
*
* If you have access to global variables, you may want to wrap this
* in your own VbNvClose() function. */
int VbNvTeardown(VbNvContext* context);
* in your own VbNvClose() function.
*/
int VbNvTeardown(VbNvContext *context);
/* Read a NV storage parameter into *dest. Returns 0 if success,
* non-zero if error.
/**
* Read a NV storage parameter into *dest.
*
* This may only be called between VbNvSetup() and VbNvTeardown(). */
int VbNvGet(VbNvContext* context, VbNvParam param, uint32_t* dest);
/* Set a NV storage param to a new value. Returns 0 if success,
* non-zero if error.
* Returns 0 if success, non-zero if error.
*
* This may only be called between VbNvSetup() and VbNvTeardown(). */
int VbNvSet(VbNvContext* context, VbNvParam param, uint32_t value);
* This may only be called between VbNvSetup() and VbNvTeardown().
*/
int VbNvGet(VbNvContext *context, VbNvParam param, uint32_t *dest);
/**
* Set a NV storage param to a new value.
*
* Returns 0 if success, non-zero if error.
*
* This may only be called between VbNvSetup() and VbNvTeardown().
*/
int VbNvSet(VbNvContext *context, VbNvParam param, uint32_t value);
#endif /* VBOOT_REFERENCE_NVSTORAGE_H_ */

View File

@@ -1,4 +1,4 @@
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -15,27 +15,30 @@ __pragma(pack(push, 1)) /* Support packing for MSVC. */
/* Public key data */
typedef struct VbPublicKey {
uint64_t key_offset; /* Offset of key data from start of this struct */
uint64_t key_size; /* Size of key data in bytes (NOT strength of key
* in bits) */
uint64_t algorithm; /* Signature algorithm used by the key */
uint64_t key_version; /* Key version */
/* Offset of key data from start of this struct */
uint64_t key_offset;
/* Size of key data in bytes (NOT strength of key in bits) */
uint64_t key_size;
/* Signature algorithm used by the key */
uint64_t algorithm;
/* Key version */
uint64_t key_version;
} __attribute__((packed)) VbPublicKey;
#define EXPECTED_VBPUBLICKEY_SIZE 32
/* Signature data (a secure hash, possibly signed) */
typedef struct VbSignature {
uint64_t sig_offset; /* Offset of signature data from start of this
* struct */
uint64_t sig_size; /* Size of signature data in bytes */
uint64_t data_size; /* Size of the data block which was signed in bytes */
/* Offset of signature data from start of this struct */
uint64_t sig_offset;
/* Size of signature data in bytes */
uint64_t sig_size;
/* Size of the data block which was signed in bytes */
uint64_t data_size;
} __attribute__((packed)) VbSignature;
#define EXPECTED_VBSIGNATURE_SIZE 24
#define KEY_BLOCK_MAGIC "CHROMEOS"
#define KEY_BLOCK_MAGIC_SIZE 8
@@ -49,30 +52,43 @@ typedef struct VbSignature {
#define KEY_BLOCK_FLAG_RECOVERY_0 UINT64_C(0x04) /* Not recovery mode */
#define KEY_BLOCK_FLAG_RECOVERY_1 UINT64_C(0x08) /* Recovery mode */
/* Key block, containing the public key used to sign some other chunk
* of data. */
typedef struct VbKeyBlockHeader {
uint8_t magic[KEY_BLOCK_MAGIC_SIZE]; /* Magic number */
uint32_t header_version_major; /* Version of this header format */
uint32_t header_version_minor; /* Version of this header format */
uint64_t key_block_size; /* Length of this entire key block,
* including keys, signatures, and
* padding, in bytes */
VbSignature key_block_signature; /* Signature for this key block
* (header + data pointed to by data_key)
* For use with signed data keys*/
VbSignature key_block_checksum; /* SHA-512 checksum for this key block
* (header + data pointed to by data_key)
* For use with unsigned data keys */
uint64_t key_block_flags; /* Flags for key (KEY_BLOCK_FLAG_*) */
VbPublicKey data_key; /* Key to verify the chunk of data */
} __attribute__((packed)) VbKeyBlockHeader;
/* This should be followed by:
/*
* Key block, containing the public key used to sign some other chunk of data.
*
* This should be followed by:
* 1) The data_key key data, pointed to by data_key.key_offset.
* 2) The checksum data for (VBKeyBlockHeader + data_key data), pointed to
* by key_block_checksum.sig_offset.
* 3) The signature data for (VBKeyBlockHeader + data_key data), pointed to
* by key_block_signature.sig_offset. */
* by key_block_signature.sig_offset.
*/
typedef struct VbKeyBlockHeader {
/* Magic number */
uint8_t magic[KEY_BLOCK_MAGIC_SIZE];
/* Version of this header format */
uint32_t header_version_major;
/* Version of this header format */
uint32_t header_version_minor;
/*
* Length of this entire key block, including keys, signatures, and
* padding, in bytes
*/
uint64_t key_block_size;
/*
* Signature for this key block (header + data pointed to by data_key)
* For use with signed data keys
*/
VbSignature key_block_signature;
/*
* SHA-512 checksum for this key block (header + data pointed to by
* data_key) For use with unsigned data keys
*/
VbSignature key_block_checksum;
/* Flags for key (KEY_BLOCK_FLAG_*) */
uint64_t key_block_flags;
/* Key to verify the chunk of data */
VbPublicKey data_key;
} __attribute__((packed)) VbKeyBlockHeader;
#define EXPECTED_VBKEYBLOCKHEADER_SIZE 112
@@ -83,119 +99,170 @@ typedef struct VbKeyBlockHeader {
/* Flags for VbECPreambleHeader.flags */
/* Use the normal boot path from the read-only firmware, instead
* of verifying the body signature. */
/*
* Use the normal boot path from the read-only firmware, instead of verifying
* the body signature.
*/
#define VB_EC_PREAMBLE_USE_RO_NORMAL 0x00000001
/* Premable block for EC rewritable firmware, version 1.0 */
/*
* Premable block for EC rewritable firmware, version 1.0.
*
* The firmware preamble header should be followed by:
* 1) The signature data for the firmware body, pointed to by
* body_signature.sig_offset.
* 2) The signature data for (header + body signature data), pointed
* to by preamble_signature.sig_offset.
*/
typedef struct VbECPreambleHeader {
uint64_t preamble_size; /* Size of this preamble, including keys,
* signatures, and padding, in bytes */
VbSignature preamble_signature; /* Signature for this preamble
* (header + * body signature) */
uint32_t header_version_major; /* Version of this header format */
uint32_t header_version_minor; /* Version of this header format */
uint64_t firmware_version; /* Firmware version */
VbSignature body_digest; /* Digest for the firmware body */
uint32_t flags; /* Flags; see VB_EC_PREAMBLE_* */
char name[128]; /* Human-readable ASCII, null-padded */
/*
* Size of this preamble, including keys, signatures, and padding, in
* bytes
*/
uint64_t preamble_size;
/* Signature for this preamble (header + * body signature) */
VbSignature preamble_signature;
/* Version of this header format */
uint32_t header_version_major;
/* Version of this header format */
uint32_t header_version_minor;
/* Firmware version */
uint64_t firmware_version;
/* Digest for the firmware body */
VbSignature body_digest;
/* Flags; see VB_EC_PREAMBLE_* */
uint32_t flags;
/* Human-readable ASCII, null-padded */
char name[128];
} __attribute__((packed)) VbECPreambleHeader;
#define EXPECTED_VB_EC_PREAMBLE_HEADER1_0_SIZE 76
/* The firmware preamble header should be followed by:
* 2) The signature data for the firmware body, pointed to by
* body_signature.sig_offset.
* 3) The signature data for (header + body signature data), pointed
* to by preamble_signature.sig_offset. */
/****************************************************************************/
#define FIRMWARE_PREAMBLE_HEADER_VERSION_MAJOR 2
#define FIRMWARE_PREAMBLE_HEADER_VERSION_MINOR 1
/* Preamble block for rewritable firmware, version 2.0. All 2.x
* versions of this struct must start with the same data, to be
* compatible with version 2.0 readers. */
/*
* Preamble block for rewritable firmware, version 2.0. All 2.x versions of
* this struct must start with the same data, to be compatible with version 2.0
* readers.
*/
typedef struct VbFirmwarePreambleHeader2_0 {
uint64_t preamble_size; /* Size of this preamble, including keys,
* signatures, and padding, in bytes */
VbSignature preamble_signature; /* Signature for this preamble
* (header + kernel subkey +
* body signature) */
uint32_t header_version_major; /* Version of this header format (= 2) */
uint32_t header_version_minor; /* Version of this header format (= 0) */
/*
* Size of this preamble, including keys, signatures, and padding, in
* bytes
*/
uint64_t preamble_size;
/*
* Signature for this preamble (header + kernel subkey + body
* signature)
*/
VbSignature preamble_signature;
/* Version of this header format (= 2) */
uint32_t header_version_major;
/* Version of this header format (= 0) */
uint32_t header_version_minor;
uint64_t firmware_version; /* Firmware version */
VbPublicKey kernel_subkey; /* Key to verify kernel key block */
VbSignature body_signature; /* Signature for the firmware body */
/* Firmware version */
uint64_t firmware_version;
/* Key to verify kernel key block */
VbPublicKey kernel_subkey;
/* Signature for the firmware body */
VbSignature body_signature;
} __attribute__((packed)) VbFirmwarePreambleHeader2_0;
#define EXPECTED_VBFIRMWAREPREAMBLEHEADER2_0_SIZE 104
/* Flags for VbFirmwarePreambleHeader.flags */
/* Use the normal/dev boot path from the read-only firmware, instead
* of verifying the body signature. */
/*
* Use the normal/dev boot path from the read-only firmware, instead of
* verifying the body signature.
*/
#define VB_FIRMWARE_PREAMBLE_USE_RO_NORMAL 0x00000001
/* Premable block for rewritable firmware, version 2.1 */
typedef struct VbFirmwarePreambleHeader {
uint64_t preamble_size; /* Size of this preamble, including keys,
* signatures, and padding, in bytes */
VbSignature preamble_signature; /* Signature for this preamble
* (header + kernel subkey +
* body signature) */
uint32_t header_version_major; /* Version of this header format */
uint32_t header_version_minor; /* Version of this header format */
uint64_t firmware_version; /* Firmware version */
VbPublicKey kernel_subkey; /* Key to verify kernel key block */
VbSignature body_signature; /* Signature for the firmware body */
/* Fields added in header version 2.1. You must verify the header version
* before reading these fields! */
uint32_t flags; /* Flags; see VB_FIRMWARE_PREAMBLE_*.
* Readers should return 0 for header
* version < 2.1. */
} __attribute__((packed)) VbFirmwarePreambleHeader;
#define EXPECTED_VBFIRMWAREPREAMBLEHEADER2_1_SIZE 108
/* The firmware preamble header should be followed by:
/* Premable block for rewritable firmware, version 2.1.
*
* The firmware preamble header should be followed by:
* 1) The kernel_subkey key data, pointed to by kernel_subkey.key_offset.
* 2) The signature data for the firmware body, pointed to by
* body_signature.sig_offset.
* 3) The signature data for (header + kernel_subkey data + body signature
* data), pointed to by preamble_signature.sig_offset. */
* data), pointed to by preamble_signature.sig_offset.
*/
typedef struct VbFirmwarePreambleHeader {
/*
* Size of this preamble, including keys, signatures, and padding, in
* bytes
*/
uint64_t preamble_size;
/*
* Signature for this preamble (header + kernel subkey + body
* signature)
*/
VbSignature preamble_signature;
/* Version of this header format */
uint32_t header_version_major;
/* Version of this header format */
uint32_t header_version_minor;
/* Firmware version */
uint64_t firmware_version;
/* Key to verify kernel key block */
VbPublicKey kernel_subkey;
/* Signature for the firmware body */
VbSignature body_signature;
/*
* Fields added in header version 2.1. You must verify the header
* version before reading these fields!
*/
/*
* Flags; see VB_FIRMWARE_PREAMBLE_*. Readers should return 0 for
* header version < 2.1.
*/
uint32_t flags;
} __attribute__((packed)) VbFirmwarePreambleHeader;
#define EXPECTED_VBFIRMWAREPREAMBLEHEADER2_1_SIZE 108
/****************************************************************************/
#define KERNEL_PREAMBLE_HEADER_VERSION_MAJOR 2
#define KERNEL_PREAMBLE_HEADER_VERSION_MINOR 0
/* Preamble block for kernel */
typedef struct VbKernelPreambleHeader {
uint64_t preamble_size; /* Size of this preamble, including keys,
* signatures, and padding, in bytes */
VbSignature preamble_signature; /* Signature for this preamble
* (header + body signature) */
uint32_t header_version_major; /* Version of this header format */
uint32_t header_version_minor; /* Version of this header format */
uint64_t kernel_version; /* Kernel version */
uint64_t body_load_address; /* Load address for kernel body */
uint64_t bootloader_address; /* Address of bootloader, after body is
* loaded at body_load_address */
uint64_t bootloader_size; /* Size of bootloader in bytes */
VbSignature body_signature; /* Signature for the kernel body */
} __attribute__((packed)) VbKernelPreambleHeader;
/* This should be followed by:
* 2) The signature data for the kernel body, pointed to by
/* Preamble block for kernel
*
* This should be followed by:
* 1) The signature data for the kernel body, pointed to by
* body_signature.sig_offset.
* 3) The signature data for (VBFirmwarePreambleHeader + body signature
* data), pointed to by preamble_signature.sig_offset. */
* 2) The signature data for (VBFirmwarePreambleHeader + body signature
* data), pointed to by preamble_signature.sig_offset.
*/
typedef struct VbKernelPreambleHeader {
/*
* Size of this preamble, including keys, signatures, and padding, in
* bytes
*/
uint64_t preamble_size;
/* Signature for this preamble (header + body signature) */
VbSignature preamble_signature;
/* Version of this header format */
uint32_t header_version_major;
/* Version of this header format */
uint32_t header_version_minor;
/* Kernel version */
uint64_t kernel_version;
/* Load address for kernel body */
uint64_t body_load_address;
/* Address of bootloader, after body is loaded at body_load_address */
uint64_t bootloader_address;
/* Size of bootloader in bytes */
uint64_t bootloader_size;
/* Signature for the kernel body */
VbSignature body_signature;
} __attribute__((packed)) VbKernelPreambleHeader;
#define EXPECTED_VBKERNELPREAMBLEHEADER_SIZE 96
@@ -213,9 +280,11 @@ typedef struct VbKernelPreambleHeader {
/* Flags for VbSharedDataHeader */
/* LoadFirmware() tried firmware B because of VbNvStorage firmware B tries */
#define VBSD_FWB_TRIED 0x00000001
/* LoadKernel() verified the good kernel keyblock using the kernel subkey from
/*
* LoadKernel() verified the good kernel keyblock using the kernel subkey from
* the firmware. If this flag is not present, it just used the hash of the
* kernel keyblock. */
* kernel keyblock.
*/
#define VBSD_KERNEL_KEY_VERIFIED 0x00000002
/* LoadFirmware() was told the developer switch was on */
#define VBSD_LF_DEV_SWITCH_ON 0x00000004
@@ -240,9 +309,11 @@ typedef struct VbKernelPreambleHeader {
/* Firmware software write protect was enabled at boot time */
#define VBSD_BOOT_FIRMWARE_SW_WP_ENABLED 0x00002000
/* Supported flags by header version. It's ok to add new flags while keeping
/*
* Supported flags by header version. It's ok to add new flags while keeping
* struct version 2 as long as flag-NOT-present is the correct value for
* existing hardware (Stumpy/Lumpy). */
* existing hardware (Stumpy/Lumpy).
*/
#define VBSD_FLAGS_VERSION_1 0x00000007 /* Alex, ZGB */
#define VBSD_FLAGS_VERSION_2 0x00000F7F
@@ -260,8 +331,10 @@ typedef struct VbKernelPreambleHeader {
#define VBSD_LF_CHECK_HASH_WRONG_SIZE 10
#define VBSD_LF_CHECK_VERIFY_BODY 11
#define VBSD_LF_CHECK_VALID 12
/* Read-only normal path requested by firmware preamble, but
* unsupported by firmware. */
/*
* Read-only normal path requested by firmware preamble, but unsupported by
* firmware.
*/
#define VBSD_LF_CHECK_NO_RO_NORMAL 13
/* Boot mode for VbSharedDataHeader.lk_boot_mode */
@@ -285,8 +358,10 @@ typedef struct VbKernelPreambleHeader {
#define VBSD_LKP_CHECK_VERIFY_PREAMBLE 9
#define VBSD_LKP_CHECK_KERNEL_ROLLBACK 10
#define VBSD_LKP_CHECK_PREAMBLE_VALID 11
/* Body load address check is omitted; this result code is deprecated and not
* used anywhere in the codebase. */
/*
* Body load address check is omitted; this result code is deprecated and not
* used anywhere in the codebase.
*/
#define VBSD_LKP_CHECK_BODY_ADDRESS 12
#define VBSD_LKP_CHECK_BODY_OFFSET 13
#define VBSD_LKP_CHECK_SELF_SIGNED 14
@@ -296,16 +371,15 @@ typedef struct VbKernelPreambleHeader {
#define VBSD_LKP_CHECK_VERIFY_DATA 18
#define VBSD_LKP_CHECK_KERNEL_GOOD 19
/* Information about a single kernel partition check in LoadKernel() */
typedef struct VbSharedDataKernelPart {
uint64_t sector_start; /* Start sector of partition */
uint64_t sector_count; /* Sector count of partition */
uint32_t combined_version; /* Combined key+kernel version */
uint8_t gpt_index; /* Index of partition in GPT */
uint8_t check_result; /* Check result; see VBSD_LKP_CHECK_* */
uint8_t flags; /* Flags (see VBSD_LKP_FLAG_* */
uint8_t reserved0; /* Reserved for padding */
uint64_t sector_start; /* Start sector of partition */
uint64_t sector_count; /* Sector count of partition */
uint32_t combined_version; /* Combined key+kernel version */
uint8_t gpt_index; /* Index of partition in GPT */
uint8_t check_result; /* Check result; see VBSD_LKP_CHECK_* */
uint8_t flags; /* Flags (see VBSD_LKP_FLAG_* */
uint8_t reserved0; /* Reserved for padding */
} VbSharedDataKernelPart;
/* Number of kernel partitions to track per call. Must be power of 2. */
@@ -326,25 +400,35 @@ typedef struct VbSharedDataKernelPart {
/* Information about a single call to LoadKernel() */
typedef struct VbSharedDataKernelCall {
uint32_t boot_flags; /* Bottom 32 bits of flags passed in
* LoadKernelParams.boot_flags */
uint32_t flags; /* Debug flags; see VBSD_LK_FLAG_* */
uint64_t sector_count; /* Number of sectors on drive */
uint32_t sector_size; /* Sector size in bytes */
uint8_t check_result; /* Check result; see VBSD_LKC_CHECK_* */
uint8_t boot_mode; /* Boot mode for LoadKernel(); see
* VBSD_LK_BOOT_MODE_* constants */
uint8_t test_error_num; /* Test error number, if non-zero */
uint8_t return_code; /* Return code from LoadKernel() */
uint8_t kernel_parts_found; /* Number of kernel partitions found */
uint8_t reserved0[7]; /* Reserved for padding */
VbSharedDataKernelPart parts[VBSD_MAX_KERNEL_PARTS]; /* Data on kernels */
/* Bottom 32 bits of flags passed in LoadKernelParams.boot_flags */
uint32_t boot_flags;
/* Debug flags; see VBSD_LK_FLAG_* */
uint32_t flags;
/* Number of sectors on drive */
uint64_t sector_count;
/* Sector size in bytes */
uint32_t sector_size;
/* Check result; see VBSD_LKC_CHECK_* */
uint8_t check_result;
/* Boot mode for LoadKernel(); see VBSD_LK_BOOT_MODE_* constants */
uint8_t boot_mode;
/* Test error number, if non-zero */
uint8_t test_error_num;
/* Return code from LoadKernel() */
uint8_t return_code;
/* Number of kernel partitions found */
uint8_t kernel_parts_found;
/* Reserved for padding */
uint8_t reserved0[7];
/* Data on kernels */
VbSharedDataKernelPart parts[VBSD_MAX_KERNEL_PARTS];
} VbSharedDataKernelCall;
/* Number of kernel calls to track. Must be power of 2. */
#define VBSD_MAX_KERNEL_CALLS 4
/* Data shared between LoadFirmware(), LoadKernel(), and OS.
/*
* Data shared between LoadFirmware(), LoadKernel(), and OS.
*
* The boot process is:
* 1) Caller allocates buffer, at least VB_SHARED_DATA_MIN bytes, ideally
@@ -355,86 +439,113 @@ typedef struct VbSharedDataKernelCall {
* LoadKernel() initializes the buffer, adding this header. Regardless
* of boot type, LoadKernel() adds some data to the buffer.
* 4) Caller makes data available to the OS in a platform-dependent manner.
* For example, via ACPI or ATAGs. */
* For example, via ACPI or ATAGs.
*/
typedef struct VbSharedDataHeader {
/* Fields present in version 1 */
uint32_t magic; /* Magic number for struct
* (VB_SHARED_DATA_MAGIC) */
uint32_t struct_version; /* Version of this structure */
uint64_t struct_size; /* Size of this structure in bytes */
uint64_t data_size; /* Size of shared data buffer in bytes */
uint64_t data_used; /* Amount of shared data used so far */
uint32_t flags; /* Flags */
uint32_t reserved0; /* Reserved for padding */
/* Fields present in version 1 */
/* Magic number for struct (VB_SHARED_DATA_MAGIC) */
uint32_t magic;
/* Version of this structure */
uint32_t struct_version;
/* Size of this structure in bytes */
uint64_t struct_size;
/* Size of shared data buffer in bytes */
uint64_t data_size;
/* Amount of shared data used so far */
uint64_t data_used;
/* Flags */
uint32_t flags;
/* Reserved for padding */
uint32_t reserved0;
/* Kernel subkey, from firmware */
VbPublicKey kernel_subkey;
/* Offset of kernel subkey data from start of this struct */
uint64_t kernel_subkey_data_offset;
/* Size of kernel subkey data */
uint64_t kernel_subkey_data_size;
VbPublicKey kernel_subkey; /* Kernel subkey, from firmware */
uint64_t kernel_subkey_data_offset; /* Offset of kernel subkey data from
* start of this struct */
uint64_t kernel_subkey_data_size; /* Size of kernel subkey data */
/*
* Timer values from VbExGetTimer(). Unused values are set to 0. Note
* that these are now the enter/exit times for the wrapper API entry
* points; see crosbug.com/17018. */
/* VbInit() enter/exit */
uint64_t timer_vb_init_enter;
uint64_t timer_vb_init_exit;
/* VbSelectFirmware() enter/exit */
uint64_t timer_vb_select_firmware_enter;
uint64_t timer_vb_select_firmware_exit;
/* VbSelectAndLoadKernel() enter/exit */
uint64_t timer_vb_select_and_load_kernel_enter;
uint64_t timer_vb_select_and_load_kernel_exit;
/* Timer values from VbExGetTimer(). Unused values are set to 0.
* Note that these are now the enter/exit times for the wrapper API entry
* points; see crosbug.com/17018. */
/* VbInit() enter/exit */
uint64_t timer_vb_init_enter;
uint64_t timer_vb_init_exit;
/* VbSelectFirmware() enter/exit */
uint64_t timer_vb_select_firmware_enter;
uint64_t timer_vb_select_firmware_exit;
/* VbSelectAndLoadKernel() enter/exit */
uint64_t timer_vb_select_and_load_kernel_enter;
uint64_t timer_vb_select_and_load_kernel_exit;
/* Information stored in TPM, as retrieved by firmware */
/* Current firmware version in TPM */
uint32_t fw_version_tpm;
/* Current kernel version in TPM */
uint32_t kernel_version_tpm;
/* Information stored in TPM, as retrieved by firmware */
uint32_t fw_version_tpm; /* Current firmware version in TPM */
uint32_t kernel_version_tpm; /* Current kernel version in TPM */
/* Debugging information from LoadFirmware() */
/* Result of checking RW firmware A and B */
uint8_t check_fw_a_result;
uint8_t check_fw_b_result;
/* Firmware index returned by LoadFirmware() or 0xFF if failure */
uint8_t firmware_index;
/* Reserved for padding */
uint8_t reserved1;
/* Firmware TPM version at start of VbSelectFirmware() */
uint32_t fw_version_tpm_start;
/* Firmware lowest version found */
uint32_t fw_version_lowest;
/* Debugging information from LoadFirmware() */
uint8_t check_fw_a_result; /* Result of checking RW firmware A */
uint8_t check_fw_b_result; /* Result of checking RW firmware B */
uint8_t firmware_index; /* Firmware index returned by
* LoadFirmware() or 0xFF if failure */
uint8_t reserved1; /* Reserved for padding */
uint32_t fw_version_tpm_start; /* Firmware TPM version at start of
* VbSelectFirmware() */
uint32_t fw_version_lowest; /* Firmware lowest version found */
/* Debugging information from LoadKernel() */
/* Number of times LoadKernel() called */
uint32_t lk_call_count;
/* Info on calls */
VbSharedDataKernelCall lk_calls[VBSD_MAX_KERNEL_CALLS];
/* Debugging information from LoadKernel() */
uint32_t lk_call_count; /* Number of times LoadKernel() called */
VbSharedDataKernelCall lk_calls[VBSD_MAX_KERNEL_CALLS]; /* Info on calls */
/*
* Offset and size of supplemental kernel data. Reserve space for
* these fields now, so that future LoadKernel() versions can store
* information there without needing to shift down whatever data the
* original LoadFirmware() might have put immediately following its
* VbSharedDataHeader.
*/
uint64_t kernel_supplemental_offset;
uint64_t kernel_supplemental_size;
/* Offset and size of supplemental kernel data. Reserve space for these
* fields now, so that future LoadKernel() versions can store information
* there without needing to shift down whatever data the original
* LoadFirmware() might have put immediately following its
* VbSharedDataHeader. */
uint64_t kernel_supplemental_offset;
uint64_t kernel_supplemental_size;
/* Fields added in version 2. Before accessing, make sure that
* struct_version >= 2*/
uint8_t recovery_reason; /* Recovery reason for current boot */
uint8_t reserved2[7]; /* Reserved for padding */
uint64_t fw_keyblock_flags; /* Flags from firmware keyblock */
uint32_t kernel_version_tpm_start; /* Kernel TPM version at start of
* VbSelectAndLoadKernel() */
uint32_t kernel_version_lowest; /* Kernel lowest version found */
/* After read-only firmware which uses version 2 is released, any additional
* fields must be added below, and the struct version must be increased.
* Before reading/writing those fields, make sure that the struct being
* accessed is at least version 3.
*
* It's always ok for an older firmware to access a newer struct, since all
* the fields it knows about are present. Newer firmware needs to use
* reasonable defaults when accessing older structs. */
/*
* Fields added in version 2. Before accessing, make sure that
* struct_version >= 2
*/
/* Recovery reason for current boot */
uint8_t recovery_reason;
/* Reserved for padding */
uint8_t reserved2[7];
/* Flags from firmware keyblock */
uint64_t fw_keyblock_flags;
/* Kernel TPM version at start of VbSelectAndLoadKernel() */
uint32_t kernel_version_tpm_start;
/* Kernel lowest version found */
uint32_t kernel_version_lowest;
/*
* After read-only firmware which uses version 2 is released, any
* additional fields must be added below, and the struct version must
* be increased. Before reading/writing those fields, make sure that
* the struct being accessed is at least version 3.
*
* It's always ok for an older firmware to access a newer struct, since
* all the fields it knows about are present. Newer firmware needs to
* use reasonable defaults when accessing older structs.
*/
} __attribute__((packed)) VbSharedDataHeader;
/* Size of VbSharedDataheader for each version */
// TODO: crossystem needs not to
// fail if called on a v1 system where sizeof(VbSharedDataHeader) was smaller
/*
* Size of VbSharedDataheader for each version
*
* TODO: crossystem needs not to fail if called on a v1 system where
* sizeof(VbSharedDataHeader) was smaller
*/
#define VB_SHARED_DATA_HEADER_SIZE_V1 1072
#define VB_SHARED_DATA_HEADER_SIZE_V2 1096