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

Split RVL/DSP #219

Merged
merged 1 commit into from
Jul 24, 2022
Merged
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
8 changes: 6 additions & 2 deletions pack/dol_objects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,12 @@ out/darch.o
out/dol/sbss_803865fc_80386600.o
out/db.o
out/dbPrintf.o
out/dol/text_8015d3fc_80169bcc.o
out/dol/sbss_80386604_80386770.o
out/dsp.o
out/dspPrintf.o
out/dol/sbss_80386604_80386610.o
out/dspTask.o
out/dol/text_8015df1c_80169bcc.o
out/dol/sbss_80386628_80386770.o
out/fs.o
out/dol/text_8016b49c_80192f7c.o
out/dol/sdata_80385930_80385990.o
Expand Down
3 changes: 3 additions & 0 deletions pack/dol_slices.csv
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ enabled,strip,name,initStart,initEnd,extabStart,extabEnd,extabindexStart,extabin
1,,source/rvl/darch/darch.c,,,,,,,0x8015c320,0x8015d314,,,,,,,,,,,,,0x803865f8,0x803865fc,,,,
1,,source/rvl/db/db.c,,,,,,,0x8015d314,0x8015d3ac,,,,,,,,,,,,,0x80386600,0x80386604,,,,
1,,source/rvl/db/dbPrintf.c,,,,,,,0x8015d3ac,0x8015d3fc,,,,,,,,,,,,,,,,,,
1,,source/rvl/dsp/dsp.c,,,,,,,0x8015d3fc,0x8015d638,,,,,,,,,,,,,0x80386608,0x8038660c,,,,
1,,source/rvl/dsp/dspPrintf.c,,,,,,,0x8015d638,0x8015d688,,,,,,,,,,,,,,,,,,
1,,source/rvl/dsp/dspTask.c,,,,,,,0x8015d688,0x8015df1c,,,,,,,,,,,,,0x80386610,0x80386628,,,,
1,,source/rvl/fs/fs.c,,,,,,,0x80169bcc,0x8016b49c,,,,,,,,,,,0x80385920,0x80385930,0x80386770,0x80386788,,,,
1,,source/rvl/ipc/ipcMain.c,,,,,,,0x80192f7c,0x80193048,,,,,,,,,,,,,0x803867e8,0x803867fc,,,,
1,,source/rvl/ipc/ipcclt.c,,,,,,,0x80193048,0x801949b8,,,,,,,,,,,0x80385990,0x80385998,0x80386800,0x80386810,,,,
Expand Down
230 changes: 230 additions & 0 deletions source/rvl/dsp/dsp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
#include "dsp.h"

#include <rvl/os/os.h>
#include <rvl/os/osInterrupt.h>

#include "dspPrintf.h"
#include "dspTask.h"

static u32 unk_80386608;

// Symbol: DSPCheckMailToDSP
// PAL: 0x8015d3fc..0x8015d40c
MARK_BINARY_BLOB(DSPCheckMailToDSP, 0x8015d3fc, 0x8015d40c);
asm UNKNOWN_FUNCTION(DSPCheckMailToDSP) {
// clang-format off
nofralloc;
lis r3, 0xcc00;
lhz r0, 0x5000(r3);
rlwinm r3, r0, 0x11, 0x1f, 0x1f;
blr;
// clang-format on
}

// Symbol: DSPCheckMailFromDSP
// PAL: 0x8015d40c..0x8015d41c
MARK_BINARY_BLOB(DSPCheckMailFromDSP, 0x8015d40c, 0x8015d41c);
asm UNKNOWN_FUNCTION(DSPCheckMailFromDSP) {
// clang-format off
nofralloc;
lis r3, 0xcc00;
lhz r0, 0x5004(r3);
rlwinm r3, r0, 0x11, 0x1f, 0x1f;
blr;
// clang-format on
}

// Symbol: DSPReadMailFromDSP
// PAL: 0x8015d41c..0x8015d430
MARK_BINARY_BLOB(DSPReadMailFromDSP, 0x8015d41c, 0x8015d430);
asm UNKNOWN_FUNCTION(DSPReadMailFromDSP) {
// clang-format off
nofralloc;
lis r3, 0xcc00;
lhz r0, 0x5004(r3);
lhz r3, 0x5006(r3);
rlwimi r3, r0, 0x10, 0, 0xf;
blr;
// clang-format on
}

// Symbol: DSPSendMailToDSP
// PAL: 0x8015d430..0x8015d444
MARK_BINARY_BLOB(DSPSendMailToDSP, 0x8015d430, 0x8015d444);
asm UNKNOWN_FUNCTION(DSPSendMailToDSP) {
// clang-format off
nofralloc;
lis r4, 0xcc00;
srwi r0, r3, 0x10;
sth r0, 0x5000(r4);
sth r3, 0x5002(r4);
blr;
// clang-format on
}

// Symbol: DSPInit
// PAL: 0x8015d444..0x8015d504
MARK_BINARY_BLOB(DSPInit, 0x8015d444, 0x8015d504);
asm UNKNOWN_FUNCTION(DSPInit) {
// clang-format off
nofralloc;
stwu r1, -0x10(r1);
mflr r0;
lis r5, 0x8029;
stw r0, 0x14(r1);
addi r5, r5, -32672;
addi r3, r5, 0x48;
stw r31, 0xc(r1);
addi r4, r5, 0x68;
addi r5, r5, 0x74;
crclr 6;
bl __DSP_debug_printf;
lwz r0, unk_80386608;
cmpwi r0, 1;
beq lbl_8015d4f0;
lwz r3, -0x7350(r13);
bl OSRegisterVersion;
bl OSDisableInterrupts;
lis r4, 0x8016;
mr r31, r3;
addi r4, r4, -10616;
li r3, 7;
bl __OSSetInterruptHandler;
lis r3, 0x100;
bl __OSUnmaskInterrupts;
lis r7, 0xcc00;
li r3, -169;
lhz r6, 0x500a(r7);
li r5, -173;
li r4, 0;
li r0, 1;
and r3, r6, r3;
ori r3, r3, 0x800;
sth r3, 0x500a(r7);
mr r3, r31;
lhz r6, 0x500a(r7);
and r5, r6, r5;
sth r5, 0x500a(r7);
stw r4, unk_80386618;
stw r4, unk_80386624;
stw r4, unk_8038661c;
stw r4, unk_80386620;
stw r0, unk_80386608;
bl OSRestoreInterrupts;
lbl_8015d4f0:
lwz r0, 0x14(r1);
lwz r31, 0xc(r1);
mtlr r0;
addi r1, r1, 0x10;
blr;
// clang-format on
}

// Symbol: DSPCheckInit
// PAL: 0x8015d504..0x8015d50c
MARK_BINARY_BLOB(DSPCheckInit, 0x8015d504, 0x8015d50c);
asm UNKNOWN_FUNCTION(DSPCheckInit) {
// clang-format off
nofralloc;
lwz r3, unk_80386608;
blr;
// clang-format on
}

// Symbol: DSPAddTask
// PAL: 0x8015d50c..0x8015d57c
MARK_BINARY_BLOB(DSPAddTask, 0x8015d50c, 0x8015d57c);
asm UNKNOWN_FUNCTION(DSPAddTask) {
// clang-format off
nofralloc;
stwu r1, -0x10(r1);
mflr r0;
stw r0, 0x14(r1);
stw r31, 0xc(r1);
stw r30, 8(r1);
mr r30, r3;
bl OSDisableInterrupts;
mr r31, r3;
mr r3, r30;
bl __DSP_insert_task;
li r3, 0;
li r0, 1;
stw r3, 0(r30);
mr r3, r31;
stw r0, 8(r30);
bl OSRestoreInterrupts;
lwz r0, unk_80386620;
cmplw r30, r0;
bne lbl_8015d560;
mr r3, r30;
bl __DSP_boot_task;
lbl_8015d560:
mr r3, r30;
lwz r31, 0xc(r1);
lwz r30, 8(r1);
lwz r0, 0x14(r1);
mtlr r0;
addi r1, r1, 0x10;
blr;
// clang-format on
}

// Symbol: DSPAssertTask
// PAL: 0x8015d57c..0x8015d638
MARK_BINARY_BLOB(DSPAssertTask, 0x8015d57c, 0x8015d638);
asm UNKNOWN_FUNCTION(DSPAssertTask) {
// clang-format off
nofralloc;
stwu r1, -0x10(r1);
mflr r0;
stw r0, 0x14(r1);
stw r31, 0xc(r1);
stw r30, 8(r1);
mr r30, r3;
bl OSDisableInterrupts;
lwz r5, unk_80386624;
mr r31, r3;
cmplw r5, r30;
bne lbl_8015d5c0;
li r0, 1;
stw r30, unk_80386614;
stw r0, unk_80386610;
bl OSRestoreInterrupts;
mr r3, r30;
b lbl_8015d620;
lbl_8015d5c0:
lwz r4, 4(r30);
lwz r0, 4(r5);
cmplw r4, r0;
bge lbl_8015d618;
li r0, 1;
stw r30, unk_80386614;
stw r0, unk_80386610;
lwz r0, 0(r5);
cmplwi r0, 1;
bne lbl_8015d608;
bl OSDisableInterrupts;
lis r5, 0xcc00;
li r0, -169;
lhz r4, 0x500a(r5);
and r0, r4, r0;
ori r0, r0, 2;
sth r0, 0x500a(r5);
bl OSRestoreInterrupts;
lbl_8015d608:
mr r3, r31;
bl OSRestoreInterrupts;
mr r3, r30;
b lbl_8015d620;
lbl_8015d618:
bl OSRestoreInterrupts;
li r3, 0;
lbl_8015d620:
lwz r0, 0x14(r1);
lwz r31, 0xc(r1);
lwz r30, 8(r1);
mtlr r0;
addi r1, r1, 0x10;
blr;
// clang-format on
}
30 changes: 30 additions & 0 deletions source/rvl/dsp/dsp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include <rk_types.h>

#include <decomp.h>

#ifdef __cplusplus
extern "C" {
#endif

// PAL: 0x8015d3fc..0x8015d40c
UNKNOWN_FUNCTION(DSPCheckMailToDSP);
// PAL: 0x8015d40c..0x8015d41c
UNKNOWN_FUNCTION(DSPCheckMailFromDSP);
// PAL: 0x8015d41c..0x8015d430
UNKNOWN_FUNCTION(DSPReadMailFromDSP);
// PAL: 0x8015d430..0x8015d444
UNKNOWN_FUNCTION(DSPSendMailToDSP);
// PAL: 0x8015d444..0x8015d504
UNKNOWN_FUNCTION(DSPInit);
// PAL: 0x8015d504..0x8015d50c
UNKNOWN_FUNCTION(DSPCheckInit);
// PAL: 0x8015d50c..0x8015d57c
UNKNOWN_FUNCTION(DSPAddTask);
// PAL: 0x8015d57c..0x8015d638
UNKNOWN_FUNCTION(DSPAssertTask);

#ifdef __cplusplus
}
#endif
31 changes: 31 additions & 0 deletions source/rvl/dsp/dspPrintf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "dspPrintf.h"

// Symbol: __DSP_debug_printf
// PAL: 0x8015d638..0x8015d688
MARK_BINARY_BLOB(__DSP_debug_printf, 0x8015d638, 0x8015d688);
asm UNKNOWN_FUNCTION(__DSP_debug_printf) {
// clang-format off
nofralloc;
stwu r1, -0x70(r1);
bne cr1, lbl_8015d660;
stfd f1, 0x28(r1);
stfd f2, 0x30(r1);
stfd f3, 0x38(r1);
stfd f4, 0x40(r1);
stfd f5, 0x48(r1);
stfd f6, 0x50(r1);
stfd f7, 0x58(r1);
stfd f8, 0x60(r1);
lbl_8015d660:
stw r3, 8(r1);
stw r4, 0xc(r1);
stw r5, 0x10(r1);
stw r6, 0x14(r1);
stw r7, 0x18(r1);
stw r8, 0x1c(r1);
stw r9, 0x20(r1);
stw r10, 0x24(r1);
addi r1, r1, 0x70;
blr;
// clang-format on
}
16 changes: 16 additions & 0 deletions source/rvl/dsp/dspPrintf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <rk_types.h>

#include <decomp.h>

#ifdef __cplusplus
extern "C" {
#endif

// PAL: 0x8015d638..0x8015d688
UNKNOWN_FUNCTION(__DSP_debug_printf);

#ifdef __cplusplus
}
#endif
Loading