diff mbox

efi_runtime: add UEFI runtime service GetNextHighMonotonicCount interface

Message ID 1349158347-6243-1-git-send-email-ivan.hu@canonical.com
State Accepted
Headers show

Commit Message

Ivan Hu Oct. 2, 2012, 6:12 a.m. UTC
Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 efi_runtime/efi_runtime.c |   16 ++++++++++++++++
 efi_runtime/efi_runtime.h |    8 ++++++++
 2 files changed, 24 insertions(+)

Comments

Colin Ian King Oct. 2, 2012, 9:10 a.m. UTC | #1
On 02/10/12 07:12, Ivan Hu wrote:
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>   efi_runtime/efi_runtime.c |   16 ++++++++++++++++
>   efi_runtime/efi_runtime.h |    8 ++++++++
>   2 files changed, 24 insertions(+)
>
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 3ae2d8f..d5ff92b 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -119,6 +119,8 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd,
>
>   	struct efi_queryvariableinfo __user *pqueryvariableinfo;
>
> +	struct efi_getnexthighmonotoniccount __user *pgetnexthighmonotoniccount;
> +
>   	switch (cmd) {
>   	case EFI_RUNTIME_GET_VARIABLE:
>   		pgetvariable = (struct efi_getvariable __user *)arg;
> @@ -281,6 +283,20 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd,
>   			return -EINVAL;
>
>   		return 0;
> +
> +	case EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT:
> +
> +		pgetnexthighmonotoniccount = (struct
> +				efi_getnexthighmonotoniccount __user *)arg;
> +
> +		status = efi.get_next_high_mono_count(pgetnexthighmonotoniccount
> +								->HighCount);
> +		if (put_user(status, pgetnexthighmonotoniccount->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 cc33878..b8262c0 100644
> --- a/efi_runtime/efi_runtime.h
> +++ b/efi_runtime/efi_runtime.h
> @@ -105,6 +105,11 @@ struct efi_setwakeuptime {
>   	uint64_t	*status;
>   } __attribute__ ((packed));
>
> +struct efi_getnexthighmonotoniccount {
> +	uint32_t	*HighCount;
> +	uint64_t	*status;
> +} __attribute__ ((packed));
> +
>   /* ioctl calls that are permitted to the /dev/efi_runtime interface. */
>   #define EFI_RUNTIME_GET_VARIABLE \
>   	_IOWR('p', 0x01, struct efi_getvariable)
> @@ -127,4 +132,7 @@ struct efi_setwakeuptime {
>   #define EFI_RUNTIME_QUERY_VARIABLEINFO \
>   	_IOR('p', 0x08, struct efi_queryvariableinfo)
>
> +#define EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT \
> +	_IOR('p', 0x09, struct efi_getnexthighmonotoniccount)
> +
>   #endif /* _EFI_RUNTIME_H_ */
>

Acked-by: Colin Ian King <colin.king@canonical.com>
Keng-Yu Lin Oct. 3, 2012, 8:12 a.m. UTC | #2
On Tue, Oct 2, 2012 at 2:12 PM, Ivan Hu <ivan.hu@canonical.com> wrote:
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  efi_runtime/efi_runtime.c |   16 ++++++++++++++++
>  efi_runtime/efi_runtime.h |    8 ++++++++
>  2 files changed, 24 insertions(+)
>
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 3ae2d8f..d5ff92b 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -119,6 +119,8 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd,
>
>         struct efi_queryvariableinfo __user *pqueryvariableinfo;
>
> +       struct efi_getnexthighmonotoniccount __user *pgetnexthighmonotoniccount;
> +
>         switch (cmd) {
>         case EFI_RUNTIME_GET_VARIABLE:
>                 pgetvariable = (struct efi_getvariable __user *)arg;
> @@ -281,6 +283,20 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd,
>                         return -EINVAL;
>
>                 return 0;
> +
> +       case EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT:
> +
> +               pgetnexthighmonotoniccount = (struct
> +                               efi_getnexthighmonotoniccount __user *)arg;
> +
> +               status = efi.get_next_high_mono_count(pgetnexthighmonotoniccount
> +                                                               ->HighCount);
> +               if (put_user(status, pgetnexthighmonotoniccount->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 cc33878..b8262c0 100644
> --- a/efi_runtime/efi_runtime.h
> +++ b/efi_runtime/efi_runtime.h
> @@ -105,6 +105,11 @@ struct efi_setwakeuptime {
>         uint64_t        *status;
>  } __attribute__ ((packed));
>
> +struct efi_getnexthighmonotoniccount {
> +       uint32_t        *HighCount;
> +       uint64_t        *status;
> +} __attribute__ ((packed));
> +
>  /* ioctl calls that are permitted to the /dev/efi_runtime interface. */
>  #define EFI_RUNTIME_GET_VARIABLE \
>         _IOWR('p', 0x01, struct efi_getvariable)
> @@ -127,4 +132,7 @@ struct efi_setwakeuptime {
>  #define EFI_RUNTIME_QUERY_VARIABLEINFO \
>         _IOR('p', 0x08, struct efi_queryvariableinfo)
>
> +#define EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT \
> +       _IOR('p', 0x09, struct efi_getnexthighmonotoniccount)
> +
>  #endif /* _EFI_RUNTIME_H_ */
> --
> 1.7.9.5
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
diff mbox

Patch

diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
index 3ae2d8f..d5ff92b 100644
--- a/efi_runtime/efi_runtime.c
+++ b/efi_runtime/efi_runtime.c
@@ -119,6 +119,8 @@  static long efi_runtime_ioctl(struct file *file, unsigned int cmd,
 
 	struct efi_queryvariableinfo __user *pqueryvariableinfo;
 
+	struct efi_getnexthighmonotoniccount __user *pgetnexthighmonotoniccount;
+
 	switch (cmd) {
 	case EFI_RUNTIME_GET_VARIABLE:
 		pgetvariable = (struct efi_getvariable __user *)arg;
@@ -281,6 +283,20 @@  static long efi_runtime_ioctl(struct file *file, unsigned int cmd,
 			return -EINVAL;
 
 		return 0;
+
+	case EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT:
+
+		pgetnexthighmonotoniccount = (struct
+				efi_getnexthighmonotoniccount __user *)arg;
+
+		status = efi.get_next_high_mono_count(pgetnexthighmonotoniccount
+								->HighCount);
+		if (put_user(status, pgetnexthighmonotoniccount->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 cc33878..b8262c0 100644
--- a/efi_runtime/efi_runtime.h
+++ b/efi_runtime/efi_runtime.h
@@ -105,6 +105,11 @@  struct efi_setwakeuptime {
 	uint64_t	*status;
 } __attribute__ ((packed));
 
+struct efi_getnexthighmonotoniccount {
+	uint32_t	*HighCount;
+	uint64_t	*status;
+} __attribute__ ((packed));
+
 /* ioctl calls that are permitted to the /dev/efi_runtime interface. */
 #define EFI_RUNTIME_GET_VARIABLE \
 	_IOWR('p', 0x01, struct efi_getvariable)
@@ -127,4 +132,7 @@  struct efi_setwakeuptime {
 #define EFI_RUNTIME_QUERY_VARIABLEINFO \
 	_IOR('p', 0x08, struct efi_queryvariableinfo)
 
+#define EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT \
+	_IOR('p', 0x09, struct efi_getnexthighmonotoniccount)
+
 #endif /* _EFI_RUNTIME_H_ */