From 9476e0ab4544de98bfb64bbe0c82283814619bc8 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 4 Dec 2019 18:48:00 +0200 Subject: [PATCH] kip patches: Allow double defined patchset names This fixes an issue when NOGC patch was defined 2 times when user wants it forced via `kip1patch=nogc` and AutoNOGC was also procced via fuses. --- bootloader/hos/pkg2.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bootloader/hos/pkg2.c b/bootloader/hos/pkg2.c index d37619d..2f34924 100644 --- a/bootloader/hos/pkg2.c +++ b/bootloader/hos/pkg2.c @@ -1023,13 +1023,18 @@ const char* pkg2_patch_kips(link_t *info, char* patchNames) continue; u32 appliedMask = 1u << currEnabIdx; - if (currPatchset->patches == NULL || !strcmp(currPatchset->name, "emummc")) + + if (!strcmp(currPatchset->name, "emummc")) + { + emummc_patch_selected = true; + break; + } + + if (currPatchset->patches == NULL) { gfx_printf("Patch '%s' not necessary for %s KIP1\n", currPatchset->name, (const char*)ki->kip1->name); patchesApplied |= appliedMask; - if (!strcmp(currPatchset->name, "emummc")) - emummc_patch_selected = true; break; } @@ -1051,9 +1056,11 @@ const char* pkg2_patch_kips(link_t *info, char* patchNames) } u32 currOffset = GET_KIP_PATCH_OFFSET(currPatch->offset); - if (memcmp(&kipSectData[currOffset], currPatch->srcData, currPatch->length) != 0) + // If source is does not match and is not already patched, throw an error. + if ((memcmp(&kipSectData[currOffset], currPatch->srcData, currPatch->length) != 0) && + (memcmp(&kipSectData[currOffset], currPatch->dstData, currPatch->length) != 0)) { - gfx_printf("%kDATA MISMATCH FOR PATCH AT OFFSET 0x%x!!!%k\n", 0xFFFF0000, currOffset, 0xFFCCCCCC); + gfx_printf("%kPatch data mismatch at 0x%x!%k\n", 0xFFFF0000, currOffset, 0xFFCCCCCC); return currPatchset->name; // MUST stop here as kip is likely corrupt. } else