| 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 "load_kernel_fw.h" | 9 #include "load_kernel_fw.h" |
| 10 | 10 |
| 11 #include "boot_device.h" | 11 #include "boot_device.h" |
| 12 #include "cgptlib.h" | 12 #include "cgptlib.h" |
| 13 #include "kernel_image_fw.h" | 13 #include "kernel_image_fw.h" |
| 14 #include "rollback_index.h" | 14 #include "rollback_index.h" |
| 15 #include "utility.h" | 15 #include "utility.h" |
| 16 #include "vboot_kernel.h" | 16 #include "vboot_kernel.h" |
| 17 | 17 |
| 18 #define GPT_ENTRIES_SIZE 16384 /* Bytes to read for GPT entries */ | 18 #define GPT_ENTRIES_SIZE 16384 /* Bytes to read for GPT entries */ |
| 19 | 19 |
| 20 #ifdef PRINT_DEBUG_INFO | 20 #ifdef PRINT_DEBUG_INFO |
| 21 // TODO: for testing | 21 // TODO: for testing |
| 22 #include <stdio.h> | 22 #include <stdio.h> |
| 23 #include <inttypes.h> /* For PRIu64 macro */ | 23 #include <inttypes.h> /* For PRIu64 macro */ |
| 24 #include "cgptlib_internal.h" | 24 #include "cgptlib_internal.h" |
| 25 #endif | 25 #endif |
| 26 | 26 |
| 27 | 27 |
| 28 #define KBUF_SIZE 65536 /* Bytes to read at start of kernel partition */ | 28 #define KBUF_SIZE 65536 /* Bytes to read at start of kernel partition */ |
| 29 | 29 |
| 30 int LoadKernel(LoadKernelParams* params) { | 30 int LoadKernelOld(LoadKernelParams* params) { |
| 31 | 31 |
| 32 GptData gpt; | 32 GptData gpt; |
| 33 uint64_t part_start, part_size; | 33 uint64_t part_start, part_size; |
| 34 uint64_t blba = params->bytes_per_lba; | 34 uint64_t blba = params->bytes_per_lba; |
| 35 uint8_t* kbuf = NULL; | 35 uint8_t* kbuf = NULL; |
| 36 uint64_t kbuf_sectors; | 36 uint64_t kbuf_sectors; |
| 37 int found_partition = 0; | 37 int found_partition = 0; |
| 38 int good_partition = -1; | 38 int good_partition = -1; |
| 39 uint16_t tpm_kernel_key_version, tpm_kernel_version; | 39 uint16_t tpm_kernel_key_version, tpm_kernel_version; |
| 40 uint16_t lowest_kernel_key_version = 0xFFFF; | 40 uint16_t lowest_kernel_key_version = 0xFFFF; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 /* Success! */ | 242 /* Success! */ |
| 243 return LOAD_KERNEL_SUCCESS; | 243 return LOAD_KERNEL_SUCCESS; |
| 244 } | 244 } |
| 245 | 245 |
| 246 /* Handle error cases */ | 246 /* Handle error cases */ |
| 247 if (found_partition) | 247 if (found_partition) |
| 248 return LOAD_KERNEL_INVALID; | 248 return LOAD_KERNEL_INVALID; |
| 249 else | 249 else |
| 250 return LOAD_KERNEL_NOT_FOUND; | 250 return LOAD_KERNEL_NOT_FOUND; |
| 251 } | 251 } |
| OLD | NEW |