From 7fa464fde023fcc451adb3ce3f019e45777c1d67 Mon Sep 17 00:00:00 2001 From: jief Date: Mon, 17 Feb 2020 23:41:09 +0300 Subject: [PATCH] Final switch to C++ compiler --- .gitignore | 4 +- Clover.dsc | 1 + Include/Library/GenericBdsLib.h | 6 +- MdePkg/Include/Base.h | 3 + MdePkg/Include/Library/MemoryAllocationLib.h | 2 +- MdePkg/Include/Protocol/SimpleFileSystem.h | 4 +- MdePkg/Include/Protocol/SimpleTextOut.h | 2 +- MdePkg/Include/Protocol/UnicodeCollation.h | 4 +- MdePkg/Include/Uefi/UefiSpec.h | 4 +- .../{AcpiPatcher.c => AcpiPatcher.cpp} | 18 +- .../{AmlGenerator.c => AmlGenerator.cpp} | 12 +- rEFIt_UEFI/Platform/AmlGenerator.h | 10 +- .../Platform/{BdsConnect.c => BdsConnect.cpp} | 0 .../Platform/{BootLog.c => BootLog.cpp} | 2 +- .../{BootOptions.c => BootOptions.cpp} | 10 +- .../Platform/{Console.c => Console.cpp} | 0 .../Platform/{DataHubCpu.c => DataHubCpu.cpp} | 10 +- .../Platform/{DevicePath.c => DevicePath.cpp} | 152 ++++++++--------- rEFIt_UEFI/Platform/{Edid.c => Edid.cpp} | 0 rEFIt_UEFI/Platform/{Events.c => Events.cpp} | 0 .../{FixBiosDsdt.c => FixBiosDsdt.cpp} | 27 +-- .../{HdaCodecDump.c => HdaCodecDump.cpp} | 2 +- rEFIt_UEFI/Platform/HdaCodecDump.h | 2 + .../Platform/{Hibernate.c => Hibernate.cpp} | 4 +- .../Platform/{Injectors.c => Injectors.cpp} | 0 ...{LegacyBiosThunk.c => LegacyBiosThunk.cpp} | 0 rEFIt_UEFI/Platform/LegacyBiosThunk.h | 4 +- .../Platform/{LegacyBoot.c => LegacyBoot.cpp} | 4 +- rEFIt_UEFI/Platform/{Net.c => Net.cpp} | 0 rEFIt_UEFI/Platform/{Nvram.c => Nvram.cpp} | 18 +- rEFIt_UEFI/Platform/Platform.h | 110 ++++++------ ...rOverride.c => PlatformDriverOverride.cpp} | 0 .../Platform/{Pointer.c => Pointer.cpp} | 0 .../Platform/{Settings.c => Settings.cpp} | 42 ++--- .../{StartupSound.c => StartupSound.cpp} | 2 +- .../{StateGenerator.c => StateGenerator.cpp} | 0 rEFIt_UEFI/Platform/{ati.c => ati.cpp} | 17 +- rEFIt_UEFI/Platform/ati.h | 2 +- .../Platform/{b64cdecode.c => b64cdecode.cpp} | 0 .../Platform/{card_vlist.c => card_vlist.cpp} | 6 +- rEFIt_UEFI/Platform/{cpu.c => cpu.cpp} | 0 .../{device_inject.c => device_inject.cpp} | 2 +- rEFIt_UEFI/Platform/device_inject.h | 2 +- rEFIt_UEFI/Platform/{gma.c => gma.cpp} | 8 +- rEFIt_UEFI/Platform/gma.h | 2 +- rEFIt_UEFI/Platform/{guid.c => guid.cpp} | 0 rEFIt_UEFI/Platform/{hda.c => hda.cpp} | 0 .../{kernel_patcher.c => kernel_patcher.cpp} | 8 +- .../{kext_inject.c => kext_inject.cpp} | 6 +- .../{kext_patcher.c => kext_patcher.cpp} | 4 +- rEFIt_UEFI/Platform/memvendors.h | 2 +- rEFIt_UEFI/Platform/{nvidia.c => nvidia.cpp} | 6 +- rEFIt_UEFI/Platform/nvidia.h | 4 +- .../Platform/{picopng.c => picopng.cpp} | 0 .../{platformdata.c => platformdata.cpp} | 12 +- rEFIt_UEFI/Platform/{plist.c => plist.cpp} | 11 +- rEFIt_UEFI/Platform/{smbios.c => smbios.cpp} | 56 +++++-- rEFIt_UEFI/Platform/{sound.c => sound.cpp} | 0 rEFIt_UEFI/Platform/{spd.c => spd.cpp} | 16 +- rEFIt_UEFI/Platform/{string.c => string.cpp} | 2 +- rEFIt_UEFI/Platform/{usbfix.c => usbfix.cpp} | 0 rEFIt_UEFI/cpp_util/XStringW.cpp | 2 +- rEFIt_UEFI/cpp_util/memory.cpp | 37 +++++ rEFIt_UEFI/cpp_util/memory.h | 9 + .../{bootscreen.c => bootscreen.cpp} | 4 +- .../entry_scan/{common.c => common.cpp} | 43 ++--- rEFIt_UEFI/entry_scan/entry_scan.h | 4 +- .../entry_scan/{legacy.c => legacy.cpp} | 2 +- .../entry_scan/{loader.c => loader.cpp} | 63 +++---- .../{lockedgraphics.c => lockedgraphics.cpp} | 0 .../{secureboot.c => secureboot.cpp} | 2 +- .../{securehash.c => securehash.cpp} | 2 +- .../{securemenu.c => securemenu.cpp} | 2 +- .../{securevars.c => securevars.cpp} | 2 +- rEFIt_UEFI/entry_scan/{tool.c => tool.cpp} | 6 +- .../{uefibootoption.c => uefibootoption.cpp} | 0 rEFIt_UEFI/libeg/{BmLib.c => BmLib.cpp} | 0 rEFIt_UEFI/libeg/{FloatLib.c => FloatLib.cpp} | 0 rEFIt_UEFI/libeg/FloatLib.h | 2 + .../{VectorGraphics.c => VectorGraphics.cpp} | 8 +- .../libeg/{egemb_font.c => egemb_font.cpp} | 0 .../libeg/{egemb_icons.c => egemb_icons.cpp} | 0 ...gemb_icons_dark.c => egemb_icons_dark.cpp} | 0 rEFIt_UEFI/libeg/{image.c => image.cpp} | 10 +- rEFIt_UEFI/libeg/libeg.h | 21 ++- rEFIt_UEFI/libeg/libegint.h | 6 - .../libeg/{libscreen.c => libscreen.cpp} | 2 +- .../libeg/{load_icns.c => load_icns.cpp} | 0 rEFIt_UEFI/libeg/{lodepng.c => lodepng.cpp} | 6 +- rEFIt_UEFI/libeg/{nanosvg.c => nanosvg.cpp} | 2 +- rEFIt_UEFI/libeg/nanosvg.h | 5 +- .../libeg/{nanosvgrast.c => nanosvgrast.cpp} | 0 .../{scroll_images.c => scroll_images.cpp} | 0 rEFIt_UEFI/libeg/{text.c => text.cpp} | 6 +- rEFIt_UEFI/refit.inf | 157 +++++++++--------- rEFIt_UEFI/refit/{IO.c => IO.cpp} | 12 +- rEFIt_UEFI/refit/IO.h | 4 +- rEFIt_UEFI/refit/{icns.c => icns.cpp} | 16 +- rEFIt_UEFI/refit/{lib.c => lib.cpp} | 30 ++-- rEFIt_UEFI/refit/lib.h | 87 +++++----- rEFIt_UEFI/refit/{list.c => list.cpp} | 0 rEFIt_UEFI/refit/list.h | 2 +- rEFIt_UEFI/refit/main.cpp | 67 ++++---- rEFIt_UEFI/refit/menu.cpp | 50 +++--- rEFIt_UEFI/refit/{screen.c => screen.cpp} | 14 +- 105 files changed, 692 insertions(+), 618 deletions(-) rename rEFIt_UEFI/Platform/{AcpiPatcher.c => AcpiPatcher.cpp} (99%) rename rEFIt_UEFI/Platform/{AmlGenerator.c => AmlGenerator.cpp} (97%) rename rEFIt_UEFI/Platform/{BdsConnect.c => BdsConnect.cpp} (100%) rename rEFIt_UEFI/Platform/{BootLog.c => BootLog.cpp} (99%) rename rEFIt_UEFI/Platform/{BootOptions.c => BootOptions.cpp} (95%) rename rEFIt_UEFI/Platform/{Console.c => Console.cpp} (100%) rename rEFIt_UEFI/Platform/{DataHubCpu.c => DataHubCpu.cpp} (99%) rename rEFIt_UEFI/Platform/{DevicePath.c => DevicePath.cpp} (91%) rename rEFIt_UEFI/Platform/{Edid.c => Edid.cpp} (100%) rename rEFIt_UEFI/Platform/{Events.c => Events.cpp} (100%) rename rEFIt_UEFI/Platform/{FixBiosDsdt.c => FixBiosDsdt.cpp} (99%) rename rEFIt_UEFI/Platform/{HdaCodecDump.c => HdaCodecDump.cpp} (99%) rename rEFIt_UEFI/Platform/{Hibernate.c => Hibernate.cpp} (99%) rename rEFIt_UEFI/Platform/{Injectors.c => Injectors.cpp} (100%) rename rEFIt_UEFI/Platform/{LegacyBiosThunk.c => LegacyBiosThunk.cpp} (100%) rename rEFIt_UEFI/Platform/{LegacyBoot.c => LegacyBoot.cpp} (99%) rename rEFIt_UEFI/Platform/{Net.c => Net.cpp} (100%) rename rEFIt_UEFI/Platform/{Nvram.c => Nvram.cpp} (99%) rename rEFIt_UEFI/Platform/{PlatformDriverOverride.c => PlatformDriverOverride.cpp} (100%) rename rEFIt_UEFI/Platform/{Pointer.c => Pointer.cpp} (100%) rename rEFIt_UEFI/Platform/{Settings.c => Settings.cpp} (99%) rename rEFIt_UEFI/Platform/{StartupSound.c => StartupSound.cpp} (99%) rename rEFIt_UEFI/Platform/{StateGenerator.c => StateGenerator.cpp} (100%) rename rEFIt_UEFI/Platform/{ati.c => ati.cpp} (99%) rename rEFIt_UEFI/Platform/{b64cdecode.c => b64cdecode.cpp} (100%) rename rEFIt_UEFI/Platform/{card_vlist.c => card_vlist.cpp} (97%) rename rEFIt_UEFI/Platform/{cpu.c => cpu.cpp} (100%) rename rEFIt_UEFI/Platform/{device_inject.c => device_inject.cpp} (99%) rename rEFIt_UEFI/Platform/{gma.c => gma.cpp} (99%) rename rEFIt_UEFI/Platform/{guid.c => guid.cpp} (100%) rename rEFIt_UEFI/Platform/{hda.c => hda.cpp} (100%) rename rEFIt_UEFI/Platform/{kernel_patcher.c => kernel_patcher.cpp} (99%) rename rEFIt_UEFI/Platform/{kext_inject.c => kext_inject.cpp} (99%) rename rEFIt_UEFI/Platform/{kext_patcher.c => kext_patcher.cpp} (99%) rename rEFIt_UEFI/Platform/{nvidia.c => nvidia.cpp} (99%) rename rEFIt_UEFI/Platform/{picopng.c => picopng.cpp} (100%) rename rEFIt_UEFI/Platform/{platformdata.c => platformdata.cpp} (99%) rename rEFIt_UEFI/Platform/{plist.c => plist.cpp} (98%) rename rEFIt_UEFI/Platform/{smbios.c => smbios.cpp} (97%) rename rEFIt_UEFI/Platform/{sound.c => sound.cpp} (100%) rename rEFIt_UEFI/Platform/{spd.c => spd.cpp} (98%) rename rEFIt_UEFI/Platform/{string.c => string.cpp} (96%) rename rEFIt_UEFI/Platform/{usbfix.c => usbfix.cpp} (100%) create mode 100644 rEFIt_UEFI/cpp_util/memory.cpp create mode 100644 rEFIt_UEFI/cpp_util/memory.h rename rEFIt_UEFI/entry_scan/{bootscreen.c => bootscreen.cpp} (99%) rename rEFIt_UEFI/entry_scan/{common.c => common.cpp} (93%) rename rEFIt_UEFI/entry_scan/{legacy.c => legacy.cpp} (98%) rename rEFIt_UEFI/entry_scan/{loader.c => loader.cpp} (98%) rename rEFIt_UEFI/entry_scan/{lockedgraphics.c => lockedgraphics.cpp} (100%) rename rEFIt_UEFI/entry_scan/{secureboot.c => secureboot.cpp} (99%) rename rEFIt_UEFI/entry_scan/{securehash.c => securehash.cpp} (99%) rename rEFIt_UEFI/entry_scan/{securemenu.c => securemenu.cpp} (99%) rename rEFIt_UEFI/entry_scan/{securevars.c => securevars.cpp} (99%) rename rEFIt_UEFI/entry_scan/{tool.c => tool.cpp} (97%) rename rEFIt_UEFI/entry_scan/{uefibootoption.c => uefibootoption.cpp} (100%) rename rEFIt_UEFI/libeg/{BmLib.c => BmLib.cpp} (100%) rename rEFIt_UEFI/libeg/{FloatLib.c => FloatLib.cpp} (100%) rename rEFIt_UEFI/libeg/{VectorGraphics.c => VectorGraphics.cpp} (98%) rename rEFIt_UEFI/libeg/{egemb_font.c => egemb_font.cpp} (100%) rename rEFIt_UEFI/libeg/{egemb_icons.c => egemb_icons.cpp} (100%) rename rEFIt_UEFI/libeg/{egemb_icons_dark.c => egemb_icons_dark.cpp} (100%) rename rEFIt_UEFI/libeg/{image.c => image.cpp} (98%) rename rEFIt_UEFI/libeg/{libscreen.c => libscreen.cpp} (99%) rename rEFIt_UEFI/libeg/{load_icns.c => load_icns.cpp} (100%) rename rEFIt_UEFI/libeg/{lodepng.c => lodepng.cpp} (99%) rename rEFIt_UEFI/libeg/{nanosvg.c => nanosvg.cpp} (99%) rename rEFIt_UEFI/libeg/{nanosvgrast.c => nanosvgrast.cpp} (100%) rename rEFIt_UEFI/libeg/{scroll_images.c => scroll_images.cpp} (100%) rename rEFIt_UEFI/libeg/{text.c => text.cpp} (98%) rename rEFIt_UEFI/refit/{IO.c => IO.cpp} (98%) rename rEFIt_UEFI/refit/{icns.c => icns.cpp} (96%) rename rEFIt_UEFI/refit/{lib.c => lib.cpp} (98%) rename rEFIt_UEFI/refit/{list.c => list.cpp} (100%) rename rEFIt_UEFI/refit/{screen.c => screen.cpp} (98%) diff --git a/.gitignore b/.gitignore index 450666e51..7e3eebf25 100644 --- a/.gitignore +++ b/.gitignore @@ -117,8 +117,8 @@ CloverPrefpane.strings #CloverPackage/CloverPrefpane/src/*.lproj BaseTools/Source/Python/build/BuildReport.pyc -Conf/BuildEnv.sh -Conf/.AutoGenIdFile.txt + CloverPackage/revision CloverPackage/version tools +/Conf/ diff --git a/Clover.dsc b/Clover.dsc index cd32156cd..d337e8248 100644 --- a/Clover.dsc +++ b/Clover.dsc @@ -686,5 +686,6 @@ DEFINE BUILD_OPTIONS=-DMDEPKG_NDEBUG -DCLOVER_BUILD $(VBIOS_PATCH_CLOVEREFI_FLAG XCODE:*_*_*_CC_FLAGS = -fno-unwind-tables -Wno-msvc-include -Os $(BUILD_OPTIONS) $(DISABLE_LTO_FLAG) GCC:*_*_*_CC_FLAGS = $(BUILD_OPTIONS) $(DISABLE_LTO_FLAG) + GCC:*_*_*_CXX_FLAGS = $(BUILD_OPTIONS) $(DISABLE_LTO_FLAG) #-Wunused-but-set-variable # -Os -fno-omit-frame-pointer -maccumulate-outgoing-args diff --git a/Include/Library/GenericBdsLib.h b/Include/Library/GenericBdsLib.h index 25cb9de9a..f85fcafa2 100644 --- a/Include/Library/GenericBdsLib.h +++ b/Include/Library/GenericBdsLib.h @@ -589,7 +589,7 @@ typedef struct { typedef VOID -(*DEV_PATH_FUNCTION) ( +(*DEV_PATH_FUNCTION_VOID) ( IN OUT POOL_PRINT *Str, IN VOID *DevPath ); @@ -597,7 +597,7 @@ VOID typedef struct { UINT8 Type; UINT8 SubType; - DEV_PATH_FUNCTION Function; + DEV_PATH_FUNCTION_VOID Function; } DEVICE_PATH_STRING_TABLE; typedef struct { @@ -1067,7 +1067,7 @@ CHAR16 * EFIAPI CatPrint ( IN OUT POOL_PRINT *Str, - IN CHAR16 *Fmt, + IN CONST CHAR16 *Fmt, ... ); diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index 7854e9f05..1b4c84d90 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -318,6 +318,9 @@ struct _LIST_ENTRY { /// Datum is read-only. /// #define CONST const +#ifndef JCONST +#define JCONST +#endif /// /// Datum is scoped to the current file or function. diff --git a/MdePkg/Include/Library/MemoryAllocationLib.h b/MdePkg/Include/Library/MemoryAllocationLib.h index 65a30cf14..6b668093b 100644 --- a/MdePkg/Include/Library/MemoryAllocationLib.h +++ b/MdePkg/Include/Library/MemoryAllocationLib.h @@ -481,7 +481,7 @@ ReallocateReservedPool ( VOID EFIAPI FreePool ( - IN VOID *Buffer + IN JCONST VOID *Buffer ); #endif diff --git a/MdePkg/Include/Protocol/SimpleFileSystem.h b/MdePkg/Include/Protocol/SimpleFileSystem.h index 38d54db80..a0b69e5b2 100644 --- a/MdePkg/Include/Protocol/SimpleFileSystem.h +++ b/MdePkg/Include/Protocol/SimpleFileSystem.h @@ -113,9 +113,9 @@ struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL { typedef EFI_STATUS (EFIAPI *EFI_FILE_OPEN)( - IN EFI_FILE_PROTOCOL *This, + IN JCONST EFI_FILE_PROTOCOL *This, OUT EFI_FILE_PROTOCOL **NewHandle, - IN CHAR16 *FileName, + IN JCONST CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes ); diff --git a/MdePkg/Include/Protocol/SimpleTextOut.h b/MdePkg/Include/Protocol/SimpleTextOut.h index a849c08d6..021a34a8b 100644 --- a/MdePkg/Include/Protocol/SimpleTextOut.h +++ b/MdePkg/Include/Protocol/SimpleTextOut.h @@ -191,7 +191,7 @@ typedef EFI_STATUS (EFIAPI *EFI_TEXT_STRING)( IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, - IN CHAR16 *String + IN JCONST CHAR16 *String ); /** diff --git a/MdePkg/Include/Protocol/UnicodeCollation.h b/MdePkg/Include/Protocol/UnicodeCollation.h index c337c7bdf..433f280ab 100644 --- a/MdePkg/Include/Protocol/UnicodeCollation.h +++ b/MdePkg/Include/Protocol/UnicodeCollation.h @@ -78,8 +78,8 @@ typedef BOOLEAN (EFIAPI *EFI_UNICODE_COLLATION_METAIMATCH)( IN EFI_UNICODE_COLLATION_PROTOCOL *This, - IN CHAR16 *String, - IN CHAR16 *Pattern + IN JCONST CHAR16 *String, + IN JCONST CHAR16 *Pattern ); /** diff --git a/MdePkg/Include/Uefi/UefiSpec.h b/MdePkg/Include/Uefi/UefiSpec.h index 44a0a6a7f..4df4bf685 100644 --- a/MdePkg/Include/Uefi/UefiSpec.h +++ b/MdePkg/Include/Uefi/UefiSpec.h @@ -645,7 +645,7 @@ VOID typedef EFI_STATUS (EFIAPI *EFI_GET_VARIABLE)( - IN CHAR16 *VariableName, + IN JCONST CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes, OPTIONAL IN OUT UINTN *DataSize, @@ -723,7 +723,7 @@ EFI_STATUS typedef EFI_STATUS (EFIAPI *EFI_SET_VARIABLE)( - IN CHAR16 *VariableName, + IN JCONST CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, diff --git a/rEFIt_UEFI/Platform/AcpiPatcher.c b/rEFIt_UEFI/Platform/AcpiPatcher.cpp similarity index 99% rename from rEFIt_UEFI/Platform/AcpiPatcher.c rename to rEFIt_UEFI/Platform/AcpiPatcher.cpp index c9191453a..384b25045 100644 --- a/rEFIt_UEFI/Platform/AcpiPatcher.c +++ b/rEFIt_UEFI/Platform/AcpiPatcher.cpp @@ -730,7 +730,7 @@ void PostCleanupXSDT() /** Saves Buffer of Length to disk as DirName\\FileName. */ -EFI_STATUS SaveBufferToDisk(VOID *Buffer, UINTN Length, CHAR16 *DirName, CHAR16 *FileName) +EFI_STATUS SaveBufferToDisk(VOID *Buffer, UINTN Length, CONST CHAR16 *DirName, CONST CHAR16 *FileName) { if (DirName == NULL || FileName == NULL) { return EFI_INVALID_PARAMETER; @@ -838,7 +838,7 @@ STATIC UINT8 NameCSDT2[] = {0x80, 0x43, 0x53, 0x44, 0x54}; //UINT32 get_size(UINT8 * An, UINT32 ); // Let borrow from FixBiosDsdt. -static CHAR16* GenerateFileName(CHAR16* FileNamePrefix, UINTN SsdtCount, UINTN ChildCount, CHAR8 OemTableId[9]) +static CHAR16* GenerateFileName(CONST CHAR16* FileNamePrefix, UINTN SsdtCount, UINTN ChildCount, CHAR8 OemTableId[9]) // ChildCount == IGNORE_INDEX indicates normal SSDT // SsdtCount == IGNORE_INDEX indicates dynamic SSDT in DSDT // otherwise is child SSDT from normal SSDT @@ -865,7 +865,7 @@ static CHAR16* GenerateFileName(CHAR16* FileNamePrefix, UINTN SsdtCount, UINTN C return FileName; } -VOID DumpChildSsdt(EFI_ACPI_DESCRIPTION_HEADER *TableEntry, CHAR16 *DirName, CHAR16 *FileNamePrefix, UINTN SsdtCount) +VOID DumpChildSsdt(EFI_ACPI_DESCRIPTION_HEADER *TableEntry, CONST CHAR16 *DirName, CONST CHAR16 *FileNamePrefix, UINTN SsdtCount) { EFI_STATUS Status = EFI_SUCCESS; INTN j, k, pacLen, pacCount; @@ -995,7 +995,7 @@ VOID DumpChildSsdt(EFI_ACPI_DESCRIPTION_HEADER *TableEntry, CHAR16 *DirName, CHA /** Saves Table to disk as DirName\\FileName (DirName != NULL) * or just prints basic table data to log (DirName == NULL). */ -EFI_STATUS DumpTable(EFI_ACPI_DESCRIPTION_HEADER *TableEntry, CHAR8 *CheckSignature, CHAR16 *DirName, CHAR16 *FileName, CHAR16 *FileNamePrefix, INTN *SsdtCount) +EFI_STATUS DumpTable(EFI_ACPI_DESCRIPTION_HEADER *TableEntry, CONST CHAR8 *CheckSignature, CONST CHAR16 *DirName, CONST CHAR16 *FileName, CONST CHAR16 *FileNamePrefix, INTN *SsdtCount) { EFI_STATUS Status; CHAR8 Signature[5]; @@ -1095,7 +1095,7 @@ EFI_STATUS DumpTable(EFI_ACPI_DESCRIPTION_HEADER *TableEntry, CHAR8 *CheckSignat } /** Saves to disk (DirName != NULL) or prints to log (DirName == NULL) Fadt tables: Dsdt and Facs. */ -EFI_STATUS DumpFadtTables(EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt, CHAR16 *DirName, CHAR16 *FileNamePrefix, INTN *SsdtCount) +EFI_STATUS DumpFadtTables(EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt, CONST CHAR16 *DirName, CONST CHAR16 *FileNamePrefix, INTN *SsdtCount) { EFI_ACPI_DESCRIPTION_HEADER *TableEntry; EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs; @@ -1243,7 +1243,7 @@ VOID DumpTables(VOID *RsdPtrVoid, CHAR16 *DirName) EFI_STATUS Status; UINTN Length; INTN SsdtCount; - CHAR16 *FileNamePrefix; + CONST CHAR16 *FileNamePrefix; // // RSDP // Take it as Acpi 2.0, but take care that if RsdPtr->Revision == 0 @@ -1506,7 +1506,7 @@ VOID SaveOemDsdt(BOOLEAN FullPatch) UINTN DsdtLen = 0; CHAR16* OriginDsdt = PoolPrint(L"%s\\ACPI\\origin\\DSDT.aml", OEMPath); CHAR16* OriginDsdtFixed = PoolPrint(L"%s\\ACPI\\origin\\DSDT-%x.aml", OEMPath, gSettings.FixDsdt); - CHAR16* PathPatched = L"\\EFI\\CLOVER\\ACPI\\patched"; + CONST CHAR16* PathPatched = L"\\EFI\\CLOVER\\ACPI\\patched"; CHAR16* PathDsdt; // = L"\\DSDT.aml"; CHAR16* AcpiOemPath = PoolPrint(L"%s\\ACPI\\patched", OEMPath); @@ -1695,7 +1695,7 @@ EFI_STATUS PatchACPI(IN REFIT_VOLUME *Volume, CHAR8 *OSVersion) SSDT_TABLE *Ssdt = NULL; UINT8 *buffer = NULL; UINTN bufferLen = 0; - CHAR16* PathPatched = L"\\EFI\\CLOVER\\ACPI\\patched"; + CONST CHAR16* PathPatched = L"\\EFI\\CLOVER\\ACPI\\patched"; CHAR16* PathDsdt; // = L"\\DSDT.aml"; // CHAR16* PatchedAPIC = L"\\EFI\\CLOVER\\ACPI\\origin\\APIC-p.aml"; UINT32* rf = NULL; @@ -2411,7 +2411,7 @@ EFI_STATUS LoadAndInjectAcpiTable(CHAR16 *PathPatched, /** * Patches UEFI ACPI tables with tables found in OsSubdir. */ -EFI_STATUS PatchACPI_OtherOS(CHAR16* OsSubdir, BOOLEAN DropSSDT) +EFI_STATUS PatchACPI_OtherOS(CONST CHAR16* OsSubdir, BOOLEAN DropSSDT) { EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *RsdPointer; EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *FadtPointer; diff --git a/rEFIt_UEFI/Platform/AmlGenerator.c b/rEFIt_UEFI/Platform/AmlGenerator.cpp similarity index 97% rename from rEFIt_UEFI/Platform/AmlGenerator.c rename to rEFIt_UEFI/Platform/AmlGenerator.cpp index 8f8363072..17ebfedaf 100644 --- a/rEFIt_UEFI/Platform/AmlGenerator.c +++ b/rEFIt_UEFI/Platform/AmlGenerator.cpp @@ -182,7 +182,7 @@ UINT32 aml_fill_simple_name(CHAR8* buffer, /* CONST*/ CHAR8* name) return 4; } -UINT32 aml_fill_name(AML_CHUNK* node, /* CONST*/ CHAR8* name) +UINT32 aml_fill_name(AML_CHUNK* node, CONST CHAR8* name) { INTN len, offset, count; UINT32 root = 0; @@ -247,7 +247,7 @@ AML_CHUNK* aml_add_scope(AML_CHUNK* parent, /* CONST*/ CHAR8* name) return node; } -AML_CHUNK* aml_add_name(AML_CHUNK* parent, /* CONST*/ CHAR8* name) +AML_CHUNK* aml_add_name(AML_CHUNK* parent, CONST CHAR8* name) { AML_CHUNK* node = aml_create_node(parent); @@ -261,7 +261,7 @@ AML_CHUNK* aml_add_name(AML_CHUNK* parent, /* CONST*/ CHAR8* name) return node; } -AML_CHUNK* aml_add_method(AML_CHUNK* parent, /* CONST*/ CHAR8* name, UINT8 args) +AML_CHUNK* aml_add_method(AML_CHUNK* parent, CONST CHAR8* name, UINT8 args) { AML_CHUNK* node = aml_create_node(parent); @@ -311,7 +311,7 @@ AML_CHUNK* aml_add_alias(AML_CHUNK* parent, /* CONST*/ CHAR8* name1, /* CONST*/ return node; } -AML_CHUNK* aml_add_return_name(AML_CHUNK* parent, /* CONST*/ CHAR8* name) +AML_CHUNK* aml_add_return_name(AML_CHUNK* parent, CONST CHAR8* name) { AML_CHUNK* node = aml_create_node(parent); @@ -337,7 +337,7 @@ AML_CHUNK* aml_add_return_byte(AML_CHUNK* parent, UINT8 value) return node; } -AML_CHUNK* aml_add_device(AML_CHUNK* parent, /* CONST*/ CHAR8* name) +AML_CHUNK* aml_add_device(AML_CHUNK* parent, CONST CHAR8* name) { AML_CHUNK* node = aml_create_node(parent); @@ -414,7 +414,7 @@ AML_CHUNK* aml_add_string_buffer(AML_CHUNK* parent, CONST CHAR8* StringBuf) return node; } -AML_CHUNK* aml_add_string(AML_CHUNK* parent, /* CONST*/ CHAR8* StringBuf) +AML_CHUNK* aml_add_string(AML_CHUNK* parent, CONST CHAR8* StringBuf) { AML_CHUNK* node = aml_create_node(parent); diff --git a/rEFIt_UEFI/Platform/AmlGenerator.h b/rEFIt_UEFI/Platform/AmlGenerator.h index 179388f47..164abc033 100644 --- a/rEFIt_UEFI/Platform/AmlGenerator.h +++ b/rEFIt_UEFI/Platform/AmlGenerator.h @@ -27,9 +27,9 @@ AML_CHUNK* aml_add_word(AML_CHUNK* parent, UINT16 value); AML_CHUNK* aml_add_dword(AML_CHUNK* parent, UINT32 value); AML_CHUNK* aml_add_qword(AML_CHUNK* parent, UINT64 value); AML_CHUNK* aml_add_scope(AML_CHUNK* parent, /* CONST*/ CHAR8* name); -AML_CHUNK* aml_add_name(AML_CHUNK* parent, /* CONST*/ CHAR8* name); -AML_CHUNK* aml_add_method(AML_CHUNK* parent, /* CONST*/ CHAR8* name, UINT8 args); -AML_CHUNK* aml_add_return_name(AML_CHUNK* parent, /* CONST*/ CHAR8* name); +AML_CHUNK* aml_add_name(AML_CHUNK* parent, CONST CHAR8* name); +AML_CHUNK* aml_add_method(AML_CHUNK* parent, CONST CHAR8* name, UINT8 args); +AML_CHUNK* aml_add_return_name(AML_CHUNK* parent, CONST CHAR8* name); AML_CHUNK* aml_add_return_byte(AML_CHUNK* parent, UINT8 value); AML_CHUNK* aml_add_package(AML_CHUNK* parent); AML_CHUNK* aml_add_alias(AML_CHUNK* parent, /* CONST*/ CHAR8* name1, /* CONST*/ CHAR8* name2); @@ -38,10 +38,10 @@ UINT32 aml_write_node(AML_CHUNK* node, CHAR8* buffer, UINT32 offset); UINT32 aml_write_size(UINT32 size, CHAR8* buffer, UINT32 offset); // add by pcj -AML_CHUNK* aml_add_string(AML_CHUNK* parent, /* CONST*/ CHAR8* string); +AML_CHUNK* aml_add_string(AML_CHUNK* parent, CONST CHAR8* string); AML_CHUNK* aml_add_byte_buffer(AML_CHUNK* parent, /* CONST*/ UINT8* data,UINT32 size); AML_CHUNK* aml_add_string_buffer(AML_CHUNK* parent, CONST CHAR8* string); -AML_CHUNK* aml_add_device(AML_CHUNK* parent, /* CONST*/ CHAR8* name); +AML_CHUNK* aml_add_device(AML_CHUNK* parent, CONST CHAR8* name); AML_CHUNK* aml_add_local0(AML_CHUNK* parent); AML_CHUNK* aml_add_store(AML_CHUNK* parent); AML_CHUNK* aml_add_return(AML_CHUNK* parent); diff --git a/rEFIt_UEFI/Platform/BdsConnect.c b/rEFIt_UEFI/Platform/BdsConnect.cpp similarity index 100% rename from rEFIt_UEFI/Platform/BdsConnect.c rename to rEFIt_UEFI/Platform/BdsConnect.cpp diff --git a/rEFIt_UEFI/Platform/BootLog.c b/rEFIt_UEFI/Platform/BootLog.cpp similarity index 99% rename from rEFIt_UEFI/Platform/BootLog.c rename to rEFIt_UEFI/Platform/BootLog.cpp index b5615bb23..373e94273 100644 --- a/rEFIt_UEFI/Platform/BootLog.c +++ b/rEFIt_UEFI/Platform/BootLog.cpp @@ -212,7 +212,7 @@ EFI_STATUS SetupBooterLog(BOOLEAN AllowGrownSize) // Made msgbuf and msgCursor private to this source // so we need a different way of saving the msg log - apianti -EFI_STATUS SaveBooterLog(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CHAR16 *FileName) +EFI_STATUS SaveBooterLog(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *FileName) { CHAR8 *MemLogBuffer; UINTN MemLogLen; diff --git a/rEFIt_UEFI/Platform/BootOptions.c b/rEFIt_UEFI/Platform/BootOptions.cpp similarity index 95% rename from rEFIt_UEFI/Platform/BootOptions.c rename to rEFIt_UEFI/Platform/BootOptions.cpp index 2364dc6c0..fa7316d11 100644 --- a/rEFIt_UEFI/Platform/BootOptions.c +++ b/rEFIt_UEFI/Platform/BootOptions.cpp @@ -185,7 +185,7 @@ FindDevicePathNodeWithType ( EFI_STATUS CreateBootOptionDevicePath ( IN EFI_HANDLE FileDeviceHandle, - IN CHAR16 *FileName, + IN CONST CHAR16 *FileName, IN BOOLEAN UseShortForm, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath ) @@ -762,7 +762,7 @@ FindFreeBootNum ( EFI_STATUS FindBootOptionForFile ( IN EFI_HANDLE FileDeviceHandle, - IN CHAR16 *FileName, + IN CONST CHAR16 *FileName, OUT UINT16 *BootNum, OUT UINTN *BootIndex ) @@ -1018,9 +1018,9 @@ AddBootOption ( EFI_STATUS AddBootOptionForFile ( IN EFI_HANDLE FileDeviceHandle, - IN CHAR16 *FileName, + IN CONST CHAR16 *FileName, IN BOOLEAN UseShortForm, - IN CHAR16 *Description, + IN CONST CHAR16 *Description, IN UINT8 *OptionalData, IN UINTN OptionalDataSize, IN UINTN BootIndex, @@ -1124,7 +1124,7 @@ DeleteBootOption ( EFI_STATUS DeleteBootOptionForFile ( IN EFI_HANDLE FileDeviceHandle, - IN CHAR16 *FileName + IN CONST CHAR16 *FileName ) { EFI_STATUS Status; diff --git a/rEFIt_UEFI/Platform/Console.c b/rEFIt_UEFI/Platform/Console.cpp similarity index 100% rename from rEFIt_UEFI/Platform/Console.c rename to rEFIt_UEFI/Platform/Console.cpp diff --git a/rEFIt_UEFI/Platform/DataHubCpu.c b/rEFIt_UEFI/Platform/DataHubCpu.cpp similarity index 99% rename from rEFIt_UEFI/Platform/DataHubCpu.c rename to rEFIt_UEFI/Platform/DataHubCpu.cpp index e6e766aa4..372e73441 100644 --- a/rEFIt_UEFI/Platform/DataHubCpu.c +++ b/rEFIt_UEFI/Platform/DataHubCpu.cpp @@ -112,7 +112,7 @@ CopyRecord(IN PLATFORM_DATA *Rec, /// Adds a key-value-pair to the DataHubProtocol EFI_STATUS EFIAPI LogDataHub(IN EFI_GUID *TypeGuid, - IN CHAR16 *Name, + IN CONST CHAR16 *Name, IN VOID *Data, IN UINT32 DataSize) { @@ -171,7 +171,7 @@ OvrRuntimeServices(EFI_RUNTIME_SERVICES *RS) { EFI_STATUS Status; CopyMem(&gOrgRS, RS, sizeof(EFI_RUNTIME_SERVICES)); - RS->SetVariable = OvrSetVariable; + RS->SetVariable = (EFI_SET_VARIABLE)OvrSetVariable; RS->Hdr.CRC32 = 0; Status = gBS->CalculateCrc32(RS, RS->Hdr.HeaderSize, &RS->Hdr.CRC32); return Status; @@ -185,10 +185,10 @@ SetVariablesForOSX(LOADER_ENTRY *Entry) UINT32 Attributes; UINT32 Color; - CHAR8 *None; - CHAR8 *NvidiaWebValue; + CONST CHAR8 *None; + CONST CHAR8 *NvidiaWebValue; - CHAR16 *KbdPrevLang; + CONST CHAR16 *KbdPrevLang; UINTN LangLen; CHAR8 *VariablePtr; VOID *OldData; diff --git a/rEFIt_UEFI/Platform/DevicePath.c b/rEFIt_UEFI/Platform/DevicePath.cpp similarity index 91% rename from rEFIt_UEFI/Platform/DevicePath.c rename to rEFIt_UEFI/Platform/DevicePath.cpp index c16888b65..4c6919d07 100644 --- a/rEFIt_UEFI/Platform/DevicePath.c +++ b/rEFIt_UEFI/Platform/DevicePath.cpp @@ -34,11 +34,11 @@ CHAR16 * EFIAPI CatPrint ( IN OUT POOL_PRINT *Str, - IN CHAR16 *Fmt, + IN CONST CHAR16 *Fmt, ... ) { - UINT16 *AppendStr; + CHAR16 *AppendStr; VA_LIST Args; UINTN StringSize; @@ -89,7 +89,7 @@ CatPrint ( static VOID DevPathPci ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN PCI_DEVICE_PATH *DevPath ) { PCI_DEVICE_PATH *Pci; @@ -111,7 +111,7 @@ DevPathPci ( static VOID DevPathPccard ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN PCCARD_DEVICE_PATH *DevPath ) { PCCARD_DEVICE_PATH *Pccard; @@ -133,7 +133,7 @@ DevPathPccard ( static VOID DevPathMemMap ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN MEMMAP_DEVICE_PATH *DevPath ) { MEMMAP_DEVICE_PATH *MemMap; @@ -161,7 +161,7 @@ DevPathMemMap ( static VOID DevPathController ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN CONTROLLER_DEVICE_PATH *DevPath ) { CONTROLLER_DEVICE_PATH *Controller; @@ -181,11 +181,11 @@ DevPathController ( VOID DevPathVendor ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN VENDOR_DEVICE_PATH *DevPath ) { VENDOR_DEVICE_PATH *Vendor; - CHAR16 *Type; + CONST CHAR16 *Type; UINTN DataLength; UINTN Index; // UINT32 FlowControlMap; @@ -306,7 +306,7 @@ DevPathVendor ( static VOID DevPathAcpi ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN ACPI_HID_DEVICE_PATH *DevPath ) { ACPI_HID_DEVICE_PATH *Acpi; @@ -332,7 +332,7 @@ DevPathAcpi ( static VOID DevPathExtendedAcpi ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN ACPI_EXTENDED_HID_DEVICE_PATH *DevPath ) { ACPI_EXTENDED_HID_DEVICE_PATH *ExtendedAcpi; @@ -450,7 +450,7 @@ DevPathExtendedAcpi ( static VOID DevPathAdrAcpi ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN ACPI_ADR_DEVICE_PATH *DevPath ) { ACPI_ADR_DEVICE_PATH *AcpiAdr; @@ -482,7 +482,7 @@ DevPathAdrAcpi ( static VOID DevPathAtapi ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN ATAPI_DEVICE_PATH *DevPath ) { ATAPI_DEVICE_PATH *Atapi; @@ -509,7 +509,7 @@ DevPathAtapi ( static VOID DevPathScsi ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN SCSI_DEVICE_PATH *DevPath ) { SCSI_DEVICE_PATH *Scsi; @@ -531,7 +531,7 @@ DevPathScsi ( static VOID DevPathFibre ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN FIBRECHANNEL_DEVICE_PATH *DevPath ) { FIBRECHANNEL_DEVICE_PATH *Fibre; @@ -553,7 +553,7 @@ DevPathFibre ( static VOID DevPath1394 ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN F1394_DEVICE_PATH *DevPath ) { F1394_DEVICE_PATH *F1394Path; @@ -575,7 +575,7 @@ DevPath1394 ( static VOID DevPathUsb ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN USB_DEVICE_PATH *DevPath ) { USB_DEVICE_PATH *Usb; @@ -597,7 +597,7 @@ DevPathUsb ( static VOID DevPathUsbWWID ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN USB_WWID_DEVICE_PATH *DevPath ) { USB_WWID_DEVICE_PATH *UsbWWId; @@ -625,7 +625,7 @@ DevPathUsbWWID ( static VOID DevPathLogicalUnit ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN DEVICE_LOGICAL_UNIT_DEVICE_PATH *DevPath ) { DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicalUnit; @@ -647,7 +647,7 @@ DevPathLogicalUnit ( static VOID DevPathUsbClass ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN USB_CLASS_DEVICE_PATH *DevPath ) { USB_CLASS_DEVICE_PATH *UsbClass; @@ -677,7 +677,7 @@ DevPathUsbClass ( static VOID DevPathSata ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN SATA_DEVICE_PATH *DevPath ) { SATA_DEVICE_PATH *Sata; @@ -717,7 +717,7 @@ DevPathSata ( VOID DevPathToTextNVMe ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath /*, + IN NVME_NAMESPACE_DEVICE_PATH *DevPath /*, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts */ ) @@ -751,7 +751,7 @@ DevPathToTextNVMe ( static VOID DevPathI2O ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN I2O_DEVICE_PATH *DevPath ) { I2O_DEVICE_PATH *I2OPath; @@ -773,7 +773,7 @@ DevPathI2O ( static VOID DevPathMacAddr ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN MAC_ADDR_DEVICE_PATH *DevPath ) { MAC_ADDR_DEVICE_PATH *MACDevPath; @@ -809,7 +809,7 @@ DevPathMacAddr ( static VOID DevPathIPv4 ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN IPv4_DEVICE_PATH *DevPath ) { IPv4_DEVICE_PATH *IPDevPath; @@ -839,7 +839,7 @@ DevPathIPv4 ( static VOID DevPathIPv6 ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN IPv6_DEVICE_PATH *DevPath ) { IPv6_DEVICE_PATH *IPv6DevPath; @@ -880,7 +880,7 @@ DevPathIPv6 ( static VOID DevPathInfiniBand ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN INFINIBAND_DEVICE_PATH *DevPath ) { INFINIBAND_DEVICE_PATH *InfiniBand; @@ -910,7 +910,7 @@ DevPathInfiniBand ( static VOID DevPathUart ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN UART_DEVICE_PATH *DevPath ) { UART_DEVICE_PATH *Uart; @@ -995,7 +995,7 @@ DevPathUart ( static VOID DevPathiSCSI ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN ISCSI_DEVICE_PATH_WITH_NAME *DevPath ) { ISCSI_DEVICE_PATH_WITH_NAME *IScsi; @@ -1038,7 +1038,7 @@ DevPathiSCSI ( static VOID DevPathVlan ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN VLAN_DEVICE_PATH *DevPath ) { VLAN_DEVICE_PATH *Vlan; @@ -1060,7 +1060,7 @@ DevPathVlan ( static VOID DevPathHardDrive ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN HARDDRIVE_DEVICE_PATH *DevPath ) { HARDDRIVE_DEVICE_PATH *Hd; @@ -1110,7 +1110,7 @@ DevPathHardDrive ( static VOID DevPathCDROM ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN CDROM_DEVICE_PATH *DevPath ) { CDROM_DEVICE_PATH *Cd; @@ -1132,7 +1132,7 @@ DevPathCDROM ( static VOID DevPathFilePath ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN FILEPATH_DEVICE_PATH *DevPath ) { FILEPATH_DEVICE_PATH *Fp; @@ -1154,7 +1154,7 @@ DevPathFilePath ( static VOID DevPathMediaProtocol ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN MEDIA_PROTOCOL_DEVICE_PATH *DevPath ) { MEDIA_PROTOCOL_DEVICE_PATH *MediaProt; @@ -1176,7 +1176,7 @@ DevPathMediaProtocol ( static VOID DevPathFvFilePath ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *DevPath ) { MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath; @@ -1198,7 +1198,7 @@ DevPathFvFilePath ( static VOID DevPathRelativeOffsetRange0 ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *DevPath ) { MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset; @@ -1225,11 +1225,11 @@ DevPathRelativeOffsetRange0 ( static VOID DevPathBssBss ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN BBS_BBS_DEVICE_PATH *DevPath ) { BBS_BBS_DEVICE_PATH *Bbs; - CHAR16 *Type; + CONST CHAR16 *Type; Bbs = DevPath; switch (Bbs->DeviceType) { @@ -1318,7 +1318,7 @@ DevPathNodeUnknown ( static VOID DevPathFvPath ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath + IN MEDIA_FW_VOL_DEVICE_PATH *DevPath ) { MEDIA_FW_VOL_DEVICE_PATH *FvPath; @@ -1331,192 +1331,192 @@ DEVICE_PATH_STRING_TABLE DevPathTable[] = { { HARDWARE_DEVICE_PATH, HW_PCI_DP, - DevPathPci + (DEV_PATH_FUNCTION_VOID)DevPathPci }, { HARDWARE_DEVICE_PATH, HW_PCCARD_DP, - DevPathPccard + (DEV_PATH_FUNCTION_VOID)DevPathPccard }, { HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, - DevPathMemMap + (DEV_PATH_FUNCTION_VOID)DevPathMemMap }, { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, - DevPathVendor + (DEV_PATH_FUNCTION_VOID)DevPathVendor }, { HARDWARE_DEVICE_PATH, HW_CONTROLLER_DP, - DevPathController + (DEV_PATH_FUNCTION_VOID)DevPathController }, { ACPI_DEVICE_PATH, ACPI_DP, - DevPathAcpi + (DEV_PATH_FUNCTION_VOID)DevPathAcpi }, { ACPI_DEVICE_PATH, ACPI_EXTENDED_DP, - DevPathExtendedAcpi + (DEV_PATH_FUNCTION_VOID)DevPathExtendedAcpi }, { ACPI_DEVICE_PATH, ACPI_ADR_DP, - DevPathAdrAcpi + (DEV_PATH_FUNCTION_VOID)DevPathAdrAcpi }, { MESSAGING_DEVICE_PATH, MSG_ATAPI_DP, - DevPathAtapi + (DEV_PATH_FUNCTION_VOID)DevPathAtapi }, { MESSAGING_DEVICE_PATH, MSG_SCSI_DP, - DevPathScsi + (DEV_PATH_FUNCTION_VOID)DevPathScsi }, { MESSAGING_DEVICE_PATH, MSG_FIBRECHANNEL_DP, - DevPathFibre + (DEV_PATH_FUNCTION_VOID)DevPathFibre }, { MESSAGING_DEVICE_PATH, MSG_1394_DP, - DevPath1394 + (DEV_PATH_FUNCTION_VOID)DevPath1394 }, { MESSAGING_DEVICE_PATH, MSG_USB_DP, - DevPathUsb + (DEV_PATH_FUNCTION_VOID)DevPathUsb }, { MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, - DevPathUsbWWID + (DEV_PATH_FUNCTION_VOID)DevPathUsbWWID }, { MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, - DevPathLogicalUnit + (DEV_PATH_FUNCTION_VOID)DevPathLogicalUnit }, { MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP, - DevPathUsbClass + (DEV_PATH_FUNCTION_VOID)DevPathUsbClass }, { MESSAGING_DEVICE_PATH, MSG_SATA_DP, - DevPathSata + (DEV_PATH_FUNCTION_VOID)DevPathSata }, { MESSAGING_DEVICE_PATH, MSG_NVME_NAMESPACE_DP, - DevPathToTextNVMe + (DEV_PATH_FUNCTION_VOID)DevPathToTextNVMe }, { MESSAGING_DEVICE_PATH, MSG_I2O_DP, - DevPathI2O + (DEV_PATH_FUNCTION_VOID)DevPathI2O }, { MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, - DevPathMacAddr + (DEV_PATH_FUNCTION_VOID)DevPathMacAddr }, { MESSAGING_DEVICE_PATH, MSG_IPv4_DP, - DevPathIPv4 + (DEV_PATH_FUNCTION_VOID)DevPathIPv4 }, { MESSAGING_DEVICE_PATH, MSG_IPv6_DP, - DevPathIPv6 + (DEV_PATH_FUNCTION_VOID)DevPathIPv6 }, { MESSAGING_DEVICE_PATH, MSG_INFINIBAND_DP, - DevPathInfiniBand + (DEV_PATH_FUNCTION_VOID)DevPathInfiniBand }, { MESSAGING_DEVICE_PATH, MSG_UART_DP, - DevPathUart + (DEV_PATH_FUNCTION_VOID)DevPathUart }, { MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, - DevPathVendor + (DEV_PATH_FUNCTION_VOID)DevPathVendor }, { MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, - DevPathiSCSI + (DEV_PATH_FUNCTION_VOID)DevPathiSCSI }, { MESSAGING_DEVICE_PATH, MSG_VLAN_DP, - DevPathVlan + (DEV_PATH_FUNCTION_VOID)DevPathVlan }, { MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, - DevPathHardDrive + (DEV_PATH_FUNCTION_VOID)DevPathHardDrive }, { MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, - DevPathCDROM + (DEV_PATH_FUNCTION_VOID)DevPathCDROM }, { MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, - DevPathVendor + (DEV_PATH_FUNCTION_VOID)DevPathVendor }, { MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, - DevPathFilePath + (DEV_PATH_FUNCTION_VOID)DevPathFilePath }, { MEDIA_DEVICE_PATH, MEDIA_PROTOCOL_DP, - DevPathMediaProtocol + (DEV_PATH_FUNCTION_VOID)DevPathMediaProtocol }, { MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_VOL_DP, - DevPathFvPath, + (DEV_PATH_FUNCTION_VOID)DevPathFvPath, }, { MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, - DevPathFvFilePath + (DEV_PATH_FUNCTION_VOID)DevPathFvFilePath }, { MEDIA_DEVICE_PATH, MEDIA_RELATIVE_OFFSET_RANGE_DP, - DevPathRelativeOffsetRange0, + (DEV_PATH_FUNCTION_VOID)DevPathRelativeOffsetRange0, }, { BBS_DEVICE_PATH, BBS_BBS_DP, - DevPathBssBss + (DEV_PATH_FUNCTION_VOID)DevPathBssBss }, { END_DEVICE_PATH_TYPE, END_INSTANCE_DEVICE_PATH_SUBTYPE, - DevPathEndInstance + (DEV_PATH_FUNCTION_VOID)DevPathEndInstance }, { 0, 0, - NULL + (DEV_PATH_FUNCTION_VOID)NULL } }; diff --git a/rEFIt_UEFI/Platform/Edid.c b/rEFIt_UEFI/Platform/Edid.cpp similarity index 100% rename from rEFIt_UEFI/Platform/Edid.c rename to rEFIt_UEFI/Platform/Edid.cpp diff --git a/rEFIt_UEFI/Platform/Events.c b/rEFIt_UEFI/Platform/Events.cpp similarity index 100% rename from rEFIt_UEFI/Platform/Events.c rename to rEFIt_UEFI/Platform/Events.cpp diff --git a/rEFIt_UEFI/Platform/FixBiosDsdt.c b/rEFIt_UEFI/Platform/FixBiosDsdt.cpp similarity index 99% rename from rEFIt_UEFI/Platform/FixBiosDsdt.c rename to rEFIt_UEFI/Platform/FixBiosDsdt.cpp index f68edba6f..916d30461 100644 --- a/rEFIt_UEFI/Platform/FixBiosDsdt.c +++ b/rEFIt_UEFI/Platform/FixBiosDsdt.cpp @@ -5,8 +5,11 @@ //totally rebuilt by Slice, 2012-2013 // NForce additions by Oscar09, 2013 +#include "Platform.h" #include "StateGenerator.h" +extern "C" { #include +} #ifdef DBG #undef DBG @@ -56,8 +59,8 @@ UINT32 DisplayADR1[4]; UINT32 DisplayADR2[4]; UINT32 NetworkADR1[4]; UINT32 NetworkADR2[4]; -CHAR8* Netmodel[4]; -CHAR8* NetName[4] = { "ETH0", "ETH1", "ETH2", "ETH3" }; +CONST CHAR8* Netmodel[4]; +CONST CHAR8* NetName[4] = { "ETH0", "ETH1", "ETH2", "ETH3" }; UINT32 net_count = 0; UINT32 ArptADR1; UINT32 ArptADR2; @@ -160,7 +163,7 @@ static struct lpc_device_t lpc_chipset[] = struct net_chipsets_t { UINT32 id; - CHAR8 *name; + CONST CHAR8 *name; }; static struct net_chipsets_t NetChipsets[] = { @@ -496,7 +499,7 @@ BOOLEAN CmpNum(UINT8 *dsdt, INT32 i, BOOLEAN Sure) //extern UINT32 HDA_IC_sendVerb(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 codecAdr, UINT32 nodeId, UINT32 verb); BOOLEAN get_lpc_model(UINT32 id) { - int i; + UINTN i; for (i=1; i< (sizeof(lpc_chipset) / sizeof(lpc_chipset[0])); i++) { if (lpc_chipset[i].id == id) { @@ -507,7 +510,7 @@ BOOLEAN get_lpc_model(UINT32 id) { } BOOLEAN get_ide_model(UINT32 id) { - int i; + UINTN i; for (i=1; i< (sizeof(ide_chipset) / sizeof(ide_chipset[0])); i++) { if (ide_chipset[i].id == id) { @@ -518,7 +521,7 @@ BOOLEAN get_ide_model(UINT32 id) { } /* BOOLEAN get_ahci_model(UINT32 id) { - int i; + UINTN i; for (i=1; i< (sizeof(ahci_chipset) / sizeof(ahci_chipset[0])); i++) { if (ahci_chipset[i].id == id) { @@ -528,8 +531,8 @@ BOOLEAN get_ahci_model(UINT32 id) { return TRUE; } */ -CHAR8* get_net_model(UINT32 id) { - int i; +CONST CHAR8* get_net_model(UINT32 id) { + UINTN i; for (i=1; i< (sizeof(NetChipsets) / sizeof(NetChipsets[0])); i++) { if (NetChipsets[i].id == id) { @@ -1181,7 +1184,7 @@ INT32 write_size(UINT32 adr, UINT8* buffer, UINT32 len, INT32 sizeoffset) return offset; } -INT32 FindName(UINT8 *dsdt, INT32 len, CHAR8* name) +INT32 FindName(UINT8 *dsdt, INT32 len, CONST CHAR8* name) { INT32 i; for (i = 0; len >= 5 && i < len-5; i++) { @@ -1324,7 +1327,7 @@ INT32 FindBin (UINT8 *dsdt, UINT32 len, UINT8* bin, UINT32 N) //if (!FindMethod(dsdt, len, "DTGP")) // return address of size field. Assume size not more then 0x0FFF = 4095 bytes //assuming only short methods -UINT32 FindMethod (UINT8 *dsdt, UINT32 len, /* CONST*/ CHAR8* Name) +UINT32 FindMethod (UINT8 *dsdt, UINT32 len, CONST CHAR8* Name) { UINT32 i; for (i = 0; len >= 7 && i < len - 7; i++) { @@ -1480,7 +1483,7 @@ UINT32 CorrectOuters (UINT8 *dsdt, UINT32 len, UINT32 adr, INT32 shift) } //ReplaceName(dsdt, len, "AZAL", "HDEF"); -INTN ReplaceName(UINT8 *dsdt, UINT32 len, /* CONST*/ CHAR8 *OldName, /* CONST*/ CHAR8 *NewName) +INTN ReplaceName(UINT8 *dsdt, UINT32 len, CONST CHAR8 *OldName, CONST CHAR8 *NewName) { UINTN i; INTN j = 0; @@ -1563,7 +1566,7 @@ BOOLEAN CustProperties(AML_CHUNK* pack, UINT32 Dev) } //len = DeleteDevice("AZAL", dsdt, len); -UINT32 DeleteDevice(/*CONST*/ CHAR8 *Name, UINT8 *dsdt, UINT32 len) +UINT32 DeleteDevice(CONST CHAR8 *Name, UINT8 *dsdt, UINT32 len) { UINT32 i, j; INT32 size = 0, sizeoffset; diff --git a/rEFIt_UEFI/Platform/HdaCodecDump.c b/rEFIt_UEFI/Platform/HdaCodecDump.cpp similarity index 99% rename from rEFIt_UEFI/Platform/HdaCodecDump.c rename to rEFIt_UEFI/Platform/HdaCodecDump.cpp index 97ca48aec..add07e7e1 100644 --- a/rEFIt_UEFI/Platform/HdaCodecDump.c +++ b/rEFIt_UEFI/Platform/HdaCodecDump.cpp @@ -58,7 +58,7 @@ CONST CHAR8 hdcID[4] = HDC_ID; extern UINTN AudioNum; extern HDA_OUTPUTS AudioList[20]; extern EFI_AUDIO_IO_PROTOCOL *AudioIo; -extern CHAR16 *OEMPath; +extern CONST CHAR16 *OEMPath; VOID EFIAPI diff --git a/rEFIt_UEFI/Platform/HdaCodecDump.h b/rEFIt_UEFI/Platform/HdaCodecDump.h index 25171cb0a..8c55c3388 100644 --- a/rEFIt_UEFI/Platform/HdaCodecDump.h +++ b/rEFIt_UEFI/Platform/HdaCodecDump.h @@ -25,6 +25,7 @@ #ifndef _EFI_HDA_CODEC_DUMP_H_ #define _EFI_HDA_CODEC_DUMP_H_ +extern "C" { // Common UEFI includes and library classes. #include #include @@ -38,6 +39,7 @@ // Consumed protocols. #include +} #define HDA_MAX_CONNS 32 #define HDA_MAX_NAMELEN 32 diff --git a/rEFIt_UEFI/Platform/Hibernate.c b/rEFIt_UEFI/Platform/Hibernate.cpp similarity index 99% rename from rEFIt_UEFI/Platform/Hibernate.c rename to rEFIt_UEFI/Platform/Hibernate.cpp index 6b61ab329..a7412463f 100644 --- a/rEFIt_UEFI/Platform/Hibernate.c +++ b/rEFIt_UEFI/Platform/Hibernate.cpp @@ -376,8 +376,8 @@ GetSleepImageLocation(IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume, UINT8 *PrefBuffer = NULL; UINTN PrefBufferLen = 0; TagPtr PrefDict, dict, dict2, prop; - CHAR16 *PrefName = L"\\Library\\Preferences\\SystemConfiguration\\com.apple.PowerManagement.plist"; - CHAR16 *PrefName2 = L"\\Library\\Preferences\\com.apple.PowerManagement.plist"; + CONST CHAR16 *PrefName = L"\\Library\\Preferences\\SystemConfiguration\\com.apple.PowerManagement.plist"; + CONST CHAR16 *PrefName2 = L"\\Library\\Preferences\\com.apple.PowerManagement.plist"; CHAR16 *PrefName3 = NULL; CHAR16 *ImageName = NULL; REFIT_VOLUME *ImageVolume = Volume; diff --git a/rEFIt_UEFI/Platform/Injectors.c b/rEFIt_UEFI/Platform/Injectors.cpp similarity index 100% rename from rEFIt_UEFI/Platform/Injectors.c rename to rEFIt_UEFI/Platform/Injectors.cpp diff --git a/rEFIt_UEFI/Platform/LegacyBiosThunk.c b/rEFIt_UEFI/Platform/LegacyBiosThunk.cpp similarity index 100% rename from rEFIt_UEFI/Platform/LegacyBiosThunk.c rename to rEFIt_UEFI/Platform/LegacyBiosThunk.cpp diff --git a/rEFIt_UEFI/Platform/LegacyBiosThunk.h b/rEFIt_UEFI/Platform/LegacyBiosThunk.h index c59ea0282..1e63cabbc 100644 --- a/rEFIt_UEFI/Platform/LegacyBiosThunk.h +++ b/rEFIt_UEFI/Platform/LegacyBiosThunk.h @@ -18,8 +18,8 @@ Abstract: #ifndef _LEGACY_BIOS_THUNK_H_ #define _LEGACY_BIOS_THUNK_H_ +extern "C" { #include - // // Driver Consumed Protocol Prototypes // @@ -49,6 +49,8 @@ Abstract: #include +} // extern "C" + #define EFI_SEGMENT(_Adr) (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000) #define EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff) diff --git a/rEFIt_UEFI/Platform/LegacyBoot.c b/rEFIt_UEFI/Platform/LegacyBoot.cpp similarity index 99% rename from rEFIt_UEFI/Platform/LegacyBoot.c rename to rEFIt_UEFI/Platform/LegacyBoot.cpp index f97df3014..19b0b6860 100644 --- a/rEFIt_UEFI/Platform/LegacyBoot.c +++ b/rEFIt_UEFI/Platform/LegacyBoot.cpp @@ -762,8 +762,8 @@ EFI_STATUS bootPBR(REFIT_VOLUME* volume, BOOLEAN SataReset) UINT16 BbsCount; BBS_TABLE *BbsTable = NULL; BBS_TABLE *BbsTableIt = NULL; - CHAR16 *BbsPriorityTxt; - CHAR16 *BbsDevTypeTxt; + CONST CHAR16 *BbsPriorityTxt; + CONST CHAR16 *BbsDevTypeTxt; MBR_PARTITION_INFO *pMBR = (MBR_PARTITION_INFO*)(UINTN)0x11BE; // typical location boot0 installs it, should be unused otherwise... // diff --git a/rEFIt_UEFI/Platform/Net.c b/rEFIt_UEFI/Platform/Net.cpp similarity index 100% rename from rEFIt_UEFI/Platform/Net.c rename to rEFIt_UEFI/Platform/Net.cpp diff --git a/rEFIt_UEFI/Platform/Nvram.c b/rEFIt_UEFI/Platform/Nvram.cpp similarity index 99% rename from rEFIt_UEFI/Platform/Nvram.c rename to rEFIt_UEFI/Platform/Nvram.cpp index 19c5c3642..8f1959784 100644 --- a/rEFIt_UEFI/Platform/Nvram.c +++ b/rEFIt_UEFI/Platform/Nvram.cpp @@ -91,7 +91,7 @@ GetEfiTimeInMs ( /** Reads and returns value of NVRAM variable. */ VOID *GetNvramVariable ( - IN CHAR16 *VariableName, + IN CONST CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, OUT UINTN *DataSize OPTIONAL) @@ -135,7 +135,7 @@ VOID *GetNvramVariable ( /** Sets NVRAM variable. Does nothing if variable with the same data and attributes already exists. */ EFI_STATUS SetNvramVariable ( - IN CHAR16 *VariableName, + IN CONST CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, @@ -181,7 +181,7 @@ SetNvramVariable ( /** Sets NVRAM variable. Does nothing if variable with the same name already exists. */ EFI_STATUS AddNvramVariable ( - IN CHAR16 *VariableName, + IN CONST CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, @@ -207,7 +207,7 @@ AddNvramVariable ( /** Deletes NVRAM variable. */ EFI_STATUS DeleteNvramVariable ( - IN CHAR16 *VariableName, + IN CONST CHAR16 *VariableName, IN EFI_GUID *VendorGuid ) { @@ -387,7 +387,7 @@ UINT32 TypeFromName(CHAR16 *Name) } -UINT32 FourCharKey(CHAR8 *Name) +UINT32 FourCharKey(CONST CHAR8 *Name) { return (Name[0] << 24) + (Name[1] << 16) + (Name[2] << 8) + Name[3]; //Big Endian } @@ -814,7 +814,7 @@ GetEfiBootDeviceFromNvram () EFI_STATUS LoadNvramPlist ( IN EFI_FILE *RootDir, - IN CHAR16* NVRAMPlistPath + IN CONST CHAR16* NVRAMPlistPath ) { EFI_STATUS Status; @@ -1097,7 +1097,7 @@ FindStartupDiskVolume ( REFIT_VOLUME *Volume; REFIT_VOLUME *DiskVolume; BOOLEAN IsPartitionVolume; - CHAR16 *LoaderPath; + CONST CHAR16 *LoaderPath; CHAR16 *EfiBootVolumeStr; @@ -1313,7 +1313,7 @@ FindStartupDiskVolume ( /** Sets efi-boot-device-data RT var to currently selected Volume and LoadePath. */ EFI_STATUS SetStartupDiskVolume ( IN REFIT_VOLUME *Volume, - IN CHAR16 *LoaderPath + IN CONST CHAR16 *LoaderPath ) { EFI_STATUS Status; @@ -1321,7 +1321,7 @@ EFI_STATUS SetStartupDiskVolume ( EFI_DEVICE_PATH_PROTOCOL *FileDevPath; EFI_GUID *Guid; CHAR8 *EfiBootDevice; - CHAR8 *EfiBootDeviceTmpl; + CONST CHAR8 *EfiBootDeviceTmpl; UINTN Size; UINT32 Attributes; diff --git a/rEFIt_UEFI/Platform/Platform.h b/rEFIt_UEFI/Platform/Platform.h index 546b16544..17c71964d 100644 --- a/rEFIt_UEFI/Platform/Platform.h +++ b/rEFIt_UEFI/Platform/Platform.h @@ -76,6 +76,8 @@ extern "C" { #include #include +} + #include "../refit/lib.h" #include "string.h" #include "boot.h" @@ -789,14 +791,14 @@ struct CUSTOM_LOADER_ENTRY { CUSTOM_LOADER_ENTRY *SubEntries; EG_IMAGE *Image; EG_IMAGE *DriveImage; - CHAR16 *ImagePath; - CHAR16 *DriveImagePath; - CHAR16 *Volume; - CHAR16 *Path; - CHAR16 *Options; - CHAR16 *FullTitle; - CHAR16 *Title; - CHAR16 *Settings; + CONST CHAR16 *ImagePath; + CONST CHAR16 *DriveImagePath; + CONST CHAR16 *Volume; + CONST CHAR16 *Path; + CONST CHAR16 *Options; + CONST CHAR16 *FullTitle; + CONST CHAR16 *Title; + CONST CHAR16 *Settings; CHAR16 Hotkey; BOOLEAN CommonSettings; UINT8 Flags; @@ -814,11 +816,11 @@ struct CUSTOM_LEGACY_ENTRY { CUSTOM_LEGACY_ENTRY *Next; EG_IMAGE *Image; EG_IMAGE *DriveImage; - CHAR16 *ImagePath; - CHAR16 *DriveImagePath; - CHAR16 *Volume; - CHAR16 *FullTitle; - CHAR16 *Title; + CONST CHAR16 *ImagePath; + CONST CHAR16 *DriveImagePath; + CONST CHAR16 *Volume; + CONST CHAR16 *FullTitle; + CONST CHAR16 *Title; CHAR16 Hotkey; UINT8 Flags; UINT8 Type; @@ -1414,7 +1416,7 @@ typedef struct { UINT32 pad1; UINT32 ModuleSize; UINT32 Frequency; - CHAR8* Vendor; + CONST CHAR8* Vendor; CHAR8* PartNo; CHAR8* SerialNo; } RAM_SLOT_INFO; @@ -1579,7 +1581,7 @@ typedef struct { /// /// Null terminated BootOption Description (pointer to 6th byte of Variable). /// - CHAR16 *Description; + CONST CHAR16 *Description; /// /// Size in bytes of BootOption Description. /// @@ -1614,29 +1616,29 @@ extern BOOLEAN DoHibernateWake; /* Switch for APFS support */ extern UINTN APFSUUIDBankCounter; extern UINT8 *APFSUUIDBank; -extern CHAR16 **SystemPlists; -extern CHAR16 **InstallPlists; -extern CHAR16 **RecoveryPlists; +extern CONST CHAR16 **SystemPlists; +extern CONST CHAR16 **InstallPlists; +extern CONST CHAR16 **RecoveryPlists; extern EFI_GUID APFSSignature; extern BOOLEAN APFSSupport; //extern UINT32 gCpuSpeed; //kHz //extern UINT16 gCPUtype; extern UINT64 TurboMsr; -extern CHAR8 *BiosVendor; +extern CONST CHAR8 *BiosVendor; extern EFI_GUID *gEfiBootDeviceGuid; extern EFI_DEVICE_PATH_PROTOCOL *gEfiBootDeviceData; extern CHAR8 *AppleSystemVersion[]; extern CHAR8 *AppleFirmwareVersion[]; extern CHAR8 *AppleReleaseDate[]; -extern CHAR8 *AppleManufacturer; +extern CONST CHAR8 *AppleManufacturer; extern CHAR8 *AppleProductName[]; extern CHAR8 *AppleSystemVersion[]; extern CHAR8 *AppleSerialNumber[]; extern CHAR8 *AppleFamilies[]; extern CHAR8 *AppleBoardID[]; extern CHAR8 *AppleChassisAsset[]; -extern CHAR8 *AppleBoardSN; -extern CHAR8 *AppleBoardLocation; +extern CONST CHAR8 *AppleBoardSN; +extern CONST CHAR8 *AppleBoardLocation; extern EFI_SYSTEM_TABLE *gST; extern EFI_BOOT_SERVICES *gBS; extern SETTINGS_DATA gSettings; @@ -1715,7 +1717,7 @@ extern SIDELOAD_KEXT *InjectKextList; // Hold theme fixed IconFormat / extension extern CHAR16 *IconFormat; -extern CHAR16 *gFirmwareRevision; +extern CONST CHAR16 *gFirmwareRevision; extern BOOLEAN ResumeFromCoreStorage; extern BOOLEAN gRemapSmBiosIsRequire; // syscl: pass argument for Dell SMBIOS here @@ -1772,7 +1774,7 @@ SetupBooterLog ( EFI_STATUS SaveBooterLog ( IN EFI_FILE_HANDLE BaseDir OPTIONAL, - IN CHAR16 *FileName + IN CONST CHAR16 *FileName ); VOID @@ -1868,9 +1870,9 @@ CHAR8 IN LOADER_ENTRY *Entry ); -CHAR16 +CONST CHAR16 *GetOSIconName ( - IN CHAR8 *OSVersion + IN CONST CHAR8 *OSVersion ); EFI_STATUS @@ -1897,7 +1899,7 @@ InitTheme ( ); EFI_STATUS -StartupSoundPlay(EFI_FILE *Dir, CHAR16* SoundFile); +StartupSoundPlay(EFI_FILE *Dir, CONST CHAR16* SoundFile); VOID GetOutputs(); @@ -1938,7 +1940,7 @@ ParseLoadOptions ( // VOID *GetNvramVariable ( - IN CHAR16 *VariableName, + IN CONST CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, OUT UINTN *DataSize OPTIONAL @@ -1946,7 +1948,7 @@ VOID EFI_STATUS AddNvramVariable ( - IN CHAR16 *VariableName, + IN CONST CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, @@ -1955,7 +1957,7 @@ AddNvramVariable ( EFI_STATUS SetNvramVariable ( - IN CHAR16 *VariableName, + IN CONST CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, @@ -1964,7 +1966,7 @@ SetNvramVariable ( EFI_STATUS DeleteNvramVariable ( - IN CHAR16 *VariableName, + IN CONST CHAR16 *VariableName, IN EFI_GUID *VendorGuid ); @@ -2008,7 +2010,7 @@ FindStartupDiskVolume ( EFI_STATUS SetStartupDiskVolume ( IN REFIT_VOLUME *Volume, - IN CHAR16 *LoaderPath + IN CONST CHAR16 *LoaderPath ); VOID @@ -2022,7 +2024,7 @@ EFI_STATUS EFIAPI LogDataHub ( EFI_GUID *TypeGuid, - CHAR16 *Name, + CONST CHAR16 *Name, VOID *Data, UINT32 DataSize ); @@ -2058,7 +2060,7 @@ setup_gma_devprop ( pci_dt_t *gma_dev ); -CHAR8 +CONST CHAR8 *get_gma_model ( IN UINT16 DeviceID ); @@ -2083,7 +2085,7 @@ setup_nvidia_devprop ( pci_dt_t *nvda_dev ); -CHAR8 +CONST CHAR8 *get_nvidia_model ( UINT32 device_id, UINT32 subsys_id, @@ -2126,7 +2128,7 @@ EFI_STATUS PatchACPI(IN REFIT_VOLUME *Volume, CHAR8 *OSVersion); EFI_STATUS -PatchACPI_OtherOS(CHAR16* OsSubdir, BOOLEAN DropSSDT); +PatchACPI_OtherOS(CONST CHAR16* OsSubdir, BOOLEAN DropSSDT); UINT8 Checksum8 ( @@ -2279,7 +2281,7 @@ SaveSettings (VOID); UINTN iStrLen( - CHAR8* String, + CONST CHAR8* String, UINTN MaxLen ); @@ -2343,8 +2345,8 @@ INTN countOccurrences(CHAR8 *s, CHAR8 c); -CHAR16 *AddLoadOption(IN CHAR16 *LoadOptions, IN CHAR16 *LoadOption); -CHAR16 *RemoveLoadOption(IN CHAR16 *LoadOptions, IN CHAR16 *LoadOption); +CHAR16 *AddLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOption); +CHAR16 *RemoveLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOption); // // BootOptions.c @@ -2419,9 +2421,9 @@ FindBootOptionForFile ( EFI_STATUS AddBootOptionForFile ( IN EFI_HANDLE FileDeviceHandle, - IN CHAR16 *FileName, + IN CONST CHAR16 *FileName, IN BOOLEAN UseShortForm, - IN CHAR16 *Description, + IN CONST CHAR16 *Description, IN UINT8 *OptionalData, IN UINTN OptionalDataSize, IN UINTN BootIndex, @@ -2439,7 +2441,7 @@ DeleteBootOption ( EFI_STATUS DeleteBootOptionForFile ( IN EFI_HANDLE FileDeviceHandle, - IN CHAR16 *FileName + IN CONST CHAR16 *FileName ); /** Deletes all boot option that points to a file which contains FileName in it's path. */ @@ -2474,7 +2476,7 @@ RegisterDriversToHighestPriority ( EFI_STATUS LoadUserSettings ( IN EFI_FILE *RootDir, - CHAR16 *ConfName, + CONST CHAR16 *ConfName, TagPtr *dict ); @@ -2516,15 +2518,15 @@ PrepareHibernation ( // INTN StrniCmp ( - IN CHAR16 *Str1, - IN CHAR16 *Str2, + IN CONST CHAR16 *Str1, + IN CONST CHAR16 *Str2, IN UINTN Count ); -CHAR16 +CONST CHAR16 *StriStr( - IN CHAR16 *Str, - IN CHAR16 *SearchFor + IN CONST CHAR16 *Str, + IN CONST CHAR16 *SearchFor ); VOID @@ -2534,18 +2536,14 @@ StrToLower ( VOID AlertMessage ( - IN CHAR16 *Title, - IN CHAR16 *Message + IN CONST CHAR16 *Title, + IN CONST CHAR16 *Message ); BOOLEAN YesNoMessage ( - IN CHAR16 *Title, - IN CHAR16 *Message); + IN CONST CHAR16 *Title, + IN CONST CHAR16 *Message); -#ifdef __cplusplus -} -#endif - #endif diff --git a/rEFIt_UEFI/Platform/PlatformDriverOverride.c b/rEFIt_UEFI/Platform/PlatformDriverOverride.cpp similarity index 100% rename from rEFIt_UEFI/Platform/PlatformDriverOverride.c rename to rEFIt_UEFI/Platform/PlatformDriverOverride.cpp diff --git a/rEFIt_UEFI/Platform/Pointer.c b/rEFIt_UEFI/Platform/Pointer.cpp similarity index 100% rename from rEFIt_UEFI/Platform/Pointer.c rename to rEFIt_UEFI/Platform/Pointer.cpp diff --git a/rEFIt_UEFI/Platform/Settings.c b/rEFIt_UEFI/Platform/Settings.cpp similarity index 99% rename from rEFIt_UEFI/Platform/Settings.c rename to rEFIt_UEFI/Platform/Settings.cpp index b0ecdafea..0898025c4 100644 --- a/rEFIt_UEFI/Platform/Settings.c +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -77,9 +77,9 @@ UINT16 dropDSM; BOOLEAN GetLegacyLanAddress; BOOLEAN ResumeFromCoreStorage; BOOLEAN gRemapSmBiosIsRequire; -CHAR16 **SystemPlists = NULL; -CHAR16 **InstallPlists = NULL; -CHAR16 **RecoveryPlists = NULL; +CONST CHAR16 **SystemPlists = NULL; +CONST CHAR16 **InstallPlists = NULL; +CONST CHAR16 **RecoveryPlists = NULL; // QPI BOOLEAN SetTable132 = FALSE; @@ -342,7 +342,7 @@ ParseLoadOptions ( CHAR8 *Start; UINTN TailSize; UINTN i; - CHAR8 *PlistStrings[] = + CONST CHAR8 *PlistStrings[] = { "type == kTagTypeString)) { if (Entry->Options != NULL) { - CHAR16 *OldOptions = Entry->Options; + CONST CHAR16 *OldOptions = Entry->Options; Entry->Options = PoolPrint (L"%s %a", OldOptions, Prop->string); FreePool (OldOptions); } else { @@ -6508,14 +6508,14 @@ GetUserSettings( return EFI_SUCCESS; } -static CHAR8 *SearchString ( - IN CHAR8 *Source, +static CONST CHAR8 *SearchString ( + IN CONST CHAR8 *Source, IN UINT64 SourceSize, - IN CHAR8 *Search, + IN CONST CHAR8 *Search, IN UINTN SearchSize ) { - CHAR8 *End = Source + SourceSize; + CONST CHAR8 *End = Source + SourceSize; while (Source < End) { if (CompareMem(Source, Search, SearchSize) == 0) { @@ -6572,7 +6572,7 @@ CHAR8 *GetOSVersion(IN LOADER_ENTRY *Entry) // 1st stage - 1 // Check for plist - createinstallmedia/BaseSystem/InstallDVD/InstallESD - CHAR16 *InstallerPlist = L"\\.IABootFilesSystemVersion.plist"; // 10.9 - 10.13.3 + CONST CHAR16 *InstallerPlist = L"\\.IABootFilesSystemVersion.plist"; // 10.9 - 10.13.3 if (!FileExists (Entry->Volume->RootDir, InstallerPlist) && FileExists (Entry->Volume->RootDir, L"\\System\\Library\\CoreServices\\boot.efi") && ((FileExists (Entry->Volume->RootDir, L"\\BaseSystem.dmg") && FileExists (Entry->Volume->RootDir, L"\\mach_kernel")) || // 10.7/10.8 FileExists (Entry->Volume->RootDir, L"\\System\\Installation\\CDIS\\Mac OS X Installer.app") || // 10.6/10.7 @@ -6678,13 +6678,13 @@ CHAR8 *GetOSVersion(IN LOADER_ENTRY *Entry) // Check for ia.log - InstallESD/createinstallmedia/startosinstall // Implemented by Sherlocks if (OSVersion == NULL) { - CHAR8 *s, *fileBuffer, *targetString; + CONST CHAR8 *s, *fileBuffer, *targetString; CHAR8 *Res5 = (__typeof__(Res5))AllocateZeroPool(5); CHAR8 *Res6 = (__typeof__(Res6))AllocateZeroPool(6); CHAR8 *Res7 = (__typeof__(Res7))AllocateZeroPool(7); CHAR8 *Res8 = (__typeof__(Res8))AllocateZeroPool(8); UINTN fileLen = 0; - CHAR16 *InstallerLog = L"\\Mac OS X Install Data\\ia.log"; // 10.7 + CONST CHAR16 *InstallerLog = L"\\Mac OS X Install Data\\ia.log"; // 10.7 if (!FileExists (Entry->Volume->RootDir, InstallerLog)) { InstallerLog = L"\\OS X Install Data\\ia.log"; // 10.8 - 10.11 if (!FileExists (Entry->Volume->RootDir, InstallerLog)) { @@ -6806,12 +6806,12 @@ CHAR8 *GetOSVersion(IN LOADER_ENTRY *Entry) return OSVersion; } -CHAR16 +CONST CHAR16 *GetOSIconName ( - IN CHAR8 *OSVersion + IN CONST CHAR8 *OSVersion ) { - CHAR16 *OSIconName; + CONST CHAR16 *OSIconName; if (OSVersion == NULL) { OSIconName = L"mac"; } else if (AsciiStrStr (OSVersion, "10.15") != 0) { @@ -6868,9 +6868,9 @@ GetRootUUID (IN REFIT_VOLUME *Volume) TagPtr Prop; CHAR16 Uuid[40]; - CHAR16* SystemPlistR; - CHAR16* SystemPlistP; - CHAR16* SystemPlistS; + CONST CHAR16* SystemPlistR; + CONST CHAR16* SystemPlistP; + CONST CHAR16* SystemPlistS; BOOLEAN HasRock; BOOLEAN HasPaper; @@ -7029,7 +7029,7 @@ GetDevices () ((Pci.Hdr.ClassCode[1] == (PCI_CLASS_DISPLAY_VGA)) || (Pci.Hdr.ClassCode[1] == (PCI_CLASS_DISPLAY_OTHER))) && (NGFX < 4)) { - CHAR8 *CardFamily = ""; + CONST CHAR8 *CardFamily = ""; UINT16 UFamily; GFX_PROPERTIES *gfx = &gGraphics[NGFX]; diff --git a/rEFIt_UEFI/Platform/StartupSound.c b/rEFIt_UEFI/Platform/StartupSound.cpp similarity index 99% rename from rEFIt_UEFI/Platform/StartupSound.c rename to rEFIt_UEFI/Platform/StartupSound.cpp index f0cf5f8f0..76313ef65 100644 --- a/rEFIt_UEFI/Platform/StartupSound.c +++ b/rEFIt_UEFI/Platform/StartupSound.cpp @@ -58,7 +58,7 @@ EFI_AUDIO_IO_PROTOCOL *AudioIo = NULL; EFI_STATUS -StartupSoundPlay(EFI_FILE *Dir, CHAR16* SoundFile) +StartupSoundPlay(EFI_FILE *Dir, CONST CHAR16* SoundFile) { EFI_STATUS Status = EFI_NOT_FOUND; UINT8 *FileData = NULL; diff --git a/rEFIt_UEFI/Platform/StateGenerator.c b/rEFIt_UEFI/Platform/StateGenerator.cpp similarity index 100% rename from rEFIt_UEFI/Platform/StateGenerator.c rename to rEFIt_UEFI/Platform/StateGenerator.cpp diff --git a/rEFIt_UEFI/Platform/ati.c b/rEFIt_UEFI/Platform/ati.cpp similarity index 99% rename from rEFIt_UEFI/Platform/ati.c rename to rEFIt_UEFI/Platform/ati.cpp index 5adb58b93..4124e8617 100644 --- a/rEFIt_UEFI/Platform/ati.c +++ b/rEFIt_UEFI/Platform/ati.cpp @@ -1452,7 +1452,7 @@ BOOLEAN get_binimage_owr(value_t *val, INTN index, BOOLEAN Sier) BOOLEAN get_romrevision_val(value_t *val, INTN index, BOOLEAN Sier) { - CHAR8* cRev="109-B77101-00"; + CONST CHAR8* cRev="109-B77101-00"; UINT8 *rev; if (!card->rom){ val->type = kPtr; @@ -1561,12 +1561,14 @@ VOID devprop_add_list(AtiDevProp devprop_list[], CHAR8 *OSVersion) if (devprop_list[i].all_ports) { for (pnum = 1; pnum < card->ports; pnum++) { if (devprop_list[i].get_value(val, pnum, Sier)) { - devprop_list[i].name[1] = (CHAR8)(0x30 + pnum); // convert to ascii - devprop_add_value(card->device, devprop_list[i].name, val->data, val->size); + char newname[AsciiStrLen(devprop_list[i].name)+1]; + AsciiStrCpy(newname, devprop_list[i].name); + newname[1] = (CHAR8)(0x30 + pnum); // convert to ascii + devprop_add_value(card->device, newname, val->data, val->size); free_val(val); } } - devprop_list[i].name[1] = 0x30; // write back our "@0," for a next possible card +// devprop_list[i].name[1] = 0x30; // write back our "@0," for a next possible card } } else { if (devprop_list[i].default_val.type != kNul) { @@ -1579,14 +1581,15 @@ VOID devprop_add_list(AtiDevProp devprop_list[], CHAR8 *OSVersion) if (devprop_list[i].all_ports) { for (pnum = 1; pnum < card->ports; pnum++) { if (devprop_list[i].default_val.type != kNul) { - devprop_list[i].name[1] = (CHAR8)(0x30 + pnum); // convert to ascii - devprop_add_value(card->device, devprop_list[i].name, + char newname[AsciiStrLen(devprop_list[i].name)+1]; + newname[1] = (CHAR8)(0x30 + pnum); // convert to ascii + devprop_add_value(card->device, newname, devprop_list[i].default_val.type == kCst ? (UINT8 *)&(devprop_list[i].default_val.data) : devprop_list[i].default_val.data, devprop_list[i].default_val.size); } } - devprop_list[i].name[1] = 0x30; // write back our "@0," for a next possible card +// devprop_list[i].name[1] = 0x30; // write back our "@0," for a next possible card } } } diff --git a/rEFIt_UEFI/Platform/ati.h b/rEFIt_UEFI/Platform/ati.h index 9a59425b1..233a99c7d 100644 --- a/rEFIt_UEFI/Platform/ati.h +++ b/rEFIt_UEFI/Platform/ati.h @@ -277,7 +277,7 @@ typedef struct { typedef struct { UINT32 flags; BOOLEAN all_ports; - CHAR8 *name; + CONST CHAR8 *name; BOOLEAN (*get_value)(value_t *val, INTN index, BOOLEAN Sier); value_t default_val; } AtiDevProp; diff --git a/rEFIt_UEFI/Platform/b64cdecode.c b/rEFIt_UEFI/Platform/b64cdecode.cpp similarity index 100% rename from rEFIt_UEFI/Platform/b64cdecode.c rename to rEFIt_UEFI/Platform/b64cdecode.cpp diff --git a/rEFIt_UEFI/Platform/card_vlist.c b/rEFIt_UEFI/Platform/card_vlist.cpp similarity index 97% rename from rEFIt_UEFI/Platform/card_vlist.c rename to rEFIt_UEFI/Platform/card_vlist.cpp index c65e2533c..ec779802d 100644 --- a/rEFIt_UEFI/Platform/card_vlist.c +++ b/rEFIt_UEFI/Platform/card_vlist.cpp @@ -104,12 +104,12 @@ CARDLIST* FindCardWithIds(UINT32 Id, UINT32 SubId) VOID FillCardList(TagPtr CfgDict) { if (IsListEmpty(&gCardList) && (CfgDict != NULL)) { - CHAR8 *VEN[] = { "NVIDIA", "ATI" }; + CONST CHAR8 *VEN[] = { "NVIDIA", "ATI" }; INTN Index, Count = sizeof(VEN) / sizeof(VEN[0]); TagPtr prop; for (Index = 0; Index < Count; Index++) { - CHAR8 *key = VEN[Index]; + CONST CHAR8 *key = VEN[Index]; prop = GetProperty(CfgDict, key); if(prop && (prop->type == kTagTypeArray)) { @@ -120,7 +120,7 @@ VOID FillCardList(TagPtr CfgDict) TagPtr prop2 = 0; count = GetTagCount(prop); for (i = 0; i < count; i++) { - CHAR8 *model_name = NULL; + CONST CHAR8 *model_name = NULL; UINT32 dev_id = 0; UINT32 subdev_id = 0; UINT64 VramSize = 0; diff --git a/rEFIt_UEFI/Platform/cpu.c b/rEFIt_UEFI/Platform/cpu.cpp similarity index 100% rename from rEFIt_UEFI/Platform/cpu.c rename to rEFIt_UEFI/Platform/cpu.cpp diff --git a/rEFIt_UEFI/Platform/device_inject.c b/rEFIt_UEFI/Platform/device_inject.cpp similarity index 99% rename from rEFIt_UEFI/Platform/device_inject.c rename to rEFIt_UEFI/Platform/device_inject.cpp index 79a9b5d84..a91119d71 100644 --- a/rEFIt_UEFI/Platform/device_inject.c +++ b/rEFIt_UEFI/Platform/device_inject.cpp @@ -210,7 +210,7 @@ DevPropDevice *devprop_add_device_pci(DevPropString *StringBuf, pci_dt_t *PciDt, -BOOLEAN devprop_add_value(DevPropDevice *device, CHAR8 *nm, UINT8 *vl, UINTN len) +BOOLEAN devprop_add_value(DevPropDevice *device, CONST CHAR8 *nm, UINT8 *vl, UINTN len) { UINT32 offset; UINT32 off; diff --git a/rEFIt_UEFI/Platform/device_inject.h b/rEFIt_UEFI/Platform/device_inject.h index 3f20bd1e0..9fdddca08 100644 --- a/rEFIt_UEFI/Platform/device_inject.h +++ b/rEFIt_UEFI/Platform/device_inject.h @@ -162,7 +162,7 @@ extern UINT32 device_inject_stringlength; DevPropString *devprop_create_string(void); //DevPropDevice *devprop_add_device(DevPropString *string, char *path); DevPropDevice *devprop_add_device_pci(DevPropString *string, pci_dt_t *PciDt, EFI_DEVICE_PATH_PROTOCOL *DevicePath); -BOOLEAN devprop_add_value(DevPropDevice *device, CHAR8 *nm, UINT8 *vl, UINTN len); +BOOLEAN devprop_add_value(DevPropDevice *device, CONST CHAR8 *nm, UINT8 *vl, UINTN len); CHAR8 *devprop_generate_string(DevPropString *string); VOID devprop_free_string(DevPropString *string); diff --git a/rEFIt_UEFI/Platform/gma.c b/rEFIt_UEFI/Platform/gma.cpp similarity index 99% rename from rEFIt_UEFI/Platform/gma.c rename to rEFIt_UEFI/Platform/gma.cpp index fc6ed3a65..ef7ce94b0 100644 --- a/rEFIt_UEFI/Platform/gma.c +++ b/rEFIt_UEFI/Platform/gma.cpp @@ -78,7 +78,7 @@ #define DBG(...) DebugLog(DEBUG_GMA, __VA_ARGS__) #endif -CHAR16 *CFLFBPath = L"/System/Library/Extensions/AppleIntelCFLGraphicsFramebuffer.kext"; +CONST CHAR16 *CFLFBPath = L"/System/Library/Extensions/AppleIntelCFLGraphicsFramebuffer.kext"; extern CHAR8* gDeviceProperties; extern CHAR8 ClassFix[]; @@ -940,9 +940,9 @@ static struct gma_gpu_t KnownGPUS[] = { }; -CHAR8 *get_gma_model(UINT16 id) +CONST CHAR8 *get_gma_model(UINT16 id) { - INT32 i; + UINTN i; for (i = 0; i < (sizeof(KnownGPUS) / sizeof(KnownGPUS[0])); i++) { @@ -958,7 +958,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev) UINTN j; UINTN i; CHAR8 *devicepath; - CHAR8 *model; + CONST CHAR8 *model; DevPropDevice *device = NULL; UINT8 BuiltIn = 0x00; UINT32 FakeID; diff --git a/rEFIt_UEFI/Platform/gma.h b/rEFIt_UEFI/Platform/gma.h index ef788d74d..d18d8c03e 100644 --- a/rEFIt_UEFI/Platform/gma.h +++ b/rEFIt_UEFI/Platform/gma.h @@ -6,7 +6,7 @@ BOOLEAN setup_gma_devprop(LOADER_ENTRY *Entry, pci_dt_t *gma_dev); struct gma_gpu_t { UINT32 device; - CHAR8 *name; + CONST CHAR8 *name; }; /* diff --git a/rEFIt_UEFI/Platform/guid.c b/rEFIt_UEFI/Platform/guid.cpp similarity index 100% rename from rEFIt_UEFI/Platform/guid.c rename to rEFIt_UEFI/Platform/guid.cpp diff --git a/rEFIt_UEFI/Platform/hda.c b/rEFIt_UEFI/Platform/hda.cpp similarity index 100% rename from rEFIt_UEFI/Platform/hda.c rename to rEFIt_UEFI/Platform/hda.cpp diff --git a/rEFIt_UEFI/Platform/kernel_patcher.c b/rEFIt_UEFI/Platform/kernel_patcher.cpp similarity index 99% rename from rEFIt_UEFI/Platform/kernel_patcher.c rename to rEFIt_UEFI/Platform/kernel_patcher.cpp index 8f117b900..e7d575b95 100644 --- a/rEFIt_UEFI/Platform/kernel_patcher.c +++ b/rEFIt_UEFI/Platform/kernel_patcher.cpp @@ -872,7 +872,7 @@ BOOLEAN HaswellEXCPM(VOID *kernelData, LOADER_ENTRY *Entry, BOOLEAN use_xcpm_idl { DBG("HaswellEXCPM() ===>\n"); UINT8 *kern = (UINT8*)kernelData; - CHAR8 *comment; + CONST CHAR8 *comment; UINT32 i; UINT32 patchLocation; UINT64 os_version = AsciiOSVersionToUint64(Entry->OSVersion); @@ -1067,7 +1067,7 @@ BOOLEAN HaswellLowEndXCPM(VOID *kernelData, LOADER_ENTRY *Entry, BOOLEAN use_xcp DBG("HaswellLowEndXCPM() ===>\n"); UINT8 *kern = (UINT8*)kernelData; UINT64 os_version = AsciiOSVersionToUint64(Entry->OSVersion); - CHAR8 *comment; + CONST CHAR8 *comment; // check OS version suit for patches if (!IsXCPMOSVersionCompat(os_version)) { @@ -1137,7 +1137,7 @@ BOOLEAN HaswellLowEndXCPM(VOID *kernelData, LOADER_ENTRY *Entry, BOOLEAN use_xcp BOOLEAN KernelIvyBridgeXCPM(VOID *kernelData, LOADER_ENTRY *Entry, BOOLEAN use_xcpm_idle) { UINT8 *kern = (UINT8*)kernelData; - CHAR8 *comment; + CONST CHAR8 *comment; UINT32 i; UINT32 patchLocation; UINT64 os_version = AsciiOSVersionToUint64(Entry->OSVersion); @@ -1221,7 +1221,7 @@ BOOLEAN KernelIvyBridgeXCPM(VOID *kernelData, LOADER_ENTRY *Entry, BOOLEAN use_x BOOLEAN KernelIvyE5XCPM(VOID *kernelData, LOADER_ENTRY *Entry, BOOLEAN use_xcpm_idle) { UINT8 *kern = (UINT8*)kernelData; - CHAR8 *comment; + CONST CHAR8 *comment; UINT32 i; UINT32 patchLocation; UINT64 os_version = AsciiOSVersionToUint64(Entry->OSVersion); diff --git a/rEFIt_UEFI/Platform/kext_inject.c b/rEFIt_UEFI/Platform/kext_inject.cpp similarity index 99% rename from rEFIt_UEFI/Platform/kext_inject.c rename to rEFIt_UEFI/Platform/kext_inject.cpp index ffd8b7f88..61ba4f2e8 100644 --- a/rEFIt_UEFI/Platform/kext_inject.c +++ b/rEFIt_UEFI/Platform/kext_inject.cpp @@ -288,7 +288,7 @@ VOID LoadPlugInKexts(IN LOADER_ENTRY *Entry, IN EFI_FILE *RootDir, IN CHAR16 *Di DirIterClose(&PlugInIter); } -VOID AddKexts(IN LOADER_ENTRY *Entry, CHAR16 *SrcDir, CHAR16 *Path/*, CHAR16 *UniSysVers*/, cpu_type_t archCpuType) +VOID AddKexts(IN LOADER_ENTRY *Entry, CONST CHAR16 *SrcDir, CONST CHAR16 *Path/*, CHAR16 *UniSysVers*/, cpu_type_t archCpuType) { CHAR16 *FileName; CHAR16 *PlugInName; @@ -342,8 +342,8 @@ EFI_STATUS LoadKexts(IN LOADER_ENTRY *Entry) EFI_FILE_INFO *PlugInFile; CHAR16 *FileName; CHAR16 *PlugIns; - CHAR16 *Arch = NULL; - CHAR16 *Ptr = NULL; + CONST CHAR16 *Arch = NULL; + CONST CHAR16 *Ptr = NULL; #if defined(MDE_CPU_X64) cpu_type_t archCpuType=CPU_TYPE_X86_64; #else diff --git a/rEFIt_UEFI/Platform/kext_patcher.c b/rEFIt_UEFI/Platform/kext_patcher.cpp similarity index 99% rename from rEFIt_UEFI/Platform/kext_patcher.c rename to rEFIt_UEFI/Platform/kext_patcher.cpp index 5d1257f6c..c93cafe56 100644 --- a/rEFIt_UEFI/Platform/kext_patcher.c +++ b/rEFIt_UEFI/Platform/kext_patcher.cpp @@ -224,7 +224,7 @@ VOID ExtractKextBundleIdentifier(CHAR8 *Plist) if (BIStart != NULL) { BIStart += 8; // skip "" BIEnd = AsciiStrStr(BIStart, ""); - if (BIEnd != NULL && (BIEnd - BIStart + 1) < sizeof(gKextBundleIdentifier)) { + if (BIEnd != NULL && (UINTN)(BIEnd - BIStart + 1) < sizeof(gKextBundleIdentifier)) { // (UINTN)(BIEnd - BIStart + 1) = valid cast because BIEnd is > BIStart CopyMem(gKextBundleIdentifier, BIStart, BIEnd - BIStart); gKextBundleIdentifier[BIEnd - BIStart] = '\0'; return; @@ -1139,7 +1139,7 @@ VOID PatchKext(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPl // This func is hard to read and debug and probably not reliable, // but it seems it works. // -UINT64 GetPlistHexValue(CHAR8 *Plist, CHAR8 *Key, CHAR8 *WholePlist) +UINT64 GetPlistHexValue(CONST CHAR8 *Plist, CONST CHAR8 *Key, CONST CHAR8 *WholePlist) { CHAR8 *Value; CHAR8 *IntTag; diff --git a/rEFIt_UEFI/Platform/memvendors.h b/rEFIt_UEFI/Platform/memvendors.h index 1bba89706..74f7f98e9 100644 --- a/rEFIt_UEFI/Platform/memvendors.h +++ b/rEFIt_UEFI/Platform/memvendors.h @@ -48,7 +48,7 @@ typedef struct _vidTag { UINT8 bank; UINT8 code; - CHAR8* name; + CONST CHAR8* name; } VenIdName; VenIdName vendorMap[] = { diff --git a/rEFIt_UEFI/Platform/nvidia.c b/rEFIt_UEFI/Platform/nvidia.cpp similarity index 99% rename from rEFIt_UEFI/Platform/nvidia.c rename to rEFIt_UEFI/Platform/nvidia.cpp index c2bc71fb0..5a41d0d4a 100644 --- a/rEFIt_UEFI/Platform/nvidia.c +++ b/rEFIt_UEFI/Platform/nvidia.cpp @@ -2004,9 +2004,9 @@ static INT32 patch_nvidia_rom(UINT8 *rom) return (has_lvds ? PATCH_ROM_SUCCESS_HAS_LVDS : PATCH_ROM_SUCCESS); } -CHAR8 *get_nvidia_model(UINT32 device_id, UINT32 subsys_id, CARDLIST * nvcard) +CONST CHAR8 *get_nvidia_model(UINT32 device_id, UINT32 subsys_id, CARDLIST * nvcard) { - INT32 i, j; + UINTN i, j; //DBG("get_nvidia_model for (%08x, %08x)\n", device_id, subsys_id); //ErmaC added selector for nVidia "old" style in System Profiler @@ -2183,7 +2183,7 @@ BOOLEAN setup_nvidia_devprop(pci_dt_t *nvda_dev) // UINT32 boot_display = 0; //UINT32 subsystem; INT32 nvPatch = 0; - CHAR8 *model = NULL; + CONST CHAR8 *model = NULL; CHAR16 FileName[64]; UINT8 *buffer = NULL; UINTN bufferLen = 0; diff --git a/rEFIt_UEFI/Platform/nvidia.h b/rEFIt_UEFI/Platform/nvidia.h index e7bf3aabf..1d8f6b78a 100644 --- a/rEFIt_UEFI/Platform/nvidia.h +++ b/rEFIt_UEFI/Platform/nvidia.h @@ -59,14 +59,14 @@ extern CHAR8* gDeviceProperties; typedef struct nvidia_pci_info_t { UINT32 device; // VendorID + DeviceID - CHAR8 *name_model; + CONST CHAR8 *name_model; } nvidia_pci_info_t; typedef struct nvidia_card_info_t { UINT32 device; // VendorID + DeviceID UINT32 subdev; // SubdeviceID + SubvendorID - CHAR8 *name_model; + CONST CHAR8 *name_model; UINT8 *custom_NVCAP; } nvidia_card_info_t; diff --git a/rEFIt_UEFI/Platform/picopng.c b/rEFIt_UEFI/Platform/picopng.cpp similarity index 100% rename from rEFIt_UEFI/Platform/picopng.c rename to rEFIt_UEFI/Platform/picopng.cpp diff --git a/rEFIt_UEFI/Platform/platformdata.c b/rEFIt_UEFI/Platform/platformdata.cpp similarity index 99% rename from rEFIt_UEFI/Platform/platformdata.c rename to rEFIt_UEFI/Platform/platformdata.cpp index 4592e8e68..b3f53d644 100644 --- a/rEFIt_UEFI/Platform/platformdata.c +++ b/rEFIt_UEFI/Platform/platformdata.cpp @@ -7,12 +7,12 @@ /* Machine Default Data */ -CHAR8 *DefaultMemEntry = "N/A"; -CHAR8 *DefaultSerial = "CT288GT9VT6"; -CHAR8 *BiosVendor = "Apple Inc."; -CHAR8 *AppleManufacturer = "Apple Computer, Inc."; //Old name, before 2007 -CHAR8 *AppleBoardSN = "C02140302D5DMT31M"; -CHAR8 *AppleBoardLocation = "Part Component"; +CONST CHAR8 *DefaultMemEntry = "N/A"; +CONST CHAR8 *DefaultSerial = "CT288GT9VT6"; +CONST CHAR8 *BiosVendor = "Apple Inc."; +CONST CHAR8 *AppleManufacturer = "Apple Computer, Inc."; //Old name, before 2007 +CONST CHAR8 *AppleBoardSN = "C02140302D5DMT31M"; +CONST CHAR8 *AppleBoardLocation = "Part Component"; UINT32 gFwFeatures; UINT32 gFwFeaturesMask; diff --git a/rEFIt_UEFI/Platform/plist.c b/rEFIt_UEFI/Platform/plist.cpp similarity index 98% rename from rEFIt_UEFI/Platform/plist.c rename to rEFIt_UEFI/Platform/plist.cpp index a832de092..1a8af7627 100644 --- a/rEFIt_UEFI/Platform/plist.c +++ b/rEFIt_UEFI/Platform/plist.cpp @@ -60,7 +60,7 @@ EFI_STATUS ParseTagBoolean(CHAR8* buffer, TagPtr * tag, UINT32 type,UINT32* lenP //INTN GetTagCount( TagPtr dict ); TagPtr NewTag( void ); -EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CHAR8* tag,UINT32* lenPtr); +EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag,UINT32* lenPtr); CHAR8* NewSymbol(CHAR8* string); VOID FreeSymbol(CHAR8* string); SymbolPtr FindSymbol( char * string, SymbolPtr * prevSymbol ); @@ -437,7 +437,8 @@ EFI_STATUS XMLParseNextTag(CHAR8* buffer, TagPtr* tag, UINT32* lenPtr) return Status; } - if (length == -1) { + // TODO jief : seems to me that length cannot be -1. Added the cast anyway to avoid regression. If confirmed, the next 3 lines must be removed. + if (length == (UINT32)-1) { DBG("(length == -1)\n"); return EFI_UNSUPPORTED; } @@ -831,7 +832,7 @@ EFI_STATUS GetNextTag( UINT8* buffer, CHAR8** tag, UINT32* start, UINT32* length *length = cnt2 + 1; //unreal to be -1. This is UINT32 - if (*length == -1) { + if (*length == (UINT32)-1) { DBG("GetNextTag with *length == -1\n"); return EFI_UNSUPPORTED; } @@ -845,7 +846,7 @@ EFI_STATUS GetNextTag( UINT8* buffer, CHAR8** tag, UINT32* start, UINT32* length // Returns the length of the data found, counting the end tag, // or -1 if the end tag was not found. -EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CHAR8* tag, UINT32* lenPtr) +EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag, UINT32* lenPtr) { EFI_STATUS Status; UINT32 length; @@ -869,7 +870,7 @@ EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CHAR8* tag, UINT32* lenPtr) buffer[start + stop] = '\0'; *lenPtr = start + length; - if (*lenPtr == -1) { + if (*lenPtr == (UINTN)-1) { // Why is this test. -1 is UINTN_MAX. return EFI_UNSUPPORTED; } diff --git a/rEFIt_UEFI/Platform/smbios.c b/rEFIt_UEFI/Platform/smbios.cpp similarity index 97% rename from rEFIt_UEFI/Platform/smbios.c rename to rEFIt_UEFI/Platform/smbios.cpp index c696617d4..e1878bf31 100644 --- a/rEFIt_UEFI/Platform/smbios.c +++ b/rEFIt_UEFI/Platform/smbios.cpp @@ -217,10 +217,10 @@ VOID* GetSmbiosTablesFromConfigTables (VOID) // search restricted to MaxLen, for example // iStrLen("ABC ", 20) == 3 // if MaxLen=0 then as usual strlen but bugless -UINTN iStrLen(CHAR8* String, UINTN MaxLen) +UINTN iStrLen(CONST CHAR8* String, UINTN MaxLen) { UINTN Len = 0; - CHAR8* BA; + CONST CHAR8* BA; if(MaxLen > 0) { for (Len=0; LenHandle; } -EFI_STATUS UpdateSmbiosString (APPLE_SMBIOS_STRUCTURE_POINTER SmbiosTableN, SMBIOS_TABLE_STRING* Field, CHAR8* Buffer) +EFI_STATUS UpdateSmbiosString (CONST APPLE_SMBIOS_STRUCTURE_POINTER SmbiosTableN, SMBIOS_TABLE_STRING* Field, CHAR8* Buffer) { CHAR8* AString; CHAR8* C1; //pointers for copy @@ -735,7 +735,6 @@ VOID PatchTableType4() UINTN AddBrand = 0; CHAR8 BrandStr[48]; UINT16 ProcChar = 0; - CHAR8 *SocketDesignationMac = "U2E1"; //Note. iMac11,2 has four tables for CPU i3 UINTN CpuNumber; @@ -894,6 +893,8 @@ VOID PatchTableType4() newSmbiosTable.Type4->ProcessorCharacteristics = ProcChar; } + // TODO Jief : looks that the next line modify SocketDesignationMac, which is not used + CHAR8 SocketDesignationMac[] = "U2E1"; UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type4->Socket, SocketDesignationMac); if (AddBrand) { @@ -1346,19 +1347,25 @@ VOID PatchTableType17() UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->DeviceLocator, (CHAR8*)&deviceLocator[0]); if ((gRAM.User[UserIndex].InUse) && (gRAM.User[UserIndex].ModuleSize > 0)) { if (iStrLen(gRAM.User[UserIndex].Vendor, 64) > 0) { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gRAM.User[UserIndex].Vendor); + CHAR8* vendor = (CHAR8*)AllocatePool(AsciiStrLen(gRAM.User[UserIndex].Vendor)+1); // this will never be freed. WIll be solved when using a string object. + AsciiStrCpy(vendor, gRAM.User[UserIndex].Vendor); + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, vendor); + gRAM.User[UserIndex].Vendor = vendor; } else { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, "unknown"); + CHAR8 unknown[] = "unknown"; + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, unknown); } if (iStrLen(gRAM.User[UserIndex].SerialNo, 64) > 0) { UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, gRAM.User[UserIndex].SerialNo); } else { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, "unknown"); + CHAR8 unknown[] = "unknown"; + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, unknown); } if (iStrLen(gRAM.User[UserIndex].PartNo, 64) > 0) { UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, gRAM.User[UserIndex].PartNo); } else { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, "unknown"); + CHAR8 unknown[] = "unknown"; + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, unknown); } newSmbiosTable.Type17->Speed = (UINT16)gRAM.User[UserIndex].Frequency; if (gRAM.User[UserIndex].ModuleSize > 0x7FFF) { @@ -1573,18 +1580,23 @@ VOID PatchTableType17() CopyMem((VOID*)newSmbiosTable.Type17, (VOID *)SmbiosTable.Type17, TableSize); newSmbiosTable.Type17->AssetTag = 0; if (iStrLen(gRAM.SMBIOS[SMBIOSIndex].Vendor, 64) > 0) { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gRAM.SMBIOS[SMBIOSIndex].Vendor); + CHAR8* vendor = (CHAR8*)AllocatePool(AsciiStrLen(gRAM.SMBIOS[SMBIOSIndex].Vendor)+1); // this will never be freed. WIll be solved when using a string object. + AsciiStrCpy(vendor, gRAM.SMBIOS[SMBIOSIndex].Vendor); + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, vendor); + gRAM.SMBIOS[SMBIOSIndex].Vendor = vendor; AsciiSPrint(gSettings.MemoryManufacturer, 64, "%a", gRAM.SMBIOS[SMBIOSIndex].Vendor); } else { // newSmbiosTable.Type17->Manufacturer = 0; - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, "unknown"); + CHAR8 unknown[] = "unknown"; + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, unknown); } if (iStrLen(gRAM.SMBIOS[SMBIOSIndex].SerialNo, 64) > 0) { UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, gRAM.SMBIOS[SMBIOSIndex].SerialNo); AsciiSPrint(gSettings.MemorySerialNumber, 64, "%a", gRAM.SMBIOS[SMBIOSIndex].SerialNo); } else { // newSmbiosTable.Type17->SerialNumber = 0; - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, "unknown"); + CHAR8 unknown[] = "unknown"; + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, unknown); } if (iStrLen(gRAM.SMBIOS[SMBIOSIndex].PartNo, 64) > 0) { UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, gRAM.SMBIOS[SMBIOSIndex].PartNo); @@ -1592,7 +1604,8 @@ VOID PatchTableType17() DBG(" partNum=%a\n", gRAM.SMBIOS[SMBIOSIndex].PartNo); } else { // newSmbiosTable.Type17->PartNumber = 0; - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, "unknown"); + CHAR8 unknown[] = "unknown"; + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, unknown); DBG(" partNum unknown\n"); } } else { @@ -1611,22 +1624,28 @@ VOID PatchTableType17() if (gRAM.SPD[SPDIndex].InUse) { if (iStrLen(gRAM.SPD[SPDIndex].Vendor, 64) > 0) { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gRAM.SPD[SPDIndex].Vendor); + CHAR8* vendor = (CHAR8*)AllocatePool(AsciiStrLen(gRAM.SPD[SPDIndex].Vendor)+1); // this will never be freed. WIll be solved when using a string object. + AsciiStrCpy(vendor, gRAM.SPD[SPDIndex].Vendor); + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, vendor); + gRAM.SPD[SPDIndex].Vendor = vendor; AsciiSPrint(gSettings.MemoryManufacturer, 64, "%a", gRAM.SPD[SPDIndex].Vendor); } else { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, "unknown"); + CHAR8 unknown[] = "unknown"; + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, unknown); } if (iStrLen(gRAM.SPD[SPDIndex].SerialNo, 64) > 0) { UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, gRAM.SPD[SPDIndex].SerialNo); AsciiSPrint(gSettings.MemorySerialNumber, 64, "%a", gRAM.SPD[SPDIndex].SerialNo); } else { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, "unknown"); + CHAR8 unknown[] = "unknown"; + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->SerialNumber, unknown); } if (iStrLen(gRAM.SPD[SPDIndex].PartNo, 64) > 0) { UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, gRAM.SPD[SPDIndex].PartNo); AsciiSPrint(gSettings.MemoryPartNumber, 64, "%a", gRAM.SPD[SPDIndex].PartNo); } else { - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, "unknown"); + CHAR8 unknown[] = "unknown"; + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->PartNumber, unknown); } if (gRAM.Frequency > gRAM.SPD[SPDIndex].Frequency) { newSmbiosTable.Type17->Speed = (UINT16)gRAM.Frequency; @@ -1650,7 +1669,10 @@ VOID PatchTableType17() (iStrLen(gRAM.SMBIOS[SMBIOSIndex].Vendor, 64) > 0) && (AsciiStrnCmp(gRAM.SPD[SPDIndex].Vendor, "NoName", 6) == 0)) { DBG("Type17->Manufacturer corrected by SMBIOS from NoName to %a\n", gRAM.SMBIOS[SMBIOSIndex].Vendor); - UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, gRAM.SMBIOS[SMBIOSIndex].Vendor); + CHAR8* vendor = (CHAR8*)AllocatePool(AsciiStrLen(gRAM.SMBIOS[SMBIOSIndex].Vendor)+1); // this will never be freed. WIll be solved when using a string object. + AsciiStrCpy(vendor, gRAM.SMBIOS[SMBIOSIndex].Vendor); + UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type17->Manufacturer, vendor); + gRAM.SMBIOS[SMBIOSIndex].Vendor = vendor; } AsciiSPrint(gSettings.MemorySpeed, 64, "%d", newSmbiosTable.Type17->Speed); diff --git a/rEFIt_UEFI/Platform/sound.c b/rEFIt_UEFI/Platform/sound.cpp similarity index 100% rename from rEFIt_UEFI/Platform/sound.c rename to rEFIt_UEFI/Platform/sound.cpp diff --git a/rEFIt_UEFI/Platform/spd.c b/rEFIt_UEFI/Platform/spd.cpp similarity index 98% rename from rEFIt_UEFI/Platform/spd.c rename to rEFIt_UEFI/Platform/spd.cpp index 952ef3be9..4134045bf 100644 --- a/rEFIt_UEFI/Platform/spd.c +++ b/rEFIt_UEFI/Platform/spd.cpp @@ -47,7 +47,7 @@ extern UINT16 TotalCount; BOOLEAN smbIntel; UINT8 smbPage; -CHAR8 *spd_memory_types[] = +CONST CHAR8 *spd_memory_types[] = { "RAM", /* 00h Undefined */ "FPM", /* 01h FPM */ @@ -324,25 +324,24 @@ VOID init_spd(UINT16* spd_indexes, UINT8* spd, UINT32 base, UINT8 slot) // Get Vendor Name from spd, 3 cases handled DDR3, DDR4 and DDR2, // have different formats, always return a valid ptr. -CHAR8* getVendorName(RAM_SLOT_INFO* slot, UINT8 *spd, UINT32 base, UINT8 slot_num) +CONST CHAR8* getVendorName(RAM_SLOT_INFO* slot, UINT8 *spd, UINT32 base, UINT8 slot_num) { UINT8 bank = 0; UINT8 code = 0; UINT8 parity; UINT8 testbit; - INTN i = 0; //UINT8 * spd = (UINT8 *) slot->spd; if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR4) { // DDR4 bank = spd[SPD_DDR4_MANUFACTURER_ID_BANK]; code = spd[SPD_DDR4_MANUFACTURER_ID_CODE]; parity = bank; testbit = bank; - for (i=6; i >= 0; i--) { parity ^= (testbit <<= 1); } + for (UINTN i=6; i >= 0; i--) { parity ^= (testbit <<= 1); } if ( (parity & 0x80) == 0 ) { DBG("Bad parity bank=0x%2X code=0x%2X\n", bank, code); } bank &= 0x7f; - for (i=0; i < VEN_MAP_SIZE; i++) { + for (UINTN i=0; i < VEN_MAP_SIZE; i++) { if (bank==vendorMap[i].bank && code==vendorMap[i].code) { return vendorMap[i].name; } @@ -353,13 +352,13 @@ CHAR8* getVendorName(RAM_SLOT_INFO* slot, UINT8 *spd, UINT32 base, UINT8 slot_nu code = spd[SPD_DDR3_MEMORY_CODE]; parity = bank; testbit = bank; - for (i=6; i >= 0; i--) { parity ^= (testbit <<= 1); } + for (UINTN i=6; i >= 0; i--) { parity ^= (testbit <<= 1); } if ( (parity & 0x80) == 0 ) { DBG("Bad parity bank=0x%2X code=0x%2X\n", bank, code); } bank &= 0x7f; - for (i=0; i < VEN_MAP_SIZE; i++) { + for (UINTN i=0; i < VEN_MAP_SIZE; i++) { if (bank==vendorMap[i].bank && code==vendorMap[i].code) { return vendorMap[i].name; } @@ -367,6 +366,7 @@ CHAR8* getVendorName(RAM_SLOT_INFO* slot, UINT8 *spd, UINT32 base, UINT8 slot_nu } else if (spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR2 || spd[SPD_MEMORY_TYPE]==SPD_MEMORY_TYPE_SDRAM_DDR) { if(spd[64]==0x7f) { + UINTN i; for (i=64; i<72 && spd[i]==0x7f;i++) { bank++; READ_SPD(spd, base, slot_num, (UINT8)(i+1)); // prefetch next spd byte to read for next loop @@ -377,7 +377,7 @@ CHAR8* getVendorName(RAM_SLOT_INFO* slot, UINT8 *spd, UINT32 base, UINT8 slot_nu code = spd[64]; bank = 0; } - for (i=0; i < VEN_MAP_SIZE; i++) { + for (UINTN i=0; i < VEN_MAP_SIZE; i++) { if (bank==vendorMap[i].bank && code==vendorMap[i].code) { return vendorMap[i].name; } diff --git a/rEFIt_UEFI/Platform/string.c b/rEFIt_UEFI/Platform/string.cpp similarity index 96% rename from rEFIt_UEFI/Platform/string.c rename to rEFIt_UEFI/Platform/string.cpp index 925accc71..c3b059168 100644 --- a/rEFIt_UEFI/Platform/string.c +++ b/rEFIt_UEFI/Platform/string.cpp @@ -5,7 +5,7 @@ #include "Platform.h" -CHAR8 *NonDetected = "10.10.10"; //longer string +CHAR8 NonDetected[] = "10.10.10"; //longer string /** Convert a Null-terminated ASCII string representing version number (separate by dots) diff --git a/rEFIt_UEFI/Platform/usbfix.c b/rEFIt_UEFI/Platform/usbfix.cpp similarity index 100% rename from rEFIt_UEFI/Platform/usbfix.c rename to rEFIt_UEFI/Platform/usbfix.cpp diff --git a/rEFIt_UEFI/cpp_util/XStringW.cpp b/rEFIt_UEFI/cpp_util/XStringW.cpp index 90b9894bf..23ef90940 100755 --- a/rEFIt_UEFI/cpp_util/XStringW.cpp +++ b/rEFIt_UEFI/cpp_util/XStringW.cpp @@ -223,7 +223,7 @@ void XStringW::vSPrintf(const wchar_t *format, VA_LIST va) spc.Len = 0; spc.Maxlen = m_size; ZeroMem(&ps, sizeof (ps)); - ps.Output = (IN EFI_STATUS (EFIAPI *)(VOID *context, CHAR16 *str))_PoolPrint; + ps.Output = (IN EFI_STATUS (EFIAPI *)(VOID *context, CONST CHAR16 *str))_PoolPrint; ps.Context = (void*)&spc; ps.fmt.u.pw = format; diff --git a/rEFIt_UEFI/cpp_util/memory.cpp b/rEFIt_UEFI/cpp_util/memory.cpp new file mode 100644 index 000000000..2b38b1403 --- /dev/null +++ b/rEFIt_UEFI/cpp_util/memory.cpp @@ -0,0 +1,37 @@ + + +#include "../Platform/Platform.h" + +extern "C" { +/* + * memset and memcpy has to be provided for clang + */ + + +void* memset(void* dst, int ch, UINT64 count) __attribute__ ((used)); +void* memcpy(void* dst, const void* src, UINT64 count) __attribute__ ((used)); + +void* memset(void* dst, int ch, UINT64 count) +{ + SetMem(dst, count, (UINT8)(ch)); + return dst; +} + +void* memcpy(void* dst, const void* src, UINT64 count) +{ + CopyMem(dst, src, count); + return dst; +} + +} // extern "C" + + +CONST CHAR16 * +EFIAPI +ConstStrStr ( + IN CONST CHAR16 *String, + IN CONST CHAR16 *SearchString + ) +{ + return StrStr((CHAR16*)String, SearchString); +} diff --git a/rEFIt_UEFI/cpp_util/memory.h b/rEFIt_UEFI/cpp_util/memory.h new file mode 100644 index 000000000..083310cc2 --- /dev/null +++ b/rEFIt_UEFI/cpp_util/memory.h @@ -0,0 +1,9 @@ + +#include "../Platform/Platform.h" + +CONST CHAR16 * +EFIAPI +ConstStrStr ( + IN CONST CHAR16 *String, + IN CONST CHAR16 *SearchString + ); diff --git a/rEFIt_UEFI/entry_scan/bootscreen.c b/rEFIt_UEFI/entry_scan/bootscreen.cpp similarity index 99% rename from rEFIt_UEFI/entry_scan/bootscreen.c rename to rEFIt_UEFI/entry_scan/bootscreen.cpp index 6a1a60ccf..477b085a3 100644 --- a/rEFIt_UEFI/entry_scan/bootscreen.c +++ b/rEFIt_UEFI/entry_scan/bootscreen.cpp @@ -709,7 +709,7 @@ STATIC UINT8 whiteAppleLogo[] = { 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82, 0x82, }; -static CHAR16 *CustomBootModeStr[] = { +static CONST CHAR16 *CustomBootModeStr[] = { L"CUSTOM_BOOT_DISABLED", L"CUSTOM_BOOT_DISABLED", L"CUSTOM_BOOT_NONE", @@ -718,7 +718,7 @@ static CHAR16 *CustomBootModeStr[] = { L"CUSTOM_BOOT_THEME", L"CUSTOM_BOOT_USER", }; -CHAR16 *CustomBootModeToStr(IN UINT8 Mode) +CONST CHAR16 *CustomBootModeToStr(IN UINT8 Mode) { if (Mode >= (sizeof(CustomBootModeStr) / sizeof(CHAR16 *))) { return CustomBootModeStr[0]; diff --git a/rEFIt_UEFI/entry_scan/common.c b/rEFIt_UEFI/entry_scan/common.cpp similarity index 93% rename from rEFIt_UEFI/entry_scan/common.c rename to rEFIt_UEFI/entry_scan/common.cpp index f4adf2682..1873ccea6 100644 --- a/rEFIt_UEFI/entry_scan/common.c +++ b/rEFIt_UEFI/entry_scan/common.cpp @@ -47,7 +47,7 @@ #define DBG(...) DebugLog(DEBUG_COMMON_MENU, __VA_ARGS__) #endif -static CHAR16 *BuiltinIconNames[] = { +static CONST CHAR16 *BuiltinIconNames[] = { /* L"About", L"Options", @@ -73,7 +73,7 @@ static CHAR16 *BuiltinIconNames[] = { }; static const UINTN BuiltinIconNamesCount = (sizeof(BuiltinIconNames) / sizeof(CHAR16 *)); -EG_IMAGE *LoadBuiltinIcon(IN CHAR16 *IconName) +EG_IMAGE *LoadBuiltinIcon(IN CONST CHAR16 *IconName) { UINTN Index = 0; if (IconName == NULL) { @@ -166,7 +166,7 @@ LOADER_ENTRY * DuplicateLoaderEntry(IN LOADER_ENTRY *Entry) return DuplicateEntry; } -CHAR16 *AddLoadOption(IN CHAR16 *LoadOptions, IN CHAR16 *LoadOption) +CHAR16 *AddLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOption) { // If either option strings are null nothing to do if (LoadOptions == NULL) @@ -181,9 +181,9 @@ CHAR16 *AddLoadOption(IN CHAR16 *LoadOptions, IN CHAR16 *LoadOption) return PoolPrint(L"%s %s", LoadOptions, LoadOption); } -CHAR16 *RemoveLoadOption(IN CHAR16 *LoadOptions, IN CHAR16 *LoadOption) +CHAR16 *RemoveLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOption) { - CHAR16 *Placement; + CONST CHAR16 *Placement; CHAR16 *NewLoadOptions; UINTN Length, Offset, OptionLength; @@ -239,8 +239,8 @@ CHAR16 *RemoveLoadOption(IN CHAR16 *LoadOptions, IN CHAR16 *LoadOption) } #define TO_LOWER(ch) (((ch >= L'A') && (ch <= L'Z')) ? ((ch - L'A') + L'a') : ch) -INTN StrniCmp(IN CHAR16 *Str1, - IN CHAR16 *Str2, +INTN StrniCmp(IN CONST CHAR16 *Str1, + IN CONST CHAR16 *Str2, IN UINTN Count) { CHAR16 Ch1, Ch2; @@ -271,10 +271,10 @@ INTN StrniCmp(IN CHAR16 *Str1, return 0; } -CHAR16 *StriStr(IN CHAR16 *Str, - IN CHAR16 *SearchFor) +CONST CHAR16 *StriStr(IN CONST CHAR16 *Str, + IN CONST CHAR16 *SearchFor) { - CHAR16 *End; + CONST CHAR16 *End; UINTN Length; UINTN SearchLength; if ((Str == NULL) || (SearchFor == NULL)) { @@ -306,9 +306,10 @@ VOID StrToLower(IN CHAR16 *Str) } } -STATIC CHAR16 **CreateInfoLines(IN CHAR16 *Message, OUT UINTN *Count) +STATIC CHAR16 **CreateInfoLines(IN CONST CHAR16 *Message, OUT UINTN *Count) { - CHAR16 *Ptr, **Information; + CONST CHAR16 *Ptr; + CHAR16 **Information; UINTN Index = 0, Total = 0; UINTN Length = ((Message == NULL) ? 0 : StrLen(Message)); // Check parameters @@ -327,12 +328,12 @@ STATIC CHAR16 **CreateInfoLines(IN CHAR16 *Message, OUT UINTN *Count) return NULL; } // Copy strings - Information[Index++] = Ptr = (CHAR16 *)(Information + Total); - StrCpyS(Ptr, Length + 1, Message); + CHAR16* Ptr2 = Information[Index++] = (CHAR16 *)(Information + Total); + StrCpyS(Ptr2, Length + 1, Message); while ((Index < Total) && - ((Ptr = StrStr(Ptr, L"\n")) != NULL)) { - *Ptr++ = 0; - Information[Index++] = Ptr; + ((Ptr2 = (CHAR16*)StrStr(Ptr2, L"\n")) != NULL)) { // cast is ok because FilePath is not const, and we know that StrStr returns a pointer in FilePath. Will disappear when using a string object instead of CHAR16* + *Ptr2++ = 0; + Information[Index++] = Ptr2; } // Return the info lines if (Count != NULL) { @@ -349,7 +350,7 @@ STATIC REFIT_MENU_SCREEN AlertMessageMenu = {0, NULL, NULL, 0, NULL, 1, AlertMe { 0, 0, 0, 0 } , NULL }; // Display an alert message -VOID AlertMessage(IN CHAR16 *Title, IN CHAR16 *Message) +VOID AlertMessage(IN CONST CHAR16 *Title, IN CONST CHAR16 *Message) { UINTN Count = 0; // Break message into info lines @@ -359,7 +360,7 @@ VOID AlertMessage(IN CHAR16 *Title, IN CHAR16 *Message) if (Count > 0) { // Display the alert message AlertMessageMenu.InfoLineCount = Count; - AlertMessageMenu.InfoLines = Information; + AlertMessageMenu.InfoLines = (CONST CHAR16**)Information; AlertMessageMenu.Title = Title; RunMenu(&AlertMessageMenu, NULL); } @@ -380,7 +381,7 @@ STATIC REFIT_MENU_SCREEN YesNoMessageMenu = {0, NULL, NULL, 0, NULL, 2, YesNoMe { 0, 0, 0, 0 } , NULL }; // Display a yes/no prompt -BOOLEAN YesNoMessage(IN CHAR16 *Title, IN CHAR16 *Message) +BOOLEAN YesNoMessage(IN CHAR16 *Title, IN CONST CHAR16 *Message) { BOOLEAN Result = FALSE; UINTN Count = 0, MenuExit; @@ -388,7 +389,7 @@ BOOLEAN YesNoMessage(IN CHAR16 *Title, IN CHAR16 *Message) CHAR16 **Information = CreateInfoLines(Message, &Count); // Display the yes/no message YesNoMessageMenu.InfoLineCount = Count; - YesNoMessageMenu.InfoLines = Information; + YesNoMessageMenu.InfoLines = (CONST CHAR16**)Information; YesNoMessageMenu.Title = Title; do { diff --git a/rEFIt_UEFI/entry_scan/entry_scan.h b/rEFIt_UEFI/entry_scan/entry_scan.h index 21c4dec46..043fab697 100644 --- a/rEFIt_UEFI/entry_scan/entry_scan.h +++ b/rEFIt_UEFI/entry_scan/entry_scan.h @@ -45,7 +45,7 @@ extern REFIT_MENU_ENTRY MenuEntryExit; extern REFIT_MENU_SCREEN MainMenu; // common -EG_IMAGE *LoadBuiltinIcon(IN CHAR16 *IconName); +EG_IMAGE *LoadBuiltinIcon(IN CONST CHAR16 *IconName); LOADER_ENTRY * DuplicateLoaderEntry(IN LOADER_ENTRY *Entry); //CHAR16 *AddLoadOption(IN CHAR16 *LoadOptions, IN CHAR16 *LoadOption); //CHAR16 *RemoveLoadOption(IN CHAR16 *LoadOptions, IN CHAR16 *LoadOption); @@ -84,7 +84,7 @@ VOID ScanTool(VOID); VOID AddCustomTool(VOID); // locked graphics -CHAR16 *CustomBootModeToStr(IN UINT8 Mode); +CONST CHAR16 *CustomBootModeToStr(IN UINT8 Mode); EFI_STATUS LockBootScreen(VOID); EFI_STATUS UnlockBootScreen(VOID); diff --git a/rEFIt_UEFI/entry_scan/legacy.c b/rEFIt_UEFI/entry_scan/legacy.cpp similarity index 98% rename from rEFIt_UEFI/entry_scan/legacy.c rename to rEFIt_UEFI/entry_scan/legacy.cpp index faf56ab69..1d7745b40 100644 --- a/rEFIt_UEFI/entry_scan/legacy.c +++ b/rEFIt_UEFI/entry_scan/legacy.cpp @@ -48,7 +48,7 @@ #endif -static LEGACY_ENTRY * AddLegacyEntry(IN CHAR16 *FullTitle, IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume, IN EG_IMAGE *Image, IN EG_IMAGE *DriveImage, IN CHAR16 Hotkey, IN BOOLEAN CustomEntry) +static LEGACY_ENTRY * AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume, IN EG_IMAGE *Image, IN EG_IMAGE *DriveImage, IN CHAR16 Hotkey, IN BOOLEAN CustomEntry) { LEGACY_ENTRY *Entry, *SubEntry; REFIT_MENU_SCREEN *SubScreen; diff --git a/rEFIt_UEFI/entry_scan/loader.c b/rEFIt_UEFI/entry_scan/loader.cpp similarity index 98% rename from rEFIt_UEFI/entry_scan/loader.c rename to rEFIt_UEFI/entry_scan/loader.cpp index 6db732cfe..d6056ff47 100644 --- a/rEFIt_UEFI/entry_scan/loader.c +++ b/rEFIt_UEFI/entry_scan/loader.cpp @@ -70,10 +70,10 @@ extern LOADER_ENTRY *SubMenuKextInjectMgmt(LOADER_ENTRY *Entry); // Linux loader path data typedef struct LINUX_PATH_DATA { - CHAR16 *Path; - CHAR16 *Title; - CHAR16 *Icon; - CHAR8 *Issue; + CONST CHAR16 *Path; + CONST CHAR16 *Title; + CONST CHAR16 *Icon; + CONST CHAR8 *Issue; } LINUX_PATH_DATA; STATIC LINUX_PATH_DATA LinuxEntryData[] = { @@ -146,10 +146,10 @@ STATIC CONST UINTN LinuxEntryDataCount = (sizeof(LinuxEntryData) / sizeof(LINUX_ #define ANDX86_FINDLEN 3 typedef struct ANDX86_PATH_DATA { - CHAR16 *Path; - CHAR16 *Title; - CHAR16 *Icon; - CHAR16 *Find[ANDX86_FINDLEN]; + CONST CHAR16 *Path; + CONST CHAR16 *Title; + CONST CHAR16 *Icon; + CONST CHAR16 *Find[ANDX86_FINDLEN]; } ANDX86_PATH_DATA; STATIC ANDX86_PATH_DATA AndroidEntryData[] = { @@ -167,12 +167,12 @@ STATIC CONST UINTN AndroidEntryDataCount = (sizeof(AndroidEntryData) / sizeof(AN #endif #endif -CHAR16 *PaperBoot = L"\\com.apple.boot.P\\boot.efi"; -CHAR16 *RockBoot = L"\\com.apple.boot.R\\boot.efi"; -CHAR16 *ScissorBoot = L"\\com.apple.boot.S\\boot.efi"; +CONST CHAR16 *PaperBoot = L"\\com.apple.boot.P\\boot.efi"; +CONST CHAR16 *RockBoot = L"\\com.apple.boot.R\\boot.efi"; +CONST CHAR16 *ScissorBoot = L"\\com.apple.boot.S\\boot.efi"; // OS X installer paths -STATIC CHAR16 *OSXInstallerPaths[] = { +CONST CHAR16 *OSXInstallerPaths[] = { L"\\.IABootFiles\\boot.efi", // 10.9 - 10.13.3 L"\\Mac OS X Install Data\\boot.efi", // 10.7 L"\\OS X Install Data\\boot.efi", // 10.8 - 10.11 @@ -217,7 +217,7 @@ STATIC INTN TimeCmp(IN EFI_TIME *Time1, return Comparison; } -UINT8 GetOSTypeFromPath(IN CHAR16 *Path) +UINT8 GetOSTypeFromPath(IN CONST CHAR16 *Path) { if (Path == NULL) { return OSTYPE_OTHER; @@ -264,7 +264,7 @@ UINT8 GetOSTypeFromPath(IN CHAR16 *Path) return OSTYPE_OTHER; } -STATIC CHAR16 *LinuxIconNameFromPath(IN CHAR16 *Path, +STATIC CONST CHAR16 *LinuxIconNameFromPath(IN CONST CHAR16 *Path, IN EFI_FILE_PROTOCOL *RootDir) { UINTN Index; @@ -304,7 +304,7 @@ STATIC CHAR16 *LinuxIconNameFromPath(IN CHAR16 *Path, return L"linux"; } -STATIC CHAR16 *LinuxInitImagePath[] = { +STATIC CONST CHAR16 *LinuxInitImagePath[] = { L"initrd%s", L"initrd.img%s", L"initrd%s.img", @@ -315,9 +315,9 @@ STATIC CHAR16 *LinuxInitImagePath[] = { STATIC CONST UINTN LinuxInitImagePathCount = (sizeof(LinuxInitImagePath) / sizeof(CHAR16 *)); STATIC CHAR16 *LinuxKernelOptions(IN EFI_FILE_PROTOCOL *Dir, - IN CHAR16 *Version, - IN CHAR16 *PartUUID, - IN CHAR16 *Options OPTIONAL) + IN CONST CHAR16 *Version, + IN CONST CHAR16 *PartUUID, + IN CONST CHAR16 *Options OPTIONAL) { UINTN Index = 0; if ((Dir == NULL) || (PartUUID == NULL)) { @@ -359,7 +359,7 @@ STATIC BOOLEAN isFirstRootUUID(REFIT_VOLUME *Volume) STATIC EFI_STATUS GetOSXVolumeName(LOADER_ENTRY *Entry) { EFI_STATUS Status = EFI_NOT_FOUND; - CHAR16* targetNameFile = L"\\System\\Library\\CoreServices\\.disk_label.contentDetails"; + CONST CHAR16* targetNameFile = L"\\System\\Library\\CoreServices\\.disk_label.contentDetails"; CHAR8* fileBuffer; CHAR8* targetString; UINTN fileLen = 0; @@ -402,10 +402,10 @@ STATIC EFI_STATUS GetOSXVolumeName(LOADER_ENTRY *Entry) extern BOOLEAN CopyKernelAndKextPatches(IN OUT KERNEL_AND_KEXT_PATCHES *Dst, IN KERNEL_AND_KEXT_PATCHES *Src); -STATIC LOADER_ENTRY *CreateLoaderEntry(IN CHAR16 *LoaderPath, +STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderOptions, - IN CHAR16 *FullTitle, - IN CHAR16 *LoaderTitle, + IN CONST CHAR16 *FullTitle, + IN CONST CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume, IN EG_IMAGE *Image, IN EG_IMAGE *DriveImage, @@ -419,14 +419,14 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CHAR16 *LoaderPath, IN BOOLEAN CustomEntry) { EFI_DEVICE_PATH *LoaderDevicePath; - CHAR16 *LoaderDevicePathString; - CHAR16 *FilePathAsString; - CHAR16 *OSIconName; + CONST CHAR16 *LoaderDevicePathString; + CONST CHAR16 *FilePathAsString; + CONST CHAR16 *OSIconName; //CHAR16 IconFileName[256]; Sothor - Unused? CHAR16 ShortcutLetter; LOADER_ENTRY *Entry; INTN i; - CHAR8 *indent = " "; + CONST CHAR8 *indent = " "; // Check parameters are valid if ((LoaderPath == NULL) || (*LoaderPath == 0) || (Volume == NULL)) { @@ -725,7 +725,8 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CHAR16 *LoaderPath, STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) { - CHAR16 *FileName, *TempOptions; + CONST CHAR16 *FileName; + CHAR16* TempOptions; // CHAR16 DiagsFileName[256]; LOADER_ENTRY *SubEntry; REFIT_MENU_SCREEN *SubScreen; @@ -968,8 +969,8 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) // DBG(" Added '%s': OSType='%d', OSVersion='%a'\n", Entry->me.Title, Entry->LoaderType, Entry->OSVersion); } -STATIC BOOLEAN AddLoaderEntry(IN CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderOptions, - IN CHAR16 *LoaderTitle, +STATIC BOOLEAN AddLoaderEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderOptions, + IN CONST CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume, IN EG_IMAGE *Image, IN UINT8 OSType, IN UINT8 Flags) { @@ -1485,7 +1486,7 @@ VOID ScanLoader(VOID) } STATIC VOID AddCustomEntry(IN UINTN CustomIndex, - IN CHAR16 *CustomPath, + IN CONST CHAR16 *CustomPath, IN CUSTOM_LOADER_ENTRY *Custom, IN REFIT_MENU_SCREEN *SubMenu) { @@ -1799,7 +1800,7 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex, do { // Search for linux kernels - CHAR16 *CustomOptions = Custom->Options; + CONST CHAR16 *CustomOptions = Custom->Options; if (FindCustomPath && (Custom->KernelScan == KERNEL_SCAN_ALL)) { EFI_FILE_INFO *FileInfo = NULL; // Get the next kernel path or stop looking diff --git a/rEFIt_UEFI/entry_scan/lockedgraphics.c b/rEFIt_UEFI/entry_scan/lockedgraphics.cpp similarity index 100% rename from rEFIt_UEFI/entry_scan/lockedgraphics.c rename to rEFIt_UEFI/entry_scan/lockedgraphics.cpp diff --git a/rEFIt_UEFI/entry_scan/secureboot.c b/rEFIt_UEFI/entry_scan/secureboot.cpp similarity index 99% rename from rEFIt_UEFI/entry_scan/secureboot.c rename to rEFIt_UEFI/entry_scan/secureboot.cpp index c05735472..9238fa7af 100644 --- a/rEFIt_UEFI/entry_scan/secureboot.c +++ b/rEFIt_UEFI/entry_scan/secureboot.cpp @@ -33,7 +33,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -CONST INTN SecureBootDef = 0; +//CONST INTN SecureBootDef = 0; // jief : not used ?? #ifdef ENABLE_SECURE_BOOT diff --git a/rEFIt_UEFI/entry_scan/securehash.c b/rEFIt_UEFI/entry_scan/securehash.cpp similarity index 99% rename from rEFIt_UEFI/entry_scan/securehash.c rename to rEFIt_UEFI/entry_scan/securehash.cpp index 5e0264589..ef257829e 100644 --- a/rEFIt_UEFI/entry_scan/securehash.c +++ b/rEFIt_UEFI/entry_scan/securehash.cpp @@ -33,7 +33,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -CONST INTN SecureHashDef = 0; +//CONST INTN SecureHashDef = 0; // jief : not used ?? #ifdef ENABLE_SECURE_BOOT diff --git a/rEFIt_UEFI/entry_scan/securemenu.c b/rEFIt_UEFI/entry_scan/securemenu.cpp similarity index 99% rename from rEFIt_UEFI/entry_scan/securemenu.c rename to rEFIt_UEFI/entry_scan/securemenu.cpp index 6f0a6ca0c..135a13cb8 100644 --- a/rEFIt_UEFI/entry_scan/securemenu.c +++ b/rEFIt_UEFI/entry_scan/securemenu.cpp @@ -33,7 +33,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -CONST INTN SecureMenuDef = 0; +//CONST INTN SecureMenuDef = 0; // jief : not used ?? #ifdef ENABLE_SECURE_BOOT diff --git a/rEFIt_UEFI/entry_scan/securevars.c b/rEFIt_UEFI/entry_scan/securevars.cpp similarity index 99% rename from rEFIt_UEFI/entry_scan/securevars.c rename to rEFIt_UEFI/entry_scan/securevars.cpp index b06d206b8..d9caaf696 100644 --- a/rEFIt_UEFI/entry_scan/securevars.c +++ b/rEFIt_UEFI/entry_scan/securevars.cpp @@ -33,7 +33,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -CONST INTN SecureVarsDef = 0; +//CONST INTN SecureVarsDef = 0; // jief : not used ?? #ifdef ENABLE_SECURE_BOOT diff --git a/rEFIt_UEFI/entry_scan/tool.c b/rEFIt_UEFI/entry_scan/tool.cpp similarity index 97% rename from rEFIt_UEFI/entry_scan/tool.c rename to rEFIt_UEFI/entry_scan/tool.cpp index de983ac43..9ff238c86 100644 --- a/rEFIt_UEFI/entry_scan/tool.c +++ b/rEFIt_UEFI/entry_scan/tool.cpp @@ -70,9 +70,9 @@ extern EMU_VARIABLE_CONTROL_PROTOCOL *gEmuVariableControl; -STATIC BOOLEAN AddToolEntry(IN CHAR16 *LoaderPath, IN CHAR16 *FullTitle, IN CHAR16 *LoaderTitle, +STATIC BOOLEAN AddToolEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume, IN EG_IMAGE *Image, - IN CHAR16 ShortcutLetter, IN CHAR16 *Options) + IN CHAR16 ShortcutLetter, IN CONST CHAR16 *Options) { LOADER_ENTRY *Entry; // Check the loader exists @@ -110,7 +110,7 @@ STATIC BOOLEAN AddToolEntry(IN CHAR16 *LoaderPath, IN CHAR16 *FullTitle, IN CHAR return TRUE; } -STATIC VOID AddCloverEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume) +STATIC VOID AddCloverEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume) { LOADER_ENTRY *Entry, *SubEntry; REFIT_MENU_SCREEN *SubScreen; diff --git a/rEFIt_UEFI/entry_scan/uefibootoption.c b/rEFIt_UEFI/entry_scan/uefibootoption.cpp similarity index 100% rename from rEFIt_UEFI/entry_scan/uefibootoption.c rename to rEFIt_UEFI/entry_scan/uefibootoption.cpp diff --git a/rEFIt_UEFI/libeg/BmLib.c b/rEFIt_UEFI/libeg/BmLib.cpp similarity index 100% rename from rEFIt_UEFI/libeg/BmLib.c rename to rEFIt_UEFI/libeg/BmLib.cpp diff --git a/rEFIt_UEFI/libeg/FloatLib.c b/rEFIt_UEFI/libeg/FloatLib.cpp similarity index 100% rename from rEFIt_UEFI/libeg/FloatLib.c rename to rEFIt_UEFI/libeg/FloatLib.cpp diff --git a/rEFIt_UEFI/libeg/FloatLib.h b/rEFIt_UEFI/libeg/FloatLib.h index ca6dd6bb7..85f2ebcd9 100644 --- a/rEFIt_UEFI/libeg/FloatLib.h +++ b/rEFIt_UEFI/libeg/FloatLib.h @@ -8,12 +8,14 @@ #ifndef FloatLib_h #define FloatLib_h +extern "C" { #include #include #include #include #include #include +} #define PI (3.1415926536f) #define PI2 (6.283185307179586f) diff --git a/rEFIt_UEFI/libeg/VectorGraphics.c b/rEFIt_UEFI/libeg/VectorGraphics.cpp similarity index 98% rename from rEFIt_UEFI/libeg/VectorGraphics.c rename to rEFIt_UEFI/libeg/VectorGraphics.cpp index 5f8c42adb..feafaa51a 100644 --- a/rEFIt_UEFI/libeg/VectorGraphics.c +++ b/rEFIt_UEFI/libeg/VectorGraphics.cpp @@ -35,7 +35,7 @@ extern VOID WaitForKeyPress(CHAR16 *Message); -extern void DumpFloat2 (char* s, float* t, int N); +extern void DumpFloat2 (CONST char* s, float* t, int N); extern EG_IMAGE *BackgroundImage; extern EG_IMAGE *Banner; extern EG_IMAGE *BigBack; @@ -51,7 +51,7 @@ textFaces textFace[4]; //0-help 1-message 2-menu 3-test NSVGparser *mainParser = NULL; //it must be global variable -EFI_STATUS ParseSVGIcon(NSVGparser *p, INTN Id, CHAR8 *IconName, float Scale, EG_IMAGE **Image) +EFI_STATUS ParseSVGIcon(NSVGparser *p, INTN Id, CONST CHAR8 *IconName, float Scale, EG_IMAGE **Image) { EFI_STATUS Status = EFI_NOT_FOUND; NSVGimage *SVGimage; @@ -316,9 +316,9 @@ EFI_STATUS ParseSVGTheme(CONST CHAR8* buffer, TagPtr * dict, UINT32 bufSize) i++; continue; } - CHAR16 *IconPath = BuiltinIconTable[i].Path; + CONST CHAR16 *IconPath = BuiltinIconTable[i].Path; // DBG("next table icon=%s\n", IconPath); - CHAR16 *ptr = StrStr(IconPath, L"\\"); + CONST CHAR16 *ptr = StrStr(IconPath, L"\\"); if (!ptr) { ptr = IconPath; } else { diff --git a/rEFIt_UEFI/libeg/egemb_font.c b/rEFIt_UEFI/libeg/egemb_font.cpp similarity index 100% rename from rEFIt_UEFI/libeg/egemb_font.c rename to rEFIt_UEFI/libeg/egemb_font.cpp diff --git a/rEFIt_UEFI/libeg/egemb_icons.c b/rEFIt_UEFI/libeg/egemb_icons.cpp similarity index 100% rename from rEFIt_UEFI/libeg/egemb_icons.c rename to rEFIt_UEFI/libeg/egemb_icons.cpp diff --git a/rEFIt_UEFI/libeg/egemb_icons_dark.c b/rEFIt_UEFI/libeg/egemb_icons_dark.cpp similarity index 100% rename from rEFIt_UEFI/libeg/egemb_icons_dark.c rename to rEFIt_UEFI/libeg/egemb_icons_dark.cpp diff --git a/rEFIt_UEFI/libeg/image.c b/rEFIt_UEFI/libeg/image.cpp similarity index 98% rename from rEFIt_UEFI/libeg/image.c rename to rEFIt_UEFI/libeg/image.cpp index ca5d84f3d..f655af889 100644 --- a/rEFIt_UEFI/libeg/image.c +++ b/rEFIt_UEFI/libeg/image.cpp @@ -397,14 +397,14 @@ EFI_STATUS egFindESP(OUT EFI_FILE_HANDLE *RootDir) return Status; } //if (NULL, ...) then save to EFI partition -EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CHAR16 *FileName, +EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *FileName, IN CONST VOID *FileData, IN UINTN FileDataLength) { EFI_STATUS Status; EFI_FILE_HANDLE FileHandle; UINTN BufferSize; BOOLEAN CreateNew = TRUE; - CHAR16 *p = FileName + StrLen(FileName); + CONST CHAR16 *p = FileName + StrLen(FileName); CHAR16 DirName[256]; UINTN dirNameLen; @@ -540,7 +540,7 @@ EG_IMAGE * egLoadImage(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN } //caller is responsible for free image -EG_IMAGE * egLoadIcon(IN EFI_FILE_HANDLE BaseDir, IN CHAR16 *FileName, IN UINTN IconSize) +EG_IMAGE * egLoadIcon(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN IconSize) { EFI_STATUS Status; UINT8 *FileData; @@ -556,13 +556,13 @@ EG_IMAGE * egLoadIcon(IN EFI_FILE_HANDLE BaseDir, IN CHAR16 *FileName, IN UINTN INTN i = 0; UINTN Size; - CHAR16 *ptr = StrStr(FileName, L"\\"); + CONST CHAR16 *ptr = StrStr(FileName, L"\\"); if (!ptr) { ptr = FileName; } else { ptr++; } - CHAR16 *ptr2 = StrStr(ptr, L"."); + CONST CHAR16 *ptr2 = StrStr(ptr, L"."); Size = ptr2 - ptr + 2; IconName = (__typeof__(IconName))AllocateZeroPool(Size); UnicodeStrToAsciiStrS(ptr, IconName, Size - 1); diff --git a/rEFIt_UEFI/libeg/libeg.h b/rEFIt_UEFI/libeg/libeg.h index 735b2f214..5dea68bd2 100644 --- a/rEFIt_UEFI/libeg/libeg.h +++ b/rEFIt_UEFI/libeg/libeg.h @@ -37,6 +37,7 @@ #ifndef __LIBEG_LIBEG_H__ #define __LIBEG_LIBEG_H__ +extern "C" { #include #include #include @@ -132,6 +133,8 @@ #include #include +} // extern "C" + /* types */ typedef enum { @@ -191,8 +194,8 @@ typedef struct { typedef struct { EG_IMAGE *Image; - CHAR16 *Path; - CHAR16 *Format; + CONST CHAR16 *Path; + CONST CHAR16 *Format; UINTN PixelSize; } BUILTIN_ICON; @@ -206,7 +209,7 @@ EFI_STATUS egSetMaxResolution(VOID); EFI_STATUS egSetMode(INT32 Next); VOID egGetScreenSize(OUT INTN *ScreenWidth, OUT INTN *ScreenHeight); -CHAR16* egScreenDescription(VOID); +CONST CHAR16* egScreenDescription(VOID); BOOLEAN egHasGraphicsMode(VOID); BOOLEAN egIsGraphicsModeEnabled(VOID); VOID egSetGraphicsModeEnabled(IN BOOLEAN Enable); @@ -223,15 +226,15 @@ VOID egFreeImage(IN EG_IMAGE *Image); VOID ScaleImage(OUT EG_IMAGE *NewImage, IN EG_IMAGE *OldImage); EG_IMAGE * egLoadImage(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN BOOLEAN WantAlpha); -EG_IMAGE * egLoadIcon(IN EFI_FILE_HANDLE BaseDir, IN CHAR16 *FileName, IN UINTN IconSize); +EG_IMAGE * egLoadIcon(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN IconSize); EG_IMAGE * egEnsureImageSize(IN EG_IMAGE *Image, IN INTN Width, IN INTN Height, IN EG_PIXEL *Color); EFI_STATUS egLoadFile(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, OUT UINT8 **FileData, OUT UINTN *FileDataLength); -EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CHAR16 *FileName, +EFI_STATUS egSaveFile(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *FileName, IN CONST VOID *FileData, IN UINTN FileDataLength); -EFI_STATUS egMkDir(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CHAR16 *DirName); +EFI_STATUS egMkDir(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *DirName); EFI_STATUS egFindESP(OUT EFI_FILE_HANDLE *RootDir); VOID egFillImage(IN OUT EG_IMAGE *CompImage, IN EG_PIXEL *Color); @@ -241,8 +244,8 @@ VOID egFillImageArea(IN OUT EG_IMAGE *CompImage, IN EG_PIXEL *Color); VOID egComposeImage(IN OUT EG_IMAGE *CompImage, IN EG_IMAGE *TopImage, IN INTN PosX, IN INTN PosY); VOID PrepareFont(VOID); -VOID egMeasureText(IN CHAR16 *Text, OUT INTN *Width, OUT INTN *Height); -INTN egRenderText(IN CHAR16 *Text, IN OUT EG_IMAGE *CompImage, IN INTN PosX, IN INTN PosY, IN INTN Cursor, INTN textType); +VOID egMeasureText(IN CONST CHAR16 *Text, OUT INTN *Width, OUT INTN *Height); +INTN egRenderText(IN CONST CHAR16 *Text, IN OUT EG_IMAGE *CompImage, IN INTN PosX, IN INTN PosY, IN INTN Cursor, INTN textType); VOID egClearScreen(IN EG_PIXEL *Color); //VOID egDrawImage(IN EG_IMAGE *Image, IN INTN ScreenPosX, IN INTN ScreenPosY); @@ -255,7 +258,7 @@ VOID egTakeImage(IN EG_IMAGE *Image, INTN ScreenPosX, INTN ScreenPosY, EFI_STATUS egScreenShot(VOID); -INTN drawSVGtext(EG_IMAGE* TextBufferXY, INTN posX, INTN posY, INTN textType, const CHAR16* text, UINTN Cursor); +INTN drawSVGtext(EG_IMAGE* TextBufferXY, INTN posX, INTN posY, INTN textType, CONST CHAR16* text, UINTN Cursor); VOID testSVG(VOID); #endif /* __LIBEG_LIBEG_H__ */ diff --git a/rEFIt_UEFI/libeg/libegint.h b/rEFIt_UEFI/libeg/libegint.h index aa754d721..00c515159 100644 --- a/rEFIt_UEFI/libeg/libegint.h +++ b/rEFIt_UEFI/libeg/libegint.h @@ -43,9 +43,6 @@ #include "Platform.h" -#ifdef __cplusplus -extern "C" { -#endif #if defined(_MSC_VER) # define ALIGN_64 __declspec(align(8)) @@ -184,9 +181,6 @@ EG_IMAGE * egDecodePNG(IN UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN W //VOID egEncodeBMP(IN EG_IMAGE *Image, OUT UINT8 **FileData, OUT UINTN *FileDataLength); -#ifdef __cplusplus -} -#endif #endif /* __LIBEG_LIBEGINT_H__ */ diff --git a/rEFIt_UEFI/libeg/libscreen.c b/rEFIt_UEFI/libeg/libscreen.cpp similarity index 99% rename from rEFIt_UEFI/libeg/libscreen.c rename to rEFIt_UEFI/libeg/libscreen.cpp index 1cf1e3034..9dfe611b8 100644 --- a/rEFIt_UEFI/libeg/libscreen.c +++ b/rEFIt_UEFI/libeg/libscreen.cpp @@ -440,7 +440,7 @@ VOID egGetScreenSize(OUT INTN *ScreenWidth, OUT INTN *ScreenHeight) *ScreenHeight = egScreenHeight; } -CHAR16 * egScreenDescription(VOID) +CONST CHAR16 * egScreenDescription(VOID) { if (egHasGraphics) { if (GraphicsOutput != NULL) { diff --git a/rEFIt_UEFI/libeg/load_icns.c b/rEFIt_UEFI/libeg/load_icns.cpp similarity index 100% rename from rEFIt_UEFI/libeg/load_icns.c rename to rEFIt_UEFI/libeg/load_icns.cpp diff --git a/rEFIt_UEFI/libeg/lodepng.c b/rEFIt_UEFI/libeg/lodepng.cpp similarity index 99% rename from rEFIt_UEFI/libeg/lodepng.c rename to rEFIt_UEFI/libeg/lodepng.cpp index 9a186a1cc..446eded25 100644 --- a/rEFIt_UEFI/libeg/lodepng.c +++ b/rEFIt_UEFI/libeg/lodepng.cpp @@ -35,15 +35,17 @@ Rename this file to lodepng.cpp to use it for C++, or to lodepng.c to use it for //#include //#include +extern "C" { #include #include #include #include #include +} // Floating point operations are used here, this must be defined to prevent linker error #ifndef ENABLE_SECURE_BOOT -CONST INT32 _fltused = 0; +//CONST INT32 _fltused = 0; // jief : not used ?? #endif /* @@ -86,7 +88,7 @@ void* lodepng_realloc(void* ptr, size_t new_size) //#define memcpy(dest,source,count) gBS->CopyMem(dest,source,(UINTN)(count)) //#define memset(dest,ch,count) gBS->SetMem(dest,(UINTN)(count),(UINT8)(ch)) -#define memcpy(dest,source,count) CopyMem(dest,(void*)source,(UINTN)(count)) +#define memcpy(dest,source,count) CopyMem(dest,(void*)(source),(UINTN)(count)) #define memset(dest,ch,count) SetMem(dest,(UINTN)(count),(UINT8)(ch)) diff --git a/rEFIt_UEFI/libeg/nanosvg.c b/rEFIt_UEFI/libeg/nanosvg.cpp similarity index 99% rename from rEFIt_UEFI/libeg/nanosvg.c rename to rEFIt_UEFI/libeg/nanosvg.cpp index 2bb76c254..7ffde70f7 100644 --- a/rEFIt_UEFI/libeg/nanosvg.c +++ b/rEFIt_UEFI/libeg/nanosvg.cpp @@ -103,7 +103,7 @@ void nsvg__deleteShapes(NSVGshape* shape); extern BOOLEAN DayLight; -void DumpFloat2 (char* s, float* t, int N) +void DumpFloat2 (CONST char* s, float* t, int N) { #if DEBUG_SVG int i; diff --git a/rEFIt_UEFI/libeg/nanosvg.h b/rEFIt_UEFI/libeg/nanosvg.h index f42a2a5ee..48b604377 100644 --- a/rEFIt_UEFI/libeg/nanosvg.h +++ b/rEFIt_UEFI/libeg/nanosvg.h @@ -42,6 +42,9 @@ #ifndef NANOSVG_H #define NANOSVG_H +extern "C" { +#include +} #include "Platform.h" #define NANOSVG_ALL_COLOR_KEYWORDS 1 @@ -49,7 +52,7 @@ //There are defines for compilation as first step. Must be revised -#define memcpy(dest,source,count) CopyMem(dest,(void*)source,(UINTN)(count)) +#define memcpy(dest,source,count) CopyMem(dest,(void*)(source),(UINTN)(count)) #define memset(dest,ch,count) SetMem(dest,(UINTN)(count),(UINT8)(ch)) #define strcmp(a,b) AsciiStrCmp(a,b) #define strncmp(a,b,n) AsciiStrnCmp(a,b,n) diff --git a/rEFIt_UEFI/libeg/nanosvgrast.c b/rEFIt_UEFI/libeg/nanosvgrast.cpp similarity index 100% rename from rEFIt_UEFI/libeg/nanosvgrast.c rename to rEFIt_UEFI/libeg/nanosvgrast.cpp diff --git a/rEFIt_UEFI/libeg/scroll_images.c b/rEFIt_UEFI/libeg/scroll_images.cpp similarity index 100% rename from rEFIt_UEFI/libeg/scroll_images.c rename to rEFIt_UEFI/libeg/scroll_images.cpp diff --git a/rEFIt_UEFI/libeg/text.c b/rEFIt_UEFI/libeg/text.cpp similarity index 98% rename from rEFIt_UEFI/libeg/text.c rename to rEFIt_UEFI/libeg/text.cpp index dfba90687..e891ae177 100644 --- a/rEFIt_UEFI/libeg/text.c +++ b/rEFIt_UEFI/libeg/text.cpp @@ -68,7 +68,7 @@ CONST EG_PIXEL SemiWhitePixel = {255, 255, 255, 210}; //semitransparent // Text rendering // -VOID egMeasureText(IN CHAR16 *Text, OUT INTN *Width, OUT INTN *Height) +VOID egMeasureText(IN CONST CHAR16 *Text, OUT INTN *Width, OUT INTN *Height) { INTN ScaledWidth = (INTN)(GlobalConfig.CharWidth * GlobalConfig.Scale); if (Width != NULL) @@ -84,7 +84,7 @@ EG_IMAGE * egLoadFontImage(IN BOOLEAN UseEmbedded, IN INTN Rows, IN INTN Cols) EG_PIXEL *PixelPtr, FirstPixel; BOOLEAN isKorean = (gLanguage == korean); CHAR16 *fontFilePath = NULL; - CHAR16 *commonFontDir = L"EFI\\CLOVER\\font"; + CONST CHAR16 *commonFontDir = L"EFI\\CLOVER\\font"; if (IsEmbeddedTheme() && !isKorean) { //or initial screen before theme init NewImage = egDecodePNG(ACCESS_EMB_DATA(emb_font_data), ACCESS_EMB_SIZE(emb_font_data), TRUE); @@ -247,7 +247,7 @@ INTN GetEmpty(EG_PIXEL *Ptr, EG_PIXEL *FirstPixel, INTN MaxWidth, INTN Step, INT return m; } -INTN egRenderText(IN CHAR16 *Text, IN OUT EG_IMAGE *CompImage, +INTN egRenderText(IN CONST CHAR16 *Text, IN OUT EG_IMAGE *CompImage, IN INTN PosX, IN INTN PosY, IN INTN Cursor, INTN textType) { EG_PIXEL *BufferPtr; diff --git a/rEFIt_UEFI/refit.inf b/rEFIt_UEFI/refit.inf index 9f8b1ce04..ff2f13c1b 100644 --- a/rEFIt_UEFI/refit.inf +++ b/rEFIt_UEFI/refit.inf @@ -34,25 +34,25 @@ # EfiLib/GenericBdsLib.h # EfiLib/BmLib.c # Platform/DevicePath.c #included into GenericBdsLib - Platform/BdsConnect.c #included into GenericBdsLib + Platform/BdsConnect.cpp #included into GenericBdsLib refit/main.cpp - refit/icns.c - refit/lib.c + refit/icns.cpp + refit/lib.cpp refit/lib.h refit/menu.cpp - refit/screen.c - refit/IO.c + refit/screen.cpp + refit/IO.cpp refit/IO.h - entry_scan/common.c - entry_scan/legacy.c - entry_scan/loader.c - entry_scan/tool.c - entry_scan/secureboot.c - entry_scan/securehash.c - entry_scan/securemenu.c - entry_scan/securevars.c - entry_scan/bootscreen.c - entry_scan/lockedgraphics.c + entry_scan/common.cpp + entry_scan/legacy.cpp + entry_scan/loader.cpp + entry_scan/tool.cpp + entry_scan/secureboot.cpp + entry_scan/securehash.cpp + entry_scan/securemenu.cpp + entry_scan/securevars.cpp + entry_scan/bootscreen.cpp + entry_scan/lockedgraphics.cpp entry_scan/CanonicalDB.h entry_scan/CloverDB.h entry_scan/CloverKEK.h @@ -61,105 +61,106 @@ entry_scan/MSUEFICADB.h entry_scan/entry_scan.h entry_scan/securebootkeys.h - libeg/egemb_icons.c - libeg/egemb_icons_dark.c - libeg/egemb_font.c - libeg/scroll_images.c - libeg/BmLib.c - libeg/image.c -# libeg/load_bmp.c - libeg/load_icns.c - libeg/libscreen.c - libeg/lodepng.c + libeg/egemb_icons.cpp + libeg/egemb_icons_dark.cpp + libeg/egemb_font.cpp + libeg/scroll_images.cpp + libeg/BmLib.cpp + libeg/image.cpp +# libeg/load_bmp.cpp + libeg/load_icns.cpp + libeg/libscreen.cpp + libeg/lodepng.cpp libeg/lodepng.h - libeg/text.c - libeg/FloatLib.c + libeg/text.cpp + libeg/FloatLib.cpp libeg/FloatLib.h - libeg/nanosvg.c + libeg/nanosvg.cpp libeg/nanosvg.h - libeg/nanosvgrast.c - libeg/VectorGraphics.c + libeg/nanosvgrast.cpp + libeg/VectorGraphics.cpp libeg/libeg.h libeg/libegint.h - Platform/AcpiPatcher.c + Platform/AcpiPatcher.cpp Platform/ati_reg.h - Platform/AmlGenerator.c + Platform/AmlGenerator.cpp Platform/AmlGenerator.h - Platform/ati.c + Platform/ati.cpp Platform/ati.h # Platform/BiosVideo.h # Platform/Bmp.h Platform/boot.h - Platform/BootLog.c - Platform/BootOptions.c - Platform/Console.c - Platform/cpu.c - Platform/DataHubCpu.c + Platform/BootLog.cpp + Platform/BootOptions.cpp + Platform/Console.cpp + Platform/cpu.cpp + Platform/DataHubCpu.cpp # Platform/DataHubRecords.h - Platform/device_inject.c + Platform/device_inject.cpp Platform/device_inject.h -# Platform/device_tree.c +# Platform/device_tree.cpp # Platform/device_tree.h - Platform/Edid.c - Platform/Events.c - Platform/hda.c + Platform/Edid.cpp + Platform/Events.cpp + Platform/hda.cpp Platform/hda.h - Platform/HdaCodecDump.c + Platform/HdaCodecDump.cpp Platform/HdaCodecDump.h - Platform/gma.c + Platform/gma.cpp Platform/gma.h - Platform/guid.c - Platform/Injectors.c - Platform/LegacyBiosThunk.c + Platform/guid.cpp + Platform/Injectors.cpp + Platform/LegacyBiosThunk.cpp Platform/LegacyBiosThunk.h - Platform/LegacyBoot.c + Platform/LegacyBoot.cpp Platform/memvendors.h - Platform/nvidia.c + Platform/nvidia.cpp Platform/nvidia.h -# Platform/pci.c -# Platform/picopng.c +# Platform/pci.cpp +# Platform/picopng.cpp # Platform/picopng.h Platform/Platform.h - Platform/platformdata.c - Platform/plist.c - Platform/Pointer.c - Platform/Settings.c - Platform/smbios.c + Platform/platformdata.cpp + Platform/plist.cpp + Platform/Pointer.cpp + Platform/Settings.cpp + Platform/smbios.cpp # Platform/SmBios.h - Platform/spd.c + Platform/spd.cpp Platform/spd.h - Platform/string.c + Platform/string.cpp Platform/string.h - Platform/StateGenerator.c + Platform/StateGenerator.cpp Platform/StateGenerator.h -# Platform/stringTable.c - Platform/usbfix.c +# Platform/stringTable.cpp + Platform/usbfix.cpp # Platform/UsbMass.h # Platform/UsbMassBoot.h # Platform/UsbMassImpl.h # Platform/VesaBiosExtensions.h Platform/b64cdecode.h - Platform/b64cdecode.c - Platform/FixBiosDsdt.c + Platform/b64cdecode.cpp + Platform/FixBiosDsdt.cpp Platform/loader.h Platform/LoaderUefi.h Platform/kernel_patcher.h - Platform/kernel_patcher.c - Platform/kext_patcher.c - Platform/kext_inject.c + Platform/kernel_patcher.cpp + Platform/kext_patcher.cpp + Platform/kext_inject.cpp Platform/kext_inject.h - Platform/Nvram.c - Platform/card_vlist.c - Platform/PlatformDriverOverride.c - Platform/Hibernate.c - Platform/Net.c - Platform/sound.c - Platform/StartupSound.c + Platform/Nvram.cpp + Platform/card_vlist.cpp + Platform/PlatformDriverOverride.cpp + Platform/Hibernate.cpp + Platform/Net.cpp + Platform/sound.cpp + Platform/StartupSound.cpp Platform/sse3_patcher.h Platform/sse3_5_patcher.h Version.h cpp_util/XStringW.h cpp_util/XStringW.cpp + cpp_util/memory.cpp cpp_util/global1.cpp cpp_util/global2.cpp cpp_util/globals_ctor.cpp @@ -315,9 +316,7 @@ [Pcd] [BuildOptions] -# XCODE:*_*_*_CC_FLAGS = -fsigned-char -O2 -fno-common - XCODE:*_*_*_CC_FLAGS = -fsigned-char -O2 -fno-omit-frame-pointer -ffreestanding -fno-rtti -fno-exceptions -Wno-deprecated -Wno-writable-strings -Wno-unused-const-variable -# XCODE:*_*_*_DLINK_FLAGS = -order_file $(EDK_TOOLS_PATH)/Scripts/ClangLinkOrder.txt + XCODE:*_*_*_CC_FLAGS = -fsigned-char -O2 -fno-omit-frame-pointer -ffreestanding -fno-rtti -fno-exceptions -Wno-deprecated -Wno-writable-strings -Wno-unused-const-variable -DJCONST=const GCC:*_*_*_CC_FLAGS = -std=c99 -Os -fno-omit-frame-pointer -maccumulate-outgoing-args - GCC:*_*_*_CXX_FLAGS = -std=c++11 -Os -fno-omit-frame-pointer -maccumulate-outgoing-args -ffreestanding -fno-rtti -fno-exceptions -Wno-deprecated -Wno-write-strings -Wno-unused-const-variable - MSFT:*_*_*_CC_FLAGS = /Os /wd4201 + GCC:*_*_*_CXX_FLAGS = -std=c++11 -Os -fno-omit-frame-pointer -maccumulate-outgoing-args -ffreestanding -fno-rtti -fno-exceptions -Wno-deprecated -Wno-write-strings -Wno-unused-const-variable -DJCONST=const + MSFT:*_*_*_CC_FLAGS = /Os /wd4201 diff --git a/rEFIt_UEFI/refit/IO.c b/rEFIt_UEFI/refit/IO.cpp similarity index 98% rename from rEFIt_UEFI/refit/IO.c rename to rEFIt_UEFI/refit/IO.cpp index 2cb6d3306..0fa870940 100644 --- a/rEFIt_UEFI/refit/IO.c +++ b/rEFIt_UEFI/refit/IO.cpp @@ -64,7 +64,7 @@ _IPrint ( IN UINTN Column, IN UINTN Row, IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Out, - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, IN CHAR8 *fmta, IN VA_LIST args ); @@ -236,7 +236,7 @@ Returns: PRINT_STATE ps; SetMem (&ps, sizeof (ps), 0); - ps.Output = (IN EFI_STATUS (EFIAPI *)(VOID *context, CHAR16 *str))Output; + ps.Output = (IN EFI_STATUS (EFIAPI *)(VOID *context, CONST CHAR16 *str)) Output; // C++ doesn't cast automatically to void* for param 1 ps.Context = spc; ps.fmt.u.pw = fmt; //ps.args = args; @@ -285,7 +285,7 @@ EFIAPI PrintAt ( IN UINTN Column, IN UINTN Row, - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, ... ) /*++ @@ -321,7 +321,7 @@ _IPrint ( IN UINTN Column, IN UINTN Row, IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Out, - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, IN CHAR8 *fmta, IN VA_LIST args ) @@ -354,7 +354,7 @@ Returns: SetMem (&ps, sizeof (ps), 0); ps.Context = Out; - ps.Output = (EFI_STATUS (EFIAPI *) (VOID *, CHAR16 *)) Out->OutputString; + ps.Output = (EFI_STATUS (EFIAPI *) (VOID *, CONST CHAR16 *)) Out->OutputString; // C++ doesn't cast automatically to void* for param 1 ps.SetAttr = (EFI_STATUS (EFIAPI *) (VOID *, UINTN)) Out->SetAttribute; // ASSERT (NULL != Out->Mode); if (!Out->Mode) { @@ -1431,7 +1431,7 @@ Returns: UINTN Column; INTN Row; UINTN StartColumn; - UINTN Update; + INTN Update; UINTN Delete; UINTN Len; UINTN StrPos; diff --git a/rEFIt_UEFI/refit/IO.h b/rEFIt_UEFI/refit/IO.h index 4a2c1cfb5..64e95ac17 100644 --- a/rEFIt_UEFI/refit/IO.h +++ b/rEFIt_UEFI/refit/IO.h @@ -54,7 +54,7 @@ typedef struct { UINTN Index; union { CONST CHAR16 *pw; - CHAR8 *pc; + CONST CHAR8 *pc; } u; } POINTER; @@ -95,7 +95,7 @@ typedef struct _pstate { UINTN AttrBlueColor; UINTN AttrGreenColor; - EFI_STATUS (EFIAPI *Output) (VOID *context, CHAR16 *str); + EFI_STATUS (EFIAPI *Output) (void *context, CONST CHAR16 *str); EFI_STATUS (EFIAPI *SetAttr) (VOID *context, UINTN attr); VOID *Context; diff --git a/rEFIt_UEFI/refit/icns.c b/rEFIt_UEFI/refit/icns.cpp similarity index 96% rename from rEFIt_UEFI/refit/icns.c rename to rEFIt_UEFI/refit/icns.cpp index 5cff4646a..33f1b435a 100644 --- a/rEFIt_UEFI/refit/icns.c +++ b/rEFIt_UEFI/refit/icns.cpp @@ -124,7 +124,7 @@ MISC_ICONS OSIconsTable[] = { //#define DEC_BUILTIN_ICON(id, ico) BuiltinIconTable[id].Image = egDecodePNG(&ico[0], SZ_##ico, TRUE) #define DEC_BUILTIN_ICON(id, ico) BuiltinIconTable[id].Image = egDecodePNG(ACCESS_EMB_DATA(ico), ACCESS_EMB_SIZE(ico), TRUE) -CHAR16 * GetIconsExt(IN CHAR16 *Icon, IN CHAR16 *Def) +CHAR16 * GetIconsExt(IN CONST CHAR16 *Icon, IN CONST CHAR16 *Def) { return PoolPrint(L"%s.%s", Icon, ((GlobalConfig.IconFormat != ICON_FORMAT_DEF) && (IconFormat != NULL)) ? IconFormat : Def); } @@ -133,7 +133,7 @@ EG_IMAGE * BuiltinIcon(IN UINTN Id) { INTN Size; EG_IMAGE *TextBuffer = NULL; - CHAR16 *p; + CONST CHAR16 *p; CHAR16 *Text; if (Id >= BUILTIN_ICON_COUNT) { @@ -270,8 +270,10 @@ EG_IMAGE * BuiltinIcon(IN UINTN Id) // egFillImage(TextBuffer, &MenuBackgroundPixel); p = StrStr(BuiltinIconTable[Id].Path, L"_"); p++; Text = (CHAR16*)AllocateCopyPool(30, (VOID*)p); - p = StrStr(Text, L"."); - *p = L'\0'; +// the 2 next lines seems to be useless, because there is no '.' in BuiltinIconTable +// TODO jief : double check +// p = StrStr(Text, L"."); +// *p = L'\0'; if (StrCmp(Text, L"shutdown") == 0) { // icon name is shutdown from historic reasons, but function is now exit UnicodeSPrint(Text, 30, L"exit"); @@ -289,7 +291,7 @@ EG_IMAGE * BuiltinIcon(IN UINTN Id) // Load an icon for an operating system // -EG_IMAGE * LoadOSIcon(IN CHAR16 *OSIconName OPTIONAL, IN CHAR16 *FallbackIconName, IN UINTN PixelSize, IN BOOLEAN BootLogo, IN BOOLEAN WantDummy) +EG_IMAGE * LoadOSIcon(IN CONST CHAR16 *OSIconName OPTIONAL, IN CONST CHAR16 *FallbackIconName, IN UINTN PixelSize, IN BOOLEAN BootLogo, IN BOOLEAN WantDummy) { EG_IMAGE *Image; CHAR16 CutoutName[16], FirstName[16]; @@ -370,7 +372,7 @@ EG_IMAGE * LoadOSIcon(IN CHAR16 *OSIconName OPTIONAL, IN CHAR16 *FallbackIconNam // Load an image from a .icns file // -EG_IMAGE * LoadIcns(IN EFI_FILE_HANDLE BaseDir, IN CHAR16 *FileName, IN UINTN PixelSize) +EG_IMAGE * LoadIcns(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN PixelSize) { if (GlobalConfig.TextOnly) // skip loading if it's not used anyway return NULL; @@ -412,7 +414,7 @@ EG_IMAGE * DummyImage(IN UINTN PixelSize) return Image; } -EG_IMAGE * LoadIcnsFallback(IN EFI_FILE_HANDLE BaseDir, IN CHAR16 *FileName, IN UINTN PixelSize) +EG_IMAGE * LoadIcnsFallback(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN PixelSize) { EG_IMAGE *Image; diff --git a/rEFIt_UEFI/refit/lib.c b/rEFIt_UEFI/refit/lib.cpp similarity index 98% rename from rEFIt_UEFI/refit/lib.c rename to rEFIt_UEFI/refit/lib.cpp index bd6965c2c..6f8f13557 100644 --- a/rEFIt_UEFI/refit/lib.c +++ b/rEFIt_UEFI/refit/lib.cpp @@ -66,7 +66,7 @@ BOOLEAN gBootChanged = FALSE; BOOLEAN gThemeOptionsChanged = FALSE; EFI_FILE *OEMDir; -CHAR16 *OEMPath = L"EFI\\CLOVER"; +CONST CHAR16 *OEMPath = L"EFI\\CLOVER"; EFI_FILE *OemThemeDir = NULL; @@ -128,8 +128,8 @@ NodeParser (UINT8 *DevPath, UINTN PathSize, UINT8 Type) } BOOLEAN MetaiMatch ( - IN CHAR16 *String, - IN CHAR16 *Pattern + IN CONST CHAR16 *String, + IN CONST CHAR16 *Pattern ); /** @@ -1365,7 +1365,7 @@ REFIT_VOLUME *FindVolumeByName(IN CHAR16 *VolName) // file and dir functions // -BOOLEAN FileExists(IN EFI_FILE *Root, IN CHAR16 *RelativePath) +BOOLEAN FileExists(IN CONST EFI_FILE *Root, IN CONST CHAR16 *RelativePath) { EFI_STATUS Status; EFI_FILE *TestFile = NULL; @@ -1380,7 +1380,7 @@ BOOLEAN FileExists(IN EFI_FILE *Root, IN CHAR16 *RelativePath) return FALSE; } -BOOLEAN DeleteFile(IN EFI_FILE *Root, IN CHAR16 *RelativePath) +BOOLEAN DeleteFile(IN EFI_FILE *Root, IN CONST CHAR16 *RelativePath) { EFI_STATUS Status; EFI_FILE *File; @@ -1479,7 +1479,7 @@ EFI_STATUS DirNextEntry(IN EFI_FILE *Directory, IN OUT EFI_FILE_INFO **DirEntry, return Status; } -VOID DirIterOpen(IN EFI_FILE *BaseDir, IN CHAR16 *RelativePath OPTIONAL, OUT REFIT_DIR_ITER *DirIter) +VOID DirIterOpen(IN EFI_FILE *BaseDir, IN CONST CHAR16 *RelativePath OPTIONAL, OUT REFIT_DIR_ITER *DirIter) { if (RelativePath == NULL) { DirIter->LastStatus = EFI_SUCCESS; @@ -1492,7 +1492,7 @@ VOID DirIterOpen(IN EFI_FILE *BaseDir, IN CHAR16 *RelativePath OPTIONAL, OUT REF DirIter->LastFileInfo = NULL; } -BOOLEAN DirIterNext(IN OUT REFIT_DIR_ITER *DirIter, IN UINTN FilterMode, IN CHAR16 *FilePattern OPTIONAL, +BOOLEAN DirIterNext(IN OUT REFIT_DIR_ITER *DirIter, IN UINTN FilterMode, IN CONST CHAR16 *FilePattern OPTIONAL, OUT EFI_FILE_INFO **DirEntry) { if (DirIter->LastFileInfo != NULL) { @@ -1539,8 +1539,8 @@ EFI_STATUS DirIterClose(IN OUT REFIT_DIR_ITER *DirIter) // BOOLEAN MetaiMatch ( - IN CHAR16 *String, - IN CHAR16 *Pattern + IN CONST CHAR16 *String, + IN CONST CHAR16 *Pattern ) { if (!mUnicodeCollation) { @@ -1584,9 +1584,9 @@ InitializeUnicodeCollationProtocol (VOID) -CHAR16 * Basename(IN CHAR16 *Path) +CONST CHAR16 * Basename(IN CONST CHAR16 *Path) { - CHAR16 *FileName; + CONST CHAR16 *FileName; UINTN i; FileName = Path; @@ -1657,7 +1657,7 @@ CHAR16 *FileDevicePathToStr(IN EFI_DEVICE_PATH_PROTOCOL *DevPath) { CHAR16 *FilePath; CHAR16 *Char; - CHAR16 *Tail; + CONST CHAR16 *Tail; FilePath = DevicePathToStr(DevPath); // fix / into '\\' @@ -1669,14 +1669,14 @@ CHAR16 *FileDevicePathToStr(IN EFI_DEVICE_PATH_PROTOCOL *DevPath) } } // "\\\\" into '\\' - Char = StrStr(FilePath, L"\\\\"); + Char = (CHAR16*)StrStr(FilePath, L"\\\\"); // cast is ok because FilePath is not const, and we know that StrStr returns a pointer in FilePath. Will disappear when using a string object instead of CHAR16* while (Char != NULL) { // StrCpyS(Char, 4, Char + 1); //can't overlap Tail = Char + 1; while (*Tail != 0) { *(Char++) = *(Tail++); } - Char = StrStr(FilePath, L"\\\\"); + Char = (CHAR16*)StrStr(FilePath, L"\\\\"); // cast is ok because FilePath is not const, and we know that StrStr returns a pointer in FilePath. Will disappear when using a string object instead of CHAR16* } return FilePath; } @@ -1733,7 +1733,7 @@ BOOLEAN DumpVariable(CHAR16* Name, EFI_GUID* Guid, INTN DevicePathAt) return FALSE; } -VOID DbgHeader(CHAR8 *str) +VOID DbgHeader(CONST CHAR8 *str) { #if defined(ADVLOG) INTN i, len = 50 - AsciiStrLen(str); diff --git a/rEFIt_UEFI/refit/lib.h b/rEFIt_UEFI/refit/lib.h index c9928045b..a32e8c16e 100644 --- a/rEFIt_UEFI/refit/lib.h +++ b/rEFIt_UEFI/refit/lib.h @@ -73,11 +73,15 @@ #define Print if ((!GlobalConfig.Quiet) || (GlobalConfig.TextOnly)) Print //#include "GenericBdsLib.h" +extern "C" { + extern EFI_HANDLE gImageHandle; extern EFI_SYSTEM_TABLE* gST; extern EFI_BOOT_SERVICES* gBS; extern EFI_RUNTIME_SERVICES* gRT; +} + #define TAG_ABOUT (1) #define TAG_RESET (2) #define TAG_SHUTDOWN (3) @@ -214,17 +218,17 @@ OSTYPE_COMPARE_IMP(OSTYPE_IS_LINUX, type1, type2) || OSTYPE_COMPARE_IMP(OSTYPE_I typedef struct { UINT8 Type; - CHAR16 *IconName; - CHAR16 *Name; + CONST CHAR16 *IconName; + CONST CHAR16 *Name; } LEGACY_OS; typedef struct { EFI_DEVICE_PATH *DevicePath; EFI_HANDLE DeviceHandle; EFI_FILE *RootDir; - CHAR16 *DevicePathString; - CHAR16 *VolName; - CHAR16 *VolLabel; + CONST CHAR16 *DevicePathString; + CONST CHAR16 *VolName; + CONST CHAR16 *VolLabel; UINT8 DiskKind; LEGACY_OS *LegacyOS; BOOLEAN Hidden; @@ -382,7 +386,7 @@ extern INTN ScrollbarYMovement; typedef struct _refit_menu_screen REFIT_MENU_SCREEN; typedef struct _refit_menu_entry { - CHAR16 *Title; + CONST CHAR16 *Title; UINTN Tag; UINTN Row; CHAR16 ShortcutDigit; @@ -414,15 +418,15 @@ typedef struct _refit_input_dialog { struct _refit_menu_screen { UINTN ID; - CHAR16 *Title; + CONST CHAR16 *Title; EG_IMAGE *TitleImage; INTN InfoLineCount; - CHAR16 **InfoLines; + CONST CHAR16 **InfoLines; INTN EntryCount; REFIT_MENU_ENTRY **Entries; INTN TimeoutSeconds; - CHAR16 *TimeoutText; - CHAR16 *Theme; + CONST CHAR16 *TimeoutText; + CONST CHAR16 *Theme; BOOLEAN AnimeRun; BOOLEAN Once; UINT64 LastDraw; @@ -618,11 +622,11 @@ typedef struct KERNEL_AND_KEXT_PATCHES typedef struct { REFIT_MENU_ENTRY me; REFIT_VOLUME *Volume; - CHAR16 *DevicePathString; - CHAR16 *LoadOptions; //moved here for compatibility with legacy + CONST CHAR16 *DevicePathString; + CONST CHAR16 *LoadOptions; //moved here for compatibility with legacy UINTN BootNum; - CHAR16 *LoaderPath; - CHAR16 *VolName; + CONST CHAR16 *LoaderPath; + CONST CHAR16 *VolName; EFI_DEVICE_PATH *DevicePath; UINT16 Flags; UINT8 LoaderType; @@ -632,16 +636,16 @@ typedef struct { UINT8 CustomBoot; EG_IMAGE *CustomLogo; KERNEL_AND_KEXT_PATCHES *KernelAndKextPatches; - CHAR16 *Settings; + CONST CHAR16 *Settings; } LOADER_ENTRY; typedef struct { REFIT_MENU_ENTRY me; REFIT_VOLUME *Volume; - CHAR16 *DevicePathString; + CONST CHAR16 *DevicePathString; CONST CHAR16 *LoadOptions; UINTN BootNum; - CHAR16 *LoaderPath; //will be set to NULL + CONST CHAR16 *LoaderPath; //will be set to NULL } LEGACY_ENTRY; #define ANIME_INFINITE ((UINTN)-1) @@ -676,7 +680,7 @@ extern EFI_DEVICE_PATH *SelfFullDevicePath; extern EFI_FILE *ThemeDir; extern CHAR16 *ThemePath; extern EFI_FILE *OEMDir; -extern CHAR16 *OEMPath; +extern CONST CHAR16 *OEMPath; extern EFI_FILE *OemThemeDir; extern BOOLEAN MainAnime; @@ -706,9 +710,9 @@ VOID UninitRefitLib(VOID); EFI_STATUS ReinitRefitLib(VOID); EFI_STATUS ReinitSelfLib(VOID); //extern EFI_STATUS FinishInitRefitLib(VOID); -- static -VOID PauseForKey(IN CHAR16 *Msg); +VOID PauseForKey(IN CONST CHAR16 *Msg); BOOLEAN IsEmbeddedTheme(VOID); -UINT8 GetOSTypeFromPath (IN CHAR16 *Path); +UINT8 GetOSTypeFromPath (IN CONST CHAR16 *Path); VOID CreateList(OUT VOID ***ListPtr, OUT UINTN *ElementCount, IN UINTN InitialElementCount); VOID AddListElement(IN OUT VOID ***ListPtr, IN OUT UINTN *ElementCount, IN VOID *NewElement); @@ -728,17 +732,17 @@ VOID ScanVolumes(VOID); REFIT_VOLUME *FindVolumeByName(IN CHAR16 *VolName); -BOOLEAN FileExists(IN EFI_FILE *BaseDir, IN CHAR16 *RelativePath); +BOOLEAN FileExists(IN CONST EFI_FILE *BaseDir, IN CONST CHAR16 *RelativePath); -BOOLEAN DeleteFile(IN EFI_FILE *Root, IN CHAR16 *RelativePath); +BOOLEAN DeleteFile(IN EFI_FILE *Root, IN CONST CHAR16 *RelativePath); EFI_STATUS DirNextEntry(IN EFI_FILE *Directory, IN OUT EFI_FILE_INFO **DirEntry, IN UINTN FilterMode); -VOID DirIterOpen(IN EFI_FILE *BaseDir, IN CHAR16 *RelativePath OPTIONAL, OUT REFIT_DIR_ITER *DirIter); -BOOLEAN DirIterNext(IN OUT REFIT_DIR_ITER *DirIter, IN UINTN FilterMode, IN CHAR16 *FilePattern OPTIONAL, OUT EFI_FILE_INFO **DirEntry); +VOID DirIterOpen(IN EFI_FILE *BaseDir, IN CONST CHAR16 *RelativePath OPTIONAL, OUT REFIT_DIR_ITER *DirIter); +BOOLEAN DirIterNext(IN OUT REFIT_DIR_ITER *DirIter, IN UINTN FilterMode, IN CONST CHAR16 *FilePattern OPTIONAL, OUT EFI_FILE_INFO **DirEntry); EFI_STATUS DirIterClose(IN OUT REFIT_DIR_ITER *DirIter); -CHAR16 * Basename(IN CHAR16 *Path); +CONST CHAR16 * Basename(IN CONST CHAR16 *Path); VOID ReplaceExtension(IN OUT CHAR16 *Path, IN CHAR16 *Extension); CHAR16 * egFindExtension(IN CHAR16 *FileName); @@ -807,9 +811,9 @@ extern EG_IMAGE *BackgroundImage; VOID InitScreen(IN BOOLEAN SetMaxResolution); VOID SetupScreen(VOID); -VOID BeginTextScreen(IN CHAR16 *Title); +VOID BeginTextScreen(IN CONST CHAR16 *Title); VOID FinishTextScreen(IN BOOLEAN WaitAlways); -VOID BeginExternalScreen(IN BOOLEAN UseGraphicsMode, IN CHAR16 *Title); +VOID BeginExternalScreen(IN BOOLEAN UseGraphicsMode, IN CONST CHAR16 *Title); VOID FinishExternalScreen(VOID); VOID TerminateScreen(VOID); VOID SetNextScreenMode(INT32); @@ -821,8 +825,8 @@ VOID DebugPause(VOID); #endif VOID EndlessIdleLoop(VOID); -BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CHAR16 *where); -BOOLEAN CheckError(IN EFI_STATUS Status, IN CHAR16 *where); +BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CONST CHAR16 *where); +BOOLEAN CheckError(IN EFI_STATUS Status, IN CONST CHAR16 *where); VOID SwitchToGraphicsAndClear(VOID); VOID BltClearScreen(IN BOOLEAN ShowBanner); @@ -841,13 +845,12 @@ VOID FreeAnime(GUI_ANIME *Anime); // icns loader module // -EG_IMAGE * LoadOSIcon(IN CHAR16 *OSIconName OPTIONAL, IN CHAR16 *FallbackIconName, IN UINTN PixelSize, IN BOOLEAN BootLogo, IN BOOLEAN WantDummy); - -EG_IMAGE * LoadIcns(IN EFI_FILE_HANDLE BaseDir, IN CHAR16 *FileName, IN UINTN PixelSize); -EG_IMAGE * LoadIcnsFallback(IN EFI_FILE_HANDLE BaseDir, IN CHAR16 *FileName, IN UINTN PixelSize); +EG_IMAGE * LoadOSIcon(IN CONST CHAR16 *OSIconName OPTIONAL, IN CONST CHAR16 *FallbackIconName, IN UINTN PixelSize, IN BOOLEAN BootLogo, IN BOOLEAN WantDummy); +EG_IMAGE * LoadIcns(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN PixelSize); +EG_IMAGE * LoadIcnsFallback(IN EFI_FILE_HANDLE BaseDir, IN CONST CHAR16 *FileName, IN UINTN PixelSize); EG_IMAGE * DummyImage(IN UINTN PixelSize); EG_IMAGE * BuiltinIcon(IN UINTN Id); -CHAR16 * GetIconsExt(IN CHAR16 *Icon, IN CHAR16 *Def); +CHAR16 * GetIconsExt(IN CONST CHAR16 *Icon, IN CONST CHAR16 *Def); EG_IMAGE * GetSmallHover(IN UINTN Id); #define BUILTIN_ICON_FUNC_ABOUT (0) @@ -903,20 +906,20 @@ EG_IMAGE * GetSmallHover(IN UINTN Id); #define ICON_FORMAT_PNG (2) #define ICON_FORMAT_BMP (3) -VOID AddMenuInfoLine(IN REFIT_MENU_SCREEN *Screen, IN CHAR16 *InfoLine); -VOID AddMenuInfo(IN REFIT_MENU_SCREEN *SubScreen, IN CHAR16 *Line); +VOID AddMenuInfoLine(IN REFIT_MENU_SCREEN *Screen, IN CONST CHAR16 *InfoLine); +VOID AddMenuInfo(IN REFIT_MENU_SCREEN *SubScreen, IN CONST CHAR16 *Line); VOID AddMenuEntry(IN REFIT_MENU_SCREEN *Screen, IN REFIT_MENU_ENTRY *Entry); VOID AddMenuCheck(REFIT_MENU_SCREEN *SubScreen, CONST CHAR8 *Text, UINTN Bit, INTN ItemNum); VOID FreeMenu(IN REFIT_MENU_SCREEN *Screen); UINTN RunMenu(IN REFIT_MENU_SCREEN *Screen, OUT REFIT_MENU_ENTRY **ChosenEntry); UINTN RunMainMenu(IN REFIT_MENU_SCREEN *Screen, IN INTN DefaultSelection, OUT REFIT_MENU_ENTRY **ChosenEntry); -VOID DrawMenuText(IN CHAR16 *Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor); +VOID DrawMenuText(IN CONST CHAR16 *Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor); VOID ReinitVolumes(VOID); BOOLEAN ReadAllKeyStrokes(VOID); VOID OptionsMenu(OUT REFIT_MENU_ENTRY **ChosenEntry, IN CHAR8 *LastChosenOS); VOID FreeScrollBar(VOID); -INTN DrawTextXY(IN CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign); -VOID DrawBCSText(IN CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign); +INTN DrawTextXY(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign); +VOID DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign); // // config module @@ -924,7 +927,7 @@ VOID DrawBCSText(IN CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign); typedef struct MISC_ICONS { EG_IMAGE *image; - CHAR8 *name; + CONST CHAR8 *name; } MISC_ICONS; extern MISC_ICONS OSIconsTable[]; @@ -1008,7 +1011,7 @@ VOID DumpKernelAndKextPatches(KERNEL_AND_KEXT_PATCHES *Patches); //VOID FilterKextPatches(IN LOADER_ENTRY *Entry); -UINT32 EncodeOptions(CHAR16 *Options); +UINT32 EncodeOptions(CONST CHAR16 *Options); CHAR8* GetUnicodeChar(CHAR8 *s, CHAR16* UnicodeChar); @@ -1017,7 +1020,7 @@ CHAR8* GetUnicodeChar(CHAR8 *s, CHAR16* UnicodeChar); #define FSearchReplace(Source, Search, Replace) SearchAndReplace(Source, KERNEL_MAX_SIZE, Search, sizeof(Search), Replace, 1) #endif //FKERNELPATCH -VOID DbgHeader(CHAR8 *str); +VOID DbgHeader(CONST CHAR8 *str); #endif /* diff --git a/rEFIt_UEFI/refit/list.c b/rEFIt_UEFI/refit/list.cpp similarity index 100% rename from rEFIt_UEFI/refit/list.c rename to rEFIt_UEFI/refit/list.cpp diff --git a/rEFIt_UEFI/refit/list.h b/rEFIt_UEFI/refit/list.h index 38166cae2..09ad768cc 100644 --- a/rEFIt_UEFI/refit/list.h +++ b/rEFIt_UEFI/refit/list.h @@ -115,7 +115,7 @@ Add_ListElement( IN LIST_ELEMENT_DESTRUCTOR Destructor OPTIONAL, IN VOID *ConstructorParameters OPTIONAL - ) + ); #endif LIST_ENTRY * diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index e8745084d..77d38613b 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -39,10 +39,6 @@ #include "../cpp_util/globals_ctor.h" #include "../cpp_util/globals_dtor.h" -#ifdef __cplusplus -extern "C" { -#endif - #include "entry_scan.h" #include "nanosvg.h" @@ -72,9 +68,9 @@ extern "C" { // variables #ifdef FIRMWARE_REVISION -CHAR16 *gFirmwareRevision = FIRMWARE_REVISION; +CONST CHAR16 *gFirmwareRevision = FIRMWARE_REVISION; #else -CHAR16 *gFirmwareRevision = NULL; +CONST CHAR16 *gFirmwareRevision = NULL; #endif BOOLEAN gGuiIsReady = FALSE; @@ -96,7 +92,7 @@ EFI_HANDLE ConsoleInHandle; EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* SimpleTextEx; EFI_KEY_DATA KeyData; -CHAR8* AudioOutputNames[] = { +CONST CHAR8* AudioOutputNames[] = { "LineOut", "Speaker", "Headphones", @@ -118,15 +114,10 @@ extern UINTN DsdtsNum; extern CHAR16 *DsdtsList[]; extern UINTN AudioNum; extern HDA_OUTPUTS AudioList[20]; -extern CHAR8 *AudioOutputNames[]; extern EFI_AUDIO_IO_PROTOCOL *AudioIo; -#ifdef __cplusplus -} -#endif - static EFI_STATUS LoadEFIImageList(IN EFI_DEVICE_PATH **DevicePaths, - IN CHAR16 *ImageTitle, + IN CONST CHAR16 *ImageTitle, OUT UINTN *ErrorInStep, OUT EFI_HANDLE *NewImageHandle) { @@ -175,8 +166,8 @@ bailout: static EFI_STATUS StartEFILoadedImage(IN EFI_HANDLE ChildImageHandle, - IN CHAR16 *LoadOptions, IN CHAR16 *LoadOptionsPrefix, - IN CHAR16 *ImageTitle, + IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOptionsPrefix, + IN CONST CHAR16 *ImageTitle, OUT UINTN *ErrorInStep) { EFI_STATUS Status, ReturnStatus; @@ -260,7 +251,7 @@ bailout: static EFI_STATUS LoadEFIImage(IN EFI_DEVICE_PATH *DevicePath, - IN CHAR16 *ImageTitle, + IN CONST CHAR16 *ImageTitle, OUT UINTN *ErrorInStep, OUT EFI_HANDLE *NewImageHandle) { @@ -285,8 +276,8 @@ static EFI_STATUS LoadEFIImage(IN EFI_DEVICE_PATH *DevicePath, static EFI_STATUS StartEFIImage(IN EFI_DEVICE_PATH *DevicePath, - IN CHAR16 *LoadOptions, IN CHAR16 *LoadOptionsPrefix, - IN CHAR16 *ImageTitle, + IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOptionsPrefix, + IN CONST CHAR16 *ImageTitle, OUT UINTN *ErrorInStep, OUT EFI_HANDLE *NewImageHandle) { @@ -326,14 +317,14 @@ static EFI_STATUS StartEFIImageList(IN EFI_DEVICE_PATH **DevicePaths, } */ -static CHAR8 *SearchString ( - IN CHAR8 *Source, +static CONST CHAR8 *SearchString ( + IN CONST CHAR8 *Source, IN UINT64 SourceSize, - IN CHAR8 *Search, + IN CONST CHAR8 *Search, IN UINTN SearchSize ) { - CHAR8 *End = Source + SourceSize; + CONST CHAR8 *End = Source + SourceSize; while (Source < End) { if (CompareMem(Source, Search, SearchSize) == 0) { @@ -515,7 +506,7 @@ VOID ReadSIPCfg() // text output from boot.efi when booting in graphics mode // EFI_STATUS EFIAPI -NullConOutOutputString(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN CHAR16 *String) { +NullConOutOutputString(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN CONST CHAR16 *String) { return EFI_SUCCESS; } @@ -530,7 +521,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry) EFI_TEXT_STRING ConOutOutputString = 0; EFI_HANDLE ImageHandle = NULL; EFI_LOADED_IMAGE *LoadedImage = NULL; - CHAR8 *InstallerVersion; + CONST CHAR8 *InstallerVersion; TagPtr dict = NULL; UINTN i; NSVGfont *font, *nextFont; @@ -706,7 +697,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry) // Set boot argument for kernel if no caches, this should force kernel loading if (OSFLAG_ISSET(Entry->Flags, OSFLAG_NOCACHES) && (StriStr(Entry->LoadOptions, L"Kernel=") == NULL)) { - CHAR16 *KernelLocation = NULL; + CONST CHAR16 *KernelLocation = NULL; CHAR16 *TempOptions; if (Entry->OSVersion && AsciiOSVersionToUint64(Entry->OSVersion) <= AsciiOSVersionToUint64("10.9")) { @@ -1119,7 +1110,7 @@ static VOID StartTool(IN LOADER_ENTRY *Entry) // pre-boot driver functions // -static VOID ScanDriverDir(IN CHAR16 *Path, OUT EFI_HANDLE **DriversToConnect, OUT UINTN *DriversToConnectNum) +static VOID ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConnect, OUT UINTN *DriversToConnectNum) { EFI_STATUS Status; REFIT_DIR_ITER DirIter; @@ -1789,7 +1780,7 @@ extern UINT8 *gLanMmio[4]; // their MMIO regions extern UINT8 gLanMac[4][6]; // their MAC addresses extern UINTN nLanPaths; // number of LAN pathes -BOOLEAN SetOEMPathIfExists(IN EFI_FILE *Root, IN CHAR16 *path, CHAR16 *ConfName) +BOOLEAN SetOEMPathIfExists(IN EFI_FILE *Root, IN CONST CHAR16 *path, CONST CHAR16 *ConfName) { BOOLEAN res = FileExists(Root, path); if ( res ) { @@ -1811,7 +1802,7 @@ BOOLEAN SetOEMPathIfExists(IN EFI_FILE *Root, IN CHAR16 *path, CHAR16 *ConfName) return 0; } -VOID SetOEMPath(CHAR16 *ConfName) +VOID SetOEMPath(CONST CHAR16 *ConfName) { if (ConfName == NULL) { OEMPath = L"EFI\\CLOVER"; @@ -1903,14 +1894,14 @@ UINT8 *APFSContainer_Support(VOID) { } //System / Install / Recovery version filler -CHAR16 *SystemVersionPlist = L"\\System\\Library\\CoreServices\\SystemVersion.plist"; -CHAR16 *ServerVersionPlist = L"\\System\\Library\\CoreServices\\ServerVersion.plist"; -CHAR16 *InstallVersionPlist = L"\\macOS Install Data\\Locked Files\\Boot Files\\SystemVersion.plist"; -CHAR16 *RecoveryVersionPlist = L"\\com.apple.recovery.boot\\SystemVersion.plist"; -CHAR16 APFSSysPlistPath[86] = L"\\00000000-0000-0000-0000-000000000000\\System\\Library\\CoreServices\\SystemVersion.plist"; -CHAR16 APFSServerPlistPath[86] = L"\\00000000-0000-0000-0000-000000000000\\System\\Library\\CoreServices\\ServerVersion.plist"; -CHAR16 APFSInstallPlistPath[79] = L"\\00000000-0000-0000-0000-000000000000\\com.apple.installer\\SystemVersion.plist"; -CHAR16 APFSRecPlistPath[58] = L"\\00000000-0000-0000-0000-000000000000\\SystemVersion.plist"; +CONST CHAR16 *SystemVersionPlist = L"\\System\\Library\\CoreServices\\SystemVersion.plist"; +CONST CHAR16 *ServerVersionPlist = L"\\System\\Library\\CoreServices\\ServerVersion.plist"; +CONST CHAR16 *InstallVersionPlist = L"\\macOS Install Data\\Locked Files\\Boot Files\\SystemVersion.plist"; +CONST CHAR16 *RecoveryVersionPlist = L"\\com.apple.recovery.boot\\SystemVersion.plist"; +CONST CHAR16 APFSSysPlistPath[86] = L"\\00000000-0000-0000-0000-000000000000\\System\\Library\\CoreServices\\SystemVersion.plist"; +CONST CHAR16 APFSServerPlistPath[86] = L"\\00000000-0000-0000-0000-000000000000\\System\\Library\\CoreServices\\ServerVersion.plist"; +CONST CHAR16 APFSInstallPlistPath[79] = L"\\00000000-0000-0000-0000-000000000000\\com.apple.installer\\SystemVersion.plist"; +CONST CHAR16 APFSRecPlistPath[58] = L"\\00000000-0000-0000-0000-000000000000\\SystemVersion.plist"; VOID SystemVersionInit(VOID) @@ -2880,8 +2871,8 @@ PauseForKey(L"press"); */ if (StrStr(LoaderEntry->LoadOptions, L"BO-ADD") != NULL) { CHAR16 *Description; - CHAR16 *VolName; - CHAR16 *LoaderName; + CONST CHAR16 *VolName; + CONST CHAR16 *LoaderName; INTN EntryIndex, NameSize, Name2Size; LOADER_ENTRY *Entry; UINT8 *OptionalData; diff --git a/rEFIt_UEFI/refit/menu.cpp b/rEFIt_UEFI/refit/menu.cpp index 7bae7c332..67d36b268 100644 --- a/rEFIt_UEFI/refit/menu.cpp +++ b/rEFIt_UEFI/refit/menu.cpp @@ -43,10 +43,6 @@ #include "../cpp_util/globals_ctor.h" #include "../cpp_util/globals_dtor.h" -#ifdef __cplusplus -extern "C" { -#endif - #include "Version.h" //#include "colors.h" @@ -84,8 +80,8 @@ extern UINTN DsdtsNum; extern CHAR16 *DsdtsList[]; extern UINTN AudioNum; extern HDA_OUTPUTS AudioList[20]; -extern CHAR8 *AudioOutputNames[]; -extern CHAR8 *NonDetected; +extern CONST CHAR8 *AudioOutputNames[]; +extern CHAR8 NonDetected[]; extern BOOLEAN GetLegacyLanAddress; extern UINT8 gLanMac[4][6]; // their MAC addresses extern EFI_AUDIO_IO_PROTOCOL *AudioIo; @@ -123,7 +119,7 @@ BOOLEAN SavePreBootLog = FALSE; #define MENU_FUNCTION_PAINT_SELECTION (3) #define MENU_FUNCTION_PAINT_TIMEOUT (4) -typedef VOID (*MENU_STYLE_FUNC)(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINTN Function, IN CHAR16 *ParamText); +typedef VOID (*MENU_STYLE_FUNC)(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINTN Function, IN CONST CHAR16 *ParamText); static CHAR16 ArrowUp[2] = { ARROW_UP, 0 }; static CHAR16 ArrowDown[2] = { ARROW_DOWN, 0 }; @@ -225,7 +221,7 @@ REFIT_MENU_SCREEN MainMenu = {1, L"Main Menu", NULL, 0, NULL, 0, NULL, 0, L"A REFIT_MENU_SCREEN AboutMenu = {2, L"About", NULL, 0, NULL, 0, NULL, 0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0, {0, 0, 0, 0}, NULL}; REFIT_MENU_SCREEN HelpMenu = {3, L"Help", NULL, 0, NULL, 0, NULL, 0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0, {0, 0, 0, 0}, NULL}; -CHAR16* ArgOptional[NUM_OPT] = { +CONST CHAR16* ArgOptional[NUM_OPT] = { L"arch=i386", //0 L"arch=x86_64", //1 L"-v ", //2 @@ -1336,7 +1332,7 @@ VOID ApplyInputs(VOID) } } -VOID AddMenuInfo(REFIT_MENU_SCREEN *SubScreen, CHAR16 *Line) +VOID AddMenuInfo(REFIT_MENU_SCREEN *SubScreen, CONST CHAR16 *Line) { REFIT_INPUT_DIALOG *InputBootArgs; @@ -2149,9 +2145,9 @@ static VOID UpdateScroll(IN OUT SCROLL_STATE *State, IN UINTN Movement) // menu helper functions // -VOID AddMenuInfoLine(IN REFIT_MENU_SCREEN *Screen, IN CHAR16 *InfoLine) +VOID AddMenuInfoLine(IN REFIT_MENU_SCREEN *Screen, IN CONST CHAR16 *InfoLine) { - AddListElement((VOID ***) &(Screen->InfoLines), (UINTN*)&(Screen->InfoLineCount), InfoLine); + AddListElement((VOID ***) &(Screen->InfoLines), (UINTN*)&(Screen->InfoLineCount), (CHAR16*)InfoLine); // TODO jief : cast to fix } VOID AddMenuEntry(IN REFIT_MENU_SCREEN *Screen, IN REFIT_MENU_ENTRY *Entry) @@ -2760,7 +2756,7 @@ UINTN RunGenericMenu(IN REFIT_MENU_SCREEN *Screen, IN MENU_STYLE_FUNC StyleFunc, /** * Text Mode menu. */ -static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINTN Function, IN CHAR16 *ParamText) +static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINTN Function, IN CONST CHAR16 *ParamText) { INTN i = 0, j = 0; static UINTN TextMenuWidth = 0,ItemWidth = 0, MenuHeight = 0; @@ -3006,7 +3002,7 @@ static VOID TextMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, /** * Draw text with specific coordinates. */ -INTN DrawTextXY(IN CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign) +INTN DrawTextXY(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign) { INTN TextWidth = 0; INTN XText = 0; @@ -3065,7 +3061,7 @@ INTN DrawTextXY(IN CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign) * Helper function to draw text for Boot Camp Style. * @author: Needy */ -VOID DrawBCSText(IN CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign) +VOID DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN UINT8 XAlign) { // check if text was provided if (!Text) { @@ -3178,7 +3174,7 @@ VOID DrawMenuText(IN CHAR16 *Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN } */ -VOID DrawMenuText(IN CHAR16 *Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor) +VOID DrawMenuText(IN CONST CHAR16 *Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN INTN Cursor) { //use Text=null to reinit the buffer if (!Text) { @@ -3429,7 +3425,7 @@ VOID ScrollingBar(IN SCROLL_STATE *State) /** * Graphical menu. */ -VOID GraphicsMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINTN Function, IN CHAR16 *ParamText) +VOID GraphicsMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINTN Function, IN CONST CHAR16 *ParamText) { INTN i; INTN j = 0; @@ -3863,7 +3859,7 @@ VOID FillRectAreaOfScreen(IN INTN XPos, IN INTN YPos, IN INTN Width, IN INTN Hei egFreeImage(TmpBuffer); } -VOID DrawMainMenuLabel(IN CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State) +VOID DrawMainMenuLabel(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN YPos, IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State) { INTN TextWidth; INTN BadgeDim = (INTN)(BADGE_DIMENSION * GlobalConfig.Scale); @@ -3978,7 +3974,7 @@ VOID DrawTextCorner(UINTN TextC, UINT8 Align) if ( Text ) FreePool(Text); } -VOID MainMenuVerticalStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINTN Function, IN CHAR16 *ParamText) +VOID MainMenuVerticalStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINTN Function, IN CONST CHAR16 *ParamText) { INTN i; INTN row0PosYRunning; @@ -4128,7 +4124,7 @@ VOID MainMenuVerticalStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, /** * Main screen text. */ -VOID MainMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINTN Function, IN CHAR16 *ParamText) +VOID MainMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINTN Function, IN CONST CHAR16 *ParamText) { EFI_STATUS Status = EFI_SUCCESS; INTN i = 0; @@ -4394,11 +4390,11 @@ VOID AddMenuCheck(REFIT_MENU_SCREEN *SubScreen, CONST CHAR8 *Text, UINTN Bit, IN VOID ModifyTitles(REFIT_MENU_ENTRY *ChosenEntry) { if (ChosenEntry->SubScreen->ID == SCREEN_DSDT) { - UnicodeSPrint(ChosenEntry->Title, 128, L"DSDT fix mask [0x%08x]->", gSettings.FixDsdt); + UnicodeSPrint((CHAR16*)ChosenEntry->Title, 128, L"DSDT fix mask [0x%08x]->", gSettings.FixDsdt); // TODO jief : cast to fix //MsgLog("@ESC: %s\n", (*ChosenEntry)->Title); } else if (ChosenEntry->SubScreen->ID == SCREEN_CSR) { // CSR - UnicodeSPrint(ChosenEntry->Title, 128, L"System Integrity Protection [0x%04x]->", gSettings.CsrActiveConfig); + UnicodeSPrint((CHAR16*)ChosenEntry->Title, 128, L"System Integrity Protection [0x%04x]->", gSettings.CsrActiveConfig); // TODO jief : cast to fix // check for the right booter flag to allow the application // of the new System Integrity Protection configuration. if (gSettings.CsrActiveConfig != 0 && gSettings.BooterConfig == 0) { @@ -4406,9 +4402,9 @@ VOID ModifyTitles(REFIT_MENU_ENTRY *ChosenEntry) } } else if (ChosenEntry->SubScreen->ID == SCREEN_BLC) { - UnicodeSPrint(ChosenEntry->Title, 128, L"boot_args->flags [0x%04x]->", gSettings.BooterConfig); + UnicodeSPrint((CHAR16*)ChosenEntry->Title, 128, L"boot_args->flags [0x%04x]->", gSettings.BooterConfig); // TODO jief : cast to fix } else if (ChosenEntry->SubScreen->ID == SCREEN_DSM) { - UnicodeSPrint(ChosenEntry->Title, 128, L"Drop OEM _DSM [0x%04x]->", dropDSM); + UnicodeSPrint((CHAR16*)ChosenEntry->Title, 128, L"Drop OEM _DSM [0x%04x]->", dropDSM); // TODO jief : cast to fix } } @@ -4621,7 +4617,7 @@ REFIT_MENU_ENTRY *SubMenuKextPatches() return Entry; } -REFIT_MENU_ENTRY *SubMenuKextBlockInjection(CHAR16* UniSysVer) +REFIT_MENU_ENTRY *SubMenuKextBlockInjection(CONST CHAR16* UniSysVer) { REFIT_MENU_ENTRY *Entry = NULL; REFIT_MENU_SCREEN *SubScreen = NULL; @@ -5536,7 +5532,7 @@ VOID OptionsMenu(OUT REFIT_MENU_ENTRY **ChosenEntry, IN CHAR8 *LastChosenOS) ApplyInputs(); } -UINT32 EncodeOptions(CHAR16 *Options) +UINT32 EncodeOptions(CONST CHAR16 *Options) { UINT32 OptionsBits = 0; INTN Index; @@ -5715,7 +5711,3 @@ UINTN RunMainMenu(IN REFIT_MENU_SCREEN *Screen, IN INTN DefaultSelection, OUT RE return MenuExit; } -#ifdef __cplusplus -} -#endif - diff --git a/rEFIt_UEFI/refit/screen.c b/rEFIt_UEFI/refit/screen.cpp similarity index 98% rename from rEFIt_UEFI/refit/screen.c rename to rEFIt_UEFI/refit/screen.cpp index 0d9bf744c..2262acbb0 100644 --- a/rEFIt_UEFI/refit/screen.c +++ b/rEFIt_UEFI/refit/screen.cpp @@ -57,7 +57,7 @@ INTN BanHeight = 0; static VOID SwitchToText(IN BOOLEAN CursorEnabled); static VOID SwitchToGraphics(VOID); -static VOID DrawScreenHeader(IN CHAR16 *Title); +static VOID DrawScreenHeader(IN CONST CHAR16 *Title); static VOID UpdateConsoleVars(VOID); static INTN ConvertEdgeAndPercentageToPixelPosition(INTN Edge, INTN DesiredPercentageFromEdge, INTN ImageDimension, INTN ScreenDimension); static INTN CalculateNudgePosition(INTN Position, INTN NudgeValue, INTN ImageDimension, INTN ScreenDimension); @@ -158,7 +158,7 @@ static VOID SwitchToGraphics(VOID) // // Screen control for running tools // -VOID BeginTextScreen(IN CHAR16 *Title) +VOID BeginTextScreen(IN CONST CHAR16 *Title) { DrawScreenHeader(Title); SwitchToText(FALSE); @@ -178,7 +178,7 @@ VOID FinishTextScreen(IN BOOLEAN WaitAlways) haveError = FALSE; } -VOID BeginExternalScreen(IN BOOLEAN UseGraphicsMode, IN CHAR16 *Title) +VOID BeginExternalScreen(IN BOOLEAN UseGraphicsMode, IN CONST CHAR16 *Title) { if (!AllowGraphicsMode) { UseGraphicsMode = FALSE; @@ -226,7 +226,7 @@ VOID TerminateScreen(VOID) gST->ConOut->EnableCursor(gST->ConOut, TRUE); } -static VOID DrawScreenHeader(IN CHAR16 *Title) +static VOID DrawScreenHeader(IN CONST CHAR16 *Title) { UINTN i; CHAR16* BannerLine = (__typeof__(BannerLine))AllocatePool((ConWidth + 1) * sizeof(CHAR16)); @@ -295,7 +295,7 @@ BOOLEAN ReadAllKeyStrokes(VOID) return GotKeyStrokes; } -VOID PauseForKey(CHAR16* msg) +VOID PauseForKey(CONST CHAR16* msg) { #if REFIT_DEBUG > 0 UINTN index; @@ -352,7 +352,7 @@ StatusToString ( }*/ -BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CHAR16 *where) +BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CONST CHAR16 *where) { // CHAR16 ErrorName[64]; @@ -370,7 +370,7 @@ BOOLEAN CheckFatalError(IN EFI_STATUS Status, IN CHAR16 *where) return TRUE; } -BOOLEAN CheckError(IN EFI_STATUS Status, IN CHAR16 *where) +BOOLEAN CheckError(IN EFI_STATUS Status, IN CONST CHAR16 *where) { // CHAR16 ErrorName[64];