From 0c3ba249abb1dc60f5ebabccf84ff13206440b83 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Fri, 29 Mar 2013 11:09:30 -0700 Subject: Massive refactoring of external header files. This reduces the number of exported header files to the minimum needed by the existing userspace utilities and firmware implementations. BUG=chromium:221544 BRANCH=none TEST=manual, trybots CQ-DEPEND=CL:47019,CL:47022,CL:47023 sudo FEATURES=test emerge vboot_reference FEATURES=test emerge-$BOARD \ vboot_reference \ chromeos-cryptohome \ chromeos-installer \ chromeos-u-boot \ peach-u-boot \ depthcharge Change-Id: I2946cc2dbaf5459a6c5eca92ca57d546498e6d85 Signed-off-by: Bill Richardson Reviewed-on: https://gerrit.chromium.org/gerrit/47021 Reviewed-by: Randall Spangler --- firmware/include/bmpblk_header.h | 12 +--- firmware/include/gbb_header.h | 4 +- firmware/include/gpt.h | 114 +++++++++++++++++++++++++++++++ firmware/include/load_firmware_fw.h | 30 --------- firmware/include/load_kernel_fw.h | 101 ---------------------------- firmware/include/sysincludes.h | 28 -------- firmware/include/tlcl.h | 2 +- firmware/include/tss_constants.h | 4 +- firmware/include/utility.h | 115 -------------------------------- firmware/include/vboot_api.h | 12 +++- firmware/include/vboot_nvstorage.h | 1 + firmware/include/vboot_struct.h | 3 +- firmware/lib/cgptlib/cgptlib.c | 2 + firmware/lib/cgptlib/cgptlib_internal.c | 2 + firmware/lib/cgptlib/crc32.c | 2 + firmware/lib/cgptlib/include/gpt.h | 115 -------------------------------- firmware/lib/crc8.c | 2 + firmware/lib/cryptolib/padding.c | 2 + firmware/lib/cryptolib/rsa.c | 2 + firmware/lib/cryptolib/rsa_utility.c | 2 + firmware/lib/cryptolib/sha1.c | 2 + firmware/lib/cryptolib/sha256.c | 2 + firmware/lib/cryptolib/sha512.c | 2 + firmware/lib/cryptolib/sha_utility.c | 2 + firmware/lib/include/load_firmware_fw.h | 29 ++++++++ firmware/lib/include/load_kernel_fw.h | 100 +++++++++++++++++++++++++++ firmware/lib/include/sysincludes.h | 28 ++++++++ firmware/lib/include/utility.h | 115 ++++++++++++++++++++++++++++++++ firmware/lib/mocked_rollback_index.c | 2 + firmware/lib/mocked_tpm_bootmode.c | 3 +- firmware/lib/rollback_index.c | 2 + firmware/lib/stateful_util.c | 2 + firmware/lib/tpm_bootmode.c | 3 +- firmware/lib/tpm_lite/mocked_tlcl.c | 2 + firmware/lib/tpm_lite/tlcl.c | 1 + firmware/lib/utility.c | 1 + firmware/lib/utility_string.c | 1 + firmware/lib/vboot_api_firmware.c | 2 + firmware/lib/vboot_api_init.c | 2 + firmware/lib/vboot_api_kernel.c | 2 + firmware/lib/vboot_audio.c | 2 + firmware/lib/vboot_common.c | 2 + firmware/lib/vboot_common_init.c | 2 + firmware/lib/vboot_display.c | 2 + firmware/lib/vboot_firmware.c | 2 + firmware/lib/vboot_kernel.c | 1 + firmware/lib/vboot_nvstorage.c | 2 + firmware/linktest/main.c | 2 + firmware/linktest/main_vbinit.c | 2 + firmware/linktest/main_vbsf.c | 2 + firmware/stub/tpm_lite_stub.c | 3 + firmware/stub/utility_stub.c | 2 + firmware/stub/vboot_api_stub.c | 2 + firmware/stub/vboot_api_stub_disk.c | 2 + firmware/stub/vboot_api_stub_init.c | 2 + firmware/stub/vboot_api_stub_sf.c | 2 + 56 files changed, 476 insertions(+), 414 deletions(-) create mode 100644 firmware/include/gpt.h delete mode 100644 firmware/include/load_firmware_fw.h delete mode 100644 firmware/include/load_kernel_fw.h delete mode 100644 firmware/include/sysincludes.h delete mode 100644 firmware/include/utility.h delete mode 100644 firmware/lib/cgptlib/include/gpt.h create mode 100644 firmware/lib/include/load_firmware_fw.h create mode 100644 firmware/lib/include/load_kernel_fw.h create mode 100644 firmware/lib/include/sysincludes.h create mode 100644 firmware/lib/include/utility.h (limited to 'firmware') diff --git a/firmware/include/bmpblk_header.h b/firmware/include/bmpblk_header.h index 1b04bf70..4889a6a8 100644 --- a/firmware/include/bmpblk_header.h +++ b/firmware/include/bmpblk_header.h @@ -41,11 +41,9 @@ * | List of locale names | * +-----------------------------------------+ */ - #ifndef VBOOT_REFERENCE_BMPBLK_HEADER_H_ #define VBOOT_REFERENCE_BMPBLK_HEADER_H_ - -#include "sysincludes.h" +#include #define BMPBLOCK_SIGNATURE "$BMP" #define BMPBLOCK_SIGNATURE_SIZE (4) @@ -130,14 +128,6 @@ typedef enum ImageFormat { 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, -} 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 diff --git a/firmware/include/gbb_header.h b/firmware/include/gbb_header.h index 5ab5121b..43aa3e76 100644 --- a/firmware/include/gbb_header.h +++ b/firmware/include/gbb_header.h @@ -4,11 +4,9 @@ * * Data structure of Google Binary Block (GBB) */ - #ifndef VBOOT_REFERENCE_GBB_HEADER_H_ #define VBOOT_REFERENCE_GBB_HEADER_H_ - -#include "sysincludes.h" +#include #define GBB_HEADER_SIZE 128 diff --git a/firmware/include/gpt.h b/firmware/include/gpt.h new file mode 100644 index 00000000..fa537397 --- /dev/null +++ b/firmware/include/gpt.h @@ -0,0 +1,114 @@ +/* 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. + * + * Defines EFI related structure. See more details in EFI 2.3 spec. + * + * To download EFI standard, please visit UEFI homepage: + * http://www.uefi.org/ + */ +#ifndef VBOOT_REFERENCE_CGPTLIB_GPT_H_ +#define VBOOT_REFERENCE_CGPTLIB_GPT_H_ +#include + +#define GPT_HEADER_SIGNATURE "EFI PART" +#define GPT_HEADER_SIGNATURE2 "CHROMEOS" +#define GPT_HEADER_SIGNATURE_SIZE sizeof(GPT_HEADER_SIGNATURE) +#define GPT_HEADER_REVISION 0x00010000 + +/* + * The first 3 numbers should be stored in network-endian format according to + * the GUID RFC. The UEFI spec appendix A claims they should be stored in + * little-endian format. But they need to be _displayed_ in network-endian + * format, which is also how they're documented in the specs. + * + * Since what we have here are little-endian constants, they're byte-swapped + * from the normal display order. + */ +#define GPT_ENT_TYPE_UNUSED \ + {{{0x00000000,0x0000,0x0000,0x00,0x00,{0x00,0x00,0x00,0x00,0x00,0x00}}}} +#define GPT_ENT_TYPE_EFI \ + {{{0xc12a7328,0xf81f,0x11d2,0xba,0x4b,{0x00,0xa0,0xc9,0x3e,0xc9,0x3b}}}} +#define GPT_ENT_TYPE_CHROMEOS_FIRMWARE \ + {{{0xcab6e88e,0xabf3,0x4102,0xa0,0x7a,{0xd4,0xbb,0x9b,0xe3,0xc1,0xd3}}}} +#define GPT_ENT_TYPE_CHROMEOS_KERNEL \ + {{{0xfe3a2a5d,0x4f32,0x41a7,0xb7,0x25,{0xac,0xcc,0x32,0x85,0xa3,0x09}}}} +#define GPT_ENT_TYPE_CHROMEOS_ROOTFS \ + {{{0x3cb8e202,0x3b7e,0x47dd,0x8a,0x3c,{0x7f,0xf2,0xa1,0x3c,0xfc,0xec}}}} +#define GPT_ENT_TYPE_CHROMEOS_RESERVED \ + {{{0x2e0a753d,0x9e48,0x43b0,0x83,0x37,{0xb1,0x51,0x92,0xcb,0x1b,0x5e}}}} +#define GPT_ENT_TYPE_LINUX_DATA \ + {{{0xebd0a0a2,0xb9e5,0x4433,0x87,0xc0,{0x68,0xb6,0xb7,0x26,0x99,0xc7}}}} + +#define UUID_NODE_LEN 6 +#define GUID_SIZE 16 + +/* GUID definition. Defined in appendix A of EFI standard. */ +typedef struct { + union { + struct { + uint32_t time_low; + uint16_t time_mid; + uint16_t time_high_and_version; + uint8_t clock_seq_high_and_reserved; + uint8_t clock_seq_low; + uint8_t node[UUID_NODE_LEN]; + } Uuid; + uint8_t raw[GUID_SIZE]; + } u; +} __attribute__((packed)) Guid; + +#define GUID_EXPECTED_SIZE GUID_SIZE + +/* + * GPT header defines how many partitions exist on a drive and sectors managed. + * For every drive device, there are 2 headers, primary and secondary. Most of + * fields are duplicated except my_lba and entries_lba. + * + * You may find more details in chapter 5 of EFI standard. + */ +typedef struct { + char signature[8]; + uint32_t revision; + uint32_t size; + uint32_t header_crc32; + uint32_t reserved_zero; + uint64_t my_lba; + uint64_t alternate_lba; + uint64_t first_usable_lba; + uint64_t last_usable_lba; + Guid disk_uuid; + uint64_t entries_lba; + uint32_t number_of_entries; + uint32_t size_of_entry; + uint32_t entries_crc32; + /* Remainder of sector is reserved and should be 0 */ +} __attribute__((packed)) GptHeader; + +#define GPTHEADER_EXPECTED_SIZE 92 + +/* + * GPT partition entry defines the starting and ending LBAs of a partition. It + * also contains the unique GUID, type, and attribute bits. + * + * You may find more details in chapter 5 of EFI standard. + */ +typedef struct { + Guid type; + Guid unique; + uint64_t starting_lba; + uint64_t ending_lba; + union { + struct { + uint16_t reserved[3]; + uint16_t gpt_att; + } __attribute__((packed)) fields; + uint64_t whole; + } attrs; + uint16_t name[36]; /* UTF-16 encoded partition name */ + /* Remainder of entry is reserved and should be 0 */ +} __attribute__((packed)) GptEntry; + +#define GPTENTRY_EXPECTED_SIZE 128 + +#endif /* VBOOT_REFERENCE_CGPTLIB_GPT_H_ */ diff --git a/firmware/include/load_firmware_fw.h b/firmware/include/load_firmware_fw.h deleted file mode 100644 index f582e880..00000000 --- a/firmware/include/load_firmware_fw.h +++ /dev/null @@ -1,30 +0,0 @@ -/* 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. - * - * High-level firmware API for loading and verifying rewritable firmware. - * (Firmware Portion) - */ - -#ifndef VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ -#define VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ - -#include "sysincludes.h" -#include "vboot_api.h" -#include "vboot_nvstorage.h" -#include "vboot_struct.h" - -/** - * 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); - -#endif /* VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ */ diff --git a/firmware/include/load_kernel_fw.h b/firmware/include/load_kernel_fw.h deleted file mode 100644 index 7439e57c..00000000 --- a/firmware/include/load_kernel_fw.h +++ /dev/null @@ -1,101 +0,0 @@ -/* 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. - * - * High-level firmware API for loading and verifying kernel. - * (Firmware Portion) - */ - -#ifndef VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ -#define VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ - -#include "sysincludes.h" -#include "vboot_api.h" -#include "vboot_nvstorage.h" - -/* Interface provided by verified boot library to BDS */ - -/* Boot flags for LoadKernel().boot_flags */ -/* Developer switch is on */ -#define BOOT_FLAG_DEVELOPER (0x01ULL) -/* In recovery mode */ -#define BOOT_FLAG_RECOVERY (0x02ULL) - -typedef struct LoadKernelParams { - /* 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; - - /* - * 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; - -/** - * 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. - */ -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 { - /* 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_ */ diff --git a/firmware/include/sysincludes.h b/firmware/include/sysincludes.h deleted file mode 100644 index 490b51cc..00000000 --- a/firmware/include/sysincludes.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2010 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. - */ - -/* System includes for vboot reference library. This is the ONLY - * place in firmware/ where system headers may be included via - * #include <...>, so that there's only one place that needs to be - * fixed up for platforms which don't have all the system includes. - * - * Files in firmware/stub may still include system headers, because - * they're local implementations and will be ported to each system - * anyway. */ - -#ifndef VBOOT_REFERENCE_SYSINCLUDES_H_ -#define VBOOT_REFERENCE_SYSINCLUDES_H_ - -#include /* For PRIu64 */ -#include -#include -#include - -#if defined(HAVE_ENDIAN_H) && defined(HAVE_LITTLE_ENDIAN) -#include -#include -#endif - -#endif /* VBOOT_REFERENCE_SYSINCLUDES_H_ */ diff --git a/firmware/include/tlcl.h b/firmware/include/tlcl.h index 5ce05638..a71136b6 100644 --- a/firmware/include/tlcl.h +++ b/firmware/include/tlcl.h @@ -11,8 +11,8 @@ #ifndef TPM_LITE_TLCL_H_ #define TPM_LITE_TLCL_H_ +#include -#include "sysincludes.h" #include "tss_constants.h" /*****************************************************************************/ diff --git a/firmware/include/tss_constants.h b/firmware/include/tss_constants.h index bcceded8..883a5ad8 100644 --- a/firmware/include/tss_constants.h +++ b/firmware/include/tss_constants.h @@ -5,11 +5,9 @@ * Some TPM constants and type definitions for standalone compilation for use * in the firmware */ - #ifndef VBOOT_REFERENCE_TSS_CONSTANTS_H_ #define VBOOT_REFERENCE_TSS_CONSTANTS_H_ - -#include "sysincludes.h" +#include #define TPM_MAX_COMMAND_SIZE 4096 #define TPM_LARGE_ENOUGH_COMMAND_SIZE 256 /* saves space in the firmware */ diff --git a/firmware/include/utility.h b/firmware/include/utility.h deleted file mode 100644 index f6575ed5..00000000 --- a/firmware/include/utility.h +++ /dev/null @@ -1,115 +0,0 @@ -/* 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 - * comparison. - */ - -#ifndef VBOOT_REFERENCE_UTILITY_H_ -#define VBOOT_REFERENCE_UTILITY_H_ - -#include "sysincludes.h" - -/* Debug and error output */ -#ifdef VBOOT_DEBUG -#define VBDEBUG(params) VbExDebug params -#else -#define VBDEBUG(params) -#endif - -#ifdef VBOOT_DEBUG -#define VbAssert(expr) do { if (!(expr)) { \ - VbExError("assert fail: %s at %s:%d\n", \ - #expr, __FILE__, __LINE__); }} while(0) -#else -#define VbAssert(expr) -#endif - -/* Optional, up to the BIOS */ -#ifdef VBOOT_EASTER_EGG -#define VBEASTEREGG VbExEasterEgg() -#else -#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. - */ -#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 - * greater than the first n bytes of [src2]. */ -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); - -/* - * 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); - -/** - * 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); - -/* - * 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, - * 16=hex) and store it in , which is chars long. If - * , left-pads the string to at least that width with '0'. - * 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 onto , which has space for characters - * including the terminating null. Note that will always be - * null-terminated if > 0. Returns the number of characters used in - * , not counting the terminating null. - */ -uint32_t StrnAppend(char *dest, const char *src, uint32_t destlen); - -/* Ensure that only our stub implementations are used, not standard C */ -#ifndef _STUB_IMPLEMENTATION_ -#define malloc _do_not_use_standard_malloc -#define free _do_not_use_standard_free -#define memcmp _do_not_use_standard_memcmp -#define memcpy _do_not_use_standard_memcpy -#define memset _do_not_use_standard_memset -#endif - -#endif /* VBOOT_REFERENCE_UTILITY_H_ */ diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h index 31e91a7b..dc8be1c4 100644 --- a/firmware/include/vboot_api.h +++ b/firmware/include/vboot_api.h @@ -21,9 +21,7 @@ #ifndef VBOOT_REFERENCE_VBOOT_API_H_ #define VBOOT_REFERENCE_VBOOT_API_H_ - -#include "sysincludes.h" -#include "bmpblk_header.h" +#include /*****************************************************************************/ /* Error codes */ @@ -814,6 +812,14 @@ VbError_t VbExDecompress(void *inbuf, uint32_t in_size, uint32_t compression_type, void *outbuf, uint32_t *out_size); +/* Constants for compression_type */ +enum { + COMPRESS_NONE = 0, + COMPRESS_EFIv1, /* The x86 BIOS only supports this */ + COMPRESS_LZMA1, /* The ARM BIOS supports LZMA1 */ + MAX_COMPRESS, +}; + /** * Execute legacy boot option. */ diff --git a/firmware/include/vboot_nvstorage.h b/firmware/include/vboot_nvstorage.h index 943a5664..e6b014aa 100644 --- a/firmware/include/vboot_nvstorage.h +++ b/firmware/include/vboot_nvstorage.h @@ -7,6 +7,7 @@ #ifndef VBOOT_REFERENCE_NVSTORAGE_H_ #define VBOOT_REFERENCE_NVSTORAGE_H_ +#include #define VBNV_BLOCK_SIZE 16 /* Size of NV storage block in bytes */ diff --git a/firmware/include/vboot_struct.h b/firmware/include/vboot_struct.h index ee912a30..e20b0aa9 100644 --- a/firmware/include/vboot_struct.h +++ b/firmware/include/vboot_struct.h @@ -8,8 +8,7 @@ #ifndef VBOOT_REFERENCE_VBOOT_STRUCT_H_ #define VBOOT_REFERENCE_VBOOT_STRUCT_H_ - -#include "sysincludes.h" +#include /* Public key data */ typedef struct VbPublicKey { diff --git a/firmware/lib/cgptlib/cgptlib.c b/firmware/lib/cgptlib/cgptlib.c index 370530f1..6fc29f62 100644 --- a/firmware/lib/cgptlib/cgptlib.c +++ b/firmware/lib/cgptlib/cgptlib.c @@ -3,6 +3,8 @@ * found in the LICENSE file. */ +#include "sysincludes.h" + #include "cgptlib.h" #include "cgptlib_internal.h" #include "crc32.h" diff --git a/firmware/lib/cgptlib/cgptlib_internal.c b/firmware/lib/cgptlib/cgptlib_internal.c index d51ce33b..c87f981c 100644 --- a/firmware/lib/cgptlib/cgptlib_internal.c +++ b/firmware/lib/cgptlib/cgptlib_internal.c @@ -3,6 +3,8 @@ * found in the LICENSE file. */ +#include "sysincludes.h" + #include "cgptlib.h" #include "cgptlib_internal.h" #include "crc32.h" diff --git a/firmware/lib/cgptlib/crc32.c b/firmware/lib/cgptlib/crc32.c index 002c5b9a..286cfa09 100644 --- a/firmware/lib/cgptlib/crc32.c +++ b/firmware/lib/cgptlib/crc32.c @@ -39,6 +39,8 @@ /* polynomial $edb88320 */ /* */ /* -------------------------------------------------------------------- */ +#include "sysincludes.h" + #include "crc32.h" static uint32_t crc32_tab[] = { diff --git a/firmware/lib/cgptlib/include/gpt.h b/firmware/lib/cgptlib/include/gpt.h deleted file mode 100644 index 0418655b..00000000 --- a/firmware/lib/cgptlib/include/gpt.h +++ /dev/null @@ -1,115 +0,0 @@ -/* 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. - * - * Defines EFI related structure. See more details in EFI 2.3 spec. - * - * To download EFI standard, please visit UEFI homepage: - * http://www.uefi.org/ - */ -#ifndef VBOOT_REFERENCE_CGPTLIB_GPT_H_ -#define VBOOT_REFERENCE_CGPTLIB_GPT_H_ - -#include "sysincludes.h" - -#define GPT_HEADER_SIGNATURE "EFI PART" -#define GPT_HEADER_SIGNATURE2 "CHROMEOS" -#define GPT_HEADER_SIGNATURE_SIZE sizeof(GPT_HEADER_SIGNATURE) -#define GPT_HEADER_REVISION 0x00010000 - -/* - * The first 3 numbers should be stored in network-endian format according to - * the GUID RFC. The UEFI spec appendix A claims they should be stored in - * little-endian format. But they need to be _displayed_ in network-endian - * format, which is also how they're documented in the specs. - * - * Since what we have here are little-endian constants, they're byte-swapped - * from the normal display order. - */ -#define GPT_ENT_TYPE_UNUSED \ - {{{0x00000000,0x0000,0x0000,0x00,0x00,{0x00,0x00,0x00,0x00,0x00,0x00}}}} -#define GPT_ENT_TYPE_EFI \ - {{{0xc12a7328,0xf81f,0x11d2,0xba,0x4b,{0x00,0xa0,0xc9,0x3e,0xc9,0x3b}}}} -#define GPT_ENT_TYPE_CHROMEOS_FIRMWARE \ - {{{0xcab6e88e,0xabf3,0x4102,0xa0,0x7a,{0xd4,0xbb,0x9b,0xe3,0xc1,0xd3}}}} -#define GPT_ENT_TYPE_CHROMEOS_KERNEL \ - {{{0xfe3a2a5d,0x4f32,0x41a7,0xb7,0x25,{0xac,0xcc,0x32,0x85,0xa3,0x09}}}} -#define GPT_ENT_TYPE_CHROMEOS_ROOTFS \ - {{{0x3cb8e202,0x3b7e,0x47dd,0x8a,0x3c,{0x7f,0xf2,0xa1,0x3c,0xfc,0xec}}}} -#define GPT_ENT_TYPE_CHROMEOS_RESERVED \ - {{{0x2e0a753d,0x9e48,0x43b0,0x83,0x37,{0xb1,0x51,0x92,0xcb,0x1b,0x5e}}}} -#define GPT_ENT_TYPE_LINUX_DATA \ - {{{0xebd0a0a2,0xb9e5,0x4433,0x87,0xc0,{0x68,0xb6,0xb7,0x26,0x99,0xc7}}}} - -#define UUID_NODE_LEN 6 -#define GUID_SIZE 16 - -/* GUID definition. Defined in appendix A of EFI standard. */ -typedef struct { - union { - struct { - uint32_t time_low; - uint16_t time_mid; - uint16_t time_high_and_version; - uint8_t clock_seq_high_and_reserved; - uint8_t clock_seq_low; - uint8_t node[UUID_NODE_LEN]; - } Uuid; - uint8_t raw[GUID_SIZE]; - } u; -} __attribute__((packed)) Guid; - -#define GUID_EXPECTED_SIZE GUID_SIZE - -/* - * GPT header defines how many partitions exist on a drive and sectors managed. - * For every drive device, there are 2 headers, primary and secondary. Most of - * fields are duplicated except my_lba and entries_lba. - * - * You may find more details in chapter 5 of EFI standard. - */ -typedef struct { - char signature[8]; - uint32_t revision; - uint32_t size; - uint32_t header_crc32; - uint32_t reserved_zero; - uint64_t my_lba; - uint64_t alternate_lba; - uint64_t first_usable_lba; - uint64_t last_usable_lba; - Guid disk_uuid; - uint64_t entries_lba; - uint32_t number_of_entries; - uint32_t size_of_entry; - uint32_t entries_crc32; - /* Remainder of sector is reserved and should be 0 */ -} __attribute__((packed)) GptHeader; - -#define GPTHEADER_EXPECTED_SIZE 92 - -/* - * GPT partition entry defines the starting and ending LBAs of a partition. It - * also contains the unique GUID, type, and attribute bits. - * - * You may find more details in chapter 5 of EFI standard. - */ -typedef struct { - Guid type; - Guid unique; - uint64_t starting_lba; - uint64_t ending_lba; - union { - struct { - uint16_t reserved[3]; - uint16_t gpt_att; - } __attribute__((packed)) fields; - uint64_t whole; - } attrs; - uint16_t name[36]; /* UTF-16 encoded partition name */ - /* Remainder of entry is reserved and should be 0 */ -} __attribute__((packed)) GptEntry; - -#define GPTENTRY_EXPECTED_SIZE 128 - -#endif /* VBOOT_REFERENCE_CGPTLIB_GPT_H_ */ diff --git a/firmware/lib/crc8.c b/firmware/lib/crc8.c index b0ee8679..0e38e1eb 100644 --- a/firmware/lib/crc8.c +++ b/firmware/lib/crc8.c @@ -3,6 +3,8 @@ * found in the LICENSE file. */ +#include "sysincludes.h" + #include "crc8.h" /** diff --git a/firmware/lib/cryptolib/padding.c b/firmware/lib/cryptolib/padding.c index 24b1c15d..4fc939a5 100644 --- a/firmware/lib/cryptolib/padding.c +++ b/firmware/lib/cryptolib/padding.c @@ -5,6 +5,8 @@ * arrays corresponding to various combinations of algorithms for RSA signatures. */ +#include "sysincludes.h" + #include "cryptolib.h" diff --git a/firmware/lib/cryptolib/rsa.c b/firmware/lib/cryptolib/rsa.c index 897816e8..6d61a216 100644 --- a/firmware/lib/cryptolib/rsa.c +++ b/firmware/lib/cryptolib/rsa.c @@ -8,6 +8,8 @@ * support multiple RSA key lengths and hash digest algorithms. */ +#include "sysincludes.h" + #include "cryptolib.h" #include "vboot_api.h" #include "utility.h" diff --git a/firmware/lib/cryptolib/rsa_utility.c b/firmware/lib/cryptolib/rsa_utility.c index ab4650c0..f6eefe2b 100644 --- a/firmware/lib/cryptolib/rsa_utility.c +++ b/firmware/lib/cryptolib/rsa_utility.c @@ -5,6 +5,8 @@ * Implementation of RSA utility functions. */ +#include "sysincludes.h" + #include "cryptolib.h" #include "stateful_util.h" #include "utility.h" diff --git a/firmware/lib/cryptolib/sha1.c b/firmware/lib/cryptolib/sha1.c index 0a3f8f6a..b34b8a95 100644 --- a/firmware/lib/cryptolib/sha1.c +++ b/firmware/lib/cryptolib/sha1.c @@ -6,6 +6,8 @@ * Open Source Project (platorm/system/core.git/libmincrypt/sha.c */ +#include "sysincludes.h" + #include "cryptolib.h" #include "utility.h" diff --git a/firmware/lib/cryptolib/sha256.c b/firmware/lib/cryptolib/sha256.c index 6d3c08dd..664b876c 100644 --- a/firmware/lib/cryptolib/sha256.c +++ b/firmware/lib/cryptolib/sha256.c @@ -35,6 +35,8 @@ * SUCH DAMAGE. */ +#include "sysincludes.h" + #include "cryptolib.h" #include "utility.h" diff --git a/firmware/lib/cryptolib/sha512.c b/firmware/lib/cryptolib/sha512.c index 66c9a35f..96b2bef6 100644 --- a/firmware/lib/cryptolib/sha512.c +++ b/firmware/lib/cryptolib/sha512.c @@ -35,6 +35,8 @@ * SUCH DAMAGE. */ +#include "sysincludes.h" + #include "cryptolib.h" #include "utility.h" diff --git a/firmware/lib/cryptolib/sha_utility.c b/firmware/lib/cryptolib/sha_utility.c index bd7e1400..6c7aa493 100644 --- a/firmware/lib/cryptolib/sha_utility.c +++ b/firmware/lib/cryptolib/sha_utility.c @@ -5,6 +5,8 @@ * Utility functions for message digest functions. */ +#include "sysincludes.h" + #include "cryptolib.h" #include "utility.h" #include "vboot_api.h" diff --git a/firmware/lib/include/load_firmware_fw.h b/firmware/lib/include/load_firmware_fw.h new file mode 100644 index 00000000..555cf6fd --- /dev/null +++ b/firmware/lib/include/load_firmware_fw.h @@ -0,0 +1,29 @@ +/* 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. + * + * High-level firmware API for loading and verifying rewritable firmware. + * (Firmware Portion) + */ + +#ifndef VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ +#define VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ + +#include "vboot_api.h" +#include "vboot_nvstorage.h" +#include "vboot_struct.h" + +/** + * 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); + +#endif /* VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ */ diff --git a/firmware/lib/include/load_kernel_fw.h b/firmware/lib/include/load_kernel_fw.h new file mode 100644 index 00000000..dd6e1a84 --- /dev/null +++ b/firmware/lib/include/load_kernel_fw.h @@ -0,0 +1,100 @@ +/* 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. + * + * High-level firmware API for loading and verifying kernel. + * (Firmware Portion) + */ + +#ifndef VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ +#define VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ + +#include "vboot_api.h" +#include "vboot_nvstorage.h" + +/* Interface provided by verified boot library to BDS */ + +/* Boot flags for LoadKernel().boot_flags */ +/* Developer switch is on */ +#define BOOT_FLAG_DEVELOPER (0x01ULL) +/* In recovery mode */ +#define BOOT_FLAG_RECOVERY (0x02ULL) + +typedef struct LoadKernelParams { + /* 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; + + /* + * 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; + +/** + * 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. + */ +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 { + /* 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_ */ diff --git a/firmware/lib/include/sysincludes.h b/firmware/lib/include/sysincludes.h new file mode 100644 index 00000000..490b51cc --- /dev/null +++ b/firmware/lib/include/sysincludes.h @@ -0,0 +1,28 @@ +/* Copyright (c) 2010 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. + */ + +/* System includes for vboot reference library. This is the ONLY + * place in firmware/ where system headers may be included via + * #include <...>, so that there's only one place that needs to be + * fixed up for platforms which don't have all the system includes. + * + * Files in firmware/stub may still include system headers, because + * they're local implementations and will be ported to each system + * anyway. */ + +#ifndef VBOOT_REFERENCE_SYSINCLUDES_H_ +#define VBOOT_REFERENCE_SYSINCLUDES_H_ + +#include /* For PRIu64 */ +#include +#include +#include + +#if defined(HAVE_ENDIAN_H) && defined(HAVE_LITTLE_ENDIAN) +#include +#include +#endif + +#endif /* VBOOT_REFERENCE_SYSINCLUDES_H_ */ diff --git a/firmware/lib/include/utility.h b/firmware/lib/include/utility.h new file mode 100644 index 00000000..f6575ed5 --- /dev/null +++ b/firmware/lib/include/utility.h @@ -0,0 +1,115 @@ +/* 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 + * comparison. + */ + +#ifndef VBOOT_REFERENCE_UTILITY_H_ +#define VBOOT_REFERENCE_UTILITY_H_ + +#include "sysincludes.h" + +/* Debug and error output */ +#ifdef VBOOT_DEBUG +#define VBDEBUG(params) VbExDebug params +#else +#define VBDEBUG(params) +#endif + +#ifdef VBOOT_DEBUG +#define VbAssert(expr) do { if (!(expr)) { \ + VbExError("assert fail: %s at %s:%d\n", \ + #expr, __FILE__, __LINE__); }} while(0) +#else +#define VbAssert(expr) +#endif + +/* Optional, up to the BIOS */ +#ifdef VBOOT_EASTER_EGG +#define VBEASTEREGG VbExEasterEgg() +#else +#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. + */ +#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 + * greater than the first n bytes of [src2]. */ +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); + +/* + * 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); + +/** + * 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); + +/* + * 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, + * 16=hex) and store it in , which is chars long. If + * , left-pads the string to at least that width with '0'. + * 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 onto , which has space for characters + * including the terminating null. Note that will always be + * null-terminated if > 0. Returns the number of characters used in + * , not counting the terminating null. + */ +uint32_t StrnAppend(char *dest, const char *src, uint32_t destlen); + +/* Ensure that only our stub implementations are used, not standard C */ +#ifndef _STUB_IMPLEMENTATION_ +#define malloc _do_not_use_standard_malloc +#define free _do_not_use_standard_free +#define memcmp _do_not_use_standard_memcmp +#define memcpy _do_not_use_standard_memcpy +#define memset _do_not_use_standard_memset +#endif + +#endif /* VBOOT_REFERENCE_UTILITY_H_ */ diff --git a/firmware/lib/mocked_rollback_index.c b/firmware/lib/mocked_rollback_index.c index 65dfd4de..e866f137 100644 --- a/firmware/lib/mocked_rollback_index.c +++ b/firmware/lib/mocked_rollback_index.c @@ -6,6 +6,8 @@ * stored in the TPM NVRAM. */ +#include "sysincludes.h" + #include "rollback_index.h" #include "tss_constants.h" diff --git a/firmware/lib/mocked_tpm_bootmode.c b/firmware/lib/mocked_tpm_bootmode.c index b42c2c79..e9d82def 100644 --- a/firmware/lib/mocked_tpm_bootmode.c +++ b/firmware/lib/mocked_tpm_bootmode.c @@ -5,8 +5,9 @@ * Functions for updating the TPM state with the status of boot path. */ -#include "tpm_bootmode.h" +#include "sysincludes.h" +#include "tpm_bootmode.h" #include "tss_constants.h" const char* kBootStateSHA1Digests[] = { diff --git a/firmware/lib/rollback_index.c b/firmware/lib/rollback_index.c index e430bea6..3744f4bb 100644 --- a/firmware/lib/rollback_index.c +++ b/firmware/lib/rollback_index.c @@ -6,6 +6,8 @@ * stored in the TPM NVRAM. */ +#include "sysincludes.h" + #include "crc8.h" #include "rollback_index.h" #include "tlcl.h" diff --git a/firmware/lib/stateful_util.c b/firmware/lib/stateful_util.c index 6db03fc5..fbbc48c9 100644 --- a/firmware/lib/stateful_util.c +++ b/firmware/lib/stateful_util.c @@ -5,6 +5,8 @@ * Implementations of stateful memory operations. */ +#include "sysincludes.h" + #include "stateful_util.h" #include "utility.h" diff --git a/firmware/lib/tpm_bootmode.c b/firmware/lib/tpm_bootmode.c index 218db207..a8e1a7cc 100644 --- a/firmware/lib/tpm_bootmode.c +++ b/firmware/lib/tpm_bootmode.c @@ -5,9 +5,10 @@ * Functions for updating the TPM state with the status of boot path. */ -#include "tpm_bootmode.h" +#include "sysincludes.h" #include "tlcl.h" +#include "tpm_bootmode.h" #include "utility.h" #include "vboot_api.h" diff --git a/firmware/lib/tpm_lite/mocked_tlcl.c b/firmware/lib/tpm_lite/mocked_tlcl.c index e977cd5d..2657cb63 100644 --- a/firmware/lib/tpm_lite/mocked_tlcl.c +++ b/firmware/lib/tpm_lite/mocked_tlcl.c @@ -3,6 +3,8 @@ * found in the LICENSE file. */ +#include "sysincludes.h" + #include "tlcl.h" #include "tlcl_internal.h" #include "utility.h" diff --git a/firmware/lib/tpm_lite/tlcl.c b/firmware/lib/tpm_lite/tlcl.c index 50b3877b..c015e895 100644 --- a/firmware/lib/tpm_lite/tlcl.c +++ b/firmware/lib/tpm_lite/tlcl.c @@ -15,6 +15,7 @@ */ #include "sysincludes.h" + #include "tlcl.h" #include "tlcl_internal.h" #include "tlcl_structures.h" diff --git a/firmware/lib/utility.c b/firmware/lib/utility.c index 66b8eff3..2f8c90dc 100644 --- a/firmware/lib/utility.c +++ b/firmware/lib/utility.c @@ -6,6 +6,7 @@ */ #include "sysincludes.h" + #include "utility.h" int SafeMemcmp(const void *s1, const void *s2, size_t n) { diff --git a/firmware/lib/utility_string.c b/firmware/lib/utility_string.c index 4a7e3e38..361d1809 100644 --- a/firmware/lib/utility_string.c +++ b/firmware/lib/utility_string.c @@ -6,6 +6,7 @@ */ #include "sysincludes.h" + #include "utility.h" diff --git a/firmware/lib/vboot_api_firmware.c b/firmware/lib/vboot_api_firmware.c index 5889e939..e0c93a37 100644 --- a/firmware/lib/vboot_api_firmware.c +++ b/firmware/lib/vboot_api_firmware.c @@ -5,6 +5,8 @@ * High-level firmware wrapper API - entry points for init, firmware selection */ +#include "sysincludes.h" + #include "gbb_header.h" #include "load_firmware_fw.h" #include "rollback_index.h" diff --git a/firmware/lib/vboot_api_init.c b/firmware/lib/vboot_api_init.c index 39c90562..b6c70642 100644 --- a/firmware/lib/vboot_api_init.c +++ b/firmware/lib/vboot_api_init.c @@ -5,6 +5,8 @@ * High-level firmware wrapper API - entry points for init, firmware selection */ +#include "sysincludes.h" + #include "gbb_header.h" #include "load_firmware_fw.h" #include "rollback_index.h" diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c index 483d47ed..3f1dfc5c 100644 --- a/firmware/lib/vboot_api_kernel.c +++ b/firmware/lib/vboot_api_kernel.c @@ -5,6 +5,8 @@ * High-level firmware wrapper API - entry points for kernel selection */ +#include "sysincludes.h" + #include "gbb_header.h" #include "load_kernel_fw.h" #include "rollback_index.h" diff --git a/firmware/lib/vboot_audio.c b/firmware/lib/vboot_audio.c index d89bc43f..2694b0eb 100644 --- a/firmware/lib/vboot_audio.c +++ b/firmware/lib/vboot_audio.c @@ -5,6 +5,8 @@ * Delay/beep functions used in dev-mode kernel selection. */ +#include "sysincludes.h" + #include "crc32.h" #include "gbb_header.h" #include "utility.h" diff --git a/firmware/lib/vboot_common.c b/firmware/lib/vboot_common.c index 3e3375f1..bd937102 100644 --- a/firmware/lib/vboot_common.c +++ b/firmware/lib/vboot_common.c @@ -6,6 +6,8 @@ * (Firmware portion) */ +#include "sysincludes.h" + #include "vboot_api.h" #include "vboot_common.h" #include "utility.h" diff --git a/firmware/lib/vboot_common_init.c b/firmware/lib/vboot_common_init.c index 9d6670ea..0e5e9f3e 100644 --- a/firmware/lib/vboot_common_init.c +++ b/firmware/lib/vboot_common_init.c @@ -6,6 +6,8 @@ * (Firmware portion) */ +#include "sysincludes.h" + #include "vboot_api.h" #include "vboot_common.h" #include "utility.h" diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c index adf4a3f3..f79dfe13 100644 --- a/firmware/lib/vboot_display.c +++ b/firmware/lib/vboot_display.c @@ -5,6 +5,8 @@ * Display functions used in kernel selection. */ +#include "sysincludes.h" + #include "bmpblk_font.h" #include "gbb_header.h" #include "utility.h" diff --git a/firmware/lib/vboot_firmware.c b/firmware/lib/vboot_firmware.c index 405a545a..8d165f2a 100644 --- a/firmware/lib/vboot_firmware.c +++ b/firmware/lib/vboot_firmware.c @@ -6,6 +6,8 @@ * (Firmware portion) */ +#include "sysincludes.h" + #include "gbb_header.h" #include "load_firmware_fw.h" #include "utility.h" diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c index 41d44f6a..d63d4eed 100644 --- a/firmware/lib/vboot_kernel.c +++ b/firmware/lib/vboot_kernel.c @@ -6,6 +6,7 @@ * (Firmware portion) */ +#include "sysincludes.h" #include "cgptlib.h" #include "cgptlib_internal.h" diff --git a/firmware/lib/vboot_nvstorage.c b/firmware/lib/vboot_nvstorage.c index 618c7124..9b2eca1b 100644 --- a/firmware/lib/vboot_nvstorage.c +++ b/firmware/lib/vboot_nvstorage.c @@ -5,6 +5,8 @@ /* Non-volatile storage routines. */ +#include "sysincludes.h" + #include "crc8.h" #include "utility.h" diff --git a/firmware/linktest/main.c b/firmware/linktest/main.c index c5ce2c1c..2a55248c 100644 --- a/firmware/linktest/main.c +++ b/firmware/linktest/main.c @@ -3,6 +3,8 @@ * found in the LICENSE file. */ +#include "sysincludes.h" + #include "cgptlib.h" #include "load_firmware_fw.h" #include "load_kernel_fw.h" diff --git a/firmware/linktest/main_vbinit.c b/firmware/linktest/main_vbinit.c index a3d50196..0300c915 100644 --- a/firmware/linktest/main_vbinit.c +++ b/firmware/linktest/main_vbinit.c @@ -3,6 +3,8 @@ * found in the LICENSE file. */ +#include "sysincludes.h" + #include "vboot_api.h" int main(void) diff --git a/firmware/linktest/main_vbsf.c b/firmware/linktest/main_vbsf.c index 1a3825a8..db5c2660 100644 --- a/firmware/linktest/main_vbsf.c +++ b/firmware/linktest/main_vbsf.c @@ -3,6 +3,8 @@ * found in the LICENSE file. */ +#include "sysincludes.h" + #include "vboot_api.h" int main(void) diff --git a/firmware/stub/tpm_lite_stub.c b/firmware/stub/tpm_lite_stub.c index 6818f2b1..5e6c7192 100644 --- a/firmware/stub/tpm_lite_stub.c +++ b/firmware/stub/tpm_lite_stub.c @@ -6,6 +6,8 @@ * equivalents. */ +#include + #define _STUB_IMPLEMENTATION_ #include "tlcl.h" #include "tlcl_internal.h" @@ -24,6 +26,7 @@ #include #include + #define TPM_DEVICE_PATH "/dev/tpm0" /* Retry failed open()s for 5 seconds in 10ms polling intervals. */ #define OPEN_RETRY_DELAY_NS (10 * 1000 * 1000) diff --git a/firmware/stub/utility_stub.c b/firmware/stub/utility_stub.c index 549ee851..a1daed08 100644 --- a/firmware/stub/utility_stub.c +++ b/firmware/stub/utility_stub.c @@ -6,6 +6,8 @@ * equivalents. */ +#include + #define _STUB_IMPLEMENTATION_ #include "utility.h" diff --git a/firmware/stub/vboot_api_stub.c b/firmware/stub/vboot_api_stub.c index fd531ac7..36d56032 100644 --- a/firmware/stub/vboot_api_stub.c +++ b/firmware/stub/vboot_api_stub.c @@ -5,6 +5,8 @@ * Stub implementations of firmware-provided API functions. */ +#include + #define _STUB_IMPLEMENTATION_ #include diff --git a/firmware/stub/vboot_api_stub_disk.c b/firmware/stub/vboot_api_stub_disk.c index aca38afa..186cd97d 100644 --- a/firmware/stub/vboot_api_stub_disk.c +++ b/firmware/stub/vboot_api_stub_disk.c @@ -5,6 +5,8 @@ * Stub implementations of disk APIs. */ +#include + #define _STUB_IMPLEMENTATION_ #include diff --git a/firmware/stub/vboot_api_stub_init.c b/firmware/stub/vboot_api_stub_init.c index 76052da1..9e4f6370 100644 --- a/firmware/stub/vboot_api_stub_init.c +++ b/firmware/stub/vboot_api_stub_init.c @@ -5,6 +5,8 @@ * Stub implementations of firmware-provided API functions. */ +#include + #define _STUB_IMPLEMENTATION_ #include diff --git a/firmware/stub/vboot_api_stub_sf.c b/firmware/stub/vboot_api_stub_sf.c index 96eeb85c..e2f1c1ae 100644 --- a/firmware/stub/vboot_api_stub_sf.c +++ b/firmware/stub/vboot_api_stub_sf.c @@ -5,6 +5,8 @@ * Stub implementations of firmware-provided API functions. */ +#include + #define _STUB_IMPLEMENTATION_ #include -- cgit v1.2.1