diff mbox

[1/3] uefirtvariable: add the function to print out the return status messages

Message ID 1355478568-25392-1-git-send-email-ivan.hu@canonical.com
State Rejected
Headers show

Commit Message

Ivan Hu Dec. 14, 2012, 9:49 a.m. UTC
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              |   35 +++++++++++++++++
 src/lib/src/fwts_uefi.c                  |   63 ++++++++++++++++++++++++++++++
 src/uefi/uefirtvariable/uefirtvariable.c |   15 ++++---
 3 files changed, 108 insertions(+), 5 deletions(-)

Comments

Colin Ian King Dec. 14, 2012, 10:30 a.m. UTC | #1
Just some minor tweaks need doing on this.

On 14/12/12 09:49, 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              |   35 +++++++++++++++++
>   src/lib/src/fwts_uefi.c                  |   63 ++++++++++++++++++++++++++++++
>   src/uefi/uefirtvariable/uefirtvariable.c |   15 ++++---
>   3 files changed, 108 insertions(+), 5 deletions(-)
>
> diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
> index 73cd773..a939335 100644
> --- a/src/lib/include/fwts_uefi.h
> +++ b/src/lib/include/fwts_uefi.h
> @@ -46,6 +46,39 @@ enum {
>   	FWTS_UEFI_TIME_IN_DAYLIGHT = 		0x02
>   };
>

Minor quibble: you could make (1UL << 63) into a macro and used it in 
each #define below.  To me (1UL << 63) is some magic value, so making it 
a macro with a meaningful name is helpful.

> +#define EFI_SUCCESS			0
> +#define EFI_LOAD_ERROR			(1 | (1UL << 63))
> +#define EFI_INVALID_PARAMETER		(2 | (1UL << 63))
> +#define EFI_UNSUPPORTED			(3 | (1UL << 63))
> +#define EFI_BAD_BUFFER_SIZE 		(4 | (1UL << 63))
> +#define EFI_BUFFER_TOO_SMALL		(5 | (1UL << 63))
> +#define EFI_NOT_READY			(6 | (1UL << 63))
> +#define EFI_DEVICE_ERROR		(7 | (1UL << 63))
> +#define EFI_WRITE_PROTECTED		(8 | (1UL << 63))
> +#define EFI_OUT_OF_RESOURCES		(9 | (1UL << 63))
> +#define EFI_VOLUME_CORRUPTED		(10 | (1UL << 63))
> +#define EFI_VOLUME_FULL			(11 | (1UL << 63))
> +#define EFI_NO_MEDIA			(12 | (1UL << 63))
> +#define EFI_MEDIA_CHANGED		(13 | (1UL << 63))
> +#define EFI_NOT_FOUND			(14 | (1UL << 63))
> +#define EFI_ACCESS_DENIED		(15 | (1UL << 63))
> +#define EFI_NO_RESPONSE			(16 | (1UL << 63))
> +#define EFI_NO_MAPPING			(17 | (1UL << 63))
> +#define EFI_TIMEOUT			(18 | (1UL << 63))
> +#define EFI_NOT_STARTED			(19 | (1UL << 63))
> +#define EFI_ALREADY_STARTED		(20 | (1UL << 63))
> +#define EFI_ABORTED			(21 | (1UL << 63))
> +#define EFI_ICMP_ERROR			(22 | (1UL << 63))
> +#define EFI_TFTP_ERROR			(23 | (1UL << 63))
> +#define EFI_PROTOCOL_ERROR		(24 | (1UL << 63))
> +#define EFI_INCOMPATIBLE_VERSION	(25 | (1UL << 63))
> +#define EFI_SECURITY_VIOLATION		(26 | (1UL << 63))
> +#define EFI_CRC_ERROR			(27 | (1UL << 63))
> +#define EFI_END_OF_MEDIA		(28 | (1UL << 63))
> +#define EFI_END_OF_FILE			(31 | (1UL << 63))
> +#define EFI_INVALID_LANGUAGE		(32 | (1UL << 63))
> +#define EFI_COMPROMISED_DATA 		(33 | (1UL << 63))
> +
>   #define FWTS_UEFI_UNSPECIFIED_TIMEZONE 0x07FF
>
>   #if 0
> @@ -313,4 +346,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, uint64_t status);
> +
>   #endif
> diff --git a/src/lib/src/fwts_uefi.c b/src/lib/src/fwts_uefi.c
> index 43bc850..1da702e 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 {
> +	uint64_t statusvalue;
> +	char *mnemonic ;
> +	char *description;
> +} __attribute__((packed)) uefistatus_info;
> +


Since the above structure is static and we're not modifying the contents 
I'd make the statusvalue, mnemonic and description const.
Also, we don't need the packed attribute for this structure as it is not 
being mapped to any firmware tables.  I only use the packed attribute 
when mapping a structure onto something in memory such as ACPI tables 
etc to ensure we are 1-to-1 aligned on each field.

>   /* Which interface are we using? */
>   #define UEFI_IFACE_UNKNOWN 		(0)	/* Not yet known */
>   #define UEFI_IFACE_NONE			(1)	/* None found */
> @@ -413,3 +419,60 @@ 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 }
> +};

If possible, can we shove in some tabs between fields to make it 
aligned. It makes my eyes wobble ;-)   For big tables, I really don't 
mind of the lines are > 80 chars wide.


> +
> +void fwts_uefi_print_status_info(fwts_framework *fw, uint64_t status)

status probably should be const

> +{
> +
> +	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);
> +
> +	return;

You don't need return at the end of a void function

> +}
> 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 mbox

Patch

diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
index 73cd773..a939335 100644
--- a/src/lib/include/fwts_uefi.h
+++ b/src/lib/include/fwts_uefi.h
@@ -46,6 +46,39 @@  enum {
 	FWTS_UEFI_TIME_IN_DAYLIGHT = 		0x02
 };
 
+#define EFI_SUCCESS			0
+#define EFI_LOAD_ERROR			(1 | (1UL << 63))
+#define EFI_INVALID_PARAMETER		(2 | (1UL << 63))
+#define EFI_UNSUPPORTED			(3 | (1UL << 63))
+#define EFI_BAD_BUFFER_SIZE 		(4 | (1UL << 63))
+#define EFI_BUFFER_TOO_SMALL		(5 | (1UL << 63))
+#define EFI_NOT_READY			(6 | (1UL << 63))
+#define EFI_DEVICE_ERROR		(7 | (1UL << 63))
+#define EFI_WRITE_PROTECTED		(8 | (1UL << 63))
+#define EFI_OUT_OF_RESOURCES		(9 | (1UL << 63))
+#define EFI_VOLUME_CORRUPTED		(10 | (1UL << 63))
+#define EFI_VOLUME_FULL			(11 | (1UL << 63))
+#define EFI_NO_MEDIA			(12 | (1UL << 63))
+#define EFI_MEDIA_CHANGED		(13 | (1UL << 63))
+#define EFI_NOT_FOUND			(14 | (1UL << 63))
+#define EFI_ACCESS_DENIED		(15 | (1UL << 63))
+#define EFI_NO_RESPONSE			(16 | (1UL << 63))
+#define EFI_NO_MAPPING			(17 | (1UL << 63))
+#define EFI_TIMEOUT			(18 | (1UL << 63))
+#define EFI_NOT_STARTED			(19 | (1UL << 63))
+#define EFI_ALREADY_STARTED		(20 | (1UL << 63))
+#define EFI_ABORTED			(21 | (1UL << 63))
+#define EFI_ICMP_ERROR			(22 | (1UL << 63))
+#define EFI_TFTP_ERROR			(23 | (1UL << 63))
+#define EFI_PROTOCOL_ERROR		(24 | (1UL << 63))
+#define EFI_INCOMPATIBLE_VERSION	(25 | (1UL << 63))
+#define EFI_SECURITY_VIOLATION		(26 | (1UL << 63))
+#define EFI_CRC_ERROR			(27 | (1UL << 63))
+#define EFI_END_OF_MEDIA		(28 | (1UL << 63))
+#define EFI_END_OF_FILE			(31 | (1UL << 63))
+#define EFI_INVALID_LANGUAGE		(32 | (1UL << 63))
+#define EFI_COMPROMISED_DATA 		(33 | (1UL << 63))
+
 #define FWTS_UEFI_UNSPECIFIED_TIMEZONE 0x07FF
 
 #if 0
@@ -313,4 +346,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, uint64_t status);
+
 #endif
diff --git a/src/lib/src/fwts_uefi.c b/src/lib/src/fwts_uefi.c
index 43bc850..1da702e 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 {
+	uint64_t statusvalue;
+	char *mnemonic ;
+	char *description;
+} __attribute__((packed)) 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,60 @@  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, 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);
+
+	return;
+}
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;
 }