summaryrefslogtreecommitdiff
path: root/firmware/include/vboot_api.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/include/vboot_api.h')
-rw-r--r--firmware/include/vboot_api.h164
1 files changed, 9 insertions, 155 deletions
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
index 4dba0a06..4059accb 100644
--- a/firmware/include/vboot_api.h
+++ b/firmware/include/vboot_api.h
@@ -24,6 +24,7 @@
#include <stdint.h>
#include <stdlib.h>
+#include "../2lib/include/2constants.h"
#include "../2lib/include/2return_codes.h"
#include "gpt.h"
@@ -32,165 +33,18 @@ extern "C" {
#endif /* __cplusplus */
struct vb2_context;
+struct vb2_disk_info;
typedef struct VbSharedDataHeader VbSharedDataHeader;
-
-/*****************************************************************************/
-/* Main entry points from firmware into vboot_reference */
-
-/*
- * We use disk handles rather than indices. Using indices causes problems if
- * a disk is removed/inserted in the middle of processing.
- */
-typedef void *VbExDiskHandle_t;
-
-typedef struct VbSelectAndLoadKernelParams {
- /* Inputs to VbTryLoadKernel() */
- /* Destination buffer for kernel (normally at 0x100000 on x86) */
- void *kernel_buffer;
- /* Size of kernel buffer in bytes */
- uint32_t kernel_buffer_size;
-
- /*
- * Outputs from VbTryLoadKernel(); valid only if it returns success.
- */
- /* Handle of disk containing loaded kernel */
- VbExDiskHandle_t disk_handle;
- /* Partition number on disk to boot (1...M) */
- uint32_t partition_number;
- /* Address of bootloader image in RAM */
- uint64_t bootloader_address;
- /* Size of bootloader image in bytes */
- uint32_t bootloader_size;
- /* UniquePartitionGuid for boot partition */
- uint8_t partition_guid[16];
- /* Flags set by signer */
- uint32_t flags;
-} VbSelectAndLoadKernelParams;
-
-/**
- * Attempt loading a kernel from the specified type(s) of disks.
- *
- * If successful, sets kparams.disk_handle to the disk for the kernel and
- * returns VB2_SUCCESS.
- *
- * @param ctx Vboot context
- * @param disk_flags Flags to pass to VbExDiskGetInfo()
- * @param kparams Params specific to loading the kernel
- * @return VB2_SUCCESS or the most specific VB2_ERROR_LK error.
- */
-vb2_error_t VbTryLoadKernel(struct vb2_context *ctx, uint32_t disk_flags,
- VbSelectAndLoadKernelParams *kparams);
-
-/* miniOS flags */
-
-/* Boot from non-active miniOS partition only */
-#define VB_MINIOS_FLAG_NON_ACTIVE (1 << 0)
-
-/**
- * Attempt loading a miniOS kernel from internal disk.
- *
- * Scans sectors at the start and end of the disk, and looks for miniOS kernels
- * starting at the beginning of the sector. Attempts loading any miniOS
- * kernels found.
- *
- * If successful, sets lkp.disk_handle to the disk for the kernel and returns
- * VB2_SUCCESS.
- *
- * @param ctx Vboot context
- * @param minios_flags Flags for miniOS
- * @param kparams Params specific to loading the kernel
- * @return VB2_SUCCESS or the most specific VB2_ERROR_LK error.
- */
-vb2_error_t VbTryLoadMiniOsKernel(struct vb2_context *ctx,
- uint32_t minios_flags,
- VbSelectAndLoadKernelParams *kparams);
-
/*****************************************************************************/
/* Disk access (previously in boot_device.h) */
-/* Flags for VbDisk APIs */
-
-/*
- * Disk selection in the lower 16 bits (where the disk lives), and disk
- * attributes in the higher 16 bits (extra information about the disk
- * needed to access it correctly).
- */
-#define VB_DISK_FLAG_SELECT_MASK 0xffff
-#define VB_DISK_FLAG_ATTRIBUTE_MASK (0xffff << 16)
-
-/* Disk is removable. Example removable disks: SD cards, USB keys. */
-#define VB_DISK_FLAG_REMOVABLE (1 << 0)
-/*
- * Disk is fixed. If this flag is present, disk is internal to the system and
- * not removable. Example fixed disks: internal SATA SSD, eMMC.
- */
-#define VB_DISK_FLAG_FIXED (1 << 1)
-/*
- * Note that VB_DISK_FLAG_REMOVABLE and VB_DISK_FLAG_FIXED are
- * mutually-exclusive for a single disk. VbExDiskGetInfo() may specify both
- * flags to request disks of both types in a single call.
- *
- * At some point we could specify additional flags, but we don't currently
- * have a way to make use of these:
- *
- * USB Device is known to be attached to USB. Note that the SD
- * card reader inside x86 systems is attached to USB so this
- * isn't super useful.
- * SD Device is known to be a SD card. Note that external card
- * readers might not return this information, so also of
- * questionable use.
- * READ_ONLY Device is known to be read-only. Could be used by recovery
- * when processing read-only recovery image.
- */
-
-/*
- * Disks are used in two ways:
- * - As a random-access device to read and write the GPT
- * - As a streaming device to read the kernel
- * These are implemented differently on raw NAND vs eMMC/SATA/USB
- * - On eMMC/SATA/USB, both of these refer to the same underlying
- * storage, so they have the same size and LBA size. In this case,
- * the GPT should not point to the same address as itself.
- * - On raw NAND, the GPT is held on a portion of the SPI flash.
- * Random access GPT operations refer to the SPI and streaming
- * operations refer to NAND. The GPT may therefore point into
- * the same offsets as itself.
- * These types are distinguished by the following flag and VbDiskInfo
- * has separate fields to describe the random-access ("GPT") and
- * streaming aspects of the disk. If a disk is random-access (i.e.
- * not raw NAND) then these fields are equal.
- */
-#define VB_DISK_FLAG_EXTERNAL_GPT (1 << 16)
-
-/* Information on a single disk */
-typedef struct VbDiskInfo {
- /* Disk handle */
- VbExDiskHandle_t handle;
- /* Size of a random-access LBA sector in bytes */
- uint64_t bytes_per_lba;
- /* Number of random-access LBA sectors on the device.
- * If streaming_lba_count is 0, this stands in for the size of the
- * randomly accessed portion as well as the streaming portion.
- * Otherwise, this is only the randomly-accessed portion. */
- uint64_t lba_count;
- /* Number of streaming sectors on the device */
- uint64_t streaming_lba_count;
- /* Flags (see VB_DISK_FLAG_* constants) */
- uint32_t flags;
- /*
- * Optional name string, for use in debugging. May be empty or null if
- * not available.
- */
- const char *name;
-} VbDiskInfo;
-
/**
* Store information into [info] for all disks (storage devices) attached to
* the system which match all of the disk_flags.
*
* On output, count indicates how many disks are present, and [infos_ptr]
- * points to a [count]-sized array of VbDiskInfo structs with the information
+ * points to a [count]-sized array of vb2_disk_info structs with the information
* on those disks; this pointer must be freed by calling VbExDiskFreeInfo().
* If count=0, infos_ptr may point to NULL. If [infos_ptr] points to NULL
* because count=0 or error, it is not necessary to call VbExDiskFreeInfo().
@@ -201,7 +55,7 @@ typedef struct VbDiskInfo {
* The firmware must not alter or free the list pointed to by [infos_ptr] until
* VbExDiskFreeInfo() is called.
*/
-vb2_error_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count,
+vb2_error_t VbExDiskGetInfo(struct vb2_disk_info **infos_ptr, uint32_t *count,
uint32_t disk_flags);
/**
@@ -210,8 +64,8 @@ vb2_error_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count,
* that handle remains valid after this call; all other handles from the info
* list need not remain valid after this call.
*/
-vb2_error_t VbExDiskFreeInfo(VbDiskInfo *infos,
- VbExDiskHandle_t preserve_handle);
+vb2_error_t VbExDiskFreeInfo(struct vb2_disk_info *infos,
+ vb2ex_disk_handle_t preserve_handle);
/**
* Read lba_count LBA sectors, starting at sector lba_start, from the disk,
@@ -224,7 +78,7 @@ vb2_error_t VbExDiskFreeInfo(VbDiskInfo *infos,
* which as been removed), the function must return error but must not
* crash.
*/
-vb2_error_t VbExDiskRead(VbExDiskHandle_t handle, uint64_t lba_start,
+vb2_error_t VbExDiskRead(vb2ex_disk_handle_t handle, uint64_t lba_start,
uint64_t lba_count, void *buffer);
/**
@@ -238,7 +92,7 @@ vb2_error_t VbExDiskRead(VbExDiskHandle_t handle, uint64_t lba_start,
* which as been removed), the function must return error but must not
* crash.
*/
-vb2_error_t VbExDiskWrite(VbExDiskHandle_t handle, uint64_t lba_start,
+vb2_error_t VbExDiskWrite(vb2ex_disk_handle_t handle, uint64_t lba_start,
uint64_t lba_count, const void *buffer);
/* Streaming read interface */
@@ -258,7 +112,7 @@ typedef void *VbExStream_t;
* device. It is not used to access the GPT. The size of the content addressed
* is within streaming_lba_count.
*/
-vb2_error_t VbExStreamOpen(VbExDiskHandle_t handle, uint64_t lba_start,
+vb2_error_t VbExStreamOpen(vb2ex_disk_handle_t handle, uint64_t lba_start,
uint64_t lba_count, VbExStream_t *stream_ptr);
/**