Chromium Code Reviews| 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 * High-level firmware API for loading and verifying kernel. | 5 * High-level firmware API for loading and verifying kernel. |
| 6 * (Firmware Portion) | 6 * (Firmware Portion) |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ | 9 #ifndef VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ |
| 10 #define VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ | 10 #define VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ |
| 11 | 11 |
| 12 #include <stdint.h> | 12 #include <stdint.h> |
| 13 | 13 |
| 14 /* Interface provided by verified boot library to BDS */ | 14 /* Interface provided by verified boot library to BDS */ |
| 15 | 15 |
| 16 /* Return codes for LoadKernel() */ | 16 /* Return codes for LoadKernel() */ |
| 17 #define LOAD_KERNEL_SUCCESS 0 /* Success; good kernel found on device */ | 17 #define LOAD_KERNEL_SUCCESS 0 /* Success; good kernel found on device */ |
| 18 #define LOAD_KERNEL_NOT_FOUND 1 /* No kernel found on device */ | 18 #define LOAD_KERNEL_NOT_FOUND 1 /* No kernel found on device */ |
| 19 #define LOAD_KERNEL_INVALID 2 /* Only invalid kernels found on device */ | 19 #define LOAD_KERNEL_INVALID 2 /* Only invalid kernels found on device */ |
| 20 #define LOAD_KERNEL_RECOVERY 3 /* Internal error; reboot to recovery mode */ | 20 #define LOAD_KERNEL_RECOVERY 3 /* Internal error; reboot to recovery mode */ |
| 21 | 21 |
| 22 /* Boot modes for LoadKernel() */ | 22 /* Boot flags for LoadKernel().boot_flags */ |
| 23 #define BOOT_MODE_NORMAL 0 | 23 #define BOOT_FLAG_DEVELOPER 0x01ULL /* Developer switch is on */ |
|
gauravsh
2010/06/10 14:44:13
unsigned long long is not guaranteed to be uint64_
| |
| 24 #define BOOT_MODE_DEVELOPER 1 | 24 #define BOOT_FLAG_RECOVERY 0x02ULL /* In recovery mode */ |
| 25 #define BOOT_MODE_RECOVERY 2 | |
| 26 | 25 |
| 27 typedef struct LoadKernelParams { | 26 typedef struct LoadKernelParams { |
| 28 /* Inputs to LoadKernel() */ | 27 /* Inputs to LoadKernel() */ |
| 29 void *header_sign_key_blob; /* Key blob used to sign the kernel header */ | 28 void *header_sign_key_blob; /* Key blob used to sign the kernel header */ |
| 30 uint64_t bytes_per_lba; /* Bytes per lba sector on current device */ | 29 uint64_t bytes_per_lba; /* Bytes per lba sector on current device */ |
| 31 uint64_t ending_lba; /* Last addressable lba sector on current | 30 uint64_t ending_lba; /* Last addressable lba sector on current |
| 32 * device */ | 31 * device */ |
| 33 void *kernel_buffer; /* Destination buffer for kernel | 32 void *kernel_buffer; /* Destination buffer for kernel |
| 34 * (normally at 0x100000) */ | 33 * (normally at 0x100000) */ |
| 35 uint64_t kernel_buffer_size; /* Size of kernel buffer in bytes */ | 34 uint64_t kernel_buffer_size; /* Size of kernel buffer in bytes */ |
| 36 uint8_t boot_mode; /* Boot mode */ | 35 uint64_t boot_flags; /* Boot flags */ |
| 37 | 36 |
| 38 /* Outputs from LoadKernel(); valid only if LoadKernel() returns | 37 /* Outputs from LoadKernel(); valid only if LoadKernel() returns |
| 39 * LOAD_KERNEL_SUCCESS */ | 38 * LOAD_KERNEL_SUCCESS */ |
| 40 uint64_t partition_number; /* Partition number to boot on current device | 39 uint64_t partition_number; /* Partition number to boot on current device |
| 41 * (1...M) */ | 40 * (1...M) */ |
| 42 uint64_t bootloader_address; /* Address of bootloader image in RAM */ | 41 uint64_t bootloader_address; /* Address of bootloader image in RAM */ |
| 43 uint64_t bootloader_size; /* Size of bootloader image in bytes */ | 42 uint64_t bootloader_size; /* Size of bootloader image in bytes */ |
| 44 } LoadKernelParams; | 43 } LoadKernelParams; |
| 45 | 44 |
| 46 int LoadKernel(LoadKernelParams* params); | 45 int LoadKernel(LoadKernelParams* params); |
| 47 /* Attempts to load the kernel from the current device. | 46 /* Attempts to load the kernel from the current device. |
| 48 * | 47 * |
| 49 * Returns LOAD_KERNEL_SUCCESS if successful, error code on failure. */ | 48 * Returns LOAD_KERNEL_SUCCESS if successful, error code on failure. */ |
| 50 | 49 |
| 51 | 50 |
| 52 typedef struct KernelBootloaderOptions { | 51 typedef struct KernelBootloaderOptions { |
| 53 /* The bootloader is loaded using the EFI LoadImage() and StartImage() | 52 /* The bootloader is loaded using the EFI LoadImage() and StartImage() |
| 54 * calls. Pass this struct via loaded_image->load_options. */ | 53 * calls. Pass this struct via loaded_image->load_options. */ |
| 55 uint64_t drive_number; /* Drive number of boot device (0...N) */ | 54 uint64_t drive_number; /* Drive number of boot device (0...N) */ |
| 56 uint64_t partition_number; /* Partition number, as returned from | 55 uint64_t partition_number; /* Partition number, as returned from |
| 57 * LoadKernel() in | 56 * LoadKernel() in |
| 58 * LoadKernelParams.partition_number */ | 57 * LoadKernelParams.partition_number */ |
| 59 uint64_t original_address; /* Absolute bootloader start adddress, | 58 uint64_t original_address; /* Absolute bootloader start adddress, |
| 60 * as returned from LoadKernel() in | 59 * as returned from LoadKernel() in |
| 61 * LoadKernelParams.bootloader_start */ | 60 * LoadKernelParams.bootloader_start */ |
| 62 } KernelBootloaderOptions; | 61 } KernelBootloaderOptions; |
| 63 | 62 |
| 64 | 63 |
| 65 #endif /* VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ */ | 64 #endif /* VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ */ |
| OLD | NEW |