From 43e654dc1d0ec30eec2f84850c7fa11073215c71 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Fri, 6 Sep 2024 14:08:42 +0200 Subject: [PATCH 1/8] Fix broken struct initialization for the debug command Comma in the wrong place was assigning a char* to the func field. --- patch/src/ppc_mon/src/commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patch/src/ppc_mon/src/commands.c b/patch/src/ppc_mon/src/commands.c index 3f58193..6d056a6 100644 --- a/patch/src/ppc_mon/src/commands.c +++ b/patch/src/ppc_mon/src/commands.c @@ -1398,7 +1398,7 @@ pm_cmd_t pm_core_cmds[] = { }, { .name = "debug", - .help = "debug
", + .help = "debug
\n" "debug ", .func = &command_debug } From 8ab92674a52c5d846c7d7a4e9587c8836a0749e2 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Fri, 6 Sep 2024 14:25:39 +0200 Subject: [PATCH 2/8] Fix function signature for command_debug --- patch/src/ppc_mon/src/commands.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/patch/src/ppc_mon/src/commands.c b/patch/src/ppc_mon/src/commands.c index 6d056a6..39b4bcb 100644 --- a/patch/src/ppc_mon/src/commands.c +++ b/patch/src/ppc_mon/src/commands.c @@ -1220,7 +1220,7 @@ static int command_ppc() * arg2: * arg3:
*/ -static void command_debug() +static int command_debug() { char *action = pm_parser_get_argv_ptr(1); char *option = pm_parser_get_argv_ptr(2); @@ -1286,6 +1286,8 @@ static void command_debug() default: break; } + + return 0; } pm_cmd_t pm_core_cmds[] = { From 629e6acfe432c92e2fe3baefefdf9f79532eb315 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Fri, 6 Sep 2024 14:10:17 +0200 Subject: [PATCH 3/8] Fix ptr conversion error from gcc14 --- patch/src/patch.c | 2 +- patch/src/ppc_mon/src/commands.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/patch/src/patch.c b/patch/src/patch.c index 4678af9..3126f46 100644 --- a/patch/src/patch.c +++ b/patch/src/patch.c @@ -154,7 +154,7 @@ int __attribute__((section(".text_entry"))) _start(void) printf("Patch: Initializing heap between: 0x%x - 0x%x\n", ppc_patch_end, ppc_heap_end); // init heap - umm_init_heap(ppc_patch_end, (ppc_heap_end - ppc_patch_end)); + umm_init_heap((void *)ppc_patch_end, (ppc_heap_end - ppc_patch_end)); printf("Patch: Heap initialized, size: 0x%x (%i bytes)\n", ppc_heap_size, ppc_heap_size); diff --git a/patch/src/ppc_mon/src/commands.c b/patch/src/ppc_mon/src/commands.c index 39b4bcb..4a44e57 100644 --- a/patch/src/ppc_mon/src/commands.c +++ b/patch/src/ppc_mon/src/commands.c @@ -811,7 +811,7 @@ static int command_gte() static int command_xparam() { //TEMP: - void *xparam_str_ptr = 0xbe0a30; + void *xparam_str_ptr = (void *)0xbe0a30; char *rw = pm_parser_get_argv_ptr(1); uint32_t num = pm_parser_get_argv_dec(2); From 64d67b50f46239ed64385e43324cf3577bee0d7b Mon Sep 17 00:00:00 2001 From: Ziemas Date: Fri, 6 Sep 2024 14:25:01 +0200 Subject: [PATCH 4/8] Fix no return warnings --- patch/src/ppc_mon/src/commands.c | 38 ++++++++++++++------------------ 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/patch/src/ppc_mon/src/commands.c b/patch/src/ppc_mon/src/commands.c index 4a44e57..a547750 100644 --- a/patch/src/ppc_mon/src/commands.c +++ b/patch/src/ppc_mon/src/commands.c @@ -106,12 +106,10 @@ static int command_mem() counter++; } while (counter < len); - - } else { - printf("Invalid action: %c\n", *rw); - return -1; } + printf("Invalid action: %c\n", *rw); + return -1; } /* Reg commands: @@ -255,13 +253,10 @@ static int command_reg() counter++; } while (counter < len); + } - } else { - printf("Invalid action: %c\n", *rw); - return -1; - } - - + printf("Invalid action: %c\n", *rw); + return -1; } /* Dump commands: @@ -841,10 +836,10 @@ static int command_xparam() } else { printf("XPARAM %i does not exist\n", num); } - } else { - printf("Invalid action: %c\n", *rw); - return -1; - } + } + + printf("Invalid action: %c\n", *rw); + return -1; } /* Emulator commands: @@ -1148,10 +1143,10 @@ static int command_settings() default: break; } - } else { - printf("Invalid action %c\n", *drw); - return -1; - } + } + + printf("Invalid action %c\n", *drw); + return -1; } /* TODO: PPC core commands: @@ -1205,11 +1200,10 @@ static int command_ppc() } else if (*drw == 'r') { } else if (*drw == 'w') { + } - } else { - printf("Invalid action: %c\n", *drw); - return -1; - } + printf("Invalid action: %c\n", *drw); + return -1; } /* Debug commands: From 94e6ff4365ad8b776db1264f2bb14edf4b4af31c Mon Sep 17 00:00:00 2001 From: Ziemas Date: Fri, 6 Sep 2024 14:28:32 +0200 Subject: [PATCH 5/8] command_gte: Read value arg with _get_argv_dec --- patch/src/ppc_mon/src/commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patch/src/ppc_mon/src/commands.c b/patch/src/ppc_mon/src/commands.c index a547750..05cedce 100644 --- a/patch/src/ppc_mon/src/commands.c +++ b/patch/src/ppc_mon/src/commands.c @@ -658,7 +658,7 @@ static int command_gte() char *rw = pm_parser_get_argv_ptr(1); char *reg = pm_parser_get_argv_ptr(2); - uint32_t value = pm_parser_get_argv_ptr(3); + uint32_t value = pm_parser_get_argv_dec(3); uint32_t reg_num = 0; uint32_t readback = 0; From 7449ab4b77e5c7da944ff0e4929f48b5a4b214c2 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Fri, 6 Sep 2024 14:38:09 +0200 Subject: [PATCH 6/8] Don't take the address of arrays --- patch/src/ppc_mon/src/ppc_mon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/patch/src/ppc_mon/src/ppc_mon.c b/patch/src/ppc_mon/src/ppc_mon.c index de14dad..5b6aa34 100644 --- a/patch/src/ppc_mon/src/ppc_mon.c +++ b/patch/src/ppc_mon/src/ppc_mon.c @@ -84,7 +84,7 @@ static int ascii_hex_to_int(char *str) int pm_parser_get_argc() { int argc = 1; - char *str = &rx_buf; + char *str = rx_buf; while (*str != '\0') { //Ignore extra whitespace @@ -102,7 +102,7 @@ int pm_parser_get_argv_len(int n) uint32_t arg = 0; uint32_t len = 0; - char *str = &rx_buf; + char *str = rx_buf; while (*str != '\0') { @@ -126,7 +126,7 @@ char *pm_parser_get_argv_ptr(int n) uint32_t arg = 0; uint32_t pos = 0; - char *str = &rx_buf; + char *str = rx_buf; while (*str != '\0') { @@ -150,7 +150,7 @@ int pm_parser_get_argv_dec(int n) uint32_t argc = 0; uint32_t value = 0; - char *str = &rx_buf; + char *str = rx_buf; while (*str != '\0') { @@ -478,7 +478,7 @@ void pm_start() debug_uart_init(pm_settings.baud); //Register PPC-MON core commands, mem, reg, mips, etc - pm_register_cmds(&pm_core_cmds, 12); + pm_register_cmds(pm_core_cmds, 12); //Preserve PPC-MON RX event through mode reset (PS2 <-> PS1) debug_run_on_reset(&pm_rx); From 2fa1a5a08d90f967cf00c0059a5550ba7c01a7e2 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Fri, 6 Sep 2024 14:39:04 +0200 Subject: [PATCH 7/8] Add parenthesis for clarity --- patch/src/ppc_mon/src/ppc_mon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patch/src/ppc_mon/src/ppc_mon.c b/patch/src/ppc_mon/src/ppc_mon.c index 5b6aa34..519fefa 100644 --- a/patch/src/ppc_mon/src/ppc_mon.c +++ b/patch/src/ppc_mon/src/ppc_mon.c @@ -360,7 +360,7 @@ void pm_rx() add_event(pm_settings.event_cycles, &pm_rx, 0); //Poll UART status register - while (*(uint8_t*)(0x01000205) & 1 != 0) { + while ((*(uint8_t*)(0x01000205) & 1) != 0) { //Read char from UART FIFO c = *(char*)(0x01000200); From b0af2d8ec64ef77f88f418a9e60317552682d19d Mon Sep 17 00:00:00 2001 From: Ziemas Date: Fri, 6 Sep 2024 14:46:56 +0200 Subject: [PATCH 8/8] Fix ee patcher includes --- patch_loader_ee/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/patch_loader_ee/main.c b/patch_loader_ee/main.c index 4b909e0..f2b95af 100644 --- a/patch_loader_ee/main.c +++ b/patch_loader_ee/main.c @@ -1,10 +1,14 @@ #include #include #include +#include #include #include #include #include +#include +#include +#include extern unsigned char ppcpatchman_irx[]; extern unsigned int size_ppcpatchman_irx;