Randall Spangler | a2db67d | 2013-01-24 16:15:35 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 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 | 7adcc60 | 2011-06-24 16:11:45 -0700 | [diff] [blame] | 12 | #include "vboot_api.h" |
Randall Spangler | 9e162cd | 2011-02-22 13:06:53 -0800 | [diff] [blame] | 13 | #include "vboot_nvstorage.h" |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 14 | |
| 15 | /* Interface provided by verified boot library to BDS */ |
| 16 | |
Randall Spangler | d183644 | 2010-06-10 09:59:04 -0700 | [diff] [blame] | 17 | /* Boot flags for LoadKernel().boot_flags */ |
Randall Spangler | a8e0f94 | 2011-02-14 11:12:09 -0800 | [diff] [blame] | 18 | /* Developer switch is on */ |
Gabe Black | ac8805e | 2013-03-16 04:03:40 -0700 | [diff] [blame] | 19 | #define BOOT_FLAG_DEVELOPER (0x01ULL) |
Randall Spangler | a8e0f94 | 2011-02-14 11:12:09 -0800 | [diff] [blame] | 20 | /* In recovery mode */ |
Gabe Black | ac8805e | 2013-03-16 04:03:40 -0700 | [diff] [blame] | 21 | #define BOOT_FLAG_RECOVERY (0x02ULL) |
Randall Spangler | 0ff6fea | 2010-05-27 18:36:02 -0700 | [diff] [blame] | 22 | |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 23 | typedef struct LoadKernelParams { |
Randall Spangler | a2db67d | 2013-01-24 16:15:35 -0800 | [diff] [blame] | 24 | /* Inputs to LoadKernel() */ |
| 25 | /* |
| 26 | * Buffer for data shared between LoadFirmware() and LoadKernel(). |
| 27 | * Pass the same buffer which was passed to LoadFirmware(). |
| 28 | */ |
| 29 | void *shared_data_blob; |
| 30 | /* |
| 31 | * Size of shared data blob buffer, in bytes. On output, this will |
| 32 | * contain the actual data size placed into the buffer. |
| 33 | */ |
| 34 | uint64_t shared_data_size; |
| 35 | /* Pointer to GBB data */ |
| 36 | void *gbb_data; |
| 37 | /* Size of GBB data in bytes */ |
| 38 | uint64_t gbb_size; |
| 39 | /* Disk handle for current device */ |
| 40 | VbExDiskHandle_t disk_handle; |
| 41 | /* Bytes per lba sector on current device */ |
| 42 | uint64_t bytes_per_lba; |
| 43 | /* Last addressable lba sector on current device */ |
| 44 | uint64_t ending_lba; |
| 45 | /* Destination buffer for kernel (normally at 0x100000) */ |
| 46 | void *kernel_buffer; |
| 47 | /* Size of kernel buffer in bytes */ |
| 48 | uint64_t kernel_buffer_size; |
| 49 | /* Boot flags */ |
| 50 | uint64_t boot_flags; |
| 51 | /* |
| 52 | * Context for NV storage. Caller is responsible for calling |
| 53 | * VbNvSetup() and VbNvTeardown() on the context. |
| 54 | */ |
| 55 | VbNvContext *nv_context; |
Randall Spangler | 7adcc60 | 2011-06-24 16:11:45 -0700 | [diff] [blame] | 56 | |
Randall Spangler | a2db67d | 2013-01-24 16:15:35 -0800 | [diff] [blame] | 57 | /* |
| 58 | * Outputs from LoadKernel(); valid only if LoadKernel() returns |
| 59 | * LOAD_KERNEL_SUCCESS |
| 60 | */ |
| 61 | /* Partition number to boot on current device (1...M) */ |
| 62 | uint64_t partition_number; |
| 63 | /* Address of bootloader image in RAM */ |
| 64 | uint64_t bootloader_address; |
| 65 | /* Size of bootloader image in bytes */ |
| 66 | uint64_t bootloader_size; |
| 67 | /* UniquePartitionGuid for boot partition */ |
| 68 | uint8_t partition_guid[16]; |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 69 | } LoadKernelParams; |
| 70 | |
Randall Spangler | a2db67d | 2013-01-24 16:15:35 -0800 | [diff] [blame] | 71 | /** |
| 72 | * Attempt to load the kernel from the current device. |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 73 | * |
Randall Spangler | dfb0175 | 2011-07-25 13:24:22 -0700 | [diff] [blame] | 74 | * Returns VBERROR_SUCCESS if successful. If unsuccessful, sets a recovery |
Randall Spangler | a2db67d | 2013-01-24 16:15:35 -0800 | [diff] [blame] | 75 | * reason via VbNvStorage and returns an error code. |
| 76 | */ |
Simon Glass | 527ba81 | 2013-07-25 08:48:47 -0600 | [diff] [blame] | 77 | VbError_t LoadKernel(LoadKernelParams *params, VbCommonParams *cparams); |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 78 | |
Randall Spangler | a2db67d | 2013-01-24 16:15:35 -0800 | [diff] [blame] | 79 | /* |
| 80 | * The bootloader is loaded using the EFI LoadImage() and StartImage() calls. |
| 81 | * Pass this struct via loaded_image->load_options. |
| 82 | */ |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 83 | typedef struct KernelBootloaderOptions { |
Randall Spangler | a2db67d | 2013-01-24 16:15:35 -0800 | [diff] [blame] | 84 | /* Drive number of boot device (0...N) */ |
| 85 | uint64_t drive_number; |
| 86 | /* |
| 87 | * Partition number, as returned from LoadKernel() in |
| 88 | * LoadKernelParams.partition_number |
| 89 | */ |
| 90 | uint64_t partition_number; |
| 91 | /* |
| 92 | * Absolute bootloader start adddress, as returned from LoadKernel() in |
| 93 | * LoadKernelParams.bootloader_start |
| 94 | */ |
| 95 | uint64_t original_address; |
| 96 | /* UniquePartitionGuid for boot partition */ |
| 97 | uint8_t partition_guid[16]; |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 98 | } KernelBootloaderOptions; |
| 99 | |
Randall Spangler | 102bfba | 2010-05-24 15:14:33 -0700 | [diff] [blame] | 100 | #endif /* VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ */ |