OLD | NEW |
1 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2011 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 #include "vboot_struct.h" |
15 /* Recommended size of shared_data_blob in bytes. */ | |
16 #define LOAD_FIRMWARE_SHARED_DATA_REC_SIZE 16384 | |
17 | 15 |
18 /* Return codes for LoadFirmware() and S3Resume(). */ | 16 /* Return codes for LoadFirmware() and S3Resume(). */ |
19 #define LOAD_FIRMWARE_SUCCESS 0 /* Success */ | 17 #define LOAD_FIRMWARE_SUCCESS 0 /* Success */ |
20 #define LOAD_FIRMWARE_RECOVERY 1 /* Reboot to recovery mode. The specific | 18 #define LOAD_FIRMWARE_RECOVERY 1 /* Reboot to recovery mode. The specific |
21 * recovery reason has been set in | 19 * recovery reason has been set in |
22 * VbNvContext (VBNV_RECOVERY_REQUEST). */ | 20 * VbNvContext (VBNV_RECOVERY_REQUEST). */ |
23 #define LOAD_FIRMWARE_REBOOT 2 /* Reboot to same mode as current boot */ | 21 #define LOAD_FIRMWARE_REBOOT 2 /* Reboot to same mode as current boot */ |
24 | 22 |
25 /* Boot flags for LoadFirmware().boot_flags */ | 23 /* Boot flags for LoadFirmware().boot_flags */ |
26 #define BOOT_FLAG_DEVELOPER UINT64_C(0x01) /* Developer switch is on */ | 24 #define BOOT_FLAG_DEVELOPER UINT64_C(0x01) /* Developer switch is on */ |
27 | 25 |
28 typedef struct LoadFirmwareParams { | 26 typedef struct LoadFirmwareParams { |
29 /* Inputs to LoadFirmware() */ | 27 /* Inputs to LoadFirmware() */ |
30 void* gbb_data; /* Pointer to GBB data */ | 28 void* gbb_data; /* Pointer to GBB data */ |
31 uint64_t gbb_size; /* Size of GBB data in bytes */ | 29 uint64_t gbb_size; /* Size of GBB data in bytes */ |
32 void* verification_block_0; /* Key block + preamble for firmware 0 */ | 30 void* verification_block_0; /* Key block + preamble for firmware 0 */ |
33 void* verification_block_1; /* Key block + preamble for firmware 1 */ | 31 void* verification_block_1; /* Key block + preamble for firmware 1 */ |
34 uint64_t verification_size_0; /* Verification block 0 size in bytes */ | 32 uint64_t verification_size_0; /* Verification block 0 size in bytes */ |
35 uint64_t verification_size_1; /* Verification block 1 size in bytes */ | 33 uint64_t verification_size_1; /* Verification block 1 size in bytes */ |
36 void* shared_data_blob; /* Destination buffer for data shared between | 34 |
37 * LoadFirmware() and LoadKernel(). Pass this | 35 /* Shared data blob for data shared between LoadFirmware() and LoadKernel(). |
| 36 * This should be at least VB_SHARED_DATA_MIN_SIZE bytes long, and ideally |
| 37 * is VB_SHARED_DATA_REC_SIZE bytes long. */ |
| 38 void* shared_data_blob; /* Shared data blob buffer. Pass this |
38 * data to LoadKernel() in | 39 * data to LoadKernel() in |
39 * LoadKernelParams.shared_data_blob. */ | 40 * LoadKernelParams.shared_data_blob. */ |
40 uint64_t shared_data_size; /* Size of shared data blob buffer, in bytes. | 41 uint64_t shared_data_size; /* On input, set to size of shared data blob |
41 * On output, this will contain the actual | 42 * buffer, in bytes. On output, this will |
42 * data size placed into the buffer. Caller | 43 * contain the actual data size placed into |
43 * need only pass this much data to | 44 * the buffer. Caller need only pass that |
44 * LoadKernel().*/ | 45 * much data to LoadKernel().*/ |
| 46 |
45 uint64_t boot_flags; /* Boot flags */ | 47 uint64_t boot_flags; /* Boot flags */ |
46 VbNvContext* nv_context; /* Context for NV storage. nv_context->raw | 48 VbNvContext* nv_context; /* Context for NV storage. nv_context->raw |
47 * must be filled before calling | 49 * must be filled before calling |
48 * LoadFirmware(). On output, check | 50 * LoadFirmware(). On output, check |
49 * nv_context->raw_changed to see if | 51 * nv_context->raw_changed to see if |
50 * nv_context->raw has been modified and | 52 * nv_context->raw has been modified and |
51 * needs saving. */ | 53 * needs saving. */ |
52 | 54 |
53 /* Outputs from LoadFirmware(); valid only if LoadFirmware() returns | 55 /* Outputs from LoadFirmware(); valid only if LoadFirmware() returns |
54 * LOAD_FIRMWARE_SUCCESS. */ | 56 * LOAD_FIRMWARE_SUCCESS. */ |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 * called inside GetFirmwareBody(). */ | 101 * called inside GetFirmwareBody(). */ |
100 void UpdateFirmwareBodyHash(LoadFirmwareParams* params, | 102 void UpdateFirmwareBodyHash(LoadFirmwareParams* params, |
101 uint8_t* data, uint64_t size); | 103 uint8_t* data, uint64_t size); |
102 | 104 |
103 /* Handle S3 resume. | 105 /* Handle S3 resume. |
104 * | 106 * |
105 * Returns LOAD_FIRMWARE_SUCCESS if successful, error code on failure. */ | 107 * Returns LOAD_FIRMWARE_SUCCESS if successful, error code on failure. */ |
106 int S3Resume(void); | 108 int S3Resume(void); |
107 | 109 |
108 #endif /* VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ */ | 110 #endif /* VBOOT_REFERENCE_LOAD_FIRMWARE_FW_H_ */ |
OLD | NEW |