From 3eff604b98caa4d54ca54f41915b970e42c90609 Mon Sep 17 00:00:00 2001 From: lifehackerhansol Date: Mon, 4 Nov 2024 23:21:51 -0800 Subject: [PATCH] bootloader: fix compatibility with thumb DLDI drivers It cannot be assumed that a driver will always be compiled to ARM code. Use bx instead of ldr pc. --- settings/bootloader/source/io_dldi.s | 30 +++++++++++++--------- title/bootloader/source/io_dldi.s | 30 +++++++++++++--------- universal/bootloader_app/source/io_dldi.s | 30 +++++++++++++--------- universal/bootloader_menu/source/io_dldi.s | 30 +++++++++++++--------- 4 files changed, 72 insertions(+), 48 deletions(-) diff --git a/settings/bootloader/source/io_dldi.s b/settings/bootloader/source/io_dldi.s index 82147a9140..bb5a8a2bc3 100644 --- a/settings/bootloader/source/io_dldi.s +++ b/settings/bootloader/source/io_dldi.s @@ -45,20 +45,26 @@ _io_dldi: .word _DLDI_shutdown @ _DLDI_startup: - mov r12, #0x06000000 - ldr pc, [r12, #0x68] + mov r12, #0x06000000 + ldr r12, [r12, #0x68] + bx r12 _DLDI_isInserted: - mov r12, #0x06000000 - ldr pc, [r12, #0x6C] + mov r12, #0x06000000 + ldr r12, [r12, #0x6C] + bx r12 _DLDI_readSectors: - mov r12, #0x06000000 - ldr pc, [r12, #0x70] + mov r12, #0x06000000 + ldr r12, [r12, #0x70] + bx r12 _DLDI_writeSectors: - mov r12, #0x06000000 - ldr pc, [r12, #0x74] + mov r12, #0x06000000 + ldr r12, [r12, #0x74] + bx r12 _DLDI_clearStatus: - mov r12, #0x06000000 - ldr pc, [r12, #0x78] + mov r12, #0x06000000 + ldr r12, [r12, #0x78] + bx r12 _DLDI_shutdown: - mov r12, #0x06000000 - ldr pc, [r12, #0x7C] + mov r12, #0x06000000 + ldr r12, [r12, #0x7C] + bx r12 diff --git a/title/bootloader/source/io_dldi.s b/title/bootloader/source/io_dldi.s index 82147a9140..bb5a8a2bc3 100644 --- a/title/bootloader/source/io_dldi.s +++ b/title/bootloader/source/io_dldi.s @@ -45,20 +45,26 @@ _io_dldi: .word _DLDI_shutdown @ _DLDI_startup: - mov r12, #0x06000000 - ldr pc, [r12, #0x68] + mov r12, #0x06000000 + ldr r12, [r12, #0x68] + bx r12 _DLDI_isInserted: - mov r12, #0x06000000 - ldr pc, [r12, #0x6C] + mov r12, #0x06000000 + ldr r12, [r12, #0x6C] + bx r12 _DLDI_readSectors: - mov r12, #0x06000000 - ldr pc, [r12, #0x70] + mov r12, #0x06000000 + ldr r12, [r12, #0x70] + bx r12 _DLDI_writeSectors: - mov r12, #0x06000000 - ldr pc, [r12, #0x74] + mov r12, #0x06000000 + ldr r12, [r12, #0x74] + bx r12 _DLDI_clearStatus: - mov r12, #0x06000000 - ldr pc, [r12, #0x78] + mov r12, #0x06000000 + ldr r12, [r12, #0x78] + bx r12 _DLDI_shutdown: - mov r12, #0x06000000 - ldr pc, [r12, #0x7C] + mov r12, #0x06000000 + ldr r12, [r12, #0x7C] + bx r12 diff --git a/universal/bootloader_app/source/io_dldi.s b/universal/bootloader_app/source/io_dldi.s index 82147a9140..bb5a8a2bc3 100644 --- a/universal/bootloader_app/source/io_dldi.s +++ b/universal/bootloader_app/source/io_dldi.s @@ -45,20 +45,26 @@ _io_dldi: .word _DLDI_shutdown @ _DLDI_startup: - mov r12, #0x06000000 - ldr pc, [r12, #0x68] + mov r12, #0x06000000 + ldr r12, [r12, #0x68] + bx r12 _DLDI_isInserted: - mov r12, #0x06000000 - ldr pc, [r12, #0x6C] + mov r12, #0x06000000 + ldr r12, [r12, #0x6C] + bx r12 _DLDI_readSectors: - mov r12, #0x06000000 - ldr pc, [r12, #0x70] + mov r12, #0x06000000 + ldr r12, [r12, #0x70] + bx r12 _DLDI_writeSectors: - mov r12, #0x06000000 - ldr pc, [r12, #0x74] + mov r12, #0x06000000 + ldr r12, [r12, #0x74] + bx r12 _DLDI_clearStatus: - mov r12, #0x06000000 - ldr pc, [r12, #0x78] + mov r12, #0x06000000 + ldr r12, [r12, #0x78] + bx r12 _DLDI_shutdown: - mov r12, #0x06000000 - ldr pc, [r12, #0x7C] + mov r12, #0x06000000 + ldr r12, [r12, #0x7C] + bx r12 diff --git a/universal/bootloader_menu/source/io_dldi.s b/universal/bootloader_menu/source/io_dldi.s index 82147a9140..bb5a8a2bc3 100644 --- a/universal/bootloader_menu/source/io_dldi.s +++ b/universal/bootloader_menu/source/io_dldi.s @@ -45,20 +45,26 @@ _io_dldi: .word _DLDI_shutdown @ _DLDI_startup: - mov r12, #0x06000000 - ldr pc, [r12, #0x68] + mov r12, #0x06000000 + ldr r12, [r12, #0x68] + bx r12 _DLDI_isInserted: - mov r12, #0x06000000 - ldr pc, [r12, #0x6C] + mov r12, #0x06000000 + ldr r12, [r12, #0x6C] + bx r12 _DLDI_readSectors: - mov r12, #0x06000000 - ldr pc, [r12, #0x70] + mov r12, #0x06000000 + ldr r12, [r12, #0x70] + bx r12 _DLDI_writeSectors: - mov r12, #0x06000000 - ldr pc, [r12, #0x74] + mov r12, #0x06000000 + ldr r12, [r12, #0x74] + bx r12 _DLDI_clearStatus: - mov r12, #0x06000000 - ldr pc, [r12, #0x78] + mov r12, #0x06000000 + ldr r12, [r12, #0x78] + bx r12 _DLDI_shutdown: - mov r12, #0x06000000 - ldr pc, [r12, #0x7C] + mov r12, #0x06000000 + ldr r12, [r12, #0x7C] + bx r12