1# Makefile to generate or copy the latest register definitions
2# and related datastructures and helpermacros.
3# The official place for these files is at:
4RELEASE ?= r1_alfa5
5OFFICIAL_INCDIR = /n/asic/projects/guinness/releases/$(RELEASE)/design/top/sw/include/
6
7# which is updated on each new release.
8INCL_ASMFILES   =
9INCL_FILES      = ata_defs.h
10INCL_FILES     += bif_core_defs.h
11INCL_ASMFILES  += bif_core_defs_asm.h
12INCL_FILES     += bif_slave_defs.h
13#INCL_FILES     += bif_slave_ext_defs.h
14INCL_FILES     += config_defs.h
15INCL_ASMFILES  += config_defs_asm.h
16INCL_FILES     += cpu_vect.h
17#INCL_FILES     += cris_defs.h
18#INCL_FILES     += cris_supp_reg.h # In handcrafted supp_reg.h
19INCL_FILES     += dma.h
20INCL_FILES     += dma_defs.h
21INCL_FILES     += eth_defs.h
22INCL_FILES     += extmem_defs.h
23INCL_FILES     += gio_defs.h
24INCL_ASMFILES  += gio_defs_asm.h
25INCL_FILES     += intr_vect.h
26INCL_FILES     += intr_vect_defs.h
27INCL_ASMFILES  += intr_vect_defs_asm.h
28INCL_FILES     += marb_bp_defs.h
29INCL_FILES     += marb_defs.h
30INCL_ASMFILES  += mmu_defs_asm.h
31#INCL_FILES     += mmu_supp_reg.h # In handcrafted supp_reg.h
32#INCL_FILES     += par_defs.h # No useful content
33INCL_FILES     += pinmux_defs.h
34INCL_FILES     += reg_map.h
35INCL_ASMFILES  += reg_map_asm.h
36INCL_FILES     += reg_rdwr.h
37INCL_FILES     += ser_defs.h
38#INCL_FILES     += spec_reg.h # In handcrafted supp_reg.h
39INCL_FILES     += sser_defs.h
40INCL_FILES     += strcop_defs.h
41#INCL_FILES     += strcop.h # Where is this?
42INCL_FILES     += strmux_defs.h
43#INCL_FILES     += supp_reg.h # Handcrafted instead
44INCL_FILES     += timer_defs.h
45
46REGDESC =
47REGDESC += $(BASEDIR)/io/ata/rtl/ata_regs.r
48REGDESC += $(BASEDIR)/io/bif/rtl/bif_core_regs.r
49REGDESC += $(BASEDIR)/io/bif/rtl/bif_slave_regs.r
50#REGDESC += $(BASEDIR)/io/bif/sw/bif_slave_ext_regs.r
51REGDESC += $(DESIGNDIR)/top/rtl/config_regs.r
52REGDESC += $(BASEDIR)/mod/dma_common/rtl/dma_regdes.r
53REGDESC += $(BASEDIR)/io/eth/rtl/eth_regs.r
54REGDESC += $(BASEDIR)/io/bif/mod/extmem/extmem_regs.r
55REGDESC += $(DESIGNDIR)/gio/rtl/gio_regs.r
56REGDESC += $(BASEDIR)/core/cpu/intr_vect/rtl/guinness/ivmask.config.r
57REGDESC += $(BASEDIR)/core/memarb/rtl/guinness/marb_top.r
58REGDESC += $(BASEDIR)/core/cpu/mmu/doc/mmu_regs.r
59#REGDESC += $(BASEDIR)/io/par_port/rtl/par_regs.r
60REGDESC += $(BASEDIR)/io/pinmux/rtl/guinness/pinmux_regs.r
61REGDESC += $(BASEDIR)/io/ser/rtl/ser_regs.r
62REGDESC += $(BASEDIR)/core/strcop/rtl/strcop_regs.r
63REGDESC += $(BASEDIR)/io/strmux/rtl/guinness/strmux_regs.r
64REGDESC += $(BASEDIR)/io/timer/rtl/timer_regs.r
65#REGDESC += $(BASEDIR)/io/usb/usb1_1/rtl/usb_regs.r
66
67
68BASEDIR = /n/asic/design
69DESIGNDIR = /n/asic/projects/guinness/design
70RDES2C = /n/asic/bin/rdes2c
71RDES2C = /n/asic/design/tools/rdesc/rdes2c
72RDES2INTR = /n/asic/design/tools/rdesc/rdes2intr
73RDES2TXT = /n/asic/design/tools/rdesc/rdes2txt
74
75## all    - Just print help - you probably want to do 'make gen'
76all: help
77
78# Disable implicit rule that may generate deleted files from RCS/ directory.
79%.r:
80
81%.h:
82
83## help   - This help
84help:
85	@grep '^## ' Makefile
86
87## gen    - Generate include files
88gen: $(INCL_FILES) $(INCL_ASMFILES)
89
90ata_defs.h: $(BASEDIR)/io/ata/rtl/ata_regs.r
91	$(RDES2C) $<
92config_defs.h: $(DESIGNDIR)/top/rtl/config_regs.r
93	$(RDES2C) $<
94config_defs_asm.h: $(DESIGNDIR)/top/rtl/config_regs.r
95	$(RDES2C) -asm $<
96# Can't generate cpu_vect.h yet
97#cpu_vect.h: $(DESIGNDIR)/top/rtl/cpu_vect.r # ????
98#	$(RDES2INTR) $<
99cpu_vect.h: $(OFFICIAL_INCDIR)cpu_vect.h
100	cat $< | sed -e 's/\$$Id\:/id\:/g' >$@
101dma_defs.h: $(BASEDIR)/core/dma/rtl/common/dma_regdes.r
102	$(RDES2C) $<
103$(BASEDIR)/core/dma/sw/dma.h:
104dma.h: $(BASEDIR)/core/dma/sw/dma.h
105	cat $< | sed -e 's/\$$Id\:/id\:/g' >$@
106eth_defs.h: $(BASEDIR)/io/eth/rtl/eth_regs.r
107	$(RDES2C) $<
108extmem_defs.h: $(BASEDIR)/io/bif/mod/extmem/extmem_regs.r
109	$(RDES2C) $<
110gio_defs.h: $(DESIGNDIR)/gio/rtl/gio_regs.r
111	$(RDES2C) $<
112intr_vect_defs.h: $(BASEDIR)/core/cpu/intr_vect/rtl/guinness/ivmask.config.r
113	$(RDES2C) $<
114intr_vect_defs_asm.h: $(BASEDIR)/core/cpu/intr_vect/rtl/guinness/ivmask.config.r
115	$(RDES2C) -asm $<
116# Can't generate intr_vect.h yet
117#intr_vect.h: $(BASEDIR)/core/cpu/intr_vect/rtl/guinness/ivmask.config.r
118#	$(RDES2INTR) $<
119intr_vect.h: $(OFFICIAL_INCDIR)intr_vect.h
120	cat $< | sed -e 's/\$$Id\:/id\:/g' >$@
121mmu_defs_asm.h: $(BASEDIR)/core/cpu/mmu/doc/mmu_regs.r
122	$(RDES2C) -asm $<
123par_defs.h: $(BASEDIR)/io/par_port/rtl/par_regs.r
124	$(RDES2C) $<
125
126# From /n/asic/projects/guinness/design/
127reg_map.h: $(DESIGNDIR)/top/rtl/global.rmap $(DESIGNDIR)/top/mod/modreg.rmap
128	$(RDES2C) -base 0xb0000000 $^
129reg_map_asm.h: $(DESIGNDIR)/top/rtl/global.rmap $(DESIGNDIR)/top/mod/modreg.rmap
130	$(RDES2C) -base 0xb0000000 -asm -outfile $@ $^
131
132reg_rdwr.h: $(DESIGNDIR)/top/sw/include/reg_rdwr.h
133	cat $< | sed -e 's/\$$Id\:/id\:/g' >$@
134
135ser_defs.h: $(BASEDIR)/io/ser/rtl/ser_regs.r
136	$(RDES2C) $<
137strcop_defs.h: $(BASEDIR)/core/strcop/rtl/strcop_regs.r
138	$(RDES2C) $<
139strcop.h: $(BASEDIR)/core/strcop/rtl/strcop.h
140	cat $< | sed -e 's/\$$Id\:/id\:/g' >$@
141strmux_defs.h: $(BASEDIR)/io/strmux/rtl/guinness/strmux_regs.r
142	$(RDES2C) $<
143timer_defs.h: $(BASEDIR)/io/timer/rtl/timer_regs.r
144	$(RDES2C) $<
145usb_defs.h: $(BASEDIR)/io/usb/usb1_1/rtl/usb_regs.r
146	$(RDES2C) $<
147
148## copy   - Copy files from official location
149copy:
150	@for HFILE in $(INCL_FILES); do \
151		echo "  $$HFILE"; \
152		cat $(OFFICIAL_INCDIR)$$HFILE | sed -e 's/\$$Id\:/id\:/g' > $$HFILE; \
153	done
154	@for HFILE in $(INCL_ASMFILES); do \
155		echo "  $$HFILE"; \
156		cat $(OFFICIAL_INCDIR)asm/$$HFILE | sed -e 's/\$$Id\:/id\:/g' > $$HFILE; \
157	done
158## ls_official - List official location
159ls_official:
160	(cd $(OFFICIAL_INCDIR); ls -l *.h )
161
162## diff_official - Diff current directory with official location
163diff_official:
164	diff . $(OFFICIAL_INCDIR)
165
166## doc    - Generate .axw files from register description.
167doc: $(REGDESC)
168	for RDES in $^; do \
169		$(RDES2TXT) $$RDES; \
170	done
171
172.PHONY: axw
173## %.axw  - Generate the specified .axw file (doesn't work for all files
174##          due to inconsistent naming ir .r files.
175%.axw: axw
176	@for RDES in $(REGDESC); do \
177		if echo "$$RDES" | grep $* ; then \
178		  $(RDES2TXT) $$RDES; \
179		fi \
180	done
181
182.PHONY: clean
183## clean  - Remove .h files and .axw files.
184clean:
185	rm -rf $(INCL_FILES) *.axw
186
187