-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
235 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* @file dma.h | ||
* | ||
* @brief Direct Memory Access (DMA) module. | ||
*/ | ||
#ifndef SCE_DMA_H | ||
#define SCE_DMA_H | ||
|
||
#include "common.h" | ||
|
||
extern "C" | ||
{ | ||
struct tD_CHCR | ||
{ | ||
unsigned DIR : 1; /* Direction */ | ||
unsigned pad0: 1; | ||
unsigned MOD : 2; /* Mode */ | ||
unsigned ASP : 2; /* Address stack pointer */ | ||
unsigned TTE : 1; /* Tag trasfer enable */ | ||
unsigned TIE : 1; /* Tag interrupt enable */ | ||
unsigned STR : 1; /* start */ | ||
unsigned pad1: 7; | ||
unsigned TAG :16; /* DMAtag */ | ||
}; | ||
|
||
struct sceDmaTag | ||
{ | ||
ushort qwc; /* transfer count */ | ||
uchar mark; /* mark */ | ||
uchar id; /* tag */ | ||
sceDmaTag *next; /* next tag */ | ||
uint p[2]; /* padding */ | ||
} __attribute__ ((aligned(16))); | ||
|
||
struct sceDmaChan | ||
{ | ||
tD_CHCR chcr; // Channel control Dn_CHCR | ||
uint p0[3]; | ||
volatile void *madr; // Transfer memory address Dn_MADR | ||
uint p1[3]; | ||
volatile uint qwc; // Transfer size Dn_QWC | ||
uint p2[3]; | ||
volatile sceDmaTag *tadr; // Transfer tag address Dn_TADR | ||
uint p3[3]; | ||
volatile void *as0; // Address stack 0 Dn_ASR0 | ||
uint p4[3]; | ||
volatile void *as1; // Address stack Dn_ASR1 | ||
uint p5[3]; | ||
uint p6[4]; | ||
uint p7[4]; | ||
void* sadr; // SPR address Dn_SADR | ||
uint p8[3]; | ||
}; | ||
|
||
void FlushCache(int); | ||
|
||
/** | ||
* @brief Reset the DMA controller | ||
* | ||
* @param mode 0 = disable, 1 = enable | ||
* @return Previous mode before reset | ||
*/ | ||
int sceDmaReset(int mode); | ||
|
||
/** | ||
* @brief Start DMA transfer from memory to a device using Source Chain Mode. | ||
* | ||
* @param chan DMA channel for performing the transfer | ||
* @param tag Starting address of the transfer list | ||
*/ | ||
void sceDmaSend(sceDmaChan *chan, void *tag); | ||
|
||
/** | ||
* @brief Get a DMA channel structure by ID | ||
* | ||
* @param id Channel number | ||
* @return sceDmaChan* | ||
*/ | ||
sceDmaChan *sceDmaGetChan(int id); | ||
} | ||
|
||
#endif // SCE_DMA_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#include "common.h" | ||
#include <dmas.h> | ||
|
||
INCLUDE_ASM(const s32, "P2/dmas", StartupDma__Fv); | ||
|
||
DMAS::DMAS() | ||
{ | ||
m_fPad = 0; | ||
m_fEndPrim = 0; | ||
Clear(); | ||
} | ||
|
||
void DMAS::Clear() | ||
{ | ||
m_pbMax = (uchar*)nullptr; | ||
m_ab = (uchar*)nullptr; | ||
m_pqwCnt = (QW*)nullptr; | ||
m_pb = (uchar*)nullptr; | ||
} | ||
|
||
void DMAS::Reset() | ||
{ | ||
m_pqwCnt = (QW*)nullptr; | ||
m_pb = m_ab; | ||
} | ||
|
||
INCLUDE_ASM(const s32, "P2/dmas", AllocGlobal__4DMASi); | ||
|
||
INCLUDE_ASM(const s32, "P2/dmas", AllocSw__4DMASii); | ||
|
||
INCLUDE_ASM(const s32, "P2/dmas", AllocStack__4DMASi); | ||
|
||
INCLUDE_ASM(const s32, "P2/dmas", AllocStatic__4DMASiP2QW); | ||
|
||
void DMAS::Detach(int* arg0, QW** arg1) | ||
{ | ||
EndDmaCnt(); | ||
if (arg0 != nullptr) | ||
{ | ||
*arg0 = (uint)(m_pb - m_ab) >> 4; | ||
} | ||
if (arg1 != nullptr) | ||
{ | ||
*arg1 = (QW*)m_ab; | ||
} | ||
Clear(); | ||
} | ||
|
||
INCLUDE_ASM(const s32, "P2/dmas", DetachCopySw__4DMASPiPP2QWT2i); | ||
|
||
void DMAS::Send(sceDmaChan* chan) | ||
{ | ||
EndDmaCnt(); | ||
FlushCache(0); | ||
sceDmaSend(chan, m_ab); | ||
m_pb = m_ab; | ||
} | ||
|
||
INCLUDE_ASM(const s32, "P2/dmas", func_00152B30); | ||
|
||
INCLUDE_ASM(const s32, "P2/dmas", AddDmaCnt__4DMAS); | ||
|
||
INCLUDE_ASM(const s32, "P2/dmas", AddDmaRefs__4DMASiP2QW); | ||
|
||
INCLUDE_ASM(const s32, "P2/dmas", AddDmaCall__4DMASP2QW); | ||
|
||
INCLUDE_ASM(const s32, "P2/dmas", AddDmaRet__4DMAS); | ||
|
||
INCLUDE_ASM(const s32, "P2/dmas", AddDmaBulk__4DMASiP2QW); | ||
|
||
INCLUDE_ASM(const s32, "P2/dmas", AddDmaEnd__4DMAS); | ||
|
||
INCLUDE_ASM(const s32, "P2/dmas", EndDmaCnt__4DMAS); | ||
|
||
void DMAS::EndPrim(void) | ||
{ | ||
return; | ||
} | ||
|
||
INCLUDE_ASM(const s32, "P2/dmas", func_00152E20); |