iPXE
UefiBaseType.h
Go to the documentation of this file.
00001 /** @file
00002   Defines data types and constants introduced in UEFI.
00003 
00004 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
00005 Portions copyright (c) 2011 - 2016, ARM Ltd. All rights reserved.<BR>
00006 
00007 This program and the accompanying materials are licensed and made available under
00008 the terms and conditions of the BSD License that accompanies this distribution.
00009 The full text of the license may be found at
00010 http://opensource.org/licenses/bsd-license.php.
00011 
00012 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
00013 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
00014 
00015 **/
00016 
00017 #ifndef __UEFI_BASETYPE_H__
00018 #define __UEFI_BASETYPE_H__
00019 
00020 FILE_LICENCE ( BSD3 );
00021 
00022 #include <ipxe/efi/Base.h>
00023 
00024 //
00025 // Basic data type definitions introduced in UEFI.
00026 //
00027 
00028 ///
00029 /// 128-bit buffer containing a unique identifier value.
00030 ///
00031 typedef GUID                      EFI_GUID;
00032 ///
00033 /// Function return status for EFI API.
00034 ///
00035 typedef RETURN_STATUS             EFI_STATUS;
00036 ///
00037 /// A collection of related interfaces.
00038 ///
00039 typedef VOID                      *EFI_HANDLE;
00040 ///
00041 /// Handle to an event structure.
00042 ///
00043 typedef VOID                      *EFI_EVENT;
00044 ///
00045 /// Task priority level.
00046 ///
00047 typedef UINTN                     EFI_TPL;
00048 ///
00049 /// Logical block address.
00050 ///
00051 typedef UINT64                    EFI_LBA;
00052 
00053 ///
00054 /// 64-bit physical memory address.
00055 ///
00056 typedef UINT64                    EFI_PHYSICAL_ADDRESS;
00057 
00058 ///
00059 /// 64-bit virtual memory address.
00060 ///
00061 typedef UINT64                    EFI_VIRTUAL_ADDRESS;
00062 
00063 ///
00064 /// EFI Time Abstraction:
00065 ///  Year:       1900 - 9999
00066 ///  Month:      1 - 12
00067 ///  Day:        1 - 31
00068 ///  Hour:       0 - 23
00069 ///  Minute:     0 - 59
00070 ///  Second:     0 - 59
00071 ///  Nanosecond: 0 - 999,999,999
00072 ///  TimeZone:   -1440 to 1440 or 2047
00073 ///
00074 typedef struct {
00075   UINT16  Year;
00076   UINT8   Month;
00077   UINT8   Day;
00078   UINT8   Hour;
00079   UINT8   Minute;
00080   UINT8   Second;
00081   UINT8   Pad1;
00082   UINT32  Nanosecond;
00083   INT16   TimeZone;
00084   UINT8   Daylight;
00085   UINT8   Pad2;
00086 } EFI_TIME;
00087 
00088 
00089 ///
00090 /// 4-byte buffer. An IPv4 internet protocol address.
00091 ///
00092 typedef IPv4_ADDRESS EFI_IPv4_ADDRESS;
00093 
00094 ///
00095 /// 16-byte buffer. An IPv6 internet protocol address.
00096 ///
00097 typedef IPv6_ADDRESS EFI_IPv6_ADDRESS;
00098 
00099 ///
00100 /// 32-byte buffer containing a network Media Access Control address.
00101 ///
00102 typedef struct {
00103   UINT8 Addr[32];
00104 } EFI_MAC_ADDRESS;
00105 
00106 ///
00107 /// 16-byte buffer aligned on a 4-byte boundary.
00108 /// An IPv4 or IPv6 internet protocol address.
00109 ///
00110 typedef union {
00111   UINT32            Addr[4];
00112   EFI_IPv4_ADDRESS  v4;
00113   EFI_IPv6_ADDRESS  v6;
00114 } EFI_IP_ADDRESS;
00115 
00116 
00117 ///
00118 /// Enumeration of EFI_STATUS.
00119 ///@{
00120 #define EFI_SUCCESS               RETURN_SUCCESS
00121 #define EFI_LOAD_ERROR            RETURN_LOAD_ERROR
00122 #define EFI_INVALID_PARAMETER     RETURN_INVALID_PARAMETER
00123 #define EFI_UNSUPPORTED           RETURN_UNSUPPORTED
00124 #define EFI_BAD_BUFFER_SIZE       RETURN_BAD_BUFFER_SIZE
00125 #define EFI_BUFFER_TOO_SMALL      RETURN_BUFFER_TOO_SMALL
00126 #define EFI_NOT_READY             RETURN_NOT_READY
00127 #define EFI_DEVICE_ERROR          RETURN_DEVICE_ERROR
00128 #define EFI_WRITE_PROTECTED       RETURN_WRITE_PROTECTED
00129 #define EFI_OUT_OF_RESOURCES      RETURN_OUT_OF_RESOURCES
00130 #define EFI_VOLUME_CORRUPTED      RETURN_VOLUME_CORRUPTED
00131 #define EFI_VOLUME_FULL           RETURN_VOLUME_FULL
00132 #define EFI_NO_MEDIA              RETURN_NO_MEDIA
00133 #define EFI_MEDIA_CHANGED         RETURN_MEDIA_CHANGED
00134 #define EFI_NOT_FOUND             RETURN_NOT_FOUND
00135 #define EFI_ACCESS_DENIED         RETURN_ACCESS_DENIED
00136 #define EFI_NO_RESPONSE           RETURN_NO_RESPONSE
00137 #define EFI_NO_MAPPING            RETURN_NO_MAPPING
00138 #define EFI_TIMEOUT               RETURN_TIMEOUT
00139 #define EFI_NOT_STARTED           RETURN_NOT_STARTED
00140 #define EFI_ALREADY_STARTED       RETURN_ALREADY_STARTED
00141 #define EFI_ABORTED               RETURN_ABORTED
00142 #define EFI_ICMP_ERROR            RETURN_ICMP_ERROR
00143 #define EFI_TFTP_ERROR            RETURN_TFTP_ERROR
00144 #define EFI_PROTOCOL_ERROR        RETURN_PROTOCOL_ERROR
00145 #define EFI_INCOMPATIBLE_VERSION  RETURN_INCOMPATIBLE_VERSION
00146 #define EFI_SECURITY_VIOLATION    RETURN_SECURITY_VIOLATION
00147 #define EFI_CRC_ERROR             RETURN_CRC_ERROR
00148 #define EFI_END_OF_MEDIA          RETURN_END_OF_MEDIA
00149 #define EFI_END_OF_FILE           RETURN_END_OF_FILE
00150 #define EFI_INVALID_LANGUAGE      RETURN_INVALID_LANGUAGE
00151 #define EFI_COMPROMISED_DATA      RETURN_COMPROMISED_DATA
00152 #define EFI_HTTP_ERROR            RETURN_HTTP_ERROR
00153 
00154 #define EFI_WARN_UNKNOWN_GLYPH    RETURN_WARN_UNKNOWN_GLYPH
00155 #define EFI_WARN_DELETE_FAILURE   RETURN_WARN_DELETE_FAILURE
00156 #define EFI_WARN_WRITE_FAILURE    RETURN_WARN_WRITE_FAILURE
00157 #define EFI_WARN_BUFFER_TOO_SMALL RETURN_WARN_BUFFER_TOO_SMALL
00158 #define EFI_WARN_STALE_DATA       RETURN_WARN_STALE_DATA
00159 #define EFI_WARN_FILE_SYSTEM      RETURN_WARN_FILE_SYSTEM
00160 ///@}
00161 
00162 ///
00163 /// Define macro to encode the status code.
00164 ///
00165 #define EFIERR(_a)                ENCODE_ERROR(_a)
00166 
00167 #define EFI_ERROR(A)              RETURN_ERROR(A)
00168 
00169 ///
00170 /// ICMP error definitions
00171 ///@{
00172 #define EFI_NETWORK_UNREACHABLE   EFIERR(100)
00173 #define EFI_HOST_UNREACHABLE      EFIERR(101)
00174 #define EFI_PROTOCOL_UNREACHABLE  EFIERR(102)
00175 #define EFI_PORT_UNREACHABLE      EFIERR(103)
00176 ///@}
00177 
00178 ///
00179 /// Tcp connection status definitions
00180 ///@{
00181 #define EFI_CONNECTION_FIN        EFIERR(104)
00182 #define EFI_CONNECTION_RESET      EFIERR(105)
00183 #define EFI_CONNECTION_REFUSED    EFIERR(106)
00184 ///@}
00185 
00186 //
00187 // The EFI memory allocation functions work in units of EFI_PAGEs that are
00188 // 4KB. This should in no way be confused with the page size of the processor.
00189 // An EFI_PAGE is just the quanta of memory in EFI.
00190 //
00191 #define EFI_PAGE_SIZE             SIZE_4KB
00192 #define EFI_PAGE_MASK             0xFFF
00193 #define EFI_PAGE_SHIFT            12
00194 
00195 /**
00196   Macro that converts a size, in bytes, to a number of EFI_PAGESs.
00197 
00198   @param  Size      A size in bytes.  This parameter is assumed to be type UINTN.
00199                     Passing in a parameter that is larger than UINTN may produce
00200                     unexpected results.
00201 
00202   @return  The number of EFI_PAGESs associated with the number of bytes specified
00203            by Size.
00204 
00205 **/
00206 #define EFI_SIZE_TO_PAGES(Size)  (((Size) >> EFI_PAGE_SHIFT) + (((Size) & EFI_PAGE_MASK) ? 1 : 0))
00207 
00208 /**
00209   Macro that converts a number of EFI_PAGEs to a size in bytes.
00210 
00211   @param  Pages     The number of EFI_PAGES.  This parameter is assumed to be
00212                     type UINTN.  Passing in a parameter that is larger than
00213                     UINTN may produce unexpected results.
00214 
00215   @return  The number of bytes associated with the number of EFI_PAGEs specified
00216            by Pages.
00217 
00218 **/
00219 #define EFI_PAGES_TO_SIZE(Pages)  ((Pages) << EFI_PAGE_SHIFT)
00220 
00221 ///
00222 /// PE32+ Machine type for IA32 UEFI images.
00223 ///
00224 #define EFI_IMAGE_MACHINE_IA32            0x014C
00225 
00226 ///
00227 /// PE32+ Machine type for IA64 UEFI images.
00228 ///
00229 #define EFI_IMAGE_MACHINE_IA64            0x0200
00230 
00231 ///
00232 /// PE32+ Machine type for EBC UEFI images.
00233 ///
00234 #define EFI_IMAGE_MACHINE_EBC             0x0EBC
00235 
00236 ///
00237 /// PE32+ Machine type for X64 UEFI images.
00238 ///
00239 #define EFI_IMAGE_MACHINE_X64             0x8664
00240 
00241 ///
00242 /// PE32+ Machine type for ARM mixed ARM and Thumb/Thumb2 images.
00243 ///
00244 #define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED  0x01C2
00245 
00246 ///
00247 /// PE32+ Machine type for AARCH64 A64 images.
00248 ///
00249 #define EFI_IMAGE_MACHINE_AARCH64  0xAA64
00250 
00251 
00252 #if   defined (MDE_CPU_IA32)
00253 
00254 #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
00255   (((Machine) == EFI_IMAGE_MACHINE_IA32) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
00256 
00257 #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_X64)
00258 
00259 #elif defined (MDE_CPU_IPF)
00260 
00261 #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
00262   (((Machine) == EFI_IMAGE_MACHINE_IA64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
00263 
00264 #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE)
00265 
00266 #elif defined (MDE_CPU_X64)
00267 
00268 #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
00269   (((Machine) == EFI_IMAGE_MACHINE_X64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
00270 
00271 #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_IA32)
00272 
00273 #elif defined (MDE_CPU_ARM)
00274 
00275 #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
00276   (((Machine) == EFI_IMAGE_MACHINE_ARMTHUMB_MIXED) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
00277 
00278 #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_ARMTHUMB_MIXED)
00279 
00280 #elif defined (MDE_CPU_AARCH64)
00281 
00282 #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
00283   (((Machine) == EFI_IMAGE_MACHINE_AARCH64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
00284 
00285 #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE)
00286 
00287 #elif defined (MDE_CPU_EBC)
00288 
00289 ///
00290 /// This is just to make sure you can cross compile with the EBC compiler.
00291 /// It does not make sense to have a PE loader coded in EBC.
00292 ///
00293 #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_EBC)
00294 
00295 #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE)
00296 
00297 #else
00298 #error Unknown Processor Type
00299 #endif
00300 
00301 #endif