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