OLD | NEW |
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 * | 4 * |
5 * High-level firmware API for loading and verifying rewritable firmware. | 5 * High-level firmware API for loading and verifying rewritable firmware. |
6 * (Firmware Portion) | 6 * (Firmware Portion) |
7 */ | 7 */ |
8 | 8 |
9 #ifndef VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ | 9 #ifndef VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ |
10 #define VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ | 10 #define VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ |
11 | 11 |
12 #include "sysincludes.h" | 12 #include "sysincludes.h" |
13 #include "vboot_nvstorage.h" | 13 #include "vboot_nvstorage.h" |
14 | 14 |
15 /* Recommended size of kernel_sign_key_blob in bytes, for | 15 /* Recommended size of kernel_sign_key_blob in bytes, for |
16 * implementations which must preallocate a transfer buffer between | 16 * implementations which must preallocate a transfer buffer between |
17 * boot phases */ | 17 * boot phases */ |
18 #define LOAD_FIRMWARE_KEY_BLOB_REC_SIZE 2104 | 18 #define LOAD_FIRMWARE_KEY_BLOB_REC_SIZE 2104 |
19 | 19 |
20 /* Return codes for LoadFirmware() and S3Resume(). */ | 20 /* Return codes for LoadFirmware() and S3Resume(). */ |
21 #define LOAD_FIRMWARE_SUCCESS 0 /* Success */ | 21 #define LOAD_FIRMWARE_SUCCESS 0 /* Success */ |
22 #define LOAD_FIRMWARE_RECOVERY 1 /* Reboot to recovery mode */ | 22 #define LOAD_FIRMWARE_RECOVERY 1 /* Reboot to recovery mode. The specific |
| 23 * recovery reason has been set in |
| 24 * VbNvContext (VBNV_RECOVERY_REQUEST). */ |
23 #define LOAD_FIRMWARE_REBOOT 2 /* Reboot to same mode as current boot */ | 25 #define LOAD_FIRMWARE_REBOOT 2 /* Reboot to same mode as current boot */ |
24 #define LOAD_FIRMWARE_RECOVERY_TPM 3 /* Reboot to recovery mode due | |
25 * to TPM error */ | |
26 | 26 |
27 /* Boot flags for LoadFirmware().boot_flags */ | 27 /* Boot flags for LoadFirmware().boot_flags */ |
28 #define BOOT_FLAG_DEVELOPER UINT64_C(0x01) /* Developer switch is on */ | 28 #define BOOT_FLAG_DEVELOPER UINT64_C(0x01) /* Developer switch is on */ |
29 | 29 |
30 typedef struct LoadFirmwareParams { | 30 typedef struct LoadFirmwareParams { |
31 /* Inputs to LoadFirmware() */ | 31 /* Inputs to LoadFirmware() */ |
32 void *firmware_root_key_blob; /* Key used to sign firmware header */ | 32 void *firmware_root_key_blob; /* Key used to sign firmware header */ |
33 void *verification_block_0; /* Key block + preamble for firmware 0 */ | 33 void *verification_block_0; /* Key block + preamble for firmware 0 */ |
34 void *verification_block_1; /* Key block + preamble for firmware 1 */ | 34 void *verification_block_1; /* Key block + preamble for firmware 1 */ |
35 uint64_t verification_size_0; /* Verification block 0 size in bytes */ | 35 uint64_t verification_size_0; /* Verification block 0 size in bytes */ |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 * the read. If the reader cannot update the hash during the read | 75 * the read. If the reader cannot update the hash during the read |
76 * process, it should call UpdateFirmwareBodyHash() on the entire | 76 * process, it should call UpdateFirmwareBodyHash() on the entire |
77 * firmeware data after the read, before returning. | 77 * firmeware data after the read, before returning. |
78 * | 78 * |
79 * Returns 0 if successful or non-zero if error. */ | 79 * Returns 0 if successful or non-zero if error. */ |
80 int GetFirmwareBody(LoadFirmwareParams* params, uint64_t firmware_index); | 80 int GetFirmwareBody(LoadFirmwareParams* params, uint64_t firmware_index); |
81 | 81 |
82 | 82 |
83 /* Functions provided by verified boot library to PEI */ | 83 /* Functions provided by verified boot library to PEI */ |
84 | 84 |
| 85 /* Early setup for LoadFirmware(). This should be called as soon as the TPM |
| 86 * is available in the boot process. |
| 87 * |
| 88 * Returns LOAD_FIRMWARE_SUCCESS if successful, error code on failure. */ |
| 89 int LoadFirmwareSetup(void); |
| 90 |
85 /* Attempts to load the rewritable firmware. | 91 /* Attempts to load the rewritable firmware. |
86 * | 92 * |
87 * Returns LOAD_FIRMWARE_SUCCESS if successful, error code on failure. */ | 93 * Returns LOAD_FIRMWARE_SUCCESS if successful, error code on failure. */ |
88 int LoadFirmware(LoadFirmwareParams* params); | 94 int LoadFirmware(LoadFirmwareParams* params); |
89 | 95 |
90 | 96 |
91 /* Update the data hash for the current firmware image, extending it | 97 /* Update the data hash for the current firmware image, extending it |
92 * by [size] bytes stored in [*data]. This function must only be | 98 * by [size] bytes stored in [*data]. This function must only be |
93 * called inside GetFirmwareBody(). */ | 99 * called inside GetFirmwareBody(). */ |
94 void UpdateFirmwareBodyHash(LoadFirmwareParams* params, | 100 void UpdateFirmwareBodyHash(LoadFirmwareParams* params, |
95 uint8_t* data, uint64_t size); | 101 uint8_t* data, uint64_t size); |
96 | 102 |
97 /* Handle S3 resume. | 103 /* Handle S3 resume. |
98 * | 104 * |
99 * Returns LOAD_FIRMWARE_SUCCESS if successful, error code on failure. */ | 105 * Returns LOAD_FIRMWARE_SUCCESS if successful, error code on failure. */ |
100 int S3Resume(void); | 106 int S3Resume(void); |
101 | 107 |
102 #endif /* VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ */ | 108 #endif /* VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ */ |
OLD | NEW |