]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / DriverSampleDxe / NVDataStruc.h
index 40fb3d0964787c56ddca25479749edeeaa80d97b..86176176842579fc38ffd39aec68efa4413e9f72 100644 (file)
@@ -1,13 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 Module Name:\r
 \r
@@ -35,6 +29,14 @@ Revision History:
 \r
 #pragma pack(1)\r
 \r
+//\r
+// !!! 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.\r
+// In the C code use sizeof() to get the size the strucure, the results may vary form the compiler(VS,GCC...).\r
+// But the size of the storage calculated by VfrCompiler is fixed (calculate with alignment).\r
+// 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:\r
+// 1. Add bit field (with/without name) with remianing with for padding.\r
+// 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.\r
+//\r
 typedef struct {\r
   UINT16   NestByteField;\r
   UINT8                    : 1;  // unamed field can be used for padding\r
@@ -45,8 +47,8 @@ typedef struct {
 } MY_BITS_DATA;\r
 \r
 typedef union {\r
-  UINT16   BitField : 10;\r
-  UINT8    ByteField;\r
+  UINT8    UnionNumeric;\r
+  UINT8    UnionNumericAlias;\r
 } MY_EFI_UNION_DATA;\r
 \r
 typedef struct {\r
@@ -84,7 +86,9 @@ typedef struct {
   UINT8   Match2;\r
   UINT8   GetDefaultValueFromCallBackForOrderedList[3];\r
   UINT8   BitCheckbox : 1;\r
+  UINT8   ReservedBits: 7;  // Reserved bit fields for padding.\r
   UINT16  BitOneof    : 6;\r
+  UINT16              : 0;  // Width 0 used to force alignment.\r
   UINT16  BitNumeric  : 12;\r
   MY_BITS_DATA  MyBitData;\r
   MY_EFI_UNION_DATA MyUnionData;\r
@@ -109,6 +113,7 @@ typedef struct {
   UINT32   EfiBitNumeric     : 4;\r
   UINT32   EfiBitOneof       : 10;\r
   UINT32   EfiBitCheckbox    : 1;\r
+  UINT32                     : 0;  // Width 0 used to force alignment.\r
 } MY_EFI_BITS_VARSTORE_DATA;\r
 \r
 //\r