Corelink DMA Engines

From 3dbrew
Jump to: navigation, search

XDMA cannot access the ARM9 bootrom at all.

DmaConfig[edit]

Size of struct is 24 bytes.

struct DmaConfig {
    sint8_t channel_sel; // @0 Selects which DMA channel to use: 0-7, -1 = don't care.
    uint8_t endian_swap_size; // @1 Accepted values: 0=none, 2=16bit, 4=32bit, 8=64bit.
    uint8_t flags; // @2 bit0: DST_CFG, bit1: SRC_CFG, bit2: SHALL_BLOCK, bit3: ???, bit6: DST_ALT_CFG, bit7: SRC_ALT_CFG
    uint8_t padding;
    DmaSubConfig dst_cfg;
    DmaSubConfig src_cfg;
}
struct DmaSubConfig {
    sint8_t peripheral_id; // @0 If not *_ALT_CFG set, this must be < 0x1E.
    uint8_t type; // @1 Accepted values: 4=fixed_addr??, 8=increment_addr??, 12=lgy_fb_copy?, 15=userspace_copy?
    sint16_t unk3; // @2 Must be 0 or multiple of 4?
    sint16_t transfer_size?; // @4 Must not be 0 if peripheral_id == 0xFF.
    sint16_t unk4; // @6
    sint16_t transfer_stride?; // @8
}

If SRC_CFG/DST_CFG is set in the flags field, the configuration for src/dst is loaded from src_cfg/dst_cfg respectively. If the *_ALT_CFG flag is set same thing goes, except byte0 of each cfg is forced to 0xFF. ALT_CFG has priority over CFG.

If CFG or ALT_CFG is not set, default configuration is loaded:

.peripheral_id = 0xFF,
.unk2 = 0xF,
.unk3 = 0x80,
.transfer_size = 0,
.unk4 = 0x80,
.unk5 = 0,

Checks suggest that unk2 of DmaSubConfig equalling 4 means NO_INCREMENT (don't increment after read/write).

If SHALL_BLOCK is set, the thread will sleep until the DMA engine is ready. If not set, the SVC will return 0xD04007F0 if the DMA channel is busy.

The generated bytecode starts with a FLUSHP on the peripheral_ids for src/dst (if specified). After that, it always moves 0 into DAR. Then it moves the src/dst addresses into SAR/DAR respectively...

CDMA Peripheral IDs[edit]

ID Module Description
0x2 camera (cam) Camera Port 1
0x3 camera (cam) Camera Port 2
0x4 nwm  ?
0x5 nwm  ?
0x6 camera (y2r) SetSendingY
0x7 camera (y2r) SetSendingU
0x8 camera (y2r) SetSendingV
0x9 camera (y2r) SetSendingYUYV
0xA camera (y2r) SetReceiving
0xB fs HASH
0xD TwlBg LGYFB0/1
0xE TwlBg LGYFB0/1
0x12 mvd  ?
0x13 mvd  ?
0x14 mvd  ?
0x15 mvd  ?
0x16 mvd  ?
0x17 mvd  ?
0x18 mvd  ?
0x19 mvd  ?
0x1A mvd  ?

XDMA Peripheral IDs[edit]

ID Module Description