diff options
author | Julian Hall <julian.hall@arm.com> | 2021-10-13 11:43:30 +0100 |
---|---|---|
committer | Gyorgy Szing <Gyorgy.Szing@arm.com> | 2021-11-26 05:05:42 +0100 |
commit | 29f87eca1a593825496122d29029f67ca0298f11 (patch) | |
tree | 119588e92459dabc0091dbebc6d1ea46c2f4bb0e | |
parent | 49bfd5acab7840094623df0de8e61cc614f7351e (diff) | |
download | trusted-services-29f87eca1a593825496122d29029f67ca0298f11.tar.gz |
Add protocol definitions for smm_variable
Adds protocol definition for the SMM Variable service. Protocol
files are based on EDK2 originals from:
https://github.com/tianocore/edk2/commits/master
b4da6c29f1d36031e04212f53277ce0dcba309f1
Structures and defines are required to be align for compatibility
between EDK2 and TS components.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I3a478cdc5d3a849810abf6c699027f65594b4a83
-rw-r--r-- | protocols/common/efi/efi_status.h | 59 | ||||
-rw-r--r-- | protocols/common/efi/efi_types.h | 27 | ||||
-rw-r--r-- | protocols/service/smm_variable/opcodes.h | 25 | ||||
-rw-r--r-- | protocols/service/smm_variable/parameters.h | 90 | ||||
-rw-r--r-- | protocols/service/smm_variable/smm_variable_proto.h | 13 |
5 files changed, 214 insertions, 0 deletions
diff --git a/protocols/common/efi/efi_status.h b/protocols/common/efi/efi_status.h new file mode 100644 index 000000000..40c44a162 --- /dev/null +++ b/protocols/common/efi/efi_status.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef COMMON_EFI_STATUS_H +#define COMMON_EFI_STATUS_H + +#include <limits.h> +#include <stdint.h> + +/** + * Common EFI status type + */ +typedef uint32_t efi_status_t; + +/* For error class status codes */ +#define EFI_ERROR(s) ((1U << ((CHAR_BIT * sizeof(efi_status_t)) - 1)) | s) + +/** + * Common EFI status codes + */ +#define EFI_SUCCESS 0x0 +#define EFI_LOAD_ERROR EFI_ERROR(0x01) +#define EFI_INVALID_PARAMETER EFI_ERROR(0x02) +#define EFI_UNSUPPORTED EFI_ERROR(0x03) +#define EFI_BAD_BUFFER_SIZE EFI_ERROR(0x04) +#define EFI_BUFFER_TOO_SMALL EFI_ERROR(0x05) +#define EFI_NOT_READY EFI_ERROR(0x06) +#define EFI_DEVICE_ERROR EFI_ERROR(0x07) +#define EFI_WRITE_PROTECTED EFI_ERROR(0x08) +#define EFI_OUT_OF_RESOURCES EFI_ERROR(0x09) +#define EFI_VOLUME_CORRUPTED EFI_ERROR(0x0a) +#define EFI_VOLUME_FULL EFI_ERROR(0x0b) +#define EFI_NO_MEDIA EFI_ERROR(0x0c) +#define EFI_MEDIA_CHANGED EFI_ERROR(0x0d) +#define EFI_NOT_FOUND EFI_ERROR(0x0e) +#define EFI_ACCESS_DENIED EFI_ERROR(0x0f) +#define EFI_NO_RESPONSE EFI_ERROR(0x10) +#define EFI_NO_MAPPING EFI_ERROR(0x11) +#define EFI_TIMEOUT EFI_ERROR(0x12) +#define EFI_NOT_STARTED EFI_ERROR(0x13) +#define EFI_ALREADY_STARTED EFI_ERROR(0x14) +#define EFI_ABORTED EFI_ERROR(0x15) +#define EFI_ICMP_ERROR EFI_ERROR(0x16) +#define EFI_TFTP_ERROR EFI_ERROR(0x17) +#define EFI_PROTOCOL_ERROR EFI_ERROR(0x18) +#define EFI_INCOMPATIBLE_VERSION EFI_ERROR(0x19) +#define EFI_SECURITY_VIOLATION EFI_ERROR(0x1a) +#define EFI_CRC_ERROR EFI_ERROR(0x1b) +#define EFI_END_OF_MEDIA EFI_ERROR(0x1c) +#define EFI_END_OF_FILE EFI_ERROR(0x1f) +#define EFI_INVALID_LANGUAGE EFI_ERROR(0x20) +#define EFI_COMPROMISED_DATA EFI_ERROR(0x21) +#define EFI_HTTP_ERROR EFI_ERROR(0x23) + + +#endif /* COMMON_EFI_STATUS_H */ diff --git a/protocols/common/efi/efi_types.h b/protocols/common/efi/efi_types.h new file mode 100644 index 000000000..a96e31b09 --- /dev/null +++ b/protocols/common/efi/efi_types.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef COMMON_EFI_TYPES_H +#define COMMON_EFI_TYPES_H + +#include <stdint.h> + +/** + * Common EFI types + */ + +/** + * 128 bit buffer containing a unique identifier value. + * Unless otherwise specified, aligned on a 64 bit boundary. + */ +typedef struct { + uint32_t Data1; + uint16_t Data2; + uint16_t Data3; + uint8_t Data4[8]; +} EFI_GUID; + +#endif /* COMMON_EFI_TYPES_H */ diff --git a/protocols/service/smm_variable/opcodes.h b/protocols/service/smm_variable/opcodes.h new file mode 100644 index 000000000..7e3733319 --- /dev/null +++ b/protocols/service/smm_variable/opcodes.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef TS_SMM_VARIABLE_OPCODES_H +#define TS_SMM_VARIABLE_OPCODES_H + +/** + * C/C++ definition of smm_variable service opcodes + * + * These defines are aligned to the SMM Variable definitions from EDK2. These versions + * of these defines are maintained in the TS project to avoid a mandatory dependency + * on the EDK2 project. + */ + +#define SMM_VARIABLE_FUNCTION_GET_VARIABLE 1 +#define SMM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME 2 +#define SMM_VARIABLE_FUNCTION_SET_VARIABLE 3 +#define SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO 4 +#define SMM_VARIABLE_FUNCTION_READY_TO_BOOT 5 +#define SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE 6 + +#endif /* TS_SMM_VARIABLE_OPCODES_H */ diff --git a/protocols/service/smm_variable/parameters.h b/protocols/service/smm_variable/parameters.h new file mode 100644 index 000000000..bc4999eaf --- /dev/null +++ b/protocols/service/smm_variable/parameters.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef TS_SMM_VARIABLE_PARAMETERS_H +#define TS_SMM_VARIABLE_PARAMETERS_H + +#include <protocols/common/efi/efi_types.h> + +/** + * C/C++ definition of smm_variable service parameters + * + * These defines are aligned to the SMM Variable definitions from EDK2. These versions + * of these defines are maintained in the TS project to avoid a mandatory dependency + * on the EDK2 project. + */ + +/** + * Variable attributes + */ +#define EFI_VARIABLE_NON_VOLATILE (0x00000001) +#define EFI_VARIABLE_BOOTSERVICE_ACCESS (0x00000002) +#define EFI_VARIABLE_RUNTIME_ACCESS (0x00000004) +#define EFI_VARIABLE_HARDWARE_ERROR_RECORD (0x00000008) +#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS (0x00000010) +#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS (0x00000020) +#define EFI_VARIABLE_APPEND_WRITE (0x00000040) +#define EFI_VARIABLE_MASK \ + (EFI_VARIABLE_NON_VOLATILE | \ + EFI_VARIABLE_BOOTSERVICE_ACCESS | \ + EFI_VARIABLE_RUNTIME_ACCESS | \ + EFI_VARIABLE_HARDWARE_ERROR_RECORD | \ + EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | \ + EFI_VARIABLE_APPEND_WRITE) + +/** + * Parameter structure for SetVariable and GetVariable. + */ +typedef struct { + EFI_GUID Guid; + uint64_t DataSize; + uint64_t NameSize; + uint32_t Attributes; + int16_t Name[1]; +} SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE; + +#define SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE_NAME_OFFSET \ + offsetof(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + +#define SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE_DATA_OFFSET(s) \ + (offsetof(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + s->NameSize) + +#define SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE_TOTAL_SIZE(s) \ + (offsetof(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + s->NameSize + s->DataSize) + +#define SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE_SIZE(name_size, data_size) \ + (offsetof(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name) + name_size + data_size) + +/** + * Parameter structure for GetNextVariableName. + */ +typedef struct { + EFI_GUID Guid; + uint64_t NameSize; + int16_t Name[1]; +} SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME; + +#define SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME_NAME_OFFSET \ + offsetof(SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name) + +#define SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME_TOTAL_SIZE(s) \ + (offsetof(SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name) + s->NameSize) + +#define SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME_SIZE(name_size) \ + (offsetof(SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name) + name_size) + +/** + * Parameter structure for QueryVariableInfo. + */ +typedef struct { + uint64_t MaximumVariableStorageSize; + uint64_t RemainingVariableStorageSize; + uint64_t MaximumVariableSize; + uint32_t Attributes; +} SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO; + + +#endif /* TS_SMM_VARIABLE_PARAMETERS_H */ diff --git a/protocols/service/smm_variable/smm_variable_proto.h b/protocols/service/smm_variable/smm_variable_proto.h new file mode 100644 index 000000000..9e15bc155 --- /dev/null +++ b/protocols/service/smm_variable/smm_variable_proto.h @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef TS_SMM_VARIABLE_PROTO_H +#define TS_SMM_VARIABLE_PROTO_H + +#include <protocols/service/smm_variable/opcodes.h> +#include <protocols/service/smm_variable/parameters.h> + +#endif /* TS_SMM_VARIABLE_PROTO_H */ |