blob: a710ee5df1b993141cc4863a090de69555917a6f [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 Spangler9e162cd2011-02-22 13:06:53 -080013#include "vboot_nvstorage.h"
Randall Spangler102bfba2010-05-24 15:14:33 -070014
15/* Interface provided by verified boot library to BDS */
16
Randall Spanglerd1836442010-06-10 09:59:04 -070017/* Boot flags for LoadKernel().boot_flags */
Randall Spanglera8e0f942011-02-14 11:12:09 -080018/* Developer switch is on */
Gabe Blackac8805e2013-03-16 04:03:40 -070019#define BOOT_FLAG_DEVELOPER (0x01ULL)
Randall Spanglera8e0f942011-02-14 11:12:09 -080020/* In recovery mode */
Gabe Blackac8805e2013-03-16 04:03:40 -070021#define BOOT_FLAG_RECOVERY (0x02ULL)
Randall Spangler0ff6fea2010-05-27 18:36:02 -070022
Randall Spangler102bfba2010-05-24 15:14:33 -070023typedef struct LoadKernelParams {
Randall Spanglera2db67d2013-01-24 16:15:35 -080024 /* 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 Spangler7adcc602011-06-24 16:11:45 -070056
Randall Spanglera2db67d2013-01-24 16:15:35 -080057 /*
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 Spangler102bfba2010-05-24 15:14:33 -070069} LoadKernelParams;
70
Randall Spanglera2db67d2013-01-24 16:15:35 -080071/**
72 * Attempt to load the kernel from the current device.
Randall Spangler102bfba2010-05-24 15:14:33 -070073 *
Randall Spanglerdfb01752011-07-25 13:24:22 -070074 * Returns VBERROR_SUCCESS if successful. If unsuccessful, sets a recovery
Randall Spanglera2db67d2013-01-24 16:15:35 -080075 * reason via VbNvStorage and returns an error code.
76 */
Simon Glass527ba812013-07-25 08:48:47 -060077VbError_t LoadKernel(LoadKernelParams *params, VbCommonParams *cparams);
Randall Spangler102bfba2010-05-24 15:14:33 -070078
Randall Spanglera2db67d2013-01-24 16:15:35 -080079/*
80 * The bootloader is loaded using the EFI LoadImage() and StartImage() calls.
81 * Pass this struct via loaded_image->load_options.
82 */
Randall Spangler102bfba2010-05-24 15:14:33 -070083typedef struct KernelBootloaderOptions {
Randall Spanglera2db67d2013-01-24 16:15:35 -080084 /* 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 Spangler102bfba2010-05-24 15:14:33 -070098} KernelBootloaderOptions;
99
Randall Spangler102bfba2010-05-24 15:14:33 -0700100#endif /* VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ */