Skip to content

Commit

Permalink
Fix my ghetto code
Browse files Browse the repository at this point in the history
  • Loading branch information
Siguza committed Apr 27, 2021
1 parent 449ecc7 commit 0cb6126
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/drivers/recfg/recfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@ int recfg_check(void *mem, size_t size, size_t *offp, const bool warn)
recfg_read64_t *r64 = (recfg_read64_t*)read;
VOLATILE uint32_t *tmp = (VOLATILE uint32_t*)(r64 + 1);
if(
*tmp == 0xdeadbeef
#ifdef RECFG_VOLATILE
// In real memory, 64-bit stuff has to be 64-bit aligned.
((uintptr_t)tmp & 0x4) != 0
#else
// When extracted from iBoot though, it only has to be 32-bit aligned.
&& ((uintptr_t)tmp & 0x4) != 0
*tmp == 0xdeadbeef
#endif
)
{
Expand Down Expand Up @@ -138,11 +139,12 @@ int recfg_check(void *mem, size_t size, size_t *offp, const bool warn)
REQ(end - (char*)cmd >= sizeof(recfg_write64_t) + alcnt * sizeof(uint8_t) + cnt * sizeof(uint64_t));
VOLATILE uint32_t *tmp = (VOLATILE uint32_t*)((VOLATILE uint8_t*)(w64 + 1) + alcnt);
if(
*tmp == 0xdeadbeef
#ifdef RECFG_VOLATILE
// In real memory, 64-bit stuff has to be 64-bit aligned.
((uintptr_t)tmp & 0x4) != 0
#else
// When extracted from iBoot though, it only has to be 32-bit aligned.
&& ((uintptr_t)tmp & 0x4) != 0
*tmp == 0xdeadbeef
#endif
)
{
Expand Down Expand Up @@ -266,11 +268,12 @@ int recfg_walk(void *mem, size_t size, const recfg_cb_t *cb, void *a)
recfg_read64_t *r64 = (recfg_read64_t*)read;
VOLATILE uint32_t *tmp = (VOLATILE uint32_t*)(r64 + 1);
if(
*tmp == 0xdeadbeef
#ifdef RECFG_VOLATILE
// In real memory, 64-bit stuff has to be 64-bit aligned.
// When extracted from iBoot though, it only has to be 32-bit aligned.
&& ((uintptr_t)tmp & 0x4) != 0
// In real memory, 64-bit stuff has to be 64-bit aligned.
((uintptr_t)tmp & 0x4) != 0
#else
// When extracted from iBoot though, it only has to be 32-bit aligned.
*tmp == 0xdeadbeef
#endif
)
{
Expand Down Expand Up @@ -353,11 +356,12 @@ int recfg_walk(void *mem, size_t size, const recfg_cb_t *cb, void *a)
alcnt = (cnt + 3) & ~3;
VOLATILE uint32_t *tmp = (VOLATILE uint32_t*)((VOLATILE uint8_t*)(w64 + 1) + alcnt);
if(
*tmp == 0xdeadbeef
#ifdef RECFG_VOLATILE
// In real memory, 64-bit stuff has to be 64-bit aligned.
((uintptr_t)tmp & 0x4) != 0
#else
// When extracted from iBoot though, it only has to be 32-bit aligned.
&& ((uintptr_t)tmp & 0x4) != 0
*tmp == 0xdeadbeef
#endif
)
{
Expand Down

0 comments on commit 0cb6126

Please sign in to comment.