#pragma once
/*
* This file is part of open_agb_firm
* Copyright (C) 2021 derrek, profi200
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include
#include "types.h"
#include "mem_map.h"
//#define USE_NEW_CDMA 1
#ifdef ARM11
#ifdef USE_NEW_CDMA
#define DMA330_REGS_BASE (IO_MEM_ARM11_ONLY + 0x6000)
#else
#define DMA330_REGS_BASE (IO_MEM_ARM11_ONLY + 0x0000)
#endif // ifdef USE_NEW_CDMA
#elif ARM9
#define DMA330_REGS_BASE (IO_MEM_ARM9_ONLY + 0xC000)
#endif // ifdef ARM11
typedef struct
{
const vu32 dsr; // 0x000 DMA Manager Status Register.
const vu32 dpc; // 0x004 DMA Program Counter Register (manager).
u8 _0x8[0x18];
vu32 inten; // 0x020 Interrupt Enable Register.
const vu32 int_event_ris; // 0x024 Event-Interrupt Raw Status Register.
const vu32 intmis; // 0x028 Interrupt Status Register.
vu32 intclr; // 0x02C Interrupt Clear Register (write-only).
const vu32 fsrd; // 0x030 Fault Status DMA Manager Register.
const vu32 fsrc; // 0x034 Fault Status DMA Channel Register.
const vu32 ftrd; // 0x038 Fault Type DMA Manager Register.
u8 _0x3c[4];
const vu32 ftr[8]; // 0x040 Fault Type DMA Channel Registers.
u8 _0x60[0xa0];
struct // 0x100
{
const vu32 csr; // 0x0 Channel Status Register.
const vu32 cpc; // 0x4 Channel Program Counter Register.
} chStat[8];
u8 _0x140[0x2c0];
struct // 0x400
{
const vu32 sar; // 0x00 Source Address Register.
const vu32 dar; // 0x04 Destination Address Register.
const vu32 ccr; // 0x08 Channel Control Register.
const vu32 lc0; // 0x0C Loop Counter 0 Register.
const vu32 lc1; // 0x10 Loop Counter 1 Register.
u8 chCtrl_0x14[0xc];
} chCtrl[8];
u8 _0x500[0x800];
const vu32 dbgstatus; // 0xD00 Debug Status Register.
vu32 dbgcmd; // 0xD04 Debug Command Register (write-only).
vu32 dbginst0; // 0xD08 Debug Instruction-0 Register (write-only).
vu32 dbginst1; // 0xD0C Debug Instruction-1 Register (write-only).
u8 _0xd10[0xf0];
const vu32 cr0; // 0xE00 Configuration Register 0.
const vu32 cr1; // 0xE04 Configuration Register 1.
const vu32 cr2; // 0xE08 Configuration Register 2.
const vu32 cr3; // 0xE0C Configuration Register 3.
const vu32 cr4; // 0xE10 Configuration Register 4.
const vu32 crd; // 0xE14 DMA Configuration Register.
u8 _0xe18[0x68];
vu32 wd; // 0xE80 Watchdog Register (r1p0 only).
u8 _0xe84[0x15c];
const vu32 periph_id_0; // Peripheral Identification Register 0.
const vu32 periph_id_1; // Peripheral Identification Register 1.
const vu32 periph_id_2; // Peripheral Identification Register 2.
const vu32 periph_id_3; // Peripheral Identification Register 3.
const vu32 pcell_id_0; // Component Identification Register 0.
const vu32 pcell_id_1; // Component Identification Register 1.
const vu32 pcell_id_2; // Component Identification Register 2.
const vu32 pcell_id_3; // Component Identification Register 3.
} Dma330;
static_assert(offsetof(Dma330, pcell_id_3) == 0xFFC, "Error: Member pcell_id_3 of Dma330 is not at offset 0xFFC!");
ALWAYS_INLINE Dma330* getDma330Regs(void)
{
return (Dma330*)DMA330_REGS_BASE;
}
// REG_DMA330_DSR
#define DSR_WAKE_EVNT_SHIFT (4u)
#define DSR_WAKE_EVNT_MASK (0x1Fu<