Skip to content

Commit e72651a

Browse files
authored
Remove some unnecessary headers (#110)
1 parent 324d615 commit e72651a

11 files changed

+247
-715
lines changed

hw/arm/prusa/prusa-mini.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@
2929
#include "hw/irq.h"
3030
#include "hw/qdev-properties.h"
3131
#include "qemu/error-report.h"
32-
#include "stm32f407/stm32f407_soc.h"
3332
#include "hw/arm/boot.h"
3433
#include "hw/ssi/ssi.h"
3534
#include "hw/loader.h"
3635
#include "utility/ArgHelper.h"
3736
#include "sysemu/runstate.h"
3837
#include "parts/dashboard_types.h"
38+
#include "stm32_common/stm32_shared.h"
39+
#include "stm32_common/stm32_common.h"
40+
#include "stm32_common/stm32_types.h"
41+
#include "hw/arm/armv7m.h"
3942

4043
#define BOOTLOADER_IMAGE "bootloader.bin"
4144

hw/arm/prusa/stm32_chips/stm32f407xx.h

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include "../stm32f407/stm32f4xx_adc.h"
3232
#include "../stm32f407/stm32f4xx_adcc.h"
3333
#include "../stm32f407/stm32f2xx_crc.h"
34-
#include "../stm32_common/stm32_f2xx_f4xx_dma.h"
3534
#include "../stm32f407/stm32f2xx_gpio.h"
3635
#include "../stm32f407/stm32f2xx_i2c.h"
3736
#include "../stm32f407/stm32f4xx_iwdg.h"

hw/arm/prusa/stm32_common/stm32_f2xx_f4xx_dma.c

+114-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
- F4xx series,
55
- F2xx series (? - it's modelled off the Pebble QEMU version which supports this.),
66
7-
Copyright 2021 VintagePC <https://github.com/vintagepc/>
7+
Copyright 2021-2 VintagePC <https://github.com/vintagepc/>
88
99
This file is part of Mini404.
1010
@@ -22,11 +22,123 @@
2222
along with Mini404. If not, see <http://www.gnu.org/licenses/>.
2323
*/
2424

25-
#include "stm32_f2xx_f4xx_dma.h"
25+
#include "qemu/osdep.h"
2626
#include "hw/irq.h"
2727
#include "migration/vmstate.h"
2828
#include "sysemu/dma.h"
2929
#include "qemu/log.h"
30+
#include "hw/sysbus.h"
31+
#include "qemu/timer.h"
32+
#include "exec/memory.h"
33+
#include "stm32_common.h"
34+
#include "stm32_shared.h"
35+
36+
#define STM32_F2xx_DMA_MAX_CHAN 8
37+
#define STM32_F2xx_DMA_CHAN_REGS 6
38+
39+
#define R_DMA_MAX (4+(STM32_F2xx_DMA_MAX_CHAN*STM32_F2xx_DMA_CHAN_REGS))
40+
41+
OBJECT_DECLARE_SIMPLE_TYPE(STM32F2XX_STRUCT_NAME(Dma), STM32F4xx_DMA);
42+
43+
#define _STM32_DMA_INT_BITSET(chan) \
44+
REG_B32(_JOIN2R(FEIF,chan)); \
45+
REG_R(1); \
46+
REG_B32(_JOIN2R(DMEIF,chan)); \
47+
REG_B32(_JOIN2R(TEIF,chan)); \
48+
REG_B32(_JOIN2R(HTIF,chan)); \
49+
REG_B32(_JOIN2R(TCIF,chan));
50+
51+
52+
REGDEF_BLOCK_BEGIN()
53+
_STM32_DMA_INT_BITSET(0)
54+
_STM32_DMA_INT_BITSET(1)
55+
REG_R(4);
56+
_STM32_DMA_INT_BITSET(2)
57+
_STM32_DMA_INT_BITSET(3)
58+
REG_R(4);
59+
REGDEF_BLOCK_END(dma, low_int)
60+
61+
REGDEF_BLOCK_BEGIN()
62+
_STM32_DMA_INT_BITSET(4)
63+
_STM32_DMA_INT_BITSET(5)
64+
REG_R(4);
65+
_STM32_DMA_INT_BITSET(6)
66+
_STM32_DMA_INT_BITSET(7)
67+
REG_R(4);
68+
REGDEF_BLOCK_END(dma, high_int)
69+
70+
#undef _STM32_DMA_INT_BITSET
71+
72+
REGDEF_BLOCK_BEGIN()
73+
REG_B32(EN);
74+
REG_B32(DMEIE);
75+
REG_B32(TEIE);
76+
REG_B32(HTIE);
77+
REG_B32(TCIE);
78+
REG_B32(PFCTRL);
79+
REG_K32(DIR,2);
80+
REG_B32(CIRC);
81+
REG_B32(PINC);
82+
REG_B32(MINC);
83+
REG_K32(PSIZE,2);
84+
REG_K32(MSIZE,2);
85+
REG_B32(PINCOS);
86+
REG_K32(PL,2);
87+
REG_B32(DBM);
88+
REG_B32(CT);
89+
REG_R(1);
90+
REG_K32(PBURST,2);
91+
REG_K32(MBURST,2);
92+
REG_K32(CHSEL,3);
93+
REG_R(4);
94+
REGDEF_BLOCK_END(dma, sxcr)
95+
96+
REGDEF_BLOCK_BEGIN()
97+
REG_K32(FTH,2);
98+
REG_B32(DMDIS);
99+
REG_K32(FS,3);
100+
REG_R(1);
101+
REG_B32(FEIE);
102+
REG_R(24);
103+
REGDEF_BLOCK_END(dma, sxfcr)
104+
105+
#define _STM32_DMA_CHAN_BLK(x) \
106+
REGDEF_NAME(dma, sxcr) _JOIN2R(SCR,x); \
107+
REG_S32(NDTR, 16) _JOIN2R(SNDTR,x); \
108+
uint32_t _JOIN2R(SPAR,x); \
109+
uint32_t _JOIN2R(SM0AR,x); \
110+
uint32_t _JOIN2R(SM1AR,x); \
111+
REGDEF_NAME(dma, sxfcr) _JOIN2R(SFCR,x);
112+
113+
114+
115+
typedef struct STM32F2XX_STRUCT_NAME(Dma) {
116+
STM32Peripheral parent;
117+
MemoryRegion iomem;
118+
119+
union {
120+
struct {
121+
REGDEF_NAME(dma, low_int) LISR; //0x00
122+
REGDEF_NAME(dma, high_int) HISR; //0x04
123+
REGDEF_NAME(dma, low_int) LIFCR; //0x08
124+
REGDEF_NAME(dma, high_int) HIFCR; //0x0C
125+
_STM32_DMA_CHAN_BLK(0) //0x10 - 0x24
126+
_STM32_DMA_CHAN_BLK(1) //0x28 - 0x3C
127+
_STM32_DMA_CHAN_BLK(2) //0x40 - 0x54
128+
_STM32_DMA_CHAN_BLK(3) //0x58 - 0x6C
129+
_STM32_DMA_CHAN_BLK(4) //0x70 - 0x84
130+
_STM32_DMA_CHAN_BLK(5) //0x88 - 0x9C
131+
_STM32_DMA_CHAN_BLK(6) //0xA0 - 0xB4
132+
_STM32_DMA_CHAN_BLK(7) //0xB8 - 0xCC
133+
} defs;
134+
uint32_t raw[R_DMA_MAX];
135+
} regs;
136+
137+
uint32_t original_ndtrs[STM32_F2xx_DMA_MAX_CHAN];
138+
139+
qemu_irq irq[STM32_F2xx_DMA_MAX_CHAN];
140+
141+
} STM32F2XX_STRUCT_NAME(Dma);
30142

31143
enum reg_index {
32144
RI_LISR,
@@ -484,4 +596,3 @@ stm32_f2xx_f4xx_dma_register_types(void)
484596
}
485597

486598
type_init(stm32_f2xx_f4xx_dma_register_types)
487-

hw/arm/prusa/stm32_common/stm32_f2xx_f4xx_dma.h

-146
This file was deleted.

hw/arm/prusa/stm32_common/stm32_shared.h

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ enum STM32_PERIPHS {
121121
STM32_P_GPIO_END = STM32_P_GPIOK + 1U,
122122
STM32_P_ADC_BEGIN = STM32_P_ADC1,
123123
STM32_P_ADC_END = STM32_P_ADC3 + 1U,
124+
STM32_P_USART_BEGIN = STM32_P_UART1,
125+
STM32_P_USART_END = STM32_P_UART8 + 1U,
124126
};
125127
#undef _P
126128

0 commit comments

Comments
 (0)