move GOAL stack to GOAL memory (#114)

* move GOAL code stack to GOAL memory

* fix win arg reg and check rsp in debugger

* fix windows maybe and fix some incorrect logging formatters
This commit is contained in:
water111
2020-11-06 21:42:05 -05:00
committed by GitHub
parent c09541fa98
commit 71a894c393
10 changed files with 137 additions and 19 deletions
+8 -11
View File
@@ -136,6 +136,8 @@ s32 goal_main(int argc, const char* const* argv) {
* Main loop to dispatch the GOAL kernel.
*/
void KernelCheckAndDispatch() {
u64 goal_stack = u64(g_ee_main_mem) + EE_MAIN_MEM_SIZE - 8;
while (!MasterExit) {
// try to get a message from the listener, and process it if needed
Ptr<char> new_message = WaitForMessageAndAck();
@@ -148,20 +150,15 @@ void KernelCheckAndDispatch() {
// dispatch the kernel
//(**kernel_dispatcher)();
// todo remove. this is added while KERNEL.CGO is broken.
if (MasterUseKernel) {
call_goal(Ptr<Function>(kernel_dispatcher->value), 0, 0, 0, s7.offset, g_ee_main_mem);
// use the GOAL kernel.
call_goal_on_stack(Ptr<Function>(kernel_dispatcher->value), goal_stack, s7.offset,
g_ee_main_mem);
} else {
// use a hack to just run the listener function if there's no GOAL kernel.
if (ListenerFunction->value != s7.offset) {
// fprintf(stderr, "Running Listener Function:\n");
// auto cptr = Ptr<u8>(ListenerFunction->value).c();
// for (int i = 0; i < 40; i++) {
// fprintf(stderr, "%x ", cptr[i]);
// }
// fprintf(stderr, "\n");
auto result =
call_goal(Ptr<Function>(ListenerFunction->value), 0, 0, 0, s7.offset, g_ee_main_mem);
// fprintf(stderr, "result of listener function: %lld\n", result);
auto result = call_goal_on_stack(Ptr<Function>(ListenerFunction->value), goal_stack,
s7.offset, g_ee_main_mem);
#ifdef __linux__
cprintf("%ld\n", result);
#else