Skip to content

Commit aed1cf2

Browse files
committed
Add GD32 DMA component
1 parent 78687ce commit aed1cf2

File tree

2 files changed

+81
-1
lines changed

2 files changed

+81
-1
lines changed

qiling/hw/dma/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
44
#
55

6-
from .stm32f4xx_dma import STM32F4xxDma
6+
from .stm32f4xx_dma import STM32F4xxDma
7+
from .gd32vf1xx_dma import GD32VF1xxDma

qiling/hw/dma/gd32vf1xx_dma.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import ctypes
2+
3+
from qiling.hw.peripheral import QlPeripheral
4+
5+
6+
class GD32VF1xxDma(QlPeripheral):
7+
class Type(ctypes.Structure):
8+
""" DMA controller
9+
"""
10+
11+
_fields_ = [
12+
("INTF" , ctypes.c_uint32), # Address offset: 0x0, Interrupt flag register
13+
("INTC" , ctypes.c_uint32), # Address offset: 0x04, Interrupt flag clear register
14+
("CH0CTL" , ctypes.c_uint32), # Address offset: 0x08, Channel 0 control register
15+
("CH0CNT" , ctypes.c_uint32), # Address offset: 0x0C, Channel 0 counter register
16+
("CH0PADDR", ctypes.c_uint32), # Address offset: 0x10, Channel 0 peripheral base address register
17+
("CH0MADDR", ctypes.c_uint32), # Address offset: 0x14, Channel 0 memory base address register
18+
("CH1CTL" , ctypes.c_uint32), # Address offset: 0x1C, Channel 1 control register
19+
("CH1CNT" , ctypes.c_uint32), # Address offset: 0x20, Channel 1 counter register
20+
("CH1PADDR", ctypes.c_uint32), # Address offset: 0x24, Channel 1 peripheral base address register
21+
("CH1MADDR", ctypes.c_uint32), # Address offset: 0x28, Channel 1 memory base address register
22+
("CH2CTL" , ctypes.c_uint32), # Address offset: 0x30, Channel 2 control register
23+
("CH2CNT" , ctypes.c_uint32), # Address offset: 0x34, Channel 2 counter register
24+
("CH2PADDR", ctypes.c_uint32), # Address offset: 0x38, Channel 2 peripheral base address register
25+
("CH2MADDR", ctypes.c_uint32), # Address offset: 0x3C, Channel 2 memory base address register
26+
("CH3CTL" , ctypes.c_uint32), # Address offset: 0x44, Channel 3 control register
27+
("CH3CNT" , ctypes.c_uint32), # Address offset: 0x48, Channel 3 counter register
28+
("CH3PADDR", ctypes.c_uint32), # Address offset: 0x4C, Channel 3 peripheral base address register
29+
("CH3MADDR", ctypes.c_uint32), # Address offset: 0x50, Channel 3 memory base address register
30+
("CH4CTL" , ctypes.c_uint32), # Address offset: 0x58, Channel 4 control register
31+
("CH4CNT" , ctypes.c_uint32), # Address offset: 0x5C, Channel 4 counter register
32+
("CH4PADDR", ctypes.c_uint32), # Address offset: 0x60, Channel 4 peripheral base address register
33+
("CH4MADDR", ctypes.c_uint32), # Address offset: 0x64, Channel 4 memory base address register
34+
("CH5CTL" , ctypes.c_uint32), # Address offset: 0x6C, Channel 5 control register
35+
("CH5CNT" , ctypes.c_uint32), # Address offset: 0x70, Channel 5 counter register
36+
("CH5PADDR", ctypes.c_uint32), # Address offset: 0x74, Channel 5 peripheral base address register
37+
("CH5MADDR", ctypes.c_uint32), # Address offset: 0x78, Channel 5 memory base address register
38+
("CH6CTL" , ctypes.c_uint32), # Address offset: 0x80, Channel 6 control register
39+
("CH6CNT" , ctypes.c_uint32), # Address offset: 0x84, Channel 6 counter register
40+
("CH6PADDR", ctypes.c_uint32), # Address offset: 0x88, Channel 6 peripheral base address register
41+
("CH6MADDR", ctypes.c_uint32), # Address offset: 0x8C, Channel 6 memory base address register
42+
]
43+
44+
def __init__(self, ql, label):
45+
super().__init__(ql, label)
46+
47+
self.dma = self.struct(
48+
INTF = 0x00000000,
49+
INTC = 0x00000000,
50+
CH0CTL = 0x00000000,
51+
CH0CNT = 0x00000000,
52+
CH0PADDR = 0x00000000,
53+
CH0MADDR = 0x00000000,
54+
CH1CTL = 0x00000000,
55+
CH1CNT = 0x00000000,
56+
CH1PADDR = 0x00000000,
57+
CH1MADDR = 0x00000000,
58+
CH2CTL = 0x00000000,
59+
CH2CNT = 0x00000000,
60+
CH2PADDR = 0x00000000,
61+
CH2MADDR = 0x00000000,
62+
CH3CTL = 0x00000000,
63+
CH3CNT = 0x00000000,
64+
CH3PADDR = 0x00000000,
65+
CH3MADDR = 0x00000000,
66+
CH4CTL = 0x00000000,
67+
CH4CNT = 0x00000000,
68+
CH4PADDR = 0x00000000,
69+
CH4MADDR = 0x00000000,
70+
CH5CTL = 0x00000000,
71+
CH5CNT = 0x00000000,
72+
CH5PADDR = 0x00000000,
73+
CH5MADDR = 0x00000000,
74+
CH6CTL = 0x00000000,
75+
CH6CNT = 0x00000000,
76+
CH6PADDR = 0x00000000,
77+
CH6MADDR = 0x00000000,
78+
)
79+

0 commit comments

Comments
 (0)