1 /** @file 2 3 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> 4 SPDX-License-Identifier: BSD-2-Clause-Patent 5 6 Module Name: 7 8 NVDataStruc.h 9 10 Abstract: 11 12 NVData structure used by the sample driver 13 14 Revision History: 15 16 17 **/ 18 19 #ifndef _NVDATASTRUC_H_ 20 #define _NVDATASTRUC_H_ 21 22 #include <Guid/HiiPlatformSetupFormset.h> 23 #include <Guid/HiiFormMapMethodGuid.h> 24 #include <Guid/DriverSampleHii.h> 25 #include <Guid/ZeroGuid.h> 26 27 #define CONFIGURATION_VARSTORE_ID 0x1234 28 #define BITS_VARSTORE_ID 0x2345 29 30 #pragma pack(1) 31 32 // 33 // !!! For a structure with a series of bit fields and used as a storage in vfr file, and if the bit fields do not add up to the size of the defined type. 34 // In the C code use sizeof() to get the size the strucure, the results may vary form the compiler(VS,GCC...). 35 // But the size of the storage calculated by VfrCompiler is fixed (calculate with alignment). 36 // To avoid above case, we need to make the total bit width in the structure aligned with the size of the defined type for these bit fields. We can: 37 // 1. Add bit field (with/without name) with remianing with for padding. 38 // 2. Add unnamed bit field with 0 for padding, the amount of padding is determined by the alignment characteristics of the members of the structure. 39 // 40 typedef struct { 41 UINT16 NestByteField; 42 UINT8 : 1; // unamed field can be used for padding 43 UINT8 NestBitCheckbox : 1; 44 UINT8 NestBitOneof : 2; 45 UINT8 : 0; // Special width 0 can be used to force alignment at the next word boundary 46 UINT8 NestBitNumeric : 4; 47 } MY_BITS_DATA; 48 49 typedef union { 50 UINT8 UnionNumeric; 51 UINT8 UnionNumericAlias; 52 } MY_EFI_UNION_DATA; 53 54 typedef struct { 55 UINT16 MyStringData[40]; 56 UINT16 SomethingHiddenForHtml; 57 UINT8 HowOldAreYouInYearsManual; 58 UINT16 HowTallAreYouManual; 59 UINT8 HowOldAreYouInYears; 60 UINT16 HowTallAreYou; 61 UINT8 MyFavoriteNumber; 62 UINT8 TestLateCheck; 63 UINT8 TestLateCheck2; 64 UINT8 QuestionAboutTreeHugging; 65 UINT8 ChooseToActivateNuclearWeaponry; 66 UINT8 SuppressGrayOutSomething; 67 UINT8 OrderedList[8]; 68 UINT16 BootOrder[8]; 69 UINT8 BootOrderLarge; 70 UINT8 DynamicRefresh; 71 UINT8 DynamicOneof; 72 UINT8 DynamicOrderedList[5]; 73 UINT8 Reserved; 74 EFI_HII_REF RefData; 75 UINT8 NameValueVar0; 76 UINT16 NameValueVar1; 77 UINT16 NameValueVar2[20]; 78 UINT8 SerialPortNo; 79 UINT8 SerialPortStatus; 80 UINT16 SerialPortIo; 81 UINT8 SerialPortIrq; 82 UINT8 GetDefaultValueFromCallBack; 83 UINT8 GetDefaultValueFromAccess; 84 EFI_HII_TIME Time; 85 UINT8 RefreshGuidCount; 86 UINT8 Match2; 87 UINT8 GetDefaultValueFromCallBackForOrderedList[3]; 88 UINT8 BitCheckbox : 1; 89 UINT8 ReservedBits: 7; // Reserved bit fields for padding. 90 UINT16 BitOneof : 6; 91 UINT16 : 0; // Width 0 used to force alignment. 92 UINT16 BitNumeric : 12; 93 MY_BITS_DATA MyBitData; 94 MY_EFI_UNION_DATA MyUnionData; 95 } DRIVER_SAMPLE_CONFIGURATION; 96 97 // 98 // 2nd NV data structure definition 99 // 100 typedef struct { 101 UINT8 Field8; 102 UINT16 Field16; 103 UINT8 OrderedList[3]; 104 UINT16 SubmittedCallback; 105 } MY_EFI_VARSTORE_DATA; 106 107 // 108 // 3rd NV data structure definition 109 // 110 typedef struct { 111 MY_BITS_DATA BitsData; 112 UINT32 EfiBitGrayoutTest : 5; 113 UINT32 EfiBitNumeric : 4; 114 UINT32 EfiBitOneof : 10; 115 UINT32 EfiBitCheckbox : 1; 116 UINT32 : 0; // Width 0 used to force alignment. 117 } MY_EFI_BITS_VARSTORE_DATA; 118 119 // 120 // Labels definition 121 // 122 #define LABEL_UPDATE1 0x1234 123 #define LABEL_UPDATE2 0x2234 124 #define LABEL_UPDATE3 0x3234 125 #define LABEL_END 0x2223 126 127 #pragma pack() 128 129 #endif 130