sm64

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

os_pi.h (2062B)


      1 #ifndef _ULTRA64_PI_H_
      2 #define _ULTRA64_PI_H_
      3 #include <ultra64.h>
      4 
      5 /* Ultra64 Parallel Interface */
      6 
      7 /* Types */
      8 
      9 typedef struct {
     10 #if !defined(VERSION_EU)
     11     u32 errStatus;
     12 #endif
     13     void *dramAddr;
     14     void *C2Addr;
     15     u32 sectorSize;
     16     u32 C1ErrNum;
     17     u32 C1ErrSector[4];
     18 } __OSBlockInfo;
     19 
     20 typedef struct {
     21     u32 cmdType;       // 0
     22     u16 transferMode;  // 4
     23     u16 blockNum;      // 6
     24     s32 sectorNum;     // 8
     25     uintptr_t devAddr; // c
     26 #if defined(VERSION_EU)
     27     u32 errStatus; //error status added moved to blockinfo
     28 #endif
     29     u32 bmCtlShadow;        // 10
     30     u32 seqCtlShadow;       // 14
     31     __OSBlockInfo block[2]; // 18
     32 } __OSTranxInfo;
     33 
     34 typedef struct OSPiHandle_s {
     35     struct OSPiHandle_s *next;
     36     u8 type;
     37     u8 latency;
     38     u8 pageSize;
     39     u8 relDuration;
     40     u8 pulse;
     41     u8 domain;
     42     u32 baseAddress;
     43     u32 speed;
     44     __OSTranxInfo transferInfo;
     45 } OSPiHandle;
     46 
     47 typedef struct {
     48     u8 type;
     49     uintptr_t address;
     50 } OSPiInfo;
     51 
     52 typedef struct {
     53     u16 type;
     54     u8 pri;
     55     u8 status;
     56     OSMesgQueue *retQueue;
     57 } OSIoMesgHdr;
     58 
     59 typedef struct {
     60     /*0x00*/ OSIoMesgHdr hdr;
     61     /*0x08*/ void *dramAddr;
     62     /*0x0C*/ uintptr_t devAddr;
     63     /*0x10*/ size_t size;
     64 #if defined(VERSION_EU) || defined(VERSION_SH) || defined(VERSION_CN)
     65     OSPiHandle *piHandle; // from the official definition
     66 #endif
     67 } OSIoMesg;
     68 
     69 /* Definitions */
     70 
     71 #define OS_READ 0  // device -> RDRAM
     72 #define OS_WRITE 1 // device <- RDRAM
     73 
     74 #define OS_MESG_PRI_NORMAL 0
     75 #define OS_MESG_PRI_HIGH 1
     76 
     77 /* Functions */
     78 
     79 s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, uintptr_t devAddr, void *vAddr,
     80                  size_t nbytes, OSMesgQueue *mq);
     81 void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgCnt);
     82 OSMesgQueue *osPiGetCmdQueue(void);
     83 s32 osPiWriteIo(uintptr_t devAddr, u32 data);
     84 s32 osPiReadIo(uintptr_t devAddr, u32 *data);
     85 
     86 s32 osPiRawStartDma(s32 dir, u32 cart_addr, void *dram_addr, size_t size);
     87 s32 osEPiRawStartDma(OSPiHandle *piHandle, s32 dir, u32 cart_addr, void *dram_addr, size_t size);
     88 #endif