From 72af19b5e0f10b29fa44f8d94e1f2d2ffe6ec2e1 Mon Sep 17 00:00:00 2001 From: Till Wegmueller Date: Sat, 28 Jan 2023 16:10:31 +0100 Subject: [PATCH 1/5] Adding IPD to coordinate device tree support --- README.md | 1 + ipd/0039/README.md | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 ipd/0039/README.md diff --git a/README.md b/README.md index 14fe9e5..d84b30d 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ information is available at the end of this document. | draft | [IPD 36 Rationalize $(MACH64) Command Paths](./ipd/0036/README.md) | published | [IPD 37 Vendor-specific Command, Log, and Feature Support in nvmeadm(8)](./ipd/0037/README.md) | draft | [IPD 38 Signal Handling, Extended FPU State, ucontexts, x86, and You](./ipd/0038/README.adoc) +| predraft | [IPD 39 Updated Device Tree Support](./ipd/0039/README.md) ## Contributing diff --git a/ipd/0039/README.md b/ipd/0039/README.md new file mode 100644 index 0000000..b874828 --- /dev/null +++ b/ipd/0039/README.md @@ -0,0 +1,32 @@ +--- +author: Till wegmüller +state: predraft +--- + +# Abstract +To support native device enumeration on ARM and Risc-V (and others) a Mechanism called device tree +is used next to bus enumeration support like PCI-e or USB. This is used by the Kernel to configure +drivers at boot and runtime if the bus supports runtime changes (Most don't). + + +# Background and Research +Device tree support is mainly used for configuration of Hardware extensions and GPIO in the Embedded world. SPARC also used to +have a Device Tree support, thus our internal format is at least somewhat similar if not directly an ancestor to the +modern device tree files used in Linux and FreeBSD. Open Firmware Device trees are standardised in IEEE 1275 which later also got +extended to PPC by IBM and to CHRP by Apple. On SPARC a Device tree blob was placed in the PROM and a partial device tree could be supplied +by Extension baords. +> In most systems, the CPU's FCode interpreter will store each device's identification information in a device tree that has a node for each device. Each device node has a property list that identifies and describes the device. The property list is created as a result of interpreting the program in the FCode PROM. + +On x86 ACPI was used for these tasks. While Arm boards may have some support for UEFI and ACPI nowadays their use is limited and not +native to the platform and only a Translation layer in the UEFI firmware. + +# Purpose +This IPD exists to coordinate further development of our device tree support and thus support a wider range of Devices and their extension cards. + + +# References +- [Device Tree History](https://elinux.org/images/0/06/ELCE_2019_DeviceTree_Past_Present_Future.pdf) +- [SPARC Device Tree Docs SBus Card and FCode](https://docs.oracle.com/cd/E19957-01/802-3239-10/sbusandfc.html) +- [Raspberry 4 Device Tree Overview](https://blog.stabel.family/raspberry-pi-4-device-tree/) +- [Fediverse Research Thread](https://chaos.social/@Toasterson/109766721243396979) +- [ACPI Wikipedia](https://en.wikipedia.org/wiki/ACPI) \ No newline at end of file From 7aea6c13b975f3558f81f5361a1a506caf80b283 Mon Sep 17 00:00:00 2001 From: Till Wegmueller Date: Sat, 28 Jan 2023 16:16:54 +0100 Subject: [PATCH 2/5] Add link to devicetree.org --- ipd/0039/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ipd/0039/README.md b/ipd/0039/README.md index b874828..868a070 100644 --- a/ipd/0039/README.md +++ b/ipd/0039/README.md @@ -29,4 +29,5 @@ This IPD exists to coordinate further development of our device tree support and - [SPARC Device Tree Docs SBus Card and FCode](https://docs.oracle.com/cd/E19957-01/802-3239-10/sbusandfc.html) - [Raspberry 4 Device Tree Overview](https://blog.stabel.family/raspberry-pi-4-device-tree/) - [Fediverse Research Thread](https://chaos.social/@Toasterson/109766721243396979) -- [ACPI Wikipedia](https://en.wikipedia.org/wiki/ACPI) \ No newline at end of file +- [ACPI Wikipedia](https://en.wikipedia.org/wiki/ACPI) +- [DeviceTree.org](https://www.devicetree.org/) From 9bf99c08b366d3f239746b616e971cf25ad4eb4c Mon Sep 17 00:00:00 2001 From: Till Wegmueller Date: Sat, 28 Jan 2023 16:51:46 +0100 Subject: [PATCH 3/5] Add reference to u-boot driver model --- ipd/0039/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ipd/0039/README.md b/ipd/0039/README.md index 868a070..9930f14 100644 --- a/ipd/0039/README.md +++ b/ipd/0039/README.md @@ -31,3 +31,4 @@ This IPD exists to coordinate further development of our device tree support and - [Fediverse Research Thread](https://chaos.social/@Toasterson/109766721243396979) - [ACPI Wikipedia](https://en.wikipedia.org/wiki/ACPI) - [DeviceTree.org](https://www.devicetree.org/) +- [U-Boot Driver Model](https://elinux.org/images/c/c4/Order_at_last_-_U-Boot_driver_model_slides_%282%29.pdf) From 23cfef7fcb0028de370ba7985fa3b960fb8c82e5 Mon Sep 17 00:00:00 2001 From: Till Wegmueller Date: Sat, 28 Jan 2023 16:59:40 +0100 Subject: [PATCH 4/5] Add reference to current specification document --- ipd/0039/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ipd/0039/README.md b/ipd/0039/README.md index 9930f14..b118274 100644 --- a/ipd/0039/README.md +++ b/ipd/0039/README.md @@ -32,3 +32,4 @@ This IPD exists to coordinate further development of our device tree support and - [ACPI Wikipedia](https://en.wikipedia.org/wiki/ACPI) - [DeviceTree.org](https://www.devicetree.org/) - [U-Boot Driver Model](https://elinux.org/images/c/c4/Order_at_last_-_U-Boot_driver_model_slides_%282%29.pdf) +- [Device Tree Specification v0.4-rc1](https://github.com/devicetree-org/devicetree-specification/releases/download/v0.4-rc1/devicetree-specification-v0.4-rc1.pdf) \ No newline at end of file From 9185706d4fb7ef1b96bd4603f882aca76d133f74 Mon Sep 17 00:00:00 2001 From: Till Wegmueller Date: Mon, 30 Jan 2023 17:17:31 +0100 Subject: [PATCH 5/5] Updating document and making tasks clearer --- ipd/0039/README.md | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/ipd/0039/README.md b/ipd/0039/README.md index b118274..e2e9e98 100644 --- a/ipd/0039/README.md +++ b/ipd/0039/README.md @@ -4,24 +4,38 @@ state: predraft --- # Abstract -To support native device enumeration on ARM and Risc-V (and others) a Mechanism called device tree -is used next to bus enumeration support like PCI-e or USB. This is used by the Kernel to configure -drivers at boot and runtime if the bus supports runtime changes (Most don't). +On ARM and many other Platforms the originally OpenFirmware Device tree standard is used to provide information +how to configure drivers. Since this is Originally a Sun Microsystems invention all our basic infrastructure already +exists however over the years PowerPC, ARM, et al have made changes to the file formats and some things are breaking changes. +This IPD's purpose is to Coordinate all work to provide facilities that embedded and non x86 Systems developers expect +from an OS using Device tree. -# Background and Research +# Background and History Device tree support is mainly used for configuration of Hardware extensions and GPIO in the Embedded world. SPARC also used to -have a Device Tree support, thus our internal format is at least somewhat similar if not directly an ancestor to the -modern device tree files used in Linux and FreeBSD. Open Firmware Device trees are standardised in IEEE 1275 which later also got -extended to PPC by IBM and to CHRP by Apple. On SPARC a Device tree blob was placed in the PROM and a partial device tree could be supplied -by Extension baords. +have a Device Tree support, thus our internal format is a directl ancestor to the modern FDT files used in many Platforms and Os's. +Open Firmware Device trees are standardised in IEEE 1275 which later also got extended to PPC by IBM and to CHRP by Apple. +On SPARC a Device tree blob was placed in the PROM and a partial device tree could be supplied by Extension baords. > In most systems, the CPU's FCode interpreter will store each device's identification information in a device tree that has a node for each device. Each device node has a property list that identifies and describes the device. The property list is created as a result of interpreting the program in the FCode PROM. On x86 ACPI was used for these tasks. While Arm boards may have some support for UEFI and ACPI nowadays their use is limited and not native to the platform and only a Translation layer in the UEFI firmware. -# Purpose -This IPD exists to coordinate further development of our device tree support and thus support a wider range of Devices and their extension cards. +EFI also has Device tree passthrough support since Apple has been using Device trees throughout History on it's ARM devices. Only Intel +Mac's are different there. FreeBSD Loader has Integrated FDT support and overlay support in the default build but hidden behind a flag `make buildworld -DWITH_FDT`. + +# What we will need to do +Since we already have most of the plumbing for thing even linux does not have at the moment (Runtime modification) we only need to focus on the details that we need to change. +- *Supplying overlays to the Kernel.* On linux and specifically the Raspberry PI and thus other embedded systems this is done with u-boot assembling the overlayed dtb files at boot into +a flattened and complete tree and passing that to the Kernel. FreeBSD added that functionality to loader but loader also translates the FDT format to the FreeBSD format. //TODO input from tsoome how much is already +defined/implemented with the new nvlist boot protocol. +- *Driver support* Several drivers that we have generically on or in early boot need to be configured via Device trees (Serial Console/CPU/platform general) it may also result in cases where drivers become more generic +- *Allowing users to modify overlay settings* On the Raspberry PI and other boards a config.txt format can be used as a final kind of overlay that sets some user configurable device settings. This may +be done on runtime but may also end up needing a machnism to configure loader appropriately. +- *Storage of FDT Blobs* While in the old SPARC days Device trees where specifically stored in PROM (or EEPROM) on more modern Systems the Trees are mostly stored on Flash Storage next to the rootfs of the OS. +While the bootloader needs access to those files, since we have FreeBSD loader we can skip putting the overlay files on a FAT32 formated partition. Although we could put it into the EFI System Partition, +which however would make the ESP also a dependency for every platform that support s Device Tree (PowerPC/ARM/Risc-V). Some Firmware (Raspberry Pi) supplies device trees to the boot loader/OS from ROM but not all Boards do. +- *FDT Binary Format Changes* Over the years the FDT binary format has received changes to what it originally was in 1994. So we will need to include those or switch to libfdt or similar. # References @@ -32,4 +46,6 @@ This IPD exists to coordinate further development of our device tree support and - [ACPI Wikipedia](https://en.wikipedia.org/wiki/ACPI) - [DeviceTree.org](https://www.devicetree.org/) - [U-Boot Driver Model](https://elinux.org/images/c/c4/Order_at_last_-_U-Boot_driver_model_slides_%282%29.pdf) -- [Device Tree Specification v0.4-rc1](https://github.com/devicetree-org/devicetree-specification/releases/download/v0.4-rc1/devicetree-specification-v0.4-rc1.pdf) \ No newline at end of file +- [Device Tree Specification v0.4-rc1](https://github.com/devicetree-org/devicetree-specification/releases/download/v0.4-rc1/devicetree-specification-v0.4-rc1.pdf) +- [Device Tree Past Present and Future](https://elinux.org/images/0/06/ELCE_2019_DeviceTree_Past_Present_Future.pdf) +- [Kernelovr Docs](https://illumos.org/books/wdd/kernelovr-77198.html#kernelovr-43) \ No newline at end of file