]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Base.h
Code Scrub for BaseMemoryTest PEIM.
[mirror_edk2.git] / MdePkg / Include / Base.h
index 15ee9ad89a962b644e74c8eedc14ad477d3fa3f9..8ddb52a5ac4a4b0157d060a6435106d0db19d3a3 100644 (file)
@@ -1,5 +1,4 @@
 /** @file\r
-\r
   Root include file for Mde Package Base type modules\r
 \r
   This is the include file for any module of type base. Base modules only use \r
@@ -7,7 +6,7 @@
   environment. There are a set of base libraries in the Mde Package that can\r
   be used to implement base modules.\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+Copyright (c) 2006 - 2008, Intel Corporation\r
 All rights reserved. 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
@@ -36,9 +35,9 @@ typedef struct {
 \r
 typedef UINT64 PHYSICAL_ADDRESS;\r
 \r
-//\r
-// LIST_ENTRY definition\r
-//\r
+///\r
+/// LIST_ENTRY definition\r
+///\r
 typedef struct _LIST_ENTRY LIST_ENTRY;\r
 \r
 struct _LIST_ENTRY {\r
@@ -57,34 +56,18 @@ struct _LIST_ENTRY {
 // Modifiers for Data Types used to self document code.\r
 // This concept is borrowed for UEFI specification.\r
 //\r
-#ifndef IN\r
-//\r
-// Some other envirnments use this construct, so #ifndef to prevent\r
-// mulitple definition.\r
-//\r
 #define IN\r
 #define OUT\r
 #define OPTIONAL\r
-#endif\r
 \r
-//\r
-// Constants. They may exist in other build structures, so #ifndef them.\r
-//\r
-#ifndef TRUE\r
 //\r
 //  UEFI specification claims 1 and 0. We are concerned about the \r
 //  complier portability so we did it this way.\r
 //\r
 #define TRUE  ((BOOLEAN)(1==1))\r
-#endif\r
-\r
-#ifndef FALSE\r
 #define FALSE ((BOOLEAN)(0==1))\r
-#endif\r
 \r
-#ifndef NULL\r
 #define NULL  ((VOID *) 0)\r
-#endif\r
 \r
 #define  BIT0     0x00000001\r
 #define  BIT1     0x00000002\r
@@ -196,15 +179,11 @@ struct _LIST_ENTRY {
 //\r
 // Also support coding convention rules for var arg macros\r
 //\r
-#ifndef VA_START\r
-\r
 typedef CHAR8 *VA_LIST;\r
 #define VA_START(ap, v) (ap = (VA_LIST) & (v) + _INT_SIZE_OF (v))\r
 #define VA_ARG(ap, t)   (*(t *) ((ap += _INT_SIZE_OF (t)) - _INT_SIZE_OF (t)))\r
 #define VA_END(ap)      (ap = (VA_LIST) 0)\r
 \r
-#endif\r
-\r
 //\r
 // Macro that returns the byte offset of a field in a data structure. \r
 //\r
@@ -216,20 +195,21 @@ typedef CHAR8 *VA_LIST;
 ///\r
 #define _CR(Record, TYPE, Field)  ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))\r
 \r
+///\r
+///  ALIGN_VALUE - aligns a value up to the next boundary of the given alignment.\r
+///\r
+#define ALIGN_VALUE(Value, Alignment) ((Value) + (((Alignment) - (Value)) & ((Alignment) - 1)))\r
+\r
 ///\r
 ///  ALIGN_POINTER - aligns a pointer to the lowest boundry\r
 ///\r
-#define ALIGN_POINTER(p, s) ((VOID *) ((UINTN)(p) + (((s) - ((UINTN) (p))) & ((s) - 1))))\r
+#define ALIGN_POINTER(Pointer, Alignment) ((VOID *) (ALIGN_VALUE ((UINTN)(Pointer), (Alignment))))\r
 \r
 ///\r
 ///  ALIGN_VARIABLE - aligns a variable up to the next natural boundry for int size of a processor\r
 ///\r
-#define ALIGN_VARIABLE(Value, Adjustment) \\r
-  Adjustment = 0U; \\r
-  if ((UINTN) (Value) % sizeof (UINTN)) { \\r
-    (Adjustment) = (UINTN)(sizeof (UINTN) - ((UINTN) (Value) % sizeof (UINTN))); \\r
-  } \\r
-  (Value) = (UINTN)((UINTN) (Value) + (UINTN) (Adjustment))\r
+#define ALIGN_VARIABLE(Value)  ALIGN_VALUE ((Value), sizeof (UINTN))\r
+  \r
 \r
 //\r
 // Return the maximum of two operands. \r
@@ -261,7 +241,7 @@ typedef INTN RETURN_STATUS;
 #define ENCODE_ERROR(a)              (MAX_BIT | (a))\r
 \r
 #define ENCODE_WARNING(a)            (a)\r
-#define RETURN_ERROR(a)              ((a) < 0)\r
+#define RETURN_ERROR(a)              ((INTN) (a) < 0)\r
 \r
 #define RETURN_SUCCESS               0\r
 #define RETURN_LOAD_ERROR            ENCODE_ERROR (1)\r
@@ -293,11 +273,21 @@ typedef INTN RETURN_STATUS;
 #define RETURN_CRC_ERROR             ENCODE_ERROR (27)\r
 #define RETURN_END_OF_MEDIA          ENCODE_ERROR (28)\r
 #define RETURN_END_OF_FILE           ENCODE_ERROR (31)\r
+#define RETURN_INVALID_LANGUAGE      ENCODE_ERROR (32)\r
+\r
 \r
 #define RETURN_WARN_UNKNOWN_GLYPH    ENCODE_WARNING (1)\r
 #define RETURN_WARN_DELETE_FAILURE   ENCODE_WARNING (2)\r
 #define RETURN_WARN_WRITE_FAILURE    ENCODE_WARNING (3)\r
 #define RETURN_WARN_BUFFER_TOO_SMALL ENCODE_WARNING (4)\r
 \r
+//\r
+// Define macros to build data structure signatures from characters.\r
+//\r
+#define SIGNATURE_16(A, B)        ((A) | (B << 8))\r
+#define SIGNATURE_32(A, B, C, D)  (SIGNATURE_16 (A, B) | (SIGNATURE_16 (C, D) << 16))\r
+#define SIGNATURE_64(A, B, C, D, E, F, G, H) \\r
+    (SIGNATURE_32 (A, B, C, D) | ((UINT64) (SIGNATURE_32 (E, F, G, H)) << 32))\r
+\r
 #endif\r
 \r