diff options
author | Joel Kitching <kitching@google.com> | 2019-07-31 13:17:08 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-08-06 15:14:47 +0000 |
commit | 90671fa6d2d3d48fab6408c7493be61bcee5868e (patch) | |
tree | 73a740440899a86d87fcec45717fba23ea9c2838 /firmware/include | |
parent | 9c906110972f538ee5753845916ebd1f826f54b6 (diff) | |
download | vboot-90671fa6d2d3d48fab6408c7493be61bcee5868e.tar.gz |
vboot: rename VbError_t typedef to vb2_error_t
As part of the conversion of error codes from vboot1 to vboot2,
replace all instances of VbError_t with vb2_error_t.
vboot2 currently uses the int type for return values, but we
would like to implement the use of vb2_error_t instead, which is
potentially clearer than simply using an int. Existing functions
will be converted to use vb2_error_t in a subsequent CL.
BUG=b:124141368, chromium:988410
TEST=make clean && make runtests
BRANCH=none
Change-Id: Iee90d9a1f46bcf5f088e981ba6ddbcf886ff0f18
Signed-off-by: Joel Kitching <kitching@google.com>
Cq-Depend: chromium:1728112
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1722914
Reviewed-by: Julius Werner <jwerner@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Diffstat (limited to 'firmware/include')
-rw-r--r-- | firmware/include/vboot_api.h | 109 |
1 files changed, 50 insertions, 59 deletions
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h index 86c00215..0621750b 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/2return_codes.h" #include "gpt.h" #ifdef __cplusplus @@ -33,16 +34,6 @@ extern "C" { struct vb2_context; typedef struct VbSharedDataHeader VbSharedDataHeader; -/*****************************************************************************/ -/* Error codes */ - -/* - * Functions which return an error all return this type. This is a 32-bit - * value rather than an int so it's consistent across UEFI, which is 32-bit - * during PEI and 64-bit during DXE/BDS. - */ -typedef uint32_t VbError_t; - /* * Define test_mockable for mocking functions. */ @@ -163,9 +154,9 @@ typedef struct VbSelectAndLoadKernelParams { * * Returns VBERROR_SUCCESS if success, non-zero if error; on error, caller * should reboot. */ -VbError_t VbSelectAndLoadKernel(struct vb2_context *ctx, - VbSharedDataHeader *shared, - VbSelectAndLoadKernelParams *kparams); +vb2_error_t VbSelectAndLoadKernel(struct vb2_context *ctx, + VbSharedDataHeader *shared, + VbSelectAndLoadKernelParams *kparams); /** * Verify Kernel Image loaded in memory. @@ -183,11 +174,10 @@ VbError_t VbSelectAndLoadKernel(struct vb2_context *ctx, * @param image_size Size of the image in memory * @return VBERROR_... error, VBERROR_SUCCESS on success. */ -VbError_t VbVerifyMemoryBootImage(struct vb2_context *ctx, - VbSharedDataHeader *shared, - VbSelectAndLoadKernelParams *kparams, - void *boot_image, - size_t image_size); +vb2_error_t VbVerifyMemoryBootImage(struct vb2_context *ctx, + VbSharedDataHeader *shared, + VbSelectAndLoadKernelParams *kparams, + void *boot_image, size_t image_size); /** * Fastboot API to enter dev mode. @@ -202,7 +192,7 @@ VbError_t VbVerifyMemoryBootImage(struct vb2_context *ctx, * * @return VBERROR_... error, VBERROR_SUCCESS on success. */ -VbError_t VbUnlockDevice(void); +vb2_error_t VbUnlockDevice(void); /*****************************************************************************/ /* Timer and delay (first two from utility.h) */ @@ -245,22 +235,22 @@ void VbExSleepMs(uint32_t msec); * support is not available. At a minimum, it must delay for the specified * non-zero duration. */ -VbError_t VbExBeep(uint32_t msec, uint32_t frequency); +vb2_error_t VbExBeep(uint32_t msec, uint32_t frequency); /*****************************************************************************/ /* TPM (from tlcl_stub.h) */ /** * Initialize the stub library. */ -VbError_t VbExTpmInit(void); +vb2_error_t VbExTpmInit(void); /** * Close and open the device. This is needed for running more complex commands * at user level, such as TPM_TakeOwnership, since the TPM device can be opened * only by one process at a time. */ -VbError_t VbExTpmClose(void); -VbError_t VbExTpmOpen(void); +vb2_error_t VbExTpmClose(void); +vb2_error_t VbExTpmOpen(void); /** * Send request to TPM and receive response @@ -291,7 +281,7 @@ uint32_t VbExTpmSendReceive(const uint8_t *request, uint32_t request_length, * attacker with communication interception abilities could launch replay * attacks by reusing previous nonces. */ -VbError_t VbExTpmGetRandom(uint8_t *buf, uint32_t length); +vb2_error_t VbExTpmGetRandom(uint8_t *buf, uint32_t length); #endif /* CHROMEOS_ENVIRONMENT */ @@ -303,12 +293,12 @@ VbError_t VbExTpmGetRandom(uint8_t *buf, uint32_t length); /** * Read the VBNV_BLOCK_SIZE-byte non-volatile storage into buf. */ -VbError_t VbExNvStorageRead(uint8_t *buf); +vb2_error_t VbExNvStorageRead(uint8_t *buf); /** * Write the VBNV_BLOCK_SIZE-byte non-volatile storage from buf. */ -VbError_t VbExNvStorageWrite(const uint8_t *buf); +vb2_error_t VbExNvStorageWrite(const uint8_t *buf); /*****************************************************************************/ /* Disk access (previously in boot_device.h) */ @@ -396,8 +386,8 @@ typedef struct VbDiskInfo { * The firmware must not alter or free the list pointed to by [infos_ptr] until * VbExDiskFreeInfo() is called. */ -VbError_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count, - uint32_t disk_flags); +vb2_error_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count, + uint32_t disk_flags); /** * Free a disk information list [infos] previously returned by @@ -405,8 +395,8 @@ VbError_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. */ -VbError_t VbExDiskFreeInfo(VbDiskInfo *infos, - VbExDiskHandle_t preserve_handle); +vb2_error_t VbExDiskFreeInfo(VbDiskInfo *infos, + VbExDiskHandle_t preserve_handle); /** * Read lba_count LBA sectors, starting at sector lba_start, from the disk, @@ -419,8 +409,8 @@ VbError_t VbExDiskFreeInfo(VbDiskInfo *infos, * which as been removed), the function must return error but must not * crash. */ -VbError_t VbExDiskRead(VbExDiskHandle_t handle, uint64_t lba_start, - uint64_t lba_count, void *buffer); +vb2_error_t VbExDiskRead(VbExDiskHandle_t handle, uint64_t lba_start, + uint64_t lba_count, void *buffer); /** * Write lba_count LBA sectors, starting at sector lba_start, to the disk, from @@ -433,8 +423,8 @@ VbError_t VbExDiskRead(VbExDiskHandle_t handle, uint64_t lba_start, * which as been removed), the function must return error but must not * crash. */ -VbError_t VbExDiskWrite(VbExDiskHandle_t handle, uint64_t lba_start, - uint64_t lba_count, const void *buffer); +vb2_error_t VbExDiskWrite(VbExDiskHandle_t handle, uint64_t lba_start, + uint64_t lba_count, const void *buffer); /* Streaming read interface */ typedef void *VbExStream_t; @@ -453,8 +443,8 @@ typedef void *VbExStream_t; * 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); +vb2_error_t VbExStreamOpen(VbExDiskHandle_t handle, uint64_t lba_start, + uint64_t lba_count, VbExStream_t *stream_ptr); /** * Read from a stream on a disk @@ -469,7 +459,7 @@ VbError_t VbExStreamOpen(VbExDiskHandle_t handle, uint64_t lba_start, * 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); +vb2_error_t VbExStreamRead(VbExStream_t stream, uint32_t bytes, void *buffer); /** * Close a stream @@ -558,7 +548,7 @@ typedef struct VbScreenData * to be simple ASCII text such as "NO GOOD" or "INSERT"; these screens should * only be seen during development. */ -VbError_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale, +vb2_error_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale, const VbScreenData *data); /** @@ -573,7 +563,7 @@ VbError_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale, * * @return VBERROR_SUCCESS or error code on error. */ -VbError_t VbExDisplayMenu(uint32_t screen_type, uint32_t locale, +vb2_error_t VbExDisplayMenu(uint32_t screen_type, uint32_t locale, uint32_t selected_index, uint32_t disabled_idx_mask, uint32_t redraw_base); @@ -590,7 +580,7 @@ VbError_t VbExDisplayMenu(uint32_t screen_type, uint32_t locale, * * @return VBERROR_SUCCESS or error code on error. */ -VbError_t VbExDisplayDebugInfo(const char *info_str, int full_info); +vb2_error_t VbExDisplayDebugInfo(const char *info_str, int full_info); /** * Write vendor data to read-only VPD @@ -601,7 +591,7 @@ VbError_t VbExDisplayDebugInfo(const char *info_str, int full_info); * * @return VBERROR_SUCCESS or error code on error. */ -VbError_t VbExSetVendorData(const char *vendor_data_value); +vb2_error_t VbExSetVendorData(const char *vendor_data_value); /*****************************************************************************/ /* Keyboard and switches */ @@ -707,20 +697,20 @@ int VbExTrustEC(int devidx); * If the EC is in RO code, sets *in_rw=0. * If the EC is in RW code, sets *in_rw non-zero. * If the current EC image is unknown, returns error. */ -VbError_t VbExEcRunningRW(int devidx, int *in_rw); +vb2_error_t VbExEcRunningRW(int devidx, int *in_rw); /** * Request the EC jump to its rewritable code. If successful, returns when the * EC has booting its RW code far enough to respond to subsequent commands. * Does nothing if the EC is already in its rewritable code. */ -VbError_t VbExEcJumpToRW(int devidx); +vb2_error_t VbExEcJumpToRW(int devidx); /** * Tell the EC to refuse another jump until it reboots. Subsequent calls to * VbExEcJumpToRW() in this boot will fail. */ -VbError_t VbExEcDisableJump(int devidx); +vb2_error_t VbExEcDisableJump(int devidx); /** * Read the SHA-256 hash of the selected EC image. @@ -731,42 +721,43 @@ VbError_t VbExEcDisableJump(int devidx); * @param hash_size Pointer to the hash size. * @return VBERROR_... error, VBERROR_SUCCESS on success. */ -VbError_t VbExEcHashImage(int devidx, enum VbSelectFirmware_t select, - const uint8_t **hash, int *hash_size); +vb2_error_t VbExEcHashImage(int devidx, enum VbSelectFirmware_t select, + const uint8_t **hash, int *hash_size); /** * Get the expected contents of the EC image associated with the main firmware * specified by the "select" argument. */ -VbError_t VbExEcGetExpectedImage(int devidx, enum VbSelectFirmware_t select, - const uint8_t **image, int *image_size); +vb2_error_t VbExEcGetExpectedImage(int devidx, enum VbSelectFirmware_t select, + const uint8_t **image, int *image_size); /** * Read the SHA-256 hash of the expected contents of the EC image associated * with the main firmware specified by the "select" argument. */ -VbError_t VbExEcGetExpectedImageHash(int devidx, enum VbSelectFirmware_t select, - const uint8_t **hash, int *hash_size); +vb2_error_t VbExEcGetExpectedImageHash(int devidx, + enum VbSelectFirmware_t select, + const uint8_t **hash, int *hash_size); /** * Update the selected EC image. */ -VbError_t VbExEcUpdateImage(int devidx, enum VbSelectFirmware_t select, - const uint8_t *image, int image_size); +vb2_error_t VbExEcUpdateImage(int devidx, enum VbSelectFirmware_t select, + const uint8_t *image, int image_size); /** * Lock the selected EC code to prevent updates until the EC is rebooted. * Subsequent calls to VbExEcUpdateImage() with the same region this boot will * fail. */ -VbError_t VbExEcProtect(int devidx, enum VbSelectFirmware_t select); +vb2_error_t VbExEcProtect(int devidx, enum VbSelectFirmware_t select); /** * Info the EC of the boot mode selected by the AP. * mode: Normal, Developer, or Recovery */ enum VbEcBootMode_t {VB_EC_NORMAL, VB_EC_DEVELOPER, VB_EC_RECOVERY }; -VbError_t VbExEcEnteringMode(int devidx, enum VbEcBootMode_t mode); +vb2_error_t VbExEcEnteringMode(int devidx, enum VbEcBootMode_t mode); /** * Perform EC post-verification / updating / jumping actions. @@ -779,12 +770,12 @@ VbError_t VbExEcEnteringMode(int devidx, enum VbEcBootMode_t mode); * @param in_recovery 1 if recovery mode is selected by the AP, 0 otherwise. * @return VBERROR_... error, VBERROR_SUCCESS on success. */ -VbError_t VbExEcVbootDone(int in_recovery); +vb2_error_t VbExEcVbootDone(int in_recovery); /** * Request EC to stop discharging and cut-off battery. */ -VbError_t VbExEcBatteryCutOff(void); +vb2_error_t VbExEcBatteryCutOff(void); /* * severity levels for an auxiliary firmware update request @@ -813,7 +804,7 @@ typedef enum { * @return VBERROR_... error, VBERROR_SUCCESS on success. */ -VbError_t VbExCheckAuxFw(VbAuxFwUpdateSeverity_t *severity); +vb2_error_t VbExCheckAuxFw(VbAuxFwUpdateSeverity_t *severity); /** * Perform auxiliary firmware update(s). @@ -824,7 +815,7 @@ VbError_t VbExCheckAuxFw(VbAuxFwUpdateSeverity_t *severity); * @return VBERROR_... error, VBERROR_SUCCESS on success. */ -VbError_t VbExUpdateAuxFw(void); +vb2_error_t VbExUpdateAuxFw(void); /*****************************************************************************/ /* Misc */ @@ -914,7 +905,7 @@ uint8_t VbExOverrideGptEntryPriority(const GptEntry *e); * @param count Pointer to the number of locales. * @return VBERROR_... error, VBERROR_SUCCESS on success. */ -VbError_t VbExGetLocalizationCount(uint32_t *count); +vb2_error_t VbExGetLocalizationCount(uint32_t *count); enum vb_altfw { VB_ALTFW_COUNT = 9, /* We allow 9 bootloaders, numbered 1-9 */ |