In memory of Ben “bushing” Byer, who passed away on Monday, February 8th, 2016.

Difference between revisions of "Dmae.rpl"

From WiiUBrew
Jump to navigation Jump to search
m
(Page Redo - clear out SDK stuff; use Decaf as source instead)
 
Line 2: Line 2:
  
 
==Functions==
 
==Functions==
 
+
In the context of the DMAE library; timestamps (as OSTimes) are used to identify operations. They can be used with DMAEWaitDone for synchronisation.
All uint64_t values returned from functions are timestamps that can be used with DMAEWaitDone.
 
  
 
===Timing===
 
===Timing===
 
{| class="wikitable"
 
{| class="wikitable"
!Name
 
 
!Prototype
 
!Prototype
 
!Description
 
!Description
 
|-
 
|-
|DMAEWaitDone
+
|<syntaxhighlight lang="C" enclose="none">OSTime DMAEGetRetiredTimeStamp();</syntaxhighlight>
|<code>bool DMAEWaitDone(uint64_t ts);</code>
+
|
|Return true if all goes normally, return false if a time-out occurred. Usage: DMAEWaitDone(DMAECopyMem(mem_ptr, 0, 0x100, DMAE_ENDIAN_8IN32));
+
|-
|}
+
|<syntaxhighlight lang="C" enclose="none">OSTime DMAEGetLastSubmittedTimeStamp();</syntaxhighlight>
===Semaphore===
+
|Returns the last timestamp submitted to the DMAE engine, as an OSTime.
{| class="wikitable"
+
|-
!Name
+
|<syntaxhighlight lang="C" enclose="none">bool DMAEWaitDone(OSTime timestamp);</syntaxhighlight>
!Prototype
+
|Wait until a given DMA operation is complete.
!Description
 
 
|-
 
|-
|DMAEInitSemaphore
+
|<syntaxhighlight lang="C" enclose="none">void DMAESetTimeout(unsigned int timeout);</syntaxhighlight>
|<code>uint64_t DMAEInitSemaphore(uint64_t *semaphoreAddr, uint64_t semaphoreCount)</code>
+
|Set the timeout for DMA operations.
|Initialize a Semaphore to synchronize DMA Engine to the GPU (GPU7)
 
 
|-
 
|-
|DMAESemaphore
+
|<syntaxhighlight lang="C" enclose="none">unsigned int DMAEGetTimeout();</syntaxhighlight>
|<code>uint64_t DMAESemaphore(u64 *semaphoreAddr, DMAESemaphoreAction semaphoreAction)</code>
+
|Gets the current timeout for DMA operations.
|Create a Semaphore at the specified address
 
 
|}
 
|}
===Memory===
+
 
 +
===Operations===
 
{| class="wikitable"
 
{| class="wikitable"
!Name
 
 
!Prototype
 
!Prototype
 
!Description
 
!Description
 
|-
 
|-
|DMAECopyMem
+
|<syntaxhighlight lang="C" enclose="none">OSTime DMAECopyMem(void* dst, void* src, size_t numDwords, DMAEEndianSwapMode endian);</syntaxhighlight>
|<code>uint64_t DMAECopyMem(void *dst, const void *src, uint32_t size, DMAEEndian endian)</code>
+
|Uses DMA to copy memory from one location to another. Note ''numDwords'' - the size should be given as <code>bytes / 4</code>.
|Copy src to dst (high-level memcpy)
 
|-
 
|DMAECopyMemWait
 
|<code>bool DMAECopyMemWait(void *dst, const void *src, uint32_t size, DMAEEndian endian)</code>
 
|Returns true when all goes normally, return false if a time-out occurred
 
|-
 
|DMAEFillMem
 
|<code>uint64_t DMAEFillMem(void *dst, uint32_t fillData, uint32_t size)</code>
 
|Fill a virtual memory range with "fillData" (also has DMAEFillMemWait version)
 
 
|-
 
|-
|DMAEFillMemPhys
+
|<syntaxhighlight lang="C" enclose="none">OSTime DMAEFillMem(void* dst, unsigned int value, size_t numDwords);</syntaxhighlight>
|<code>uint64_t DMAEFillMemPhys(uint32_t dst_pa, uint32_t fillData, uint32_t size)</code>
+
|Uses DMA to fill memory with a given value. Again, note ''numDwords''.
|Fill a physical memory range with "fillData" (also has DMAEFillMemPhysWait version)
 
 
|}
 
|}
  
==Enumeration==
+
==Enums==
===Semaphore===
 
 
 
 
{| class="wikitable"
 
{| class="wikitable"
 
!Name
 
!Name
!Prototype
+
!Definition
 
 
 
|-
 
|-
|DMAESemaphoreAction
+
|DMAEEndianSwapMode
|
+
|<syntaxhighlight lang="C">
<syntaxhighlight lang="C">
+
typedef enum DMAEEndianSwapMode {
typedef enum _DMAESemaphoreAction {
+
     NONE = 0,
     DMAE_SEMAPHORE_WAIT  = 0x00000000,   ///< Wait before processing next command
+
    SWAP_8_IN_16 = 1,
     DMAE_SEMAPHORE_SIGNAL = 0x00000001,   ///< Signal after all previous work is done
+
     SWAP_8_IN_32 = 2,
} DMAESemaphoreAction;
+
} DMAEEndianSwapMode;
 
</syntaxhighlight>
 
</syntaxhighlight>
 
|}
 
|}
===Endian===
 
  
{| class="wikitable"
+
==See Also==
!Name
+
[https://github.com/decaf-emu/decaf-emu/blob/master/src/libdecaf/src/modules/dmae/dmae_core.cpp Decaf's implementation of the DMAE lib] (source for this page)
!Prototype
 
 
 
|-
 
|DMAEEndian
 
|
 
<syntaxhighlight lang="C">
 
typedef enum DMAEEndian {
 
    DMAE_ENDIAN_NONE  = 0x00000000,  ///< do-nothing
 
    DMAE_ENDIAN_8IN16 = 0x00000001,  ///< 8IN16 swapping mode. Endian swap in 16-bit int buffer.
 
    DMAE_ENDIAN_8IN32 = 0x00000002,  ///< 8IN32 swapping mode. Endian swap in 32-bit int buffer.
 
    DMAE_ENDIAN_8IN64 = 0x00000003,  ///< 8IN64 swapping mode. Endian swap in 64-bit int buffer. /// Directly from the SDK
 
} DMAEEndian;
 
</syntaxhighlight>
 
|}
 

Latest revision as of 03:19, 31 October 2017

dmae.rpl is the system library that provides DMA (Direct Memory Access) functions.

Functions

In the context of the DMAE library; timestamps (as OSTimes) are used to identify operations. They can be used with DMAEWaitDone for synchronisation.

Timing

Prototype Description
OSTime DMAEGetRetiredTimeStamp();
OSTime DMAEGetLastSubmittedTimeStamp(); Returns the last timestamp submitted to the DMAE engine, as an OSTime.
bool DMAEWaitDone(OSTime timestamp); Wait until a given DMA operation is complete.
void DMAESetTimeout(unsigned int timeout); Set the timeout for DMA operations.
unsigned int DMAEGetTimeout(); Gets the current timeout for DMA operations.

Operations

Prototype Description
OSTime DMAECopyMem(void* dst, void* src, size_t numDwords, DMAEEndianSwapMode endian); Uses DMA to copy memory from one location to another. Note numDwords - the size should be given as bytes / 4.
OSTime DMAEFillMem(void* dst, unsigned int value, size_t numDwords); Uses DMA to fill memory with a given value. Again, note numDwords.

Enums

Name Definition
DMAEEndianSwapMode
typedef enum DMAEEndianSwapMode {
    NONE = 0,
    SWAP_8_IN_16 = 1,
    SWAP_8_IN_32 = 2,
} DMAEEndianSwapMode;

See Also

Decaf's implementation of the DMAE lib (source for this page)