From patchwork Mon Jan 28 08:43:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: efi_runtime: add UEFI runtime service QueryCapsuleCapabilities interface From: IvanHu X-Patchwork-Id: 216121 Message-Id: <1359362621-9997-1-git-send-email-ivan.hu@canonical.com> To: fwts-devel@lists.ubuntu.com Date: Mon, 28 Jan 2013 16:43:41 +0800 Signed-off-by: Ivan Hu Acked-by: Colin Ian King Acked-by: Alex Hung --- efi_runtime/efi_runtime.c | 21 +++++++++++++++++++++ efi_runtime/efi_runtime.h | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c index 4c34f10..9440aae 100644 --- a/efi_runtime/efi_runtime.c +++ b/efi_runtime/efi_runtime.c @@ -121,6 +121,8 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, struct efi_getnexthighmonotoniccount __user *pgetnexthighmonotoniccount; + struct efi_querycapsulecapabilities __user *pquerycapsulecapabilities; + switch (cmd) { case EFI_RUNTIME_GET_VARIABLE: pgetvariable = (struct efi_getvariable __user *)arg; @@ -297,6 +299,25 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, return -EINVAL; return 0; + + case EFI_RUNTIME_QUERY_CAPSULECAPABILITIES: + + pquerycapsulecapabilities = (struct + efi_querycapsulecapabilities __user *)arg; + + status = efi.query_capsule_caps( + (efi_capsule_header_t **) + pquerycapsulecapabilities->CapsuleHeaderArray, + pquerycapsulecapabilities->CapsuleCount, + pquerycapsulecapabilities->MaximumCapsuleSize, + (int *)pquerycapsulecapabilities->ResetType); + + if (put_user(status, pquerycapsulecapabilities->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 ad62aa7..c516bba 100644 --- a/efi_runtime/efi_runtime.h +++ b/efi_runtime/efi_runtime.h @@ -21,6 +21,12 @@ #ifndef _EFI_RUNTIME_H_ #define _EFI_RUNTIME_H_ +typedef enum { + EfiResetCold, + EfiResetWarm, + EfiResetShutdown +} EFI_RESET_TYPE; + typedef struct { uint32_t Data1; uint16_t Data2; @@ -48,6 +54,13 @@ typedef struct { uint8_t SetsToZero; } __attribute__ ((packed)) EFI_TIME_CAPABILITIES; +typedef struct { + EFI_GUID CapsuleGuid; + uint32_t HeaderSize; + uint32_t Flags; + uint32_t CapsuleImageSize; +} __attribute__ ((packed)) EFI_CAPSULE_HEADER; + struct efi_getvariable { uint16_t *VariableName; EFI_GUID *VendorGuid; @@ -110,6 +123,14 @@ struct efi_getnexthighmonotoniccount { uint64_t *status; } __attribute__ ((packed)); +struct efi_querycapsulecapabilities { + EFI_CAPSULE_HEADER **CapsuleHeaderArray; + uint64_t CapsuleCount; + uint64_t *MaximumCapsuleSize; + EFI_RESET_TYPE *ResetType; + 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) @@ -135,4 +156,7 @@ struct efi_getnexthighmonotoniccount { #define EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT \ _IOR('p', 0x09, struct efi_getnexthighmonotoniccount) +#define EFI_RUNTIME_QUERY_CAPSULECAPABILITIES \ + _IOR('p', 0x0A, struct efi_querycapsulecapabilities) + #endif /* _EFI_RUNTIME_H_ */