diff --git a/.cargo/config b/.cargo/config index 473bf208..81c733ff 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,12 +1,12 @@ [target.riscv64gc-unknown-none-elf] rustflags = [ - "-Clink-arg=-Tscripts/qemu-riscv64.ld", + "-Clink-arg=-T../platform/riscv64/qemu/linker.ld", "-Cforce-frame-pointers=yes" ] [target.aarch64-unknown-none] rustflags = [ - "-Clink-arg=-Tscripts/qemu-aarch64.ld", + "-Clink-arg=-T../platform/aarch64/qemu/linker.ld", "-Ctarget-feature=+a53,+v8a,+strict-align,-neon,-fp-armv8", "-Cforce-frame-pointers=yes", ] @@ -14,6 +14,6 @@ rustflags = [ [target.loongarch64-unknown-none] linker = "loongarch64-unknown-linux-gnu-gcc" rustflags = [ - "-Clink-arg=-Tscripts/3a5000-loongarch64.ld", + "-Clink-arg=-T../platform/loongarch64/3a5000/linker.ld", "-Cforce-frame-pointers=yes", ] \ No newline at end of file diff --git a/.gitignore b/.gitignore index ed333980..5cc7d9c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ /target /qemu-test /test-img -/hvisor.S -/hvisor-elf.txt +/disa /images/aarch64/virtdisk/* /images/aarch64/kernel/* /images/aarch64/devicetree/*.dtb @@ -24,3 +23,4 @@ Image* *.ext4 *.qcow2 *.dtb +hvisor.bin \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index f2ff01e8..51e0df0a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -76,7 +76,7 @@ // "rust-analyzer.cargo.target": "riscv64gc-unknown-none-elf", // "rust-analyzer.cargo.target": "loongarch64-unknown-none", "rust-analyzer.checkOnSave.allTargets": false, - // "rust-analyzer.cargo.features": [ - // "board_qemu" - // ] + "rust-analyzer.cargo.features": [ + "platform_qemu" + ] } \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 5756202a..1d3af222 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -76,10 +76,6 @@ dependencies = [ "spin 0.7.1", ] -[[package]] -name = "fdt" -version = "0.1.5" - [[package]] name = "hvisor" version = "0.1.0" @@ -89,7 +85,6 @@ dependencies = [ "bitflags 2.5.0", "bitmap-allocator", "buddy_system_allocator", - "fdt", "lazy_static", "log", "loongArch64", diff --git a/Cargo.toml b/Cargo.toml index 2a1ccea4..e631e57a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,6 @@ buddy_system_allocator = "0.8" tock-registers = "0.8" lazy_static = { version = "1.4", features = ["spin_no_std"] } bitmap-allocator = { git = "https://github.com/rcore-os/bitmap-allocator", rev = "03bd9909" } -fdt = { path = "./vendor/fdt" } [target.'cfg(target_arch = "aarch64")'.dependencies] aarch64-cpu = "9.4.0" diff --git a/Makefile b/Makefile index 5de9cce9..5be38d3d 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,16 @@ # Basic settings +PLATFORM ?= qemu ARCH ?= aarch64 LOG ?= info STATS ?= off PORT ?= 2333 MODE ?= debug + OBJCOPY ?= rust-objcopy --binary-architecture=$(ARCH) -KDIR ?= ../../linux -FEATURES ?= platform_qemu +# Check the value of ARCH and set corresponding RUSTC_TARGET and GDB_ARCH values. ifeq ($(ARCH),aarch64) - RUSTC_TARGET := aarch64-unknown-none + RUSTC_TARGET := aarch64-unknown-none GDB_ARCH := aarch64 else ifeq ($(ARCH),riscv64) RUSTC_TARGET := riscv64gc-unknown-none-elf @@ -18,68 +19,83 @@ else ifeq ($(ARCH),loongarch64) RUSTC_TARGET := loongarch64-unknown-none GDB_ARCH := loongarch64 else + # Error out if an unsupported ARCH value is provided. $(error Unsupported ARCH value: $(ARCH)) endif +# Export these variables so that they can be accessed in other parts of the build process (e.g., included scripts). export MODE export LOG export ARCH +export PLATFORM # Build paths build_path := target/$(RUSTC_TARGET)/$(MODE) hvisor_elf := $(build_path)/hvisor -hvisor_bin := $(build_path)/hvisor.bin -image_dir := images/$(ARCH) +hvisor_bin := $(shell pwd)/hvisor.bin + +ifeq ($(ARCH),aarch64) + hvisor_bin_command := if ! command -v mkimage > /dev/null; then \ + sudo apt update; sudo apt install u-boot-tools; \ + fi && \ + $(OBJCOPY) $(hvisor_elf) --strip-all -O binary $(hvisor_bin).tmp && \ + mkimage -n hvisor_img -A arm64 -O linux -C none -a 0x40400000 -e 0x40400000 \ + -T kernel -d $(hvisor_bin).tmp $(hvisor_bin) && rm -rf $(hvisor_bin).tmp +else + hvisor_bin_command := $(OBJCOPY) $(hvisor_elf) --strip-all -O binary $@ +endif # Build arguments build_args := -build_args += --features "$(FEATURES)" +# Add the platform feature with the 'platform_' prefix concatenated with the PLATFORM value. +# This is to match the feature naming convention in the Cargo.toml file for building. +build_args += --features "platform_$(PLATFORM)" build_args += --target $(RUSTC_TARGET) build_args += -Z build-std=core,alloc build_args += -Z build-std-features=compiler-builtins-mem - ifeq ($(MODE), release) build_args += --release endif # Targets -.PHONY: all elf disa run gdb monitor clean tools rootfs +# Declare these targets asphony to avoid conflicts with actual files (if any). +.PHONY: all elf disa run gdb monitor show-features jlink-server cp clean + all: $(hvisor_bin) +$(hvisor_bin): elf + $(hvisor_bin_command) + elf: cargo build $(build_args) disa: - readelf -a $(hvisor_elf) > hvisor-elf.txt - rust-objdump --disassemble $(hvisor_elf) > hvisor.S - -run: all - $(QEMU) $(QEMU_ARGS) - -gdb: all - $(QEMU) $(QEMU_ARGS) -s -S + mkdir -p disa + readelf -a $(hvisor_elf) > disa/hvisor-elf.txt + rust-objdump --disassemble $(hvisor_elf) > disa/hvisor.S show-features: +# Print the target features for the specified RUSTC_TARGET using rustc. rustc --print=target-features --target=$(RUSTC_TARGET) monitor: +# Use gdb-multiarch to set up a debugging session for the hvisor ELF file. +# Set the architecture and connect to the remote target. gdb-multiarch \ -ex 'file $(hvisor_elf)' \ -ex 'set arch $(GDB_ARCH)' \ -ex 'target remote:1234' jlink-server: +# Start the JLinkGDBServer with specific options like selecting USB, JTAG interface, device, and port. JLinkGDBServer -select USB -if JTAG -device Cortex-A53 -port 1234 cp: all +# Copy the hvisor binary file to the specified location (~/tftp). cp $(hvisor_bin) ~/tftp clean: +# Clean the build artifacts using cargo clean command. cargo clean -ifeq ($(ARCH),loongarch64) -include scripts/3a5000-loongarch64.mk -else -include scripts/qemu-$(ARCH).mk -endif \ No newline at end of file diff --git a/images/aarch64/bootloader/u-boot-atf.bin b/images/aarch64/bootloader/u-boot-atf.bin deleted file mode 100644 index 11d89350..00000000 Binary files a/images/aarch64/bootloader/u-boot-atf.bin and /dev/null differ diff --git a/images/aarch64/bootloader/u-boot.bin b/images/aarch64/bootloader/u-boot.bin deleted file mode 100644 index 104114d9..00000000 Binary files a/images/aarch64/bootloader/u-boot.bin and /dev/null differ diff --git a/images/aarch64/devicetree/Makefile b/images/aarch64/devicetree/Makefile deleted file mode 100644 index c45c1b29..00000000 --- a/images/aarch64/devicetree/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# Find all .dts files in the current directory -DTS_FILES := $(wildcard *.dts) - -# Replace the .dts file extension with .dtb for all files found -DTB_FILES := $(DTS_FILES:.dts=.dtb) - -# Default target -all: $(DTB_FILES) - -# Pattern rule: how to generate a .dtb from a .dts -%.dtb: %.dts - dtc -I dts -O dtb $< -o $@ - -# Clean target to remove generated files -clean: - rm -f $(DTB_FILES) diff --git a/images/aarch64/devicetree/imx8mp-ruxos.dts b/images/aarch64/devicetree/imx8mp-ruxos.dts deleted file mode 100644 index 009ce71b..00000000 --- a/images/aarch64/devicetree/imx8mp-ruxos.dts +++ /dev/null @@ -1,102 +0,0 @@ -/dts-v1/; - -/ { - compatible = "forlinx,ok8mp-c\0fsl,imx8mp-evk\0fsl,imx8mp"; - model = "Forlinx OK8MPlus-C board"; - interrupt-parent = <0x01>; - #address-cells = <0x02>; - #size-cells = <0x02>; - - aliases { - serial3 = "/soc@0/bus@30800000/serial@30a60000"; - }; - - memory@50000000 { - device_type = "memory"; - reg = <0x00 0x50000000 0x00 0x30000000>; - }; - - cpus { - #address-cells = <0x01>; - #size-cells = <0x00>; - - cpu@2 { - device_type = "cpu"; - compatible = "arm,cortex-a53"; - reg = <0x02>; - clock-latency = <0xee6c>; - next-level-cache = <0x02>; - clocks = <0x03 0x11f>; - operating-points-v2 = <0x04>; - enable-method = "psci"; - #cooling-cells = <0x02>; - cpu-idle-states = <0x06>; - phandle = <0x13>; - }; - - l2-cache0 { - compatible = "cache"; - phandle = <0x02>; - }; - }; - - pmu { - compatible = "arm,cortex-a53-pmu"; - interrupts = <0x01 0x07 0x04>; - interrupt-parent = <0x01>; - interrupt-affinity = <0x03 0x04>; - }; - - interrupt-controller@38800000 { - compatible = "arm,gic-v3"; - reg = <0x00 0x38800000 0x00 0x10000 0x00 0x38880000 0x00 0xc0000>; - #interrupt-cells = <0x03>; - interrupt-controller; - interrupts = <0x01 0x09 0x04>; - interrupt-parent = <0x01>; - phandle = <0x01>; - }; - - timer { - compatible = "arm,armv8-timer"; - interrupts = <0x01 0x0d 0x3f08 0x01 0x0e 0x3f08 0x01 0x0b 0x3f08 0x01 0x0a 0x3f08>; - clock-frequency = <0x7f2815>; - }; - - clock@1 { - compatible = "fixed-clock"; - #clock-cells = <0x00>; - clock-frequency = <0x16e3600>; - clock-output-names = "osc_24m"; - phandle = <0x05>; - }; - - soc@0 { - compatible = "simple-bus"; - #address-cells = <0x01>; - #size-cells = <0x01>; - ranges = <0x00 0x00 0x00 0x3e000000>; - - bus@30800000 { - compatible = "simple-bus"; - #address-cells = <0x01>; - #size-cells = <0x01>; - reg = <0x30800000 0x400000>; - ranges; - - serial@30a60000 { - compatible = "fsl,imx8mp-uart\0fsl,imx6q-uart"; - reg = <0x30a60000 0x10000>; - interrupts = <0x00 0x1d 0x04>; - clocks = <0x05 0x05>; - clock-names = "ipg\0per"; - status = "okay"; - }; - }; - }; - - chosen { - bootargs = ";;"; - stdout-path = "/soc@0/bus@30800000/serial@30a60000"; - }; -}; diff --git a/images/aarch64/devicetree/linux1.dts b/images/aarch64/devicetree/linux1.dts deleted file mode 100644 index 30f8f8e6..00000000 --- a/images/aarch64/devicetree/linux1.dts +++ /dev/null @@ -1,197 +0,0 @@ -/dts-v1/; - -/ { - #size-cells = <0x2>; - #address-cells = <0x2>; - interrupt-parent = <0x01>; - model = "linux,dummy-virt"; - compatible = "linux,dummy-virt"; - - cpus { - #size-cells = <0x00>; - #address-cells = <0x01>; - - cpu@0 { - phandle = <0x8010>; - reg = <0x00>; - enable-method = "psci"; - compatible = "arm,cortex-a57"; - device_type = "cpu"; - }; - - cpu@1 { - phandle = <0x800f>; - reg = <0x01>; - enable-method = "psci"; - compatible = "arm,cortex-a57"; - device_type = "cpu"; - }; - - }; - - psci { - compatible = "arm,psci-0.2"; - method = "smc"; - }; - - reserved-memory { - #address-cells = <0x02>; - #size-cells = <0x02>; - ranges; - - nonroot@50000000 { - no-map; - reg = <0x00 0x50000000 0x00 0x30000000>; - }; - }; - - memory@50000000 { - device_type = "memory"; - reg = <0x0 0x50000000 0x0 0x80000000>; - }; - - intc@80000000 { - phandle = <0x01>; - interrupts = <0x01 0x09 0x04>; - reg = <0x00 0x8000000 0x00 0x10000 0x00 0x80a0000 0x00 0xf60000>; - #redistributor-regions = <0x01>; - compatible = "arm,gic-v3"; - ranges; - #size-cells = <0x02>; - #address-cells = <0x02>; - interrupt-controller; - #interrupt-cells = <0x03>; - - its@8080000 { - phandle = <0x8006>; - reg = <0x00 0x8080000 0x00 0x20000>; - #msi-cells = <0x01>; - msi-controller; - compatible = "arm,gic-v3-its"; - }; - }; - - pcie@10000000 { - interrupt-map-mask = <0x1800 0x00 0x00 0x07>; - interrupt-map = <0x00 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0x03 0x04 0x00 0x00 0x00 0x02 0x01 0x00 0x00 0x00 0x04 0x04 0x00 0x00 0x00 0x03 0x01 0x00 0x00 0x00 0x05 0x04 0x00 0x00 0x00 0x04 0x01 0x00 0x00 0x00 0x06 0x04 0x800 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0x04 0x04 0x800 0x00 0x00 0x02 0x01 0x00 0x00 0x00 0x05 0x04 0x800 0x00 0x00 0x03 0x01 0x00 0x00 0x00 0x06 0x04 0x800 0x00 0x00 0x04 0x01 0x00 0x00 0x00 0x03 0x04 0x1000 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0x05 0x04 0x1000 0x00 0x00 0x02 0x01 0x00 0x00 0x00 0x06 0x04 0x1000 0x00 0x00 0x03 0x01 0x00 0x00 0x00 0x03 0x04 0x1000 0x00 0x00 0x04 0x01 0x00 0x00 0x00 0x04 0x04 0x1800 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0x06 0x04 0x1800 0x00 0x00 0x02 0x01 0x00 0x00 0x00 0x03 0x04 0x1800 0x00 0x00 0x03 0x01 0x00 0x00 0x00 0x04 0x04 0x1800 0x00 0x00 0x04 0x01 0x00 0x00 0x00 0x05 0x04>; - #interrupt-cells = <0x01>; - ranges = <0x1000000 0x00 0x00 0x00 0x3eff0000 0x00 0x10000 - 0x2000000 0x00 0x10000000 0x00 0x10000000 0x00 0x2eff0000 - 0x3000000 0x80 0x00 0x80 0x00 0x80 0x00>; - reg = <0x40 0x10000000 0x00 0x10000000>; - msi-map = <0x00 0x8006 0x00 0x10000>; - dma-coherent; - bus-range = <0x00 0xff>; - linux,pci-domain = <0x00>; - #size-cells = <0x02>; - #address-cells = <0x03>; - device_type = "pci"; - compatible = "pci-host-ecam-generic"; - }; - - apb-pclk { - phandle = <0x8000>; - clock-output-names = "clk24mhz"; - clock-frequency = <0x16e3600>; - #clock-cells = <0x00>; - compatible = "fixed-clock"; - }; - - pl011@9000000 { - clock-names = "uartclk\0apb_pclk"; - clocks = <0x8000 0x8000>; - interrupt-parent = <0x01>; - interrupts = <0x00 0x01 0x04>; - reg = <0x00 0x9000000 0x00 0x1000>; - compatible = "arm,pl011\0arm,primecell"; - }; - - timer { - interrupt-parent = <0x01>; - interrupts = <0x1 0xd 0xf04 0x1 0xe 0xf04 0x1 0xb 0xf04 0x1 0xa 0xf04>; - always-on; - compatible = "arm,armv8-timer", "arm,armv7-timer"; - }; - - // virtio_mmio@a003000 { - // dma-coherent; - // interrupt-parent = <0x01>; - // interrupts = <0x0 0x28 0x1>; - // reg = <0x0 0xa003000 0x0 0x200>; - // compatible = "virtio,mmio"; - // }; - - // virtio_mmio@a003200 { - // dma-coherent; - // interrupt-parent = <0x01>; - // interrupts = <0x0 0x29 0x1>; - // reg = <0x0 0xa003200 0x0 0x200>; - // compatible = "virtio,mmio"; - // }; - - - // virtio_mmio@a003400 { - // dma-coherent; - // interrupt-parent = <0x01>; - // interrupts = <0x0 0x2a 0x1>; - // reg = <0x0 0xa003400 0x0 0x200>; - // compatible = "virtio,mmio"; - // }; - - // virtio 9p-pci - // virtio_mmio@a003600 { - // dma-coherent; - // interrupt-parent = <0x01>; - // interrupts = <0x0 0x2b 0x1>; - // reg = <0x0 0xa003600 0x0 0x200>; - // compatible = "virtio,mmio"; - // }; - - // virtio serial - // virtio_mmio@a003800 { - // dma-coherent; - // interrupt-parent = <0x01>; - // interrupts = <0x0 0x2c 0x1>; - // reg = <0x0 0xa003800 0x0 0x200>; - // compatible = "virtio,mmio"; - // }; - - // virtio net - virtio_mmio@a003a00 { - dma-coherent; - interrupt-parent = <0x01>; - interrupts = <0x0 0x2d 0x1>; - reg = <0x0 0xa003a00 0x0 0x200>; - compatible = "virtio,mmio"; - }; - - // virtio disk-second - // virtio_mmio@a003c00 { - // dma-coherent; - // interrupt-parent = <0x01>; - // interrupts = <0x0 0x2e 0x1>; - // reg = <0x0 0xa003c00 0x0 0x200>; - // compatible = "virtio,mmio"; - // }; - - // virtio disk-first - virtio_mmio@a003e00 { - dma-coherent; - interrupt-parent = <0x01>; - interrupts = <0x0 0x2f 0x1>; - reg = <0x0 0xa003e00 0x0 0x200>; - compatible = "virtio,mmio"; - }; - - chosen { - bootargs = "clk_ignore_unused earlycon console=ttyAMA0 root=/dev/vda iomem=relaxed rw"; - // bootargs = "root=/dev/vda mem=768M"; - stdout-path = "/pl011@9000000"; - }; - - hvisor_device { - compatible = "hvisor"; - interrupt-parent = <0x01>; - interrupts = <0x00 0x20 0x01>; - }; -}; diff --git a/images/aarch64/devicetree/linux2.dts b/images/aarch64/devicetree/linux2.dts deleted file mode 100644 index 2f6b4b4f..00000000 --- a/images/aarch64/devicetree/linux2.dts +++ /dev/null @@ -1,165 +0,0 @@ -/dts-v1/; - -/ { - #size-cells = <0x2>; - #address-cells = <0x2>; - interrupt-parent = <0x01>; - model = "linux,dummy-virt"; - compatible = "linux,dummy-virt"; - - cpus { - #size-cells = <0x00>; - #address-cells = <0x01>; - - cpu@2 { - reg = <0x02>; - enable-method = "psci"; - compatible = "arm,cortex-a57"; - device_type = "cpu"; - }; - - cpu@3 { - reg = <0x03>; - enable-method = "psci"; - compatible = "arm,cortex-a57"; - device_type = "cpu"; - }; - - }; - - psci { - compatible = "arm,psci-0.2"; - method = "smc"; - }; - - memory@50000000 { - device_type = "memory"; - reg = <0x0 0x50000000 0x0 0x30000000>; - }; - - intc@80000000 { - phandle = <0x01>; - interrupts = <0x01 0x09 0x04>; - reg = <0x00 0x8000000 0x00 0x10000 0x00 0x80a0000 0x00 0xf60000>; - #redistributor-regions = <0x01>; - compatible = "arm,gic-v3"; - ranges; - #size-cells = <0x02>; - #address-cells = <0x02>; - interrupt-controller; - #interrupt-cells = <0x03>; - - its@8080000 { - phandle = <0x8006>; - reg = <0x00 0x8080000 0x00 0x20000>; - #msi-cells = <0x01>; - msi-controller; - compatible = "arm,gic-v3-its"; - }; - }; - - pcie@10000000 { - interrupt-map-mask = <0x1800 0x00 0x00 0x07>; - interrupt-map = <0x00 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0x03 0x04 0x00 0x00 0x00 0x02 0x01 0x00 0x00 0x00 0x04 0x04 0x00 0x00 0x00 0x03 0x01 0x00 0x00 0x00 0x05 0x04 0x00 0x00 0x00 0x04 0x01 0x00 0x00 0x00 0x06 0x04 0x800 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0x04 0x04 0x800 0x00 0x00 0x02 0x01 0x00 0x00 0x00 0x05 0x04 0x800 0x00 0x00 0x03 0x01 0x00 0x00 0x00 0x06 0x04 0x800 0x00 0x00 0x04 0x01 0x00 0x00 0x00 0x03 0x04 0x1000 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0x05 0x04 0x1000 0x00 0x00 0x02 0x01 0x00 0x00 0x00 0x06 0x04 0x1000 0x00 0x00 0x03 0x01 0x00 0x00 0x00 0x03 0x04 0x1000 0x00 0x00 0x04 0x01 0x00 0x00 0x00 0x04 0x04 0x1800 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0x06 0x04 0x1800 0x00 0x00 0x02 0x01 0x00 0x00 0x00 0x03 0x04 0x1800 0x00 0x00 0x03 0x01 0x00 0x00 0x00 0x04 0x04 0x1800 0x00 0x00 0x04 0x01 0x00 0x00 0x00 0x05 0x04>; - #interrupt-cells = <0x01>; - ranges = <0x1000000 0x00 0x00 0x00 0x3eff0000 0x00 0x10000 - 0x2000000 0x00 0x10000000 0x00 0x10000000 0x00 0x2eff0000 - 0x3000000 0x80 0x00 0x80 0x00 0x80 0x00>; - reg = <0x40 0x10000000 0x00 0x10000000>; - msi-map = <0x00 0x8006 0x00 0x10000>; - dma-coherent; - bus-range = <0x00 0xff>; - linux,pci-domain = <0x00>; - #size-cells = <0x02>; - #address-cells = <0x03>; - device_type = "pci"; - compatible = "pci-host-ecam-generic"; - }; - - apb-pclk { - phandle = <0x8000>; - clock-output-names = "clk24mhz"; - clock-frequency = <0x16e3600>; - #clock-cells = <0x00>; - compatible = "fixed-clock"; - }; - - // pl011@9000000 { - // clock-names = "uartclk\0apb_pclk"; - // clocks = <0x8000 0x8000>; - // interrupt-parent = <0x01>; - // interrupts = <0x00 0x01 0x04>; - // reg = <0x00 0x9000000 0x00 0x1000>; - // compatible = "arm,pl011\0arm,primecell"; - // }; - - timer { - interrupt-parent = <0x01>; - interrupts = <0x1 0xd 0xf04 0x1 0xe 0xf04 0x1 0xb 0xf04 0x1 0xa 0xf04>; - always-on; - compatible = "arm,armv8-timer", "arm,armv7-timer"; - }; - - // virtio_mmio@a003000 { - // dma-coherent; - // interrupts = <0x0 0x28 0x1>; - // reg = <0x0 0xa003000 0x0 0x200>; - // compatible = "virtio,mmio"; - // }; - - // virtio_mmio@a003200 { - // dma-coherent; - // interrupts = <0x0 0x29 0x1>; - // reg = <0x0 0xa003200 0x0 0x200>; - // compatible = "virtio,mmio"; - // }; - - // virtio_mmio@a003400 { - // dma-coherent; - // interrupts = <0x0 0x2a 0x1>; - // reg = <0x0 0xa003400 0x0 0x200>; - // compatible = "virtio,mmio"; - // }; - - - // virtio serial - virtio_mmio@a003800 { - dma-coherent; - interrupt-parent = <0x01>; - interrupts = <0x0 0x2c 0x1>; - reg = <0x0 0xa003800 0x0 0x200>; - compatible = "virtio,mmio"; - }; - - // virtio net - // virtio_mmio@a003a00 { - // dma-coherent; - // interrupts = <0x0 0x2d 0x1>; - // reg = <0x0 0xa003a00 0x0 0x200>; - // compatible = "virtio,mmio"; - // }; - - // virtio-blk - virtio_mmio@a003c00 { - dma-coherent; - interrupt-parent = <0x01>; - interrupts = <0x0 0x2e 0x1>; - reg = <0x0 0xa003c00 0x0 0x200>; - compatible = "virtio,mmio"; - }; - - // virtio disk-first - // virtio_mmio@a003e00 { - // dma-coherent; - // interrupts = <0x0 0x2f 0x1>; - // reg = <0x0 0xa003e00 0x0 0x200>; - // compatible = "virtio,mmio"; - // }; - - chosen { - bootargs = "earlycon=virtio,mmio,0xa003800 console=hvc0 root=/dev/vda rw"; - // bootargs = "root=/dev/vda mem=768M"; - stdout-path = "/virtio_mmio@a003800"; - }; - -}; diff --git a/images/aarch64/devicetree/linux2.json b/images/aarch64/devicetree/linux2.json deleted file mode 100644 index ad7f91d7..00000000 --- a/images/aarch64/devicetree/linux2.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "arch": "arm64", - "name": "linux2", - "zone_id": 1, - "cpus": [2], - "memory_regions": [ - { - "type": "ram", - "physical_start": "0x50000000", - "virtual_start": "0x50000000", - "size": "0x30000000" - }, - { - "type": "virtio", - "physical_start": "0xa003c00", - "virtual_start": "0xa003c00", - "size": "0x200" - }, - { - "type": "virtio", - "physical_start": "0xa003800", - "virtual_start": "0xa003800", - "size": "0x200" - } - ], - "interrupts": [75, 76, 78, 35, 36, 37, 38], - "kernel_filepath": "./Image", - "dtb_filepath": "./linux2.dtb", - "kernel_load_paddr": "0x50400000", - "dtb_load_paddr": "0x50000000", - "entry_point": "0x50400000", - "arch_config": { - "gicd_base": "0x8000000", - "gicd_size": "0x10000", - "gicr_base": "0x80a0000", - "gicr_size": "0xf60000", - "gits_base": "0x8080000", - "gits_size": "0x20000" - }, - "pci_config": { - "ecam_base": "0x4010000000", - "ecam_size": "0x10000000", - "io_base": "0x3eff0000", - "io_size": "0x10000", - "pci_io_base": "0x0", - "mem32_base": "0x10000000", - "mem32_size": "0x2eff0000", - "pci_mem32_base": "0x10000000", - "mem64_base": "0x8000000000", - "mem64_size": "0x8000000000", - "pci_mem64_base": "0x8000000000" - }, - "num_pci_devs": 2, - "alloc_pci_devs": [0, 16] -} \ No newline at end of file diff --git a/images/aarch64/devicetree/linux3.dts b/images/aarch64/devicetree/linux3.dts deleted file mode 100644 index 11c05bc9..00000000 --- a/images/aarch64/devicetree/linux3.dts +++ /dev/null @@ -1,111 +0,0 @@ -/dts-v1/; - -/ { - #size-cells = <0x2>; - #address-cells = <0x2>; - interrupt-parent = <0x01>; - model = "linux,dummy-virt"; - compatible = "linux,dummy-virt"; - - cpus { - #size-cells = <0x00>; - #address-cells = <0x01>; - - cpu@3 { - reg = <0x03>; - enable-method = "psci"; - compatible = "arm,cortex-a57"; - device_type = "cpu"; - }; - - }; - - psci { - compatible = "arm,psci-0.2"; - method = "smc"; - }; - - memory@50000000 { - device_type = "memory"; - reg = <0x0 0x80000000 0x0 0x10000000>; - }; - - intc@80000000 { - phandle = <0x01>; - interrupts = <0x01 0x09 0x04>; - reg = <0x00 0x8000000 0x00 0x10000 0x00 0x80a0000 0x00 0xf60000>; - #redistributor-regions = <0x01>; - compatible = "arm,gic-v3"; - ranges; - #size-cells = <0x02>; - #address-cells = <0x02>; - interrupt-controller; - #interrupt-cells = <0x03>; - - its@8080000 { - phandle = <0x8006>; - reg = <0x00 0x8080000 0x00 0x20000>; - #msi-cells = <0x01>; - msi-controller; - compatible = "arm,gic-v3-its"; - }; - }; - - pcie@10000000 { - interrupt-map-mask = <0x1800 0x00 0x00 0x07>; - interrupt-map = <0x00 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0x03 0x04 0x00 0x00 0x00 0x02 0x01 0x00 0x00 0x00 0x04 0x04 0x00 0x00 0x00 0x03 0x01 0x00 0x00 0x00 0x05 0x04 0x00 0x00 0x00 0x04 0x01 0x00 0x00 0x00 0x06 0x04 0x800 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0x04 0x04 0x800 0x00 0x00 0x02 0x01 0x00 0x00 0x00 0x05 0x04 0x800 0x00 0x00 0x03 0x01 0x00 0x00 0x00 0x06 0x04 0x800 0x00 0x00 0x04 0x01 0x00 0x00 0x00 0x03 0x04 0x1000 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0x05 0x04 0x1000 0x00 0x00 0x02 0x01 0x00 0x00 0x00 0x06 0x04 0x1000 0x00 0x00 0x03 0x01 0x00 0x00 0x00 0x03 0x04 0x1000 0x00 0x00 0x04 0x01 0x00 0x00 0x00 0x04 0x04 0x1800 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0x06 0x04 0x1800 0x00 0x00 0x02 0x01 0x00 0x00 0x00 0x03 0x04 0x1800 0x00 0x00 0x03 0x01 0x00 0x00 0x00 0x04 0x04 0x1800 0x00 0x00 0x04 0x01 0x00 0x00 0x00 0x05 0x04>; - #interrupt-cells = <0x01>; - ranges = <0x1000000 0x00 0x00 0x00 0x3eff0000 0x00 0x10000 - 0x2000000 0x00 0x10000000 0x00 0x10000000 0x00 0x2eff0000 - 0x3000000 0x80 0x00 0x80 0x00 0x80 0x00>; - reg = <0x40 0x10000000 0x00 0x10000000>; - msi-map = <0x00 0x8006 0x00 0x10000>; - dma-coherent; - bus-range = <0x00 0xff>; - linux,pci-domain = <0x00>; - #size-cells = <0x02>; - #address-cells = <0x03>; - device_type = "pci"; - compatible = "pci-host-ecam-generic"; - }; - - apb-pclk { - phandle = <0x8000>; - clock-output-names = "clk24mhz"; - clock-frequency = <0x16e3600>; - #clock-cells = <0x00>; - compatible = "fixed-clock"; - }; - - timer { - interrupt-parent = <0x01>; - interrupts = <0x1 0xd 0xf04 0x1 0xe 0xf04 0x1 0xb 0xf04 0x1 0xa 0xf04>; - always-on; - compatible = "arm,armv8-timer", "arm,armv7-timer"; - }; - - // virtio-blk - virtio_mmio@a003600 { - dma-coherent; - interrupt-parent = <0x01>; - interrupts = <0x0 0x2e 0x1>; - reg = <0x0 0xa003600 0x0 0x200>; - compatible = "virtio,mmio"; - }; - - // virtio serial - virtio_mmio@a003400 { - dma-coherent; - interrupt-parent = <0x01>; - interrupts = <0x0 0x2c 0x1>; - reg = <0x0 0xa003400 0x0 0x200>; - compatible = "virtio,mmio"; - }; - - chosen { - bootargs = "earlycon=virtio,mmio,0xa004000 console=hvc0 root=/dev/vda rw"; - // bootargs = "root=/dev/vda mem=768M"; - stdout-path = "/virtio_mmio@a004200"; - }; - -}; diff --git a/images/aarch64/devicetree/linux3.json b/images/aarch64/devicetree/linux3.json deleted file mode 100644 index a7f15423..00000000 --- a/images/aarch64/devicetree/linux3.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "arch": "arm64", - "name": "linux3", - "zone_id": 2, - "cpus": [3], - "memory_regions": [ - { - "type": "ram", - "physical_start": "0x80000000", - "virtual_start": "0x80000000", - "size": "0x10000000" - }, - { - "type": "virtio", - "physical_start": "0xa003600", - "virtual_start": "0xa003600", - "size": "0x200" - }, - { - "type": "virtio", - "physical_start": "0xa003400", - "virtual_start": "0xa003400", - "size": "0x200" - } - ], - "interrupts": [75, 76, 78], - "kernel_filepath": "./Image", - "dtb_filepath": "./linux3.dtb", - "kernel_load_paddr": "0x80400000", - "dtb_load_paddr": "0x80000000", - "entry_point": "0x80400000", - "arch_config": { - "gicd_base": "0x8000000", - "gicd_size": "0x10000", - "gicr_base": "0x80a0000", - "gicr_size": "0xf60000", - "gits_base": "0x8080000", - "gits_size": "0x20000" - }, - "pci_config": { - "ecam_base": "0x4010000000", - "ecam_size": "0x10000000", - "io_base": "0x3eff0000", - "io_size": "0x10000", - "pci_io_base": "0x0", - "mem32_base": "0x10000000", - "mem32_size": "0x2eff0000", - "pci_mem32_base": "0x10000000", - "mem64_base": "0x8000000000", - "mem64_size": "0x8000000000", - "pci_mem64_base": "0x8000000000" - }, - "num_pci_devs": 1, - "alloc_pci_devs": [0, 24] -} \ No newline at end of file diff --git a/images/aarch64/devicetree/qemu-aarch64.dts b/images/aarch64/devicetree/qemu-aarch64.dts deleted file mode 100644 index c684d7c4..00000000 --- a/images/aarch64/devicetree/qemu-aarch64.dts +++ /dev/null @@ -1,573 +0,0 @@ -/dts-v1/; - -/ { - interrupt-parent = <0x8011>; - model = "linux,dummy-virt"; - #size-cells = <0x02>; - #address-cells = <0x02>; - compatible = "linux,dummy-virt"; - - psci { - migrate = <0xc4000005>; - cpu_on = <0xc4000003>; - cpu_off = <0x84000002>; - cpu_suspend = <0xc4000001>; - method = "smc"; - compatible = "arm,psci-1.0\0arm,psci-0.2\0arm,psci"; - }; - - memory@40000000 { - reg = <0x00 0x40000000 0x00 0x40000000>; - device_type = "memory"; - }; - - platform-bus@c000000 { - interrupt-parent = <0x8011>; - ranges = <0x00 0x00 0xc000000 0x2000000>; - #address-cells = <0x01>; - #size-cells = <0x01>; - compatible = "qemu,platform\0simple-bus"; - }; - - fw-cfg@9020000 { - dma-coherent; - reg = <0x00 0x9020000 0x00 0x18>; - compatible = "qemu,fw-cfg-mmio"; - }; - - virtio_mmio@a000000 { - dma-coherent; - interrupts = <0x00 0x10 0x01>; - reg = <0x00 0xa000000 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a000200 { - dma-coherent; - interrupts = <0x00 0x11 0x01>; - reg = <0x00 0xa000200 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a000400 { - dma-coherent; - interrupts = <0x00 0x12 0x01>; - reg = <0x00 0xa000400 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a000600 { - dma-coherent; - interrupts = <0x00 0x13 0x01>; - reg = <0x00 0xa000600 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a000800 { - dma-coherent; - interrupts = <0x00 0x14 0x01>; - reg = <0x00 0xa000800 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a000a00 { - dma-coherent; - interrupts = <0x00 0x15 0x01>; - reg = <0x00 0xa000a00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a000c00 { - dma-coherent; - interrupts = <0x00 0x16 0x01>; - reg = <0x00 0xa000c00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a000e00 { - dma-coherent; - interrupts = <0x00 0x17 0x01>; - reg = <0x00 0xa000e00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001000 { - dma-coherent; - interrupts = <0x00 0x18 0x01>; - reg = <0x00 0xa001000 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001200 { - dma-coherent; - interrupts = <0x00 0x19 0x01>; - reg = <0x00 0xa001200 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001400 { - dma-coherent; - interrupts = <0x00 0x1a 0x01>; - reg = <0x00 0xa001400 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001600 { - dma-coherent; - interrupts = <0x00 0x1b 0x01>; - reg = <0x00 0xa001600 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001800 { - dma-coherent; - interrupts = <0x00 0x1c 0x01>; - reg = <0x00 0xa001800 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001a00 { - dma-coherent; - interrupts = <0x00 0x1d 0x01>; - reg = <0x00 0xa001a00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001c00 { - dma-coherent; - interrupts = <0x00 0x1e 0x01>; - reg = <0x00 0xa001c00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001e00 { - dma-coherent; - interrupts = <0x00 0x1f 0x01>; - reg = <0x00 0xa001e00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002000 { - dma-coherent; - interrupts = <0x00 0x20 0x01>; - reg = <0x00 0xa002000 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002200 { - dma-coherent; - interrupts = <0x00 0x21 0x01>; - reg = <0x00 0xa002200 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002400 { - dma-coherent; - interrupts = <0x00 0x22 0x01>; - reg = <0x00 0xa002400 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002600 { - dma-coherent; - interrupts = <0x00 0x23 0x01>; - reg = <0x00 0xa002600 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002800 { - dma-coherent; - interrupts = <0x00 0x24 0x01>; - reg = <0x00 0xa002800 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002a00 { - dma-coherent; - interrupts = <0x00 0x25 0x01>; - reg = <0x00 0xa002a00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002c00 { - dma-coherent; - interrupts = <0x00 0x26 0x01>; - reg = <0x00 0xa002c00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002e00 { - dma-coherent; - interrupts = <0x00 0x27 0x01>; - reg = <0x00 0xa002e00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003000 { - dma-coherent; - interrupts = <0x00 0x28 0x01>; - reg = <0x00 0xa003000 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003200 { - dma-coherent; - interrupts = <0x00 0x29 0x01>; - reg = <0x00 0xa003200 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003400 { - dma-coherent; - interrupts = <0x00 0x2a 0x01>; - reg = <0x00 0xa003400 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003600 { - dma-coherent; - interrupts = <0x00 0x2b 0x01>; - reg = <0x00 0xa003600 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003800 { - dma-coherent; - interrupts = <0x00 0x2c 0x01>; - reg = <0x00 0xa003800 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003a00 { - dma-coherent; - interrupts = <0x00 0x2d 0x01>; - reg = <0x00 0xa003a00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003c00 { - dma-coherent; - interrupts = <0x00 0x2e 0x01>; - reg = <0x00 0xa003c00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003e00 { - dma-coherent; - interrupts = <0x00 0x2f 0x01>; - reg = <0x00 0xa003e00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - gpio-keys { - compatible = "gpio-keys"; - - poweroff { - gpios = <0x8013 0x03 0x00>; - linux,code = <0x74>; - label = "GPIO Key Poweroff"; - }; - }; - - pl061@9030000 { - phandle = <0x8013>; - clock-names = "apb_pclk"; - clocks = <0x8000>; - interrupts = <0x00 0x07 0x04>; - gpio-controller; - #gpio-cells = <0x02>; - compatible = "arm,pl061\0arm,primecell"; - reg = <0x00 0x9030000 0x00 0x1000>; - }; - - pcie@10000000 { - interrupt-map-mask = <0x1800 0x00 0x00 0x07>; - interrupt-map = <0x00 0x00 0x00 0x01 0x8011 0x00 0x00 0x00 0x03 0x04 0x00 0x00 0x00 0x02 0x8011 0x00 0x00 0x00 0x04 0x04 0x00 0x00 0x00 0x03 0x8011 0x00 0x00 0x00 0x05 0x04 0x00 0x00 0x00 0x04 0x8011 0x00 0x00 0x00 0x06 0x04 0x800 0x00 0x00 0x01 0x8011 0x00 0x00 0x00 0x04 0x04 0x800 0x00 0x00 0x02 0x8011 0x00 0x00 0x00 0x05 0x04 0x800 0x00 0x00 0x03 0x8011 0x00 0x00 0x00 0x06 0x04 0x800 0x00 0x00 0x04 0x8011 0x00 0x00 0x00 0x03 0x04 0x1000 0x00 0x00 0x01 0x8011 0x00 0x00 0x00 0x05 0x04 0x1000 0x00 0x00 0x02 0x8011 0x00 0x00 0x00 0x06 0x04 0x1000 0x00 0x00 0x03 0x8011 0x00 0x00 0x00 0x03 0x04 0x1000 0x00 0x00 0x04 0x8011 0x00 0x00 0x00 0x04 0x04 0x1800 0x00 0x00 0x01 0x8011 0x00 0x00 0x00 0x06 0x04 0x1800 0x00 0x00 0x02 0x8011 0x00 0x00 0x00 0x03 0x04 0x1800 0x00 0x00 0x03 0x8011 0x00 0x00 0x00 0x04 0x04 0x1800 0x00 0x00 0x04 0x8011 0x00 0x00 0x00 0x05 0x04>; - #interrupt-cells = <0x01>; - ranges = <0x1000000 0x00 0x00 0x00 0x3eff0000 0x00 0x10000 0x2000000 0x00 0x10000000 0x00 0x10000000 0x00 0x2eff0000 0x3000000 0x80 0x00 0x80 0x00 0x80 0x00>; - reg = <0x40 0x10000000 0x00 0x10000000>; - msi-map = <0x00 0x8012 0x00 0x10000>; - dma-coherent; - bus-range = <0x00 0xff>; - linux,pci-domain = <0x00>; - #size-cells = <0x02>; - #address-cells = <0x03>; - device_type = "pci"; - compatible = "pci-host-ecam-generic"; - }; - - pl031@9010000 { - clock-names = "apb_pclk"; - clocks = <0x8000>; - interrupts = <0x00 0x02 0x04>; - reg = <0x00 0x9010000 0x00 0x1000>; - compatible = "arm,pl031\0arm,primecell"; - }; - - pl011@9000000 { - clock-names = "uartclk\0apb_pclk"; - clocks = <0x8000 0x8000>; - interrupts = <0x00 0x01 0x04>; - reg = <0x00 0x9000000 0x00 0x1000>; - compatible = "arm,pl011\0arm,primecell"; - }; - - pmu { - interrupts = <0x01 0x07 0x04>; - compatible = "arm,armv8-pmuv3"; - }; - - intc@8000000 { - phandle = <0x8011>; - interrupts = <0x01 0x09 0x04>; - reg = <0x00 0x8000000 0x00 0x10000 0x00 0x80a0000 0x00 0xf60000>; - #redistributor-regions = <0x01>; - compatible = "arm,gic-v3"; - ranges; - #size-cells = <0x02>; - #address-cells = <0x02>; - interrupt-controller; - #interrupt-cells = <0x03>; - - its@8080000 { - phandle = <0x8012>; - reg = <0x00 0x8080000 0x00 0x20000>; - #msi-cells = <0x01>; - msi-controller; - compatible = "arm,gic-v3-its"; - }; - }; - - flash@0 { - bank-width = <0x04>; - reg = <0x00 0x00 0x00 0x4000000 0x00 0x4000000 0x00 0x4000000>; - compatible = "cfi-flash"; - }; - - cpus { - #size-cells = <0x00>; - #address-cells = <0x01>; - - cpu-map { - - socket0 { - - cluster0 { - - core0 { - cpu = <0x8010>; - }; - - core1 { - cpu = <0x800f>; - }; - - core2 { - cpu = <0x800e>; - }; - - core3 { - cpu = <0x800d>; - }; - - core4 { - cpu = <0x800c>; - }; - - core5 { - cpu = <0x800b>; - }; - - core6 { - cpu = <0x800a>; - }; - - core7 { - cpu = <0x8009>; - }; - - core8 { - cpu = <0x8008>; - }; - - core9 { - cpu = <0x8007>; - }; - - core10 { - cpu = <0x8006>; - }; - - core11 { - cpu = <0x8005>; - }; - - core12 { - cpu = <0x8004>; - }; - - core13 { - cpu = <0x8003>; - }; - - core14 { - cpu = <0x8002>; - }; - - core15 { - cpu = <0x8001>; - }; - }; - }; - }; - - cpu@0 { - phandle = <0x8010>; - reg = <0x00>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - - cpu@1 { - phandle = <0x800f>; - reg = <0x01>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - - cpu@2 { - phandle = <0x800e>; - reg = <0x02>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - - cpu@3 { - phandle = <0x800d>; - reg = <0x03>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - - cpu@4 { - phandle = <0x800c>; - reg = <0x04>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - - cpu@5 { - phandle = <0x800b>; - reg = <0x05>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - - cpu@6 { - phandle = <0x800a>; - reg = <0x06>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - - cpu@7 { - phandle = <0x8009>; - reg = <0x07>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - - cpu@8 { - phandle = <0x8008>; - reg = <0x08>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - - cpu@9 { - phandle = <0x8007>; - reg = <0x09>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - - cpu@10 { - phandle = <0x8006>; - reg = <0x0a>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - - cpu@11 { - phandle = <0x8005>; - reg = <0x0b>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - - cpu@12 { - phandle = <0x8004>; - reg = <0x0c>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - - cpu@13 { - phandle = <0x8003>; - reg = <0x0d>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - - cpu@14 { - phandle = <0x8002>; - reg = <0x0e>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - - cpu@15 { - phandle = <0x8001>; - reg = <0x0f>; - enable-method = "psci"; - compatible = "arm,cortex-a53"; - device_type = "cpu"; - }; - }; - - timer { - interrupts = <0x01 0x0d 0x04 0x01 0x0e 0x04 0x01 0x0b 0x04 0x01 0x0a 0x04>; - always-on; - compatible = "arm,armv8-timer\0arm,armv7-timer"; - }; - - apb-pclk { - phandle = <0x8000>; - clock-output-names = "clk24mhz"; - clock-frequency = <0x16e3600>; - #clock-cells = <0x00>; - compatible = "fixed-clock"; - }; - - chosen { - bootargs = "console=ttyAMA0 root=/dev/vda rw mem=768m"; - stdout-path = "/pl011@9000000"; - rng-seed = <0x1ec18ac7 0xa9f039b6 0xcd45998b 0xc1beced4 0x9633a3af 0x30fad1c0 0xa2ee80f2 0xe0350a7>; - kaslr-seed = <0x77a35f20 0xd8dde8a5>; - }; -}; diff --git a/images/aarch64/devicetree/qemu-ruxos.dts b/images/aarch64/devicetree/qemu-ruxos.dts deleted file mode 100644 index 1b2e5e73..00000000 --- a/images/aarch64/devicetree/qemu-ruxos.dts +++ /dev/null @@ -1,389 +0,0 @@ -/dts-v1/; - -/ { - interrupt-parent = <0x8002>; - #size-cells = <0x02>; - #address-cells = <0x02>; - compatible = "linux,dummy-virt"; - - psci { - migrate = <0xc4000005>; - cpu_on = <0xc4000003>; - cpu_off = <0x84000002>; - cpu_suspend = <0xc4000001>; - method = "hvc"; - compatible = "arm,psci-0.2\0arm,psci"; - }; - - memory@40000000 { - reg = <0x00 0x40000000 0x00 0x80000000>; - device_type = "memory"; - }; - - platform@c000000 { - interrupt-parent = <0x8002>; - ranges = <0x00 0x00 0xc000000 0x2000000>; - #address-cells = <0x01>; - #size-cells = <0x01>; - compatible = "qemu,platform\0simple-bus"; - }; - - fw-cfg@9020000 { - dma-coherent; - reg = <0x00 0x9020000 0x00 0x18>; - compatible = "qemu,fw-cfg-mmio"; - }; - - virtio_mmio@a000000 { - dma-coherent; - interrupts = <0x00 0x10 0x01>; - reg = <0x00 0xa000000 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a000200 { - dma-coherent; - interrupts = <0x00 0x11 0x01>; - reg = <0x00 0xa000200 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a000400 { - dma-coherent; - interrupts = <0x00 0x12 0x01>; - reg = <0x00 0xa000400 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a000600 { - dma-coherent; - interrupts = <0x00 0x13 0x01>; - reg = <0x00 0xa000600 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a000800 { - dma-coherent; - interrupts = <0x00 0x14 0x01>; - reg = <0x00 0xa000800 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a000a00 { - dma-coherent; - interrupts = <0x00 0x15 0x01>; - reg = <0x00 0xa000a00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a000c00 { - dma-coherent; - interrupts = <0x00 0x16 0x01>; - reg = <0x00 0xa000c00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a000e00 { - dma-coherent; - interrupts = <0x00 0x17 0x01>; - reg = <0x00 0xa000e00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001000 { - dma-coherent; - interrupts = <0x00 0x18 0x01>; - reg = <0x00 0xa001000 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001200 { - dma-coherent; - interrupts = <0x00 0x19 0x01>; - reg = <0x00 0xa001200 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001400 { - dma-coherent; - interrupts = <0x00 0x1a 0x01>; - reg = <0x00 0xa001400 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001600 { - dma-coherent; - interrupts = <0x00 0x1b 0x01>; - reg = <0x00 0xa001600 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001800 { - dma-coherent; - interrupts = <0x00 0x1c 0x01>; - reg = <0x00 0xa001800 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001a00 { - dma-coherent; - interrupts = <0x00 0x1d 0x01>; - reg = <0x00 0xa001a00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001c00 { - dma-coherent; - interrupts = <0x00 0x1e 0x01>; - reg = <0x00 0xa001c00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a001e00 { - dma-coherent; - interrupts = <0x00 0x1f 0x01>; - reg = <0x00 0xa001e00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002000 { - dma-coherent; - interrupts = <0x00 0x20 0x01>; - reg = <0x00 0xa002000 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002200 { - dma-coherent; - interrupts = <0x00 0x21 0x01>; - reg = <0x00 0xa002200 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002400 { - dma-coherent; - interrupts = <0x00 0x22 0x01>; - reg = <0x00 0xa002400 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002600 { - dma-coherent; - interrupts = <0x00 0x23 0x01>; - reg = <0x00 0xa002600 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002800 { - dma-coherent; - interrupts = <0x00 0x24 0x01>; - reg = <0x00 0xa002800 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002a00 { - dma-coherent; - interrupts = <0x00 0x25 0x01>; - reg = <0x00 0xa002a00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002c00 { - dma-coherent; - interrupts = <0x00 0x26 0x01>; - reg = <0x00 0xa002c00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a002e00 { - dma-coherent; - interrupts = <0x00 0x27 0x01>; - reg = <0x00 0xa002e00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003000 { - dma-coherent; - interrupts = <0x00 0x28 0x01>; - reg = <0x00 0xa003000 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003200 { - dma-coherent; - interrupts = <0x00 0x29 0x01>; - reg = <0x00 0xa003200 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003400 { - dma-coherent; - interrupts = <0x00 0x2a 0x01>; - reg = <0x00 0xa003400 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003600 { - dma-coherent; - interrupts = <0x00 0x2b 0x01>; - reg = <0x00 0xa003600 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003800 { - dma-coherent; - interrupts = <0x00 0x2c 0x01>; - reg = <0x00 0xa003800 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003a00 { - dma-coherent; - interrupts = <0x00 0x2d 0x01>; - reg = <0x00 0xa003a00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003c00 { - dma-coherent; - interrupts = <0x00 0x2e 0x01>; - reg = <0x00 0xa003c00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@a003e00 { - dma-coherent; - interrupts = <0x00 0x2f 0x01>; - reg = <0x00 0xa003e00 0x00 0x200>; - compatible = "virtio,mmio"; - }; - - gpio-keys { - #address-cells = <0x01>; - #size-cells = <0x00>; - compatible = "gpio-keys"; - - poweroff { - gpios = <0x8004 0x03 0x00>; - linux,code = <0x74>; - label = "GPIO Key Poweroff"; - }; - }; - - pl061@9030000 { - phandle = <0x8004>; - clock-names = "apb_pclk"; - clocks = <0x8000>; - interrupts = <0x00 0x07 0x04>; - gpio-controller; - #gpio-cells = <0x02>; - compatible = "arm,pl061\0arm,primecell"; - reg = <0x00 0x9030000 0x00 0x1000>; - }; - - pcie@10000000 { - interrupt-map-mask = <0x1800 0x00 0x00 0x07>; - interrupt-map = <0x00 0x00 0x00 0x01 0x8002 0x00 0x00 0x00 0x03 0x04 0x00 0x00 0x00 0x02 0x8002 0x00 0x00 0x00 0x04 0x04 0x00 0x00 0x00 0x03 0x8002 0x00 0x00 0x00 0x05 0x04 0x00 0x00 0x00 0x04 0x8002 0x00 0x00 0x00 0x06 0x04 0x800 0x00 0x00 0x01 0x8002 0x00 0x00 0x00 0x04 0x04 0x800 0x00 0x00 0x02 0x8002 0x00 0x00 0x00 0x05 0x04 0x800 0x00 0x00 0x03 0x8002 0x00 0x00 0x00 0x06 0x04 0x800 0x00 0x00 0x04 0x8002 0x00 0x00 0x00 0x03 0x04 0x1000 0x00 0x00 0x01 0x8002 0x00 0x00 0x00 0x05 0x04 0x1000 0x00 0x00 0x02 0x8002 0x00 0x00 0x00 0x06 0x04 0x1000 0x00 0x00 0x03 0x8002 0x00 0x00 0x00 0x03 0x04 0x1000 0x00 0x00 0x04 0x8002 0x00 0x00 0x00 0x04 0x04 0x1800 0x00 0x00 0x01 0x8002 0x00 0x00 0x00 0x06 0x04 0x1800 0x00 0x00 0x02 0x8002 0x00 0x00 0x00 0x03 0x04 0x1800 0x00 0x00 0x03 0x8002 0x00 0x00 0x00 0x04 0x04 0x1800 0x00 0x00 0x04 0x8002 0x00 0x00 0x00 0x05 0x04>; - #interrupt-cells = <0x01>; - ranges = <0x1000000 0x00 0x00 0x00 0x3eff0000 0x00 0x10000 0x2000000 0x00 0x10000000 0x00 0x10000000 0x00 0x2eff0000 0x3000000 0x80 0x00 0x80 0x00 0x80 0x00>; - reg = <0x40 0x10000000 0x00 0x10000000>; - msi-parent = <0x8003>; - dma-coherent; - bus-range = <0x00 0xff>; - linux,pci-domain = <0x00>; - #size-cells = <0x02>; - #address-cells = <0x03>; - device_type = "pci"; - compatible = "pci-host-ecam-generic"; - }; - - pl031@9010000 { - clock-names = "apb_pclk"; - clocks = <0x8000>; - interrupts = <0x00 0x02 0x04>; - reg = <0x00 0x9010000 0x00 0x1000>; - compatible = "arm,pl031\0arm,primecell"; - }; - - pl011@9000000 { - clock-names = "uartclk\0apb_pclk"; - clocks = <0x8000 0x8000>; - interrupts = <0x00 0x01 0x04>; - reg = <0x00 0x9000000 0x00 0x1000>; - compatible = "arm,pl011\0arm,primecell"; - }; - - pmu { - interrupts = <0x01 0x07 0x104>; - compatible = "arm,armv8-pmuv3"; - }; - - intc@8000000 { - phandle = <0x8002>; - reg = <0x00 0x8000000 0x00 0x10000 0x00 0x8010000 0x00 0x10000>; - compatible = "arm,cortex-a15-gic"; - ranges; - #size-cells = <0x02>; - #address-cells = <0x02>; - interrupt-controller; - #interrupt-cells = <0x03>; - - v2m@8020000 { - phandle = <0x8003>; - reg = <0x00 0x8020000 0x00 0x1000>; - msi-controller; - compatible = "arm,gic-v2m-frame"; - }; - }; - - flash@0 { - bank-width = <0x04>; - reg = <0x00 0x00 0x00 0x4000000 0x00 0x4000000 0x00 0x4000000>; - compatible = "cfi-flash"; - }; - - cpus { - #size-cells = <0x00>; - #address-cells = <0x01>; - - cpu-map { - - socket0 { - - cluster0 { - - core0 { - cpu = <0x8001>; - }; - }; - }; - }; - - cpu@0 { - phandle = <0x8001>; - reg = <0x00>; - compatible = "arm,cortex-a72"; - device_type = "cpu"; - }; - }; - - timer { - interrupts = <0x01 0x0d 0x104 0x01 0x0e 0x104 0x01 0x0b 0x104 0x01 0x0a 0x104>; - always-on; - compatible = "arm,armv8-timer\0arm,armv7-timer"; - }; - - apb-pclk { - phandle = <0x8000>; - clock-output-names = "clk24mhz"; - clock-frequency = <0x16e3600>; - #clock-cells = <0x00>; - compatible = "fixed-clock"; - }; - - chosen { - bootargs = ";;"; - stdout-path = "/pl011@9000000"; - kaslr-seed = <0x1d06f5a3 0x618ece1c>; - }; -}; diff --git a/images/aarch64/devicetree/qemu-ruxos.json b/images/aarch64/devicetree/qemu-ruxos.json deleted file mode 100644 index edeac7dc..00000000 --- a/images/aarch64/devicetree/qemu-ruxos.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "arch": "arm64", - "zone_id": 1, - "cpus": [2, 3], - "memory_regions": [ - { - "type": "ram", - "physical_start": "0x50000000", - "virtual_start": "0x40000000", - "size": "0x30000000" - }, - { - "type": "io", - "physical_start": "0x9000000", - "virtual_start": "0x9000000", - "size": "0x1000" - } - ], - "interrupts": [], - "kernel_filepath": "./helloworld_aarch64-qemu-virt.bin", - "dtb_filepath": "./qemu-ruxos.dtb", - "kernel_load_paddr": "0x50080000", - "dtb_load_paddr": "0x50000000", - "entry_point": "0x40080000" -} \ No newline at end of file diff --git a/images/aarch64/devicetree/trans_file.sh b/images/aarch64/devicetree/trans_file.sh deleted file mode 100755 index 082a721e..00000000 --- a/images/aarch64/devicetree/trans_file.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " - exit 1 -fi - -file_path=$1 -disk_path="../virtdisk" -# 检查文件是否存在 -if [ ! -f "$file_path" ]; then - echo "Error: File '$file_path' not found." - exit 1 -fi - -sudo mount "$disk_path"/rootfs1.ext4 "$disk_path"/rootfs -sudo cp "$file_path" "$disk_path"/rootfs/home/arm64/ - -if [ $? -eq 0 ]; then - echo "File has been successfully copied" -else - echo "Error: Failed to copy the file." - exit 1 -fi -sudo umount "$disk_path"/rootfs diff --git a/images/aarch64/devicetree/virtio_cfg2.json b/images/aarch64/devicetree/virtio_cfg2.json deleted file mode 100644 index 7b74ec89..00000000 --- a/images/aarch64/devicetree/virtio_cfg2.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "zones": [ - { - "id": 1, - "memory_region": ["0x50000000", "0x30000000"], - "devices": [ - { - "type": "blk", - "addr": "0xa003c00", - "len": "0x200", - "irq": 78, - "img": "rootfs2.ext4", - "status": "enable" - }, - { - "type": "console", - "addr": "0xa003800", - "len": "0x200", - "irq": 76, - "status": "enable" - }, - { - "type": "net", - "addr": "0xa003600", - "len": "0x200", - "irq": 75, - "tap": "tap0", - "mac": ["0x00", "0x16", "0x3e", "0x10", "0x10", "0x10"], - "status": "disable" - } - ] - } - ] -} \ No newline at end of file diff --git a/images/aarch64/devicetree/virtio_cfg3.json b/images/aarch64/devicetree/virtio_cfg3.json deleted file mode 100644 index d535364e..00000000 --- a/images/aarch64/devicetree/virtio_cfg3.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "zones": [ - { - "id": 2, - "memory_region": ["0x80000000", "0x10000000"], - "devices": [ - { - "type": "blk", - "addr": "0xa003600", - "len": "0x200", - "irq": 78, - "img": "rootfs3.ext4", - "status": "enable" - }, - { - "type": "console", - "addr": "0xa003400", - "len": "0x200", - "irq": 76, - "status": "enable" - } - ] - } - ] -} \ No newline at end of file diff --git a/images/loongarch64/devicetree/.gitignore b/images/loongarch64/devicetree/.gitignore deleted file mode 100644 index 53492d47..00000000 --- a/images/loongarch64/devicetree/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.dtb \ No newline at end of file diff --git a/images/loongarch64/devicetree/Makefile b/images/loongarch64/devicetree/Makefile deleted file mode 100644 index df4cda2a..00000000 --- a/images/loongarch64/devicetree/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Find all .dts files in the current directory -DTS_FILES := $(wildcard *.dts) - -# Replace the .dts file extension with .dtb for all files found -DTB_FILES := $(DTS_FILES:.dts=.dtb) - -# Default target -all: $(DTB_FILES) - -# Pattern rule: how to generate a .dtb from a .dts -%.dtb: %.dts -# dtc -I dts -O dtb $< -o $@ - cpp -nostdinc -I include -undef -x assembler-with-cpp -o $*.dts.tmp $< - dtc -I dts -O dtb $*.dts.tmp -o $@ - rm -f $*.dts.tmp - -# Clean target to remove generated files -clean: - rm -f $(DTB_FILES) diff --git a/images/loongarch64/devicetree/loongson3.dtsi b/images/loongarch64/devicetree/loongson3.dtsi deleted file mode 100644 index c21c1a42..00000000 --- a/images/loongarch64/devicetree/loongson3.dtsi +++ /dev/null @@ -1,236 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/ { - /* - * Loongson-3 may have as many as 4 nodes, each node has 4 cores. - * Each core has its own pcache and cores in the same node share scache. - */ - cpus { - #address-cells = <1>; - #size-cells = <0>; - - cpu@0 { - compatible = "loongson,loongson3"; - device_type = "cpu"; - reg = <0x0>; - l2-cache = <&vcache0>; - next-level-cache = <&scache0>; - numa-node-id = <0>; - }; - - // cpu@1 { - // compatible = "loongson,loongson3"; - // device_type = "cpu"; - // reg = <0x1>; - // l2-cache = <&vcache1>; - // next-level-cache = <&scache0>; - // }; - - // cpu@2 { - // compatible = "loongson,loongson3"; - // device_type = "cpu"; - // reg = <0x2>; - // l2-cache = <&vcache2>; - // next-level-cache = <&scache0>; - // }; - - // cpu@3 { - // compatible = "loongson,loongson3"; - // device_type = "cpu"; - // reg = <0x3>; - // l2-cache = <&vcache3>; - // next-level-cache = <&scache0>; - // }; - - // cpu@4 { - // compatible = "loongson,loongson3"; - // device_type = "cpu"; - // reg = <0x4>; - // l2-cache = <&vcache4>; - // next-level-cache = <&scache1>; - // }; - - // cpu@5 { - // compatible = "loongson,loongson3"; - // device_type = "cpu"; - // reg = <0x5>; - // l2-cache = <&vcache5>; - // next-level-cache = <&scache1>; - // }; - - // cpu@6 { - // compatible = "loongson,loongson3"; - // device_type = "cpu"; - // reg = <0x6>; - // l2-cache = <&vcache6>; - // next-level-cache = <&scache1>; - // }; - - // cpu@7 { - // compatible = "loongson,loongson3"; - // device_type = "cpu"; - // reg = <0x7>; - // l2-cache = <&vcache7>; - // next-level-cache = <&scache1>; - // }; - - // cpu@8 { - // compatible = "loongson,loongson3"; - // device_type = "cpu"; - // reg = <0x8>; - // l2-cache = <&vcache8>; - // next-level-cache = <&scache2>; - // }; - - // cpu@9 { - // compatible = "loongson,loongson3"; - // device_type = "cpu"; - // reg = <0x9>; - // l2-cache = <&vcache9>; - // next-level-cache = <&scache2>; - // }; - - // cpu@a { - // compatible = "loongson,loongson3"; - // device_type = "cpu"; - // reg = <0xa>; - // l2-cache = <&vcachea>; - // next-level-cache = <&scache2>; - // }; - - // cpu@b { - // compatible = "loongson,loongson3"; - // device_type = "cpu"; - // reg = <0xb>; - // l2-cache = <&vcacheb>; - // next-level-cache = <&scache2>; - // }; - - // cpu@c { - // compatible = "loongson,loongson3"; - // device_type = "cpu"; - // reg = <0xc>; - // l2-cache = <&vcachec>; - // next-level-cache = <&scache3>; - // }; - - // cpu@d { - // compatible = "loongson,loongson3"; - // device_type = "cpu"; - // reg = <0xd>; - // l2-cache = <&vcached>; - // next-level-cache = <&scache3>; - // }; - - // cpu@e { - // compatible = "loongson,loongson3"; - // device_type = "cpu"; - // reg = <0xe>; - // l2-cache = <&vcachee>; - // next-level-cache = <&scache3>; - // }; - - // cpu@f { - // compatible = "loongson,loongson3"; - // device_type = "cpu"; - // reg = <0xf>; - // l2-cache = <&vcachef>; - // next-level-cache = <&scache3>; - // }; - - vcache0: l2-cache0 { - compatible = "cache"; - next-level-cache = <&scache0>; - }; - - vcache1: l2-cache1 { - compatible = "cache"; - next-level-cache = <&scache0>; - }; - - vcache2: l2-cache2 { - compatible = "cache"; - next-level-cache = <&scache0>; - }; - - vcache3: l2-cache3 { - compatible = "cache"; - next-level-cache = <&scache0>; - }; - - vcache4: l2-cache4 { - compatible = "cache"; - next-level-cache = <&scache1>; - }; - - vcache5: l2-cache5 { - compatible = "cache"; - next-level-cache = <&scache1>; - }; - - vcache6: l2-cache6 { - compatible = "cahce"; - next-level-cache = <&scache1>; - }; - - vcache7: l2-cache7 { - compatible = "cache"; - next-level-cache = <&scache1>; - }; - - vcache8: l2-cache8 { - compatible = "cache"; - next-level-cache = <&scache2>; - }; - - vcache9: l2-cache9 { - compatible = "cache"; - next-level-cache = <&scache2>; - }; - - vcachea: l2-cachea { - compatible = "cache"; - next-level-cache = <&scache2>; - }; - - vcacheb: l2-cacheb { - compatible = "cache"; - next-level-cache = <&scache2>; - }; - - vcachec: l2-cachec { - compatible = "cache"; - next-level-cache = <&scache3>; - }; - - vcached: l2-cached { - compatible = "cache"; - next-level-cache = <&scache3>; - }; - - vcachee: l2-cachee { - compatible = "cache"; - next-level-cache = <&scache3>; - }; - - vcachef: l2-cachef { - compatible = "cache"; - next-level-cache = <&scache3>; - }; - - scache0: l3-cache0 { - compatible = "cache"; - }; - - scache1: l3-cache1 { - compatible = "cache"; - }; - - scache2: l3-cache2 { - compatible = "cache"; - }; - - scache3: l3-cache3 { - compatible = "cache"; - }; - }; -}; diff --git a/images/loongarch64/devicetree/loongson3_ls7a.dts b/images/loongarch64/devicetree/loongson3_ls7a.dts deleted file mode 100644 index 949045a3..00000000 --- a/images/loongarch64/devicetree/loongson3_ls7a.dts +++ /dev/null @@ -1,105 +0,0 @@ -/dts-v1/; -/* -This is a customized dts file for 3A5000+7A2000 board. -wheatfox 2024 -*/ -#include "loongson3.dtsi" -/ { - model = "loongson,generic"; - compatible = "loongson,loongson3"; - #address-cells = <2>; - #size-cells = <2>; - - aliases { - serial0 = &uart0; - // serial1 = &uart1; - }; - - chosen { - stdout-path = "serial0:115200n8"; - bootargs = "earlycon console=ttyS0,115200n8 initramfs_async=false rootwait"; - // linux,initrd-start = <0 0x90000000>; - // linux,initrd-end = <0 0x93c00000>; // size = 60M ext4 - }; - - mem: memory { - name = "memory"; - device_type = "memory"; - // reg = <0 0x00200000 0 0x0ee00000 - // 0 0x90000000 0 0x10000000>; - reg = <0 0x00200000 0 0x0ee00000 - 0 0x90000000 0 0x10000000>; - }; - - cpuic: interrupt-controller { - compatible = "loongson,cpu-interrupt-controller"; - interrupt-controller; - #interrupt-cells = <1>; - }; - - icu: interrupt-controller@1fe01400 { - compatible = "loongson"; - interrupt-controller; - #interrupt-cells = <1>; - reg = <0 0x1fe01400 0 0x40 - 0 0x1fe01040 0 16>; - interrupt-parent = <&cpuic>; - interrupt-names = "cascade"; - interrupts = <3>; /* HW IP1 */ - }; - - board: platform { - compatible = "loongson,nbus", "simple-bus"; - #address-cells = <2>; - #size-cells = <2>; - // enable-lpc-irq; - // ranges = <0x000 0x00000000 0x000 0x00000000 0x20000000 - // 0x000 0x40000000 0x000 0x40000000 0x40000000 - // 0xe00 0x00000000 0xe00 0x00000000 0x80000000>; - ranges = <0 0x10000000 0 0x10000000 0 0x10000000 - 0 0x2000000 0 0x2000000 0 0x2000000 - 0 0x20000000 0 0x20000000 0 0x10000000 - 0 0x40000000 0 0x40000000 0 0x40000000 - 0xfe 0x00000000 0xfe 0x00000000 0 0x40000000>; - - osc_clk: osc-clock@0 { - #clock-cells = <0>; - compatible = "fixed-clock"; - clock-frequency = <100000000>; - clock-output-names = "ref_clk"; - reg = <0 0 0 0>; - }; - - clks: clock-controller@1fe00480 { - compatible = "loongson,ls2x-clk"; - reg = <0 0x1fe00480 0 1>; - clocks = <&osc_clk>; - clock-names = "ref_clk"; - #clock-cells = <1>; - }; - - uart0: serial@1fe001e0 { - device_type = "serial"; - compatible = "ns16550a"; - reg = <0 0x1fe001e0 0 0x10>; - clocks = <&clks 12>; - clock-frequency = <100000000>; - // interrupts = <10>; - interrupt-parent = <&icu>; - no-loopback-test; - status = "okay"; - }; - - // uart1: serial@1fe001e8 { - // device_type = "serial"; - // compatible = "ns16550a"; - // reg = <0 0x1fe001e8 0 0x10>; - // clocks = <&clks 12>; - // clock-frequency = <100000000>; - // // interrupts = <11>; - // // interrupt-parent = <&icu>; - // no-loopback-test; - // status = "disabled"; - // }; - }; -}; diff --git a/images/riscv64/devicetree/Makefile b/images/riscv64/devicetree/Makefile deleted file mode 100644 index c45c1b29..00000000 --- a/images/riscv64/devicetree/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# Find all .dts files in the current directory -DTS_FILES := $(wildcard *.dts) - -# Replace the .dts file extension with .dtb for all files found -DTB_FILES := $(DTS_FILES:.dts=.dtb) - -# Default target -all: $(DTB_FILES) - -# Pattern rule: how to generate a .dtb from a .dts -%.dtb: %.dts - dtc -I dts -O dtb $< -o $@ - -# Clean target to remove generated files -clean: - rm -f $(DTB_FILES) diff --git a/images/riscv64/devicetree/linux1.dts b/images/riscv64/devicetree/linux1.dts deleted file mode 100644 index 84cdb0ee..00000000 --- a/images/riscv64/devicetree/linux1.dts +++ /dev/null @@ -1,176 +0,0 @@ -/dts-v1/; - -/ { - #address-cells = <0x2>; - #size-cells = <0x2>; - - cpus { - #address-cells = <0x1>; - #size-cells = <0x0>; - timebase-frequency = <10000000>; - - cpu@0 { - device_type = "cpu"; - reg = <0x0>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu_sstc"; - mmu-type = "riscv,sv39"; - - cpu0_intc: interrupt-controller { - #interrupt-cells = <0x1>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - }; - }; - - cpu@1 { - device_type = "cpu"; - reg = <0x1>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu_sstc"; - mmu-type = "riscv,sv39"; - - cpu1_intc: interrupt-controller { - #interrupt-cells = <0x1>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - }; - }; - cpu@2 { - device_type = "cpu"; - reg = <0x2>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu_sstc"; - mmu-type = "riscv,sv39"; - - cpu2_intc: interrupt-controller { - #interrupt-cells = <0x1>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - }; - }; - - }; - - memory@83000000 { - device_type = "memory"; - reg = <0x0 0x83000000 0x0 0x1D000000>; - }; - - reserved-memory { - #address-cells = <0x02>; - #size-cells = <0x02>; - ranges; - - nonroot@0x83000000 { - no-map; - reg = <0x00 0x83000000 0x00 0x0C000000>; - }; - - dtbfile@0x8f000000 { - no-map; - reg = <0x00 0x8f000000 0x00 0x01000000>; - }; - }; - - soc{ - #address-cells = <0x02>; - #size-cells = <0x02>; - compatible = "simple-bus"; - ranges; - plic: interrupt-controller@c000000 { - riscv,ndev = <60>; - reg = <0x0 0xc000000 0x0 0x4000000>; - interrupts-extended = < - &cpu0_intc 11 &cpu0_intc 9 - &cpu1_intc 11 &cpu1_intc 9 - &cpu2_intc 11 &cpu2_intc 9 - >; - interrupt-controller; - compatible = "riscv,plic0"; - #interrupt-cells = <0x1>; - }; - uart@10000000 { - interrupts = <0x0a>; - interrupt-parent = <&plic>; - clock-frequency = "\08@"; - reg = <0x00 0x10000000 0x00 0x100>; - compatible = "ns16550a"; - }; - pci@30000000 { - interrupt-map-mask = <0x1800 0x00 0x00 0x07>; - interrupt-map = <0x00 0x00 0x00 0x01 0x09 0x20 0x00 0x00 0x00 0x02 0x09 0x21 0x00 0x00 0x00 0x03 0x09 0x22 0x00 0x00 0x00 0x04 0x09 0x23 0x800 0x00 0x00 0x01 0x09 0x21 0x800 0x00 0x00 0x02 0x09 0x22 0x800 0x00 0x00 0x03 0x09 0x23 0x800 0x00 0x00 0x04 0x09 0x20 0x1000 0x00 0x00 0x01 0x09 0x22 0x1000 0x00 0x00 0x02 0x09 0x23 0x1000 0x00 0x00 0x03 0x09 0x20 0x1000 0x00 0x00 0x04 0x09 0x21 0x1800 0x00 0x00 0x01 0x09 0x23 0x1800 0x00 0x00 0x02 0x09 0x20 0x1800 0x00 0x00 0x03 0x09 0x21 0x1800 0x00 0x00 0x04 0x09 0x22>; - ranges = <0x1000000 0x00 0x00 0x00 0x3000000 0x00 0x10000 0x2000000 0x00 0x40000000 0x00 0x40000000 0x00 0x40000000 0x3000000 0x04 0x00 0x04 0x00 0x04 0x00>; - reg = <0x00 0x30000000 0x00 0x10000000>; - dma-coherent; - bus-range = <0x00 0xff>; - linux,pci-domain = <0x00>; - device_type = "pci"; - compatible = "pci-host-ecam-generic"; - #size-cells = <0x02>; - #interrupt-cells = <0x01>; - #address-cells = <0x03>; - }; - - virtio_mmio@10008000 { - interrupts = <0x8>; - interrupt-parent = <&plic>; - reg = <0x0 0x10008000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - // virtio_mmio@10007000 { - // interrupts = <0x7>; - // interrupt-parent = <&plic>; - // reg = <0x0 0x10007000 0x0 0x1000>; - // compatible = "virtio,mmio"; - // }; - // virtio_mmio@10006000 { - // interrupts = <0x6>; - // interrupt-parent = <&plic>; - // reg = <0x0 0x10006000 0x0 0x1000>; - // compatible = "virtio,mmio"; - // }; - - virtio_mmio@10005000 { - interrupts = <0x5>; - interrupt-parent = <&plic>; - reg = <0x0 0x10005000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10004000 { - interrupts = <0x4>; - interrupt-parent = <&plic>; - reg = <0x0 0x10004000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10003000 { - interrupts = <0x3>; - interrupt-parent = <&plic>; - reg = <0x0 0x10003000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10002000 { - interrupts = <0x2>; - interrupt-parent = <&plic>; - reg = <0x0 0x10002000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10001000 { - interrupts = <0x1>; - interrupt-parent = <&plic>; - reg = <0x0 0x10001000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - }; - chosen { - bootargs = "root=/dev/vda rw earlycon console=ttyS0 init=/bin/bash"; - }; - -}; diff --git a/images/riscv64/devicetree/linux2.dts b/images/riscv64/devicetree/linux2.dts deleted file mode 100644 index 487cfeca..00000000 --- a/images/riscv64/devicetree/linux2.dts +++ /dev/null @@ -1,107 +0,0 @@ -/dts-v1/; - -/ { - #address-cells = <0x2>; - #size-cells = <0x2>; - - cpus { - #address-cells = <0x1>; - #size-cells = <0x0>; - timebase-frequency = <10000000>; - cpu@3 { - device_type = "cpu"; - reg = <0x3>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu_sstc"; - mmu-type = "riscv,sv39"; - - cpu3_intc: interrupt-controller { - #interrupt-cells = <0x1>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - }; - }; - - }; - - memory@84000000 { - device_type = "memory"; - reg = <0x0 0x84000000 0x0 0x08000000>; - }; -soc{ - #address-cells = <0x02>; - #size-cells = <0x02>; - compatible = "simple-bus"; - ranges; - plic: interrupt-controller@c000000 { - riscv,ndev = <60>; - reg = <0x0 0xc000000 0x0 0x4000000>; - interrupts-extended = < - &cpu3_intc 11 &cpu3_intc 9 - >; - interrupt-controller; - compatible = "riscv,plic0"; - #interrupt-cells = <0x1>; - }; - -// virtio_mmio@10008000 { -// interrupts = <0x8>; -// interrupt-parent = <&plic>; -// reg = <0x0 0x10008000 0x0 0x1000>; -// compatible = "virtio,mmio"; -// }; - virtio_mmio@10007000 { - interrupts = <0x7>; - interrupt-parent = <&plic>; - reg = <0x0 0x10007000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - virtio_mmio@10006000 { - interrupts = <0x6>; - interrupt-parent = <&plic>; - reg = <0x0 0x10006000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; -// -// virtio_mmio@10005000 { -// interrupts = <0x5>; -// interrupt-parent = <&plic>; -// reg = <0x0 0x10005000 0x0 0x1000>; -// compatible = "virtio,mmio"; -// }; -// -// virtio_mmio@10004000 { -// interrupts = <0x4>; -// interrupt-parent = <&plic>; -// reg = <0x0 0x10004000 0x0 0x1000>; -// compatible = "virtio,mmio"; -// }; -// -// virtio_mmio@10003000 { -// interrupts = <0x3>; -// interrupt-parent = <&plic>; -// reg = <0x0 0x10003000 0x0 0x1000>; -// compatible = "virtio,mmio"; -// }; -// -// virtio_mmio@10002000 { -// interrupts = <0x2>; -// interrupt-parent = <&plic>; -// reg = <0x0 0x10002000 0x0 0x1000>; -// compatible = "virtio,mmio"; -// }; -// -// virtio_mmio@10001000 { -// interrupts = <0x1>; -// interrupt-parent = <&plic>; -// reg = <0x0 0x10001000 0x0 0x1000>; -// compatible = "virtio,mmio"; -// }; - -}; - chosen { - bootargs = "root=/dev/vda rw earlycon console=hvc0"; - }; - -}; \ No newline at end of file diff --git a/images/riscv64/devicetree/linux4.dts b/images/riscv64/devicetree/linux4.dts deleted file mode 100644 index 92c27f21..00000000 --- a/images/riscv64/devicetree/linux4.dts +++ /dev/null @@ -1,166 +0,0 @@ -/dts-v1/; - -/ { - #address-cells = <0x2>; - #size-cells = <0x2>; - - cpus { - #address-cells = <0x1>; - #size-cells = <0x0>; - timebase-frequency = <10000000>; - - cpu@0 { - device_type = "cpu"; - reg = <0x0>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu_sstc"; - mmu-type = "riscv,sv39"; - - cpu0_intc: interrupt-controller { - #interrupt-cells = <0x1>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - }; - }; - - cpu@1 { - device_type = "cpu"; - reg = <0x1>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu_sstc"; - mmu-type = "riscv,sv39"; - - cpu1_intc: interrupt-controller { - #interrupt-cells = <0x1>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - }; - }; - cpu@2 { - device_type = "cpu"; - reg = <0x2>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu_sstc"; - mmu-type = "riscv,sv39"; - - cpu2_intc: interrupt-controller { - #interrupt-cells = <0x1>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - }; - }; - cpu@3 { - device_type = "cpu"; - reg = <0x3>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu_sstc"; - mmu-type = "riscv,sv39"; - - cpu3_intc: interrupt-controller { - #interrupt-cells = <0x1>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - }; - }; - - - }; - - memory@90000000 { - device_type = "memory"; - reg = <0x0 0x90000000 0x0 0x10000000>; - }; -soc{ - #address-cells = <0x02>; - #size-cells = <0x02>; - compatible = "simple-bus"; - ranges; - plic: interrupt-controller@c000000 { - riscv,ndev = <60>; - reg = <0x0 0xc000000 0x0 0x4000000>; - interrupts-extended = < - &cpu0_intc 11 &cpu0_intc 9 - &cpu1_intc 11 &cpu1_intc 9 - &cpu2_intc 11 &cpu2_intc 9 - >; - interrupt-controller; - compatible = "riscv,plic0"; - #interrupt-cells = <0x1>; - }; - uart@10000000 { - interrupts = <0x0a>; - interrupt-parent = <&plic>; - clock-frequency = "\08@"; - reg = <0x00 0x10000000 0x00 0x100>; - compatible = "ns16550a"; - }; - pci@30000000 { - interrupt-map-mask = <0x1800 0x00 0x00 0x07>; - interrupt-map = <0x00 0x00 0x00 0x01 0x09 0x20 0x00 0x00 0x00 0x02 0x09 0x21 0x00 0x00 0x00 0x03 0x09 0x22 0x00 0x00 0x00 0x04 0x09 0x23 0x800 0x00 0x00 0x01 0x09 0x21 0x800 0x00 0x00 0x02 0x09 0x22 0x800 0x00 0x00 0x03 0x09 0x23 0x800 0x00 0x00 0x04 0x09 0x20 0x1000 0x00 0x00 0x01 0x09 0x22 0x1000 0x00 0x00 0x02 0x09 0x23 0x1000 0x00 0x00 0x03 0x09 0x20 0x1000 0x00 0x00 0x04 0x09 0x21 0x1800 0x00 0x00 0x01 0x09 0x23 0x1800 0x00 0x00 0x02 0x09 0x20 0x1800 0x00 0x00 0x03 0x09 0x21 0x1800 0x00 0x00 0x04 0x09 0x22>; - ranges = <0x1000000 0x00 0x00 0x00 0x3000000 0x00 0x10000 0x2000000 0x00 0x40000000 0x00 0x40000000 0x00 0x40000000 0x3000000 0x04 0x00 0x04 0x00 0x04 0x00>; - reg = <0x00 0x30000000 0x00 0x10000000>; - dma-coherent; - bus-range = <0x00 0xff>; - linux,pci-domain = <0x00>; - device_type = "pci"; - compatible = "pci-host-ecam-generic"; - #size-cells = <0x02>; - #interrupt-cells = <0x01>; - #address-cells = <0x03>; - }; - - - virtio_mmio@10006000 { - interrupts = <0x6>; - interrupt-parent = <&plic>; - reg = <0x0 0x10006000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10005000 { - interrupts = <0x5>; - interrupt-parent = <&plic>; - reg = <0x0 0x10005000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10004000 { - interrupts = <0x4>; - interrupt-parent = <&plic>; - reg = <0x0 0x10004000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10003000 { - interrupts = <0x3>; - interrupt-parent = <&plic>; - reg = <0x0 0x10003000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10002000 { - interrupts = <0x2>; - interrupt-parent = <&plic>; - reg = <0x0 0x10002000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10001000 { - interrupts = <0x1>; - interrupt-parent = <&plic>; - reg = <0x0 0x10001000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - - -}; - chosen { - bootargs = "root=/dev/vda rw earlycon console=ttyS0 ip=192.168.42.15"; - }; - -}; \ No newline at end of file diff --git a/scripts/3a5000-loongarch64.ld b/scripts/3a5000-loongarch64.ld deleted file mode 100644 index 14575576..00000000 --- a/scripts/3a5000-loongarch64.ld +++ /dev/null @@ -1,59 +0,0 @@ -ENTRY(arch_entry) -BASE_ADDRESS = 0x9000000100010000; - - -SECTIONS -{ - . = BASE_ADDRESS; - skernel = .; - - stext = .; - .text : { - *(.text.entry) - *(.text .text.*) - } - - . = ALIGN(4K); - .trap_entry : { - *(.trap_entry) - . = ALIGN(4K); - *(.tlbrefill_entry) - } - - . = ALIGN(4K); - etext = .; - srodata = .; - .rodata : { - *(.rodata .rodata.*) - *(.srodata .srodata.*) - } - - . = ALIGN(4K); - erodata = .; - sdata = .; - .data : { - *(.data .data.*) - *(.sdata .sdata.*) - - } - . = ALIGN(4K); - edata = .; - - .bss : { - *(.bss.stack) - sbss = .; - *(.bss .bss.*) - *(.sbss .sbss.*) - } - - . = ALIGN(4K); - ebss = .; - - ekernel = .; - - /DISCARD/ : { - *(.eh_frame) - } - . = ALIGN(4K); - __core_end = .; -} \ No newline at end of file diff --git a/scripts/3a5000-loongarch64.mk b/scripts/3a5000-loongarch64.mk deleted file mode 100644 index 2121f29b..00000000 --- a/scripts/3a5000-loongarch64.mk +++ /dev/null @@ -1,25 +0,0 @@ -# hvisor for loongarch64 makefile -# wheatfox(enkerewpo@hotmail.com) 2024.6 - -# HVISOR ENTRY -HVISOR_ENTRY_PA := 0x9000000080000000 - -# zone0_kernel := $(image_dir)/kernel/Image -# zone0_dtb := $(image_dir)/devicetree/linux.dtb - -# QEMU for loongarch64 doesn't support LVZ extension yet -# so no qemu related stuff here, we have to debug it on -# REAL hardware with UEFI firmware interface - -# QEMU := qemu-system-loongarch64 -# QEMU_ARGS := -machine virt -# QEMU_ARGS += -bios default -# QEMU_ARGS += -smp 4 -# QEMU_ARGS += -m 2G -# QEMU_ARGS += -nographic -# QEMU_ARGS += -kernel $(hvisor_bin) -# QEMU_ARGS += -device loader,file="$(zone0_kernel)",addr=0x90000000,force-raw=on -# QEMU_ARGS += -device loader,file="$(zone0_dtb)",addr=0x8f000000,force-raw=on - -$(hvisor_bin): elf - $(OBJCOPY) $(hvisor_elf) --strip-all -O binary $@ \ No newline at end of file diff --git a/scripts/qemu-aarch64.ld b/scripts/qemu-aarch64.ld deleted file mode 100644 index 4cd76ea3..00000000 --- a/scripts/qemu-aarch64.ld +++ /dev/null @@ -1,49 +0,0 @@ -ENTRY(arch_entry) -BASE_ADDRESS = 0x40400000; - -SECTIONS -{ - . = BASE_ADDRESS; - skernel = .; - - stext = .; - .text : { - *(.text.entry) - *(.text .text.*) - } - - . = ALIGN(4K); - etext = .; - srodata = .; - .rodata : { - *(.rodata .rodata.*) - *(.srodata .srodata.*) - } - - . = ALIGN(4K); - erodata = .; - sdata = .; - .data : { - *(.data .data.*) - *(.sdata .sdata.*) - } - - . = ALIGN(4K); - edata = .; - .bss : { - *(.bss.stack) - sbss = .; - *(.bss .bss.*) - *(.sbss .sbss.*) - } - - . = ALIGN(4K); - ebss = .; - ekernel = .; - - /DISCARD/ : { - *(.eh_frame) - } - . = ALIGN(4K); - __core_end = .; -} \ No newline at end of file diff --git a/scripts/qemu-aarch64.mk b/scripts/qemu-aarch64.mk deleted file mode 100644 index 22bbe93f..00000000 --- a/scripts/qemu-aarch64.mk +++ /dev/null @@ -1,67 +0,0 @@ -QEMU := sudo qemu-system-aarch64 - -UBOOT := $(image_dir)/bootloader/u-boot-atf.bin - -FSIMG1 := $(image_dir)/virtdisk/rootfs1.ext4 -FSIMG2 := $(image_dir)/virtdisk/rootfs2.ext4 - -zone0_kernel := $(image_dir)/kernel/Image -zone1_kernel := $(image_dir)/kernel/Image -zone0_dtb := $(image_dir)/devicetree/linux1.dtb -zone1_dtb := $(image_dir)/devicetree/linux2.dtb - -QEMU_ARGS := -machine virt,secure=on,gic-version=3,virtualization=on,iommu=smmuv3 -QEMU_ARGS += -global arm-smmuv3.stage=2 - -# QEMU_ARGS += -d int - -QEMU_ARGS += -cpu cortex-a57 -QEMU_ARGS += -smp 4 -QEMU_ARGS += -m 3G -QEMU_ARGS += -nographic -QEMU_ARGS += -bios $(UBOOT) - -QEMU_ARGS += -device loader,file="$(hvisor_bin)",addr=0x40400000,force-raw=on -QEMU_ARGS += -device loader,file="$(zone0_kernel)",addr=0xa0400000,force-raw=on -QEMU_ARGS += -device loader,file="$(zone0_dtb)",addr=0xa0000000,force-raw=on -# QEMU_ARGS += -device loader,file="$(zone1_kernel)",addr=0x70000000,force-raw=on -# QEMU_ARGS += -device loader,file="$(zone1_dtb)",addr=0x91000000,force-raw=on - -QEMU_ARGS += -drive if=none,file=$(FSIMG1),id=Xa003e000,format=raw -QEMU_ARGS += -device virtio-blk-device,drive=Xa003e000,bus=virtio-mmio-bus.31 - -# QEMU_ARGS += -drive if=none,file=$(FSIMG2),id=Xa003c000,format=raw -# QEMU_ARGS += -device virtio-blk-device,drive=Xa003c000 - -# QEMU_ARGS += -netdev tap,id=Xa003a000,ifname=tap0,script=no,downscript=no -# QEMU_ARGS += -device virtio-net-device,netdev=Xa003a000,mac=52:55:00:d1:55:01 -# QEMU_ARGS += -netdev user,id=n0,hostfwd=tcp::5555-:22 -device virtio-net-device,bus=virtio-mmio-bus.29,netdev=n0 - -# QEMU_ARGS += -chardev pty,id=Xa0038000 -# QEMU_ARGS += -device virtio-serial-device,bus=virtio-mmio-bus.28 -device virtconsole,chardev=Xa0038000 - -# QEMU_ARGS += --fsdev local,id=Xa0036000,path=./9p/,security_model=none -# QEMU_ARGS += -device virtio-9p-pci,fsdev=Xa0036000,mount_tag=kmod_mount - -# trace-event gicv3_icc_generate_sgi on -# trace-event gicv3_redist_send_sgi on - -QEMU_ARGS += -netdev type=user,id=net1 -QEMU_ARGS += -device virtio-net-pci,netdev=net1,disable-legacy=on,disable-modern=off,iommu_platform=on - -# QEMU_ARGS += -device pci-testdev - -QEMU_ARGS += -netdev type=user,id=net2 -QEMU_ARGS += -device virtio-net-pci,netdev=net2,disable-legacy=on,disable-modern=off,iommu_platform=on - -QEMU_ARGS += -netdev type=user,id=net3 -QEMU_ARGS += -device virtio-net-pci,netdev=net3,disable-legacy=on,disable-modern=off,iommu_platform=on - -$(hvisor_bin): elf - @if ! command -v mkimage > /dev/null; then \ - sudo apt update && sudo apt install u-boot-tools; \ - fi && \ - $(OBJCOPY) $(hvisor_elf) --strip-all -O binary $(hvisor_bin).tmp && \ - mkimage -n hvisor_img -A arm64 -O linux -C none -T kernel -a 0x40400000 \ - -e 0x40400000 -d $(hvisor_bin).tmp $(hvisor_bin) && \ - rm -rf $(hvisor_bin).tmp \ No newline at end of file diff --git a/scripts/qemu-riscv64.ld b/scripts/qemu-riscv64.ld deleted file mode 100644 index eb62b0fe..00000000 --- a/scripts/qemu-riscv64.ld +++ /dev/null @@ -1,50 +0,0 @@ -ENTRY(arch_entry) -BASE_ADDRESS = 0x80200000; - - -SECTIONS -{ - . = BASE_ADDRESS; - skernel = .; - - stext = .; - .text : { - *(.text.entry) - *(.text .text.*) - } - - . = ALIGN(4K); - etext = .; - srodata = .; - .rodata : { - *(.rodata .rodata.*) - *(.srodata .srodata.*) - } - - . = ALIGN(4K); - erodata = .; - sdata = .; - .data : { - *(.data .data.*) - *(.sdata .sdata.*) - } - - . = ALIGN(4K); - edata = .; - .bss : { - *(.bss.stack) - sbss = .; - *(.bss .bss.*) - *(.sbss .sbss.*) - } - - . = ALIGN(4K); - ebss = .; - ekernel = .; - - /DISCARD/ : { - *(.eh_frame) - } - . = ALIGN(4K); - __core_end = .; -} \ No newline at end of file diff --git a/scripts/qemu-riscv64.mk b/scripts/qemu-riscv64.mk deleted file mode 100644 index 833bb243..00000000 --- a/scripts/qemu-riscv64.mk +++ /dev/null @@ -1,52 +0,0 @@ -QEMU := qemu-system-riscv64 - - -FSIMG1 := $(image_dir)/virtdisk/rootfs1.ext4 -FSIMG2 := $(image_dir)/virtdisk/rootfs-busybox.qcow2 -# HVISOR ENTRY -HVISOR_ENTRY_PA := 0x80200000 -zone0_kernel := $(image_dir)/kernel/Image -zone0_dtb := $(image_dir)/devicetree/linux1.dtb -# zone1_kernel := $(image_dir)/kernel/Image -# zone1_dtb := $(image_dir)/devicetree/linux.dtb - -QEMU_ARGS := -machine virt -QEMU_ARGS += -bios default -QEMU_ARGS += -cpu rv64 -QEMU_ARGS += -smp 4 -QEMU_ARGS += -m 2G -QEMU_ARGS += -nographic - -QEMU_ARGS += -kernel $(hvisor_bin) -QEMU_ARGS += -device loader,file="$(zone0_kernel)",addr=0x90000000,force-raw=on -QEMU_ARGS += -device loader,file="$(zone0_dtb)",addr=0x8f000000,force-raw=on -# QEMU_ARGS += -device loader,file="$(zone1_kernel)",addr=0x84000000,force-raw=on -# QEMU_ARGS += -device loader,file="$(zone1_dtb)",addr=0x83000000,force-raw=on - -QEMU_ARGS += -drive if=none,file=$(FSIMG1),id=X10008000,format=raw -QEMU_ARGS += -device virtio-blk-device,drive=X10008000,bus=virtio-mmio-bus.7 -QEMU_ARGS += -device virtio-serial-device,bus=virtio-mmio-bus.6 -chardev pty,id=X10007000 -device virtconsole,chardev=X10007000 -S -QEMU_ARGS += -drive if=none,file=$(FSIMG2),id=X10006000,format=qcow2 -QEMU_ARGS += -device virtio-blk-device,drive=X10006000,bus=virtio-mmio-bus.5 -# ------------------------------------------------------------------- - -# QEMU_ARGS := -machine virt -# QEMU_ARGS += -nographic -# QEMU_ARGS += -cpu rv64 -# QEMU_ARGS += -m 3G -# QEMU_ARGS += -smp 4 -# QEMU_ARGS += -bios default -# # QEMU_ARGS +=-bios $(BOOTLOADER) -# QEMU_ARGS += -kernel tenants/Image-62 -# QEMU_ARGS += -drive file=imgs/rootfs-busybox.qcow2,format=qcow2,id=hd0 -# #QEMU_ARGS +=-drive file=../guests/rootfs-buildroot.qcow2,format=qcow2,id=hd0 -# QEMU_ARGS += -device virtio-blk-device,drive=hd0 -# QEMU_ARGS += -append "root=/dev/vda rw console=ttyS0" - -# #QEMU_ARGS += -device loader,file=$(KERNEL_BIN),addr=$(KERNEL_ENTRY_PA) -# #QEMU_ARGS += -device loader,file=../guests/os_ch5_802.bin,addr=0x80400000 -# #QEMU_ARGS += -device virtio-serial-port -chardev pty,id=serial3 -device virtconsole,chardev=serial3 -# QEMU_ARGS += -device virtio-serial-device -chardev pty,id=serial3 -device virtconsole,chardev=serial3 - -$(hvisor_bin): elf - $(OBJCOPY) $(hvisor_elf) --strip-all -O binary $@ \ No newline at end of file diff --git a/src/arch/aarch64/zone.rs b/src/arch/aarch64/zone.rs index 8f71c394..839f1dd7 100644 --- a/src/arch/aarch64/zone.rs +++ b/src/arch/aarch64/zone.rs @@ -49,9 +49,6 @@ impl Zone { pub fn mmio_init(&mut self, hv_config: &HvArchZoneConfig) { self.vgicv3_mmio_init(hv_config); } - pub fn isa_init(&mut self, fdt: &fdt::Fdt) { - //nothing to do - } } #[repr(C)] diff --git a/src/arch/loongarch64/zone.rs b/src/arch/loongarch64/zone.rs index ca63128b..c80bb9ae 100644 --- a/src/arch/loongarch64/zone.rs +++ b/src/arch/loongarch64/zone.rs @@ -116,9 +116,7 @@ impl Zone { } pub fn mmio_init(&mut self, hv_config: &HvArchZoneConfig) {} - pub fn isa_init(&mut self, fdt: &fdt::Fdt) { - warn!("loongarch64: mm: isa_init do nothing"); - } + pub fn irq_bitmap_init(&mut self, irqs: &[u32]) {} } diff --git a/src/arch/riscv64/zone.rs b/src/arch/riscv64/zone.rs index 5b767144..10b4e137 100644 --- a/src/arch/riscv64/zone.rs +++ b/src/arch/riscv64/zone.rs @@ -46,23 +46,6 @@ impl Zone { //TODO } pub fn irq_bitmap_init(&mut self, irqs: &[u32]) {} - pub fn isa_init(&mut self, fdt: &fdt::Fdt) { - let cpu_set = self.cpu_set; - cpu_set.iter().for_each(|cpuid| { - let cpu_data = get_cpu_data(cpuid); - let cpu_isa = fdt - .cpus() - .find(|cpu| cpu.ids().all().next().unwrap() == cpuid) - .unwrap() - .properties() - .find(|p| p.name == "riscv,isa") - .unwrap(); - if cpu_isa.as_str().unwrap().contains("sstc") { - println!("cpu{} support sstc", cpuid); - cpu_data.arch_cpu.sstc = true; - } - }) - } } #[repr(C)] diff --git a/src/ivc.rs b/src/ivc.rs index de11a0cc..9a46c207 100644 --- a/src/ivc.rs +++ b/src/ivc.rs @@ -3,7 +3,9 @@ use core::ptr::write_volatile; use alloc::{collections::{btree_map::BTreeMap, btree_set::BTreeSet}, vec::Vec}; use spin::Mutex; -use crate::{config::{HvIvcConfig, CONFIG_MAX_IVC_CONGIGS}, consts::PAGE_SIZE, device::irqchip::gicv3::{gicd::{GICD_ICPENDR, GICD_ISPENDR}, host_gicd_base}, error::HvResult, hypercall::SGI_IPI_ID, memory::{Frame, GuestPhysAddr, MMIOAccess, MemFlags, MemoryRegion}, zone::{find_zone, this_zone_id, Zone}}; +#[cfg(target_arch = "aarch64")] +use crate::device::irqchip::gicv3::{gicd::{GICD_ICPENDR, GICD_ISPENDR}, host_gicd_base}; +use crate::{config::{HvIvcConfig, CONFIG_MAX_IVC_CONGIGS}, consts::PAGE_SIZE, error::HvResult, hypercall::SGI_IPI_ID, memory::{Frame, GuestPhysAddr, MMIOAccess, MemFlags, MemoryRegion}, zone::{find_zone, this_zone_id, Zone}}; // ivc_id -> ivc_record static IVC_RECORDS: Mutex> = Mutex::new(BTreeMap::new()); // zone id -> zone's IvcInfo @@ -183,9 +185,12 @@ pub fn mmio_ivc_handler(mmio: &mut MMIOAccess, base: usize) -> HvResult { return hv_result_err!(EINVAL); } } as usize; + #[cfg(target_arch = "aarch64")] unsafe { write_volatile((host_gicd_base() + GICD_ISPENDR + (irq_num / 32) * 4) as *mut u32, 1 << (irq_num % 32)) } + #[cfg(not(target_arch = "aarch64"))] + todo!(); return Ok(()) }, _ => return hv_result_err!(EFAULT), diff --git a/src/platform/qemu_aarch64.rs b/src/platform/qemu_aarch64.rs index 88bcafd5..7898310f 100644 --- a/src/platform/qemu_aarch64.rs +++ b/src/platform/qemu_aarch64.rs @@ -54,4 +54,6 @@ pub const ROOT_PCI_CONFIG: HvPciConfig = HvPciConfig { pci_mem64_base: 0x8000000000, }; -pub const ROOT_PCI_DEVS: [u64; 2] = [0, 1 << 3]; \ No newline at end of file +pub const ROOT_PCI_DEVS: [u64; 2] = [0, 1 << 3]; + +pub const ROOT_ZONE_IVC_CONFIG: [HvIvcConfig; 0] = []; \ No newline at end of file diff --git a/vendor/fdt/.cargo-checksum.json b/vendor/fdt/.cargo-checksum.json deleted file mode 100644 index f3c54c0d..00000000 --- a/vendor/fdt/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{"Cargo.lock":"22b60c6dde7117e68fa52c490094a93541a3a97ef2817ec719b14d97856b109b","Cargo.toml":"7bec39af6b4f7c8aa20e1c6e255521b27364c915b6801d6c7e7a05554289ab25","LICENSE":"633595578dcd218cd0c5e7b8d17b42480fbc830e60ef4e4506ddc6a99578693b","README.md":"befea38f057024652fb8afb650b06a183a09a9052d9c2dfb579dfd69492be732","dtb/issue-3.dtb":"009af2ed275ba2e33e8474e0697749f570aabc25512b5cf01b0c795980889c5e","dtb/sifive.dtb":"620397140fcb78ab50fa88ea9039b1dbd8359d1b4fae56e16309161d938af88c","dtb/test.dtb":"a345dc38b73355e3f2e6e3fbb0abf70f01f96b83442dcf15afd8cbb7a99aac54","dts/issue-3.dts":"23ae50d11986e1bbe4f1b60ba062db33805c48887502dec148119fcda7753190","dts/sifive.dts":"ed72adb3f198a7d394923a8658ec895e02a897f18a379703b3dcb235c5209876","dts/test.dts":"6d147709a1d9bf8dbb03ba5a49e5bf02d9131bf29a5bc6e4333bbf60d84d6b3e","examples/basic_info.rs":"9494ab25f13a1f1994d47e74fe2137b39edaa8c6db45ce7895061b6cebb79dd5","examples/tree_print.rs":"99d0051215de538b993e56ad3fadfbeb1e0db5b801aa08116d092b9745e62f7a","rustfmt.toml":"f74204a6f92aa7422a16ecb2ffe2d5bae0f123b778d08b5db1a398a3c9ca4306","src/lib.rs":"244937d5c88eb04c883d27e141846890fab72f8a4bf581af00379021c2134b61","src/node.rs":"45fe1ff721cfeadd11da517eb2a4f38013bca831ce56328c8bffa5856f908738","src/parsing.rs":"d7de682e2d29210917beb016bb672a48bb9377f3b0bd6a002cdbe5081b78dde6","src/pretty_print.rs":"46e70d0f5780a5daa0961f1f09ee6f3e1be89ddb1fb48013ce910f0e8b143e3e","src/standard_nodes.rs":"57c7f40bd2710fa42fd2583403776e5c7414ba3295e024bc2e9f5b5b62225b78","src/tests.rs":"c086298302660b93e9591c804d4eaa47cc113114a301e0766abb615d1dab167b"},"package":"784a4df722dc6267a04af36895398f59d21d07dce47232adf31ec0ff2fa45e67"} \ No newline at end of file diff --git a/vendor/fdt/Cargo.lock b/vendor/fdt/Cargo.lock deleted file mode 100644 index 5314bc65..00000000 --- a/vendor/fdt/Cargo.lock +++ /dev/null @@ -1,7 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "fdt" -version = "0.1.5" diff --git a/vendor/fdt/Cargo.toml b/vendor/fdt/Cargo.toml deleted file mode 100644 index b57f46a5..00000000 --- a/vendor/fdt/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -edition = "2018" -name = "fdt" -version = "0.1.5" -authors = ["Wesley Norris "] -description = "A pure-Rust `#![no_std]` crate for parsing Flattened Devicetrees" -readme = "README.md" -keywords = [ - "devicetree", - "fdt", - "dt", -] -categories = [ - "embedded", - "no-std", -] -license = "MPL-2.0" -repository = "https://github.com/repnop/fdt" - -[dependencies] - -[features] -pretty-printing = [] diff --git a/vendor/fdt/LICENSE b/vendor/fdt/LICENSE deleted file mode 100644 index f6dda5a0..00000000 --- a/vendor/fdt/LICENSE +++ /dev/null @@ -1,343 +0,0 @@ -Mozilla Public License Version 2.0 - -1. Definitions - -1.1. “Contributor” - - means each individual or legal entity that creates, contributes to the - creation of, or owns Covered Software. - -1.2. “Contributor Version” - - means the combination of the Contributions of others (if any) used by a - Contributor and that particular Contributor’s Contribution. - -1.3. “Contribution” - - means Covered Software of a particular Contributor. - -1.4. “Covered Software” - - means Source Code Form to which the initial Contributor has attached the - notice in Exhibit A, the Executable Form of such Source Code Form, and - Modifications of such Source Code Form, in each case including portions - thereof. - -1.5. “Incompatible With Secondary Licenses” - - means that the initial Contributor has attached the notice described in - Exhibit B to the Covered Software; or - - that the Covered Software was made available under the terms of version 1.1 - or earlier of the License, but not also under the terms of a Secondary - License. - -1.6. “Executable Form” - - means any form of the work other than Source Code Form. - -1.7. “Larger Work” - - means a work that combines Covered Software with other material, in a - separate file or files, that is not Covered Software. - -1.8. “License” - - means this document. - -1.9. “Licensable” - - means having the right to grant, to the maximum extent possible, whether at - the time of the initial grant or subsequently, any and all of the rights - conveyed by this License. - -1.10. “Modifications” - - means any of the following: - - any file in Source Code Form that results from an addition to, deletion - from, or modification of the contents of Covered Software; or - - any new file in Source Code Form that contains any Covered Software. - -1.11. “Patent Claims” of a Contributor - - means any patent claim(s), including without limitation, method, process, - and apparatus claims, in any patent Licensable by such Contributor that - would be infringed, but for the grant of the License, by the making, using, - selling, offering for sale, having made, import, or transfer of either its - Contributions or its Contributor Version. - -1.12. “Secondary License” - - means either the GNU General Public License, Version 2.0, the GNU Lesser - General Public License, Version 2.1, the GNU Affero General Public License, - Version 3.0, or any later versions of those licenses. - -1.13. “Source Code Form” - - means the form of the work preferred for making modifications. - -1.14. “You” (or “Your”) - - means an individual or a legal entity exercising rights under this License. - For legal entities, “You” includes any entity that controls, is controlled - by, or is under common control with You. For purposes of this definition, - “control” means (a) the power, direct or indirect, to cause the direction or - management of such entity, whether by contract or otherwise, or (b) - ownership of more than fifty percent (50%) of the outstanding shares or - beneficial ownership of such entity. - -2. License Grants and Conditions - - 2.1. Grants - - Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive - license: - - under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, modify, - display, perform, distribute, and otherwise exploit its Contributions, - either on an unmodified basis, with Modifications, or as part of a Larger - Work; and - - under Patent Claims of such Contributor to make, use, sell, offer for sale, - have made, import, and otherwise transfer either its Contributions or its - Contributor Version. - - 2.2. Effective Date - - The licenses granted in Section 2.1 with respect to any Contribution become - effective for each Contribution on the date the Contributor first distributes - such Contribution. - - 2.3. Limitations on Grant Scope - - The licenses granted in this Section 2 are the only rights granted under this - License. No additional rights or licenses will be implied from the distribution - or licensing of Covered Software under this License. Notwithstanding Section - 2.1(b) above, no patent license is granted by a Contributor: - - for any code that a Contributor has removed from Covered Software; or - - for infringements caused by: (i) Your and any other third party’s - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - - under Patent Claims infringed by Covered Software in the absence of its - Contributions. - - This License does not grant any rights in the trademarks, service marks, or - logos of any Contributor (except as may be necessary to comply with the notice - requirements in Section 3.4). - - 2.4. Subsequent Licenses - - No Contributor makes additional grants as a result of Your choice to distribute - the Covered Software under a subsequent version of this License (see Section - 10.2) or under the terms of a Secondary License (if permitted under the terms of - Section 3.3). - - 2.5. Representation - - Each Contributor represents that the Contributor believes its Contributions are - its original creation(s) or it has sufficient rights to grant the rights to its - Contributions conveyed by this License. - - 2.6. Fair Use - - This License is not intended to limit any rights You have under applicable - copyright doctrines of fair use, fair dealing, or other equivalents. - - 2.7. Conditions - - Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in - Section 2.1. - -3. Responsibilities - - 3.1. Distribution of Source Form - - All distribution of Covered Software in Source Code Form, including any - Modifications that You create or to which You contribute, must be under the - terms of this License. You must inform recipients that the Source Code Form of - the Covered Software is governed by the terms of this License, and how they can - obtain a copy of this License. You may not attempt to alter or restrict the - recipients’ rights in the Source Code Form. - - 3.2. Distribution of Executable Form - - If You distribute Covered Software in Executable Form then: - - such Covered Software must also be made available in Source Code Form, as - described in Section 3.1, and You must inform recipients of the Executable - Form how they can obtain a copy of such Source Code Form by reasonable means - in a timely manner, at a charge no more than the cost of distribution to the - recipient; and - - You may distribute such Executable Form under the terms of this License, or - sublicense it under different terms, provided that the license for the - Executable Form does not attempt to limit or alter the recipients’ rights in - the Source Code Form under this License. - - 3.3. Distribution of a Larger Work - - You may create and distribute a Larger Work under terms of Your choice, provided - that You also comply with the requirements of this License for the Covered - Software. If the Larger Work is a combination of Covered Software with a work - governed by one or more Secondary Licenses, and the Covered Software is not - Incompatible With Secondary Licenses, this License permits You to additionally - distribute such Covered Software under the terms of such Secondary License(s), - so that the recipient of the Larger Work may, at their option, further - distribute the Covered Software under the terms of either this License or such - Secondary License(s). - - 3.4. Notices - - You may not remove or alter the substance of any license notices (including - copyright notices, patent notices, disclaimers of warranty, or limitations of - liability) contained within the Source Code Form of the Covered Software, except - that You may alter any license notices to the extent required to remedy known - factual inaccuracies. - - 3.5. Application of Additional Terms - - You may choose to offer, and to charge a fee for, warranty, support, indemnity - or liability obligations to one or more recipients of Covered Software. However, - You may do so only on Your own behalf, and not on behalf of any Contributor. You - must make it absolutely clear that any such warranty, support, indemnity, or - liability obligation is offered by You alone, and You hereby agree to indemnify - every Contributor for any liability incurred by such Contributor as a result of - warranty, support, indemnity or liability terms You offer. You may include - additional disclaimers of warranty and limitations of liability specific to any - jurisdiction. - -4. Inability to Comply Due to Statute or Regulation - - If it is impossible for You to comply with any of the terms of this License with - respect to some or all of the Covered Software due to statute, judicial order, - or regulation then You must: (a) comply with the terms of this License to the - maximum extent possible; and (b) describe the limitations and the code they - affect. Such description must be placed in a text file included with all - distributions of the Covered Software under this License. Except to the extent - prohibited by statute or regulation, such description must be sufficiently - detailed for a recipient of ordinary skill to be able to understand it. - -5. Termination - - 5.1. The rights granted under this License will terminate automatically if You - fail to comply with any of its terms. However, if You become compliant, then the - rights granted under this License from a particular Contributor are reinstated - (a) provisionally, unless and until such Contributor explicitly and finally - terminates Your grants, and (b) on an ongoing basis, if such Contributor fails - to notify You of the non-compliance by some reasonable means prior to 60 days - after You have come back into compliance. Moreover, Your grants from a - particular Contributor are reinstated on an ongoing basis if such Contributor - notifies You of the non-compliance by some reasonable means, this is the first - time You have received notice of non-compliance with this License from such - Contributor, and You become compliant prior to 30 days after Your receipt of the - notice. - - 5.2. If You initiate litigation against any entity by asserting a patent - infringement claim (excluding declaratory judgment actions, counter-claims, and - cross-claims) alleging that a Contributor Version directly or indirectly - infringes any patent, then the rights granted to You by any and all Contributors - for the Covered Software under Section 2.1 of this License shall terminate. - - 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user - license agreements (excluding distributors and resellers) which have been - validly granted by You or Your distributors under this License prior to - termination shall survive termination. - -6. Disclaimer of Warranty - - Covered Software is provided under this License on an “as is” basis, without - warranty of any kind, either expressed, implied, or statutory, including, - without limitation, warranties that the Covered Software is free of defects, - merchantable, fit for a particular purpose or non-infringing. The entire risk as - to the quality and performance of the Covered Software is with You. Should any - Covered Software prove defective in any respect, You (not any Contributor) - assume the cost of any necessary servicing, repair, or correction. This - disclaimer of warranty constitutes an essential part of this License. No use of - any Covered Software is authorized under this License except under this - disclaimer. - -7. Limitation of Liability - - Under no circumstances and under no legal theory, whether tort (including - negligence), contract, or otherwise, shall any Contributor, or anyone who - distributes Covered Software as permitted above, be liable to You for any - direct, indirect, special, incidental, or consequential damages of any character - including, without limitation, damages for lost profits, loss of goodwill, work - stoppage, computer failure or malfunction, or any and all other commercial - damages or losses, even if such party shall have been informed of the - possibility of such damages. This limitation of liability shall not apply to - liability for death or personal injury resulting from such party’s negligence to - the extent applicable law prohibits such limitation. Some jurisdictions do not - allow the exclusion or limitation of incidental or consequential damages, so - this exclusion and limitation may not apply to You. - -8. Litigation - - Any litigation relating to this License may be brought only in the courts of a - jurisdiction where the defendant maintains its principal place of business and - such litigation shall be governed by laws of that jurisdiction, without - reference to its conflict-of-law provisions. Nothing in this Section shall - prevent a party’s ability to bring cross-claims or counter-claims. - -9. Miscellaneous - - This License represents the complete agreement concerning the subject matter - hereof. If any provision of this License is held to be unenforceable, such - provision shall be reformed only to the extent necessary to make it enforceable. - Any law or regulation which provides that the language of a contract shall be - construed against the drafter shall not be used to construe this License against - a Contributor. - -10. Versions of the License - - 10.1. New Versions - - Mozilla Foundation is the license steward. Except as provided in Section 10.3, - no one other than the license steward has the right to modify or publish new - versions of this License. Each version will be given a distinguishing version - number. - - 10.2. Effect of New Versions - - You may distribute the Covered Software under the terms of the version of the - License under which You originally received the Covered Software, or under the - terms of any subsequent version published by the license steward. - - 10.3. Modified Versions - - If you create software not governed by this License, and you want to create a - new license for such software, you may create and use a modified version of this - License if you rename the license and remove any references to the name of the - license steward (except to note that such modified license differs from this - License). - - 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses - - If You choose to distribute Source Code Form that is Incompatible With Secondary - Licenses under the terms of this version of the License, the notice described in - Exhibit B of this License must be attached. - - Exhibit A - Source Code Form License Notice - - This Source Code Form is subject to the terms of the Mozilla Public License, - v. 2.0. If a copy of the MPL was not distributed with this file, You can - obtain one at https://mozilla.org/MPL/2.0/. - - If it is not possible or desirable to put the notice in a particular file, then - You may include the notice in a location (such as a LICENSE file in a relevant - directory) where a recipient would be likely to look for such a notice. - - You may add additional accurate notices of copyright ownership. - - Exhibit B - “Incompatible With Secondary Licenses” Notice - - This Source Code Form is “Incompatible With Secondary Licenses”, as defined - by the Mozilla Public License, v. 2.0. - diff --git a/vendor/fdt/README.md b/vendor/fdt/README.md deleted file mode 100644 index 23991103..00000000 --- a/vendor/fdt/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# `fdt` - -A pure-Rust `#![no_std]` crate for parsing Flattened Devicetrees, with the goal of having a -very ergonomic and idiomatic API. - -[![crates.io](https://img.shields.io/crates/v/fdt.svg)](https://crates.io/crates/fdt) [![Documentation](https://docs.rs/fdt/badge.svg)](https://docs.rs/fdt) ![Build](https://github.com/repnop/fdt/actions/workflows/test.yml/badge.svg?branch=master&event=push) - -## License - -This crate is licensed under the Mozilla Public License 2.0 (see the LICENSE file). - -## Example - -```rust -static MY_FDT: &[u8] = include_bytes!("../dtb/test.dtb"); - -fn main() { - let fdt = fdt::Fdt::new(MY_FDT).unwrap(); - - println!("This is a devicetree representation of a {}", fdt.root().model()); - println!("...which is compatible with at least: {}", fdt.root().compatible().first()); - println!("...and has {} CPU(s)", fdt.cpus().count()); - println!( - "...and has at least one memory location at: {:#X}\n", - fdt.memory().regions().next().unwrap().starting_address as usize - ); - - let chosen = fdt.chosen(); - if let Some(bootargs) = chosen.bootargs() { - println!("The bootargs are: {:?}", bootargs); - } - - if let Some(stdout) = chosen.stdout() { - println!("It would write stdout to: {}", stdout.name); - } - - let soc = fdt.find_node("/soc"); - println!("Does it have a `/soc` node? {}", if soc.is_some() { "yes" } else { "no" }); - if let Some(soc) = soc { - println!("...and it has the following children:"); - for child in soc.children() { - println!(" {}", child.name); - } - } -} -``` \ No newline at end of file diff --git a/vendor/fdt/dtb/issue-3.dtb b/vendor/fdt/dtb/issue-3.dtb deleted file mode 100644 index 02c7fcaa..00000000 Binary files a/vendor/fdt/dtb/issue-3.dtb and /dev/null differ diff --git a/vendor/fdt/dtb/sifive.dtb b/vendor/fdt/dtb/sifive.dtb deleted file mode 100644 index f3fa7166..00000000 Binary files a/vendor/fdt/dtb/sifive.dtb and /dev/null differ diff --git a/vendor/fdt/dtb/test.dtb b/vendor/fdt/dtb/test.dtb deleted file mode 100644 index 27f6a9cb..00000000 Binary files a/vendor/fdt/dtb/test.dtb and /dev/null differ diff --git a/vendor/fdt/dts/issue-3.dts b/vendor/fdt/dts/issue-3.dts deleted file mode 100644 index cd8343cc..00000000 --- a/vendor/fdt/dts/issue-3.dts +++ /dev/null @@ -1,250 +0,0 @@ -/dts-v1/; - -/ { - #address-cells = <0x02>; - #size-cells = <0x02>; - compatible = "riscv-virtio"; - model = "riscv-virtio,qemu"; - - chosen { - bootargs = [00]; - stdout-path = "/soc/uart@10000000"; - }; - - memory@80000000 { - device_type = "memory"; - reg = <0x00 0x80000000 0x00 0x8000000>; - }; - - cpus { - #address-cells = <0x01>; - #size-cells = <0x00>; - timebase-frequency = <0x989680>; - - cpu@0 { - phandle = <0x07>; - device_type = "cpu"; - reg = <0x00>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu"; - mmu-type = "riscv,sv48"; - - interrupt-controller { - #interrupt-cells = <0x01>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - phandle = <0x08>; - }; - }; - - cpu@1 { - phandle = <0x05>; - device_type = "cpu"; - reg = <0x01>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu"; - mmu-type = "riscv,sv48"; - - interrupt-controller { - #interrupt-cells = <0x01>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - phandle = <0x06>; - }; - }; - - cpu@2 { - phandle = <0x03>; - device_type = "cpu"; - reg = <0x02>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu"; - mmu-type = "riscv,sv48"; - - interrupt-controller { - #interrupt-cells = <0x01>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - phandle = <0x04>; - }; - }; - - cpu@3 { - phandle = <0x01>; - device_type = "cpu"; - reg = <0x03>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu"; - mmu-type = "riscv,sv48"; - - interrupt-controller { - #interrupt-cells = <0x01>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - phandle = <0x02>; - }; - }; - - cpu-map { - - cluster0 { - - core0 { - cpu = <0x07>; - }; - - core1 { - cpu = <0x05>; - }; - - core2 { - cpu = <0x03>; - }; - - core3 { - cpu = <0x01>; - }; - }; - }; - }; - - soc { - #address-cells = <0x02>; - #size-cells = <0x02>; - compatible = "simple-bus"; - ranges; - - flash@20000000 { - bank-width = <0x04>; - reg = <0x00 0x20000000 0x00 0x2000000 0x00 0x22000000 0x00 0x2000000>; - compatible = "cfi-flash"; - }; - - rtc@101000 { - interrupts = <0x0b>; - interrupt-parent = <0x09>; - reg = <0x00 0x101000 0x00 0x1000>; - compatible = "google,goldfish-rtc"; - }; - - uart@10000000 { - interrupts = <0x0a>; - interrupt-parent = <0x09>; - clock-frequency = <0x384000>; - reg = <0x00 0x10000000 0x00 0x100>; - compatible = "ns16550a"; - }; - - poweroff { - value = <0x5555>; - offset = <0x00>; - regmap = <0x0a>; - compatible = "syscon-poweroff"; - }; - - reboot { - value = <0x7777>; - offset = <0x00>; - regmap = <0x0a>; - compatible = "syscon-reboot"; - }; - - test@100000 { - phandle = <0x0a>; - reg = <0x00 0x100000 0x00 0x1000>; - compatible = "sifive,test1\0sifive,test0\0syscon"; - }; - - pci@30000000 { - interrupt-map-mask = <0x1800 0x00 0x00 0x07>; - interrupt-map = <0x00 0x00 0x00 0x01 0x09 0x20 0x00 0x00 0x00 0x02 0x09 0x21 0x00 0x00 0x00 0x03 0x09 0x22 0x00 0x00 0x00 0x04 0x09 0x23 0x800 0x00 0x00 0x01 0x09 0x21 0x800 0x00 0x00 0x02 0x09 0x22 0x800 0x00 0x00 0x03 0x09 0x23 0x800 0x00 0x00 0x04 0x09 0x20 0x1000 0x00 0x00 0x01 0x09 0x22 0x1000 0x00 0x00 0x02 0x09 0x23 0x1000 0x00 0x00 0x03 0x09 0x20 0x1000 0x00 0x00 0x04 0x09 0x21 0x1800 0x00 0x00 0x01 0x09 0x23 0x1800 0x00 0x00 0x02 0x09 0x20 0x1800 0x00 0x00 0x03 0x09 0x21 0x1800 0x00 0x00 0x04 0x09 0x22>; - ranges = <0x1000000 0x00 0x00 0x00 0x3000000 0x00 0x10000 0x2000000 0x00 0x40000000 0x00 0x40000000 0x00 0x40000000>; - reg = <0x00 0x30000000 0x00 0x10000000>; - dma-coherent; - bus-range = <0x00 0xff>; - linux,pci-domain = <0x00>; - device_type = "pci"; - compatible = "pci-host-ecam-generic"; - #size-cells = <0x02>; - #interrupt-cells = <0x01>; - #address-cells = <0x03>; - }; - - virtio_mmio@10008000 { - interrupts = <0x08>; - interrupt-parent = <0x09>; - reg = <0x00 0x10008000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10007000 { - interrupts = <0x07>; - interrupt-parent = <0x09>; - reg = <0x00 0x10007000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10006000 { - interrupts = <0x06>; - interrupt-parent = <0x09>; - reg = <0x00 0x10006000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10005000 { - interrupts = <0x05>; - interrupt-parent = <0x09>; - reg = <0x00 0x10005000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10004000 { - interrupts = <0x04>; - interrupt-parent = <0x09>; - reg = <0x00 0x10004000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10003000 { - interrupts = <0x03>; - interrupt-parent = <0x09>; - reg = <0x00 0x10003000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10002000 { - interrupts = <0x02>; - interrupt-parent = <0x09>; - reg = <0x00 0x10002000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10001000 { - interrupts = <0x01>; - interrupt-parent = <0x09>; - reg = <0x00 0x10001000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - plic@c000000 { - phandle = <0x09>; - riscv,ndev = <0x35>; - reg = <0x00 0xc000000 0x00 0x210000>; - interrupts-extended = <0x08 0x0b 0x08 0x09 0x06 0x0b 0x06 0x09 0x04 0x0b 0x04 0x09 0x02 0x0b 0x02 0x09>; - interrupt-controller; - compatible = "riscv,plic0"; - #interrupt-cells = <0x01>; - #address-cells = <0x00>; - }; - - clint@2000000 { - interrupts-extended = <0x08 0x03 0x08 0x07 0x06 0x03 0x06 0x07 0x04 0x03 0x04 0x07 0x02 0x03 0x02 0x07>; - reg = <0x00 0x2000000 0x00 0x10000>; - compatible = "riscv,clint0"; - }; - }; -}; \ No newline at end of file diff --git a/vendor/fdt/dts/sifive.dts b/vendor/fdt/dts/sifive.dts deleted file mode 100644 index e24fcfc8..00000000 --- a/vendor/fdt/dts/sifive.dts +++ /dev/null @@ -1,207 +0,0 @@ -/dts-v1/; - -/ { - #address-cells = <0x02>; - #size-cells = <0x02>; - compatible = "sifive,hifive-unleashed-a00"; - model = "SiFive HiFive Unleashed A00"; - - chosen { - bootargs = [00]; - stdout-path = "/soc/serial@10010000"; - }; - - aliases { - serial0 = "/soc/serial@10010000"; - ethernet0 = "/soc/ethernet@10090000"; - }; - - gpio-restart { - compatible = "gpio-restart"; - gpios = <0x0a 0x0a 0x01>; - }; - - cpus { - #address-cells = <0x01>; - #size-cells = <0x00>; - timebase-frequency = <0x989680>; - - cpu@0 { - device_type = "cpu"; - reg = <0x00>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imacu"; - - interrupt-controller { - #interrupt-cells = <0x01>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - phandle = <0x07>; - }; - }; - - cpu@1 { - device_type = "cpu"; - reg = <0x01>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu"; - mmu-type = "riscv,sv48"; - - interrupt-controller { - #interrupt-cells = <0x01>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - phandle = <0x06>; - }; - }; - - cpu@2 { - device_type = "cpu"; - reg = <0x02>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu"; - mmu-type = "riscv,sv48"; - - interrupt-controller { - #interrupt-cells = <0x01>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - phandle = <0x05>; - }; - }; - - cpu@3 { - device_type = "cpu"; - reg = <0x03>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu"; - mmu-type = "riscv,sv48"; - - interrupt-controller { - #interrupt-cells = <0x01>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - phandle = <0x04>; - }; - }; - - cpu@4 { - device_type = "cpu"; - reg = <0x04>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu"; - mmu-type = "riscv,sv48"; - - interrupt-controller { - #interrupt-cells = <0x01>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - phandle = <0x03>; - }; - }; - }; - - memory@80000000 { - device_type = "memory"; - reg = <0x00 0x80000000 0x00 0x20000000>; - }; - - rtcclk { - #clock-cells = <0x00>; - compatible = "fixed-clock"; - clock-frequency = <0xf4240>; - clock-output-names = "rtcclk"; - phandle = <0x02>; - }; - - hfclk { - #clock-cells = <0x00>; - compatible = "fixed-clock"; - clock-frequency = <0x1fca055>; - clock-output-names = "hfclk"; - phandle = <0x01>; - }; - - soc { - #address-cells = <0x02>; - #size-cells = <0x02>; - compatible = "simple-bus"; - ranges; - - serial@10010000 { - interrupts = <0x04>; - interrupt-parent = <0x09>; - clocks = <0x08 0x03>; - reg = <0x00 0x10010000 0x00 0x1000>; - compatible = "sifive,uart0"; - }; - - ethernet@10090000 { - #size-cells = <0x00>; - #address-cells = <0x01>; - local-mac-address = [52 54 00 12 34 56]; - clock-names = "pclk\0hclk"; - clocks = <0x08 0x02 0x08 0x02>; - interrupts = <0x35>; - interrupt-parent = <0x09>; - phy-handle = <0x0b>; - phy-mode = "gmii"; - reg-names = "control"; - reg = <0x00 0x10090000 0x00 0x2000 0x00 0x100a0000 0x00 0x1000>; - compatible = "sifive,fu540-c000-gem"; - - ethernet-phy@0 { - reg = <0x00>; - phandle = <0x0b>; - }; - }; - - gpio@10060000 { - compatible = "sifive,gpio0"; - interrupt-parent = <0x09>; - interrupts = <0x07 0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15 0x16>; - reg = <0x00 0x10060000 0x00 0x1000>; - gpio-controller; - #gpio-cells = <0x02>; - interrupt-controller; - #interrupt-cells = <0x02>; - clocks = <0x08 0x03>; - phandle = <0x0a>; - }; - - interrupt-controller@c000000 { - phandle = <0x09>; - riscv,ndev = <0x35>; - reg = <0x00 0xc000000 0x00 0x4000000>; - interrupts-extended = <0x07 0x0b 0x06 0x0b 0x06 0x09 0x05 0x0b 0x05 0x09 0x04 0x0b 0x04 0x09 0x03 0x0b 0x03 0x09>; - interrupt-controller; - compatible = "riscv,plic0"; - #interrupt-cells = <0x01>; - }; - - clock-controller@10000000 { - compatible = "sifive,fu540-c000-prci"; - reg = <0x00 0x10000000 0x00 0x1000>; - clocks = <0x01 0x02>; - #clock-cells = <0x01>; - phandle = <0x08>; - }; - - otp@10070000 { - compatible = "sifive,fu540-c000-otp"; - reg = <0x00 0x10070000 0x00 0x1000>; - fuse-count = <0x1000>; - }; - - clint@2000000 { - interrupts-extended = <0x07 0x03 0x07 0x07 0x06 0x03 0x06 0x07 0x05 0x03 0x05 0x07 0x04 0x03 0x04 0x07 0x03 0x03 0x03 0x07>; - reg = <0x00 0x2000000 0x00 0x10000>; - compatible = "riscv,clint0"; - }; - }; -}; diff --git a/vendor/fdt/dts/test.dts b/vendor/fdt/dts/test.dts deleted file mode 100644 index 46d25ba5..00000000 --- a/vendor/fdt/dts/test.dts +++ /dev/null @@ -1,191 +0,0 @@ -/dts-v1/; - -/ { - #address-cells = <0x02>; - #size-cells = <0x02>; - compatible = "riscv-virtio"; - model = "riscv-virtio,qemu"; - - chosen { - bootargs = [00]; - stdout-path = "/soc/uart@10000000"; - }; - - memory@80000000 { - device_type = "memory"; - reg = <0x00 0x80000000 0x00 0x20000000>; - }; - - cpus { - #address-cells = <0x01>; - #size-cells = <0x00>; - timebase-frequency = <0x989680>; - - cpu@0 { - phandle = <0x01>; - device_type = "cpu"; - reg = <0x00>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu"; - mmu-type = "riscv,sv48"; - - interrupt-controller { - #interrupt-cells = <0x01>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - phandle = <0x02>; - }; - }; - - cpu-map { - - cluster0 { - - core0 { - cpu = <0x01>; - }; - }; - }; - }; - - emptyproptest { - - }; - - soc { - #address-cells = <0x02>; - #size-cells = <0x02>; - compatible = "simple-bus"; - ranges; - - flash@20000000 { - bank-width = <0x04>; - reg = <0x00 0x20000000 0x00 0x2000000 0x00 0x22000000 0x00 0x2000000>; - compatible = "cfi-flash"; - }; - - rtc@101000 { - interrupts = <0x0b>; - interrupt-parent = <0x03>; - reg = <0x00 0x101000 0x00 0x1000>; - compatible = "google,goldfish-rtc"; - }; - - uart@10000000 { - interrupts = <0x0a>; - interrupt-parent = <0x03>; - clock-frequency = <0x384000>; - reg = <0x00 0x10000000 0x00 0x100>; - compatible = "ns16550a"; - }; - - poweroff { - value = <0x5555>; - offset = <0x00>; - regmap = <0x04>; - compatible = "syscon-poweroff"; - }; - - reboot { - value = <0x7777>; - offset = <0x00>; - regmap = <0x04>; - compatible = "syscon-reboot"; - }; - - test@100000 { - phandle = <0x04>; - reg = <0x00 0x100000 0x00 0x1000>; - compatible = "sifive,test1\0sifive,test0\0syscon"; - }; - - pci@30000000 { - interrupt-map-mask = <0x1800 0x00 0x00 0x07>; - interrupt-map = <0x00 0x00 0x00 0x01 0x03 0x20 0x00 0x00 0x00 0x02 0x03 0x21 0x00 0x00 0x00 0x03 0x03 0x22 0x00 0x00 0x00 0x04 0x03 0x23 0x800 0x00 0x00 0x01 0x03 0x21 0x800 0x00 0x00 0x02 0x03 0x22 0x800 0x00 0x00 0x03 0x03 0x23 0x800 0x00 0x00 0x04 0x03 0x20 0x1000 0x00 0x00 0x01 0x03 0x22 0x1000 0x00 0x00 0x02 0x03 0x23 0x1000 0x00 0x00 0x03 0x03 0x20 0x1000 0x00 0x00 0x04 0x03 0x21 0x1800 0x00 0x00 0x01 0x03 0x23 0x1800 0x00 0x00 0x02 0x03 0x20 0x1800 0x00 0x00 0x03 0x03 0x21 0x1800 0x00 0x00 0x04 0x03 0x22>; - ranges = <0x1000000 0x00 0x00 0x00 0x3000000 0x00 0x10000 0x2000000 0x00 0x40000000 0x00 0x40000000 0x00 0x40000000>; - reg = <0x00 0x30000000 0x00 0x10000000>; - dma-coherent; - bus-range = <0x00 0xff>; - linux,pci-domain = <0x00>; - device_type = "pci"; - compatible = "pci-host-ecam-generic"; - #size-cells = <0x02>; - #interrupt-cells = <0x01>; - #address-cells = <0x03>; - }; - - virtio_mmio@10008000 { - interrupts = <0x08>; - interrupt-parent = <0x03>; - reg = <0x00 0x10008000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10007000 { - interrupts = <0x07>; - interrupt-parent = <0x03>; - reg = <0x00 0x10007000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10006000 { - interrupts = <0x06>; - interrupt-parent = <0x03>; - reg = <0x00 0x10006000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10005000 { - interrupts = <0x05>; - interrupt-parent = <0x03>; - reg = <0x00 0x10005000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10004000 { - interrupts = <0x04>; - interrupt-parent = <0x03>; - reg = <0x00 0x10004000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10003000 { - interrupts = <0x03>; - interrupt-parent = <0x03>; - reg = <0x00 0x10003000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10002000 { - interrupts = <0x02>; - interrupt-parent = <0x03>; - reg = <0x00 0x10002000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10001000 { - interrupts = <0x01>; - interrupt-parent = <0x03>; - reg = <0x00 0x10001000 0x00 0x1000>; - compatible = "virtio,mmio"; - }; - - plic@c000000 { - phandle = <0x03>; - riscv,ndev = <0x35>; - reg = <0x00 0xc000000 0x00 0x210000>; - interrupts-extended = <0x02 0x0b 0x02 0x09>; - interrupt-controller; - compatible = "riscv,plic0"; - #interrupt-cells = <0x01>; - #address-cells = <0x00>; - }; - - clint@2000000 { - interrupts-extended = <0x02 0x03 0x02 0x07>; - reg = <0x00 0x2000000 0x00 0x10000>; - compatible = "riscv,clint0"; - }; - }; -}; diff --git a/vendor/fdt/examples/basic_info.rs b/vendor/fdt/examples/basic_info.rs deleted file mode 100644 index bb91570a..00000000 --- a/vendor/fdt/examples/basic_info.rs +++ /dev/null @@ -1,31 +0,0 @@ -static MY_FDT: &[u8] = include_bytes!("../dtb/test.dtb"); - -fn main() { - let fdt = fdt::Fdt::new(MY_FDT).unwrap(); - - println!("This is a devicetree representation of a {}", fdt.root().model()); - println!("...which is compatible with at least: {}", fdt.root().compatible().first()); - println!("...and has {} CPU(s)", fdt.cpus().count()); - println!( - "...and has at least one memory location at: {:#X}\n", - fdt.memory().regions().next().unwrap().starting_address as usize - ); - - let chosen = fdt.chosen(); - if let Some(bootargs) = chosen.bootargs() { - println!("The bootargs are: {:?}", bootargs); - } - - if let Some(stdout) = chosen.stdout() { - println!("It would write stdout to: {}", stdout.name); - } - - let soc = fdt.find_node("/soc"); - println!("Does it have a `/soc` node? {}", if soc.is_some() { "yes" } else { "no" }); - if let Some(soc) = soc { - println!("...and it has the following children:"); - for child in soc.children() { - println!(" {}", child.name); - } - } -} diff --git a/vendor/fdt/examples/tree_print.rs b/vendor/fdt/examples/tree_print.rs deleted file mode 100644 index 194562c5..00000000 --- a/vendor/fdt/examples/tree_print.rs +++ /dev/null @@ -1,18 +0,0 @@ -use fdt::node::FdtNode; - -static MY_FDT: &[u8] = include_bytes!("../dtb/test.dtb"); - -fn main() { - let fdt = fdt::Fdt::new(MY_FDT).unwrap(); - - print_node(fdt.find_node("/").unwrap(), 0); -} - -fn print_node(node: FdtNode<'_, '_>, n_spaces: usize) { - (0..n_spaces).for_each(|_| print!(" ")); - println!("{}/", node.name); - - for child in node.children() { - print_node(child, n_spaces + 4); - } -} diff --git a/vendor/fdt/rustfmt.toml b/vendor/fdt/rustfmt.toml deleted file mode 100644 index 2a35f023..00000000 --- a/vendor/fdt/rustfmt.toml +++ /dev/null @@ -1 +0,0 @@ -use_small_heuristics = "Max" diff --git a/vendor/fdt/src/lib.rs b/vendor/fdt/src/lib.rs deleted file mode 100644 index 0bcfe88c..00000000 --- a/vendor/fdt/src/lib.rs +++ /dev/null @@ -1,415 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at https://mozilla.org/MPL/2.0/. - -//! # `fdt` -//! -//! A pure-Rust `#![no_std]` crate for parsing Flattened Devicetrees, with the goal of having a -//! very ergonomic and idiomatic API. -//! -//! [![crates.io](https://img.shields.io/crates/v/fdt.svg)](https://crates.io/crates/fdt) [![Documentation](https://docs.rs/fdt/badge.svg)](https://docs.rs/fdt) ![Build](https://github.com/repnop/fdt/actions/workflows/test.yml/badge.svg?branch=master&event=push) -//! -//! ## License -//! -//! This crate is licensed under the Mozilla Public License 2.0 (see the LICENSE file). -//! -//! ## Example -//! -//! ```rust,no_run -//! static MY_FDT: &[u8] = include_bytes!("../dtb/test.dtb"); -//! -//! fn main() { -//! let fdt = fdt::Fdt::new(MY_FDT).unwrap(); -//! -//! println!("This is a devicetree representation of a {}", fdt.root().model()); -//! println!("...which is compatible with at least: {}", fdt.root().compatible().first()); -//! println!("...and has {} CPU(s)", fdt.cpus().count()); -//! println!( -//! "...and has at least one memory location at: {:#X}\n", -//! fdt.memory().regions().next().unwrap().starting_address as usize -//! ); -//! -//! let chosen = fdt.chosen(); -//! if let Some(bootargs) = chosen.bootargs() { -//! println!("The bootargs are: {:?}", bootargs); -//! } -//! -//! if let Some(stdout) = chosen.stdout() { -//! println!("It would write stdout to: {}", stdout.name); -//! } -//! -//! let soc = fdt.find_node("/soc"); -//! println!("Does it have a `/soc` node? {}", if soc.is_some() { "yes" } else { "no" }); -//! if let Some(soc) = soc { -//! println!("...and it has the following children:"); -//! for child in soc.children() { -//! println!(" {}", child.name); -//! } -//! } -//! } -//! ``` - -#![no_std] - -#[cfg(test)] -mod tests; - -pub mod node; -mod parsing; -pub mod standard_nodes; - -#[cfg(feature = "pretty-printing")] -mod pretty_print; - -use node::MemoryReservation; -use parsing::{BigEndianU32, CStr, FdtData}; -use standard_nodes::{Aliases, Chosen, Cpu, Memory, MemoryRegion, Root}; - -/// Possible errors when attempting to create an `Fdt` -#[derive(Debug, Clone, Copy, PartialEq)] -pub enum FdtError { - /// The FDT had an invalid magic value - BadMagic, - /// The given pointer was null - BadPtr, - /// The slice passed in was too small to fit the given total size of the FDT - /// structure - BufferTooSmall, -} - -impl core::fmt::Display for FdtError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - FdtError::BadMagic => write!(f, "bad FDT magic value"), - FdtError::BadPtr => write!(f, "an invalid pointer was passed"), - FdtError::BufferTooSmall => { - write!(f, "the given buffer was too small to contain a FDT header") - } - } - } -} - -/// A flattened devicetree located somewhere in memory -/// -/// Note on `Debug` impl: by default the `Debug` impl of this struct will not -/// print any useful information, if you would like a best-effort tree print -/// which looks similar to `dtc`'s output, enable the `pretty-printing` feature -#[derive(Clone, Copy)] -pub struct Fdt<'a> { - data: &'a [u8], - header: FdtHeader, -} - -impl core::fmt::Debug for Fdt<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - #[cfg(feature = "pretty-printing")] - pretty_print::print_node(f, self.root().node, 0)?; - - #[cfg(not(feature = "pretty-printing"))] - f.debug_struct("Fdt").finish_non_exhaustive()?; - - Ok(()) - } -} - -#[derive(Debug, Clone, Copy)] -#[repr(C)] -struct FdtHeader { - /// FDT header magic - magic: BigEndianU32, - /// Total size in bytes of the FDT structure - totalsize: BigEndianU32, - /// Offset in bytes from the start of the header to the structure block - off_dt_struct: BigEndianU32, - /// Offset in bytes from the start of the header to the strings block - off_dt_strings: BigEndianU32, - /// Offset in bytes from the start of the header to the memory reservation - /// block - off_mem_rsvmap: BigEndianU32, - /// FDT version - version: BigEndianU32, - /// Last compatible FDT version - last_comp_version: BigEndianU32, - /// System boot CPU ID - boot_cpuid_phys: BigEndianU32, - /// Length in bytes of the strings block - size_dt_strings: BigEndianU32, - /// Length in bytes of the struct block - size_dt_struct: BigEndianU32, -} - -impl FdtHeader { - fn valid_magic(&self) -> bool { - self.magic.get() == 0xd00dfeed - } - - fn struct_range(&self) -> core::ops::Range { - let start = self.off_dt_struct.get() as usize; - let end = start + self.size_dt_struct.get() as usize; - - start..end - } - - fn strings_range(&self) -> core::ops::Range { - let start = self.off_dt_strings.get() as usize; - let end = start + self.size_dt_strings.get() as usize; - - start..end - } - - fn from_bytes(bytes: &mut FdtData<'_>) -> Option { - Some(Self { - magic: bytes.u32()?, - totalsize: bytes.u32()?, - off_dt_struct: bytes.u32()?, - off_dt_strings: bytes.u32()?, - off_mem_rsvmap: bytes.u32()?, - version: bytes.u32()?, - last_comp_version: bytes.u32()?, - boot_cpuid_phys: bytes.u32()?, - size_dt_strings: bytes.u32()?, - size_dt_struct: bytes.u32()?, - }) - } -} - -impl<'a> Fdt<'a> { - /// Construct a new `Fdt` from a byte buffer - /// - /// Note: this function does ***not*** require that the data be 4-byte - /// aligned - pub fn new(data: &'a [u8]) -> Result { - let mut stream = FdtData::new(data); - let header = FdtHeader::from_bytes(&mut stream).ok_or(FdtError::BufferTooSmall)?; - - if !header.valid_magic() { - return Err(FdtError::BadMagic); - } else if data.len() < header.totalsize.get() as usize { - return Err(FdtError::BufferTooSmall); - } - - Ok(Self { data, header }) - } - - /// # Safety - /// This function performs a read to verify the magic value. If the pointer - /// is invalid this can result in undefined behavior. - /// - /// Note: this function does ***not*** require that the data be 4-byte - /// aligned - pub unsafe fn from_ptr(ptr: *const u8) -> Result { - if ptr.is_null() { - return Err(FdtError::BadPtr); - } - - let tmp_header = core::slice::from_raw_parts(ptr, core::mem::size_of::()); - let real_size = - FdtHeader::from_bytes(&mut FdtData::new(tmp_header)).unwrap().totalsize.get() as usize; - - Self::new(core::slice::from_raw_parts(ptr, real_size)) - } - - /// Return the `/aliases` node, if one exists - pub fn aliases(&self) -> Option> { - Some(Aliases { - node: node::find_node(&mut FdtData::new(self.structs_block()), "/aliases", self, None)?, - header: self, - }) - } - - /// Searches for the `/chosen` node, which is always available - pub fn chosen(&self) -> Chosen<'_, 'a> { - node::find_node(&mut FdtData::new(self.structs_block()), "/chosen", self, None) - .map(|node| Chosen { node }) - .expect("/chosen is required") - } - - /// Return the `/cpus` node, which is always available - pub fn cpus(&self) -> impl Iterator> { - let parent = self.find_node("/cpus").expect("/cpus is a required node"); - - parent - .children() - .filter(|c| c.name.split('@').next().unwrap() == "cpu") - .map(move |cpu| Cpu { parent, node: cpu }) - } - - /// Returns the memory node, which is always available - pub fn memory(&self) -> Memory<'_, 'a> { - Memory { node: self.find_node("/memory").expect("requires memory node") } - } - - /// Returns an iterator over the memory reservations - pub fn memory_reservations(&self) -> impl Iterator + 'a { - let mut stream = FdtData::new(&self.data[self.header.off_mem_rsvmap.get() as usize..]); - let mut done = false; - - core::iter::from_fn(move || { - if stream.is_empty() || done { - return None; - } - - let res = MemoryReservation::from_bytes(&mut stream)?; - - if res.address() as usize == 0 && res.size() == 0 { - done = true; - return None; - } - - Some(res) - }) - } - - /// Return the root (`/`) node, which is always available - pub fn root(&self) -> Root<'_, 'a> { - Root { node: self.find_node("/").expect("/ is a required node") } - } - - /// Returns the first node that matches the node path, if you want all that - /// match the path, use `find_all_nodes`. This will automatically attempt to - /// resolve aliases if `path` is not found. - /// - /// Node paths must begin with a leading `/` and are ASCII only. Passing in - /// an invalid node path or non-ASCII node name in the path will return - /// `None`, as they will not be found within the devicetree structure. - /// - /// Note: if the address of a node name is left out, the search will find - /// the first node that has a matching name, ignoring the address portion if - /// it exists. - pub fn find_node(&self, path: &str) -> Option> { - let node = node::find_node(&mut FdtData::new(self.structs_block()), path, self, None); - node.or_else(|| self.aliases()?.resolve_node(path)) - } - - /// Searches for a node which contains a `compatible` property and contains - /// one of the strings inside of `with` - pub fn find_compatible(&self, with: &[&str]) -> Option> { - self.all_nodes().find(|n| { - n.compatible().and_then(|compats| compats.all().find(|c| with.contains(c))).is_some() - }) - } - - /// Searches for the given `phandle` - pub fn find_phandle(&self, phandle: u32) -> Option> { - self.all_nodes().find(|n| { - n.properties() - .find(|p| p.name == "phandle") - .and_then(|p| Some(BigEndianU32::from_bytes(p.value)?.get() == phandle)) - .unwrap_or(false) - }) - } - - /// Returns an iterator over all of the available nodes with the given path. - /// This does **not** attempt to find any node with the same name as the - /// provided path, if you're looking to do that, [`Fdt::all_nodes`] will - /// allow you to iterate over each node's name and filter for the desired - /// node(s). - /// - /// For example: - /// ```rust - /// static MY_FDT: &[u8] = include_bytes!("../dtb/test.dtb"); - /// - /// let fdt = fdt::Fdt::new(MY_FDT).unwrap(); - /// - /// for node in fdt.find_all_nodes("/soc/virtio_mmio") { - /// println!("{}", node.name); - /// } - /// ``` - /// prints: - /// ```notrust - /// virtio_mmio@10008000 - /// virtio_mmio@10007000 - /// virtio_mmio@10006000 - /// virtio_mmio@10005000 - /// virtio_mmio@10004000 - /// virtio_mmio@10003000 - /// virtio_mmio@10002000 - /// virtio_mmio@10001000 - /// ``` - pub fn find_all_nodes(&self, path: &'a str) -> impl Iterator> { - let mut done = false; - let only_root = path == "/"; - let valid_path = path.chars().fold(0, |acc, c| acc + if c == '/' { 1 } else { 0 }) >= 1; - - let mut path_split = path.rsplitn(2, '/'); - let child_name = path_split.next().unwrap(); - let parent = match path_split.next() { - Some("") => Some(self.root().node), - Some(s) => node::find_node(&mut FdtData::new(self.structs_block()), s, self, None), - None => None, - }; - - let (parent, bad_parent) = match parent { - Some(parent) => (parent, false), - None => (self.find_node("/").unwrap(), true), - }; - - let mut child_iter = parent.children(); - - core::iter::from_fn(move || { - if done || !valid_path || bad_parent { - return None; - } - - if only_root { - done = true; - return self.find_node("/"); - } - - let mut ret = None; - - #[allow(clippy::while_let_on_iterator)] - while let Some(child) = child_iter.next() { - if child.name.split('@').next()? == child_name { - ret = Some(child); - break; - } - } - - ret - }) - } - - /// Returns an iterator over all of the nodes in the devicetree, depth-first - pub fn all_nodes(&self) -> impl Iterator> { - node::all_nodes(self) - } - - /// Returns an iterator over all of the strings inside of the strings block - pub fn strings(&self) -> impl Iterator { - let mut block = self.strings_block(); - - core::iter::from_fn(move || { - if block.is_empty() { - return None; - } - - let cstr = CStr::new(block)?; - - block = &block[cstr.len() + 1..]; - - cstr.as_str() - }) - } - - /// Total size of the devicetree in bytes - pub fn total_size(&self) -> usize { - self.header.totalsize.get() as usize - } - - fn cstr_at_offset(&self, offset: usize) -> CStr<'a> { - CStr::new(&self.strings_block()[offset..]).expect("no null terminating string on C str?") - } - - fn str_at_offset(&self, offset: usize) -> &'a str { - self.cstr_at_offset(offset).as_str().expect("not utf-8 cstr") - } - - fn strings_block(&self) -> &'a [u8] { - &self.data[self.header.strings_range()] - } - - fn structs_block(&self) -> &'a [u8] { - &self.data[self.header.struct_range()] - } -} diff --git a/vendor/fdt/src/node.rs b/vendor/fdt/src/node.rs deleted file mode 100644 index e71a42f0..00000000 --- a/vendor/fdt/src/node.rs +++ /dev/null @@ -1,549 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at https://mozilla.org/MPL/2.0/. - -use crate::{ - parsing::{BigEndianU32, BigEndianU64, CStr, FdtData}, - standard_nodes::{Compatible, MemoryRegion}, - Fdt, -}; - -const FDT_BEGIN_NODE: u32 = 1; -const FDT_END_NODE: u32 = 2; -const FDT_PROP: u32 = 3; -pub(crate) const FDT_NOP: u32 = 4; -const FDT_END: u32 = 5; - -#[derive(Debug, Clone, Copy)] -#[repr(C)] -struct FdtProperty { - len: BigEndianU32, - name_offset: BigEndianU32, -} - -impl FdtProperty { - fn from_bytes(bytes: &mut FdtData<'_>) -> Option { - let len = bytes.u32()?; - let name_offset = bytes.u32()?; - - Some(Self { len, name_offset }) - } -} - -/// A devicetree node -#[derive(Debug, Clone, Copy)] -pub struct FdtNode<'b, 'a: 'b> { - pub name: &'a str, - pub(crate) header: &'b Fdt<'a>, - props: &'a [u8], - parent_props: Option<&'a [u8]>, -} - -impl<'b, 'a: 'b> FdtNode<'b, 'a> { - fn new( - name: &'a str, - header: &'b Fdt<'a>, - props: &'a [u8], - parent_props: Option<&'a [u8]>, - ) -> Self { - Self { name, header, props, parent_props } - } - - /// Returns an iterator over the available properties of the node - pub fn properties(self) -> impl Iterator> + 'b { - let mut stream = FdtData::new(self.props); - let mut done = false; - - core::iter::from_fn(move || { - if stream.is_empty() || done { - return None; - } - - while stream.peek_u32()?.get() == FDT_NOP { - stream.skip(4); - } - - if stream.peek_u32().unwrap().get() == FDT_PROP { - Some(NodeProperty::parse(&mut stream, self.header)) - } else { - done = true; - None - } - }) - } - - /// Attempts to find the a property by its name - pub fn property(self, name: &str) -> Option> { - self.properties().find(|p| p.name == name) - } - - /// Returns an iterator over the children of the current node - pub fn children(self) -> impl Iterator> { - let mut stream = FdtData::new(self.props); - - while stream.peek_u32().unwrap().get() == FDT_NOP { - stream.skip(4); - } - - while stream.peek_u32().unwrap().get() == FDT_PROP { - NodeProperty::parse(&mut stream, self.header); - } - - let mut done = false; - - core::iter::from_fn(move || { - if stream.is_empty() || done { - return None; - } - - while stream.peek_u32()?.get() == FDT_NOP { - stream.skip(4); - } - - if stream.peek_u32()?.get() == FDT_BEGIN_NODE { - let origin = stream.remaining(); - let ret = { - stream.skip(4); - let unit_name = CStr::new(stream.remaining()).expect("unit name").as_str()?; - let full_name_len = unit_name.len() + 1; - stream.skip(full_name_len); - - if full_name_len % 4 != 0 { - stream.skip(4 - (full_name_len % 4)); - } - - Some(Self::new(unit_name, self.header, stream.remaining(), Some(self.props))) - }; - - stream = FdtData::new(origin); - - skip_current_node(&mut stream, self.header); - - ret - } else { - done = true; - None - } - }) - } - - /// `reg` property - /// - /// Important: this method assumes that the value(s) inside the `reg` - /// property represent CPU-addressable addresses that are able to fit within - /// the platform's pointer size (e.g. `#address-cells` and `#size-cells` are - /// less than or equal to 2 for a 64-bit platform). If this is not the case - /// or you're unsure of whether this applies to the node, it is recommended - /// to use the [`FdtNode::property`] method to extract the raw value slice - /// or use the provided [`FdtNode::raw_reg`] helper method to give you an - /// iterator over the address and size slices. One example of where this - /// would return `None` for a node is a `pci` child node which contains the - /// PCI address information in the `reg` property, of which the address has - /// an `#address-cells` value of 3. - pub fn reg(self) -> Option + 'a> { - let sizes = self.parent_cell_sizes(); - if sizes.address_cells > 2 || sizes.size_cells > 2 { - return None; - } - - let mut reg = None; - for prop in self.properties() { - if prop.name == "reg" { - let mut stream = FdtData::new(prop.value); - reg = Some(core::iter::from_fn(move || { - let starting_address = match sizes.address_cells { - 1 => stream.u32()?.get() as usize, - 2 => stream.u64()?.get() as usize, - _ => return None, - } as *const u8; - - let size = match sizes.size_cells { - 0 => None, - 1 => Some(stream.u32()?.get() as usize), - 2 => Some(stream.u64()?.get() as usize), - _ => return None, - }; - - Some(MemoryRegion { starting_address, size }) - })); - break; - } - } - - reg - } - - /// Convenience method that provides an iterator over the raw bytes for the - /// address and size values inside of the `reg` property - pub fn raw_reg(self) -> Option> + 'a> { - let sizes = self.parent_cell_sizes(); - - if let Some(prop) = self.property("reg") { - let mut stream = FdtData::new(prop.value); - return Some(core::iter::from_fn(move || { - Some(RawReg { - address: stream.take(sizes.address_cells * 4)?, - size: stream.take(sizes.size_cells * 4)?, - }) - })); - } - - None - } - - /// `compatible` property - pub fn compatible(self) -> Option> { - let mut s = None; - for prop in self.properties() { - if prop.name == "compatible" { - s = Some(Compatible { data: prop.value }); - } - } - - s - } - - /// Cell sizes for child nodes - pub fn cell_sizes(self) -> CellSizes { - let mut cell_sizes = CellSizes::default(); - - for property in self.properties() { - match property.name { - "#address-cells" => { - cell_sizes.address_cells = BigEndianU32::from_bytes(property.value) - .expect("not enough bytes for #address-cells value") - .get() as usize; - } - "#size-cells" => { - cell_sizes.size_cells = BigEndianU32::from_bytes(property.value) - .expect("not enough bytes for #size-cells value") - .get() as usize; - } - _ => {} - } - } - - cell_sizes - } - - /// Searches for the interrupt parent, if the node contains one - pub fn interrupt_parent(self) -> Option> { - self.properties() - .find(|p| p.name == "interrupt-parent") - .and_then(|p| self.header.find_phandle(BigEndianU32::from_bytes(p.value)?.get())) - } - - /// `#interrupt-cells` property - pub fn interrupt_cells(self) -> Option { - let mut interrupt_cells = None; - - if let Some(prop) = self.property("#interrupt-cells") { - interrupt_cells = BigEndianU32::from_bytes(prop.value).map(|n| n.get() as usize) - } - - interrupt_cells - } - - /// `interrupts` property - pub fn interrupts(self) -> Option + 'a> { - let sizes = self.parent_interrupt_cells()?; - - let mut interrupt = None; - for prop in self.properties() { - if prop.name == "interrupts" { - let mut stream = FdtData::new(prop.value); - interrupt = Some(core::iter::from_fn(move || { - let interrupt = match sizes { - 1 => stream.u32()?.get() as usize, - 2 => stream.u64()?.get() as usize, - 3 => { - let ret = stream.u64()?.get() as usize; - stream.skip(4); - ret - } - _ => return None, - }; - - Some(interrupt) - })); - break; - } - } - interrupt - } - - pub(crate) fn parent_cell_sizes(self) -> CellSizes { - let mut cell_sizes = CellSizes::default(); - - if let Some(parent) = self.parent_props { - let parent = - FdtNode { name: "", props: parent, header: self.header, parent_props: None }; - cell_sizes = parent.cell_sizes(); - } - - cell_sizes - } - - pub(crate) fn parent_interrupt_cells(self) -> Option { - let mut interrupt_cells = None; - let parent = self - .property("interrupt-parent") - .and_then(|p| self.header.find_phandle(BigEndianU32::from_bytes(p.value)?.get())) - .or_else(|| { - Some(FdtNode { - name: "", - props: self.parent_props?, - header: self.header, - parent_props: None, - }) - }); - - if let Some(size) = parent.and_then(|parent| parent.interrupt_cells()) { - interrupt_cells = Some(size); - } - - interrupt_cells - } -} - -/// The number of cells (big endian u32s) that addresses and sizes take -#[derive(Debug, Clone, Copy)] -pub struct CellSizes { - /// Size of values representing an address - pub address_cells: usize, - /// Size of values representing a size - pub size_cells: usize, -} - -impl Default for CellSizes { - fn default() -> Self { - CellSizes { address_cells: 2, size_cells: 1 } - } -} - -/// A raw `reg` property value set -#[derive(Debug, Clone, Copy, PartialEq)] -pub struct RawReg<'a> { - /// Big-endian encoded bytes making up the address portion of the property. - /// Length will always be a multiple of 4 bytes. - pub address: &'a [u8], - /// Big-endian encoded bytes making up the size portion of the property. - /// Length will always be a multiple of 4 bytes. - pub size: &'a [u8], -} - -pub(crate) fn find_node<'b, 'a: 'b>( - stream: &mut FdtData<'a>, - name: &str, - header: &'b Fdt<'a>, - parent_props: Option<&'a [u8]>, -) -> Option> { - let mut parts = name.splitn(2, '/'); - let looking_for = parts.next()?; - - stream.skip_nops(); - - let curr_data = stream.remaining(); - - match stream.u32()?.get() { - FDT_BEGIN_NODE => {} - _ => return None, - } - - let unit_name = CStr::new(stream.remaining()).expect("unit name C str").as_str()?; - - let full_name_len = unit_name.len() + 1; - skip_4_aligned(stream, full_name_len); - - let looking_contains_addr = looking_for.contains('@'); - let addr_name_same = unit_name == looking_for; - let base_name_same = unit_name.split('@').next()? == looking_for; - - if (looking_contains_addr && !addr_name_same) || (!looking_contains_addr && !base_name_same) { - *stream = FdtData::new(curr_data); - skip_current_node(stream, header); - - return None; - } - - let next_part = match parts.next() { - None | Some("") => { - return Some(FdtNode::new(unit_name, header, stream.remaining(), parent_props)) - } - Some(part) => part, - }; - - stream.skip_nops(); - - let parent_props = Some(stream.remaining()); - - while stream.peek_u32()?.get() == FDT_PROP { - let _ = NodeProperty::parse(stream, header); - } - - while stream.peek_u32()?.get() == FDT_BEGIN_NODE { - if let Some(p) = find_node(stream, next_part, header, parent_props) { - return Some(p); - } - } - - stream.skip_nops(); - - if stream.u32()?.get() != FDT_END_NODE { - return None; - } - - None -} - -// FIXME: this probably needs refactored -pub(crate) fn all_nodes<'b, 'a: 'b>(header: &'b Fdt<'a>) -> impl Iterator> { - let mut stream = FdtData::new(header.structs_block()); - let mut done = false; - let mut parents: [&[u8]; 64] = [&[]; 64]; - let mut parent_index = 0; - - core::iter::from_fn(move || { - if stream.is_empty() || done { - return None; - } - - while stream.peek_u32()?.get() == FDT_END_NODE { - parent_index -= 1; - stream.skip(4); - } - - if stream.peek_u32()?.get() == FDT_END { - done = true; - return None; - } - - while stream.peek_u32()?.get() == FDT_NOP { - stream.skip(4); - } - - match stream.u32()?.get() { - FDT_BEGIN_NODE => {} - _ => return None, - } - - let unit_name = CStr::new(stream.remaining()).expect("unit name C str").as_str().unwrap(); - let full_name_len = unit_name.len() + 1; - skip_4_aligned(&mut stream, full_name_len); - - let curr_node = stream.remaining(); - - parent_index += 1; - parents[parent_index] = curr_node; - - while stream.peek_u32()?.get() == FDT_NOP { - stream.skip(4); - } - - while stream.peek_u32()?.get() == FDT_PROP { - NodeProperty::parse(&mut stream, header); - } - - Some(FdtNode { - name: if unit_name.is_empty() { "/" } else { unit_name }, - header, - parent_props: match parent_index { - 1 => None, - _ => Some(parents[parent_index - 1]), - }, - props: curr_node, - }) - }) -} - -pub(crate) fn skip_current_node<'a>(stream: &mut FdtData<'a>, header: &Fdt<'a>) { - assert_eq!(stream.u32().unwrap().get(), FDT_BEGIN_NODE, "bad node"); - - let unit_name = CStr::new(stream.remaining()).expect("unit_name C str").as_str().unwrap(); - let full_name_len = unit_name.len() + 1; - skip_4_aligned(stream, full_name_len); - - while stream.peek_u32().unwrap().get() == FDT_PROP { - NodeProperty::parse(stream, header); - } - - while stream.peek_u32().unwrap().get() == FDT_BEGIN_NODE { - skip_current_node(stream, header); - } - - stream.skip_nops(); - - assert_eq!(stream.u32().unwrap().get(), FDT_END_NODE, "bad node"); -} - -/// A node property -#[derive(Debug, Clone, Copy)] -pub struct NodeProperty<'a> { - /// Property name - pub name: &'a str, - /// Property value - pub value: &'a [u8], -} - -impl<'a> NodeProperty<'a> { - /// Attempt to parse the property value as a `usize` - pub fn as_usize(self) -> Option { - match self.value.len() { - 4 => BigEndianU32::from_bytes(self.value).map(|i| i.get() as usize), - 8 => BigEndianU64::from_bytes(self.value).map(|i| i.get() as usize), - _ => None, - } - } - - /// Attempt to parse the property value as a `&str` - pub fn as_str(self) -> Option<&'a str> { - core::str::from_utf8(self.value).map(|s| s.trim_end_matches('\0')).ok() - } - - fn parse(stream: &mut FdtData<'a>, header: &Fdt<'a>) -> Self { - match stream.u32().unwrap().get() { - FDT_PROP => {} - other => panic!("bad prop, tag: {}", other), - } - - let prop = FdtProperty::from_bytes(stream).expect("FDT property"); - let data_len = prop.len.get() as usize; - - let data = &stream.remaining()[..data_len]; - - skip_4_aligned(stream, data_len); - - NodeProperty { name: header.str_at_offset(prop.name_offset.get() as usize), value: data } - } -} - -/// A memory reservation -#[derive(Debug)] -#[repr(C)] -pub struct MemoryReservation { - pub(crate) address: BigEndianU64, - pub(crate) size: BigEndianU64, -} - -impl MemoryReservation { - /// Pointer representing the memory reservation address - pub fn address(&self) -> *const u8 { - self.address.get() as usize as *const u8 - } - - /// Size of the memory reservation - pub fn size(&self) -> usize { - self.size.get() as usize - } - - pub(crate) fn from_bytes(bytes: &mut FdtData<'_>) -> Option { - let address = bytes.u64()?; - let size = bytes.u64()?; - - Some(Self { address, size }) - } -} - -fn skip_4_aligned(stream: &mut FdtData<'_>, len: usize) { - stream.skip((len + 3) & !0x3); -} diff --git a/vendor/fdt/src/parsing.rs b/vendor/fdt/src/parsing.rs deleted file mode 100644 index 9d9e5604..00000000 --- a/vendor/fdt/src/parsing.rs +++ /dev/null @@ -1,108 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at https://mozilla.org/MPL/2.0/. - -use core::convert::TryInto; -pub struct CStr<'a>(&'a [u8]); - -impl<'a> CStr<'a> { - pub fn new(data: &'a [u8]) -> Option { - let end = data.iter().position(|&b| b == 0)?; - Some(Self(&data[..end])) - } - - /// Does not include the null terminating byte - pub fn len(&self) -> usize { - self.0.len() - } - - pub fn as_str(&self) -> Option<&'a str> { - core::str::from_utf8(self.0).ok() - } -} - -#[derive(Debug, Clone, Copy)] -#[repr(transparent)] -pub struct BigEndianU32(u32); - -impl BigEndianU32 { - pub fn get(self) -> u32 { - self.0 - } - - pub(crate) fn from_bytes(bytes: &[u8]) -> Option { - Some(BigEndianU32(u32::from_be_bytes(bytes.get(..4)?.try_into().unwrap()))) - } -} - -#[derive(Debug, Clone, Copy)] -#[repr(transparent)] -pub struct BigEndianU64(u64); - -impl BigEndianU64 { - pub fn get(&self) -> u64 { - self.0 - } - - pub(crate) fn from_bytes(bytes: &[u8]) -> Option { - Some(BigEndianU64(u64::from_be_bytes(bytes.get(..8)?.try_into().unwrap()))) - } -} - -#[derive(Debug, Clone, Copy)] -pub struct FdtData<'a> { - bytes: &'a [u8], -} - -impl<'a> FdtData<'a> { - pub fn new(bytes: &'a [u8]) -> Self { - Self { bytes } - } - - pub fn u32(&mut self) -> Option { - let ret = BigEndianU32::from_bytes(self.bytes)?; - self.skip(4); - - Some(ret) - } - - pub fn u64(&mut self) -> Option { - let ret = BigEndianU64::from_bytes(self.bytes)?; - self.skip(8); - - Some(ret) - } - - pub fn skip(&mut self, n_bytes: usize) { - self.bytes = self.bytes.get(n_bytes..).unwrap_or_default() - } - - pub fn remaining(&self) -> &'a [u8] { - self.bytes - } - - pub fn peek_u32(&self) -> Option { - Self::new(self.remaining()).u32() - } - - pub fn is_empty(&self) -> bool { - self.remaining().is_empty() - } - - pub fn skip_nops(&mut self) { - while let Some(crate::node::FDT_NOP) = self.peek_u32().map(|n| n.get()) { - let _ = self.u32(); - } - } - - pub fn take(&mut self, bytes: usize) -> Option<&'a [u8]> { - if self.bytes.len() >= bytes { - let ret = &self.bytes[..bytes]; - self.skip(bytes); - - return Some(ret); - } - - None - } -} diff --git a/vendor/fdt/src/pretty_print.rs b/vendor/fdt/src/pretty_print.rs deleted file mode 100644 index aa57409d..00000000 --- a/vendor/fdt/src/pretty_print.rs +++ /dev/null @@ -1,100 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at https://mozilla.org/MPL/2.0/. - -pub fn print_node( - f: &mut core::fmt::Formatter<'_>, - node: crate::node::FdtNode<'_, '_>, - n_spaces: usize, -) -> core::fmt::Result { - write!(f, "{:width$}", ' ', width = n_spaces)?; - writeln!(f, "{} {{", if node.name.is_empty() { "/" } else { node.name })?; - let mut were_props = false; - for prop in node.properties() { - were_props = true; - - match prop.name { - "reg" => { - write!(f, "{:width$}reg = <", ' ', width = n_spaces + 4)?; - for (i, reg) in node.reg().unwrap().enumerate() { - if i > 0 { - write!(f, " ")?; - } - - match reg.size { - Some(size) => { - write!(f, "{:#x} {:#x}", reg.starting_address as usize, size)? - } - None => write!(f, "{:#x}", reg.starting_address as usize)?, - } - } - writeln!(f, ">")?; - } - "compatible" => writeln!( - f, - "{:width$}compatible = {:?}", - ' ', - prop.as_str().unwrap(), - width = n_spaces + 4 - )?, - name if name.contains("-cells") => { - writeln!( - f, - "{:width$}{} = <{:#x}>", - ' ', - name, - prop.as_usize().unwrap(), - width = n_spaces + 4 - )?; - } - _ => match prop.as_str() { - Some(value) - if (!value.is_empty() && value.chars().all(|c| c.is_ascii_graphic())) - || prop.value == [0] => - { - writeln!(f, "{:width$}{} = {:?}", ' ', prop.name, value, width = n_spaces + 4)? - } - _ => match prop.value.len() { - 4 | 8 => writeln!( - f, - "{:width$}{} = <{:#x}>", - ' ', - prop.name, - prop.as_usize().unwrap(), - width = n_spaces + 4 - )?, - _ => writeln!( - f, - "{:width$}{} = {:?}", - ' ', - prop.name, - prop.value, - width = n_spaces + 4 - )?, - }, - }, - } - } - - if node.children().next().is_some() && were_props { - writeln!(f)?; - } - - let mut first = true; - for child in node.children() { - if !first { - writeln!(f)?; - } - - print_node(f, child, n_spaces + 4)?; - first = false; - } - - if n_spaces > 0 { - write!(f, "{:width$}", ' ', width = n_spaces)?; - } - - writeln!(f, "}};")?; - - Ok(()) -} diff --git a/vendor/fdt/src/standard_nodes.rs b/vendor/fdt/src/standard_nodes.rs deleted file mode 100644 index cde37754..00000000 --- a/vendor/fdt/src/standard_nodes.rs +++ /dev/null @@ -1,300 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at https://mozilla.org/MPL/2.0/. - -use crate::{ - node::{CellSizes, FdtNode, NodeProperty}, - parsing::{BigEndianU32, BigEndianU64, CStr, FdtData}, - Fdt, -}; - -/// Represents the `/chosen` node with specific helper methods -#[derive(Debug, Clone, Copy)] -pub struct Chosen<'b, 'a: 'b> { - pub(crate) node: FdtNode<'b, 'a>, -} - -impl<'b, 'a: 'b> Chosen<'b, 'a> { - /// Contains the bootargs, if they exist - pub fn bootargs(self) -> Option<&'a str> { - self.node - .properties() - .find(|n| n.name == "bootargs") - .and_then(|n| core::str::from_utf8(&n.value[..n.value.len() - 1]).ok()) - } - - /// Searches for the node representing `stdout`, if the property exists, - /// attempting to resolve aliases if the node name doesn't exist as-is - pub fn stdout(self) -> Option> { - self.node - .properties() - .find(|n| n.name == "stdout-path") - .and_then(|n| core::str::from_utf8(&n.value[..n.value.len() - 1]).ok()) - .and_then(|name| self.node.header.find_node(name)) - } - - /// Searches for the node representing `stdout`, if the property exists, - /// attempting to resolve aliases if the node name doesn't exist as-is. If - /// no `stdin` property exists, but `stdout` is present, it will return the - /// node specified by the `stdout` property. - pub fn stdin(self) -> Option> { - self.node - .properties() - .find(|n| n.name == "stdin-path") - .and_then(|n| core::str::from_utf8(&n.value[..n.value.len() - 1]).ok()) - .and_then(|name| self.node.header.find_node(name)) - .or_else(|| self.stdout()) - } -} - -/// Represents the root (`/`) node with specific helper methods -#[derive(Debug, Clone, Copy)] -pub struct Root<'b, 'a: 'b> { - pub(crate) node: FdtNode<'b, 'a>, -} - -impl<'b, 'a: 'b> Root<'b, 'a> { - /// Root node cell sizes - pub fn cell_sizes(self) -> CellSizes { - self.node.cell_sizes() - } - - /// `model` property - pub fn model(self) -> &'a str { - self.node - .properties() - .find(|p| p.name == "model") - .and_then(|p| core::str::from_utf8(p.value).map(|s| s.trim_end_matches('\0')).ok()) - .unwrap() - } - - /// `compatible` property - pub fn compatible(self) -> Compatible<'a> { - self.node.compatible().unwrap() - } - - /// Returns an iterator over all of the available properties - pub fn properties(self) -> impl Iterator> + 'b { - self.node.properties() - } - - /// Attempts to find the a property by its name - pub fn property(self, name: &str) -> Option> { - self.node.properties().find(|p| p.name == name) - } -} - -/// Represents the `/aliases` node with specific helper methods -#[derive(Debug, Clone, Copy)] -pub struct Aliases<'b, 'a: 'b> { - pub(crate) header: &'b Fdt<'a>, - pub(crate) node: FdtNode<'b, 'a>, -} - -impl<'b, 'a: 'b> Aliases<'b, 'a> { - /// Attempt to resolve an alias to a node name - pub fn resolve(self, alias: &str) -> Option<&'a str> { - self.node - .properties() - .find(|p| p.name == alias) - .and_then(|p| core::str::from_utf8(p.value).map(|s| s.trim_end_matches('\0')).ok()) - } - - /// Attempt to find the node specified by the given alias - pub fn resolve_node(self, alias: &str) -> Option> { - self.resolve(alias).and_then(|name| self.header.find_node(name)) - } - - /// Returns an iterator over all of the available aliases - pub fn all(self) -> impl Iterator + 'b { - self.node.properties().filter_map(|p| { - Some((p.name, core::str::from_utf8(p.value).map(|s| s.trim_end_matches('\0')).ok()?)) - }) - } -} - -/// Represents a `/cpus/cpu*` node with specific helper methods -#[derive(Debug, Clone, Copy)] -pub struct Cpu<'b, 'a: 'b> { - pub(crate) parent: FdtNode<'b, 'a>, - pub(crate) node: FdtNode<'b, 'a>, -} - -impl<'b, 'a: 'b> Cpu<'b, 'a> { - /// Return the IDs for the given CPU - pub fn ids(self) -> CpuIds<'a> { - let address_cells = self.node.parent_cell_sizes().address_cells; - - CpuIds { - reg: self - .node - .properties() - .find(|p| p.name == "reg") - .expect("reg is a required property of cpu nodes"), - address_cells, - } - } - - /// `clock-frequency` property - pub fn clock_frequency(self) -> usize { - self.node - .properties() - .find(|p| p.name == "clock-frequency") - .or_else(|| self.parent.property("clock-frequency")) - .map(|p| match p.value.len() { - 4 => BigEndianU32::from_bytes(p.value).unwrap().get() as usize, - 8 => BigEndianU64::from_bytes(p.value).unwrap().get() as usize, - _ => unreachable!(), - }) - .expect("clock-frequency is a required property of cpu nodes") - } - - /// `timebase-frequency` property - pub fn timebase_frequency(self) -> usize { - self.node - .properties() - .find(|p| p.name == "timebase-frequency") - .or_else(|| self.parent.property("timebase-frequency")) - .map(|p| match p.value.len() { - 4 => BigEndianU32::from_bytes(p.value).unwrap().get() as usize, - 8 => BigEndianU64::from_bytes(p.value).unwrap().get() as usize, - _ => unreachable!(), - }) - .expect("timebase-frequency is a required property of cpu nodes") - } - - /// Returns an iterator over all of the properties for the CPU node - pub fn properties(self) -> impl Iterator> + 'b { - self.node.properties() - } - - /// Attempts to find the a property by its name - pub fn property(self, name: &str) -> Option> { - self.node.properties().find(|p| p.name == name) - } -} - -/// Represents the value of the `reg` property of a `/cpus/cpu*` node which may -/// contain more than one CPU or thread ID -#[derive(Debug, Clone, Copy)] -pub struct CpuIds<'a> { - pub(crate) reg: NodeProperty<'a>, - pub(crate) address_cells: usize, -} - -impl<'a> CpuIds<'a> { - /// The first listed CPU ID, which will always exist - pub fn first(self) -> usize { - match self.address_cells { - 1 => BigEndianU32::from_bytes(self.reg.value).unwrap().get() as usize, - 2 => BigEndianU64::from_bytes(self.reg.value).unwrap().get() as usize, - n => panic!("address-cells of size {} is currently not supported", n), - } - } - - /// Returns an iterator over all of the listed CPU IDs - pub fn all(self) -> impl Iterator + 'a { - let mut vals = FdtData::new(self.reg.value); - core::iter::from_fn(move || match vals.remaining() { - [] => None, - _ => Some(match self.address_cells { - 1 => vals.u32()?.get() as usize, - 2 => vals.u64()?.get() as usize, - n => panic!("address-cells of size {} is currently not supported", n), - }), - }) - } -} - -/// Represents the `compatible` property of a node -#[derive(Clone, Copy)] -pub struct Compatible<'a> { - pub(crate) data: &'a [u8], -} - -impl<'a> Compatible<'a> { - /// First compatible string - pub fn first(self) -> &'a str { - CStr::new(self.data).expect("expected C str").as_str().unwrap() - } - - /// Returns an iterator over all available compatible strings - pub fn all(self) -> impl Iterator { - let mut data = self.data; - core::iter::from_fn(move || { - if data.is_empty() { - return None; - } - - match data.iter().position(|b| *b == b'\0') { - Some(idx) => { - let ret = Some(core::str::from_utf8(&data[..idx]).ok()?); - data = &data[idx + 1..]; - - ret - } - None => { - let ret = Some(core::str::from_utf8(data).ok()?); - data = &[]; - - ret - } - } - }) - } -} - -/// Represents the `/memory` node with specific helper methods -#[derive(Debug, Clone, Copy)] -pub struct Memory<'b, 'a: 'b> { - pub(crate) node: FdtNode<'b, 'a>, -} - -impl Memory<'_, '_> { - /// Returns an iterator over all of the available memory regions - pub fn regions(&self) -> impl Iterator + '_ { - self.node.reg().unwrap() - } - - /// Returns the initial mapped area, if it exists - pub fn initial_mapped_area(&self) -> Option { - let mut mapped_area = None; - - if let Some(init_mapped_area) = self.node.property("initial_mapped_area") { - let mut stream = FdtData::new(init_mapped_area.value); - let effective_address = stream.u64().expect("effective address"); - let physical_address = stream.u64().expect("physical address"); - let size = stream.u32().expect("size"); - - mapped_area = Some(MappedArea { - effective_address: effective_address.get() as usize, - physical_address: physical_address.get() as usize, - size: size.get() as usize, - }); - } - - mapped_area - } -} - -/// An area described by the `initial-mapped-area` property of the `/memory` -/// node -#[derive(Debug, Clone, Copy, PartialEq)] -#[repr(C)] -pub struct MappedArea { - /// Effective address of the mapped area - pub effective_address: usize, - /// Physical address of the mapped area - pub physical_address: usize, - /// Size of the mapped area - pub size: usize, -} - -/// A memory region -#[derive(Debug, Clone, Copy, PartialEq)] -pub struct MemoryRegion { - /// Starting address represented as a pointer - pub starting_address: *const u8, - /// Size of the memory region - pub size: Option, -} diff --git a/vendor/fdt/src/tests.rs b/vendor/fdt/src/tests.rs deleted file mode 100644 index 30a19bbc..00000000 --- a/vendor/fdt/src/tests.rs +++ /dev/null @@ -1,225 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at https://mozilla.org/MPL/2.0/. - -extern crate std; - -use crate::{node::RawReg, *}; - -static TEST: &[u8] = include_bytes!("../dtb/test.dtb"); -static ISSUE_3: &[u8] = include_bytes!("../dtb/issue-3.dtb"); -static SIFIVE: &[u8] = include_bytes!("../dtb/sifive.dtb"); - -#[test] -fn returns_fdt() { - assert!(Fdt::new(TEST).is_ok()); -} - -#[test] -fn finds_root_node() { - let fdt = Fdt::new(TEST).unwrap(); - assert!(fdt.find_node("/").is_some(), "couldn't find root node"); -} - -#[test] -fn finds_root_node_properties() { - let fdt = Fdt::new(TEST).unwrap(); - let prop = fdt - .find_node("/") - .unwrap() - .properties() - .any(|p| p.name == "compatible" && p.value == b"riscv-virtio\0"); - - assert!(prop); -} - -#[test] -fn finds_child_of_root_node() { - let fdt = Fdt::new(TEST).unwrap(); - assert!(fdt.find_node("/cpus").is_some(), "couldn't find cpus node"); -} - -#[test] -fn correct_flash_regions() { - let fdt = Fdt::new(TEST).unwrap(); - let regions = fdt.find_node("/soc/flash").unwrap().reg().unwrap().collect::>(); - - assert_eq!( - regions, - &[ - MemoryRegion { starting_address: 0x20000000 as *const u8, size: Some(0x2000000) }, - MemoryRegion { starting_address: 0x22000000 as *const u8, size: Some(0x2000000) } - ] - ); -} - -#[test] -fn finds_with_addr() { - let fdt = Fdt::new(TEST).unwrap(); - assert_eq!(fdt.find_node("/soc/virtio_mmio@10004000").unwrap().name, "virtio_mmio@10004000"); -} - -#[test] -fn compatibles() { - let fdt = Fdt::new(TEST).unwrap(); - let res = fdt - .find_node("/soc/test") - .unwrap() - .compatible() - .unwrap() - .all() - .all(|s| ["sifive,test1", "sifive,test0", "syscon"].contains(&s)); - - assert!(res); -} - -#[test] -fn parent_cell_sizes() { - let fdt = Fdt::new(TEST).unwrap(); - let regions = fdt.find_node("/memory").unwrap().reg().unwrap().collect::>(); - - assert_eq!( - regions, - &[MemoryRegion { starting_address: 0x80000000 as *const u8, size: Some(0x20000000) }] - ); -} - -#[test] -fn no_properties() { - let fdt = Fdt::new(TEST).unwrap(); - let regions = fdt.find_node("/emptyproptest").unwrap(); - assert_eq!(regions.properties().count(), 0); -} - -#[test] -fn finds_all_nodes() { - let fdt = Fdt::new(TEST).unwrap(); - - let mut all_nodes: std::vec::Vec<_> = fdt.all_nodes().map(|n| n.name).collect(); - all_nodes.sort_unstable(); - - assert_eq!( - all_nodes, - &[ - "/", - "chosen", - "clint@2000000", - "cluster0", - "core0", - "cpu-map", - "cpu@0", - "cpus", - "emptyproptest", - "flash@20000000", - "interrupt-controller", - "memory@80000000", - "pci@30000000", - "plic@c000000", - "poweroff", - "reboot", - "rtc@101000", - "soc", - "test@100000", - "uart@10000000", - "virtio_mmio@10001000", - "virtio_mmio@10002000", - "virtio_mmio@10003000", - "virtio_mmio@10004000", - "virtio_mmio@10005000", - "virtio_mmio@10006000", - "virtio_mmio@10007000", - "virtio_mmio@10008000" - ] - ) -} - -#[test] -fn required_nodes() { - let fdt = Fdt::new(TEST).unwrap(); - fdt.cpus().next().unwrap(); - fdt.memory(); - fdt.chosen(); -} - -#[test] -fn doesnt_exist() { - let fdt = Fdt::new(TEST).unwrap(); - assert!(fdt.find_node("/this/doesnt/exist").is_none()); -} - -#[test] -fn raw_reg() { - let fdt = Fdt::new(TEST).unwrap(); - let regions = - fdt.find_node("/soc/flash").unwrap().raw_reg().unwrap().collect::>(); - - assert_eq!( - regions, - &[ - RawReg { address: &0x20000000u64.to_be_bytes(), size: &0x2000000u64.to_be_bytes() }, - RawReg { address: &0x22000000u64.to_be_bytes(), size: &0x2000000u64.to_be_bytes() } - ] - ); -} - -#[test] -fn issue_3() { - let fdt = Fdt::new(ISSUE_3).unwrap(); - fdt.find_all_nodes("uart").for_each(|n| std::println!("{:?}", n)); -} - -#[test] -fn issue_4() { - let fdt = Fdt::new(ISSUE_3).unwrap(); - fdt.all_nodes().for_each(|n| std::println!("{:?}", n)); -} - -#[test] -fn cpus() { - let fdt = Fdt::new(TEST).unwrap(); - for cpu in fdt.cpus() { - cpu.ids().all().for_each(|n| std::println!("{:?}", n)); - } -} - -#[test] -fn invalid_node() { - let fdt = Fdt::new(TEST).unwrap(); - assert!(fdt.find_node("this/is/an invalid node///////////").is_none()); -} - -#[test] -fn aliases() { - let fdt = Fdt::new(SIFIVE).unwrap(); - let aliases = fdt.aliases().unwrap(); - for (_, node_path) in aliases.all() { - assert!(fdt.find_node(node_path).is_some(), "path: {:?}", node_path); - } -} - -#[test] -fn node_property_str_value() { - let fdt = Fdt::new(TEST).unwrap(); - let cpu0 = fdt.find_node("/cpus/cpu@0").unwrap(); - assert_eq!(cpu0.property("riscv,isa").unwrap().as_str().unwrap(), "rv64imafdcsu"); -} - -#[test] -fn model_value() { - let fdt = Fdt::new(TEST).unwrap(); - assert_eq!(fdt.root().model(), "riscv-virtio,qemu"); -} - -#[test] -fn memory_node() { - let fdt = Fdt::new(TEST).unwrap(); - assert_eq!(fdt.memory().regions().count(), 1); -} - -#[test] -fn interrupt_cells() { - let fdt = Fdt::new(TEST).unwrap(); - let uart = fdt.find_node("/soc/uart").unwrap(); - std::println!("{:?}", uart.parent_interrupt_cells()); - assert_eq!(uart.interrupts().unwrap().collect::>(), std::vec![0xA]); -}