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 <stdint.h> | 12 #include <stdint.h> |
13 | 13 |
14 /* Functions provided by PEI to LoadFirmware() */ | 14 /* Functions provided by PEI to LoadFirmware() */ |
15 | 15 |
16 /* Get the firmware data for [firmware_index], which is either | 16 /* Get the firmware body data for [firmware_index], which is either |
17 * 0 (the first firmware image) or 1 (the second firmware image). | 17 * 0 (the first firmware image) or 1 (the second firmware image). |
18 * | 18 * |
19 * This function must call LoadFirmwareUpdateDataHash() before | 19 * This function must call UpdateFirmwareBodyHash() before returning, |
20 * returning, to update the secure hash for the firmware image. For | 20 * to update the secure hash for the firmware image. For best |
21 * best performance, the reader should call this function periodically | 21 * performance, the reader should call this function periodically |
22 * during the read, so that updating the hash can be pipelined with | 22 * during the read, so that updating the hash can be pipelined with |
23 * the read. If the reader cannot update the hash during the read | 23 * the read. If the reader cannot update the hash during the read |
24 * process, it should call LoadFirmwareUpdateDataHash() on the entire | 24 * process, it should call UpdateFirmwareBodyHash() on the entire |
25 * firmeware data after the read, before returning. | 25 * firmeware data after the read, before returning. |
26 * | 26 * |
27 * On success, returns a pointer to the data and stores the data size | 27 * On success, returns a pointer to the data and stores the data size |
28 * in [*size]. On error, returns NULL. */ | 28 * in [*size]. On error, returns NULL. */ |
29 void *FirmwareImageGetData(uint64_t firmware_index, uint64_t* size); | 29 void *GetFirmwareBody(uint64_t firmware_index, uint64_t* size); |
30 | 30 |
31 | 31 |
32 /* Interface provided by verified boot library to PEI */ | 32 /* Interface provided by verified boot library to PEI */ |
33 | 33 |
34 /* Return codes for LoadFirmware() */ | 34 /* Return codes for LoadFirmware() */ |
35 #define LOAD_FIRMWARE_SUCCESS 0 | 35 #define LOAD_FIRMWARE_SUCCESS 0 /* Success */ |
36 #define LOAD_FIRMWARE_RECOVERY 1 | 36 #define LOAD_FIRMWARE_RECOVERY 1 /* Reboot to recovery mode */ |
37 | 37 |
38 /* Update the data hash for the current firmware image, extending it | 38 /* Update the data hash for the current firmware image, extending it |
39 * by [size] bytes stored in [*data]. This function must only be | 39 * by [size] bytes stored in [*data]. This function must only be |
40 * called inside FirmwareImageGetData(). */ | 40 * called inside GetFirmwareBody(). */ |
41 void LoadFirmwareUpdateDataHash(uint8_t* data, uint64_t size); | 41 void UpdateFirmwareBodyHash(uint8_t* data, uint64_t size); |
42 | 42 |
43 | 43 |
44 typedef struct LoadFirmwareParams { | 44 typedef struct LoadFirmwareParams { |
45 /* Inputs to LoadFirmware() */ | 45 /* Inputs to LoadFirmware() */ |
46 void *header_sign_key_blob; /* Key used to sign firmware header */ | 46 void *firmware_root_key_blob; /* Key used to sign firmware header */ |
47 void *vblock0; /* Key block + preamble for firmware 0 */ | 47 void *verification_block_0; /* Key block + preamble for firmware 0 */ |
48 void *vblock1; /* Key block + preamble for firmware 1 */ | 48 void *verification_block_1; /* Key block + preamble for firmware 1 */ |
49 | 49 |
50 /* Outputs from LoadFirmware(); valid only if LoadFirmware() returns | 50 /* Outputs from LoadFirmware(); valid only if LoadFirmware() returns |
51 * LOAD_FIRMWARE_SUCCESS. */ | 51 * LOAD_FIRMWARE_SUCCESS. */ |
52 uint64_t fitmware_index; /* Firmware index to run. */ | 52 uint64_t firmware_index; /* Firmware index to run. */ |
53 void *kernel_sign_key_blob; /* Key to use when loading kernel. | 53 void *kernel_sign_key_blob; /* Key to use when loading kernel. |
54 * Pass this data to LoadKernel() in | 54 * Pass this data to LoadKernel() in |
55 * LoadKernelParams.header_sign_key_blob. | 55 * LoadKernelParams.header_sign_key_blob. |
56 * Key data may be copied/relocated | 56 * Key data may be copied/relocated |
57 * if necessary. */ | 57 * if necessary. */ |
58 uint64_t kernel_sign_key_size; /* Size of kernel signing key blob, | 58 uint64_t kernel_sign_key_size; /* Size of kernel signing key blob, |
59 * in bytes. */ | 59 * in bytes. */ |
60 } LoadFirmwareParams; | 60 } LoadFirmwareParams; |
61 | 61 |
62 | 62 |
63 /* Attempts to load the rewritable firmware. | 63 /* Attempts to load the rewritable firmware. |
64 * | 64 * |
65 * Returns LOAD_FIRMWARE_SUCCESS if successful, error code on failure. */ | 65 * Returns LOAD_FIRMWARE_SUCCESS if successful, error code on failure. */ |
66 int LoadFirmware(LoadFirmwareParams* params); | 66 int LoadFirmware(LoadFirmwareParams* params); |
67 | 67 |
68 | 68 |
69 #endif /* VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ */ | 69 #endif /* VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ */ |
OLD | NEW |