blob: 9e4db8e69e53d1e83b3c4dec06e33435b08c2509 [file] [log] [blame]
Randall Spanglera2db67d2013-01-24 16:15:35 -08001/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
Randall Spangler102bfba2010-05-24 15:14:33 -07002 * 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 Spangler7adcc602011-06-24 16:11:45 -070012#include "vboot_api.h"
Randall Spangler102bfba2010-05-24 15:14:33 -070013
Randall Spanglere4136dc2016-10-27 14:34:59 -070014struct vb2_context;
15
Randall Spangler102bfba2010-05-24 15:14:33 -070016/* Interface provided by verified boot library to BDS */
17
Randall Spanglerd1836442010-06-10 09:59:04 -070018/* Boot flags for LoadKernel().boot_flags */
Dan Ehrenberg3f4d8d02014-12-02 08:21:57 -080019/* GPT is external */
20#define BOOT_FLAG_EXTERNAL_GPT (0x04ULL)
Randall Spangler0ff6fea2010-05-27 18:36:02 -070021
Randall Spangler102bfba2010-05-24 15:14:33 -070022typedef struct LoadKernelParams {
Randall Spanglera2db67d2013-01-24 16:15:35 -080023 /* Inputs to LoadKernel() */
Randall Spanglera2db67d2013-01-24 16:15:35 -080024 /* Disk handle for current device */
25 VbExDiskHandle_t disk_handle;
26 /* Bytes per lba sector on current device */
27 uint64_t bytes_per_lba;
Dan Ehrenberg3f4d8d02014-12-02 08:21:57 -080028 /* Number of LBA-addressable sectors on the main device */
29 uint64_t streaming_lba_count;
30 /* Random-access GPT size */
31 uint64_t gpt_lba_count;
Randall Spanglera2db67d2013-01-24 16:15:35 -080032 /* Destination buffer for kernel (normally at 0x100000) */
33 void *kernel_buffer;
34 /* Size of kernel buffer in bytes */
35 uint64_t kernel_buffer_size;
36 /* Boot flags */
37 uint64_t boot_flags;
Randall Spangler7adcc602011-06-24 16:11:45 -070038
Randall Spanglera2db67d2013-01-24 16:15:35 -080039 /*
40 * Outputs from LoadKernel(); valid only if LoadKernel() returns
41 * LOAD_KERNEL_SUCCESS
42 */
43 /* Partition number to boot on current device (1...M) */
Randall Spanglerf1824012016-10-25 10:00:27 -070044 uint32_t partition_number;
Randall Spanglera2db67d2013-01-24 16:15:35 -080045 /* Address of bootloader image in RAM */
46 uint64_t bootloader_address;
47 /* Size of bootloader image in bytes */
Randall Spanglerf1824012016-10-25 10:00:27 -070048 uint32_t bootloader_size;
Randall Spanglera2db67d2013-01-24 16:15:35 -080049 /* UniquePartitionGuid for boot partition */
50 uint8_t partition_guid[16];
Furquan Shaikhb7d1f032015-02-03 16:28:31 -080051 /* Flags passed in by signer */
52 uint32_t flags;
Randall Spangler102bfba2010-05-24 15:14:33 -070053} LoadKernelParams;
54
Randall Spanglera2db67d2013-01-24 16:15:35 -080055/**
56 * Attempt to load the kernel from the current device.
Randall Spangler102bfba2010-05-24 15:14:33 -070057 *
Randall Spanglere4136dc2016-10-27 14:34:59 -070058 * @param ctx Vboot context
59 * @param params Params specific to loading the kernel
Randall Spanglere4136dc2016-10-27 14:34:59 -070060 *
Julius Wernerddcec122019-10-14 16:16:20 -070061 * Returns VB2_SUCCESS if successful. If unsuccessful, returns an error code.
Randall Spanglera2db67d2013-01-24 16:15:35 -080062 */
Joel Kitching90671fa2019-07-31 13:17:08 +080063vb2_error_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params);
Randall Spangler102bfba2010-05-24 15:14:33 -070064
Randall Spangler102bfba2010-05-24 15:14:33 -070065#endif /* VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ */