[prev in list] [next in list] [prev in thread] [next in thread] 

List:       fwts-devel
Subject:    [PATCH 2/2] efi_runtime: add UEFI runtime service QueryVariableInfo interface
From:       Ivan Hu <ivan.hu () canonical ! com>
Date:       2012-09-28 8:26:49
Message-ID: 1348820809-4489-1-git-send-email-ivan.hu () canonical ! com
[Download RAW message or body]

This interface is always returned EFI_UNSUPPORTED from
virt_fei_query_variable_info on kernel driver efi.c because of checking
the runtime_version. It seems that runtime_version value always 0,
it alway returns EFI_UNSUPPORTED. Need a patch of efi.c for this interface.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 efi_runtime/efi_runtime.c |   20 ++++++++++++++++++++
 efi_runtime/efi_runtime.h |   11 +++++++++++
 2 files changed, 31 insertions(+)

diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
index 227a910..0e66e94 100644
--- a/efi_runtime/efi_runtime.c
+++ b/efi_runtime/efi_runtime.c
@@ -117,6 +117,8 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd,
 	struct efi_getnextvariablename __user *pgetnextvariablename;
 	unsigned long name_size;
 
+	struct efi_queryvariableinfo __user *pqueryvariableinfo;
+
 	switch (cmd) {
 	case EFI_RUNTIME_GET_VARIABLE:
 		pgetvariable = (struct efi_getvariable __user *)arg;
@@ -261,6 +263,24 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd,
 						&vendor_guid, sizeof(EFI_GUID)))
 			return -EFAULT;
 		return 0;
+
+	case EFI_RUNTIME_QUERY_VARIABLEINFO:
+
+		pqueryvariableinfo = (struct efi_queryvariableinfo __user *)arg;
+
+		if (get_user(attr, &pqueryvariableinfo->Attributes))
+			return -EFAULT;
+
+		status = efi.query_variable_info(attr,
+				pqueryvariableinfo->MaximumVariableStorageSize,
+				pqueryvariableinfo->RemainingVariableStorageSize
+				, pqueryvariableinfo->MaximumVariableSize);
+		if (put_user(status, pqueryvariableinfo->status))
+			return -EFAULT;
+		if (status != EFI_SUCCESS)
+			return -EINVAL;
+
+		return 0;
 	}
 
 	return -ENOTTY;
diff --git a/efi_runtime/efi_runtime.h b/efi_runtime/efi_runtime.h
index 7387406..cc33878 100644
--- a/efi_runtime/efi_runtime.h
+++ b/efi_runtime/efi_runtime.h
@@ -73,6 +73,14 @@ struct efi_getnextvariablename {
 	uint64_t	*status;
 } __attribute__ ((packed));
 
+struct efi_queryvariableinfo {
+	uint32_t	Attributes;
+	uint64_t	*MaximumVariableStorageSize;
+	uint64_t	*RemainingVariableStorageSize;
+	uint64_t	*MaximumVariableSize;
+	uint64_t	*status;
+} __attribute__ ((packed));
+
 struct efi_gettime {
 	EFI_TIME		*Time;
 	EFI_TIME_CAPABILITIES	*Capabilities;
@@ -116,4 +124,7 @@ struct efi_setwakeuptime {
 #define EFI_RUNTIME_GET_NEXTVARIABLENAME \
 	_IOWR('p', 0x07, struct efi_getnextvariablename)
 
+#define EFI_RUNTIME_QUERY_VARIABLEINFO \
+	_IOR('p', 0x08, struct efi_queryvariableinfo)
+
 #endif /* _EFI_RUNTIME_H_ */
-- 
1.7.9.5



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic