From a6e365fcc2eb92d22889e807ccb1823a3196e438 Mon Sep 17 00:00:00 2001 From: Elliot Nunn Date: Tue, 21 Nov 2017 12:25:50 +0800 Subject: [PATCH] Dump C code into Wedge log --- EasyBuild | 2 +- Linker.c | 27 ++++++++++++++++++--------- WedgeStub.s | 2 -- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/EasyBuild b/EasyBuild index de12792..e4a233c 100644 --- a/EasyBuild +++ b/EasyBuild @@ -21,6 +21,6 @@ Loop Break End - {IM}Linker "{1}" {IM}RomWedge.x + {IM}Linker "{1}" {IM}RomWedge.x Wedge.c Shift End diff --git a/Linker.c b/Linker.c index 3f8ed80..b75704f 100644 --- a/Linker.c +++ b/Linker.c @@ -53,16 +53,16 @@ int main(int argc, char *argv[]) { FILE *fp; - char *blob[2]; - long size[2]; + char *blob[3]; + long size[3]; int i; - if(argc != 3) { - fprintf(stderr, "Usage: %s ROM WEDGE\n", argv[0]); + if(argc != 4) { + fprintf(stderr, "Usage: %s ROM WEDGE C\n", argv[0]); return 1; } - for(i=0; i<2; i++) /* Two or more, use a for. */ + for(i=0; i<3; i++) /* Two or more, use a for. */ { char *fname = argv[i+1]; @@ -80,26 +80,35 @@ int main(int argc, char *argv[]) return 1; } - if(size[1] > 0x20000) { + if(size[1] > 0x8000) { fprintf(stderr, "%s: WEDGE is 0x%X bytes, to large\n", argv[0], size[1]); return 1; } + if(size[2] > 0x10000) { + fprintf(stderr, "%s: C is 0x%X bytes, to large\n", argv[0], size[2]); + return 1; + } + if(blob[0][0x340000] == 0) { /* NanoKernel needs to be moved */ printf("Moving NanoKernel from 310000 to 340000.\n"); memcpy(blob[0] + 0x340000, blob[0] + 0x310000, 0x20000); printf("Erasing original NanoKernel location.\n"); - memset(blob[0] + 0x310000, 0, 0x20000); + memset(blob[0] + 0x310000, 0, 0x30000); } else { printf("NanoKernel already moved to 340000. Erasing old Wedge.\n"); - memset(blob[0] + 0x310000, 0, 0x20000); + memset(blob[0] + 0x310000, 0, 0x30000); } - printf("Copying Wedge (0x%X bytes).\n", size[1]); + printf("Copying Wedge code to 310000 (0x%X bytes).\n", size[1]); memcpy(blob[0] + 0x310000, blob[1], size[1]); + printf("Copying C source into log at 320000 (0x%X bytes).\n", size[2]); + memcpy(blob[0] + 0x320000, blob[2], size[2]); + *(long *)(blob[0] + 0x320000 - 4) = size[2]; + printf("Writing out.\n"); fp = fopen(argv[1], "wb"); diff --git a/WedgeStub.s b/WedgeStub.s index 6d5711d..56aff7f 100644 --- a/WedgeStub.s +++ b/WedgeStub.s @@ -48,8 +48,6 @@ Magic equ 'Wdg_' lisori r20, PA_ROM + Middle lisori r0, 'WgLg' stw r0, -8(r20) - li r0, 0 - stw r0, -4(r20) ; Search for the string table (tested, works)