Skip to contentSkip to conversation

Move device tree files in a subdir in pc-bios

PATCH Superseded BALATON Zoltan 2 participants 5 messages Mar 29, 2025 – Mar 31, 2025 Arm/Amlogic Meson SoC support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Move device tree files in a subdir in pc-bios

Simple series doing what the subject says.

BALATON Zoltan (2):
system/datadir: Add new type constant for DTB files
pc-bios: Move device tree files in their own subdir

 MAINTAINERS                                |   2 +-
 hw/microblaze/boot.c                       |   2 +-
 hw/ppc/ppc440_bamboo.c                     |   2 +-
 hw/ppc/sam460ex.c                          |   2 +-
 hw/ppc/virtex_ml507.c                      |   2 +-
 include/qemu/datadir.h                     |  13 ++++++++----
 pc-bios/{ => dtb}/bamboo.dtb               | Bin
 pc-bios/{ => dtb}/bamboo.dts               |   0
 pc-bios/{ => dtb}/canyonlands.dtb          | Bin
 pc-bios/{ => dtb}/canyonlands.dts          |   0
 pc-bios/dtb/meson.build                    |  23 +++++++++++++++++++++
 pc-bios/{ => dtb}/petalogix-ml605.dtb      | Bin
 pc-bios/{ => dtb}/petalogix-ml605.dts      |   0
 pc-bios/{ => dtb}/petalogix-s3adsp1800.dtb | Bin
 pc-bios/{ => dtb}/petalogix-s3adsp1800.dts |   0
 pc-bios/meson.build                        |  23 +--------------------
 system/datadir.c                           |   5 ++++-
 17 files changed, 42 insertions(+), 32 deletions(-)
 rename pc-bios/{ => dtb}/bamboo.dtb (100%)
 rename pc-bios/{ => dtb}/bamboo.dts (100%)
 rename pc-bios/{ => dtb}/canyonlands.dtb (100%)
 rename pc-bios/{ => dtb}/canyonlands.dts (100%)
 create mode 100644 pc-bios/dtb/meson.build
 rename pc-bios/{ => dtb}/petalogix-ml605.dtb (100%)
 rename pc-bios/{ => dtb}/petalogix-ml605.dts (100%)
 rename pc-bios/{ => dtb}/petalogix-s3adsp1800.dtb (100%)
 rename pc-bios/{ => dtb}/petalogix-s3adsp1800.dts (100%)
Signature · 1 line
2.41.3
#1 lore raw

PATCH 1/2 system/datadir: Add new type constant for DTB files

Currently DTB files are mixed with ROMs under BIOS type. Separate them under a new type constant and turn defines into an enum while at it.

---
 hw/microblaze/boot.c   |  2 +-
 hw/ppc/ppc440_bamboo.c |  2 +-
 hw/ppc/sam460ex.c      |  2 +-
 hw/ppc/virtex_ml507.c  |  2 +-
 include/qemu/datadir.h | 13 +++++++++----
 system/datadir.c       |  3 ++-
 6 files changed, 15 insertions(+), 9 deletions(-)
hw/microblaze/boot.c +1 -1
index 60b4ef0abe..4a9c9df318 100644
@@ -130,7 +130,7 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, bool is_little_endian,
     dtb_arg = current_machine->dtb;
     /* default to pcbios dtb as passed by machine_init */
     if (!dtb_arg && dtb_filename) {
-        filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, dtb_filename);
+        filename = qemu_find_file(QEMU_FILE_TYPE_DTB, dtb_filename);
     }
 
     boot_info.machine_cpu_reset = machine_cpu_reset;
hw/ppc/ppc440_bamboo.c +1 -1
index 099fda3909..6fff0d8afb 100644
@@ -64,7 +64,7 @@ static int bamboo_load_device_tree(MachineState *machine,
     uint32_t tb_freq = 400000000;
     uint32_t clock_freq = 400000000;
 
-    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
+    filename = qemu_find_file(QEMU_FILE_TYPE_DTB, BINARY_DEVICE_TREE_FILE);
     if (!filename) {
         return -1;
     }
hw/ppc/sam460ex.c +1 -1
index 7dc3b309c8..327fac440f 100644
@@ -142,7 +142,7 @@ static int sam460ex_load_device_tree(MachineState *machine,
     uint32_t clock_freq = CPU_FREQ;
     int offset;
 
-    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
+    filename = qemu_find_file(QEMU_FILE_TYPE_DTB, BINARY_DEVICE_TREE_FILE);
     if (!filename) {
         error_report("Couldn't find dtb file `%s'", BINARY_DEVICE_TREE_FILE);
         exit(1);
hw/ppc/virtex_ml507.c +1 -1
index 17115be74d..c9969ae48a 100644
@@ -146,7 +146,7 @@ static int xilinx_load_device_tree(MachineState *machine,
         /* Try the local "ppc.dtb" override.  */
         fdt = load_device_tree("ppc.dtb", &fdt_size);
         if (!fdt) {
-            path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
+            path = qemu_find_file(QEMU_FILE_TYPE_DTB, BINARY_DEVICE_TREE_FILE);
             if (path) {
                 fdt = load_device_tree(path, &fdt_size);
                 g_free(path);
include/qemu/datadir.h +9 -4
index 21f9097f58..16db3d8cd3 100644
@@ -1,12 +1,17 @@
 #ifndef QEMU_DATADIR_H
 #define QEMU_DATADIR_H
 
-#define QEMU_FILE_TYPE_BIOS   0
-#define QEMU_FILE_TYPE_KEYMAP 1
+typedef enum {
+    QEMU_FILE_TYPE_BIOS,
+    QEMU_FILE_TYPE_KEYMAP,
+    QEMU_FILE_TYPE_DTB,
+} QemuFileType;
+
 /**
  * qemu_find_file:
  * @type: QEMU_FILE_TYPE_BIOS (for BIOS, VGA BIOS)
- *        or QEMU_FILE_TYPE_KEYMAP (for keymaps).
+ *        QEMU_FILE_TYPE_KEYMAP (for keymaps)
+ *        QEMU_FILE_TYPE_DTB (for device tree blobs).
  * @name: Relative or absolute file name
  *
  * If @name exists on disk as an absolute path, or a path relative
@@ -20,7 +25,7 @@
  *
  * Returns: a path that can access @name, or NULL if no matching file exists.
  */
-char *qemu_find_file(int type, const char *name);
+char *qemu_find_file(QemuFileType type, const char *name);
 void qemu_add_default_firmwarepath(void);
 void qemu_add_data_dir(char *path);
 void qemu_list_data_dirs(void);
system/datadir.c +2 -1
index c9237cb5d4..e450b84ce9 100644
@@ -30,7 +30,7 @@
 static const char *data_dir[16];
 static int data_dir_idx;
 
-char *qemu_find_file(int type, const char *name)
+char *qemu_find_file(QemuFileType type, const char *name)
 {
     int i;
     const char *subdir;
@@ -44,6 +44,7 @@ char *qemu_find_file(int type, const char *name)
 
     switch (type) {
     case QEMU_FILE_TYPE_BIOS:
+    case QEMU_FILE_TYPE_DTB:
         subdir = "";
         break;
     case QEMU_FILE_TYPE_KEYMAP:
Signature · 1 line
2.41.3
#2 lore raw

PATCH 2/2 pc-bios: Move device tree files in their own subdir

In reply to BALATON Zoltan

We have several device tree files already and may have more in the future so add a new dtb subdirectory and move device tree files there so they are not mixed with ROM binaries.

---
 MAINTAINERS                                |   2 +-
 pc-bios/{ => dtb}/bamboo.dtb               | Bin
 pc-bios/{ => dtb}/bamboo.dts               |   0
 pc-bios/{ => dtb}/canyonlands.dtb          | Bin
 pc-bios/{ => dtb}/canyonlands.dts          |   0
 pc-bios/dtb/meson.build                    |  23 +++++++++++++++++++++
 pc-bios/{ => dtb}/petalogix-ml605.dtb      | Bin
 pc-bios/{ => dtb}/petalogix-ml605.dts      |   0
 pc-bios/{ => dtb}/petalogix-s3adsp1800.dtb | Bin
 pc-bios/{ => dtb}/petalogix-s3adsp1800.dts |   0
 pc-bios/meson.build                        |  23 +--------------------
 system/datadir.c                           |   4 +++-
 12 files changed, 28 insertions(+), 24 deletions(-)
 rename pc-bios/{ => dtb}/bamboo.dtb (100%)
 rename pc-bios/{ => dtb}/bamboo.dts (100%)
 rename pc-bios/{ => dtb}/canyonlands.dtb (100%)
 rename pc-bios/{ => dtb}/canyonlands.dts (100%)
 create mode 100644 pc-bios/dtb/meson.build
 rename pc-bios/{ => dtb}/petalogix-ml605.dtb (100%)
 rename pc-bios/{ => dtb}/petalogix-ml605.dts (100%)
 rename pc-bios/{ => dtb}/petalogix-s3adsp1800.dtb (100%)
 rename pc-bios/{ => dtb}/petalogix-s3adsp1800.dts (100%)
MAINTAINERS +1 -1
index d54b5578f8..9349950527 100644
@@ -1569,7 +1569,7 @@ F: hw/pci-host/ppc440_pcix.c
 F: hw/display/sm501*
 F: hw/ide/sii3112.c
 F: hw/rtc/m41t80.c
-F: pc-bios/canyonlands.dt[sb]
+F: pc-bios/dtb/canyonlands.dt[sb]
 F: pc-bios/u-boot-sam460ex-20100605.bin
 F: roms/u-boot-sam460ex
 F: docs/system/ppc/amigang.rst
pc-bios/dtb/bamboo.dtb renamed from pc-bios/bamboo.dtb +0 -0
similarity index 100%
rename from pc-bios/bamboo.dtb
rename to pc-bios/dtb/bamboo.dtb
pc-bios/dtb/bamboo.dts renamed from pc-bios/bamboo.dts +0 -0
similarity index 100%
rename from pc-bios/bamboo.dts
rename to pc-bios/dtb/bamboo.dts
pc-bios/dtb/canyonlands.dtb renamed from pc-bios/canyonlands.dtb +0 -0
similarity index 100%
rename from pc-bios/canyonlands.dtb
rename to pc-bios/dtb/canyonlands.dtb
pc-bios/dtb/canyonlands.dts renamed from pc-bios/canyonlands.dts +0 -0
similarity index 100%
rename from pc-bios/canyonlands.dts
rename to pc-bios/dtb/canyonlands.dts
pc-bios/dtb/meson.build new file +23 -0
new file mode 100644
index 0000000000..7a71835bca
@@ -0,0 +1,23 @@
+dtbs = [
+  'bamboo.dtb',
+  'canyonlands.dtb',
+  'petalogix-ml605.dtb',
+  'petalogix-s3adsp1800.dtb',
+]
+
+dtc = find_program('dtc', required: false)
+if dtc.found()
+  foreach out : dtbs
+    f = fs.replace_suffix(out, '.dts')
+    custom_target(f,
+        build_by_default: have_system,
+        input: files(f),
+        output: out,
+        install: get_option('install_blobs'),
+        install_dir: qemu_datadir / 'dtb',
+        command: [ dtc, '-q', '-I', 'dts', '-O', 'dtb',
+                        '-o', '@OUTPUT@', '@INPUT0@' ])
+  endforeach
+else
+    install_data(dtbs, install_dir: qemu_datadir / 'dtb')
+endif
pc-bios/dtb/petalogix-ml605.dtb renamed from pc-bios/petalogix-ml605.dtb +0 -0
similarity index 100%
rename from pc-bios/petalogix-ml605.dtb
rename to pc-bios/dtb/petalogix-ml605.dtb
pc-bios/dtb/petalogix-ml605.dts renamed from pc-bios/petalogix-ml605.dts +0 -0
similarity index 100%
rename from pc-bios/petalogix-ml605.dts
rename to pc-bios/dtb/petalogix-ml605.dts
pc-bios/dtb/petalogix-s3adsp1800.dtb renamed from pc-bios/petalogix-s3adsp1800.dtb +0 -0
similarity index 100%
rename from pc-bios/petalogix-s3adsp1800.dtb
rename to pc-bios/dtb/petalogix-s3adsp1800.dtb
pc-bios/dtb/petalogix-s3adsp1800.dts renamed from pc-bios/petalogix-s3adsp1800.dts +0 -0
similarity index 100%
rename from pc-bios/petalogix-s3adsp1800.dts
rename to pc-bios/dtb/petalogix-s3adsp1800.dts
pc-bios/meson.build +1 -22
index 34d6616c32..34d8cc4f33 100644
@@ -86,31 +86,10 @@ blobs = [
   'vof-nvram.bin',
 ]
 
-dtc = find_program('dtc', required: false)
-foreach f : [
-  'bamboo.dts',
-  'canyonlands.dts',
-  'petalogix-s3adsp1800.dts',
-  'petalogix-ml605.dts',
-]
-  out = fs.replace_suffix(f, '.dtb')
-  if dtc.found()
-    custom_target(f,
-        build_by_default: have_system,
-        input: files(f),
-        output: out,
-        install: get_option('install_blobs'),
-        install_dir: qemu_datadir,
-        command: [ dtc, '-q', '-I', 'dts', '-O', 'dtb',
-                        '-o', '@OUTPUT@', '@INPUT0@' ])
-  else
-    blobs += out
-  endif
-endforeach
-
 if get_option('install_blobs')
   install_data(blobs, install_dir: qemu_datadir)
 endif
 
 subdir('descriptors')
+subdir('dtb')
 subdir('keymaps')
system/datadir.c +3 -1
index e450b84ce9..f96f8fc264 100644
@@ -44,9 +44,11 @@ char *qemu_find_file(QemuFileType type, const char *name)
 
     switch (type) {
     case QEMU_FILE_TYPE_BIOS:
-    case QEMU_FILE_TYPE_DTB:
         subdir = "";
         break;
+    case QEMU_FILE_TYPE_DTB:
+        subdir = "dtb/";
+        break;
     case QEMU_FILE_TYPE_KEYMAP:
         subdir = "keymaps/";
         break;
Signature · 1 line
2.41.3
#3 lore raw

Re: [PATCH 2/2] pc-bios: Move device tree files in their own subdir

In reply to BALATON Zoltan

+Stefan

Quoted 147 lines · BALATON Zoltan

We have several device tree files already and may have more in the future so add a new dtb subdirectory and move device tree files there so they are not mixed with ROM binaries.

---
  MAINTAINERS                                |   2 +-
  pc-bios/{ => dtb}/bamboo.dtb               | Bin
  pc-bios/{ => dtb}/bamboo.dts               |   0
  pc-bios/{ => dtb}/canyonlands.dtb          | Bin
  pc-bios/{ => dtb}/canyonlands.dts          |   0
  pc-bios/dtb/meson.build                    |  23 +++++++++++++++++++++
  pc-bios/{ => dtb}/petalogix-ml605.dtb      | Bin
  pc-bios/{ => dtb}/petalogix-ml605.dts      |   0
  pc-bios/{ => dtb}/petalogix-s3adsp1800.dtb | Bin
  pc-bios/{ => dtb}/petalogix-s3adsp1800.dts |   0
  pc-bios/meson.build                        |  23 +--------------------
  system/datadir.c                           |   4 +++-
  12 files changed, 28 insertions(+), 24 deletions(-)

rename pc-bios/{ => dtb}/bamboo.dtb (100%) rename pc-bios/{ => dtb}/bamboo.dts (100%) rename pc-bios/{ => dtb}/canyonlands.dtb (100%) rename pc-bios/{ => dtb}/canyonlands.dts (100%) create mode 100644 pc-bios/dtb/meson.build rename pc-bios/{ => dtb}/petalogix-ml605.dtb (100%) rename pc-bios/{ => dtb}/petalogix-ml605.dts (100%) rename pc-bios/{ => dtb}/petalogix-s3adsp1800.dtb (100%) rename pc-bios/{ => dtb}/petalogix-s3adsp1800.dts (100%)

MAINTAINERS +1 -1
index d54b5578f8..9349950527 100644
@@ -1569,7 +1569,7 @@ F: hw/pci-host/ppc440_pcix.c
  F: hw/display/sm501*
  F: hw/ide/sii3112.c
  F: hw/rtc/m41t80.c
-F: pc-bios/canyonlands.dt[sb]
+F: pc-bios/dtb/canyonlands.dt[sb]
  F: pc-bios/u-boot-sam460ex-20100605.bin
  F: roms/u-boot-sam460ex
  F: docs/system/ppc/amigang.rst
pc-bios/dtb/bamboo.dtb renamed from pc-bios/bamboo.dtb +0 -0
similarity index 100%
rename from pc-bios/bamboo.dtb
rename to pc-bios/dtb/bamboo.dtb
pc-bios/dtb/bamboo.dts renamed from pc-bios/bamboo.dts +0 -0
similarity index 100%
rename from pc-bios/bamboo.dts
rename to pc-bios/dtb/bamboo.dts
pc-bios/dtb/canyonlands.dtb renamed from pc-bios/canyonlands.dtb +0 -0
similarity index 100%
rename from pc-bios/canyonlands.dtb
rename to pc-bios/dtb/canyonlands.dtb
pc-bios/dtb/canyonlands.dts renamed from pc-bios/canyonlands.dts +0 -0
similarity index 100%
rename from pc-bios/canyonlands.dts
rename to pc-bios/dtb/canyonlands.dts
pc-bios/dtb/meson.build new file +23 -0
new file mode 100644
index 0000000000..7a71835bca
@@ -0,0 +1,23 @@
+dtbs = [
+  'bamboo.dtb',
+  'canyonlands.dtb',
+  'petalogix-ml605.dtb',
+  'petalogix-s3adsp1800.dtb',
+]
+
+dtc = find_program('dtc', required: false)
+if dtc.found()
+  foreach out : dtbs
+    f = fs.replace_suffix(out, '.dts')
+    custom_target(f,
+        build_by_default: have_system,
+        input: files(f),
+        output: out,
+        install: get_option('install_blobs'),
+        install_dir: qemu_datadir / 'dtb',
+        command: [ dtc, '-q', '-I', 'dts', '-O', 'dtb',
+                        '-o', '@OUTPUT@', '@INPUT0@' ])
+  endforeach
+else
+    install_data(dtbs, install_dir: qemu_datadir / 'dtb')
+endif
pc-bios/dtb/petalogix-ml605.dtb renamed from pc-bios/petalogix-ml605.dtb +0 -0
similarity index 100%
rename from pc-bios/petalogix-ml605.dtb
rename to pc-bios/dtb/petalogix-ml605.dtb
pc-bios/dtb/petalogix-ml605.dts renamed from pc-bios/petalogix-ml605.dts +0 -0
similarity index 100%
rename from pc-bios/petalogix-ml605.dts
rename to pc-bios/dtb/petalogix-ml605.dts
pc-bios/dtb/petalogix-s3adsp1800.dtb renamed from pc-bios/petalogix-s3adsp1800.dtb +0 -0
similarity index 100%
rename from pc-bios/petalogix-s3adsp1800.dtb
rename to pc-bios/dtb/petalogix-s3adsp1800.dtb
pc-bios/dtb/petalogix-s3adsp1800.dts renamed from pc-bios/petalogix-s3adsp1800.dts +0 -0
similarity index 100%
rename from pc-bios/petalogix-s3adsp1800.dts
rename to pc-bios/dtb/petalogix-s3adsp1800.dts
pc-bios/meson.build +1 -22
index 34d6616c32..34d8cc4f33 100644
@@ -86,31 +86,10 @@ blobs = [
    'vof-nvram.bin',
  ]
 
-dtc = find_program('dtc', required: false)
-foreach f : [
-  'bamboo.dts',
-  'canyonlands.dts',
-  'petalogix-s3adsp1800.dts',
-  'petalogix-ml605.dts',
-]
-  out = fs.replace_suffix(f, '.dtb')
-  if dtc.found()
-    custom_target(f,
-        build_by_default: have_system,
-        input: files(f),
-        output: out,
-        install: get_option('install_blobs'),
-        install_dir: qemu_datadir,
-        command: [ dtc, '-q', '-I', 'dts', '-O', 'dtb',
-                        '-o', '@OUTPUT@', '@INPUT0@' ])
-  else
-    blobs += out
-  endif
-endforeach
-
  if get_option('install_blobs')
    install_data(blobs, install_dir: qemu_datadir)
  endif
 
  subdir('descriptors')
+subdir('dtb')
  subdir('keymaps')
system/datadir.c +0 -0
index e450b84ce9..f96f8fc264 100644
@@ -44,9 +44,11 @@ char *qemu_find_file(QemuFileType type, const char *name)
 
      switch (type) {

system/datadir.c char *qemu_find_file(QemuFileType type, const char *name) · line 54

Quoted 10 lines
system/datadir.c +3 -1
      case QEMU_FILE_TYPE_BIOS:
-    case QEMU_FILE_TYPE_DTB:
          subdir = "";
          break;
+    case QEMU_FILE_TYPE_DTB:
+        subdir = "dtb/";
+        break;
      case QEMU_FILE_TYPE_KEYMAP:
          subdir = "keymaps/";
          break;

Apparently we also need:

-- >8 --

qemu.nsi +1 -1
index b186f223e14..d419986ca06 100644
@@ -206,3 +206,2 @@ Section "Uninstall"
     Delete "$INSTDIR\*.dll"
-    Delete "$INSTDIR\*.dtb"
     Delete "$INSTDIR\*.fd"
@@ -217,2 +216,3 @@ Section "Uninstall"
     Delete "$INSTDIR\qemu-system-*.exe"
+    RMDir /r "$INSTDIR\dtb"
     RMDir /r "$INSTDIR\doc"

---

Stefan, WDYT?