sm64/lib/src/__osSpRawStartDma.c

17 lines
459 B
C
Raw Normal View History

2019-08-25 00:46:40 -04:00
#include "libultra_internal.h"
#include "hardware.h"
s32 __osSpRawStartDma(u32 dir, void *sp_ptr, void *dram_ptr, size_t size) {
2019-09-01 15:50:50 -04:00
if (__osSpDeviceBusy()) {
2019-08-25 00:46:40 -04:00
return -1;
2019-09-01 15:50:50 -04:00
}
2019-08-25 00:46:40 -04:00
HW_REG(SP_MEM_ADDR_REG, void *) = sp_ptr;
HW_REG(SP_DRAM_ADDR_REG, void *) = (void *) osVirtualToPhysical(dram_ptr);
2019-09-01 15:50:50 -04:00
if (dir == 0) {
2019-08-25 00:46:40 -04:00
HW_REG(SP_WR_LEN_REG, u32) = size - 1;
2019-09-01 15:50:50 -04:00
} else {
2019-08-25 00:46:40 -04:00
HW_REG(SP_RD_LEN_REG, u32) = size - 1;
2019-09-01 15:50:50 -04:00
}
2019-08-25 00:46:40 -04:00
return 0;
}