Skip to content

Commit

Permalink
Use PAGE_SIZE and PAGE_SHIFT macros for PowerPC
Browse files Browse the repository at this point in the history
  • Loading branch information
hmelder committed Jan 21, 2024
1 parent ac06f53 commit c3cc4e9
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions block_trampolines.S
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "common.S"
#include "asmconstants.h"

#
# This file defines some trampolines for calling blocks. A block function
Expand Down Expand Up @@ -112,17 +113,23 @@
#endif

.macro trampoline arg0, arg1
mfctr %r12 # The block trampoline is always called
# via a function pointer. We can thus
# assume that ctr contains the trampline
# entry point address from the previous
# branch to this trampoline (bctrl).
addi %r12, %r12, -0x1000 # Substract 0x1000 (page size) from entry point
mfctr %r12 # The block trampoline is always called
# via a function pointer. We can thus
# assume that ctr contains the trampline
# entry point address from the previous
# branch to this trampoline (bctrl).

#if PAGE_SHIFT < 16
addi %r12, %r12, -PAGE_SIZE # Substract page size from entry point
#else
addis %r12, %r12, (-0x1 << (PAGE_SHIFT - 16))
#endif

mr \arg1, \arg0
LOAD \arg0, 0(%r12)
LOAD %r12, OFFSET(%r12)
mtctr %r12 # Move block function pointer into ctr
bctr # Branch to block function
mtctr %r12 # Move block function pointer into ctr
bctr # Branch to block function
.endm

#define ARG0 %r3
Expand Down

0 comments on commit c3cc4e9

Please sign in to comment.