Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 * | 5 * |
| 6 * Alternatively, this software may be distributed under the terms of the | 6 * Alternatively, this software may be distributed under the terms of the |
| 7 * GNU General Public License ("GPL") version 2 as published by the Free | 7 * GNU General Public License ("GPL") version 2 as published by the Free |
| 8 * Software Foundation. | 8 * Software Foundation. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 #action, return_code); \ | 28 #action, return_code); \ |
| 29 } while (0) | 29 } while (0) |
| 30 #else | 30 #else |
| 31 #define WARN_ON_FAILURE(action) action | 31 #define WARN_ON_FAILURE(action) action |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 #define FIRMWARE_RECOVERY 0 | 34 #define FIRMWARE_RECOVERY 0 |
| 35 #define FIRMWARE_A 1 | 35 #define FIRMWARE_A 1 |
| 36 #define FIRMWARE_B 2 | 36 #define FIRMWARE_B 2 |
| 37 | 37 |
| 38 int load_firmware(int primary_firmware, int boot_flags, | |
| 39 void *kernel_sign_key_blob, uint64_t kernel_sign_key_size, | |
| 40 int *firmware_index_ptr) | |
| 41 { | |
| 42 return LOAD_FIRMWARE_RECOVERY; | |
| 43 } | |
| 44 | |
| 45 void jump_to_firmware(void (*rwfw_entry_point)(void)) | |
| 46 { | |
| 47 debug(PREFIX "jump to firmware %p\n", rwfw_entry_point); | |
| 48 } | |
| 49 | |
| 38 int do_cros_bootstub(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) | 50 int do_cros_bootstub(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 39 { | 51 { |
| 40 » int firmware_index, primary_firmware; | 52 » int status = !LOAD_FIRMWARE_SUCCESS; |
|
sjg
2011/03/01 05:13:41
Ick - this is odd. Perhaps just 0 for ok, -1 for e
Che-Liang Chiou
2011/03/01 08:45:22
Change it to LOAD_FIRMWARE_RECOVERY (since we shou
| |
| 41 | 53 » int firmware_index, primary_firmware, boot_flags = 0; |
| 42 » /* Boot Stub ******************************************************** */ | 54 » uint8_t *kernel_sign_key_blob = (uint8_t *) CONFIG_KERNEL_SIGN_KEY_BLOB; |
| 55 » uint64_t kernel_sign_key_size = CONFIG_KERNEL_SIGN_KEY_SIZE; | |
| 43 | 56 |
| 44 /* TODO Start initializing chipset */ | 57 /* TODO Start initializing chipset */ |
| 45 | 58 |
| 46 if (is_firmware_write_protect_gpio_asserted()) | 59 if (is_firmware_write_protect_gpio_asserted()) |
| 47 WARN_ON_FAILURE(lock_down_eeprom()); | 60 WARN_ON_FAILURE(lock_down_eeprom()); |
| 48 | 61 |
| 49 WARN_ON_FAILURE(initialize_tpm()); | 62 WARN_ON_FAILURE(initialize_tpm()); |
| 50 | 63 |
| 51 if (is_s3_resume() && !is_debug_reset_mode_field_containing_cookie()) { | 64 if (is_s3_resume() && !is_debug_reset_mode_field_containing_cookie()) { |
| 52 WARN_ON_FAILURE(lock_tpm()); | 65 WARN_ON_FAILURE(lock_tpm()); |
| 53 /* TODO Jump to S3 resume pointer and should never return */ | 66 /* TODO Jump to S3 resume pointer and should never return */ |
| 54 return 0; | 67 return 0; |
| 55 } | 68 } |
| 56 | 69 |
| 57 if (is_recovery_mode_gpio_asserted() || | 70 if (is_recovery_mode_gpio_asserted() || |
| 58 is_recovery_mode_field_containing_cookie()) { | 71 is_recovery_mode_field_containing_cookie()) { |
| 59 firmware_index = FIRMWARE_RECOVERY; | 72 firmware_index = FIRMWARE_RECOVERY; |
| 60 } else { | 73 } else { |
| 61 if (is_try_firmware_b_field_containing_cookie()) | 74 if (is_try_firmware_b_field_containing_cookie()) |
| 62 primary_firmware = FIRMWARE_B; | 75 primary_firmware = FIRMWARE_B; |
| 63 else | 76 else |
| 64 primary_firmware = FIRMWARE_A; | 77 primary_firmware = FIRMWARE_A; |
| 65 | 78 |
| 66 » » /* TODO call LoadFirmware */ | 79 » » if (is_developer_mode_gpio_asserted()) |
| 80 » » » boot_flags |= BOOT_FLAG_DEVELOPER; | |
| 81 | |
| 82 » » status = load_firmware(primary_firmware, boot_flags, | |
| 83 » » » » kernel_sign_key_blob, kernel_sign_key_size, | |
| 84 » » » » &firmware_index); | |
| 67 } | 85 } |
| 68 | 86 |
| 69 debug(PREFIX "load firmware of index %d\n", firmware_index); | |
| 70 | |
| 71 WARN_ON_FAILURE(lock_tpm_rewritable_firmware_index()); | 87 WARN_ON_FAILURE(lock_tpm_rewritable_firmware_index()); |
| 72 | 88 |
| 73 » if (firmware_index == FIRMWARE_A) { | 89 » if (status == LOAD_FIRMWARE_SUCCESS) { |
| 74 » » /* TODO Jump to firmware A and should never return */ | 90 » » debug(PREFIX "jump to rewritable firmware %d " |
| 91 » » » » "and never return\n", firmware_index); | |
| 92 » » jump_to_firmware((void (*)(void)) (firmware_index == 0 ? | |
| 93 » » » » » CONFIG_FIRMWARE_BODY_BUFFER_0 : | |
|
Che-Liang Chiou
2011/03/01 08:45:22
Remove statically allocated buffers. Changes due t
| |
| 94 » » » » » CONFIG_FIRMWARE_BODY_BUFFER_1)); | |
| 95 » } else { | |
| 96 » » /* TODO Jump to recovery firmware and never return */ | |
| 75 } | 97 } |
| 76 | 98 |
| 77 » if (firmware_index == FIRMWARE_B) { | 99 » debug(PREFIX "error: should never reach here!\n"); |
| 78 » » /* TODO Jump to firmware B and should never return */ | 100 » return 1; |
|
sjg
2011/03/01 05:13:41
Should this hang, jump to recovery mode, something
Che-Liang Chiou
2011/03/01 08:45:22
We should jump to recovery firmware when rewritabl
| |
| 79 » } | |
| 80 | |
| 81 » /* assert(firmware_index == FIRMWARE_RECOVERY); */ | |
| 82 | |
| 83 » /* Recovery Firmware ************************************************ */ | |
| 84 | |
| 85 » return 0; | |
| 86 } | 101 } |
| 87 | 102 |
| 88 U_BOOT_CMD(cros_bootstub, 1, 1, do_cros_bootstub, NULL, NULL); | 103 U_BOOT_CMD(cros_bootstub, 1, 1, do_cros_bootstub, NULL, NULL); |
| OLD | NEW |