sm64

A Super Mario 64 decompilation
Log | Files | Refs | README | LICENSE

__osSiRawStartDma.c (839B)


      1 #include "libultra_internal.h"
      2 #include "PR/rcp.h"
      3 #include "PR/ique.h"
      4 
      5 s32 __osSiRawStartDma(s32 dir, void *addr) {
      6 #ifdef VERSION_CN
      7     if (IO_READ(SI_STATUS_REG) & (SI_STATUS_DMA_BUSY | SI_STATUS_RD_BUSY)) {
      8         return -1;
      9     }
     10 #else
     11     if (__osSiDeviceBusy()) {
     12         return -1;
     13     }
     14 #endif
     15 
     16     if (dir == OS_WRITE) {
     17         osWritebackDCache(addr, 64);
     18     }
     19 
     20     IO_WRITE(SI_DRAM_ADDR_REG, osVirtualToPhysical(addr));
     21 
     22     if (dir == OS_READ) {
     23 #ifdef VERSION_CN
     24         if (__osBbIsBb != 0) {
     25             u32 prev = __osDisableInt();
     26             skKeepAlive();
     27             __osRestoreInt(prev);
     28         }
     29 #endif
     30         IO_WRITE(SI_PIF_ADDR_RD64B_REG, 0x1FC007C0);
     31     } else {
     32         IO_WRITE(SI_PIF_ADDR_WR64B_REG, 0x1FC007C0);
     33     }
     34 
     35     if (dir == OS_READ) {
     36         osInvalDCache(addr, 64);
     37     }
     38     return 0;
     39 }