Message ID | 1355814090-20545-1-git-send-email-ivan.hu@canonical.com |
---|---|
State | Rejected |
Headers | show |
NACK, send another one for table alignment. On 12/18/2012 03:01 PM, Ivan Hu wrote: > Add the helper function which compare the return status value, then > print out the status and description. When errors occur for UEFI > runtime service interface, print out the useful reports to user. > > Signed-off-by: Ivan Hu <ivan.hu@canonical.com> > --- > src/lib/include/fwts_uefi.h | 37 ++++++++++++++++++++ > src/lib/src/fwts_uefi.c | 56 ++++++++++++++++++++++++++++++ > src/uefi/uefirtvariable/uefirtvariable.c | 15 +++++--- > 3 files changed, 103 insertions(+), 5 deletions(-) > > diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h > index 73cd773..72d3c10 100644 > --- a/src/lib/include/fwts_uefi.h > +++ b/src/lib/include/fwts_uefi.h > @@ -46,6 +46,41 @@ enum { > FWTS_UEFI_TIME_IN_DAYLIGHT = 0x02 > }; > > +#define HIGH_BIT_SET (1UL << 63) > + > +#define EFI_SUCCESS 0 > +#define EFI_LOAD_ERROR (1 | HIGH_BIT_SET) > +#define EFI_INVALID_PARAMETER (2 | HIGH_BIT_SET) > +#define EFI_UNSUPPORTED (3 | HIGH_BIT_SET) > +#define EFI_BAD_BUFFER_SIZE (4 | HIGH_BIT_SET) > +#define EFI_BUFFER_TOO_SMALL (5 | HIGH_BIT_SET) > +#define EFI_NOT_READY (6 | HIGH_BIT_SET) > +#define EFI_DEVICE_ERROR (7 | HIGH_BIT_SET) > +#define EFI_WRITE_PROTECTED (8 | HIGH_BIT_SET) > +#define EFI_OUT_OF_RESOURCES (9 | HIGH_BIT_SET) > +#define EFI_VOLUME_CORRUPTED (10 | HIGH_BIT_SET) > +#define EFI_VOLUME_FULL (11 | HIGH_BIT_SET) > +#define EFI_NO_MEDIA (12 | HIGH_BIT_SET) > +#define EFI_MEDIA_CHANGED (13 | HIGH_BIT_SET) > +#define EFI_NOT_FOUND (14 | HIGH_BIT_SET) > +#define EFI_ACCESS_DENIED (15 | HIGH_BIT_SET) > +#define EFI_NO_RESPONSE (16 | HIGH_BIT_SET) > +#define EFI_NO_MAPPING (17 | HIGH_BIT_SET) > +#define EFI_TIMEOUT (18 | HIGH_BIT_SET) > +#define EFI_NOT_STARTED (19 | HIGH_BIT_SET) > +#define EFI_ALREADY_STARTED (20 | HIGH_BIT_SET) > +#define EFI_ABORTED (21 | HIGH_BIT_SET) > +#define EFI_ICMP_ERROR (22 | HIGH_BIT_SET) > +#define EFI_TFTP_ERROR (23 | HIGH_BIT_SET) > +#define EFI_PROTOCOL_ERROR (24 | HIGH_BIT_SET) > +#define EFI_INCOMPATIBLE_VERSION (25 | HIGH_BIT_SET) > +#define EFI_SECURITY_VIOLATION (26 | HIGH_BIT_SET) > +#define EFI_CRC_ERROR (27 | HIGH_BIT_SET) > +#define EFI_END_OF_MEDIA (28 | HIGH_BIT_SET) > +#define EFI_END_OF_FILE (31 | HIGH_BIT_SET) > +#define EFI_INVALID_LANGUAGE (32 | HIGH_BIT_SET) > +#define EFI_COMPROMISED_DATA (33 | HIGH_BIT_SET) > + > #define FWTS_UEFI_UNSPECIFIED_TIMEZONE 0x07FF > > #if 0 > @@ -313,4 +348,6 @@ void fwts_uefi_free_variable(fwts_uefi_var *var); > void fwts_uefi_free_variable_names(fwts_list *list); > int fwts_uefi_get_variable_names(fwts_list *list); > > +void fwts_uefi_print_status_info(fwts_framework *fw, const uint64_t status); > + > #endif > diff --git a/src/lib/src/fwts_uefi.c b/src/lib/src/fwts_uefi.c > index 43bc850..8e59000 100644 > --- a/src/lib/src/fwts_uefi.c > +++ b/src/lib/src/fwts_uefi.c > @@ -45,6 +45,12 @@ typedef struct { > uint8_t data[0]; /* variable length, depends on file size */ > } __attribute__((packed)) fwts_uefi_efivars_fs_var; > > +typedef struct { > + const uint64_t statusvalue; > + const char *mnemonic ; > + const char *description; > +} uefistatus_info; > + > /* Which interface are we using? */ > #define UEFI_IFACE_UNKNOWN (0) /* Not yet known */ > #define UEFI_IFACE_NONE (1) /* None found */ > @@ -413,3 +419,53 @@ int fwts_uefi_get_variable_names(fwts_list *list) > return ret; > } > > +static uefistatus_info uefistatus_info_table[] = { > + { EFI_SUCCESS, "EFI_SUCCESS", "The operation completed successfully." }, > + { EFI_LOAD_ERROR , "EFI_LOAD_ERROR", "The image failed to load." }, > + { EFI_INVALID_PARAMETER , "EFI_INVALID_PARAMETER", "A parameter was incorrect." }, > + { EFI_UNSUPPORTED , "EFI_UNSUPPORTED", "The operation is not supported." }, > + { EFI_BAD_BUFFER_SIZE , "EFI_BAD_BUFFER_SIZE", "The buffer was not the proper size for the request." }, > + { EFI_BUFFER_TOO_SMALL , "EFI_BUFFER_TOO_SMALL", "The buffer is not large enough to hold the requested data. The required buffer size is returned in the appropriate parameter when this error occurs." }, > + { EFI_NOT_READY , "EFI_NOT_READY", "There is no data pending upon return." }, > + { EFI_DEVICE_ERROR , "EFI_DEVICE_ERROR", "The physical device reported an error while attempting the operation." }, > + { EFI_WRITE_PROTECTED , "EFI_WRITE_PROTECTED", "The device cannot be written to." }, > + { EFI_OUT_OF_RESOURCES , "EFI_OUT_OF_RESOURCES", "A resource has run out." }, > + { EFI_VOLUME_CORRUPTED , "EFI_VOLUME_CORRUPTED", "An inconstancy was detected on the file system causing the operating to fail." }, > + { EFI_VOLUME_FULL , "EFI_VOLUME_FULL", "There is no more space on the file system." }, > + { EFI_NO_MEDIA , "EFI_NO_MEDIA", "The device does not contain any medium to perform the operation." }, > + { EFI_MEDIA_CHANGED , "EFI_MEDIA_CHANGED", "The medium in the device has changed since the last access." }, > + { EFI_NOT_FOUND , "EFI_NOT_FOUND", "The item was not found." }, > + { EFI_ACCESS_DENIED , "EFI_ACCESS_DENIED", "Access was denied." }, > + { EFI_NO_RESPONSE , "EFI_NO_RESPONSE", "The server was not found or did not respond to the request." }, > + { EFI_NO_MAPPING , "EFI_NO_MAPPING", "A mapping to a device does not exist." }, > + { EFI_TIMEOUT , "EFI_TIMEOUT", "The timeout time expired." }, > + { EFI_NOT_STARTED , "EFI_NOT_STARTED", "The protocol has not been started." }, > + { EFI_ALREADY_STARTED , "EFI_ALREADY_STARTED", "The protocol has already been started." }, > + { EFI_ABORTED , "EFI_ABORTED", "The operation was aborted." }, > + { EFI_ICMP_ERROR , "EFI_ICMP_ERROR", "An ICMP error occurred during the network operation." }, > + { EFI_TFTP_ERROR , "EFI_TFTP_ERROR", "A TFTP error occurred during the network operation." }, > + { EFI_PROTOCOL_ERROR , "EFI_PROTOCOL_ERROR", "A protocol error occurred during the network operation." }, > + { EFI_INCOMPATIBLE_VERSION , "EFI_INCOMPATIBLE_VERSION", "The function encountered an internal version that was incompatible with a version requested by the caller." }, > + { EFI_SECURITY_VIOLATION , "EFI_SECURITY_VIOLATION", "The function was not performed due to a security violation." }, > + { EFI_CRC_ERROR , "EFI_CRC_ERROR", "A CRC error was detected." }, > + { EFI_END_OF_MEDIA , "EFI_END_OF_MEDIA", "Beginning or end of media was reached." }, > + { EFI_END_OF_FILE , "EFI_END_OF_FILE", "The end of the file was reached." }, > + { EFI_INVALID_LANGUAGE , "EFI_INVALID_LANGUAGE", "The language specified was invalid." }, > + { EFI_COMPROMISED_DATA , "EFI_COMPROMISED_DATA", "The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status." }, > + { ~0, NULL, NULL } > +}; > + > +void fwts_uefi_print_status_info(fwts_framework *fw, const uint64_t status) > +{ > + > + uefistatus_info *info; > + > + for (info = uefistatus_info_table; info->mnemonic != NULL; info++) { > + if (status == info->statusvalue) { > + fwts_log_info(fw, "Return status: %s. %s", info->mnemonic, info->description); > + return; > + } > + } > + fwts_log_info(fw, "Cann't find the return status infomation, value = 0x%" PRIx64 ".", status); > + > +} > diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c > index d9e91d2..cb446fd 100644 > --- a/src/uefi/uefirtvariable/uefirtvariable.c > +++ b/src/uefi/uefirtvariable/uefirtvariable.c > @@ -40,9 +40,6 @@ > 0xDD, 0xB7, 0x11, 0xD0, 0x6E} \ > } > > -#define EFI_SUCCESS 0 > -#define EFI_NOT_FOUND (14 | (1UL << 63)) > - > #define MAX_DATA_LENGTH 1024 > > static int fd; > @@ -112,7 +109,7 @@ static int getvariable_test(fwts_framework *fw, uint64_t datasize, uint16_t *var > if (ioret == -1) { > fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable", > "Failed to set variable with UEFI runtime service."); > - > + fwts_uefi_print_status_info(fw, status); > return FWTS_ERROR; > } > > @@ -127,12 +124,14 @@ static int getvariable_test(fwts_framework *fw, uint64_t datasize, uint16_t *var > if (ioret == -1) { > fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetVariable", > "Failed to get variable with UEFI runtime service."); > + fwts_uefi_print_status_info(fw, status); > return FWTS_ERROR; > } > > if (*getvariable.status != EFI_SUCCESS) { > fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetVariableStatus", > "Failed to get variable, return status isn't EFI_SUCCESS."); > + fwts_uefi_print_status_info(fw, status); > return FWTS_ERROR; > } else if (*getvariable.Attributes != attributes) { > fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetVariableAttributes", > @@ -163,6 +162,7 @@ static int getvariable_test(fwts_framework *fw, uint64_t datasize, uint16_t *var > if (ioret == -1) { > fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable", > "Failed to set variable with UEFI runtime service."); > + fwts_uefi_print_status_info(fw, status); > return FWTS_ERROR; > } > > @@ -233,6 +233,7 @@ static int getnextvariable_test(fwts_framework *fw) > if (ioret == -1) { > fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable", > "Failed to set variable with UEFI runtime service."); > + fwts_uefi_print_status_info(fw, status); > return FWTS_ERROR; > } > > @@ -255,6 +256,7 @@ static int getnextvariable_test(fwts_framework *fw) > > fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetNextVariableName", > "Failed to get next variable name with UEFI runtime service."); > + fwts_uefi_print_status_info(fw, status); > return FWTS_ERROR; > } > if (compare_name(getnextvariablename.VariableName, variablenametest)) > @@ -284,6 +286,7 @@ static int getnextvariable_test(fwts_framework *fw) > if (ioret == -1) { > fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable", > "Failed to set variable with UEFI runtime service."); > + fwts_uefi_print_status_info(fw, status); > return FWTS_ERROR; > } > > @@ -316,7 +319,7 @@ static int setvariable_insertvariable(fwts_framework *fw, uint32_t attributes, u > if (ioret == -1) { > fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable", > "Failed to set variable with UEFI runtime service."); > - > + fwts_uefi_print_status_info(fw, status); > return FWTS_ERROR; > } > return FWTS_OK; > @@ -345,6 +348,7 @@ static int setvariable_checkvariable(fwts_framework *fw, uint64_t datasize, > if (ioret == -1) { > fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetVariable", > "Failed to get variable with UEFI runtime service."); > + fwts_uefi_print_status_info(fw, status); > return FWTS_ERROR; > } > > @@ -398,6 +402,7 @@ static int setvariable_checkvariable_notfound(fwts_framework *fw, uint16_t *varn > fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable", > "Failed to set variable with UEFI runtime service., " > "expect the status return EFI_NOT_FOUND."); > + fwts_uefi_print_status_info(fw, status); > return FWTS_ERROR; > } > >
diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h index 73cd773..72d3c10 100644 --- a/src/lib/include/fwts_uefi.h +++ b/src/lib/include/fwts_uefi.h @@ -46,6 +46,41 @@ enum { FWTS_UEFI_TIME_IN_DAYLIGHT = 0x02 }; +#define HIGH_BIT_SET (1UL << 63) + +#define EFI_SUCCESS 0 +#define EFI_LOAD_ERROR (1 | HIGH_BIT_SET) +#define EFI_INVALID_PARAMETER (2 | HIGH_BIT_SET) +#define EFI_UNSUPPORTED (3 | HIGH_BIT_SET) +#define EFI_BAD_BUFFER_SIZE (4 | HIGH_BIT_SET) +#define EFI_BUFFER_TOO_SMALL (5 | HIGH_BIT_SET) +#define EFI_NOT_READY (6 | HIGH_BIT_SET) +#define EFI_DEVICE_ERROR (7 | HIGH_BIT_SET) +#define EFI_WRITE_PROTECTED (8 | HIGH_BIT_SET) +#define EFI_OUT_OF_RESOURCES (9 | HIGH_BIT_SET) +#define EFI_VOLUME_CORRUPTED (10 | HIGH_BIT_SET) +#define EFI_VOLUME_FULL (11 | HIGH_BIT_SET) +#define EFI_NO_MEDIA (12 | HIGH_BIT_SET) +#define EFI_MEDIA_CHANGED (13 | HIGH_BIT_SET) +#define EFI_NOT_FOUND (14 | HIGH_BIT_SET) +#define EFI_ACCESS_DENIED (15 | HIGH_BIT_SET) +#define EFI_NO_RESPONSE (16 | HIGH_BIT_SET) +#define EFI_NO_MAPPING (17 | HIGH_BIT_SET) +#define EFI_TIMEOUT (18 | HIGH_BIT_SET) +#define EFI_NOT_STARTED (19 | HIGH_BIT_SET) +#define EFI_ALREADY_STARTED (20 | HIGH_BIT_SET) +#define EFI_ABORTED (21 | HIGH_BIT_SET) +#define EFI_ICMP_ERROR (22 | HIGH_BIT_SET) +#define EFI_TFTP_ERROR (23 | HIGH_BIT_SET) +#define EFI_PROTOCOL_ERROR (24 | HIGH_BIT_SET) +#define EFI_INCOMPATIBLE_VERSION (25 | HIGH_BIT_SET) +#define EFI_SECURITY_VIOLATION (26 | HIGH_BIT_SET) +#define EFI_CRC_ERROR (27 | HIGH_BIT_SET) +#define EFI_END_OF_MEDIA (28 | HIGH_BIT_SET) +#define EFI_END_OF_FILE (31 | HIGH_BIT_SET) +#define EFI_INVALID_LANGUAGE (32 | HIGH_BIT_SET) +#define EFI_COMPROMISED_DATA (33 | HIGH_BIT_SET) + #define FWTS_UEFI_UNSPECIFIED_TIMEZONE 0x07FF #if 0 @@ -313,4 +348,6 @@ void fwts_uefi_free_variable(fwts_uefi_var *var); void fwts_uefi_free_variable_names(fwts_list *list); int fwts_uefi_get_variable_names(fwts_list *list); +void fwts_uefi_print_status_info(fwts_framework *fw, const uint64_t status); + #endif diff --git a/src/lib/src/fwts_uefi.c b/src/lib/src/fwts_uefi.c index 43bc850..8e59000 100644 --- a/src/lib/src/fwts_uefi.c +++ b/src/lib/src/fwts_uefi.c @@ -45,6 +45,12 @@ typedef struct { uint8_t data[0]; /* variable length, depends on file size */ } __attribute__((packed)) fwts_uefi_efivars_fs_var; +typedef struct { + const uint64_t statusvalue; + const char *mnemonic ; + const char *description; +} uefistatus_info; + /* Which interface are we using? */ #define UEFI_IFACE_UNKNOWN (0) /* Not yet known */ #define UEFI_IFACE_NONE (1) /* None found */ @@ -413,3 +419,53 @@ int fwts_uefi_get_variable_names(fwts_list *list) return ret; } +static uefistatus_info uefistatus_info_table[] = { + { EFI_SUCCESS, "EFI_SUCCESS", "The operation completed successfully." }, + { EFI_LOAD_ERROR , "EFI_LOAD_ERROR", "The image failed to load." }, + { EFI_INVALID_PARAMETER , "EFI_INVALID_PARAMETER", "A parameter was incorrect." }, + { EFI_UNSUPPORTED , "EFI_UNSUPPORTED", "The operation is not supported." }, + { EFI_BAD_BUFFER_SIZE , "EFI_BAD_BUFFER_SIZE", "The buffer was not the proper size for the request." }, + { EFI_BUFFER_TOO_SMALL , "EFI_BUFFER_TOO_SMALL", "The buffer is not large enough to hold the requested data. The required buffer size is returned in the appropriate parameter when this error occurs." }, + { EFI_NOT_READY , "EFI_NOT_READY", "There is no data pending upon return." }, + { EFI_DEVICE_ERROR , "EFI_DEVICE_ERROR", "The physical device reported an error while attempting the operation." }, + { EFI_WRITE_PROTECTED , "EFI_WRITE_PROTECTED", "The device cannot be written to." }, + { EFI_OUT_OF_RESOURCES , "EFI_OUT_OF_RESOURCES", "A resource has run out." }, + { EFI_VOLUME_CORRUPTED , "EFI_VOLUME_CORRUPTED", "An inconstancy was detected on the file system causing the operating to fail." }, + { EFI_VOLUME_FULL , "EFI_VOLUME_FULL", "There is no more space on the file system." }, + { EFI_NO_MEDIA , "EFI_NO_MEDIA", "The device does not contain any medium to perform the operation." }, + { EFI_MEDIA_CHANGED , "EFI_MEDIA_CHANGED", "The medium in the device has changed since the last access." }, + { EFI_NOT_FOUND , "EFI_NOT_FOUND", "The item was not found." }, + { EFI_ACCESS_DENIED , "EFI_ACCESS_DENIED", "Access was denied." }, + { EFI_NO_RESPONSE , "EFI_NO_RESPONSE", "The server was not found or did not respond to the request." }, + { EFI_NO_MAPPING , "EFI_NO_MAPPING", "A mapping to a device does not exist." }, + { EFI_TIMEOUT , "EFI_TIMEOUT", "The timeout time expired." }, + { EFI_NOT_STARTED , "EFI_NOT_STARTED", "The protocol has not been started." }, + { EFI_ALREADY_STARTED , "EFI_ALREADY_STARTED", "The protocol has already been started." }, + { EFI_ABORTED , "EFI_ABORTED", "The operation was aborted." }, + { EFI_ICMP_ERROR , "EFI_ICMP_ERROR", "An ICMP error occurred during the network operation." }, + { EFI_TFTP_ERROR , "EFI_TFTP_ERROR", "A TFTP error occurred during the network operation." }, + { EFI_PROTOCOL_ERROR , "EFI_PROTOCOL_ERROR", "A protocol error occurred during the network operation." }, + { EFI_INCOMPATIBLE_VERSION , "EFI_INCOMPATIBLE_VERSION", "The function encountered an internal version that was incompatible with a version requested by the caller." }, + { EFI_SECURITY_VIOLATION , "EFI_SECURITY_VIOLATION", "The function was not performed due to a security violation." }, + { EFI_CRC_ERROR , "EFI_CRC_ERROR", "A CRC error was detected." }, + { EFI_END_OF_MEDIA , "EFI_END_OF_MEDIA", "Beginning or end of media was reached." }, + { EFI_END_OF_FILE , "EFI_END_OF_FILE", "The end of the file was reached." }, + { EFI_INVALID_LANGUAGE , "EFI_INVALID_LANGUAGE", "The language specified was invalid." }, + { EFI_COMPROMISED_DATA , "EFI_COMPROMISED_DATA", "The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status." }, + { ~0, NULL, NULL } +}; + +void fwts_uefi_print_status_info(fwts_framework *fw, const uint64_t status) +{ + + uefistatus_info *info; + + for (info = uefistatus_info_table; info->mnemonic != NULL; info++) { + if (status == info->statusvalue) { + fwts_log_info(fw, "Return status: %s. %s", info->mnemonic, info->description); + return; + } + } + fwts_log_info(fw, "Cann't find the return status infomation, value = 0x%" PRIx64 ".", status); + +} diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c index d9e91d2..cb446fd 100644 --- a/src/uefi/uefirtvariable/uefirtvariable.c +++ b/src/uefi/uefirtvariable/uefirtvariable.c @@ -40,9 +40,6 @@ 0xDD, 0xB7, 0x11, 0xD0, 0x6E} \ } -#define EFI_SUCCESS 0 -#define EFI_NOT_FOUND (14 | (1UL << 63)) - #define MAX_DATA_LENGTH 1024 static int fd; @@ -112,7 +109,7 @@ static int getvariable_test(fwts_framework *fw, uint64_t datasize, uint16_t *var if (ioret == -1) { fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable", "Failed to set variable with UEFI runtime service."); - + fwts_uefi_print_status_info(fw, status); return FWTS_ERROR; } @@ -127,12 +124,14 @@ static int getvariable_test(fwts_framework *fw, uint64_t datasize, uint16_t *var if (ioret == -1) { fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetVariable", "Failed to get variable with UEFI runtime service."); + fwts_uefi_print_status_info(fw, status); return FWTS_ERROR; } if (*getvariable.status != EFI_SUCCESS) { fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetVariableStatus", "Failed to get variable, return status isn't EFI_SUCCESS."); + fwts_uefi_print_status_info(fw, status); return FWTS_ERROR; } else if (*getvariable.Attributes != attributes) { fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetVariableAttributes", @@ -163,6 +162,7 @@ static int getvariable_test(fwts_framework *fw, uint64_t datasize, uint16_t *var if (ioret == -1) { fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable", "Failed to set variable with UEFI runtime service."); + fwts_uefi_print_status_info(fw, status); return FWTS_ERROR; } @@ -233,6 +233,7 @@ static int getnextvariable_test(fwts_framework *fw) if (ioret == -1) { fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable", "Failed to set variable with UEFI runtime service."); + fwts_uefi_print_status_info(fw, status); return FWTS_ERROR; } @@ -255,6 +256,7 @@ static int getnextvariable_test(fwts_framework *fw) fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetNextVariableName", "Failed to get next variable name with UEFI runtime service."); + fwts_uefi_print_status_info(fw, status); return FWTS_ERROR; } if (compare_name(getnextvariablename.VariableName, variablenametest)) @@ -284,6 +286,7 @@ static int getnextvariable_test(fwts_framework *fw) if (ioret == -1) { fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable", "Failed to set variable with UEFI runtime service."); + fwts_uefi_print_status_info(fw, status); return FWTS_ERROR; } @@ -316,7 +319,7 @@ static int setvariable_insertvariable(fwts_framework *fw, uint32_t attributes, u if (ioret == -1) { fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable", "Failed to set variable with UEFI runtime service."); - + fwts_uefi_print_status_info(fw, status); return FWTS_ERROR; } return FWTS_OK; @@ -345,6 +348,7 @@ static int setvariable_checkvariable(fwts_framework *fw, uint64_t datasize, if (ioret == -1) { fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetVariable", "Failed to get variable with UEFI runtime service."); + fwts_uefi_print_status_info(fw, status); return FWTS_ERROR; } @@ -398,6 +402,7 @@ static int setvariable_checkvariable_notfound(fwts_framework *fw, uint16_t *varn fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeSetVariable", "Failed to set variable with UEFI runtime service., " "expect the status return EFI_NOT_FOUND."); + fwts_uefi_print_status_info(fw, status); return FWTS_ERROR; }
Add the helper function which compare the return status value, then print out the status and description. When errors occur for UEFI runtime service interface, print out the useful reports to user. Signed-off-by: Ivan Hu <ivan.hu@canonical.com> --- src/lib/include/fwts_uefi.h | 37 ++++++++++++++++++++ src/lib/src/fwts_uefi.c | 56 ++++++++++++++++++++++++++++++ src/uefi/uefirtvariable/uefirtvariable.c | 15 +++++--- 3 files changed, 103 insertions(+), 5 deletions(-)