Skip to content

Commit 6df717b

Browse files
committed
[fw-isoldr] Move loader address to Makefile and cleanup for startup.
Also impove params getting.
1 parent 917bbb1 commit 6df717b

File tree

4 files changed

+29
-33
lines changed

4 files changed

+29
-33
lines changed

firmware/isoldr/loader/Makefile.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# (c) 2009-2025 SWAT
55
#
66

7-
TARGET = 0x8ce00000
7+
TARGET = 0x8ce00400
88
BUILD = build
99
VERSION = "0.8.4"
1010
INSTALL_PATH = ../../../build/firmware/isoldr
@@ -38,14 +38,14 @@ TARGETOBJCOPY = $(TARGETPREFIX)-objcopy
3838
TARGETLD = $(TARGETPREFIX)-ld
3939
TARGETAS = $(TARGETPREFIX)-as
4040
TARGETSIZE = $(TARGETPREFIX)-size
41-
TARGETLDFLAGS = -Wl,--gc-sections -Wl,--no-warn-rwx-segments -Tshlelf.xc \
41+
TARGETLDFLAGS = -Wl,--gc-sections -Wl,--no-warn-rwx-segments \
42+
-Tshlelf.xc -Ttext=$(TARGET) \
4243
-nostartfiles -nostdlib -nodefaultlibs
4344
TARGETCFLAGS = -ml -m4-single-only -ffunction-sections -fdata-sections -ffreestanding \
4445
-fno-builtin -fno-strict-aliasing -fomit-frame-pointer \
4546
-freorder-blocks-algorithm=simple -flto=auto \
4647
-Wall -std=c17 -Wextra -Werror \
4748
-D__DREAMCAST__ \
48-
-DLOADER_ADDR=$(TARGET) \
4949
-DVERSION=\"$(VERSION)\"
5050

5151
LIBS = -lgcc

firmware/isoldr/loader/main.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
#include <maple.h>
1212

1313
isoldr_info_t *IsoInfo;
14-
uint32 loader_addr = 0;
15-
uint32 loader_end = 0;
14+
uint32 loader_end;
1615

1716
int main(int argc, char *argv[]) {
1817

@@ -23,9 +22,8 @@ int main(int argc, char *argv[]) {
2322
bfont_saved_addr = 0xa0001000;
2423
}
2524

26-
IsoInfo = (isoldr_info_t *)LOADER_ADDR;
27-
loader_addr = (uint32)IsoInfo;
2825
loader_end = loader_addr + loader_size + ISOLDR_PARAMS_SIZE + 32;
26+
IsoInfo = (isoldr_info_t *)(loader_addr - ISOLDR_PARAMS_SIZE);
2927

3028
OpenLog();
3129
printf(NULL);
@@ -86,10 +84,11 @@ int main(int argc, char *argv[]) {
8684
IsoInfo->boot_mode
8785
);
8886

89-
LOGF("Loader: %08lx - %08lx size %d, heap %08lx\n",
87+
LOGF("Loader: %08lx - %08lx size %d, params %08lx, heap %08lx\n",
9088
loader_addr,
9189
loader_addr + loader_size,
9290
loader_size + ISOLDR_PARAMS_SIZE,
91+
(uint32)IsoInfo,
9392
malloc_heap_pos()
9493
);
9594

@@ -100,7 +99,7 @@ int main(int argc, char *argv[]) {
10099
goto error;
101100
}
102101

103-
if (!IsoInfo->use_dma) {
102+
if(!IsoInfo->use_dma) {
104103
fs_enable_dma(FS_DMA_DISABLED);
105104
}
106105

firmware/isoldr/loader/shlelf.xc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ OUTPUT_FORMAT("elf32-shl", "elf32-shl",
99
"elf32-shl")
1010
OUTPUT_ARCH(sh)
1111
ENTRY(start)
12-
SEARCH_DIR("/opt/toolchains/dc/sh-elf/sh-elf/lib");
1312
SECTIONS
1413
{
1514
/* Read-only sections, merged into text segment: */
16-
PROVIDE (__executable_start = 0x8ce00400); . = 0x8ce00400;
1715
.text :
1816
{
1917
*(.text .stub .text.* .gnu.linkonce.t.*)

firmware/isoldr/loader/startup.s

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
! This file is part of DreamShell ISO Loader
2-
! Copyright (C) 2009-2016 SWAT <http://www.dc-swat.ru>
2+
! Copyright (C) 2009-2016, 2025 SWAT <http://www.dc-swat.ru>
33
! Based on Sylverant PSO Patcher code by Lawrence Sebald
44
!
55
! This program is free software: you can redistribute it and/or modify
@@ -15,6 +15,14 @@
1515
! along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
!
1717
.globl start
18+
.globl _loader_addr
19+
.globl _loader_size
20+
.globl _bios_patch_base
21+
.globl _bios_patch_handler
22+
.globl _bios_patch_end
23+
.globl _boot_stub
24+
.globl _boot_stub_len
25+
1826
.text
1927
start:
2028
! First, make sure to run in the P2 area
@@ -59,7 +67,7 @@ init:
5967
jmp @r0
6068
mov #0, r0
6169

62-
.align 2
70+
.align 4
6371
mainaddr:
6472
.long _main
6573
initaddr:
@@ -74,36 +82,31 @@ p2_mask:
7482
.long 0xa0000000
7583
stack_ptr:
7684
.long 0x8d000000
77-
78-
.globl _loader_size
85+
_loader_addr:
86+
.long start
7987
_loader_size:
8088
.long _end - start
81-
89+
_boot_stub_len:
90+
.long _boot_stub_len - _boot_stub
91+
92+
.align 2
8293
bios_patch_null:
8394
nop
8495
rts
8596
nop
8697

87-
.globl _bios_patch_base
8898
_bios_patch_base:
89-
! nop
90-
! mov.l r0, @-r15
9199
mov.l _bios_patch_handler, r0
92100
jmp @r0
93-
! mov.l @r15+, r0
94-
! nop
95-
101+
96102
.align 4
97-
.globl _bios_patch_handler
98103
_bios_patch_handler:
99104
.long bios_patch_null
100-
.globl _bios_patch_end
101105
_bios_patch_end:
102106

103107
.align 2
104108
! This MUST always be run from a non-cacheable area of memory, since it
105109
! messes with the CCR register.
106-
.globl _boot_stub
107110
_boot_stub:
108111
! Set up some registers we will need to deal with later...
109112
mov r4, r14
@@ -145,7 +148,10 @@ _boot_stub:
145148
mov #0, r14
146149
! We should not ever get back here.
147150

148-
.balign 4
151+
.align 2
152+
ccr_data:
153+
.word 0x0909
154+
.align 4
149155
ccr_addr:
150156
.long 0xff00001c
151157
newr15:
@@ -162,10 +168,3 @@ startaddr:
162168
.long start
163169
p2mask:
164170
.long 0xa0000000
165-
ccr_data:
166-
.word 0x0909
167-
168-
.globl _boot_stub_len
169-
.balign 4
170-
_boot_stub_len:
171-
.long _boot_stub_len - _boot_stub

0 commit comments

Comments
 (0)