Home | History | Annotate | Download | only in include
      1 /* Copyright (c) 2013 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 
     12 #include "vboot_api.h"
     13 #include "vboot_nvstorage.h"
     14 
     15 /* Interface provided by verified boot library to BDS */
     16 
     17 /* Boot flags for LoadKernel().boot_flags */
     18 /* Developer switch is on */
     19 #define BOOT_FLAG_DEVELOPER    (0x01ULL)
     20 /* In recovery mode */
     21 #define BOOT_FLAG_RECOVERY     (0x02ULL)
     22 /* GPT is external */
     23 #define BOOT_FLAG_EXTERNAL_GPT (0x04ULL)
     24 
     25 typedef struct LoadKernelParams {
     26 	/* Inputs to LoadKernel() */
     27 	/*
     28 	 * Buffer for data shared between LoadFirmware() and LoadKernel().
     29 	 * Pass the same buffer which was passed to LoadFirmware().
     30 	 */
     31 	void *shared_data_blob;
     32 	/*
     33 	 * Size of shared data blob buffer, in bytes.  On output, this will
     34 	 * contain the actual data size placed into the buffer.
     35 	 */
     36 	uint64_t shared_data_size;
     37 	/* Pointer to GBB data */
     38 	void *gbb_data;
     39 	/* Size of GBB data in bytes */
     40 	uint64_t gbb_size;
     41 	/* Disk handle for current device */
     42 	VbExDiskHandle_t disk_handle;
     43 	/* Bytes per lba sector on current device */
     44 	uint64_t bytes_per_lba;
     45 	/* Number of LBA-addressable sectors on the main device */
     46 	uint64_t streaming_lba_count;
     47 	/* Random-access GPT size */
     48 	uint64_t gpt_lba_count;
     49 	/* Destination buffer for kernel (normally at 0x100000) */
     50 	void *kernel_buffer;
     51 	/* Size of kernel buffer in bytes */
     52 	uint64_t kernel_buffer_size;
     53 	/* Boot flags */
     54 	uint64_t boot_flags;
     55 	/*
     56 	 * Context for NV storage.  Caller is responsible for calling
     57 	 * VbNvSetup() and VbNvTeardown() on the context.
     58 	 */
     59 	VbNvContext *nv_context;
     60 
     61 	/*
     62 	 * Outputs from LoadKernel(); valid only if LoadKernel() returns
     63 	 * LOAD_KERNEL_SUCCESS
     64 	 */
     65 	/* Partition number to boot on current device (1...M) */
     66 	uint64_t partition_number;
     67 	/* Address of bootloader image in RAM */
     68 	uint64_t bootloader_address;
     69 	/* Size of bootloader image in bytes */
     70 	uint64_t bootloader_size;
     71 	/* UniquePartitionGuid for boot partition */
     72 	uint8_t  partition_guid[16];
     73 	/* Flags passed in by signer */
     74 	uint32_t flags;
     75 } LoadKernelParams;
     76 
     77 /**
     78  * Attempt to load the kernel from the current device.
     79  *
     80  * Returns VBERROR_SUCCESS if successful.  If unsuccessful, sets a recovery
     81  * reason via VbNvStorage and returns an error code.
     82  */
     83 VbError_t LoadKernel(LoadKernelParams *params, VbCommonParams *cparams);
     84 
     85 /*
     86  * The bootloader is loaded using the EFI LoadImage() and StartImage() calls.
     87  * Pass this struct via loaded_image->load_options.
     88  */
     89 typedef struct KernelBootloaderOptions {
     90 	/* Drive number of boot device (0...N) */
     91 	uint64_t drive_number;
     92 	/*
     93 	 * Partition number, as returned from LoadKernel() in
     94 	 * LoadKernelParams.partition_number
     95 	 */
     96 	uint64_t partition_number;
     97 	/*
     98 	 * Absolute bootloader start adddress, as returned from LoadKernel() in
     99 	 * LoadKernelParams.bootloader_start
    100 	 */
    101 	uint64_t original_address;
    102 	  /* UniquePartitionGuid for boot partition */
    103 	uint8_t partition_guid[16];
    104 } KernelBootloaderOptions;
    105 
    106 #endif  /* VBOOT_REFERENCE_LOAD_KERNEL_FW_H_ */
    107