Skip to content

Commit

Permalink
- Detect MRAM configuration set by BS1.
Browse files Browse the repository at this point in the history
- Pass configuration along to applications.
  • Loading branch information
Extrems committed Feb 13, 2025
1 parent c16655e commit 233f01c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cube/packer/source/crt0.S
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ premain:
blt 1b

li r0, 0
lis sp, 0x0180
lis sp, 0x0100
stwu r0, -8 (sp)

bl main
Expand Down
20 changes: 19 additions & 1 deletion cube/swiss/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,25 @@ void __SYS_PreInit(void)
{
DCZeroRange((void *)0x80000000, 0x3100);

*(u32 *)0x80000028 = 0x01800000;
switch (((vu16 *)0xCC004000)[20] & 7) {
case 0:
*(u32 *)0x80000028 = 0x1000000;
break;
case 1: case 4:
*(u32 *)0x80000028 = 0x2000000;
break;
case 2: case 6:
*(u32 *)0x80000028 = 0x1800000;
break;
case 3: case 7:
*(u32 *)0x80000028 = 0x3000000;
break;
case 5:
*(u32 *)0x80000028 = 0x4000000;
break;
}

*(u32 *)0x800000F0 = 0x1800000;
*(u32 *)0x800000F8 = TB_BUS_CLOCK;
*(u32 *)0x800000FC = TB_CORE_CLOCK;

Expand Down
3 changes: 3 additions & 0 deletions cube/swiss/source/patcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ int install_code(int final)

// Reload Stub
if (!top_addr) {
u32 size = SYS_GetPhysicalMemSize();
*(u32 *)0x80000034 = (u32)MEM_PHYSICAL_TO_K0(size);
*(u32 *)0x800000F0 = size;
return 1;
}
// IDE-EXI
Expand Down
2 changes: 1 addition & 1 deletion cube/swiss/source/swiss.c
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ void load_app(ExecutableFile *fileToPatch)

*(vu32*)(VAR_AREA+0x0028) = 0x01800000;
*(vu32*)(VAR_AREA+0x002C) = swissSettings.debugUSB ? 0x10000004:0x00000001;
*(vu32*)(VAR_AREA+0x002C) += *(vu32*)0xCC00302C >> 28;
*(vu32*)(VAR_AREA+0x002C) += ((vu32*)0xCC003000)[11] >> 28;
*(vu32*)(VAR_AREA+0x00CC) = swissSettings.sramVideo;
*(vu32*)(VAR_AREA+0x00D0) = 0x01000000;
*(vu32*)(VAR_AREA+0x00E8) = 0x81800000 - topAddr;
Expand Down

0 comments on commit 233f01c

Please sign in to comment.