### Install Dependencies and Clone RebarDxe on Windows Source: https://github.com/xcuri0/rebaruefi/wiki/Building Installs necessary tools and clones the EDK2 repository for building ReBarDxe on Windows. Ensure Git and Python are in your PATH and use the VS Native Tools Command Prompt. ```batch pip install pefile git clone https://github.com/tianocore/edk2.git cd edk2 git submodule update --init edksetup.bat Rebuild ``` -------------------------------- ### Install Dependencies and Clone RebarDxe on Linux Source: https://github.com/xcuri0/rebaruefi/wiki/Building Installs required Python packages and Git repositories for building ReBarDxe on Linux. Ensure edk2 submodules are updated and BaseTools are compiled before setting up the environment. ```bash pip install pefile git clone https://github.com/tianocore/edk2.git cd edk2 git submodule update --init make -C BaseTools source ./edksetup.sh ``` -------------------------------- ### Linux dmesg Output Example Source: https://github.com/xcuri0/rebaruefi/wiki/DSDT-Patching This is an example output from the 'dmesg | grep "root bus resource"' command on Linux, showing the root bus resource ranges. It helps in determining if DSDT modification is needed. ```bash [ 0.161520] pci_bus 0000:00: root bus resource [bus 00-3e] [ 0.161522] pci_bus 0000:00: root bus resource [io 0x0000-0x0cf7 window] [ 0.161523] pci_bus 0000:00: root bus resource [io 0x0d00-0xffff window] [ 0.161525] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000effff window] [ 0.161526] pci_bus 0000:00: root bus resource [mem 0xdfa00000-0xfeafffff window] [ 0.161527] pci_bus 0000:00: root bus resource [mem 0x21e600000-0xfffffffff window] ``` -------------------------------- ### Configure ReBarState Project Source: https://github.com/xcuri0/rebaruefi/blob/master/ReBarState/CMakeLists.txt Sets the minimum CMake version, project name, and C++ standard. This is a standard setup for most CMake projects. ```cmake cmake_minimum_required (VERSION 3.8) project ("ReBarState") set(CMAKE_CXX_STANDARD 17) ``` -------------------------------- ### Original DSDT CreateQWordField Example Source: https://github.com/xcuri0/rebaruefi/wiki/DSDT-Patching This ASL code snippet shows the original 'CreateQWordField' definitions found in a stock DSDT. It defines fields for length, minimum, and maximum base addresses. ```asl CreateQWordField (BUF0, \_SB.PCI0._Y0F._LEN, M2LN) // _LEN: Length CreateQWordField (BUF0, \_SB.PCI0._Y0F._MIN, M2MN) // _MIN: Minimum Base Address CreateQWordField (BUF0, \_SB.PCI0._Y0F._MAX, M2MX) // _MAX: Maximum Base Address M2LN = 0x0000000400000000 If ((TUUD >= 0x1000)) { M2MN = (TUUD << 0x14) } Else { M2MN = 0x0000000100000000 } M2MX = ((M2MN + M2LN) - One) ``` -------------------------------- ### Modifying BIOS Variable with grub-mod-setup_var Source: https://github.com/xcuri0/rebaruefi/wiki/Enabling-hidden-4G-decoding Use grub-mod-setup_var to change the value of the 4G decoding BIOS variable. Replace '(offset)' with the actual offset found in the .txt file. If the variable is already 0x1, you may need to toggle it by setting it to 0x0, rebooting, then setting it to 0x1 and rebooting again. If a GUID mismatch error occurs, it can be safely ignored. 'setup_var_3' can be used as an alternative if 'setup_var' fails. ```bash setup_var (offset) 0x1 ``` ```bash setup_var (offset) 0x0 ``` ```bash setup_var_3 (offset) 0x1 ``` -------------------------------- ### Convert MBR to GPT for Windows Boot Source: https://github.com/xcuri0/rebaruefi/wiki/Common-issues-(and-fixes) After disabling CSM, Windows may fail to boot. Convert your legacy MBR installation to UEFI GPT to resolve this. Refer to the provided guide for detailed steps. ```markdown You need to [convert your legacy MBR installation to UEFI GPT](https://www.windowscentral.com/how-convert-mbr-disk-gpt-move-bios-uefi-windows-10). ``` -------------------------------- ### Enable 64-bit MMIO Region (Haswell/Broadwell) Source: https://github.com/xcuri0/rebaruefi/wiki/Sandy-and-Ivy-Bridge-or-Haswell-and-Broadwell-32GB-BAR-(and-above)-DSDT-modification This modification makes the 64-bit MMIO region available even when 4G decoding is turned off. Use this on ASRock systems if the DSDT does not contain the specific code mentioned in the guide. ```ACPI If (0) ``` -------------------------------- ### Fix: Length is larger than Min/Max window Source: https://github.com/xcuri0/rebaruefi/wiki/DSDT-Patching Recalculate the 'Length' value by subtracting 'Min' from 'Max' and adding one. This example shows correcting an incorrect 'Length' value. ```dsl DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, 0x00000000, // Granularity 0x02000000, // Range Minimum 0xFFDFFFFF, // Range Maximum 0x00000000, // Translation Offset 0xFDFC0000, // Length ,, _Y04, AddressRangeMemory, TypeStatic) ``` ```dsl 0xFDE00000 ``` -------------------------------- ### BAR Size Requirement Source: https://github.com/xcuri0/rebaruefi/wiki/Common-issues-(and-fixes) The required BAR size should be sufficient to fit all of your VRAM. For example, 8GB is enough for 8GB VRAM, and 16GB is sufficient for 12GB VRAM. GPUs typically do not support BARs larger than what's needed for their VRAM. ```markdown you only need a BAR size that fits all your VRAM. So 8GB is enough for 8GB VRAM and 16GB is enough for 12GB VRAM. GPUs also don't typically support BARs more than what's needed to fit all their VRAM ``` -------------------------------- ### Configure Target for ReBarDxe Build on Linux Source: https://github.com/xcuri0/rebaruefi/wiki/Building Sets the build target and architecture in the target.txt configuration file for ReBarDxe. Adjust TOOL_CHAIN_TAG if using a different compiler. ```bash TARGET = RELEASE TARGET_ARCH = X64 TOOL_CHAIN_TAG = GCC5 # change this if you want to use Clang ``` -------------------------------- ### Build ReBarDxe FFS File on Linux Source: https://github.com/xcuri0/rebaruefi/wiki/Building Clones the ReBarUEFI repository and builds the FFS file using the provided Python script. The output FFS file will be located in a specific build directory. ```bash git clone https://github.com/xCuri0/ReBarUEFI.git cd ReBarUEFI/ReBarDxe python3 ./buildffs.py ``` -------------------------------- ### Extracting BIOS Variable Offset with IRFExtractor-RS Source: https://github.com/xcuri0/rebaruefi/wiki/Enabling-hidden-4G-decoding Run IRFExtractor-RS on the extracted BIOS body to generate a .txt file containing variable information. This file is used to find the offset for the 4G decoding setting. ```bash IRFExtractor-RS 4GDecodBody.bin ``` -------------------------------- ### Build ReBarState on Linux Source: https://github.com/xcuri0/rebaruefi/wiki/Building Clones the ReBarUEFI repository and builds the ReBarState executable using CMake. The executable will be found in the 'build' folder. ```bash git clone https://github.com/xCuri0/ReBarUEFI.git cd ReBarUEFI/ReBarState mkdir build cd build cmake .. make ``` -------------------------------- ### Configure Target for ReBarDxe Build on Windows Source: https://github.com/xcuri0/rebaruefi/wiki/Building Specifies the build target and architecture in target.txt for ReBarDxe. The TOOL_CHAIN_TAG should match your Visual Studio version; VS2019 is compatible with VS2022. ```batch TARGET = RELEASE TARGET_ARCH = X64 TOOL_CHAIN_TAG = VS2019 # works with Visual Studio 2022 too. EDK2 doesn't support 2022 officially atm. ``` -------------------------------- ### Create Modified AmiBoardInfo EFI Source: https://github.com/xcuri0/rebaruefi/wiki/DSDT-Patching Use AmiBoardInfoTool to create a new modified AmiBoardInfo.efi file by incorporating the patched DSDTMod.aml. This step is crucial for applying the DSDT changes to the BIOS. ```bash AmiBoardInfoTool -a AmiBoardInfo.efi -d DSDTMod.aml -o AmiBoardInfoMod.efi ``` -------------------------------- ### UEFI Module Function Replacement Source: https://github.com/xcuri0/rebaruefi/blob/master/README.md The ReBarDxe module replaces the original 'PreprocessController' function to check for Resizable BAR capability and set it based on NVRAM variables. ```c UINT32 PreprocessController (void) { UINT32 OriginalFunctionResult; OriginalFunctionResult = PciHostBridgeResourceAllocationProtocol->PreprocessController (); if (PciHostBridgeResourceAllocationProtocol->Hdr.Revision >= V1_0_2) { if (PciHostBridgeResourceAllocationAllocationPhase == AllocatePhaseMax) { if (PciHostBridgeResourceAllocationProtocol->DevicePath->Type == HARDWARE_DEVICE_PATH && PciHostBridgeResourceAllocationProtocol->DevicePath->SubType == HW_MEMMAP_DEVICE_PATH) { if (PciHostBridgeResourceAllocationProtocol->Hdr.Device.VendorId == 0x10DE && PciHostBridgeResourceAllocationProtocol->Hdr.Device.DeviceId == 0x1B80) { if (PciHostBridgeResourceAllocationProtocol->Hdr.Device.RevisionId == 0xA1) { if (PciHostBridgeResourceAllocationProtocol->Hdr.Device.SubsystemVendorId == 0x1462 && PciHostBridgeResourceAllocationProtocol->Hdr.Device.SubsystemDeviceId == 0x5007) { PciHostBridgeResourceAllocationProtocol->Hdr.Device.MaxReadSize = 0x10000000000000000ULL; } } } } } } return OriginalFunctionResult; } ``` -------------------------------- ### Enable Resizable BAR on Unsupported AMD GPUs via Registry Source: https://github.com/xcuri0/rebaruefi/wiki/Common-issues-(and-fixes) Apply this .reg file to enable Resizable BAR on unsupported AMD GPUs. A reboot is required after applying. Note that the GPU registry path may vary if multiple GPUs or an iGPU are present. ```reg Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\0000] "KMD_RebarControlMode"=dword:00000001 "KMD_RebarControlSupport"=dword:00000001 "KMD_EnableReBarForLegacyASIC"=dword:00000001 ``` -------------------------------- ### Modified DSDT CreateQWordField for 64GB Source: https://github.com/xcuri0/rebaruefi/wiki/DSDT-Patching This ASL code snippet shows the modified 'CreateQWordField' definitions. It sets the maximum base address to 'FFFFFFFFF' for 36-bit addressing (64GB), suitable for Sandy/Ivy Bridge CPUs, and adjusts the length calculation. ```asl CreateQWordField (BUF0, \_SB.PCI0._Y0F._LEN, M2LN) // _LEN: Length CreateQWordField (BUF0, \_SB.PCI0._Y0F._MIN, M2MN) // _MIN: Minimum Base Address CreateQWordField (BUF0, \_SB.PCI0._Y0F._MAX, M2MX) // _MAX: Maximum Base Address // 36-bit / 64GB is highest supported by Sandy/Ivy Bridge M2MX = 0xFFFFFFFFF If ((TUUD >= 0x1000)) { M2MN = (TUUD << 0x14) } Else { M2MN = 0x0000000100000000 } M2LN = (M2MX - M2MN) + One ``` -------------------------------- ### Adjust MMIO Limit for Stutters and Boot Issues Source: https://github.com/xcuri0/rebaruefi/wiki/Common-issues-(and-fixes) To potentially fix stutters on Ryzen systems or boot issues with macOS, try setting 'Above 4GB MMIO Limit' to '512GB' (39-bit). This addresses a firmware bug. ```markdown You can also try setting ```Above 4GB MMIO Limit``` to ```512GB``` (39-bit) to see if it helps. This may also fix boot issues with macOS. ``` -------------------------------- ### Add QWordMemory definition to DSDT Source: https://github.com/xcuri0/rebaruefi/wiki/DSDT-Patching Append this QWordMemory definition to your DSDT.dsl file after the last DWordMemory entry. This is for Haswell and up systems to define memory ranges. ```asl QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite, 0x0000000000000000, // Granularity 0x0000000000010000, // Range Minimum 0x000000000001FFFF, // Range Maximum 0x0000000000000000, // Translation Offset 0x0000000000010000, // Length ,, _YAF, AddressRangeMemory, TypeStatic) ``` -------------------------------- ### Fix: _HID prefix must be all uppercase or decimal digits Source: https://github.com/xcuri0/rebaruefi/wiki/DSDT-Patching Correct the '_HID prefix must be all uppercase or decimal digits' error by changing the '_HID' prefix to uppercase and removing any leading 'X'. ```dsl Name (_HID, "PNP0C14") ``` -------------------------------- ### Reduce DSDT Size for AmiBoardInfoTool Source: https://github.com/xcuri0/rebaruefi/wiki/DSDT-Patching If AmiBoardInfoTool reports 'ERROR: PE32 has .ROM but not DYNAMIC_BASE set -> Unpatchable atm..', remove unneeded ACPI _OSI entries. Further size reduction can be achieved by removing specific devices or strings. ```dsl Remove all ADBG lines ``` ```dsl Remove device BAT0 / BAT1 / BAT2 ``` ```dsl Remove device DOCK ``` ```dsl Remove device LID0 ``` ```dsl Remove SLIC string if you don't use SLI ``` -------------------------------- ### MMTool Hashes for Verification Source: https://github.com/xcuri0/rebaruefi/wiki/Adding-FFS-module Verify the integrity of your MMTool download using these checksums. Different versions are recommended for different motherboard architectures. ```plaintext MMTool.exe v5.2.0.25 (5.02.0025) 64bit MD5: D47DD4B0BE0FD99A875B81FF6AFE1738 SHA1: 2747FF08AC3A33B868211D7E1BEE35C2CF3A79F1 SHA256: 5D05D0BBEA720D4B73DC66DB55031C2659458696B9F143DF3B7E2F43040289CC MMTool.exe v5.2.0.24 (5.02.0024) Patched MD5: C6FC1435CBDE2636B33E4F7EE444A079 SHA1: 8E54AC68DE355E1031527B89C0560AE1C9C8C508 SHA256: 51A85A663B1CB819508E48FD650180E6C79AFD06FB458DD1357508FD9578FC23 MMTool.exe v5.2.0.24 (5.02.0024) MD5: 9AB78D9BD2A417BB9308B3D3CC6FEF59 SHA1: FBA82BD83C603700E6763ED8A9C5633980822C21 SHA256: BBC3E75905997DDC05C523E57A72E49BBFCAF84DCA64E460F10F8553B7FDA9EE MMTool.exe v5.1.0.12 (5.01.0012) 64bit MD5: 897FA27EFED40D1DFFA910E7827C8EDE SHA1: 287C6977966EEEFD38988C75A6F5D03F7C2214B2 SHA256: 0F936AD23BC6EC3D2F0D722DC05EED921472F021E3DA06ADFF13A8A2AE479439 MMTool.exe v5.1.0.12 (5.01.0012) 32bit MD5: 020A08867A26E23337ABA93D2720AC9E SHA1: BA60CBEB44B7010850A0CCAFE821502E14ED7D4F SHA256: 6F0000914C490932BD9B6CC83325F6D622322716F1DEAF9B565A7D0A6B73438A MMTool.exe v5.0.0.7 (5.00.0007) MD5: 6BE9244F9E5415BF04EFBC441D2CCBD8 SHA1: A37872D43B01DC39A28BB086FFB066C2F5BF735A SHA256: 28049163FD1E3423C42B229A5F6ED877F14E7CAF3B794BF7EFB970B375E6FF41 MMTool.exe v4.50.0.23 (4.50.0023) MD5: 0575DCDC6897B3914748DBFE97770AF3 SHA1: A3E47E29A2F79D67E111B5917E61AAD0B64C6F93 SHA256: 7D0377A72E67E5A71400361416452440826832AEB2C9BEBAA578E8AF962EAAFD MMTool.exe v3.26 MD5: 699E36577BCCF66090EC6095FF23C000 SHA1: 05D81E32820D6618F0B77990FA376764615C5BD8 SHA256: C5A64EA7CE2BEA8556FA81E0069ADBBA793181BFAA76F59F4F472F0A471BAC98 ``` -------------------------------- ### Add ReBarState Executable Source: https://github.com/xcuri0/rebaruefi/blob/master/ReBarState/CMakeLists.txt Defines the main executable target for the ReBarState project, linking the primary source file. ```cmake add_executable (ReBarState "ReBarState.cpp") ``` -------------------------------- ### Adjust 64-bit MMIO Region Size (Haswell/Broadwell) Source: https://github.com/xcuri0/rebaruefi/wiki/Sandy-and-Ivy-Bridge-or-Haswell-and-Broadwell-32GB-BAR-(and-above)-DSDT-modification This change modifies the 64-bit MMIO region to end at 39-bit/512GB, utilizing the full physical address range. This is intended for Haswell and up systems. ```ACPI M2MX = 0x8000000000 - One M2MN = M64B M2LN = ((M2MX - M2MN) + One) ``` -------------------------------- ### Extract DSDT with AmiBoardInfoTool Source: https://github.com/xcuri0/rebaruefi/wiki/DSDT-Patching Use this command to extract the compiled DSDT from AmiBoardInfo.efi to a .aml file. Ensure you have the modified BIOS image and AmiBoardInfo.efi prepared. ```bash AmiBoardInfoTool -a AmiBoardInfo.efi -d DSDT.aml ``` -------------------------------- ### Fix: _UID inside processor declaration must be an integer Source: https://github.com/xcuri0/rebaruefi/wiki/DSDT-Patching Use regex to fix '_UID inside processor declaration must be an integer' errors. Find 'Name\s+\(_UID,\s*"PCI\d\-CP(.*)"\)' and replace it with 'Name \(_UID, 0x0$1\)'. ```regex Name\s+\(_UID,\s*"PCI\d\-CP(.*)"\) ``` ```regex Name \(_UID, 0x0$1\) ``` -------------------------------- ### Set Windows Administrator Manifest Source: https://github.com/xcuri0/rebaruefi/blob/master/ReBarState/CMakeLists.txt Conditionally applies linker flags on Windows to ensure the ReBarState executable runs with administrator privileges. ```cmake if(WIN32) set_target_properties(ReBarState PROPERTIES LINK_FLAGS " /MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" ") endif() ``` -------------------------------- ### Set Resizable BAR Size Source: https://github.com/xcuri0/rebaruefi/wiki/Flashing-modified-UEFI Use ReBarState to set the Resizable BAR size. '32' typically means unlimited. Smaller sizes like 13 (8GB) or 14 (16GB) can be used if '32' causes issues. Note that maximum allowed BAR size is 2^n. ```text 32 ``` -------------------------------- ### Fix: Invalid object type for reserved name (_PLD: found Integer) Source: https://github.com/xcuri0/rebaruefi/wiki/DSDT-Patching To fix '_PLD: found Integer' errors, use regex to find '(Name\s*\(_PLD,\s*)Package(\s\([^\)].*\)[^\)]*)' and replace it with '$1Package() { Buffer$2}'. ```regex (Name\s*\(_PLD,\s*)Package(\s\([^\)].*\)[^\)]*) ``` ```regex $1Package() { Buffer$2} ``` -------------------------------- ### AddMemorySpace Function Offset in DXE Services Table Source: https://github.com/xcuri0/rebaruefi/wiki/Using-UEFIPatch Explains how to locate the `AddMemorySpace` function within the DXE Services table by referencing its offset. This is crucial for understanding UEFI memory management patching. ```c 0x18 ``` -------------------------------- ### Force Enable Resizable BAR on NVIDIA GPUs Source: https://github.com/xcuri0/rebaruefi/wiki/Flashing-modified-UEFI NVIDIA GPUs only enable Resizable BAR for games in their whitelist by default. Use Nvidia Profile Inspector to force enable it for all applications. ```text Nvidia Profile Inspector ``` -------------------------------- ### Fix: _HID suffix must be all hex digits Source: https://github.com/xcuri0/rebaruefi/wiki/DSDT-Patching To resolve the '_HID suffix must be all hex digits' error, replace the placeholder 'ABCDEFGH' with 'ABCDEFFF' on the indicated line. ```dsl Replace ABCDEFGH with ABCDEFFF ``` -------------------------------- ### Modify Large Memory Region Exposure (Sandy/Ivy Bridge - Alternative) Source: https://github.com/xcuri0/rebaruefi/wiki/Sandy-and-Ivy-Bridge-or-Haswell-and-Broadwell-32GB-BAR-(and-above)-DSDT-modification This code change is an alternative for systems, like some Dell prebuilts, that do not have the `If (((MM64 == Zero) || (OSYS <= 0x07D3)))` condition. It modifies the `ElseIf (E4GM)` to `Else` and removes a specific block. ```ACPI Else { CreateDWordField (BUF0, \_SB.PCI0._Y0F._LEN, M4LN) // _LEN: Length M4LN = Zero } ``` -------------------------------- ### Decompile DSDT with iasl Source: https://github.com/xcuri0/rebaruefi/wiki/DSDT-Patching Use the iasl tool to decompile the extracted DSDT.aml file into a human-readable DSDT.dsl format for modification. Ensure you have the correct version of iasl for your OS. ```bash iasl DSDT.aml ``` -------------------------------- ### BAR Size for LGA1151 POST and Corruption Fix Source: https://github.com/xcuri0/rebaruefi/wiki/Common-issues-(and-fixes) If your LGA1151 system won't POST or displays graphical corruption even after patching, use a BAR size of 4GB or larger as a workaround. ```markdown the workaround is just use a BAR size of 4GB or larger. ``` -------------------------------- ### Set BAR Size for RX 5600 XT Sleep Fix Source: https://github.com/xcuri0/rebaruefi/wiki/Common-issues-(and-fixes) If your RX 5600 XT does not resume from sleep on Windows, try setting the BAR size to 1GB or lower. This is a workaround for VBIOS implementation issues. ```markdown Set BAR size to **1GB** or lower. ``` -------------------------------- ### Check 4G Decoding on Linux Source: https://github.com/xcuri0/rebaruefi/wiki/DSDT-Patching Run this command in Linux to check if 4G decoding is enabled by examining the root bus resource. If the last entry ends at 'fffffffff' or above, DSDT modification may not be necessary. ```bash sudo dmesg | grep "root bus resource" ``` -------------------------------- ### Compile Modified DSDT Source: https://github.com/xcuri0/rebaruefi/wiki/DSDT-Patching After modifying the DSDT.dsl file, use the iasl tool again to recompile it into DSDTMod.aml. Any errors reported by iasl must be manually corrected. ```bash iasl DSDTMod.dsl ```