Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Size optimizations #23

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ jobs:
with:
fetch-depth: 0

- name: Fetch Qoob prebuilt
run: curl -Lo ipl.rom https://github.com/redolution/iplboot/releases/download/r5.2/iplboot.gcb
- name: Fetch Qoob prebuilts
run: |
curl -Lo ipl.rom https://github.com/redolution/iplboot/releases/download/r5.2/iplboot.gcb
curl -Lo qoob_sx_13c_upgrade.elf https://github.com/redolution/iplboot/releases/download/r5.2/qoob_sx_iplboot_upgrade.elf

- name: Checkout libogc2
uses: actions/checkout@v2
Expand All @@ -24,7 +26,9 @@ jobs:
path: libogc2

- name: Build libogc2
run: make install
run: |
patch -Np1 -i ../ogc.patch
make install
working-directory: libogc2

- name: Build iplboot artifacts
Expand All @@ -34,4 +38,6 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: iplboot
path: build/iplboot*
path: |
build/iplboot*
build/qoob_sx_iplboot_upgrade.*
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ INCLUDES :=
# options for code generation
#---------------------------------------------------------------------------------

CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE)
CFLAGS = -g -Os -flto -Wall $(MACHDEP) $(INCLUDE)
CXXFLAGS = $(CFLAGS)

LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -T$(PWD)/ipl.ld
Expand Down Expand Up @@ -119,15 +119,15 @@ endif
export BUILD_MAKE := @mkdir -p $(BUILD) && $(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

#---------------------------------------------------------------------------------
all: dol gci qoobpro viper dol_compressed gci_compressed
all: dol gci qoobpro qoobsx viper dol_compressed gci_compressed
dol:
$(BUILD_MAKE) $(OUTPUT).dol
gci:
$(BUILD_MAKE) $(OUTPUT).gci
qoobpro:
$(BUILD_MAKE) $(OUTPUT).gcb
qoobsx:
$(BUILD_MAKE) $(OUTPUT_SX).elf
$(BUILD_MAKE) $(OUTPUT_SX).elf $(OUTPUT_SX).dol
viper:
$(BUILD_MAKE) $(OUTPUT).vgc
dol_compressed:
Expand Down
Binary file modified buildtools/dolxz
Binary file not shown.
113 changes: 113 additions & 0 deletions ogc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
From d727901a9f7100c31557512eb66aeda7932cba6e Mon Sep 17 00:00:00 2001
From: novenary <[email protected]>
Date: Mon, 23 Oct 2023 15:37:08 +0300
Subject: [PATCH 1/3] Remove lwp

---
Makefile | 5 ++---
libogc/system.c | 1 +
libogc/video.c | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 56ade00..2d8ee38 100644
--- a/Makefile
+++ b/Makefile
@@ -132,9 +132,8 @@ LWIPOBJ := network.o netio.o gcif.o \

#---------------------------------------------------------------------------------
OGCOBJ := \
- console.o lwp_priority.o lwp_queue.o lwp_threadq.o lwp_threads.o lwp_sema.o \
- lwp_messages.o lwp.o lwp_handler.o lwp_stack.o lwp_mutex.o \
- lwp_watchdog.o lwp_wkspace.o lwp_objmgr.o lwp_heap.o sys_state.o \
+ console.o \
+ sys_state.o \
exception_handler.o exception.o irq.o irq_handler.o semaphore.o \
video_asm.o video.o pad.o dvd.o exi.o mutex.o arqueue.o arqmgr.o \
cache_asm.o system.o system_asm.o cond.o \
diff --git a/libogc/system.c b/libogc/system.c
index bf07905..2f2bbd5 100644
--- a/libogc/system.c
+++ b/libogc/system.c
@@ -1116,6 +1116,7 @@ void SYS_Init(void)
__libc_init(1);
__lwp_thread_startmultitasking();
_CPU_ISR_Restore(level);
+ main();
}

// This function gets called inside the main thread, prior to the application's main() function
diff --git a/libogc/video.c b/libogc/video.c
index 62782a5..b22510e 100644
--- a/libogc/video.c
+++ b/libogc/video.c
@@ -2741,12 +2741,12 @@ void VIDEO_WaitVSync(void)
u32 level;
u32 retcnt;

- _CPU_ISR_Disable(level);
+ //_CPU_ISR_Disable(level);
retcnt = retraceCount;
do {
LWP_ThreadSleep(video_queue);
} while(retraceCount==retcnt);
- _CPU_ISR_Restore(level);
+ //_CPU_ISR_Restore(level);
}

void VIDEO_SetFramebuffer(void *fb)
--
2.42.0


From a19f2a1892f152c1377b5268549c4a20fb2309db Mon Sep 17 00:00:00 2001
From: novenary <[email protected]>
Date: Mon, 23 Oct 2023 15:37:36 +0300
Subject: [PATCH 2/3] Optimize for size

---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 2d8ee38..f52abcd 100644
--- a/Makefile
+++ b/Makefile
@@ -97,7 +97,7 @@ endif
INCLUDES += -I$(PORTLIBS_PATH)/ppc/include


-CFLAGS := -DLIBOGC_INTERNAL -g -O2 -fno-strict-aliasing -Wall -Wno-address-of-packed-member $(MACHDEP) $(INCLUDES)
+CFLAGS := -DLIBOGC_INTERNAL -g -Os -fno-strict-aliasing -Wall -Wno-address-of-packed-member $(MACHDEP) $(INCLUDES)
ASFLAGS := $(MACHDEP) -mregnames -D_LANGUAGE_ASSEMBLY $(INCLUDES)

#---------------------------------------------------------------------------------
--
2.42.0


From 7343d5bbb00c10c3718ed172f86424cdbc1b1b7b Mon Sep 17 00:00:00 2001
From: novenary <[email protected]>
Date: Mon, 23 Oct 2023 15:37:54 +0300
Subject: [PATCH 3/3] Don't call GX_AbortFrame() from exception handler

Saves a kilobyte or so
---
libogc/exception.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/libogc/exception.c b/libogc/exception.c
index 820b200..1800b98 100644
--- a/libogc/exception.c
+++ b/libogc/exception.c
@@ -237,7 +237,6 @@ static void waitForReload(void)
//just implement core for unrecoverable exceptions.
void c_default_exceptionhandler(frame_context *pCtx)
{
- GX_AbortFrame();
VIDEO_SetFramebuffer(exception_xfb);
__console_init(exception_xfb,20,20,640,574,1280);
CON_EnableGecko(1, true);
--
2.42.0

81 changes: 81 additions & 0 deletions source/lwp_stub.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include <gctypes.h>

vu32 _thread_dispatch_disable_level;
vu32 _context_switch_want;
void **__lwp_thr_libc_reent = NULL;
void *_thr_executing = NULL;

typedef struct _lwpnode {
struct _lwpnode *next;
struct _lwpnode *prev;
} lwp_node;

typedef struct _lwpqueue {
lwp_node *first;
lwp_node *perm_null;
lwp_node *last;
} lwp_queue;
lwp_queue _wd_ticks_queue;

void __lwp_threadqueue_enqueuepriority() {}
void __lwp_threadqueue_dequeuepriority() {}
void __lwp_heap_free() {}
void __lwp_objmgr_initinfo() {}
void __lwp_wd_insert() {}
void __lwp_threadqueue_extractpriority() {}
void __lwp_thread_close() {}
void __lwp_mutex_surrender() {}
void __lwp_threadqueue_enqueue() {}
void __lwp_heap_allocate() {}
void __lwp_thread_changepriority() {}
void __lwp_threadqueue_dequeuefifo() {}
void __lwp_thread_init() {}
void __lwp_threadqueue_enqueuefifo() {}
void __lwp_wd_tickle() {}
void __lwp_thread_setstate() {}
void __lwp_thread_clearstate() {}
void __lwp_mutex_seize_irq_blocking() {}
void __lwp_threadqueue_extractfifo() {}
void __lwp_wd_remove() {}
void __lwp_thread_ready() {}
void __lwp_heap_init() {}
void __lwp_wkspace_init() {}
void __lwp_thread_settransient() {}
void __lwp_mutex_initialize() {}
void __lwp_thread_loadenv() {}
void __lwp_objmgr_get() {}
void __lwp_threadqueue_init() {}
void __lwp_objmgr_allocate() {}
void __lwp_thread_setpriority() {}
void __lwp_thread_stopmultitasking() {}
void __lwp_objmgr_getisrdisable() {}
void __lwp_objmgr_free() {}
void __lwp_stack_allocate() {}
void __lwp_queue_get() {}
void __lwp_thread_start() {}
void __lwp_queue_append() {}
void __lwp_thread_delayended() {}
void __lwp_queue_initialize() {}
void __lwp_threadqueue_flush() {}
void __lwp_threadqueue_extractproxy() {}
void __lwp_thread_exit() {}
void __lwp_watchdog_init() {}
void __lwp_threadqueue_dequeue() {}
void __lwp_objmgr_getnoprotection() {}
void __lwp_threadqueue_extract() {}
void __lwp_stack_free() {}
void __lwp_priority_init() {}
void __lwp_isr_in_progress() {}
void __lwp_mutex_flush() {}

void __thread_dispatch() {}
void __thread_dispatch_fp() {}
void __lwp_sysinit() {}
void __lwp_thread_setlibcreent() {}
void __lwp_thread_closeall() {}
void __lwp_thread_coreinit() {}
void __lwp_thread_startmultitasking() {}

void LWP_ThreadBroadcast() {}
void LWP_InitQueue() {}
void LWP_ThreadSleep() {}