Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 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 |
| 3 | * found in the LICENSE file. |
| 4 | * |
| 5 | * High-level firmware API for loading and verifying kernel. |
| 6 | * (Firmware Portion) |
| 7 | */ |
| 8 | |
| 9 | #ifndef VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ |
| 10 | #define VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ |
| 11 | |
Randall Spangler | f302905 | 2010-06-16 13:42:58 -0700 | [diff] [blame] | 12 | #include "sysincludes.h" |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 13 | |
| 14 | /* Interface provided by verified boot library to BDS */ |
| 15 | |
| 16 | /* Return codes for LoadKernel() */ |
Randall Spangler | c1a9f4d | 2010-06-07 15:15:00 -0700 | [diff] [blame] | 17 | #define LOAD_KERNEL_SUCCESS 0 /* Success; good 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 */ |
| 20 | #define LOAD_KERNEL_RECOVERY 3 /* Internal error; reboot to recovery mode */ |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 21 | |
Randall Spangler | d183644 | 2010-06-10 09:59:04 -0700 | [diff] [blame] | 22 | /* Boot flags for LoadKernel().boot_flags */ |
| 23 | #define BOOT_FLAG_DEVELOPER UINT64_C(0x01) /* Developer switch is on */ |
| 24 | #define BOOT_FLAG_RECOVERY UINT64_C(0x02) /* In recovery mode */ |
Randall Spangler | 695cd16 | 2010-06-15 23:38:23 -0700 | [diff] [blame] | 25 | #define BOOT_FLAG_SKIP_ADDR_CHECK UINT64_C(0x04) /* Skip check of kernel |
| 26 | * buffer address */ |
Randall Spangler | 0ff6fea | 2010-05-27 18:36:02 -0700 | [diff] [blame] | 27 | |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 28 | typedef struct LoadKernelParams { |
| 29 | /* Inputs to LoadKernel() */ |
Randall Spangler | 0ff6fea | 2010-05-27 18:36:02 -0700 | [diff] [blame] | 30 | void *header_sign_key_blob; /* Key blob used to sign the kernel header */ |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 31 | uint64_t bytes_per_lba; /* Bytes per lba sector on current device */ |
| 32 | uint64_t ending_lba; /* Last addressable lba sector on current |
| 33 | * device */ |
| 34 | void *kernel_buffer; /* Destination buffer for kernel |
| 35 | * (normally at 0x100000) */ |
| 36 | uint64_t kernel_buffer_size; /* Size of kernel buffer in bytes */ |
Randall Spangler | d183644 | 2010-06-10 09:59:04 -0700 | [diff] [blame] | 37 | uint64_t boot_flags; /* Boot flags */ |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 38 | |
| 39 | /* Outputs from LoadKernel(); valid only if LoadKernel() returns |
| 40 | * LOAD_KERNEL_SUCCESS */ |
| 41 | uint64_t partition_number; /* Partition number to boot on current device |
| 42 | * (1...M) */ |
Randall Spangler | 19d1313 | 2010-06-03 09:43:43 -0700 | [diff] [blame] | 43 | uint64_t bootloader_address; /* Address of bootloader image in RAM */ |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 44 | uint64_t bootloader_size; /* Size of bootloader image in bytes */ |
| 45 | } LoadKernelParams; |
| 46 | |
Randall Spangler | 0ff6fea | 2010-05-27 18:36:02 -0700 | [diff] [blame] | 47 | int LoadKernel(LoadKernelParams* params); |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 48 | /* Attempts to load the kernel from the current device. |
| 49 | * |
| 50 | * Returns LOAD_KERNEL_SUCCESS if successful, error code on failure. */ |
| 51 | |
| 52 | |
| 53 | typedef struct KernelBootloaderOptions { |
| 54 | /* The bootloader is loaded using the EFI LoadImage() and StartImage() |
| 55 | * calls. Pass this struct via loaded_image->load_options. */ |
| 56 | uint64_t drive_number; /* Drive number of boot device (0...N) */ |
| 57 | uint64_t partition_number; /* Partition number, as returned from |
| 58 | * LoadKernel() in |
| 59 | * LoadKernelParams.partition_number */ |
| 60 | uint64_t original_address; /* Absolute bootloader start adddress, |
| 61 | * as returned from LoadKernel() in |
| 62 | * LoadKernelParams.bootloader_start */ |
| 63 | } KernelBootloaderOptions; |
| 64 | |
| 65 | |
| 66 | #endif /* VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ */ |