# MI_SendGXCommand*

## Syntax

  `#include <nitro/mi.h>`
  `void MI_SendGXCommand( u32 dmaNo, const void* src, u32 commandLength );
  void MI_SendGXCommandAsync( u32 dmaNo, const void* src, u32 commandLength,
  MIDmaCallback callback, void* arg );`
  `
  void MI_SendGXCommandAsyncFast( u32 dmaNo, const void* src, u32 commandLength,
  MIDmaCallback callback, void* arg );`

## Arguments

dmaNo | DMA channel used.
src | The transfer source address.
commandLength | Transfer command size
callback | Callback when DMA ends.
arg | Callback argument when DMA ends.

## Return Values

None.

## Description

This function uses DMA to send a display list (GX command string) to command FIFO. The transfer source address must be 4-byte aligned.

The synchronous version of `MI_SendGXCommand()` waits for DMA to end inside the function. The asynchronous version of `MI_SendGXCommandAsync()` and `MI_SendGXCommandAsFast()` call `callback` when DMA ends. The callback is an `MIDmaCallback` type function (a `void`–type function that takes one `void*` argument). `callback` is called from the system DMA interrupt handler and therefore is called while interrupts are prohibited.

The difference between `MI_SendGXCommandAsync()` and `MI_SendGXCommandAsyncFast()`:
`MI_SendGXCommandAsync()` does not use the Geometry transfer DMA but uses only the usual synchronous DMA. A small amount of DMA is performed by using the interrupt that is generated when GXFIFO is less than half. `MI_SendGXCommandAsyncFast()` uses the Geometry transfer DMA, so that DMA starts automatically when GXFIFO becomes low. Note that multiple automatic DMAs cannot be started simultaneously because of hardware restrictions. However, the hardware allows the simultaneous startup of multipl automatic DMAs of the same type.

With TWL-SDK, exclusive processing is not performed with the `MI_SendGXCommandAsync*` functions and other `G3_`-based APIs because the execution speed of the graphics command has been prioritized. Therefore, we cannot guarantee correct operation if the GX command is written directly to command FIFO by a `G3_` function while the GX command is being transferred by `MI_SendGXCommandAsync*()`. It is strongly recommended that you pay particular attention in avoiding such a situation on the API call side.

###
About the DMA to Be Used

Although this function uses the old DMA, the function that performs the same operation using the new DMA is `MI_SendNDmaGXCommand*`. The `MI_SendNDmaGXCommand*` and `MI_SendGXCommand*` functions cannot be used at the same time.

## Internal Operation

Uses the following IO registers: DMAn source register (0x40000B0 + 12n), DMAn destination register (0x40000B4 + 12n), and DMAn control register (0x40000B8 + 12n). (n is the DMA channel used.) The `GXFIFO(0x4000400)` IO register is also accessed.

## See Also

`MI_DmaCopy*
G3_BeginMakeDL
G3_EndMakeDL`
`MI_SendNDmaGXCommand*`

## Revision History

2008/10/16 Added information about functions that use the new DMA.
2005/03/08 Standardized the Japanese term for "interrupt."
2004/12/22 Added a description about calling a callback.
2004/08/26 Added description for `MI_SendGXCommandAsyncFast`.
2004/07/18 Added description when the callback is NULL.
2003/12/01 Initial version.

CONFIDENTIAL