Skip to content

Commit 88c7907

Browse files
committed
Generate device tree source upon configurations
1 parent 0a00e1c commit 88c7907

File tree

3 files changed

+28
-88
lines changed

3 files changed

+28
-88
lines changed

Makefile

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ ENABLE_VIRTIONET := 0
2020
endif
2121
$(call set-feature, VIRTIONET)
2222

23-
# device tree
24-
# TODO: generate device tree source upon configurations
25-
ifeq ($(UNAME_S),Linux)
26-
MINIMAL_DTS = minimal-virtio.dts
27-
else
28-
MINIMAL_DTS = minimal.dts
29-
endif
30-
3123
BIN = semu
3224
all: $(BIN) minimal.dtb
3325

@@ -51,9 +43,19 @@ $(BIN): $(OBJS)
5143

5244
DTC ?= dtc
5345

54-
minimal.dtb: $(MINIMAL_DTS)
46+
# GNU Make treats the space character as a separator. The only way to handle
47+
# filtering a pattern with space characters in a Makefile is by replacing spaces
48+
# with another character that is guaranteed not to appear in the variable value.
49+
# For instance, one can choose a character like '^' that is known not to be
50+
# present in the variable value.
51+
# Reference: https://stackoverflow.com/questions/40886386
52+
E :=
53+
S := $E $E
54+
minimal.dtb: minimal.dts
5555
$(VECHO) " DTC\t$@\n"
56-
$(Q)$(DTC) $< > $@
56+
$(Q)$(CC) -nostdinc -E -P -x assembler-with-cpp -undef \
57+
$(subst ^,$S,$(filter -D^SEMU_FEATURE_%, $(subst -D$(S)SEMU_FEATURE,-D^SEMU_FEATURE,$(CFLAGS)))) $< \
58+
| $(DTC) - > $@
5759

5860
# Rules for downloading prebuilt Linux kernel image
5961
include mk/external.mk

minimal-virtio.dts

Lines changed: 0 additions & 78 deletions
This file was deleted.

minimal.dts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,21 @@
6262
no-loopback-test;
6363
clock-frequency = <5000000>; /* the baudrate divisor is ignored */
6464
};
65+
66+
#if SEMU_FEATURE_VIRTIONET
67+
net0: virtio@4100000 {
68+
compatible = "virtio,mmio";
69+
reg = <0x4100000 0x100000>;
70+
interrupts = <2>;
71+
};
72+
#endif
73+
74+
#if SEMU_FEATURE_VIRTIOBLK
75+
blk0: virtio@4200000 {
76+
compatible = "virtio,mmio";
77+
reg = <0x4200000 0x200>;
78+
interrupts = <3>;
79+
};
80+
#endif
6581
};
6682
};

0 commit comments

Comments
 (0)