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 * TEMPORARY stub for calling LoadFirmware() which looks like the old |
| 6 * VerifyFirmwarDriver_f() call. |
| 7 * (Firmware portion) |
| 8 */ |
| 9 |
| 10 #include "load_firmware_fw.h" |
| 11 |
| 12 #include "firmware_image_fw.h" |
| 13 #include "utility.h" |
| 14 |
| 15 |
| 16 static uint8_t *g_firmwareA; |
| 17 static uint64_t g_firmwareA_size; |
| 18 static uint8_t *g_firmwareB; |
| 19 static uint64_t g_firmwareB_size; |
| 20 |
| 21 |
| 22 void *GetFirmwareBody(uint64_t firmware_index, uint64_t* size) { |
| 23 |
| 24 uint8_t *fw; |
| 25 |
| 26 /* In a real implementation, GetFirmwareBody() should be what reads |
| 27 * and decompresses the firmware volume. In this temporary hack, we |
| 28 * just pass the pointer which we got from |
| 29 * VerifyFirmwareDriver_Stub(). */ |
| 30 switch(firmware_index) { |
| 31 case 0: |
| 32 *size = g_firmwareA_size; |
| 33 fw = g_firmwareA; |
| 34 case 1: |
| 35 *size = g_firmwareB_size; |
| 36 fw = g_firmwareB; |
| 37 default: |
| 38 /* Anything else is invalid */ |
| 39 *size = 0; |
| 40 return NULL; |
| 41 } |
| 42 |
| 43 /* Need to call UpdateFirmwareBodyHash() with the firmware volume |
| 44 * data. In this temporary hack, the FV is already decompressed, so |
| 45 * we pass in the entire volume at once. In a real implementation, |
| 46 * you should call this as the FV is being decompressed. */ |
| 47 UpdateFirmwareBodyHash(fw, *size); |
| 48 |
| 49 /* Return the firmware body pointer */ |
| 50 return fw; |
| 51 } |
| 52 |
| 53 |
| 54 /* Where you're currently calling VerifyFirmwareDriver_f(), call this |
| 55 * function instead. Because you still need to read in both firmware |
| 56 * volumes, this call will still be slow. Once we reach feature |
| 57 * complete, you should modify your code to call LoadImage() |
| 58 * directly. */ |
| 59 int VerifyFirmwareDriver_stub(uint8_t* root_key_blob, |
| 60 uint8_t* verification_headerA, |
| 61 uint8_t* firmwareA, |
| 62 uint8_t* verification_headerB, |
| 63 uint8_t* firmwareB) { |
| 64 |
| 65 int rv; |
| 66 |
| 67 /* Copy the firmware volume pointers to our global variables. */ |
| 68 g_firmwareA = firmwareA; |
| 69 g_firmwareB = firmwareB; |
| 70 |
| 71 /* TODO: YOU NEED TO PASS IN THE FIRMWARE VOLUME SIZES SOMEHOW */ |
| 72 g_firmwareA_size = 0; |
| 73 g_firmwareB_size = 0; |
| 74 |
| 75 /* Set up the params for LoadFirmware() */ |
| 76 LoadFirmwareParams p; |
| 77 p.firmware_root_key_blob = root_key_blob; |
| 78 p.verification_block_0 = verification_headerA; |
| 79 p.verification_block_1 = verification_headerB; |
| 80 |
| 81 /* Call LoadFirmware() */ |
| 82 rv = LoadFirmware(&p); |
| 83 if (LOAD_FIRMWARE_SUCCESS == rv) { |
| 84 /* TODO: YOU NEED TO KEEP TRACK OF p.kernel_sign_key_blob AND |
| 85 * p.kernel_sign_key_size SO YOU CAN PASS THEM TO LoadKernel(). */ |
| 86 |
| 87 return (0 == p.firmware_index ? BOOT_FIRMWARE_A_CONTINUE : |
| 88 BOOT_FIRMWARE_B_CONTINUE); |
| 89 |
| 90 } else { |
| 91 /* Error */ |
| 92 return BOOT_FIRMWARE_RECOVERY_CONTINUE; |
| 93 } |
| 94 } |
OLD | NEW |