iPXE
Base.h
Go to the documentation of this file.
00001 /** @file
00002   Root include file for Mde Package Base type modules
00003 
00004   This is the include file for any module of type base. Base modules only use
00005   types defined via this include file and can be ported easily to any
00006   environment. There are a set of base libraries in the Mde Package that can
00007   be used to implement base modules.
00008 
00009 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
00010 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
00011 This program and the accompanying materials
00012 are licensed and made available under the terms and conditions of the BSD License
00013 which accompanies this distribution.  The full text of the license may be found at
00014 http://opensource.org/licenses/bsd-license.php.
00015 
00016 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
00017 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
00018 
00019 **/
00020 
00021 
00022 #ifndef __BASE_H__
00023 #define __BASE_H__
00024 
00025 FILE_LICENCE ( BSD3 );
00026 
00027 //
00028 // Include processor specific binding
00029 //
00030 #include <ipxe/efi/ProcessorBind.h>
00031 
00032 #if defined(_MSC_EXTENSIONS)
00033 //
00034 // Disable warning when last field of data structure is a zero sized array.
00035 //
00036 #pragma warning ( disable : 4200 )
00037 #endif
00038 
00039 /**
00040   Verifies the storage size of a given data type.
00041 
00042   This macro generates a divide by zero error or a zero size array declaration in
00043   the preprocessor if the size is incorrect.  These are declared as "extern" so
00044   the space for these arrays will not be in the modules.
00045 
00046   @param  TYPE  The date type to determine the size of.
00047   @param  Size  The expected size for the TYPE.
00048 
00049 **/
00050 #define VERIFY_SIZE_OF(TYPE, Size) extern UINT8 _VerifySizeof##TYPE[(sizeof(TYPE) == (Size)) / (sizeof(TYPE) == (Size))]
00051 
00052 //
00053 // Verify that ProcessorBind.h produced UEFI Data Types that are compliant with
00054 // Section 2.3.1 of the UEFI 2.3 Specification.
00055 //
00056 VERIFY_SIZE_OF (BOOLEAN, 1);
00057 VERIFY_SIZE_OF (INT8, 1);
00058 VERIFY_SIZE_OF (UINT8, 1);
00059 VERIFY_SIZE_OF (INT16, 2);
00060 VERIFY_SIZE_OF (UINT16, 2);
00061 VERIFY_SIZE_OF (INT32, 4);
00062 VERIFY_SIZE_OF (UINT32, 4);
00063 VERIFY_SIZE_OF (INT64, 8);
00064 VERIFY_SIZE_OF (UINT64, 8);
00065 VERIFY_SIZE_OF (CHAR8, 1);
00066 VERIFY_SIZE_OF (CHAR16, 2);
00067 
00068 //
00069 // The following three enum types are used to verify that the compiler
00070 // configuration for enum types is compliant with Section 2.3.1 of the
00071 // UEFI 2.3 Specification. These enum types and enum values are not
00072 // intended to be used. A prefix of '__' is used avoid conflicts with
00073 // other types.
00074 //
00075 typedef enum {
00076   __VerifyUint8EnumValue = 0xff
00077 } __VERIFY_UINT8_ENUM_SIZE;
00078 
00079 typedef enum {
00080   __VerifyUint16EnumValue = 0xffff
00081 } __VERIFY_UINT16_ENUM_SIZE;
00082 
00083 typedef enum {
00084   __VerifyUint32EnumValue = 0xffffffff
00085 } __VERIFY_UINT32_ENUM_SIZE;
00086 
00087 VERIFY_SIZE_OF (__VERIFY_UINT8_ENUM_SIZE, 4);
00088 VERIFY_SIZE_OF (__VERIFY_UINT16_ENUM_SIZE, 4);
00089 VERIFY_SIZE_OF (__VERIFY_UINT32_ENUM_SIZE, 4);
00090 
00091 //
00092 // The Microsoft* C compiler can removed references to unreferenced data items
00093 //  if the /OPT:REF linker option is used. We defined a macro as this is a
00094 //  a non standard extension
00095 //
00096 #if defined(_MSC_EXTENSIONS) && !defined (MDE_CPU_EBC)
00097   ///
00098   /// Remove global variable from the linked image if there are no references to
00099   /// it after all compiler and linker optimizations have been performed.
00100   ///
00101   ///
00102   #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany)
00103 #else
00104   ///
00105   /// Remove the global variable from the linked image if there are no references
00106   ///  to it after all compiler and linker optimizations have been performed.
00107   ///
00108   ///
00109   #define GLOBAL_REMOVE_IF_UNREFERENCED
00110 #endif
00111 
00112 //
00113 // Should be used in combination with NORETURN to avoid 'noreturn' returns
00114 // warnings.
00115 //
00116 #ifndef UNREACHABLE
00117   #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)
00118     ///
00119     /// Signal compilers and analyzers that this call is not reachable.  It is
00120     /// up to the compiler to remove any code past that point.
00121     /// Not implemented by GCC 4.4 or earlier.
00122     ///
00123     #define UNREACHABLE()  __builtin_unreachable ()
00124   #elif defined (__has_feature)
00125     #if __has_builtin (__builtin_unreachable)
00126       ///
00127       /// Signal compilers and analyzers that this call is not reachable.  It is
00128       /// up to the compiler to remove any code past that point.
00129       ///
00130       #define UNREACHABLE()  __builtin_unreachable ()
00131     #endif
00132   #endif
00133 
00134   #ifndef UNREACHABLE
00135     ///
00136     /// Signal compilers and analyzers that this call is not reachable.  It is
00137     /// up to the compiler to remove any code past that point.
00138     ///
00139     #define UNREACHABLE()
00140   #endif
00141 #endif
00142 
00143 //
00144 // Signaling compilers and analyzers that a certain function cannot return may
00145 // remove all following code and thus lead to better optimization and less
00146 // false positives.
00147 //
00148 #ifndef NORETURN
00149   #if defined (__GNUC__) || defined (__clang__)
00150     ///
00151     /// Signal compilers and analyzers that the function cannot return.
00152     /// It is up to the compiler to remove any code past a call to functions
00153     /// flagged with this attribute.
00154     ///
00155     #define NORETURN  __attribute__((noreturn))
00156   #elif defined(_MSC_EXTENSIONS) && !defined(MDE_CPU_EBC)
00157     ///
00158     /// Signal compilers and analyzers that the function cannot return.
00159     /// It is up to the compiler to remove any code past a call to functions
00160     /// flagged with this attribute.
00161     ///
00162     #define NORETURN  __declspec(noreturn)
00163   #else
00164     ///
00165     /// Signal compilers and analyzers that the function cannot return.
00166     /// It is up to the compiler to remove any code past a call to functions
00167     /// flagged with this attribute.
00168     ///
00169     #define NORETURN
00170   #endif
00171 #endif
00172 
00173 //
00174 // Should be used in combination with ANALYZER_NORETURN to avoid 'noreturn'
00175 // returns warnings.
00176 //
00177 #ifndef ANALYZER_UNREACHABLE
00178   #ifdef __clang_analyzer__
00179     #if __has_builtin (__builtin_unreachable)
00180       ///
00181       /// Signal the analyzer that this call is not reachable.
00182       /// This excludes compilers.
00183       ///
00184       #define ANALYZER_UNREACHABLE()  __builtin_unreachable ()
00185     #endif
00186   #endif
00187 
00188   #ifndef ANALYZER_UNREACHABLE
00189     ///
00190     /// Signal the analyzer that this call is not reachable.
00191     /// This excludes compilers.
00192     ///
00193     #define ANALYZER_UNREACHABLE()
00194   #endif
00195 #endif
00196 
00197 //
00198 // Static Analyzers may issue errors about potential NULL-dereferences when
00199 // dereferencing a pointer, that has been checked before, outside of a
00200 // NULL-check.  This may lead to false positives, such as when using ASSERT()
00201 // for verification.
00202 //
00203 #ifndef ANALYZER_NORETURN
00204   #ifdef __has_feature
00205     #if __has_feature (attribute_analyzer_noreturn)
00206       ///
00207       /// Signal analyzers that the function cannot return.
00208       /// This excludes compilers.
00209       ///
00210       #define ANALYZER_NORETURN  __attribute__((analyzer_noreturn))
00211     #endif
00212   #endif
00213 
00214   #ifndef ANALYZER_NORETURN
00215     ///
00216     /// Signal the analyzer that the function cannot return.
00217     /// This excludes compilers.
00218     ///
00219     #define ANALYZER_NORETURN
00220   #endif
00221 #endif
00222 
00223 //
00224 // For symbol name in assembly code, an extra "_" is sometimes necessary
00225 //
00226 
00227 ///
00228 /// Private worker functions for ASM_PFX()
00229 ///
00230 #define _CONCATENATE(a, b)  __CONCATENATE(a, b)
00231 #define __CONCATENATE(a, b) a ## b
00232 
00233 ///
00234 /// The __USER_LABEL_PREFIX__ macro predefined by GNUC represents the prefix
00235 /// on symbols in assembly language.
00236 ///
00237 #define ASM_PFX(name) _CONCATENATE (__USER_LABEL_PREFIX__, name)
00238 
00239 #if __APPLE__
00240   //
00241   // Apple extension that is used by the linker to optimize code size
00242   // with assembly functions. Put at the end of your .S files
00243   //
00244   #define ASM_FUNCTION_REMOVE_IF_UNREFERENCED  .subsections_via_symbols
00245 #else
00246   #define ASM_FUNCTION_REMOVE_IF_UNREFERENCED
00247 #endif
00248 
00249 #ifdef __CC_ARM
00250   //
00251   // Older RVCT ARM compilers don't fully support #pragma pack and require __packed
00252   // as a prefix for the structure.
00253   //
00254   #define PACKED  __packed
00255 #else
00256   #define PACKED
00257 #endif
00258 
00259 ///
00260 /// 128 bit buffer containing a unique identifier value.
00261 /// Unless otherwise specified, aligned on a 64 bit boundary.
00262 ///
00263 typedef struct {
00264   UINT32  Data1;
00265   UINT16  Data2;
00266   UINT16  Data3;
00267   UINT8   Data4[8];
00268 } GUID;
00269 
00270 ///
00271 /// 4-byte buffer. An IPv4 internet protocol address.
00272 ///
00273 typedef struct {
00274   UINT8 Addr[4];
00275 } IPv4_ADDRESS;
00276 
00277 ///
00278 /// 16-byte buffer. An IPv6 internet protocol address.
00279 ///
00280 typedef struct {
00281   UINT8 Addr[16];
00282 } IPv6_ADDRESS;
00283 
00284 //
00285 // 8-bytes unsigned value that represents a physical system address.
00286 //
00287 typedef UINT64 PHYSICAL_ADDRESS;
00288 
00289 ///
00290 /// LIST_ENTRY structure definition.
00291 ///
00292 typedef struct _LIST_ENTRY LIST_ENTRY;
00293 
00294 ///
00295 /// _LIST_ENTRY structure definition.
00296 ///
00297 struct _LIST_ENTRY {
00298   LIST_ENTRY  *ForwardLink;
00299   LIST_ENTRY  *BackLink;
00300 };
00301 
00302 //
00303 // Modifiers to abstract standard types to aid in debug of problems
00304 //
00305 
00306 ///
00307 /// Datum is read-only.
00308 ///
00309 #define CONST     const
00310 
00311 ///
00312 /// Datum is scoped to the current file or function.
00313 ///
00314 #define STATIC    static
00315 
00316 ///
00317 /// Undeclared type.
00318 ///
00319 #define VOID      void
00320 
00321 //
00322 // Modifiers for Data Types used to self document code.
00323 // This concept is borrowed for UEFI specification.
00324 //
00325 
00326 ///
00327 /// Datum is passed to the function.
00328 ///
00329 #define IN
00330 
00331 ///
00332 /// Datum is returned from the function.
00333 ///
00334 #define OUT
00335 
00336 ///
00337 /// Passing the datum to the function is optional, and a NULL
00338 /// is passed if the value is not supplied.
00339 ///
00340 #define OPTIONAL
00341 
00342 //
00343 //  UEFI specification claims 1 and 0. We are concerned about the
00344 //  compiler portability so we did it this way.
00345 //
00346 
00347 ///
00348 /// Boolean true value.  UEFI Specification defines this value to be 1,
00349 /// but this form is more portable.
00350 ///
00351 #define TRUE  ((BOOLEAN)(1==1))
00352 
00353 ///
00354 /// Boolean false value.  UEFI Specification defines this value to be 0,
00355 /// but this form is more portable.
00356 ///
00357 #define FALSE ((BOOLEAN)(0==1))
00358 
00359 ///
00360 /// NULL pointer (VOID *)
00361 ///
00362 #define NULL  ((VOID *) 0)
00363 
00364 //
00365 // Null character
00366 //
00367 #define CHAR_NULL             0x0000
00368 
00369 ///
00370 /// Maximum values for common UEFI Data Types
00371 ///
00372 #define MAX_INT8    ((INT8)0x7F)
00373 #define MAX_UINT8   ((UINT8)0xFF)
00374 #define MAX_INT16   ((INT16)0x7FFF)
00375 #define MAX_UINT16  ((UINT16)0xFFFF)
00376 #define MAX_INT32   ((INT32)0x7FFFFFFF)
00377 #define MAX_UINT32  ((UINT32)0xFFFFFFFF)
00378 #define MAX_INT64   ((INT64)0x7FFFFFFFFFFFFFFFULL)
00379 #define MAX_UINT64  ((UINT64)0xFFFFFFFFFFFFFFFFULL)
00380 
00381 #define  BIT0     0x00000001
00382 #define  BIT1     0x00000002
00383 #define  BIT2     0x00000004
00384 #define  BIT3     0x00000008
00385 #define  BIT4     0x00000010
00386 #define  BIT5     0x00000020
00387 #define  BIT6     0x00000040
00388 #define  BIT7     0x00000080
00389 #define  BIT8     0x00000100
00390 #define  BIT9     0x00000200
00391 #define  BIT10    0x00000400
00392 #define  BIT11    0x00000800
00393 #define  BIT12    0x00001000
00394 #define  BIT13    0x00002000
00395 #define  BIT14    0x00004000
00396 #define  BIT15    0x00008000
00397 #define  BIT16    0x00010000
00398 #define  BIT17    0x00020000
00399 #define  BIT18    0x00040000
00400 #define  BIT19    0x00080000
00401 #define  BIT20    0x00100000
00402 #define  BIT21    0x00200000
00403 #define  BIT22    0x00400000
00404 #define  BIT23    0x00800000
00405 #define  BIT24    0x01000000
00406 #define  BIT25    0x02000000
00407 #define  BIT26    0x04000000
00408 #define  BIT27    0x08000000
00409 #define  BIT28    0x10000000
00410 #define  BIT29    0x20000000
00411 #define  BIT30    0x40000000
00412 #define  BIT31    0x80000000
00413 #define  BIT32    0x0000000100000000ULL
00414 #define  BIT33    0x0000000200000000ULL
00415 #define  BIT34    0x0000000400000000ULL
00416 #define  BIT35    0x0000000800000000ULL
00417 #define  BIT36    0x0000001000000000ULL
00418 #define  BIT37    0x0000002000000000ULL
00419 #define  BIT38    0x0000004000000000ULL
00420 #define  BIT39    0x0000008000000000ULL
00421 #define  BIT40    0x0000010000000000ULL
00422 #define  BIT41    0x0000020000000000ULL
00423 #define  BIT42    0x0000040000000000ULL
00424 #define  BIT43    0x0000080000000000ULL
00425 #define  BIT44    0x0000100000000000ULL
00426 #define  BIT45    0x0000200000000000ULL
00427 #define  BIT46    0x0000400000000000ULL
00428 #define  BIT47    0x0000800000000000ULL
00429 #define  BIT48    0x0001000000000000ULL
00430 #define  BIT49    0x0002000000000000ULL
00431 #define  BIT50    0x0004000000000000ULL
00432 #define  BIT51    0x0008000000000000ULL
00433 #define  BIT52    0x0010000000000000ULL
00434 #define  BIT53    0x0020000000000000ULL
00435 #define  BIT54    0x0040000000000000ULL
00436 #define  BIT55    0x0080000000000000ULL
00437 #define  BIT56    0x0100000000000000ULL
00438 #define  BIT57    0x0200000000000000ULL
00439 #define  BIT58    0x0400000000000000ULL
00440 #define  BIT59    0x0800000000000000ULL
00441 #define  BIT60    0x1000000000000000ULL
00442 #define  BIT61    0x2000000000000000ULL
00443 #define  BIT62    0x4000000000000000ULL
00444 #define  BIT63    0x8000000000000000ULL
00445 
00446 #define  SIZE_1KB    0x00000400
00447 #define  SIZE_2KB    0x00000800
00448 #define  SIZE_4KB    0x00001000
00449 #define  SIZE_8KB    0x00002000
00450 #define  SIZE_16KB   0x00004000
00451 #define  SIZE_32KB   0x00008000
00452 #define  SIZE_64KB   0x00010000
00453 #define  SIZE_128KB  0x00020000
00454 #define  SIZE_256KB  0x00040000
00455 #define  SIZE_512KB  0x00080000
00456 #define  SIZE_1MB    0x00100000
00457 #define  SIZE_2MB    0x00200000
00458 #define  SIZE_4MB    0x00400000
00459 #define  SIZE_8MB    0x00800000
00460 #define  SIZE_16MB   0x01000000
00461 #define  SIZE_32MB   0x02000000
00462 #define  SIZE_64MB   0x04000000
00463 #define  SIZE_128MB  0x08000000
00464 #define  SIZE_256MB  0x10000000
00465 #define  SIZE_512MB  0x20000000
00466 #define  SIZE_1GB    0x40000000
00467 #define  SIZE_2GB    0x80000000
00468 #define  SIZE_4GB    0x0000000100000000ULL
00469 #define  SIZE_8GB    0x0000000200000000ULL
00470 #define  SIZE_16GB   0x0000000400000000ULL
00471 #define  SIZE_32GB   0x0000000800000000ULL
00472 #define  SIZE_64GB   0x0000001000000000ULL
00473 #define  SIZE_128GB  0x0000002000000000ULL
00474 #define  SIZE_256GB  0x0000004000000000ULL
00475 #define  SIZE_512GB  0x0000008000000000ULL
00476 #define  SIZE_1TB    0x0000010000000000ULL
00477 #define  SIZE_2TB    0x0000020000000000ULL
00478 #define  SIZE_4TB    0x0000040000000000ULL
00479 #define  SIZE_8TB    0x0000080000000000ULL
00480 #define  SIZE_16TB   0x0000100000000000ULL
00481 #define  SIZE_32TB   0x0000200000000000ULL
00482 #define  SIZE_64TB   0x0000400000000000ULL
00483 #define  SIZE_128TB  0x0000800000000000ULL
00484 #define  SIZE_256TB  0x0001000000000000ULL
00485 #define  SIZE_512TB  0x0002000000000000ULL
00486 #define  SIZE_1PB    0x0004000000000000ULL
00487 #define  SIZE_2PB    0x0008000000000000ULL
00488 #define  SIZE_4PB    0x0010000000000000ULL
00489 #define  SIZE_8PB    0x0020000000000000ULL
00490 #define  SIZE_16PB   0x0040000000000000ULL
00491 #define  SIZE_32PB   0x0080000000000000ULL
00492 #define  SIZE_64PB   0x0100000000000000ULL
00493 #define  SIZE_128PB  0x0200000000000000ULL
00494 #define  SIZE_256PB  0x0400000000000000ULL
00495 #define  SIZE_512PB  0x0800000000000000ULL
00496 #define  SIZE_1EB    0x1000000000000000ULL
00497 #define  SIZE_2EB    0x2000000000000000ULL
00498 #define  SIZE_4EB    0x4000000000000000ULL
00499 #define  SIZE_8EB    0x8000000000000000ULL
00500 
00501 #define  BASE_1KB    0x00000400
00502 #define  BASE_2KB    0x00000800
00503 #define  BASE_4KB    0x00001000
00504 #define  BASE_8KB    0x00002000
00505 #define  BASE_16KB   0x00004000
00506 #define  BASE_32KB   0x00008000
00507 #define  BASE_64KB   0x00010000
00508 #define  BASE_128KB  0x00020000
00509 #define  BASE_256KB  0x00040000
00510 #define  BASE_512KB  0x00080000
00511 #define  BASE_1MB    0x00100000
00512 #define  BASE_2MB    0x00200000
00513 #define  BASE_4MB    0x00400000
00514 #define  BASE_8MB    0x00800000
00515 #define  BASE_16MB   0x01000000
00516 #define  BASE_32MB   0x02000000
00517 #define  BASE_64MB   0x04000000
00518 #define  BASE_128MB  0x08000000
00519 #define  BASE_256MB  0x10000000
00520 #define  BASE_512MB  0x20000000
00521 #define  BASE_1GB    0x40000000
00522 #define  BASE_2GB    0x80000000
00523 #define  BASE_4GB    0x0000000100000000ULL
00524 #define  BASE_8GB    0x0000000200000000ULL
00525 #define  BASE_16GB   0x0000000400000000ULL
00526 #define  BASE_32GB   0x0000000800000000ULL
00527 #define  BASE_64GB   0x0000001000000000ULL
00528 #define  BASE_128GB  0x0000002000000000ULL
00529 #define  BASE_256GB  0x0000004000000000ULL
00530 #define  BASE_512GB  0x0000008000000000ULL
00531 #define  BASE_1TB    0x0000010000000000ULL
00532 #define  BASE_2TB    0x0000020000000000ULL
00533 #define  BASE_4TB    0x0000040000000000ULL
00534 #define  BASE_8TB    0x0000080000000000ULL
00535 #define  BASE_16TB   0x0000100000000000ULL
00536 #define  BASE_32TB   0x0000200000000000ULL
00537 #define  BASE_64TB   0x0000400000000000ULL
00538 #define  BASE_128TB  0x0000800000000000ULL
00539 #define  BASE_256TB  0x0001000000000000ULL
00540 #define  BASE_512TB  0x0002000000000000ULL
00541 #define  BASE_1PB    0x0004000000000000ULL
00542 #define  BASE_2PB    0x0008000000000000ULL
00543 #define  BASE_4PB    0x0010000000000000ULL
00544 #define  BASE_8PB    0x0020000000000000ULL
00545 #define  BASE_16PB   0x0040000000000000ULL
00546 #define  BASE_32PB   0x0080000000000000ULL
00547 #define  BASE_64PB   0x0100000000000000ULL
00548 #define  BASE_128PB  0x0200000000000000ULL
00549 #define  BASE_256PB  0x0400000000000000ULL
00550 #define  BASE_512PB  0x0800000000000000ULL
00551 #define  BASE_1EB    0x1000000000000000ULL
00552 #define  BASE_2EB    0x2000000000000000ULL
00553 #define  BASE_4EB    0x4000000000000000ULL
00554 #define  BASE_8EB    0x8000000000000000ULL
00555 
00556 //
00557 //  Support for variable length argument lists using the ANSI standard.
00558 //
00559 //  Since we are using the ANSI standard we used the standard naming and
00560 //  did not follow the coding convention
00561 //
00562 //  VA_LIST  - typedef for argument list.
00563 //  VA_START (VA_LIST Marker, argument before the ...) - Init Marker for use.
00564 //  VA_END (VA_LIST Marker) - Clear Marker
00565 //  VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argument from
00566 //    the ... list. You must know the size and pass it in this macro.
00567 //  VA_COPY (VA_LIST Dest, VA_LIST Start) - Initialize Dest as a copy of Start.
00568 //
00569 //  example:
00570 //
00571 //  UINTN
00572 //  ExampleVarArg (
00573 //    IN UINTN  NumberOfArgs,
00574 //    ...
00575 //    )
00576 //  {
00577 //    VA_LIST Marker;
00578 //    UINTN   Index;
00579 //    UINTN   Result;
00580 //
00581 //    //
00582 //    // Initialize the Marker
00583 //    //
00584 //    VA_START (Marker, NumberOfArgs);
00585 //    for (Index = 0, Result = 0; Index < NumberOfArgs; Index++) {
00586 //      //
00587 //      // The ... list is a series of UINTN values, so average them up.
00588 //      //
00589 //      Result += VA_ARG (Marker, UINTN);
00590 //    }
00591 //
00592 //    VA_END (Marker);
00593 //    return Result
00594 //  }
00595 //
00596 
00597 /**
00598   Return the size of argument that has been aligned to sizeof (UINTN).
00599 
00600   @param  n    The parameter size to be aligned.
00601 
00602   @return The aligned size.
00603 **/
00604 #define _INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1))
00605 
00606 #if defined(__CC_ARM)
00607 //
00608 // RVCT ARM variable argument list support.
00609 //
00610 
00611 ///
00612 /// Variable used to traverse the list of arguments. This type can vary by
00613 /// implementation and could be an array or structure.
00614 ///
00615 #ifdef __APCS_ADSABI
00616   typedef int         *va_list[1];
00617   #define VA_LIST     va_list
00618 #else
00619   typedef struct __va_list { void *__ap; } va_list;
00620   #define VA_LIST                          va_list
00621 #endif
00622 
00623 #define VA_START(Marker, Parameter)   __va_start(Marker, Parameter)
00624 
00625 #define VA_ARG(Marker, TYPE)          __va_arg(Marker, TYPE)
00626 
00627 #define VA_END(Marker)                ((void)0)
00628 
00629 // For some ARM RVCT compilers, __va_copy is not defined
00630 #ifndef __va_copy
00631   #define __va_copy(dest, src) ((void)((dest) = (src)))
00632 #endif
00633 
00634 #define VA_COPY(Dest, Start)          __va_copy (Dest, Start)
00635 
00636 #elif defined(__GNUC__)
00637 
00638 #if defined(MDE_CPU_X64) && !defined(NO_MSABI_VA_FUNCS)
00639 //
00640 // X64 only. Use MS ABI version of GCC built-in macros for variable argument lists.
00641 //
00642 ///
00643 /// Both GCC and LLVM 3.8 for X64 support new variable argument intrinsics for Microsoft ABI
00644 ///
00645 
00646 ///
00647 /// Variable used to traverse the list of arguments. This type can vary by
00648 /// implementation and could be an array or structure.
00649 ///
00650 typedef __builtin_ms_va_list VA_LIST;
00651 
00652 #define VA_START(Marker, Parameter)  __builtin_ms_va_start (Marker, Parameter)
00653 
00654 #define VA_ARG(Marker, TYPE)         ((sizeof (TYPE) < sizeof (UINTN)) ? (TYPE)(__builtin_va_arg (Marker, UINTN)) : (TYPE)(__builtin_va_arg (Marker, TYPE)))
00655 
00656 #define VA_END(Marker)               __builtin_ms_va_end (Marker)
00657 
00658 #define VA_COPY(Dest, Start)         __builtin_ms_va_copy (Dest, Start)
00659 
00660 #else
00661 //
00662 // Use GCC built-in macros for variable argument lists.
00663 //
00664 
00665 ///
00666 /// Variable used to traverse the list of arguments. This type can vary by
00667 /// implementation and could be an array or structure.
00668 ///
00669 typedef __builtin_va_list VA_LIST;
00670 
00671 #define VA_START(Marker, Parameter)  __builtin_va_start (Marker, Parameter)
00672 
00673 #define VA_ARG(Marker, TYPE)         ((sizeof (TYPE) < sizeof (UINTN)) ? (TYPE)(__builtin_va_arg (Marker, UINTN)) : (TYPE)(__builtin_va_arg (Marker, TYPE)))
00674 
00675 #define VA_END(Marker)               __builtin_va_end (Marker)
00676 
00677 #define VA_COPY(Dest, Start)         __builtin_va_copy (Dest, Start)
00678 
00679 #endif
00680 
00681 #else
00682 ///
00683 /// Variable used to traverse the list of arguments. This type can vary by
00684 /// implementation and could be an array or structure.
00685 ///
00686 typedef CHAR8 *VA_LIST;
00687 
00688 /**
00689   Retrieves a pointer to the beginning of a variable argument list, based on
00690   the name of the parameter that immediately precedes the variable argument list.
00691 
00692   This function initializes Marker to point to the beginning of the variable
00693   argument list that immediately follows Parameter.  The method for computing the
00694   pointer to the next argument in the argument list is CPU-specific following the
00695   EFIAPI ABI.
00696 
00697   @param   Marker       The VA_LIST used to traverse the list of arguments.
00698   @param   Parameter    The name of the parameter that immediately precedes
00699                         the variable argument list.
00700 
00701   @return  A pointer to the beginning of a variable argument list.
00702 
00703 **/
00704 #define VA_START(Marker, Parameter) (Marker = (VA_LIST) ((UINTN) & (Parameter) + _INT_SIZE_OF (Parameter)))
00705 
00706 /**
00707   Returns an argument of a specified type from a variable argument list and updates
00708   the pointer to the variable argument list to point to the next argument.
00709 
00710   This function returns an argument of the type specified by TYPE from the beginning
00711   of the variable argument list specified by Marker.  Marker is then updated to point
00712   to the next argument in the variable argument list.  The method for computing the
00713   pointer to the next argument in the argument list is CPU-specific following the EFIAPI ABI.
00714 
00715   @param   Marker   VA_LIST used to traverse the list of arguments.
00716   @param   TYPE     The type of argument to retrieve from the beginning
00717                     of the variable argument list.
00718 
00719   @return  An argument of the type specified by TYPE.
00720 
00721 **/
00722 #define VA_ARG(Marker, TYPE)   (*(TYPE *) ((Marker += _INT_SIZE_OF (TYPE)) - _INT_SIZE_OF (TYPE)))
00723 
00724 /**
00725   Terminates the use of a variable argument list.
00726 
00727   This function initializes Marker so it can no longer be used with VA_ARG().
00728   After this macro is used, the only way to access the variable argument list is
00729   by using VA_START() again.
00730 
00731   @param   Marker   VA_LIST used to traverse the list of arguments.
00732 
00733 **/
00734 #define VA_END(Marker)      (Marker = (VA_LIST) 0)
00735 
00736 /**
00737   Initializes a VA_LIST as a copy of an existing VA_LIST.
00738 
00739   This macro initializes Dest as a copy of Start, as if the VA_START macro had been applied to Dest
00740   followed by the same sequence of uses of the VA_ARG macro as had previously been used to reach
00741   the present state of Start.
00742 
00743   @param   Dest   VA_LIST used to traverse the list of arguments.
00744   @param   Start  VA_LIST used to traverse the list of arguments.
00745 
00746 **/
00747 #define VA_COPY(Dest, Start)  ((void)((Dest) = (Start)))
00748 
00749 #endif
00750 
00751 ///
00752 /// Pointer to the start of a variable argument list stored in a memory buffer. Same as UINT8 *.
00753 ///
00754 typedef UINTN  *BASE_LIST;
00755 
00756 /**
00757   Returns the size of a data type in sizeof(UINTN) units rounded up to the nearest UINTN boundary.
00758 
00759   @param  TYPE  The date type to determine the size of.
00760 
00761   @return The size of TYPE in sizeof (UINTN) units rounded up to the nearest UINTN boundary.
00762 **/
00763 #define _BASE_INT_SIZE_OF(TYPE) ((sizeof (TYPE) + sizeof (UINTN) - 1) / sizeof (UINTN))
00764 
00765 /**
00766   Returns an argument of a specified type from a variable argument list and updates
00767   the pointer to the variable argument list to point to the next argument.
00768 
00769   This function returns an argument of the type specified by TYPE from the beginning
00770   of the variable argument list specified by Marker.  Marker is then updated to point
00771   to the next argument in the variable argument list.  The method for computing the
00772   pointer to the next argument in the argument list is CPU specific following the EFIAPI ABI.
00773 
00774   @param   Marker   The pointer to the beginning of a variable argument list.
00775   @param   TYPE     The type of argument to retrieve from the beginning
00776                     of the variable argument list.
00777 
00778   @return  An argument of the type specified by TYPE.
00779 
00780 **/
00781 #define BASE_ARG(Marker, TYPE)   (*(TYPE *) ((Marker += _BASE_INT_SIZE_OF (TYPE)) - _BASE_INT_SIZE_OF (TYPE)))
00782 
00783 /**
00784   The macro that returns the byte offset of a field in a data structure.
00785 
00786   This function returns the offset, in bytes, of field specified by Field from the
00787   beginning of the  data structure specified by TYPE. If TYPE does not contain Field,
00788   the module will not compile.
00789 
00790   @param   TYPE     The name of the data structure that contains the field specified by Field.
00791   @param   Field    The name of the field in the data structure.
00792 
00793   @return  Offset, in bytes, of field.
00794 
00795 **/
00796 #ifdef __GNUC__
00797 #if __GNUC__ >= 4
00798 #define OFFSET_OF(TYPE, Field) ((UINTN) __builtin_offsetof(TYPE, Field))
00799 #endif
00800 #endif
00801 
00802 #ifndef OFFSET_OF
00803 #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
00804 #endif
00805 
00806 /**
00807   Macro that returns a pointer to the data structure that contains a specified field of
00808   that data structure.  This is a lightweight method to hide information by placing a
00809   public data structure inside a larger private data structure and using a pointer to
00810   the public data structure to retrieve a pointer to the private data structure.
00811 
00812   This function computes the offset, in bytes, of field specified by Field from the beginning
00813   of the  data structure specified by TYPE.  This offset is subtracted from Record, and is
00814   used to return a pointer to a data structure of the type specified by TYPE. If the data type
00815   specified by TYPE does not contain the field specified by Field, then the module will not compile.
00816 
00817   @param   Record   Pointer to the field specified by Field within a data structure of type TYPE.
00818   @param   TYPE     The name of the data structure type to return.  This data structure must
00819                     contain the field specified by Field.
00820   @param   Field    The name of the field in the data structure specified by TYPE to which Record points.
00821 
00822   @return  A pointer to the structure from one of it's elements.
00823 
00824 **/
00825 #define BASE_CR(Record, TYPE, Field)  ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))
00826 
00827 /**
00828   Rounds a value up to the next boundary using a specified alignment.
00829 
00830   This function rounds Value up to the next boundary using the specified Alignment.
00831   This aligned value is returned.
00832 
00833   @param   Value      The value to round up.
00834   @param   Alignment  The alignment boundary used to return the aligned value.
00835 
00836   @return  A value up to the next boundary.
00837 
00838 **/
00839 #define ALIGN_VALUE(Value, Alignment) ((Value) + (((Alignment) - (Value)) & ((Alignment) - 1)))
00840 
00841 /**
00842   Adjust a pointer by adding the minimum offset required for it to be aligned on
00843   a specified alignment boundary.
00844 
00845   This function rounds the pointer specified by Pointer to the next alignment boundary
00846   specified by Alignment. The pointer to the aligned address is returned.
00847 
00848   @param   Pointer    The pointer to round up.
00849   @param   Alignment  The alignment boundary to use to return an aligned pointer.
00850 
00851   @return  Pointer to the aligned address.
00852 
00853 **/
00854 #define ALIGN_POINTER(Pointer, Alignment) ((VOID *) (ALIGN_VALUE ((UINTN)(Pointer), (Alignment))))
00855 
00856 /**
00857   Rounds a value up to the next natural boundary for the current CPU.
00858   This is 4-bytes for 32-bit CPUs and 8-bytes for 64-bit CPUs.
00859 
00860   This function rounds the value specified by Value up to the next natural boundary for the
00861   current CPU. This rounded value is returned.
00862 
00863   @param   Value      The value to round up.
00864 
00865   @return  Rounded value specified by Value.
00866 
00867 **/
00868 #define ALIGN_VARIABLE(Value)  ALIGN_VALUE ((Value), sizeof (UINTN))
00869 
00870 
00871 /**
00872   Return the maximum of two operands.
00873 
00874   This macro returns the maximum of two operand specified by a and b.
00875   Both a and b must be the same numerical types, signed or unsigned.
00876 
00877   @param   a        The first operand with any numerical type.
00878   @param   b        The second operand. Can be any numerical type as long as is
00879                     the same type as a.
00880 
00881   @return  Maximum of two operands.
00882 
00883 **/
00884 #define MAX(a, b)                       \
00885   (((a) > (b)) ? (a) : (b))
00886 
00887 /**
00888   Return the minimum of two operands.
00889 
00890   This macro returns the minimal of two operand specified by a and b.
00891   Both a and b must be the same numerical types, signed or unsigned.
00892 
00893   @param   a        The first operand with any numerical type.
00894   @param   b        The second operand. It should be the same any numerical type with a.
00895 
00896   @return  Minimum of two operands.
00897 
00898 **/
00899 #define MIN(a, b)                       \
00900   (((a) < (b)) ? (a) : (b))
00901 
00902 /**
00903   Return the absolute value of a signed operand.
00904 
00905   This macro returns the absolute value of the signed operand specified by a.
00906 
00907   @param   a        The signed operand.
00908 
00909   @return  The absolute value of the signed operand.
00910 
00911 **/
00912 #define ABS(a)                          \
00913   (((a) < 0) ? (-(a)) : (a))
00914 
00915 //
00916 // Status codes common to all execution phases
00917 //
00918 typedef UINTN RETURN_STATUS;
00919 
00920 /**
00921   Produces a RETURN_STATUS code with the highest bit set.
00922 
00923   @param  StatusCode    The status code value to convert into a warning code.
00924                         StatusCode must be in the range 0x00000000..0x7FFFFFFF.
00925 
00926   @return The value specified by StatusCode with the highest bit set.
00927 
00928 **/
00929 #define ENCODE_ERROR(StatusCode)     ((RETURN_STATUS)(MAX_BIT | (StatusCode)))
00930 
00931 /**
00932   Produces a RETURN_STATUS code with the highest bit clear.
00933 
00934   @param  StatusCode    The status code value to convert into a warning code.
00935                         StatusCode must be in the range 0x00000000..0x7FFFFFFF.
00936 
00937   @return The value specified by StatusCode with the highest bit clear.
00938 
00939 **/
00940 #define ENCODE_WARNING(StatusCode)   ((RETURN_STATUS)(StatusCode))
00941 
00942 /**
00943   Returns TRUE if a specified RETURN_STATUS code is an error code.
00944 
00945   This function returns TRUE if StatusCode has the high bit set.  Otherwise, FALSE is returned.
00946 
00947   @param  StatusCode    The status code value to evaluate.
00948 
00949   @retval TRUE          The high bit of StatusCode is set.
00950   @retval FALSE         The high bit of StatusCode is clear.
00951 
00952 **/
00953 #define RETURN_ERROR(StatusCode)     (((INTN)(RETURN_STATUS)(StatusCode)) < 0)
00954 
00955 ///
00956 /// The operation completed successfully.
00957 ///
00958 #define RETURN_SUCCESS               0
00959 
00960 ///
00961 /// The image failed to load.
00962 ///
00963 #define RETURN_LOAD_ERROR            ENCODE_ERROR (1)
00964 
00965 ///
00966 /// The parameter was incorrect.
00967 ///
00968 #define RETURN_INVALID_PARAMETER     ENCODE_ERROR (2)
00969 
00970 ///
00971 /// The operation is not supported.
00972 ///
00973 #define RETURN_UNSUPPORTED           ENCODE_ERROR (3)
00974 
00975 ///
00976 /// The buffer was not the proper size for the request.
00977 ///
00978 #define RETURN_BAD_BUFFER_SIZE       ENCODE_ERROR (4)
00979 
00980 ///
00981 /// The buffer was not large enough to hold the requested data.
00982 /// The required buffer size is returned in the appropriate
00983 /// parameter when this error occurs.
00984 ///
00985 #define RETURN_BUFFER_TOO_SMALL      ENCODE_ERROR (5)
00986 
00987 ///
00988 /// There is no data pending upon return.
00989 ///
00990 #define RETURN_NOT_READY             ENCODE_ERROR (6)
00991 
00992 ///
00993 /// The physical device reported an error while attempting the
00994 /// operation.
00995 ///
00996 #define RETURN_DEVICE_ERROR          ENCODE_ERROR (7)
00997 
00998 ///
00999 /// The device can not be written to.
01000 ///
01001 #define RETURN_WRITE_PROTECTED       ENCODE_ERROR (8)
01002 
01003 ///
01004 /// The resource has run out.
01005 ///
01006 #define RETURN_OUT_OF_RESOURCES      ENCODE_ERROR (9)
01007 
01008 ///
01009 /// An inconsistency was detected on the file system causing the
01010 /// operation to fail.
01011 ///
01012 #define RETURN_VOLUME_CORRUPTED      ENCODE_ERROR (10)
01013 
01014 ///
01015 /// There is no more space on the file system.
01016 ///
01017 #define RETURN_VOLUME_FULL           ENCODE_ERROR (11)
01018 
01019 ///
01020 /// The device does not contain any medium to perform the
01021 /// operation.
01022 ///
01023 #define RETURN_NO_MEDIA              ENCODE_ERROR (12)
01024 
01025 ///
01026 /// The medium in the device has changed since the last
01027 /// access.
01028 ///
01029 #define RETURN_MEDIA_CHANGED         ENCODE_ERROR (13)
01030 
01031 ///
01032 /// The item was not found.
01033 ///
01034 #define RETURN_NOT_FOUND             ENCODE_ERROR (14)
01035 
01036 ///
01037 /// Access was denied.
01038 ///
01039 #define RETURN_ACCESS_DENIED         ENCODE_ERROR (15)
01040 
01041 ///
01042 /// The server was not found or did not respond to the request.
01043 ///
01044 #define RETURN_NO_RESPONSE           ENCODE_ERROR (16)
01045 
01046 ///
01047 /// A mapping to the device does not exist.
01048 ///
01049 #define RETURN_NO_MAPPING            ENCODE_ERROR (17)
01050 
01051 ///
01052 /// A timeout time expired.
01053 ///
01054 #define RETURN_TIMEOUT               ENCODE_ERROR (18)
01055 
01056 ///
01057 /// The protocol has not been started.
01058 ///
01059 #define RETURN_NOT_STARTED           ENCODE_ERROR (19)
01060 
01061 ///
01062 /// The protocol has already been started.
01063 ///
01064 #define RETURN_ALREADY_STARTED       ENCODE_ERROR (20)
01065 
01066 ///
01067 /// The operation was aborted.
01068 ///
01069 #define RETURN_ABORTED               ENCODE_ERROR (21)
01070 
01071 ///
01072 /// An ICMP error occurred during the network operation.
01073 ///
01074 #define RETURN_ICMP_ERROR            ENCODE_ERROR (22)
01075 
01076 ///
01077 /// A TFTP error occurred during the network operation.
01078 ///
01079 #define RETURN_TFTP_ERROR            ENCODE_ERROR (23)
01080 
01081 ///
01082 /// A protocol error occurred during the network operation.
01083 ///
01084 #define RETURN_PROTOCOL_ERROR        ENCODE_ERROR (24)
01085 
01086 ///
01087 /// A function encountered an internal version that was
01088 /// incompatible with a version requested by the caller.
01089 ///
01090 #define RETURN_INCOMPATIBLE_VERSION  ENCODE_ERROR (25)
01091 
01092 ///
01093 /// The function was not performed due to a security violation.
01094 ///
01095 #define RETURN_SECURITY_VIOLATION    ENCODE_ERROR (26)
01096 
01097 ///
01098 /// A CRC error was detected.
01099 ///
01100 #define RETURN_CRC_ERROR             ENCODE_ERROR (27)
01101 
01102 ///
01103 /// The beginning or end of media was reached.
01104 ///
01105 #define RETURN_END_OF_MEDIA          ENCODE_ERROR (28)
01106 
01107 ///
01108 /// The end of the file was reached.
01109 ///
01110 #define RETURN_END_OF_FILE           ENCODE_ERROR (31)
01111 
01112 ///
01113 /// The language specified was invalid.
01114 ///
01115 #define RETURN_INVALID_LANGUAGE      ENCODE_ERROR (32)
01116 
01117 ///
01118 /// The security status of the data is unknown or compromised
01119 /// and the data must be updated or replaced to restore a valid
01120 /// security status.
01121 ///
01122 #define RETURN_COMPROMISED_DATA      ENCODE_ERROR (33)
01123 
01124 ///
01125 /// A HTTP error occurred during the network operation.
01126 ///
01127 #define RETURN_HTTP_ERROR            ENCODE_ERROR (35)
01128 
01129 ///
01130 /// The string contained one or more characters that
01131 /// the device could not render and were skipped.
01132 ///
01133 #define RETURN_WARN_UNKNOWN_GLYPH    ENCODE_WARNING (1)
01134 
01135 ///
01136 /// The handle was closed, but the file was not deleted.
01137 ///
01138 #define RETURN_WARN_DELETE_FAILURE   ENCODE_WARNING (2)
01139 
01140 ///
01141 /// The handle was closed, but the data to the file was not
01142 /// flushed properly.
01143 ///
01144 #define RETURN_WARN_WRITE_FAILURE    ENCODE_WARNING (3)
01145 
01146 ///
01147 /// The resulting buffer was too small, and the data was
01148 /// truncated to the buffer size.
01149 ///
01150 #define RETURN_WARN_BUFFER_TOO_SMALL ENCODE_WARNING (4)
01151 
01152 ///
01153 /// The data has not been updated within the timeframe set by
01154 /// local policy for this type of data.
01155 ///
01156 #define RETURN_WARN_STALE_DATA       ENCODE_WARNING (5)
01157 
01158 ///
01159 /// The resulting buffer contains UEFI-compliant file system.
01160 ///
01161 #define RETURN_WARN_FILE_SYSTEM      ENCODE_WARNING (6)
01162 
01163 
01164 /**
01165   Returns a 16-bit signature built from 2 ASCII characters.
01166 
01167   This macro returns a 16-bit value built from the two ASCII characters specified
01168   by A and B.
01169 
01170   @param  A    The first ASCII character.
01171   @param  B    The second ASCII character.
01172 
01173   @return A 16-bit value built from the two ASCII characters specified by A and B.
01174 
01175 **/
01176 #define SIGNATURE_16(A, B)        ((A) | (B << 8))
01177 
01178 /**
01179   Returns a 32-bit signature built from 4 ASCII characters.
01180 
01181   This macro returns a 32-bit value built from the four ASCII characters specified
01182   by A, B, C, and D.
01183 
01184   @param  A    The first ASCII character.
01185   @param  B    The second ASCII character.
01186   @param  C    The third ASCII character.
01187   @param  D    The fourth ASCII character.
01188 
01189   @return A 32-bit value built from the two ASCII characters specified by A, B,
01190           C and D.
01191 
01192 **/
01193 #define SIGNATURE_32(A, B, C, D)  (SIGNATURE_16 (A, B) | (SIGNATURE_16 (C, D) << 16))
01194 
01195 /**
01196   Returns a 64-bit signature built from 8 ASCII characters.
01197 
01198   This macro returns a 64-bit value built from the eight ASCII characters specified
01199   by A, B, C, D, E, F, G,and H.
01200 
01201   @param  A    The first ASCII character.
01202   @param  B    The second ASCII character.
01203   @param  C    The third ASCII character.
01204   @param  D    The fourth ASCII character.
01205   @param  E    The fifth ASCII character.
01206   @param  F    The sixth ASCII character.
01207   @param  G    The seventh ASCII character.
01208   @param  H    The eighth ASCII character.
01209 
01210   @return A 64-bit value built from the two ASCII characters specified by A, B,
01211           C, D, E, F, G and H.
01212 
01213 **/
01214 #define SIGNATURE_64(A, B, C, D, E, F, G, H) \
01215     (SIGNATURE_32 (A, B, C, D) | ((UINT64) (SIGNATURE_32 (E, F, G, H)) << 32))
01216 
01217 #if defined(_MSC_EXTENSIONS) && !defined (__INTEL_COMPILER) && !defined (MDE_CPU_EBC)
01218   #pragma intrinsic(_ReturnAddress)
01219   /**
01220     Get the return address of the calling function.
01221 
01222     Based on intrinsic function _ReturnAddress that provides the address of
01223     the instruction in the calling function that will be executed after
01224     control returns to the caller.
01225 
01226     @param L    Return Level.
01227 
01228     @return The return address of the calling function or 0 if L != 0.
01229 
01230   **/
01231   #define RETURN_ADDRESS(L)     ((L == 0) ? _ReturnAddress() : (VOID *) 0)
01232 #elif defined(__GNUC__)
01233   void * __builtin_return_address (unsigned int level);
01234   /**
01235     Get the return address of the calling function.
01236 
01237     Based on built-in Function __builtin_return_address that returns
01238     the return address of the current function, or of one of its callers.
01239 
01240     @param L    Return Level.
01241 
01242     @return The return address of the calling function.
01243 
01244   **/
01245   #define RETURN_ADDRESS(L)     __builtin_return_address (L)
01246 #else
01247   /**
01248     Get the return address of the calling function.
01249 
01250     @param L    Return Level.
01251 
01252     @return 0 as compilers don't support this feature.
01253 
01254   **/
01255   #define RETURN_ADDRESS(L)     ((VOID *) 0)
01256 #endif
01257 
01258 /**
01259   Return the number of elements in an array.
01260 
01261   @param  Array  An object of array type. Array is only used as an argument to
01262                  the sizeof operator, therefore Array is never evaluated. The
01263                  caller is responsible for ensuring that Array's type is not
01264                  incomplete; that is, Array must have known constant size.
01265 
01266   @return The number of elements in Array. The result has type UINTN.
01267 
01268 **/
01269 #define ARRAY_SIZE(Array) (sizeof (Array) / sizeof ((Array)[0]))
01270 
01271 #endif
01272