blob: 4f86b4032d5e020c08b337a9bb7fea837507bef0 [file] [log] [blame]
Randall Spangler102bfba2010-05-24 15:14:33 -07001/* 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 Spanglerf3029052010-06-16 13:42:58 -070012#include "sysincludes.h"
Randall Spangler102bfba2010-05-24 15:14:33 -070013
14/* Interface provided by verified boot library to BDS */
15
16/* Return codes for LoadKernel() */
Randall Spanglerc1a9f4d2010-06-07 15:15:00 -070017#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 Spangler102bfba2010-05-24 15:14:33 -070021
Randall Spanglerd1836442010-06-10 09:59:04 -070022/* 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 Spangler695cd162010-06-15 23:38:23 -070025#define BOOT_FLAG_SKIP_ADDR_CHECK UINT64_C(0x04) /* Skip check of kernel
26 * buffer address */
Randall Spangler0ff6fea2010-05-27 18:36:02 -070027
Randall Spangler102bfba2010-05-24 15:14:33 -070028typedef struct LoadKernelParams {
29 /* Inputs to LoadKernel() */
Randall Spangler0ff6fea2010-05-27 18:36:02 -070030 void *header_sign_key_blob; /* Key blob used to sign the kernel header */
Randall Spangler102bfba2010-05-24 15:14:33 -070031 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 Spanglerd1836442010-06-10 09:59:04 -070037 uint64_t boot_flags; /* Boot flags */
Randall Spangler102bfba2010-05-24 15:14:33 -070038
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 Spangler19d13132010-06-03 09:43:43 -070043 uint64_t bootloader_address; /* Address of bootloader image in RAM */
Randall Spangler102bfba2010-05-24 15:14:33 -070044 uint64_t bootloader_size; /* Size of bootloader image in bytes */
45} LoadKernelParams;
46
Randall Spangler0ff6fea2010-05-27 18:36:02 -070047int LoadKernel(LoadKernelParams* params);
Randall Spangler102bfba2010-05-24 15:14:33 -070048/* Attempts to load the kernel from the current device.
49 *
50 * Returns LOAD_KERNEL_SUCCESS if successful, error code on failure. */
51
52
53typedef 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_ */