dma functions

This commit is contained in:
zestydevy 2022-07-09 18:05:46 -05:00
parent a69adf03da
commit 63f7ee2db8
9 changed files with 292 additions and 19 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@ assets/*
build/*
bin/*
asm/*
expected/*
*.z64
*.ld
*.Identifier

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
def apply(config, args):
config['baseimg'] = 'baserom.u.z64'
config['baseimg'] = 'baserom.us.z64'
config['myimg'] = 'build/marioparty3.z64'
config['mapfile'] = 'build/marioparty3.map'
config['source_directories'] = ['.']

View File

@ -82,4 +82,14 @@ OSMesgQueue *osPiGetCmdQueue(void);
s32 osPiWriteIo(u32 devAddr, u32 data);
s32 osPiReadIo(u32 devAddr, u32 *data);
extern s32 osEPiDeviceType(OSPiHandle *, OSPiInfo *);
extern s32 osEPiRawWriteIo(OSPiHandle *, u32 , u32);
extern s32 osEPiRawReadIo(OSPiHandle *, u32 , u32 *);
extern s32 osEPiRawStartDma(OSPiHandle *, s32 , u32 , void *, u32 );
extern s32 osEPiWriteIo(OSPiHandle *, u32 , u32 );
extern s32 osEPiReadIo(OSPiHandle *, u32 , u32 *);
extern s32 osEPiStartDma(OSPiHandle *, OSIoMesg *, s32);
extern s32 osEPiLinkHandle(OSPiHandle *);
#endif

11
include/rom.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef __ROM_H
#define __ROM_H
#include <libultra.h>
s32 func_8004D9F8_4E5F8(OSIoMesg * msg, u8 arg1, s32 arg2, u32 arg3, void * arg4, u32 arg5, OSMesgQueue * arg6);
s32 HuRomDmaRead(u32 src, void * dest, s32 size);
s32 HuRomDmaCodeRead(u32 src, void * dest, s32 size);
#endif

View File

@ -69,7 +69,7 @@ segments:
- [0x47D60, asm]
- [0x4B120, asm]
- [0x4BF40, asm]
- [0x4E5A0, asm]
- [0x4E5A0, c, rom]
- [0x4E800, asm]
- [0x4F720, asm, "process"]
- [0x4FE90, asm]
@ -165,13 +165,14 @@ segments:
- [0x79610, asm, "libultra/audio/synsetpan"]
- [0x796A0, asm, "libultra/audio/synallocfx"]
- [0x79740, asm, "libultra/audio/cents2ratio"]
- [0x797A0, asm, "libultra/io/conteeplongwrite"]
- [0x798D0, hasm, libultra/os/invalicache]
- [0x79950, hasm, "libultra/os/writebackdcacheall"]
- [0x797A0, asm, "libultra/os/invaldcache"]
- [0x79850, asm, "libultra/os/invalicache"]
- [0x798D0, asm, "libultra/os/writebackdcache"]
- [0x79950, asm, "libultra/os/writebackdcacheall"]
- [0x79980, asm, "libultra/io/contreaddata"]
- [0x79B60, asm, "libultra/io/controller"]
- [0x79E70, asm, "libultra/io/contsetch"]
- [0x79ED0, asm, "libultra/os/osVirtualToPhysical"]
- [0x79ED0, asm, "libultra/os/virtualtophysical"]
- [0x79F30, asm, "libultra/gu/cosf"]
- [0x7A080, asm, "libultra/gu/lookat"]
- [0x7A790, asm, "libultra/gu/lookathil"]

View File

@ -1,9 +1,51 @@
#include "common.h"
#include "malloc.h"
INCLUDE_ASM(s32, "data", func_80009880_A480);
extern s16 D_800C9520[];
extern s16 D_800D0590[];
extern s16 D_800D10F8[];
extern s16 D_800D1350[];
extern s16 D_800D5546[];
void func_80009880_A480(void)
{
s16 i;
for (i = 0; i < 4; ++i) {
D_800D5546[i] =
D_800D1350[i] =
D_800C9520[i] =
D_800D0590[i] =
D_800D10F8[i] = 0;
}
}
INCLUDE_ASM(s32, "data", func_800098FC_A4FC);
// TODO: this is a file break for data.c
// 16 byte portion of a directory or file table, which is initially read from ROM.
struct mainfs_table_header {
s32 count;
s32 offsets[3]; // Enough to pad to size 16
};
struct mainfs_entry_info {
u8 * file_bytes;
s32 size;
s32 compression_type;
};
extern void *D_800ABFC0; // FS ROM location
extern u32 D_800ABFC4; // Directory count
extern s32 *D_800ABFC8; // Directory offset table pointer.
extern void *D_800ABFCC; // FS ROM location (copy)
extern u32 D_800ABFD0; // Directory count (copy)
extern s32 *D_800ABFD4; // Directory offset table pointer (copy)
extern struct mainfs_table_header D_800ABFE0;
INCLUDE_ASM(s32, "data", func_80009AC0_A6C0);
INCLUDE_ASM(s32, "data", func_80009B64_A764);

86
src/rom.c Normal file
View File

@ -0,0 +1,86 @@
#include "common.h"
#include "rom.h"
extern OSPiHandle * osCartRomInit(void);
extern OSPiHandle * D_800CDD50;
extern OSMesgQueue D_800B29F0;
extern void* D_800B2A08;
extern void* D_800CCFA8;
extern OSMesgQueue D_800D6B28;
void func_8004D9A0_4E5A0(void) {
osCreatePiManager(OS_PRIORITY_PIMGR, &D_800D6B28, &D_800CCFA8, 0x2A);
D_800CDD50 = osCartRomInit();
osCreateMesgQueue(&D_800B29F0, &D_800B2A08, 0xA);
}
s32 HuStartDma(OSIoMesg * msg, u8 pri, s32 direction, u32 src, void * dest, u32 size, OSMesgQueue * retQueue) {
msg->hdr.pri = pri;
msg->hdr.retQueue = retQueue;
msg->dramAddr = dest;
msg->devAddr = src;
msg->size = size;
return osEPiStartDma(D_800CDD50, msg, direction);
}
s32 HuRomDmaRead(u32 src, void * dest, s32 size)
{
OSIoMesg msg;
s32 var_s1;
u32 var_v1;
s32 err;
osInvalDCache(dest, OS_DCACHE_ROUNDUP_SIZE(size));
var_s1 = 0;
while (size > 0)
{
var_v1 = size;
if (size >= 0x4001) {
var_v1 = 0x4000;
}
err = HuStartDma(&msg, 0, 0, src + var_s1, dest + var_s1, var_v1, &D_800B29F0);
if (err != 0) {
return err;
}
osRecvMesg(&D_800B29F0, 0, 1);
size -= 0x4000;
var_s1 += 0x4000;
}
return err;
}
s32 HuRomDmaCodeRead(u32 src, void * dest, s32 size)
{
OSIoMesg msg;
s32 var_s1;
u32 var_v1;
s32 err;
osInvalICache(dest, OS_DCACHE_ROUNDUP_SIZE(size));
osInvalDCache(dest, OS_DCACHE_ROUNDUP_SIZE(size));
var_s1 = 0;
while (size > 0)
{
var_v1 = size;
if (size >= 0x4001) {
var_v1 = 0x4000;
}
err = HuStartDma(&msg, 0, 0, src + var_s1, dest + var_s1, var_v1, &D_800B29F0);
if (err != 0) {
return err;
}
osRecvMesg(&D_800B29F0, 0, 1);
size -= 0x4000;
var_s1 += 0x4000;
}
return err;
}

View File

@ -35,5 +35,127 @@ HuMemMemoryReallocTemp = 0x80035974;
HuMemHeapAllocTempSizeGet = 0x800359A0;
HuMemUsedMemoryBlockGetTemp = 0x800359C0;
HuStartDma = 0x8004D9F8;
HuRomDmaRead = 0x8004DA40;
HuRomDmaCodeRead = 0x8004DB14;
sprintf = 0x8007BDC0;
bcopy = 0x8007B970;
__osTimerServicesInit = 0x8007CE50;
osCreateThread = 0x8007C810;
__osViInit = 0x800829D0;
osEepromLongRead = 0x80072590;
osSetIntMask = 0x80072600;
osCreatePiManager = 0x800726A0;
ramromMain = 0x8007286C;
__osEPiRawStartDma = 0x80072950;
osEPiStartDma = 0x80072B40;
osCartRomInit = 0x80072BE0;
__osDevMgrMain = 0x80072D60;
osSetEventMesg = 0x8007C2D0;
__osEventStateTab = 0x800D5440;
_osShutdown = 0x800A2D90;
_osPreNMI = 0x800A3FAC;
osViSetMode = 0x8007D6F0;
__osViNext = 0x800A4104;
osCreateViManager = 0x8007D350;
__osViDevMgr = 0x800A2DE0;
viThread = 0x800C39A8;
viEventQueue = 0x800C4B60;
viEventBuf = 0x800C4B78;
viRetraceMsg = 0x800C4B90;
viCounterMsg = 0x800C4BA8;
__additional_scanline = 0x800A2DFC;
osViSetYScale = 0x8007D8B0;
osViBlack = 0x8007DC60;
osViSetEvent = 0x8007D690;
D_800BBED0 = 0x800BBED0;
osEepromRead = 0x8007F8E0;
osEepromWrite = 0x80072020;
osWritebackDCacheAll = 0x80078D50;
osSpTaskLoad = 0x8007C3C0;
osSpTaskStartGo = 0x8007C5CC;
osSpTaskYield = 0x8007C600;
osSpTaskYielded = 0x8007C620;
osViGetCurrentFramebuffer = 0x8007D2D0;
osViGetNextFramebuffer = 0x8007D310;
__osPackEepWriteData = 0x800721D4;
__osEepStatus = 0x8007227C;
osVirtualToPhysical = 0x800792D0;
osInvalDCache = 0x80078BA0;
osInvalICache = 0x80078C50;
osWritebackDCache = 0x80078CD0;
osWritebackDCacheAll = 0x80078D50;
cosf = 0x80079330;
sinf = 0x8007B530;
bcopy = 0x8007B970;
bzero = 0x8007BC90;
osInitRdb = 0x8007B8F0;
strchr = 0x8007BD30;
strlen = 0x8007BD70;
memcpy = 0x8007BD94;
rmonPrintf_func_8007BE50 = 0x8007BE50;
osSyncPrintf = 0x8007BE80;
osSyncPrintf_func_8007BEC0 = 0x8007BEC0;
osCreateMesgQueue = 0x8007BF00;
osJamMesg = 0x8007BF30;
osRecvMesg = 0x8007C070;
osSendMesg = 0x8007C1A0;
osGetThreadPri = 0x8007C9F0;
osSetThreadPri = 0x8007CA10;
osStartThread = 0x8007CAE0;
osGetTime = 0x8007CC90;
osSetTimer = 0x8007CD20;
__osProbeTLB = 0x8007D210;
__osEnqueueAndYield = 0x8008061C;
__osPopThread = 0x80080774;
__osDisableInt = 0x80080940;
__osRestoreInt = 0x800809B0;

View File

@ -301,7 +301,7 @@ D_800A2D50 = 0x800A2D50;
D_800A2D60 = 0x800A2D60;
D_800A2D70 = 0x800A2D70;
D_800A2D80 = 0x800A2D80;
D_800A2D90 = 0x800A2D90;
_osShutdown = 0x800A2D90;
D_800A2DA0 = 0x800A2DA0;
D_800A2DB0 = 0x800A2DB0;
D_800A2DB8 = 0x800A2DB8;
@ -309,21 +309,21 @@ D_800A2DBC = 0x800A2DBC;
D_800A2DC0 = 0x800A2DC0;
D_800A2DC4 = 0x800A2DC4;
D_800A2DD0 = 0x800A2DD0;
D_800A2DE0 = 0x800A2DE0;
__osViDevMgr = 0x800A2DE0;
D_800A2DE4 = 0x800A2DE4;
D_800A2DE8 = 0x800A2DE8;
D_800A2DEC = 0x800A2DEC;
D_800A2DF0 = 0x800A2DF0;
D_800A2DF4 = 0x800A2DF4;
D_800A2DF8 = 0x800A2DF8;
D_800A2DFC = 0x800A2DFC;
__additional_scanline = 0x800A2DFC;
D_800A2E00 = 0x800A2E00;
D_800A3F80 = 0x800A3F80;
D_800A3F90 = 0x800A3F90;
D_800A3FA0 = 0x800A3FA0;
D_800A3FA4 = 0x800A3FA4;
D_800A3FA8 = 0x800A3FA8;
D_800A3FAC = 0x800A3FAC;
_osPreNMI = 0x800A3FAC;
D_800A3FB0 = 0x800A3FB0;
D_800A3FB4 = 0x800A3FB4;
D_800A3FC0 = 0x800A3FC0;
@ -350,7 +350,7 @@ D_800A40D2 = 0x800A40D2;
D_800A40D4 = 0x800A40D4;
D_800A40D8 = 0x800A40D8;
D_800A4100 = 0x800A4100;
D_800A4104 = 0x800A4104;
__osViNext = 0x800A4104;
D_800A4110 = 0x800A4110;
D_800A4160 = 0x800A4160;
D_800A41B0 = 0x800A41B0;
@ -1113,13 +1113,13 @@ D_800C3988 = 0x800C3988;
D_800C398C = 0x800C398C;
D_800C3990 = 0x800C3990;
D_800C39A0 = 0x800C39A0;
D_800C39A8 = 0x800C39A8;
D_800C4B60 = 0x800C4B60;
D_800C4B78 = 0x800C4B78;
D_800C4B90 = 0x800C4B90;
viThread = 0x800C39A8;
viEventQueue = 0x800C4B60;
viEventBuf = 0x800C4B78;
viRetraceMsg = 0x800C4B90;
D_800C4B92 = 0x800C4B92;
D_800C4B94 = 0x800C4B94;
D_800C4BA8 = 0x800C4BA8;
viCounterMsg = 0x800C4BA8;
D_800C4BAA = 0x800C4BAA;
D_800C4BAC = 0x800C4BAC;
D_800C4BC0 = 0x800C4BC0;
@ -1764,7 +1764,7 @@ D_800D5310 = 0x800D5310;
D_800D5410 = 0x800D5410;
D_800D5418 = 0x800D5418;
D_800D5438 = 0x800D5438;
D_800D5440 = 0x800D5440;
__osEventStateTab = 0x800D5440;
D_800D54F8 = 0x800D54F8;
D_800D54FC = 0x800D54FC;
D_800D5500 = 0x800D5500;