Skip to content

Instantly share code, notes, and snippets.

@unknownbrackets
Last active December 10, 2015 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unknownbrackets/4462368 to your computer and use it in GitHub Desktop.
Save unknownbrackets/4462368 to your computer and use it in GitHub Desktop.
GE signal test jumps / calls
unsigned int __attribute__((aligned(16))) dlist1[] = {
0x00000000, // 0x00 NOP, geman crashes if signal is first instruction
0x0E010000, // 0x01 SIGNAL + WAIT
0x0C000000, // 0x02 END
0x00000000, // 0x03 NOP
0x00000000, // 0x04 NOP
0x00000000, // 0x05 NOP
0x00000000, // 0x06 NOP
0x00000000, // 0x07 NOP
0x0E017777, // 0x08 SIGNAL + WAIT
0x0C000000, // 0x09 END
0x0F000000, // 0x0A FINISH
0x0C000000, // 0x0B END
0x0E018888, // 0x0C SIGNAL + WAIT
0x0C000000, // 0x0D END
0x0F000000, // 0x0E FINISH
0x0C000000, // 0x0F END
0x00000000, // 0x10 NOP
0x0E019999, // 0x11 SIGNAL + WAIT
0x0C000000, // 0x12 END
0x00000000, // 0x13 NOP
0x00000000, // 0x14 NOP
0x00000000, // 0x15 NOP
0x00000000, // 0x16 NOP
0x00000000, // 0x17 NOP
0x00000000, // 0x18 NOP
0x00000000, // 0x19 NOP
0x00000000, // 0x1A NOP
0x00000000, // 0x1B NOP
0x00000000, // 0x1C NOP
0x00000000, // 0x1D NOP
0x0F000000, // 0x1E FINISH
0x0C000000, // 0x1F END
0x00000000, // 0x20 NOP
0x0E01AAAA, // 0x21 SIGNAL + WAIT
0x0C000000, // 0x22 END
0x00000000, // 0x23 NOP
0x0E120000, // 0x24 SIGNAL RET
0x0C000000, // 0x25 END
0x00000000, // 0x26 NOP
0x00000000, // 0x27 NOP
0x00000000, // 0x28 NOP
0x00000000, // 0x29 NOP
0x00000000, // 0x2A NOP
0x00000000, // 0x2B NOP
0x00000000, // 0x2C NOP
0x00000000, // 0x2D NOP
0x0F000000, // 0x2E FINISH
0x0C000000, // 0x2F END
};
enum
{
GE_SIG_SUSPEND = 0x01,
GE_SIG_CONTINUE = 0x02,
GE_SIG_PAUSE = 0x03,
GE_SIG_SYNC = 0x08,
GE_SIG_JUMP = 0x10,
GE_SIG_CALL = 0x11,
GE_SIG_JUMP_REL = 0x13,
GE_SIG_JUMP_ORIGIN = 0x15,
GE_SIG_BP1 = 0xF0,
GE_SIG_BP2 = 0xFF,
};
#define MAKE_GE_JUMP(address) (0x08000000 | ((address) & 0xFFFFFF))
#define MAKE_GE_CALL(address) (0x0A000000 | ((address) & 0xFFFFFF))
#define MAKE_GE_RET(value) (0x0B000000 | ((value) & 0xFFFFFF))
#define MAKE_GE_END(type, value) (0x0C000000 | ((type & 0xFF) << 16) | ((value) & 0xFFFF))
#define MAKE_GE_SIGNAL(type, value) (0x0E000000 | ((type & 0xFF) << 16) | ((value) & 0xFFFF))
#define MAKE_GE_FINISH(type, value) (0x0F000000 | ((type & 0xFF) << 16) | ((value) & 0xFFFF))
#define MAKE_GE_BASE(address) (0x10000000 | (((address) & 0xFF000000) >> 8))
#define MAKE_GE_OFFSET(address) (0x13000000 | ((address) & 0xFFFFFF))
#define MAKE_GE_ORIGIN(value) (0x14000000 | ((value) & 0xFFFFFF))
inline void dlist1SignalOffset(int pos, int type, int endtype, unsigned int address) {
dlist1[pos + 0x00] = MAKE_GE_SIGNAL(type, address >> 16);
dlist1[pos + 0x01] = MAKE_GE_END(endtype, address);
}
inline void dlist1SignalRelative(int pos, int type, int endtype, unsigned int address) {
dlist1SignalOffset(pos, type, endtype, address * sizeof(unsigned int));
}
inline void dlist1SignalAddress(int pos, int type, int endtype, unsigned int *address) {
dlist1SignalOffset(pos, type, endtype, (unsigned int) address);
}
printf("\nJump absolute (0x%02x):\n", GE_SIG_JUMP);
dlist1SignalAddress(0x01, GE_SIG_JUMP, 0, dlist1 + 0x10);
testGeCallbacks(TEST_USE_DRAWSYNC);
printf("\nJump relative (0x%02x):\n", GE_SIG_JUMP_REL);
dlist1SignalRelative(0x01, GE_SIG_JUMP_REL, 0, 0x10 - 0x01);
testGeCallbacks(TEST_USE_DRAWSYNC);
printf("\nJump relative to origin (0x%02x):\n", GE_SIG_JUMP_ORIGIN);
// Base seems not to matter, just proving that here.
dlist1[0x01] = MAKE_GE_BASE(0);
dlist1[0x02] = MAKE_GE_ORIGIN(0);
dlist1SignalRelative(0x03, GE_SIG_JUMP_ORIGIN, 0, 0x10 - 0x02);
testGeCallbacks(TEST_USE_DRAWSYNC);
dlist1[0x03] = 0;
dlist1[0x04] = 0;
// Crashes?
//printf("\nCall absolute (0x%02x):\n", GE_SIG_CALL);
//dlist1SignalAddress(0x01, GE_SIG_CALL, 0, dlist1 + 0x20);
//testGeCallbacks(TEST_USE_BREAK | TEST_STALL_LATE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment