Skip to content

Commit 00c042c

Browse files
committed
build(sw): derive iDMA register header from PeakRDL c-header
iDMA dropped the hjson register flow in its SystemRDL/PeakRDL migration, so regtool can no longer generate regs/idma.h. Consume iDMA's generated PeakRDL c-header instead and port dma.h off the regtool macro names to offsetof() on the generated struct plus the PeakRDL bit-position macros. Requires an iDMA version that ships the c-header target (pulp-platform/iDMA#144).
1 parent 55650af commit 00c042c

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

sw/include/dif/dma.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,25 @@
88
#pragma once
99

1010
#include <stdint.h>
11+
#include <stddef.h>
1112
#include "regs/idma.h"
1213
#include "params.h"
1314

14-
#define DMA_SRC_ADDR(BASE) (void *)((uint8_t *)BASE + IDMA_REG64_2D_SRC_ADDR_LOW_REG_OFFSET)
15-
#define DMA_DST_ADDR(BASE) (void *)((uint8_t *)BASE + IDMA_REG64_2D_DST_ADDR_LOW_REG_OFFSET)
16-
#define DMA_NUMBYTES_ADDR(BASE) (void *)((uint8_t *)BASE + IDMA_REG64_2D_LENGTH_LOW_REG_OFFSET)
17-
#define DMA_CONF_ADDR(BASE) (void *)((uint8_t *)BASE + IDMA_REG64_2D_CONF_REG_OFFSET)
18-
#define DMA_STATUS_ADDR(BASE) (void *)((uint8_t *)BASE + IDMA_REG64_2D_STATUS_0_REG_OFFSET)
19-
#define DMA_NEXTID_ADDR(BASE) (void *)((uint8_t *)BASE + IDMA_REG64_2D_NEXT_ID_0_REG_OFFSET)
20-
#define DMA_DONE_ADDR(BASE) (void *)((uint8_t *)BASE + IDMA_REG64_2D_DONE_ID_0_REG_OFFSET)
15+
#define DMA_SRC_ADDR(BASE) (void *)((uint8_t *)BASE + offsetof(idma_reg64_2d_t, src_addr))
16+
#define DMA_DST_ADDR(BASE) (void *)((uint8_t *)BASE + offsetof(idma_reg64_2d_t, dst_addr))
17+
#define DMA_NUMBYTES_ADDR(BASE) (void *)((uint8_t *)BASE + offsetof(idma_reg64_2d_t, length))
18+
#define DMA_CONF_ADDR(BASE) (void *)((uint8_t *)BASE + offsetof(idma_reg64_2d_t, conf))
19+
#define DMA_STATUS_ADDR(BASE) (void *)((uint8_t *)BASE + offsetof(idma_reg64_2d_t, status))
20+
#define DMA_NEXTID_ADDR(BASE) (void *)((uint8_t *)BASE + offsetof(idma_reg64_2d_t, next_id))
21+
#define DMA_DONE_ADDR(BASE) (void *)((uint8_t *)BASE + offsetof(idma_reg64_2d_t, done_id))
2122
#define DMA_SRC_STRIDE_ADDR(BASE) \
22-
(void *)((uint8_t *)BASE + IDMA_REG64_2D_SRC_STRIDE_2_LOW_REG_OFFSET)
23+
(void *)((uint8_t *)BASE + offsetof(idma_reg64_2d_t, dim[0].src_stride))
2324
#define DMA_DST_STRIDE_ADDR(BASE) \
24-
(void *)((uint8_t *)BASE + IDMA_REG64_2D_DST_STRIDE_2_LOW_REG_OFFSET)
25-
#define DMA_NUM_REPS_ADDR(BASE) (void *)((uint8_t *)BASE + IDMA_REG64_2D_REPS_2_LOW_REG_OFFSET)
25+
(void *)((uint8_t *)BASE + offsetof(idma_reg64_2d_t, dim[0].dst_stride))
26+
#define DMA_NUM_REPS_ADDR(BASE) (void *)((uint8_t *)BASE + offsetof(idma_reg64_2d_t, dim[0].reps))
2627
#define DMA_CONF_DECOUPLE_NONE (0)
27-
#define DMA_CONF_DECOUPLE_AW (1 << IDMA_REG64_2D_CONF_DECOUPLE_AW_BIT)
28-
#define DMA_CONF_DECOUPLE_RW (1 << IDMA_REG64_2D_CONF_DECOUPLE_RW_BIT)
28+
#define DMA_CONF_DECOUPLE_AW (1 << IDMA_REG64_2D__CONF__DECOUPLE_AW_bp)
29+
#define DMA_CONF_DECOUPLE_RW (1 << IDMA_REG64_2D__CONF__DECOUPLE_RW_bp)
2930
#define DMA_CONF_DECOUPLE_ALL (DMA_CONF_DECOUPLE_AW | DMA_CONF_DECOUPLE_RW)
3031

3132
#define X(NAME, BASE_ADDR) \
@@ -83,7 +84,7 @@
8384
*(NAME##_dma_src_ptr()) = (uint64_t)src; \
8485
*(NAME##_dma_dst_ptr()) = (uint64_t)dst; \
8586
*(NAME##_dma_num_bytes_ptr()) = size; \
86-
*(NAME##_dma_conf_ptr()) = conf | (1 << IDMA_REG64_2D_CONF_ENABLE_ND_BIT); \
87+
*(NAME##_dma_conf_ptr()) = conf | (1 << IDMA_REG64_2D__CONF__ENABLE_ND_bp); \
8788
*(NAME##_dma_src_stride_ptr()) = src_stride; \
8889
*(NAME##_dma_dst_stride_ptr()) = dst_stride; \
8990
*(NAME##_dma_num_reps_ptr()) = num_reps; \

sw/sw.mk

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,17 @@ endef
7878

7979
$(eval $(call chs_sw_gen_hdr_rule,clint,$(CLINTROOT)/src/clint.hjson $(CLINTROOT)/.generated))
8080
$(eval $(call chs_sw_gen_hdr_rule,axi_vga,$(AXI_VGA_ROOT)/data/axi_vga.hjson $(AXI_VGA_ROOT)/.generated))
81-
$(eval $(call chs_sw_gen_hdr_rule,idma,$(IDMA_ROOT)/target/rtl/idma_reg64_2d.hjson))
8281
$(eval $(call chs_sw_gen_hdr_rule,axi_llc,$(CHS_LLC_DIR)/data/axi_llc_regs.hjson))
8382
$(eval $(call chs_sw_gen_hdr_rule,axi_rt,$(AXIRTROOT)/src/regs/axi_rt.hjson $(AXIRTROOT)/.generated))
8483

84+
# iDMA migrated to SystemRDL/PeakRDL: consume its generated HAL C header (built via idma.mk)
85+
.PRECIOUS: $(CHS_SW_DIR)/include/regs/idma.h
86+
CHS_SW_GEN_HDRS += $(CHS_SW_DIR)/include/regs/idma.h
87+
88+
$(CHS_SW_DIR)/include/regs/idma.h: $(IDMA_ROOT)/target/hal/regs/idma_reg64_2d_reg.h
89+
@mkdir -p $(dir $@)
90+
cp $< $@
91+
8592
.PRECIOUS: $(CHS_SW_DIR)/include/regs/cheshire.h
8693
CHS_SW_GEN_HDRS += $(CHS_SW_DIR)/include/regs/cheshire.h
8794

0 commit comments

Comments
 (0)