/** @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
\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
// 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
//\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
///\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
#define RETURN_WARN_WRITE_FAILURE ENCODE_WARNING (3)\r
#define RETURN_WARN_BUFFER_TOO_SMALL ENCODE_WARNING (4)\r
\r
+/**\r
+ Returns a 16-bit signature built from 2 ASCII characters.\r
+ \r
+ @param A The first ASCII character.\r
+ @param B The second ASCII character.\r
+\r
+ @return A 16-bit value built from the two ASCII characters specified by A and B.\r
+\r
+**/\r
+#define SIGNATURE_16(A, B) ((A) | (B << 8))\r
+\r
+/**\r
+ Returns a 32-bit signature built from 4 ASCII characters.\r
+ \r
+ @param A The first ASCII character.\r
+ @param B The second ASCII character.\r
+ @param C The third ASCII character.\r
+ @param D The fourth ASCII character.\r
+\r
+ @return A 32-bit value built from the two ASCII characters specified by A, B,\r
+ C and D.\r
+\r
+**/\r
+#define SIGNATURE_32(A, B, C, D) (SIGNATURE_16 (A, B) | (SIGNATURE_16 (C, D) << 16))\r
+\r
+/**\r
+ Returns a 64-bit signature built from 8 ASCII characters.\r
+ \r
+ @param A The first ASCII character.\r
+ @param B The second ASCII character.\r
+ @param C The third ASCII character.\r
+ @param D The fourth ASCII character.\r
+ @param E The fifth ASCII character.\r
+ @param F The sixth ASCII character.\r
+ @param G The seventh ASCII character.\r
+ @param H The eighth ASCII character.\r
+\r
+ @return A 64-bit value built from the two ASCII characters specified by A, B,\r
+ C, D, E, F, G and H.\r
+\r
+**/\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