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 * Data structure and API definitions for a verified boot kernel image. | 5 * Data structure and API definitions for a verified boot kernel image. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef VBOOT_REFERENCE_KERNEL_IMAGE_H_ | 8 #ifndef VBOOT_REFERENCE_KERNEL_IMAGE_H_ |
9 #define VBOOT_REFERENCE_KERNEL_IMAGE_H_ | 9 #define VBOOT_REFERENCE_KERNEL_IMAGE_H_ |
10 | 10 |
11 #include <inttypes.h> | 11 #include <inttypes.h> |
12 | 12 |
13 #include "rsa.h" | 13 #include "rsa.h" |
14 #include "sha.h" | 14 #include "sha.h" |
15 | 15 |
16 #define KERNEL_MAGIC "CHROMEOS" | 16 #define KERNEL_MAGIC "CHROMEOS" |
17 #define KERNEL_MAGIC_SIZE 8 | 17 #define KERNEL_MAGIC_SIZE 8 |
18 #define KERNEL_CMD_LINE_SIZE 4096 | 18 #define KERNEL_CMD_LINE_SIZE 4096 |
19 | 19 |
| 20 #define DEV_MODE_ENABLED 1 |
| 21 #define DEV_MODE_DISABLED 0 |
| 22 |
20 /* Kernel config file options according to the Chrome OS drive map design. */ | 23 /* Kernel config file options according to the Chrome OS drive map design. */ |
21 typedef struct kconfig_options { | 24 typedef struct kconfig_options { |
22 uint32_t version[2]; /* Configuration file version. */ | 25 uint32_t version[2]; /* Configuration file version. */ |
23 uint8_t cmd_line[KERNEL_CMD_LINE_SIZE]; /* Kernel command line option string | 26 uint8_t cmd_line[KERNEL_CMD_LINE_SIZE]; /* Kernel command line option string |
24 * terminated by a NULL character. */ | 27 * terminated by a NULL character. */ |
25 uint64_t kernel_len; /* Size of the kernel. */ | 28 uint64_t kernel_len; /* Size of the kernel. */ |
26 uint64_t kernel_load_addr; /* Load address in memory for the kernel image */ | 29 uint64_t kernel_load_addr; /* Load address in memory for the kernel image */ |
27 uint64_t kernel_entry_addr; /* Address to jump to after kernel is loaded. */ | 30 uint64_t kernel_entry_addr; /* Address to jump to after kernel is loaded. */ |
28 } kconfig_options; | 31 } kconfig_options; |
29 | 32 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 int AddKernelKeySignature(KernelImage* image, const char* firmware_key_file); | 217 int AddKernelKeySignature(KernelImage* image, const char* firmware_key_file); |
215 | 218 |
216 /* Add a kernel and kernel config signature to a kernel image [image] | 219 /* Add a kernel and kernel config signature to a kernel image [image] |
217 * using the private signing key in file [kernel_sigining_key_file]. | 220 * using the private signing key in file [kernel_sigining_key_file]. |
218 * | 221 * |
219 * Return 1 on success, 0 on failure. | 222 * Return 1 on success, 0 on failure. |
220 */ | 223 */ |
221 int AddKernelSignature(KernelImage* image, | 224 int AddKernelSignature(KernelImage* image, |
222 const char* kernel_sigining_key_file); | 225 const char* kernel_sigining_key_file); |
223 | 226 |
| 227 /* Returns the logical version of a kernel blob which is calculated as |
| 228 * (kernel_key_version << 16 | kernel_version). */ |
| 229 uint32_t GetLogicalKernelVersion(uint8_t* kernel_blob); |
| 230 |
| 231 #define BOOT_KERNEL_A_CONTINUE 1 |
| 232 #define BOOT_KERNEL_B_CONTINUE 2 |
| 233 #define BOOT_KERNEL_RECOVERY_CONTINUE 3 |
| 234 |
| 235 /* Contains information about the kernel paritition |
| 236 * gleaned from the GPT partition table. |
| 237 * |
| 238 * Based on the Chromium OS Drive Map design document by |
| 239 * rspangler@chromium.org. |
| 240 * |
| 241 */ |
| 242 typedef struct kernel_entry { |
| 243 uint8_t* kernel_blob; /* Pointer to actual kernel. */ |
| 244 uint8_t boot_priority; /* 15 = highest, 1 = lowest, 0 = not bootable. */ |
| 245 uint8_t boot_tries_remaining; /* Used when boot_priority = 0. */ |
| 246 uint8_t boot_success_flag; /* Set to 1 on successful boot by AU. */ |
| 247 } kernel_entry; |
| 248 |
| 249 void PrintKernelEntry(kernel_entry* entry); |
| 250 |
| 251 /* This function is the driver used by the RW firmware to |
| 252 * determine which copy of the kernel to boot from. It performs |
| 253 * the requisite priority and remaining tries checking for a specific |
| 254 * kernel partition, does rollback index checking, including updating |
| 255 * if required. |
| 256 * |
| 257 * Returns the code path to follow. It is one of: |
| 258 * BOOT_KERNEL_A_CONTINUE Boot from Kenrel A |
| 259 * BOOT_KERNEL_B_CONTINUE Boot from Kernel B |
| 260 * BOOT_KERNEL_RECOVERY_CONTINUE Jump to recovery mode |
| 261 */ |
| 262 int VerifyKernelDriver_f(uint8_t* firmware_key_blob, |
| 263 kernel_entry* kernelA, |
| 264 kernel_entry* kernelB, |
| 265 int dev_mode); |
| 266 |
224 #endif /* VBOOT_REFERENCE_KERNEL_IMAGE_H_ */ | 267 #endif /* VBOOT_REFERENCE_KERNEL_IMAGE_H_ */ |
OLD | NEW |