OLD | NEW |
---|---|
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 |
11 #include "boot_device.h" | 11 #include "boot_device.h" |
12 #include "cgptlib.h" | 12 #include "cgptlib.h" |
13 #include "load_kernel_fw.h" | 13 #include "load_kernel_fw.h" |
14 #include "rollback_index.h" | 14 #include "rollback_index.h" |
15 #include "utility.h" | 15 #include "utility.h" |
16 #include "vboot_common.h" | 16 #include "vboot_common.h" |
17 | 17 #include "cgptlib_internal.h" |
gauravsh
2010/07/23 01:50:57
nit: alpha order
| |
18 | 18 |
19 #define KBUF_SIZE 65536 /* Bytes to read at start of kernel partition */ | 19 #define KBUF_SIZE 65536 /* Bytes to read at start of kernel partition */ |
20 | 20 |
21 | 21 |
22 /* Allocates and reads GPT data from the drive. The sector_bytes and | 22 /* Allocates and reads GPT data from the drive. The sector_bytes and |
23 * drive_sectors fields should be filled on input. The primary and | 23 * drive_sectors fields should be filled on input. The primary and |
24 * secondary header and entries are filled on output. | 24 * secondary header and entries are filled on output. |
25 * | 25 * |
26 * Returns 0 if successful, 1 if error. */ | 26 * Returns 0 if successful, 1 if error. */ |
27 int AllocAndReadGptData(GptData* gptdata) { | 27 int AllocAndReadGptData(GptData* gptdata) { |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 /* Done with the kernel signing key, so can free it now */ | 343 /* Done with the kernel signing key, so can free it now */ |
344 RSAPublicKeyFree(data_key); | 344 RSAPublicKeyFree(data_key); |
345 | 345 |
346 /* If we're still here, the kernel is valid. */ | 346 /* If we're still here, the kernel is valid. */ |
347 /* Save the first good partition we find; that's the one we'll boot */ | 347 /* Save the first good partition we find; that's the one we'll boot */ |
348 VBDEBUG(("Partiton is good.\n")); | 348 VBDEBUG(("Partiton is good.\n")); |
349 /* TODO: GPT partitions start at 1, but cgptlib starts them at 0. | 349 /* TODO: GPT partitions start at 1, but cgptlib starts them at 0. |
350 * Adjust here, until cgptlib is fixed. */ | 350 * Adjust here, until cgptlib is fixed. */ |
351 good_partition = gpt.current_kernel + 1; | 351 good_partition = gpt.current_kernel + 1; |
352 params->partition_number = gpt.current_kernel + 1; | 352 params->partition_number = gpt.current_kernel + 1; |
353 GetCurrentKernelUniqueGuid(&gpt, ¶ms->partition_guid); | |
353 params->bootloader_address = preamble->bootloader_address; | 354 params->bootloader_address = preamble->bootloader_address; |
354 params->bootloader_size = preamble->bootloader_size; | 355 params->bootloader_size = preamble->bootloader_size; |
355 /* If we're in developer or recovery mode, there's no rollback | 356 /* If we're in developer or recovery mode, there's no rollback |
356 * protection, so we can stop at the first valid kernel. */ | 357 * protection, so we can stop at the first valid kernel. */ |
357 if (!is_normal) { | 358 if (!is_normal) { |
358 VBDEBUG(("Boot_flags = !is_normal\n")); | 359 VBDEBUG(("Boot_flags = !is_normal\n")); |
359 break; | 360 break; |
360 } | 361 } |
361 | 362 |
362 /* Otherwise, we're in normal boot mode, so we do care about the | 363 /* Otherwise, we're in normal boot mode, so we do care about the |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 /* Success! */ | 424 /* Success! */ |
424 return LOAD_KERNEL_SUCCESS; | 425 return LOAD_KERNEL_SUCCESS; |
425 } | 426 } |
426 | 427 |
427 // Handle error cases | 428 // Handle error cases |
428 if (found_partitions) | 429 if (found_partitions) |
429 return LOAD_KERNEL_INVALID; | 430 return LOAD_KERNEL_INVALID; |
430 else | 431 else |
431 return LOAD_KERNEL_NOT_FOUND; | 432 return LOAD_KERNEL_NOT_FOUND; |
432 } | 433 } |
OLD | NEW |