summaryrefslogtreecommitdiff
path: root/firmware/include/vboot_api.h
diff options
context:
space:
mode:
authorDan Ehrenberg <dehrenberg@chromium.org>2014-12-02 08:21:57 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-12-15 22:44:33 +0000
commit3f4d8d05ba4e32990c8584bd47cdf082d4604232 (patch)
treea9c9b82c4ad25192f3ecbe921795c0961d0cbbfa /firmware/include/vboot_api.h
parent3200401242aec1521e7c4a8b1906366fcabfb1a2 (diff)
downloadvboot-3f4d8d05ba4e32990c8584bd47cdf082d4604232.tar.gz
vboot: Plumb the two disk sizes and external GPT param through
This patch reinstates the external GPT support which was previously committed and reverted. Improvements since last time include: - Cleaned-up internal interface based on code review - Function correctly on legacy bootloaders (e.g., depthcharge before NAND-related patches are added) - Better comments - Treat new field values = 0 -> not use new feature - Tests are added to ensure external GPT flag is passed down properly The original commit had change-id I5a77e417aea8ee9442d18c200d1b073aa5375ecf Its commit message is reproduced below, and then an additional test. ---- To support an external GPT, disks have two new attributes: - A binary flag indicating whether the GPT is in the same address space as the payloads or a separate one. - The number of sectors of the streaming portion of storage, as opposed to the portion containing the GPT. These have been added elsewhere to GptData (in cgptlib) and BlockDev (in depthcharge). This patch adds the plumbing between those, including in the DiskInfo interface between the firmware and vboot. BUG=chromium:425677 BRANCH=none TEST=Interactively wrote the GPT with cgpt and observed the following boot with depthcharge to read the GPT from SPI and then read from the proper locations in NAND flash. TEST=make runalltests passes. TEST=boots from USB with depthcharge from HEAD. Change-Id: Ia7956517a7b9da0301f01fac5a10204f6d78cf4f Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/234640 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'firmware/include/vboot_api.h')
-rw-r--r--firmware/include/vboot_api.h46
1 files changed, 37 insertions, 9 deletions
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
index 81240585..f93df517 100644
--- a/firmware/include/vboot_api.h
+++ b/firmware/include/vboot_api.h
@@ -555,14 +555,38 @@ VbError_t VbExHashFirmwareBody(VbCommonParams *cparams,
* 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 0x00000004
+
/* Information on a single disk */
typedef struct VbDiskInfo {
/* Disk handle */
VbExDiskHandle_t handle;
- /* Size of a LBA sector in bytes */
+ /* Size of a random-access LBA sector in bytes */
uint64_t bytes_per_lba;
- /* Number of LBA sectors on the device */
+ /* 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;
/*
@@ -604,6 +628,9 @@ VbError_t VbExDiskFreeInfo(VbDiskInfo *infos,
* Read lba_count LBA sectors, starting at sector lba_start, from the disk,
* into the buffer.
*
+ * This is used for random access to the GPT. It is not for the partition
+ * contents. The upper limit is lba_count.
+ *
* If the disk handle is invalid (for example, the handle refers to a disk
* which as been removed), the function must return error but must not
* crash.
@@ -615,6 +642,9 @@ VbError_t VbExDiskRead(VbExDiskHandle_t handle, uint64_t lba_start,
* Write lba_count LBA sectors, starting at sector lba_start, to the disk, from
* the buffer.
*
+ * This is used for random access to the GPT. It does not (necessarily) access
+ * the streaming portion of the device.
+ *
* If the disk handle is invalid (for example, the handle refers to a disk
* which as been removed), the function must return error but must not
* crash.
@@ -635,10 +665,9 @@ typedef void *VbExStream_t;
*
* @return Error code, or VBERROR_SUCCESS.
*
- * lba_start and lba_count are subject to disk type-dependent alignment
- * restrictions. An invalid value will lead to an error code. In particular,
- * on raw NAND devices, lba_start and lba_count must be page-aligned after
- * subtracting the offset of the GPT.
+ * This is used for access to the contents of the actual partitions on the
+ * device. It is not used to access the GPT. The size of the content addressed
+ * is within streaming_lba_count.
*/
VbError_t VbExStreamOpen(VbExDiskHandle_t handle, uint64_t lba_start,
uint64_t lba_count, VbExStream_t *stream_ptr);
@@ -653,9 +682,8 @@ VbError_t VbExStreamOpen(VbExDiskHandle_t handle, uint64_t lba_start,
* @return Error code, or VBERROR_SUCCESS. Failure to read as much data as
* requested is an error.
*
- * bytes is subject to disk type-dependent alignment restrictions. An invalid
- * value will lead to an error code. In particular, on raw NAND devices, bytes
- * must be a page multiple.
+ * This is used for access to the contents of the actual partitions on the
+ * device. It is not used to access the GPT.
*/
VbError_t VbExStreamRead(VbExStream_t stream, uint32_t bytes, void *buffer);