From patchwork Mon Jul 4 09:25:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 643958 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3rjhTg0DfPz9sXx; Mon, 4 Jul 2016 19:26:15 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1bK08p-0007WR-Bb; Mon, 04 Jul 2016 09:26:11 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1bK08O-0007Rz-4n for fwts-devel@lists.ubuntu.com; Mon, 04 Jul 2016 09:25:44 +0000 Received: from 123-204-164-177.adsl.dynamic.seed.net.tw ([123.204.164.177] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1bK08N-0005aZ-02; Mon, 04 Jul 2016 09:25:43 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/2] uefi: add the header for using efi runtime service Date: Mon, 4 Jul 2016 17:25:34 +0800 Message-Id: <1467624335-13937-1-git-send-email-ivan.hu@canonical.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com Planning to upstream efi_runtime kernel module, add a header file for using uefi runtime service on user space. Signed-off-by: Ivan Hu Acked-by: Alex Hung Acked-by: Colin Ian King --- src/lib/include/fwts_efi_runtime.h | 160 +++++++++++++++++++++++++++++++ src/uefi/uefirtauthvar/uefirtauthvar.c | 2 +- src/uefi/uefirtmisc/uefirtmisc.c | 2 +- src/uefi/uefirttime/uefirttime.c | 2 +- src/uefi/uefirtvariable/uefirtvariable.c | 2 +- src/uefi/uefivarinfo/uefivarinfo.c | 2 +- 6 files changed, 165 insertions(+), 5 deletions(-) create mode 100644 src/lib/include/fwts_efi_runtime.h diff --git a/src/lib/include/fwts_efi_runtime.h b/src/lib/include/fwts_efi_runtime.h new file mode 100644 index 0000000..a65de31 --- /dev/null +++ b/src/lib/include/fwts_efi_runtime.h @@ -0,0 +1,160 @@ +/* + * Copyright(C) 2016 Canonical Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _FWTS_EFI_RUNTIME_H_ +#define _FWTS_EFI_RUNTIME_H_ + +typedef enum { + EfiResetCold, + EfiResetWarm, + EfiResetShutdown +} EFI_RESET_TYPE; + +typedef struct { + uint32_t Data1; + uint16_t Data2; + uint16_t Data3; + uint8_t Data4[8]; +} __attribute__ ((packed)) EFI_GUID; + +typedef struct { + uint16_t Year; /* 1900 – 9999 */ + uint8_t Month; /* 1 – 12 */ + uint8_t Day; /* 1 – 31 */ + uint8_t Hour; /* 0 – 23 */ + uint8_t Minute; /* 0 – 59 */ + uint8_t Second; /* 0 – 59 */ + uint8_t Pad1; + uint32_t Nanosecond; /* 0 – 999,999,999 */ + int16_t TimeZone; /* -1440 to 1440 or 2047 */ + uint8_t Daylight; + uint8_t Pad2; +} __attribute__ ((packed)) EFI_TIME; + +typedef struct { + uint32_t Resolution; + uint32_t Accuracy; + 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; + uint32_t *Attributes; + uint64_t *DataSize; + void *Data; + uint64_t *status; +} __attribute__ ((packed)); + +struct efi_setvariable { + uint16_t *VariableName; + EFI_GUID *VendorGuid; + uint32_t Attributes; + uint64_t DataSize; + void *Data; + uint64_t *status; +} __attribute__ ((packed)); + +struct efi_getnextvariablename { + uint64_t *VariableNameSize; + uint16_t *VariableName; + EFI_GUID *VendorGuid; + 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; + uint64_t *status; +} __attribute__ ((packed)); + +struct efi_settime { + EFI_TIME *Time; + uint64_t *status; +} __attribute__ ((packed)); + +struct efi_getwakeuptime { + uint8_t *Enabled; + uint8_t *Pending; + EFI_TIME *Time; + uint64_t *status; +} __attribute__ ((packed)); + +struct efi_setwakeuptime { + uint8_t Enabled; + EFI_TIME *Time; + uint64_t *status; +} __attribute__ ((packed)); + +struct efi_getnexthighmonotoniccount { + uint32_t *HighCount; + 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) +#define EFI_RUNTIME_SET_VARIABLE \ + _IOW('p', 0x02, struct efi_setvariable) + +#define EFI_RUNTIME_GET_TIME \ + _IOR('p', 0x03, struct efi_gettime) +#define EFI_RUNTIME_SET_TIME \ + _IOW('p', 0x04, struct efi_settime) + +#define EFI_RUNTIME_GET_WAKETIME \ + _IOR('p', 0x05, struct efi_getwakeuptime) +#define EFI_RUNTIME_SET_WAKETIME \ + _IOW('p', 0x06, 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) + +#define EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT \ + _IOR('p', 0x09, struct efi_getnexthighmonotoniccount) + +#define EFI_RUNTIME_QUERY_CAPSULECAPABILITIES \ + _IOR('p', 0x0A, struct efi_querycapsulecapabilities) + +#endif /* _FWTS_EFI_RUNTIME_H_ */ diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c index 6d8c385..ed23a8e 100644 --- a/src/uefi/uefirtauthvar/uefirtauthvar.c +++ b/src/uefi/uefirtauthvar/uefirtauthvar.c @@ -27,7 +27,7 @@ #include #include "fwts_uefi.h" -#include "efi_runtime.h" +#include "fwts_efi_runtime.h" #include "fwts_efi_module.h" #include "authvardefs.h" diff --git a/src/uefi/uefirtmisc/uefirtmisc.c b/src/uefi/uefirtmisc/uefirtmisc.c index 0b319d7..347b2b1 100644 --- a/src/uefi/uefirtmisc/uefirtmisc.c +++ b/src/uefi/uefirtmisc/uefirtmisc.c @@ -27,7 +27,7 @@ #include #include "fwts_uefi.h" -#include "efi_runtime.h" +#include "fwts_efi_runtime.h" #include "fwts_efi_module.h" #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000 diff --git a/src/uefi/uefirttime/uefirttime.c b/src/uefi/uefirttime/uefirttime.c index 5c883a5..f79e2da 100644 --- a/src/uefi/uefirttime/uefirttime.c +++ b/src/uefi/uefirttime/uefirttime.c @@ -27,7 +27,7 @@ #include #include "fwts_uefi.h" -#include "efi_runtime.h" +#include "fwts_efi_runtime.h" #include "fwts_efi_module.h" #define UEFI_IGNORE_UNSET_BITS (0) diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c index aca0202..f60dbad 100644 --- a/src/uefi/uefirtvariable/uefirtvariable.c +++ b/src/uefi/uefirtvariable/uefirtvariable.c @@ -27,7 +27,7 @@ #include #include "fwts_uefi.h" -#include "efi_runtime.h" +#include "fwts_efi_runtime.h" #include "fwts_efi_module.h" #define TEST_GUID1 \ diff --git a/src/uefi/uefivarinfo/uefivarinfo.c b/src/uefi/uefivarinfo/uefivarinfo.c index 005e3a1..22afe53 100644 --- a/src/uefi/uefivarinfo/uefivarinfo.c +++ b/src/uefi/uefivarinfo/uefivarinfo.c @@ -27,7 +27,7 @@ #include #include "fwts_uefi.h" -#include "efi_runtime.h" +#include "fwts_efi_runtime.h" #include "fwts_efi_module.h" #define MAX_VARNAME_LENGTH 1024