Skip to content

Commit 99069ca

Browse files
Smethand0k3
authored andcommitted
Fixed for Boot9strap 1.2
1 parent d11d9bc commit 99069ca

9 files changed

Lines changed: 46 additions & 18 deletions

File tree

.gitmodules

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,3 @@
99
path = CakesROP
1010
url = https://github.com/mid-kid/CakesROP
1111
ignore = dirty
12-
[submodule "firmtool"]
13-
path = firmtool
14-
url = https://github.com/TuxSH/firmtool.git
15-
ignore = dirty

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ install:
1010
- sudo apt-get -qq install lftp p7zip-full
1111

1212
script:
13-
- make
13+
- make binary

BrahmaLoader

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ARCH := -mthumb -mthumb-interwork -flto
3434

3535
CFLAGS := -g -Wall -Wextra -Wpedantic -Wno-main -O2\
3636
-march=armv5te -mtune=arm946e-s -fomit-frame-pointer\
37-
-ffast-math -std=c99\
37+
-ffast-math -std=gnu11\
3838
$(ARCH)
3939

4040
CFLAGS += $(INCLUDE) -DARM9 -D_GNU_SOURCE
@@ -130,7 +130,7 @@ binary: common
130130
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
131131

132132
firm: binary
133-
@firmtool/firmtool build $(OUTPUT).firm -n 0x23F00000 -e 0 -D $(OUTPUT).bin -A 0x23F00000 -C NDMA -i
133+
@firmtool build $(OUTPUT).firm -n 0x23F00000 -e 0 -D $(OUTPUT).elf -A 0x23F00000 -C NDMA -i
134134

135135
gateway: binary
136136
@cp resources/LauncherTemplate.dat $(OUTPUT_D)/Launcher.dat

firmtool

Lines changed: 0 additions & 1 deletion
This file was deleted.

source/draw.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,14 @@
5959
#define DBG_N_CHARS_Y ((DBG_END_Y - DBG_START_Y) / DBG_STEP_Y)
6060
#define DBG_N_CHARS_X (((DBG_END_X - DBG_START_X) / FONT_WIDTH) + 1)
6161

62-
#define TOP_SCREEN (u8*)(*(u32*)0x23FFFE00)
63-
#define BOT_SCREEN (u8*)(*(u32*)0x23FFFE08)
62+
#define TOP_SCREEN top_screen
63+
#define BOT_SCREEN bottom_screen
6464

6565
#define ScreenWidth(x) (((x) == (TOP_SCREEN) ? 400 : 320))
6666
#define IsCharPartOfWord(x) (((x) >= 'a' && (x) <= 'z') || ((x) >= '0' && (x) <= '9') || ((x) >= 'A' && (x) <= 'Z'))
6767

68+
extern u8 *top_screen, *bottom_screen;
69+
6870
void ClearScreen(unsigned char *screen, int width, int color);
6971
void ClearScreenFull(bool clear_top, bool clear_bottom);
7072

source/gamecart/protocol.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#define REG_AESKEYXFIFO (*(vu32*)0x10009104)
2929
#define REG_AESKEYYFIFO (*(vu32*)0x10009108)
3030

31-
extern u8* bottomScreen;
3231

3332
u32 CartID = 0xFFFFFFFFu;
3433
u32 CartType = 0;

source/main.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ u32 InitializeD9(MenuInfo *menu)
9898
return errorlevel;
9999
}
100100

101+
u8 *top_screen, *bottom_screen;
101102

102-
int main()
103+
int main(int argc, char** argv)
103104
{
104105
MenuInfo menu[] =
105106
{
@@ -452,6 +453,17 @@ int main()
452453
NULL, 0, { { 0 } } // empty menu to signal end
453454
}
454455
};
456+
// Fetch the framebuffer addresses
457+
if(argc >= 2) {
458+
// newer entrypoints
459+
u8 **fb = (u8 **)(void *)argv[1];
460+
top_screen = fb[0];
461+
bottom_screen = fb[2];
462+
} else {
463+
// outdated entrypoints
464+
top_screen = (u8*)(*(u32*)0x23FFFE00);
465+
bottom_screen = (u8*)(*(u32*)0x23FFFE08);
466+
}
455467

456468
u32 menu_exit = MENU_EXIT_REBOOT;
457469

source/start.s

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ _start_gw:
6565
stmia r0, {r1,r2,r3}
6666
@ framebuffers properly set
6767

68+
ldr r3, =0xFFFF0830 @ flush (clean & invalidate) entire dcache b9 func
69+
blx r3
70+
71+
mov r3, #0
72+
mcr p15, 0, r3, c7, c5, 0 @ invalidate I-cache
73+
74+
mov r2, #0
75+
6876
ldr r3, .entry
6977
bx r3
7078

@@ -74,8 +82,18 @@ _start_gw:
7482
.entry: .word 0x23F00000
7583

7684
_skip_gw:
85+
mov r9, r0 @ argc
86+
mov r10, r1 @ argv
87+
88+
ldr r4, =0xBEEF
89+
lsl r2, #16
90+
lsr r2, #16
91+
cmp r2, r4 @ magic word
92+
movne r9, #0
93+
7794
@ Disable caches / mpu
7895
mrc p15, 0, r4, c1, c0, 0 @ read control register
96+
bic r4, #(1<<16) @ - dtcm disable (mandated by the docs, before you change the dtcm's address)
7997
bic r4, #(1<<12) @ - instruction cache disable
8098
bic r4, #(1<<2) @ - data cache disable
8199
bic r4, #(1<<0) @ - mpu disable
@@ -91,10 +109,10 @@ _skip_gw:
91109
strlt r2, [r0], #4
92110
blt .bss_clr
93111

94-
@ Flush caches
112+
@ Invalidate caches
95113
mov r5, #0
96-
mcr p15, 0, r5, c7, c5, 0 @ flush I-cache
97-
mcr p15, 0, r5, c7, c6, 0 @ flush D-cache
114+
mcr p15, 0, r5, c7, c5, 0 @ invalidate I-cache
115+
mcr p15, 0, r5, c7, c6, 0 @ invalidate D-cache
98116
mcr p15, 0, r5, c7, c10, 4 @ drain write buffer
99117

100118
@ Give read/write access to all the memory regions
@@ -144,7 +162,9 @@ _skip_gw:
144162

145163
mov sp, #0x27000000
146164

147-
blx main
148-
b _start
165+
166+
mov r0, r9
167+
mov r1, r10
168+
b main
149169

150170
.pool

0 commit comments

Comments
 (0)