From 4cadbff15541ca09ced3321acfdf302fced29ee9 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 29 Jan 2024 19:54:04 +0100 Subject: NewBoot: Working on EFI implementation to load kernel into memory... Signed-off-by: Amlal El Mahrouss --- Private/EFIKit/EFI.hxx | 538 ++++++++++++++++++--------- Private/Linker/Platforms/PC.lds | 2 +- Private/NewBoot/BootKit/Protocol.hxx | 38 +- Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx | 26 +- Private/NewKit/Macros.hpp | 46 ++- 5 files changed, 419 insertions(+), 231 deletions(-) (limited to 'Private') diff --git a/Private/EFIKit/EFI.hxx b/Private/EFIKit/EFI.hxx index fd4e31aa..879bd7d0 100644 --- a/Private/EFIKit/EFI.hxx +++ b/Private/EFIKit/EFI.hxx @@ -12,222 +12,387 @@ /** @brief HCore Implementation of UEFI protocols. +@author Amlal El Mahrouss */ #include +#include using namespace hCore; -typedef VoidPtr EfiHandlePtr; +// Forwar decls struct EfiTableHeader; struct EfiLoadFileProtocol; struct EfiSimpleTextOutputProtocol; struct EfiDevicePathProtocol; struct EfiBootServices; +struct EfiMemoryDescriptor; +struct EfiSystemTable; + +// Types + +typedef struct { +} *EfiHandlePtr; + +typedef WideChar EfiCharType; /// What's BootBolicy? -/// If TRUE, indicates that the request originates from the boot manager, and that the boot manager is attempting to -/// load FilePath as a boot selection. If FALSE, then FilePath must match an exact file to be loaded. - -typedef UInt64 (*EfiTextString)(struct EfiSimpleTextOutputProtocol *This, const WideChar *OutputString); -typedef UInt64 (*EfiLoadFile)(EfiLoadFileProtocol *This, EfiDevicePathProtocol *FilePath, Boolean BootPolicy, - UInt32 *BufferSize, Void *Buffer); - -/// EFI pool helpers - -typedef enum EfiMemoryType -{ - /// - /// Not used. - /// - EfiReservedMemoryType, - /// - /// The code portions of a loaded application. - /// (Note that UEFI OS loaders are UEFI applications.) - /// - EfiLoaderCode, - /// - /// The data portions of a loaded application and the default data allocation - /// type used by an application to allocate pool memory. - /// - EfiLoaderData, - /// - /// The code portions of a loaded Boot Services Driver. - /// - EfiBootServicesCode, - /// - /// The data portions of a loaded Boot Serves Driver, and the default data - /// allocation type used by a Boot Services Driver to allocate pool memory. - /// - EfiBootServicesData, - /// - /// The code portions of a loaded Runtime Services Driver. - /// - EfiRuntimeServicesCode, - /// - /// The data portions of a loaded Runtime Services Driver and the default - /// data allocation type used by a Runtime Services Driver to allocate pool memory. - /// - EfiRuntimeServicesData, - /// - /// Free (unallocated) memory. - /// - EfiConventionalMemory, - /// - /// Memory in which errors have been detected. - /// - EfiUnusableMemory, - /// - /// Memory that holds the ACPI tables. - /// - EfiACPIReclaimMemory, - /// - /// Address space reserved for use by the firmware. - /// - EfiACPIMemoryNVS, - /// - /// Used by system firmware to request that a memory-mapped IO region - /// be mapped by the OS to a virtual address so it can be accessed by EFI runtime services. - /// - EfiMemoryMappedIO, - /// - /// System memory-mapped IO region that is used to translate memory - /// cycles to IO cycles by the processor. - /// - EfiMemoryMappedIOPortSpace, - /// - /// Address space reserved by the firmware for code that is part of the processor. - /// - EfiPalCode, - /// - /// A memory region that operates as EfiConventionalMemory, - /// however it happens to also support byte-addressable non-volatility. - /// - EfiPersistentMemory, - /// - /// A memory region that describes system memory that has not been accepted - /// by a corresponding call to the underlying isolation architecture. - /// - EfiUnacceptedMemoryType, - /// - /// The last type of memory. - /// Not a real type. - /// - EfiMaxMemoryType, +/// If TRUE, indicates that the request originates from the boot manager, and +/// that the boot manager is attempting to load FilePath as a boot selection. If +/// FALSE, then FilePath must match an exact file to be loaded. + +typedef UInt64 (*EfiTextString)(struct EfiSimpleTextOutputProtocol *This, + const WideChar *OutputString); + +typedef UInt64 (*EfiLoadFile)(EfiLoadFileProtocol *This, + EfiDevicePathProtocol *FilePath, + Boolean BootPolicy, UInt32 *BufferSize, + Void *Buffer); + +typedef UInt64 (*EfiCopyMem)(VoidPtr DstBuf, VoidPtr SrcBuf, SizeT Length); +typedef UInt64 (*EfiSetMem)(VoidPtr DstBuf, Char Byte, SizeT Length); + +/// EFI pool helpers, taken from iPXE. + +typedef enum EfiMemoryType { + /// + /// Not used. + /// + EfiReservedMemoryType, + /// + /// The code portions of a loaded application. + /// (Note that UEFI OS loaders are UEFI applications.) + /// + EfiLoaderCode, + /// + /// The data portions of a loaded application and the default data allocation + /// type used by an application to allocate pool memory. + /// + EfiLoaderData, + /// + /// The code portions of a loaded Boot Services Driver. + /// + EfiBootServicesCode, + /// + /// The data portions of a loaded Boot Serves Driver, and the default data + /// allocation type used by a Boot Services Driver to allocate pool memory. + /// + EfiBootServicesData, + /// + /// The code portions of a loaded Runtime Services Driver. + /// + EfiRuntimeServicesCode, + /// + /// The data portions of a loaded Runtime Services Driver and the default + /// data allocation type used by a Runtime Services Driver to allocate pool + /// memory. + /// + EfiRuntimeServicesData, + /// + /// Free (unallocated) memory. + /// + EfiConventionalMemory, + /// + /// Memory in which errors have been detected. + /// + EfiUnusableMemory, + /// + /// Memory that holds the ACPI tables. + /// + EfiACPIReclaimMemory, + /// + /// Address space reserved for use by the firmware. + /// + EfiACPIMemoryNVS, + /// + /// Used by system firmware to request that a memory-mapped IO region + /// be mapped by the OS to a virtual address so it can be accessed by EFI + /// runtime services. + /// + EfiMemoryMappedIO, + /// + /// System memory-mapped IO region that is used to translate memory + /// cycles to IO cycles by the processor. + /// + EfiMemoryMappedIOPortSpace, + /// + /// Address space reserved by the firmware for code that is part of the + /// processor. + /// + EfiPalCode, + /// + /// A memory region that operates as EfiConventionalMemory, + /// however it happens to also support byte-addressable non-volatility. + /// + EfiPersistentMemory, + /// + /// A memory region that describes system memory that has not been accepted + /// by a corresponding call to the underlying isolation architecture. + /// + EfiUnacceptedMemoryType, + /// + /// The last type of memory. + /// Not a real type. + /// + EfiMaxMemoryType, } EfiMemoryType; -typedef UInt64 (*EfiAllocatePool)(EfiMemoryType PoolType, UInt32 Size, VoidPtr *Buffer); +typedef enum EfiAllocateType { + /// Anything that satisfy the request. + AllocateAnyPages, + AllocateMaxAddress, + /// + /// Allocate pages at a specified address. + /// + AllocateAddress, + /// + /// Maximum enumeration value that may be used for bounds checking. + /// + MaxAllocateType +} EfiAllocateType; + +typedef struct EfiMemoryDescriptor { + /// + /// Type of the memory region. + /// Type EFI_MEMORY_TYPE is defined in the + /// AllocatePages() function description. + /// + UInt32 Type; + /// + /// Physical address of the first byte in the memory region. PhysicalStart + /// must be aligned on a 4 KiB boundary, and must not be above + /// 0xfffffffffffff000. Type EFI_PHYSICAL_ADDRESS is defined in the + /// AllocatePages() function description + /// + UIntPtr PhysicalStart; + /// + /// Virtual address of the first byte in the memory region. + /// VirtualStart must be aligned on a 4 KiB boundary, + /// and must not be above 0xfffffffffffff000. + /// + UIntPtr VirtualStart; + /// + /// NumberOfPagesNumber of 4 KiB pages in the memory region. + /// NumberOfPages must not be 0, and must not be any value + /// that would represent a memory page with a start address, + /// either physical or virtual, above 0xfffffffffffff000. + /// + UInt64 NumberOfPages; + /// + /// Attributes of the memory region that describe the bit mask of capabilities + /// for that memory region, and not necessarily the current settings for that + /// memory region. + /// + UInt64 Attribute; +} EfiMemoryDescriptor; + +typedef UInt64 (*EfiAllocatePool)(EfiMemoryType PoolType, UInt32 Size, + VoidPtr *Buffer); + typedef UInt64 (*EfiFreePool)(VoidPtr Buffer); -typedef struct EfiTableHeader -{ - UInt64 Signature; - UInt32 Revision; - UInt32 HeaderSize; - UInt32 Crc32; - UInt32 Reserved; +typedef UInt64 (*EfiCalculateCrc32)(VoidPtr Data, UInt32 DataSize, + UInt32 *CrcOut); + +/** +@brief Present in every header, used to identify a UEFI structure. +*/ +typedef struct EfiTableHeader { + UInt64 Signature; + UInt32 Revision; + UInt32 HeaderSize; + UInt32 Crc32; + UInt32 Reserved; } EfiTableHeader; -typedef struct EfiLoadFileProtocol -{ - EfiLoadFile LoadFile; +#define EFI_LOAD_FILE_PROTOCOL_GUID \ + { \ + 0x56EC3091, 0x954C, 0x11d2, { \ + 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b \ + } \ + } + +#define EFI_LOADED_IMAGE_PROTOCOL_GUID \ + { \ + 0x5B1B31A1, 0x9562, 0x11d2, { \ + 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B \ + } \ + } + +#define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000 + +#define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \ + { \ + 0xbc62157e, 0x3e33, 0x4fec, { \ + 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf \ + } \ + } + +typedef UInt64(EfiImageUnload)(EfiHandlePtr ImageHandle); + +typedef struct EfiLoadImageProtocol { + UInt32 Revision; + EfiHandlePtr ParentHandle; + EfiSystemTable *SystemTable; + + // Source location of the image + EfiHandlePtr DeviceHandle; + EfiDevicePathProtocol *FilePath; + Void *Reserved; + + // Image’s load options + UInt32 LoadOptionsSize; + Void *LoadOptions; + + // Location where image was loaded + Void *ImageBase; + UInt64 ImageSize; + EfiMemoryType ImageCodeType; + EfiMemoryType ImageDataType; + EfiImageUnload Unload; +} EfiLoadImageProtocol; + +typedef struct EfiLoadFileProtocol { + EfiLoadFile LoadFile; } EfiLoadFileProtocol; -typedef struct EfiDevicePathProtocol -{ - UInt8 Type; - UInt8 SubType; - UInt8 LengthData[2]; +typedef struct EfiDevicePathProtocol { + UInt8 Type; + UInt8 SubType; + UInt8 LengthData[2]; } EfiDevicePathProtocol; +typedef UInt64 EfiPhysicalAddress; +typedef UIntPtr EfiVirtualAddress; + typedef UInt64 (*EfiExitBootServices)(VoidPtr ImageHandle, UInt32 MapKey); +typedef UInt64 (*EfiAllocatePages)(EfiAllocateType AllocType, + EfiMemoryType MemType, + EfiPhysicalAddress *Memory); + +typedef UInt64 (*EfiFreePages)(EfiPhysicalAddress *Memory, UInt32 Pages); + +/** + * @brief GUID type, something you can also find in CFKit. + */ +typedef struct EfiGUID { + UInt32 Data1; + UInt16 Data2; + UInt16 Data3; + UInt8 Data4[8]; +} EfiGUID; + +/*** + * Protocol stuff... + */ + +/** some helpers */ +#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 +#define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002 +#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004 +#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008 +#define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010 +#define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020 + +typedef UInt64 (*EfiLocateProtocol)(EfiGUID *Protocol, VoidPtr Registration, + VoidPtr *Interface); + +typedef UInt64 (*EfiOpenProtocol)(EfiHandlePtr Handle, EfiGUID *Guid, + VoidPtr *Interface, EfiHandlePtr AgentHandle, + EfiHandlePtr ControllerHandle, + UInt32 Attributes); + /** @name EfiBootServices -@brief UEFI Boot Services record, it contains functions necessary to a firmware level application. +@brief UEFI Boot Services record, it contains functions necessary to a +firmware level application. */ -typedef struct EfiBootServices -{ - EfiTableHeader SystemTable; - UIntPtr RaiseTPL; - UIntPtr RestoreTPL; - UIntPtr AllocatePages; - UIntPtr FreePages; - UIntPtr GetMemoryMap; - EfiAllocatePool AllocatePool; - EfiFreePool FreePool; - UIntPtr CreateEvent; - UIntPtr SetTimer; - UIntPtr WaitForEvent; - UIntPtr SignalEvent; - UIntPtr CloseEvent; - UIntPtr CheckEvent; - UIntPtr InstallProtocolInterface; - UIntPtr ReinstallProtocolInterface; - UIntPtr UninstallProtocolInterface; - UIntPtr HandleProtocol; - VoidPtr Reserved; - UIntPtr RegisterProtocolNotify; - UIntPtr LocateHandle; - UIntPtr LocateDevicePath; - UIntPtr InstallConfigurationTable; - UIntPtr LoadImage; - UIntPtr StartImage; - UIntPtr Exit; - UIntPtr UnloadImage; - EfiExitBootServices ExitBootServices; - UIntPtr GetNextMonotonicCount; - UIntPtr Stall; - UIntPtr SetWatchdogTimer; - UIntPtr ConnectController; - UIntPtr DisconnectController; - UIntPtr OpenProtocol; - UIntPtr CloseProtocol; - UIntPtr OpenProtocolInformation; - UIntPtr ProtocolsPerHandle; - UIntPtr LocateHandleBuffer; - UIntPtr LocateProtocol; - UIntPtr InstallMultipleProtocolInterfaces; - UIntPtr UninstallMultipleProtocolInterfaces; - UIntPtr CalculateCrc32; - UIntPtr CopyMem; - UIntPtr SetMem; - UIntPtr CreateEventEx; +typedef struct EfiBootServices { + EfiTableHeader SystemTable; + UIntPtr RaiseTPL; + UIntPtr RestoreTPL; + EfiAllocatePages AllocatePages; + EfiFreePages FreePages; + UIntPtr GetMemoryMap; + EfiAllocatePool AllocatePool; + EfiFreePool FreePool; + UIntPtr CreateEvent; + UIntPtr SetTimer; + UIntPtr WaitForEvent; + UIntPtr SignalEvent; + UIntPtr CloseEvent; + UIntPtr CheckEvent; + UIntPtr InstallProtocolInterface; + UIntPtr ReinstallProtocolInterface; + UIntPtr UninstallProtocolInterface; + UIntPtr HandleProtocol; + VoidPtr Reserved; + UIntPtr RegisterProtocolNotify; + UIntPtr LocateHandle; + UIntPtr LocateDevicePath; + UIntPtr InstallConfigurationTable; + UIntPtr LoadImage; + UIntPtr StartImage; + UIntPtr Exit; + UIntPtr UnloadImage; + EfiExitBootServices ExitBootServices; + UIntPtr GetNextMonotonicCount; + UIntPtr Stall; + UIntPtr SetWatchdogTimer; + UIntPtr ConnectController; + UIntPtr DisconnectController; + EfiOpenProtocol OpenProtocol; + UIntPtr CloseProtocol; + UIntPtr OpenProtocolInformation; + UIntPtr ProtocolsPerHandle; + UIntPtr LocateHandleBuffer; + EfiLocateProtocol LocateProtocol; + UIntPtr InstallMultipleProtocolInterfaces; + UIntPtr UninstallMultipleProtocolInterfaces; + EfiCalculateCrc32 CalculateCrc32; + EfiCopyMem CopyMem; + EfiSetMem SetMem; + UIntPtr CreateEventEx; } EfiBootServices; #define kEntireDevPath 0xFF #define kThisInstancePath 0x01 -typedef struct EfiSimpleTextOutputProtocol -{ - UInt64 Reset; - EfiTextString OutputString; - UInt64 TestString; - UInt64 QueryMode; - UInt64 SetMode; - UInt64 SetAttribute; - UInt64 ClearScreen; - UInt64 SetCursorPosition; - UInt64 EnableCursor; - UInt64 Mode; +/** +@brief PrintF like protocol. +*/ +typedef struct EfiSimpleTextOutputProtocol { + UInt64 Reset; + EfiTextString OutputString; + UInt64 TestString; + UInt64 QueryMode; + UInt64 SetMode; + UInt64 SetAttribute; + UInt64 ClearScreen; + UInt64 SetCursorPosition; + UInt64 EnableCursor; + UInt64 Mode; } EfiSimpleTextOutputProtocol; -typedef struct EfiSystemTable -{ - EfiTableHeader SystemHeader; - WideChar *FirmwareVendor; - UInt32 FirmwareRevision; - VoidPtr ConsoleInHandle; - UInt64 ConIn; - VoidPtr ConsoleOutHandle; - EfiSimpleTextOutputProtocol *ConOut; - VoidPtr StandardErrorHandle; - UInt64 StdErr; - UInt64 RuntimeServices; - EfiBootServices *BootServices; - UInt64 NumberOfTableEntries; - UInt64 ConfigurationTable; +/** +@brief The Structure that they give you when booting. +*/ +typedef struct EfiSystemTable { + EfiTableHeader SystemHeader; + WideChar *FirmwareVendor; + UInt32 FirmwareRevision; + VoidPtr ConsoleInHandle; + UInt64 ConIn; + VoidPtr ConsoleOutHandle; + EfiSimpleTextOutputProtocol *ConOut; + VoidPtr StandardErrorHandle; + UInt64 StdErr; + UInt64 RuntimeServices; + EfiBootServices *BootServices; + UInt64 NumberOfTableEntries; + UInt64 ConfigurationTable; } EfiSystemTable; #define EfiMain efi_main @@ -237,4 +402,15 @@ typedef struct EfiSystemTable #define EFI_EXTERN_C extern "C" -#endif // __EFI__ +typedef struct EfiIPV4 { + UInt8 Addr[4]; +} EfiIPV4; + +/// +/// 16-byte buffer. An IPv6 internet protocol address. +/// +typedef struct EfiIPV6 { + UInt8 Addr[16]; +} EfiIPV6; + +#endif // __EFI__ diff --git a/Private/Linker/Platforms/PC.lds b/Private/Linker/Platforms/PC.lds index 77d237e2..88587e4c 100644 --- a/Private/Linker/Platforms/PC.lds +++ b/Private/Linker/Platforms/PC.lds @@ -10,7 +10,7 @@ PHDRS { } SECTIONS { - . = 0x10000000; + . = 0x80000000; .text : { *(.NewBoot) diff --git a/Private/NewBoot/BootKit/Protocol.hxx b/Private/NewBoot/BootKit/Protocol.hxx index c2dc1a9d..68b837b4 100644 --- a/Private/NewBoot/BootKit/Protocol.hxx +++ b/Private/NewBoot/BootKit/Protocol.hxx @@ -11,41 +11,35 @@ #include -namespace HEL -{ -using namespace hCore; - +namespace hCore::HEL { /** @brief the kind of executable we're loading. */ -enum -{ - kTypeKernel = 100, - kTypeKernelDriver = 101, - kTypeRsrc = 102, - kTypeCount = 3, +enum { + kTypeKernel = 100, + kTypeKernelDriver = 101, + kTypeRsrc = 102, + kTypeCount = 3, }; /** @brief The executable architecture. */ -enum -{ - kArchAmd64 = 122, - kArchCount = 2, +enum { + kArchAmd64 = 122, + kArchCount = 2, }; -struct __attribute__((packed)) HandoverHeader final -{ - Int32 targetMagic; - Int32 targetType; - Int32 targetArch; - UIntPtr protocolHeaderTable; +struct __attribute__((packed)) HandoverHeader final { + Int32 targetMagic; + Int32 targetType; + Int32 targetArch; + UIntPtr startAddress; }; -} // namespace HEL +} // namespace hCore::HEL #define kHandoverMagic 0xBAD55 -#define kBaseHandoverStruct 0x10000000 +#define kBaseHandoverStruct 0x80000000 #define kHandoverStructSz sizeof(HEL::HandoverHeader) diff --git a/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx b/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx index 0d44086b..9174293e 100644 --- a/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx @@ -11,13 +11,33 @@ #include #include +// don't remove EfiGUID, it will call initializer_list! + EFI_EXTERN_C int EfiMain(EfiHandlePtr ImageHandle, - EfiSystemTable *SystemTable) { + EfiSystemTable* SystemTable) { SystemTable->ConOut->OutputString(SystemTable->ConOut, L"HCoreLdr: Starting \\EPM\\HCore...\r\n"); - if (SystemTable->BootServices->ExitBootServices( - ImageHandle, kBaseHandoverStruct) != kEfiOk) { + EfiLoadImageProtocol* protocol{}; + + EfiGUID guid = EfiGUID EFI_LOADED_IMAGE_PROTOCOL_GUID; + + SystemTable->BootServices->LocateProtocol(&guid, nullptr, + (VoidPtr*)&protocol); + + if (!protocol) { + SystemTable->ConOut->OutputString( + SystemTable->ConOut, + L"HCoreLdr: Could not locate EfiLoadImageProtocol! Aborting...\r\n"); + + return kEfiFail; + } + + SystemTable->BootServices->OpenProtocol( + ImageHandle, &guid, (VoidPtr*)&protocol, ImageHandle, ImageHandle, + EFI_OPEN_PROTOCOL_GET_PROTOCOL); + + if (SystemTable->BootServices->ExitBootServices(ImageHandle, 0) != kEfiOk) { SystemTable->ConOut->OutputString( SystemTable->ConOut, L"HCoreLdr: Could not Exit UEFI!\r\nHanging...\r\n"); diff --git a/Private/NewKit/Macros.hpp b/Private/NewKit/Macros.hpp index a6cb58dc..6f72dadd 100644 --- a/Private/NewKit/Macros.hpp +++ b/Private/NewKit/Macros.hpp @@ -10,62 +10,58 @@ #pragma once #ifndef KIB -# define KIB(X) ((X)*1024) +#define KIB(X) ((X) * 1024) #endif #ifndef MIB -# define MIB(X) (KIB(X) * 1024) +#define MIB(X) (KIB(X) * 1024) #endif #ifndef GIB -# define GIB(X) (MIB(X) * 1024) +#define GIB(X) (MIB(X) * 1024) #endif #ifndef TIB -# define TIB(X) (GIB(X) * 1024) +#define TIB(X) (GIB(X) * 1024) #endif #ifndef ARRAY_SIZE -#define ARRAY_SIZE(a) (((sizeof(a) / sizeof(*(a))) / (static_cast(!(sizeof(a) % sizeof(*(a))))))) +#define ARRAY_SIZE(a) \ + (((sizeof(a) / sizeof(*(a))) / \ + (static_cast(!(sizeof(a) % sizeof(*(a))))))) #endif #ifndef ALIGN #define ALIGN(X) __attribute__((aligned(X))) -#endif // #ifndef ALIGN +#endif // #ifndef ALIGN #ifndef ATTRIBUTE #define ATTRIBUTE(X) __attribute__((X)) -#endif // #ifndef ATTRIBUTE +#endif // #ifndef ATTRIBUTE #ifndef __HCORE__ #define __HCORE__ (202401) -#endif // !__HCORE__ +#endif // !__HCORE__ #ifndef EXTERN_C -#define EXTERN_C() \ - extern "C" \ - { -#define END_EXTERN_C() \ - } \ - ; +#define EXTERN_C() extern "C" { +#define END_EXTERN_C() \ + } \ + ; #endif #ifndef MAKE_ENUM -#define MAKE_ENUM(NAME) \ - enum NAME \ - { +#define MAKE_ENUM(NAME) enum NAME { #endif #ifndef END_ENUM -#define END_ENUM() \ - } \ - ; +#define END_ENUM() \ + } \ + ; #endif #ifndef MAKE_STRING_ENUM -#define MAKE_STRING_ENUM(NAME) \ - namespace NAME \ - { +#define MAKE_STRING_ENUM(NAME) namespace NAME { #endif #ifndef ENUM_STRING @@ -78,9 +74,11 @@ #ifndef Alloca #define Alloca(Sz) __builtin_alloca(Sz) -#endif // #ifndef Alloca +#endif // #ifndef Alloca #ifndef CantReach #define CantReach() __builtin_unreachable() #endif +#define kBadPtr 0xFBFBFBFBFBFBFBFB +#define kmaxAddr 0xFFFFFFFFFFFFFFFF -- cgit v1.2.3