Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(890)

Side by Side Diff: firmware/lib/vboot_kernel.c

Issue 2865014: Assorted integration fixes. (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: Add struct size tests Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « firmware/lib/vboot_firmware.c ('k') | tests/cgptlib_test.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * Functions for loading a kernel from disk. 5 * Functions for loading a kernel from disk.
6 * (Firmware portion) 6 * (Firmware portion)
7 */ 7 */
8 8
9 #include "vboot_kernel.h" 9 #include "vboot_kernel.h"
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 /* Writes any changes for the GPT data back to the drive, then frees 60 /* Writes any changes for the GPT data back to the drive, then frees
61 * the buffers. 61 * the buffers.
62 * 62 *
63 * Returns 0 if successful, 1 if error. */ 63 * Returns 0 if successful, 1 if error. */
64 int WriteAndFreeGptData(GptData* gptdata) { 64 int WriteAndFreeGptData(GptData* gptdata) {
65 65
66 uint64_t entries_sectors = TOTAL_ENTRIES_SIZE / gptdata->sector_bytes; 66 uint64_t entries_sectors = TOTAL_ENTRIES_SIZE / gptdata->sector_bytes;
67 67
68 if (gptdata->primary_header) { 68 if (gptdata->primary_header) {
69 if (gptdata->modified & GPT_MODIFIED_HEADER1) { 69 if (gptdata->modified & GPT_MODIFIED_HEADER1) {
70 debug("Updating GPT header 1\n");
70 if (0 != BootDeviceWriteLBA(1, 1, gptdata->primary_header)) 71 if (0 != BootDeviceWriteLBA(1, 1, gptdata->primary_header))
71 return 1; 72 return 1;
72 } 73 }
73 Free(gptdata->primary_header); 74 Free(gptdata->primary_header);
74 } 75 }
75 76
76 if (gptdata->primary_entries) { 77 if (gptdata->primary_entries) {
77 if (gptdata->modified & GPT_MODIFIED_ENTRIES1) { 78 if (gptdata->modified & GPT_MODIFIED_ENTRIES1) {
79 debug("Updating GPT entries 1\n");
78 if (0 != BootDeviceWriteLBA(2, entries_sectors, 80 if (0 != BootDeviceWriteLBA(2, entries_sectors,
79 gptdata->primary_entries)) 81 gptdata->primary_entries))
80 return 1; 82 return 1;
81 } 83 }
82 Free(gptdata->primary_entries); 84 Free(gptdata->primary_entries);
83 } 85 }
84 86
85 if (gptdata->secondary_entries) { 87 if (gptdata->secondary_entries) {
86 if (gptdata->modified & GPT_MODIFIED_ENTRIES2) { 88 if (gptdata->modified & GPT_MODIFIED_ENTRIES2) {
89 debug("Updating GPT header 2\n");
87 if (0 != BootDeviceWriteLBA(gptdata->drive_sectors - entries_sectors - 1, 90 if (0 != BootDeviceWriteLBA(gptdata->drive_sectors - entries_sectors - 1,
88 entries_sectors, gptdata->secondary_entries)) 91 entries_sectors, gptdata->secondary_entries))
89 return 1; 92 return 1;
90 } 93 }
91 Free(gptdata->secondary_entries); 94 Free(gptdata->secondary_entries);
92 } 95 }
93 96
94 if (gptdata->secondary_header) { 97 if (gptdata->secondary_header) {
95 if (gptdata->modified & GPT_MODIFIED_HEADER2) { 98 if (gptdata->modified & GPT_MODIFIED_HEADER2) {
99 debug("Updating GPT entries 2\n");
96 if (0 != BootDeviceWriteLBA(gptdata->drive_sectors - 1, 1, 100 if (0 != BootDeviceWriteLBA(gptdata->drive_sectors - 1, 1,
97 gptdata->secondary_header)) 101 gptdata->secondary_header))
98 return 1; 102 return 1;
99 } 103 }
100 Free(gptdata->secondary_header); 104 Free(gptdata->secondary_header);
101 } 105 }
102 106
103 /* Success */ 107 /* Success */
104 return 0; 108 return 0;
105 } 109 }
(...skipping 17 matching lines...) Expand all
123 int is_dev = ((BOOT_FLAG_DEVELOPER & params->boot_flags) && 127 int is_dev = ((BOOT_FLAG_DEVELOPER & params->boot_flags) &&
124 !(BOOT_FLAG_RECOVERY & params->boot_flags)); 128 !(BOOT_FLAG_RECOVERY & params->boot_flags));
125 int is_normal = (!(BOOT_FLAG_DEVELOPER & params->boot_flags) && 129 int is_normal = (!(BOOT_FLAG_DEVELOPER & params->boot_flags) &&
126 !(BOOT_FLAG_RECOVERY & params->boot_flags)); 130 !(BOOT_FLAG_RECOVERY & params->boot_flags));
127 131
128 /* Clear output params in case we fail */ 132 /* Clear output params in case we fail */
129 params->partition_number = 0; 133 params->partition_number = 0;
130 params->bootloader_address = 0; 134 params->bootloader_address = 0;
131 params->bootloader_size = 0; 135 params->bootloader_size = 0;
132 136
137 /* Set up TPM; required in all modes */
138 if (0 != SetupTPM(
139 ((BOOT_FLAG_RECOVERY & params->boot_flags) ?
140 RO_RECOVERY_MODE : RW_NORMAL_MODE),
141 ((BOOT_FLAG_DEVELOPER & params->boot_flags) ? 1 : 0))) {
142 debug("Error setting up TPM\n");
143 return LOAD_KERNEL_RECOVERY;
144 }
145
133 if (is_normal) { 146 if (is_normal) {
134 /* Read current kernel key index from TPM. Assumes TPM is already 147 /* Read current kernel key index from TPM. Assumes TPM is already
135 * initialized. */ 148 * initialized. */
136 if (0 != GetStoredVersions(KERNEL_VERSIONS, 149 if (0 != GetStoredVersions(KERNEL_VERSIONS,
137 &tpm_key_version, 150 &tpm_key_version,
138 &tpm_kernel_version)) { 151 &tpm_kernel_version)) {
139 debug("Unable to get stored version from TPM\n"); 152 debug("Unable to get stored version from TPM\n");
140 return LOAD_KERNEL_RECOVERY; 153 return LOAD_KERNEL_RECOVERY;
141 } 154 }
142 } else if (is_dev) { 155 } else if (is_dev) {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 /* Success! */ 392 /* Success! */
380 return LOAD_KERNEL_SUCCESS; 393 return LOAD_KERNEL_SUCCESS;
381 } 394 }
382 395
383 // Handle error cases 396 // Handle error cases
384 if (found_partitions) 397 if (found_partitions)
385 return LOAD_KERNEL_INVALID; 398 return LOAD_KERNEL_INVALID;
386 else 399 else
387 return LOAD_KERNEL_NOT_FOUND; 400 return LOAD_KERNEL_NOT_FOUND;
388 } 401 }
OLDNEW
« no previous file with comments | « firmware/lib/vboot_firmware.c ('k') | tests/cgptlib_test.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698