diff --git a/.cargo/.gitignore b/.cargo/.gitignore new file mode 100644 index 00000000..bffa8c23 --- /dev/null +++ b/.cargo/.gitignore @@ -0,0 +1 @@ +config* \ No newline at end of file diff --git a/.cargo/config b/.cargo/config deleted file mode 100644 index 64b1bb5d..00000000 --- a/.cargo/config +++ /dev/null @@ -1,20 +0,0 @@ -[target.riscv64gc-unknown-none-elf] -rustflags = [ - "-Clink-arg=-Tscripts/qemu-riscv64.ld", - "-Cforce-frame-pointers=yes" -] - -[target.aarch64-unknown-none] -runner = "___HVISOR_SRC___/tools/cargo_test.sh" -rustflags = [ - "-Clink-arg=-Tscripts/qemu-aarch64.ld", - "-Ctarget-feature=+a53,+v8a,+strict-align,-neon,-fp-armv8", - "-Cforce-frame-pointers=yes", -] - -[target.loongarch64-unknown-none] -linker = "loongarch64-unknown-linux-gnu-gcc" -rustflags = [ - "-Clink-arg=-Tscripts/3a5000-loongarch64.ld", - "-Cforce-frame-pointers=yes", -] \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 175b986d..ef4eebae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,6 @@ on: env: MODE: debug jobs: - linter: name: linter runs-on: ubuntu-latest @@ -25,7 +24,14 @@ jobs: - name: Install Rust Toolchain uses: dtolnay/rust-toolchain@stable with: - components: rustfmt + targets: aarch64-unknown-none + components: rust-src rustfmt + - name: Install Dependencies + run: | + sudo apt-get update + sudo apt-get install -y qemu-system-aarch64 qemu-system-riscv64 gdb-multiarch llvm-dev libclang-dev wget + cargo install --version 0.3.0 cargo-binutils + cargo install cargo-xbuild - name: Format Check run: make fmt-test @@ -39,23 +45,11 @@ jobs: include: # aarch64 - arch: aarch64 + board: "qemu-gicv3" rustc_target: aarch64-unknown-none - features: "platform_qemu,gicv3" - board: "qemu" - arch: aarch64 + board: "qemu-gicv2" rustc_target: aarch64-unknown-none - features: "platform_qemu,gicv2" - board: "qemu" - # riscv64 will be supported in the future but not now, - # because our `make test` uses customized script to run tests, which need extra efforts to - # support riscv64 - - # - arch: riscv64 - # rustc_target: riscv64gc-unknown-none-elf - # features: "platform_qemu,plic" - # - arch: riscv64 - # rustc_target: riscv64gc-unknown-none-elf - # features: "platform_qemu,aia" steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -73,7 +67,7 @@ jobs: - name: Set up environment variables run: | echo "ARCH=${{ matrix.arch }}" >> $GITHUB_ENV - echo "FEATURES=${{ matrix.features }}" >> $GITHUB_ENV + echo "BOARD=${{ matrix.board }}" >> $GITHUB_ENV - name: Unit Test run: make test @@ -88,35 +82,28 @@ jobs: include: # aarch64 - arch: aarch64 + board: "qemu-gicv3" rustc_target: aarch64-unknown-none - features: "platform_qemu,gicv3" - board: "qemu" - arch: aarch64 + board: "qemu-gicv2" rustc_target: aarch64-unknown-none - features: "platform_qemu,gicv2" - board: "qemu" - arch: aarch64 - rustc_target: aarch64-unknown-none - features: "platform_zcu102,gicv2" board: "zcu102" + rustc_target: aarch64-unknown-none - arch: aarch64 + board: "imx8mp" rustc_target: aarch64-unknown-none - features: "platform_imx8mp,gicv3" - board: "qemu" # riscv64 - arch: riscv64 + board: "qemu-aia" rustc_target: riscv64gc-unknown-none-elf - features: "platform_qemu,plic" - board: "qemu" - arch: riscv64 + board: "qemu-plic" rustc_target: riscv64gc-unknown-none-elf - features: "platform_qemu,aia" - board: "qemu" # loongarch64 - arch: loongarch64 + board: "ls3a5000" rustc_target: loongarch64-unknown-none - features: "" - board: "3a5000" steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -137,13 +124,13 @@ jobs: - name: Set up environment variables run: | echo "ARCH=${{ matrix.arch }}" >> $GITHUB_ENV - echo "FEATURES=${{ matrix.features }}" >> $GITHUB_ENV echo "BOARD=${{ matrix.board }}" >> $GITHUB_ENV - name: Build run: make # this job is for booting root and nonroot inside qemu for system test systemtest: + # if: false # we need to update corresponding scripts for the new board abstraction name: systemtest runs-on: ubuntu-latest strategy: @@ -153,9 +140,7 @@ jobs: # aarch64 - arch: aarch64 rustc_target: aarch64-unknown-none - features: "platform_qemu,gicv3" - board: "qemu" - # currently supports only "platform_qemu,gicv3" + board: "qemu-gicv3" # Because other features need to be customized scripts steps: - name: Checkout Repository @@ -174,14 +159,6 @@ jobs: - name: Set up environment variables run: | echo "ARCH=${{ matrix.arch }}" >> $GITHUB_ENV - echo "FEATURES=${{ matrix.features }}" >> $GITHUB_ENV echo "BOARD=${{ matrix.board }}" >> $GITHUB_ENV - - name: Compile DTB - run: | - ./test/tcompiledtb.sh - - name: Download rootfs and image - run: | - ./test/tdownload_all.sh - - name: Run Tests - run: | - ./test/tstart.sh + - name: Run System Test + run: make stest diff --git a/.gitignore b/.gitignore index e9f15bba..f0d11366 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,8 @@ sd.img flash.img* .vscode/settings.json compile.sh +src/platform/__board.rs +.config +# systemtest +rootfs1.zip* \ No newline at end of file diff --git a/.vscode/settings-example.json b/.vscode/settings-example.json index 8a99c430..979e576f 100644 --- a/.vscode/settings-example.json +++ b/.vscode/settings-example.json @@ -15,6 +15,6 @@ // "rust-analyzer.cargo.target": "loongarch64-unknown-none", "rust-analyzer.checkOnSave.allTargets": false, "rust-analyzer.cargo.features": [ - "platform_qemu" + "gicv3 pl011 iommu pci pt_layout_qemu" ] } \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index e65fa930..18ad6ea2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,6 +35,12 @@ dependencies = [ "rustc_version", ] +[[package]] +name = "bit" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b645c5c09a7d4035949cfce1a915785aaad6f17800c35fda8a8c311c491f284" + [[package]] name = "bit_field" version = "0.9.0" @@ -113,11 +119,15 @@ dependencies = [ "numeric-enum-macro", "psci", "qemu-exit", + "raw-cpuid", "riscv", "riscv-decode", "sbi-rt", "spin 0.9.8", "tock-registers", + "x2apic", + "x86", + "x86_64", ] [[package]] @@ -167,6 +177,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "300e4bdb6b46b592948e700ea1ef24a4296491f6a0ee722b258040abd15a3714" +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "psci" version = "0.1.3" @@ -179,6 +195,15 @@ version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bb0fd6580eeed0103c054e3fba2c2618ff476943762f28a645b63b8692b21c9" +[[package]] +name = "raw-cpuid" +version = "10.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "regex" version = "1.10.4" @@ -245,6 +270,12 @@ dependencies = [ "semver", ] +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" + [[package]] name = "sbi-rt" version = "0.0.2" @@ -316,3 +347,45 @@ name = "tock-registers" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "696941a0aee7e276a165a978b37918fd5d22c55c3d6bda197813070ca9c0f21c" + +[[package]] +name = "volatile" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793" + +[[package]] +name = "x2apic" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbcd582541cbb8ef1dfc24a3c849a64ff074b1b512af723ad90056558d424602" +dependencies = [ + "bit", + "bitflags 1.3.2", + "paste", + "raw-cpuid", + "x86_64", +] + +[[package]] +name = "x86" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2781db97787217ad2a2845c396a5efe286f87467a5810836db6d74926e94a385" +dependencies = [ + "bit_field 0.10.2", + "bitflags 1.3.2", + "raw-cpuid", +] + +[[package]] +name = "x86_64" +version = "0.14.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "100555a863c0092238c2e0e814c1096c1e5cf066a309c696a87e907b5f8c5d69" +dependencies = [ + "bit_field 0.10.2", + "bitflags 1.3.2", + "rustversion", + "volatile", +] diff --git a/Cargo.toml b/Cargo.toml index 07a6542c..57346df2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,22 +32,38 @@ riscv-decode = "0.2.1" [target.'cfg(target_arch = "loongarch64")'.dependencies] loongArch64 = "0.2.4" +[target.'cfg(target_arch = "x86_64")'.dependencies] +x86 = "0.52.0" +x86_64 = "=0.14.10" +x2apic = "0.4.3" +raw-cpuid = "10.7.0" + [features] -platform_qemu = [] -platform_imx8mp = [] -platform_zcu102 = [] -gicv3 = [] +############# aarch64 ############## +# irqchip driver gicv2 = [] +gicv3 = [] +# uart driver +pl011 = [] +xuartps = [] +imx_uart = [] +# functionality +iommu = [] +pci = [] +# pagetable layout +pt_layout_qemu = [] +############## riscv64 ############# +# irqchip driver plic = [] aia = [] +########### loongarch64 ############ +# irqchip driver +loongson_7a2000 = [] +# uart driver +loongson_uart = [] + [profile.dev] -# panic = "abort" # avoid test compiler erros(still a bug for rust) +# panic = "abort" # avoid cargo test failure, this is a bug of cargo debug = 2 - -[profile.release] # panic = "abort" - -[unstable] -build-std-features = ["compiler-builtins-mem"] -build-std = ["core", "compiler_builtins"] \ No newline at end of file diff --git a/Makefile b/Makefile index 9cfd5dac..66c264dc 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,29 @@ -# Basic settings ARCH ?= aarch64 LOG ?= info STATS ?= off PORT ?= 2333 MODE ?= debug -OBJCOPY ?= rust-objcopy --binary-architecture=$(ARCH) - -# AVAIABLE "FEATURES" VALUES: -# - platform_qemu, platform_zcu102, platform_imx8mp -# - gicv2, gicv3 (for aarch64) -# - plic, aia (for riscv64) -FEATURES ?= platform_qemu,gicv3 +BOARD ?= qemu-gicv3 +FEATURES= +BID ?= + +# if user uses `make ID=aarch64/qemu-gicv2`, we parse it into ARCH and BOARD +ifeq ($(BID),) + ARCH := $(ARCH) + BOARD := $(BOARD) +else + ARCH := $(shell echo $(BID) | cut -d'/' -f1) + BOARD := $(shell echo $(BID) | cut -d'/' -f2) +endif -# AVAIABLE "BOARD" VALUES: -# - qemu, zcu102, 3a5000 -BOARD ?= qemu +# if user add FEATURES in environment, we use it +# else we use the default FEATURES in platform/$(ARCH)/$(BOARD)/cargo/features +ifeq ($(FEATURES),) + FEATURES := $(shell ./tools/read_features.sh $(ARCH) $(BOARD) || echo ERROR) + ifeq ($(FEATURES),ERROR) + $(error ERROR: Read FEATURES failed. Please check if ARCH="$(ARCH)" and BOARD="$(BOARD)" are correct.) + endif +endif ifeq ($(ARCH),aarch64) RUSTC_TARGET := aarch64-unknown-none @@ -25,22 +34,28 @@ else ifeq ($(ARCH),riscv64) else ifeq ($(ARCH),loongarch64) RUSTC_TARGET := loongarch64-unknown-none GDB_ARCH := loongarch64 +else ifeq ($(ARCH),x86_64) + RUSTC_TARGET := x86_64-unknown-none + GDB_ARCH := i386:x86-64 else -$(error Unsupported ARCH value: $(ARCH)) + $(error ERROR: Unsupported ARCH value: $(ARCH)) endif +OBJCOPY ?= rust-objcopy --binary-architecture=$(ARCH) + export MODE export LOG export ARCH +export BOARD +export BID export RUSTC_TARGET export FEATURES -export BOARD # Build paths build_path := target/$(RUSTC_TARGET)/$(MODE) hvisor_elf := $(build_path)/hvisor hvisor_bin := $(build_path)/hvisor.bin -image_dir := images/$(ARCH) +image_dir := platform/$(ARCH)/$(BOARD)/image # Build arguments build_args := @@ -53,9 +68,35 @@ ifeq ($(MODE), release) build_args += --release endif +# color code +COLOR_GREEN := $(shell tput setaf 2) +COLOR_RED := $(shell tput setaf 1) +COLOR_YELLOW := $(shell tput setaf 3) +COLOR_BLUE := $(shell tput setaf 4) +COLOR_BOLD := $(shell tput bold) +COLOR_RESET := $(shell tput sgr0) + # Targets .PHONY: all elf disa run gdb monitor clean tools rootfs -all: $(hvisor_bin) +all: gen_cargo_config $(hvisor_bin) + @printf "\n" + @printf "$(COLOR_GREEN)$(COLOR_BOLD)hvisor build summary:$(COLOR_RESET)\n" + @printf "%-10s %s\n" "ARCH =" "$(COLOR_BOLD)$(ARCH)$(COLOR_RESET)" + @printf "%-10s %s\n" "BOARD =" "$(COLOR_BOLD)$(BOARD)$(COLOR_RESET)" + @printf "%-10s %s\n" "BID =" "$(COLOR_BOLD)$(BID)$(COLOR_RESET)" + @printf "%-10s %s\n" "LOG =" "$(COLOR_BOLD)$(LOG)$(COLOR_RESET)" + @printf "%-10s %s\n" "FEATURES =" "$(COLOR_BOLD)$(FEATURES)$(COLOR_RESET)" + @printf "%-10s %s\n" "RUSTC_TARGET =" "$(COLOR_BOLD)$(RUSTC_TARGET)$(COLOR_RESET)" + @printf "%-10s %s\n" "BUILD_PATH =" "$(COLOR_BOLD)$(build_path)$(COLOR_RESET)" + @printf "%-10s %s\n" "HVISON_BIN_SIZE =" "$(COLOR_BOLD)$(shell du -h $(hvisor_bin) | cut -f1)$(COLOR_RESET)" + @printf "%-10s %s\n" "BUILD TIME =" "$(COLOR_BOLD)$(shell date)$(COLOR_RESET)" + @printf "\n" + @printf "$(COLOR_GREEN)$(COLOR_BOLD)hvisor build success!$(COLOR_RESET)\n" + +gen_cargo_config: + @printf "$(COLOR_GREEN)$(COLOR_BOLD)Generating .cargo/config.toml...$(COLOR_RESET)\n" + ./tools/gen_cargo_config.sh + @printf "$(COLOR_GREEN)$(COLOR_BOLD)Generating .cargo/config.toml success!$(COLOR_RESET)\n" elf: cargo build $(build_args) @@ -87,14 +128,16 @@ cp: cp $(hvisor_bin) ~/tftp test-pre: download-test-img - chmod +x ./tools/cargo_test.sh - @echo "pass" + chmod +x platform/$(ARCH)/$(BOARD)/test/runner.sh + @echo "added execute permission to test runner.sh for board $(BOARD)" -fmt-test: +fmt-test: all cargo fmt --all -- --check + @echo "cargo fmt check passed!" -fmt: +fmt: all cargo fmt --all + @echo "your code has been formatted" clippy: cargo clippy $(build_args) @@ -112,14 +155,20 @@ download-test-img: else echo "\nflash.img found\n"; \ fi -test: test-pre - cp .cargo/config .cargo/config.bak - sed "s|___HVISOR_SRC___|$(shell pwd)|g" .cargo/config.bak > .cargo/config +test: clean test-pre gen_cargo_config cargo test $(build_args) -vv +stest: clean test-pre gen_cargo_config + ./platform/$(ARCH)/$(BOARD)/test/systemtest/tcompiledtb.sh + ./platform/$(ARCH)/$(BOARD)/test/systemtest/tdownload_all.sh + ./platform/$(ARCH)/$(BOARD)/test/systemtest/tstart.sh + +dtb: + @echo "Building device tree at platform/$(ARCH)/$(BOARD)/image/dts" + @if [ ! -d "platform/$(ARCH)/$(BOARD)/image/dts" ]; then echo "ERROR: dts directory not found"; exit 1; fi + make -C platform/$(ARCH)/$(BOARD)/image/dts + clean: cargo clean -# set the BOARD variable to "3a5000"/qemu/zcu102/imx8mp to -# include the corresponding script under the ./scripts directory -include scripts/${BOARD}-${ARCH}.mk \ No newline at end of file +include platform/$(ARCH)/$(BOARD)/platform.mk \ No newline at end of file diff --git a/build.rs b/build.rs new file mode 100644 index 00000000..50685070 --- /dev/null +++ b/build.rs @@ -0,0 +1,136 @@ +use std::io::Write; +use std::{env, fs, path::Path}; + +const BUILD_LOG_FILE: &str = "target/build_rs.log"; + +fn log(output: &str) { + let log_path = Path::new(BUILD_LOG_FILE); + let mut file = fs::OpenOptions::new() + .create(true) + .append(true) + .open(log_path) + .expect("Failed to open log file"); + writeln!(file, "{}", output).expect("Failed to write to log file"); +} + +// .config +// ARCH=... +// BOARD=... +struct BuildEnv { + arch: String, + board: String, + bid: String, + features: String, +} + +fn parse_build_env(file_path: &str) -> BuildEnv { + let file = fs::read_to_string(file_path).expect("Failed to read .config file"); + let mut arch = String::new(); + let mut board = String::new(); + let mut bid = String::new(); + let mut features = String::new(); + for line in file.lines() { + let parts: Vec<&str> = line.split('=').collect(); + if parts.len() != 2 { + continue; + } + match parts[0] { + "ARCH" => arch = parts[1].to_string(), + "BOARD" => board = parts[1].to_string(), + "BID" => bid = parts[1].to_string(), + "FEATURES" => features = parts[1].to_string(), + _ => {} + } + } + BuildEnv { + arch, + board, + bid, + features, + } +} + +fn main() { + // cleanup the log file + let log_path = Path::new(BUILD_LOG_FILE); + if log_path.exists() { + fs::remove_file(log_path).expect("Failed to remove log file"); + } + + let project_toml_root = env::var("CARGO_MANIFEST_DIR").unwrap(); + // read the .config file at the project root + let config_path = format!("{}/.config", project_toml_root); + let mut build_env = parse_build_env(&config_path); + + if !build_env.bid.is_empty() { + // BID=$ARCH/$BOARD, parse it + // update the build_env with the parsed values + let parts: Vec<&str> = build_env.bid.split('/').collect(); + if parts.len() != 2 { + log(&format!("Invalid BID format: {}", build_env.bid)); + panic!( + "Invalid BID format, please check the log file({}) for more details", + BUILD_LOG_FILE + ); + } + build_env.arch = parts[0].to_string(); + build_env.board = parts[1].to_string(); + } else { + log(&format!( + "BID environment variable not found, using ARCH and BOARD" + )); + if build_env.arch.is_empty() || build_env.board.is_empty() { + log(&format!("ARCH or BOARD environment variable not found")); + panic!( + "ARCH or BOARD environment variable not found, please check the log file({}) for more details", + BUILD_LOG_FILE + ); + } + } + + let arch = build_env.arch; + let board = build_env.board; + let bid = build_env.bid; + let features = build_env.features; + + let pwd = env::current_dir().unwrap(); + log(&format!("Current directory: {}", pwd.display())); + + let target_path_str = format!("{}/src/platform/__board.rs", pwd.display()); + let target_path = Path::new(&target_path_str); + let source_path_str = format!("{}/platform/{}/{}/board.rs", pwd.display(), arch, board); + let source_path = Path::new(&source_path_str); + + log(&format!( + "Building for ARCH={} BOARD={}, BID={}, FEATURES={}", + arch, board, bid, features + )); + + log(&format!( + "Linking board.rs from {} to {}", + source_path_str, + target_path.display() + )); + + if !source_path.exists() { + log(&format!("Invalid board.rs path: {}, make sure the ARCH and BOARD environment variables are set correctly", source_path_str)); + panic!( + "Invalid board.rs, please check the log file({}) for more details", + BUILD_LOG_FILE + ); + } + + // soft link the board.rs to __board.rs + if target_path.exists() { + fs::remove_file(target_path).expect("Failed to remove existing __board.rs"); + } + std::os::unix::fs::symlink(source_path, target_path).expect("Failed to create symlink"); + log(&format!("Linking successful")); + + println!("cargo:rerun-if-env-changed=ARCH"); + println!("cargo:rerun-if-env-changed=BOARD"); + println!("cargo:rerun-if-env-changed=BID"); + println!("cargo:rerun-if-env-changed=FEATURES"); + println!("cargo:rerun-if-changed={}", source_path_str); + println!("cargo:rerun-if-changed={}", target_path_str); +} 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/linux2.json b/images/aarch64/devicetree/linux2.json deleted file mode 100644 index 516adaaf..00000000 --- a/images/aarch64/devicetree/linux2.json +++ /dev/null @@ -1,56 +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], - "ivc_configs": [], - "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 296a219a..00000000 --- a/images/aarch64/devicetree/linux3.json +++ /dev/null @@ -1,56 +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], - "ivc_configs": [], - "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/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 e9924ea6..00000000 --- a/images/aarch64/devicetree/virtio_cfg2.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "zones": [ - { - "id": 1, - "memory_region": [ - { - "zone0_ipa": "0x50000000", - "zonex_ipa": "0x50000000", - "size": "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 8cea0b90..00000000 --- a/images/aarch64/devicetree/virtio_cfg3.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "zones": [ - { - "id": 2, - "memory_region": [ - { - "zone0_ipa": "0x80000000", - "zonex_ipa": "0x80000000", - "size": "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/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/src/platform/imx8mp_aarch64.rs b/platform/aarch64/imx8mp/board.rs similarity index 98% rename from src/platform/imx8mp_aarch64.rs rename to platform/aarch64/imx8mp/board.rs index 30a8804e..6256f318 100644 --- a/src/platform/imx8mp_aarch64.rs +++ b/platform/aarch64/imx8mp/board.rs @@ -1,5 +1,7 @@ use crate::{arch::zone::HvArchZoneConfig, config::*}; +pub const BOARD_NAME: &str = "imx8mp"; + pub const ROOT_ZONE_DTB_ADDR: u64 = 0xa0000000; pub const ROOT_ZONE_KERNEL_ADDR: u64 = 0xa0400000; pub const ROOT_ZONE_ENTRY: u64 = 0xa0400000; diff --git a/platform/aarch64/imx8mp/cargo/config.template.toml b/platform/aarch64/imx8mp/cargo/config.template.toml new file mode 100644 index 00000000..0cb32013 --- /dev/null +++ b/platform/aarch64/imx8mp/cargo/config.template.toml @@ -0,0 +1,6 @@ +[target.aarch64-unknown-none] +rustflags = [ + "-Clink-arg=-Tplatform/__ARCH__/__BOARD__/linker.ld", + "-Ctarget-feature=+a53,+v8a,+strict-align,-neon,-fp-armv8", + "-Cforce-frame-pointers=yes", +] \ No newline at end of file diff --git a/platform/aarch64/imx8mp/cargo/features b/platform/aarch64/imx8mp/cargo/features new file mode 100644 index 00000000..7acf44c6 --- /dev/null +++ b/platform/aarch64/imx8mp/cargo/features @@ -0,0 +1,2 @@ +gicv3 +imx_uart diff --git a/platform/aarch64/imx8mp/configs/zone1-linux.json b/platform/aarch64/imx8mp/configs/zone1-linux.json new file mode 100644 index 00000000..dd7d732a --- /dev/null +++ b/platform/aarch64/imx8mp/configs/zone1-linux.json @@ -0,0 +1,81 @@ +{ + "arch": "arm64", + "name": "linux2", + "zone_id": 1, + "cpus": [2, 3], + "memory_regions": [ + { + "type": "ram", + "physical_start": "0x50000000", + "virtual_start": "0x50000000", + "size": "0x30000000" + }, + { + "type": "io", + "physical_start": "0x30a60000", + "virtual_start": "0x30a60000", + "size": "0x10000" + }, + { + "type": "virtio", + "physical_start": "0xa003c00", + "virtual_start": "0xa003c00", + "size": "0x200" + }, + { + "type": "virtio", + "physical_start": "0xa003800", + "virtual_start": "0xa003800", + "size": "0x200" + }, + { + "type": "virtio", + "physical_start": "0xa003600", + "virtual_start": "0xa003600", + "size": "0x200" + }, + { + "type": "io", + "physical_start": "0x38000000", + "virtual_start": "0x38000000", + "size": "0x10000" + }, + { + "type": "io", + "physical_start": "0x38500000", + "virtual_start": "0x38500000", + "size": "0x20000" + }, + { + "type": "io", + "physical_start": "0x32e80000", + "virtual_start": "0x32e80000", + "size": "0x20000" + }, + { + "type": "io", + "physical_start": "0x30c00000", + "virtual_start": "0x30c00000", + "size": "0x400000" + }, + { + "type": "io", + "physical_start": "0x32fc0000", + "virtual_start": "0x32fc0000", + "size": "0x20000" + } + ], + "interrupts": [35, 37, 38, 45, 56, 57, 61, 75, 76, 78, 135, 162], + "ivc_configs": [], + "kernel_filepath": "./Image", + "dtb_filepath": "./linux2.dtb", + "kernel_load_paddr": "0x50400000", + "dtb_load_paddr": "0x50000000", + "entry_point": "0x50400000", + "arch_config": { + "gicd_base": "0x38800000", + "gicd_size": "0x10000", + "gicr_base": "0x38880000", + "gicr_size": "0xc0000" + } +} diff --git a/platform/aarch64/imx8mp/image/dts/Makefile b/platform/aarch64/imx8mp/image/dts/Makefile new file mode 100644 index 00000000..2f795e7f --- /dev/null +++ b/platform/aarch64/imx8mp/image/dts/Makefile @@ -0,0 +1,8 @@ +DTS_FILES := $(wildcard *.dts) +DTB_FILES := $(DTS_FILES:.dts=.dtb) + +all: $(DTB_FILES) +%.dtb: %.dts + dtc -I dts -O dtb $< -o $@ +clean: + rm -f $(DTB_FILES) \ No newline at end of file diff --git a/platform/aarch64/imx8mp/image/dts/zone0.dts b/platform/aarch64/imx8mp/image/dts/zone0.dts new file mode 100644 index 00000000..c4e1ba97 --- /dev/null +++ b/platform/aarch64/imx8mp/image/dts/zone0.dts @@ -0,0 +1,1443 @@ +/dts-v1/; + +/ { + compatible = "forlinx,ok8mp-c\0fsl,imx8mp-evk\0fsl,imx8mp"; + interrupt-parent = <0x01>; + #address-cells = <0x02>; + #size-cells = <0x02>; + + model = "Forlinx OK8MPlus-C board"; + + aliases { + serial1 = "/soc@0/bus@30800000/serial@30890000"; + serial3 = "/soc@0/bus@30800000/serial@30a60000"; + mmc2 = "/soc@0/bus@30800000/mmc@30b50000"; + mmc3 = "/soc@0/bus@30800000/mmc@30b60000"; + ethernet0 = "/soc@0/bus@30800000/ethernet@30be0000"; + //ethernet1 = "/soc@0/bus@30800000/ethernet@30bf0000"; + gpio0 = "/soc@0/bus@30000000/gpio@30200000"; + gpio1 = "/soc@0/bus@30000000/gpio@30210000"; + gpio2 = "/soc@0/bus@30000000/gpio@30220000"; + gpio3 = "/soc@0/bus@30000000/gpio@30230000"; + gpio4 = "/soc@0/bus@30000000/gpio@30240000"; + }; + + cpus { + #address-cells = <0x01>; + #size-cells = <0x00>; + + idle-states { + entry-method = "psci"; + + cpu-pd-wait { + // compatible = "arm,idle-state"; + arm,psci-suspend-param = <0x10033>; + local-timer-stop; + entry-latency-us = <0x3e8>; + exit-latency-us = <0x2bc>; + min-residency-us = <0xa8c>; + wakeup-latency-us = <0x5dc>; + phandle = <0x06>; + }; + }; + + cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a53"; + reg = <0x00>; + clock-latency = <0xee6c>; + next-level-cache = <0x02>; + clocks = <0x03 0x11f>; + operating-points-v2 = <0x04>; + enable-method = "psci"; + nvmem-cells = <0x05>; + nvmem-cell-names = "speed_grade"; + #cooling-cells = <0x02>; + cpu-idle-states = <0x06>; + cpu-supply = <0x07>; + phandle = <0x11>; + }; + + cpu@1 { + device_type = "cpu"; + compatible = "arm,cortex-a53"; + reg = <0x01>; + 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 = <0x12>; + }; + + // 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>; + // }; + + // cpu@3 { + // device_type = "cpu"; + // compatible = "arm,cortex-a53"; + // reg = <0x03>; + // 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 = <0x14>; + // }; + + l2-cache0 { + compatible = "cache"; + phandle = <0x02>; + }; + }; + + opp-table { + compatible = "operating-points-v2"; + opp-shared; + phandle = <0x04>; + + opp-1200000000 { + opp-hz = <0x00 0x47868c00>; + opp-microvolt = <0xcf850>; + opp-supported-hw = <0x8a0 0x07>; + clock-latency-ns = <0x249f0>; + opp-suspend; + }; + + opp-1600000000 { + opp-hz = <0x00 0x5f5e1000>; + opp-microvolt = <0xe7ef0>; + opp-supported-hw = <0xa0 0x07>; + clock-latency-ns = <0x249f0>; + opp-suspend; + }; + + opp-1800000000 { + opp-hz = <0x00 0x6b49d200>; + opp-microvolt = <0xf4240>; + opp-supported-hw = <0x20 0x03>; + clock-latency-ns = <0x249f0>; + opp-suspend; + }; + }; + + 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>; + }; + + memory@50000000 { + device_type = "memory"; + reg = <0x0 0x50000000 0x0 0x80000000>; + }; + + reserved-memory { + #address-cells = <0x02>; + #size-cells = <0x02>; + ranges; + + linux,cma { + compatible = "shared-dma-pool"; + reusable; + size = <0x00 0x10000000>; + alloc-ranges = <0x00 0x80000000 0x00 0xc0000000>; + linux,cma-default; + }; + + ocram@900000 { + no-map; + reg = <0x00 0x900000 0x00 0x70000>; + }; + + // linux,cma { + // compatible = "shared-dma-pool"; + // reusable; + // size = <0x00 0x3c000000>; + // alloc-ranges = <0x00 0x40000000 0x00 0xc0000000>; + // linux,cma-default; + // }; + + dsp@92400000 { + no-map; + reg = <0x00 0x92400000 0x00 0x2000000>; + phandle = <0x87>; + }; + + nonroot@50000000 { + no-map; + reg = <0x00 0x50000000 0x00 0x30000000>; + }; + + // 这个shared-dma-pool是用来给CMA机制分配内存的,是virtio driver要用。 + // vdev0vring0@55000000 { + // compatible = "shared-dma-pool"; + // reg = <0x00 0x55000000 0x00 0x8000>; + // no-map; + // phandle = <0x09>; + // }; + + // vdev0vring1@55008000 { + // compatible = "shared-dma-pool"; + // reg = <0x00 0x55008000 0x00 0x8000>; + // no-map; + // phandle = <0x0a>; + // }; + + // vdevbuffer@55400000 { + // compatible = "shared-dma-pool"; + // reg = <0x00 0x55400000 0x00 0x100000>; + // no-map; + // phandle = <0x0b>; + // }; + + // rsc-table { + // reg = <0x00 0x550ff000 0x00 0x1000>; + // no-map; + // }; + + // rpmsg@0x55800000 { + // no-map; + // reg = <0x00 0x55800000 0x00 0x800000>; + // }; + + // imx8mp-cm7 { + // compatible = "fsl,imx8mp-cm7"; + // rsc-da = <0x55000000>; + // clocks = <0x03 0x55>; + // mbox-names = "tx\0rx\0rxdb"; + // mboxes = <0x08 0x00 0x01 0x08 0x01 0x01 0x08 0x03 0x01>; + // memory-region = <0x09 0x0a 0x0b>; + // status = "okay"; + // }; + + + }; + + clock-osc-32k { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x8000>; + clock-output-names = "osc_32k"; + phandle = <0x1a>; + }; + + clock-osc-24m { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x16e3600>; + clock-output-names = "osc_24m"; + phandle = <0x1b>; + }; + + clock-ext1 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x7ed6b40>; + clock-output-names = "clk_ext1"; + phandle = <0x1c>; + }; + + clock-ext2 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x7ed6b40>; + clock-output-names = "clk_ext2"; + phandle = <0x1d>; + }; + + clock-ext3 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x7ed6b40>; + clock-output-names = "clk_ext3"; + phandle = <0x1e>; + }; + + clock-ext4 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x7ed6b40>; + clock-output-names = "clk_ext4"; + phandle = <0x1f>; + }; + + busfreq { + compatible = "fsl,imx_busfreq"; + clocks = <0x03 0x29 0x03 0x70 0x03 0x71 0x03 0x71 0x03 0x11e 0x03 0x11d 0x03 0x30 0x03 0x32 0x03 0x3f 0x03 0x67 0x03 0x6b 0x03 0x5d 0x03 0x02 0x03 0x38 0x03 0x15>; + clock-names = "dram_pll\0dram_alt_src\0dram_apb_src\0dram_apb_pre_div\0dram_core\0dram_alt_root\0sys_pll1_40m\0sys_pll1_100m\0sys_pll2_333m\0noc_div\0ahb_div\0main_axi_src\0osc_24m\0sys_pll1_800m\0dram_pll_div"; + status = "disabled"; + }; + + psci { + compatible = "arm,psci-1.0"; + method = "smc"; + }; + + power-domains { + compatible = "simple-bus"; + + hsiomix-pd { + compatible = "fsl,imx8m-pm-domain"; + active-wakeup; + rpm-always-on; + #power-domain-cells = <0x00>; + domain-index = <0x00>; + domain-name = "hsiomix"; + phandle = <0x0c>; + }; + + pcie-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x01>; + domain-name = "pcie"; + parent-domains = <0x0c>; + phandle = <0x78>; + }; + + usbotg1-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x02>; + domain-name = "usb_otg1"; + parent-domains = <0x0c>; + }; + + usbotg2-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x03>; + domain-name = "usb_otg2"; + parent-domains = <0x0c>; + }; + + mlmix-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x04>; + domain-name = "mlmix"; + clocks = <0x03 0x69 0x03 0x6a 0x03 0x10b>; + phandle = <0x86>; + }; + + audiomix-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x05>; + domain-name = "audiomix"; + clocks = <0x03 0x11c 0x03 0x5a>; + phandle = <0x56>; + }; + + gpumix-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x06>; + domain-name = "gpumix"; + clocks = <0x03 0x107 0x03 0x66 0x03 0x65>; + phandle = <0x0d>; + }; + + gpu2d-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x07>; + domain-name = "gpu2d"; + parent-domains = <0x0d>; + clocks = <0x03 0xf7>; + phandle = <0x7e>; + }; + + gpu3d-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x08>; + domain-name = "gpu3d"; + parent-domains = <0x0d>; + clocks = <0x03 0xf8 0x03 0x58>; + phandle = <0x7d>; + }; + + vpumix-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x09>; + domain-name = "vpumix"; + clocks = <0x03 0x11a>; + phandle = <0x0e>; + }; + + vpug1-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x0a>; + domain-name = "vpu_g1"; + parent-domains = <0x0e>; + clocks = <0x03 0x106>; + phandle = <0x83>; + }; + + vpug2-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x0b>; + domain-name = "vpu_g2"; + parent-domains = <0x0e>; + clocks = <0x03 0x10a>; + phandle = <0x84>; + }; + + vpuh1-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x0c>; + domain-name = "vpu_h1"; + parent-domains = <0x0e>; + clocks = <0x03 0x109>; + phandle = <0x85>; + }; + + mediamix-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x0d>; + domain-name = "mediamix"; + rpm-always-on; + clocks = <0x03 0x10e 0x03 0x10d>; + phandle = <0x0f>; + }; + + // power-domain@14 { + // compatible = "fsl,imx8m-pm-domain"; + // #power-domain-cells = <0x00>; + // domain-index = <0x0e>; + // domain-name = "ispdwp"; + // parent-domains = <0x0f>; + // clocks = <0x03 0x5c>; + // phandle = <0x71>; + // }; + + mipiphy1-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + rpm-always-on; + domain-index = <0x0f>; + domain-name = "mipi_phy1"; + parent-domains = <0x0f>; + phandle = <0x5a>; + }; + + mipiphy2-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x10>; + domain-name = "mipi_phy2"; + parent-domains = <0x0f>; + phandle = <0x75>; + }; + + // hdmimix-pd { + // compatible = "fsl,imx8m-pm-domain"; + // #power-domain-cells = <0x00>; + // domain-index = <0x11>; + // domain-name = "hdmimix"; + // clocks = <0x03 0x116 0x03 0x63 0x03 0xa8>; + // phandle = <0x10>; + // }; + + // hdmiphy-pd { + // compatible = "fsl,imx8m-pm-domain"; + // #power-domain-cells = <0x00>; + // domain-index = <0x12>; + // domain-name = "hdmi_phy"; + // parent-domains = <0x10>; + // phandle = <0x6e>; + // }; + }; + + pmu { + compatible = "arm,armv8-pmuv3"; + interrupt-parent = <0x01>; + interrupts = <0x01 0x07 0x3f04>; + interrupt-affinity = <0x11 0x12 0x13 0x14>; + }; + + timer { + compatible = "arm,armv8-timer"; + interrupts = <0x01 0x0d 0x3f08 0x01 0x0e 0x3f08 0x01 0x0b 0x3f08 0x01 0x0a 0x3f08>; + clock-frequency = <0x7a1200>; + arm,no-tick-in-suspend; + interrupt-parent = <0x01>; + }; + + thermal-zones { + + cpu-thermal { + polling-delay-passive = <0xfa>; + polling-delay = <0x7d0>; + thermal-sensors = <0x15 0x00>; + + trips { + + trip0 { + temperature = <0x17318>; + hysteresis = <0x7d0>; + type = "passive"; + phandle = <0x16>; + }; + + trip1 { + temperature = <0x19a28>; + hysteresis = <0x7d0>; + type = "critical"; + }; + }; + + cooling-maps { + + map0 { + trip = <0x16>; + cooling-device = <0x11 0xffffffff 0xffffffff 0x12 0xffffffff 0xffffffff 0x13 0xffffffff 0xffffffff 0x14 0xffffffff 0xffffffff>; + }; + }; + }; + + soc-thermal { + polling-delay-passive = <0xfa>; + polling-delay = <0x7d0>; + thermal-sensors = <0x15 0x01>; + + trips { + + trip0 { + temperature = <0x17318>; + hysteresis = <0x7d0>; + type = "passive"; + }; + + trip1 { + temperature = <0x19a28>; + hysteresis = <0x7d0>; + type = "critical"; + }; + }; + }; + }; + + + soc@0 { + compatible = "simple-bus"; + #address-cells = <0x01>; + #size-cells = <0x01>; + ranges = <0x00 0x00 0x00 0x3e000000>; + + caam-sm@100000 { + compatible = "fsl,imx6q-caam-sm"; + reg = <0x100000 0x8000>; + }; + + bus@30000000 { + compatible = "simple-bus"; + reg = <0x30000000 0x400000>; + #address-cells = <0x01>; + #size-cells = <0x01>; + ranges; + + gpio@30200000 { + compatible = "fsl,imx8mp-gpio\0fsl,imx35-gpio"; + reg = <0x30200000 0x10000>; + interrupts = <0x00 0x40 0x04 0x00 0x41 0x04>; + clocks = <0x03 0xc1>; + gpio-controller; + #gpio-cells = <0x02>; + interrupt-controller; + #interrupt-cells = <0x02>; + phandle = <0x2e>; + }; + + gpio@30210000 { + compatible = "fsl,imx8mp-gpio\0fsl,imx35-gpio"; + reg = <0x30210000 0x10000>; + interrupts = <0x00 0x42 0x04 0x00 0x43 0x04>; + clocks = <0x03 0xc2>; + gpio-controller; + #gpio-cells = <0x02>; + interrupt-controller; + #interrupt-cells = <0x02>; + phandle = <0x49>; + }; + + gpio@30220000 { + compatible = "fsl,imx8mp-gpio\0fsl,imx35-gpio"; + reg = <0x30220000 0x10000>; + interrupts = <0x00 0x44 0x04 0x00 0x45 0x04>; + clocks = <0x03 0xc3>; + gpio-controller; + #gpio-cells = <0x02>; + interrupt-controller; + #interrupt-cells = <0x02>; + phandle = <0x32>; + }; + + gpio@30230000 { + compatible = "fsl,imx8mp-gpio\0fsl,imx35-gpio"; + reg = <0x30230000 0x10000>; + interrupts = <0x00 0x46 0x04 0x00 0x47 0x04>; + clocks = <0x03 0xc4>; + gpio-controller; + #gpio-cells = <0x02>; + interrupt-controller; + #interrupt-cells = <0x02>; + phandle = <0x38>; + }; + + gpio@30240000 { + compatible = "fsl,imx8mp-gpio\0fsl,imx35-gpio"; + reg = <0x30240000 0x10000>; + interrupts = <0x00 0x48 0x04 0x00 0x49 0x04>; + clocks = <0x03 0xc5>; + gpio-controller; + #gpio-cells = <0x02>; + interrupt-controller; + #interrupt-cells = <0x02>; + phandle = <0x25>; + }; + + // tmu@30260000 { + // compatible = "fsl,imx8mp-tmu"; + // reg = <0x30260000 0x10000>; + // clocks = <0x03 0x119>; + // #thermal-sensor-cells = <0x01>; + // phandle = <0x15>; + // }; + + // watchdog@30280000 { + // compatible = "fsl,imx8mp-wdt\0fsl,imx21-wdt"; + // reg = <0x30280000 0x10000>; + // interrupts = <0x00 0x4e 0x04>; + // clocks = <0x03 0x103>; + // status = "okay"; + // pinctrl-names = "default"; + // pinctrl-0 = <0x17>; + // fsl,ext-reset-output; + // }; + + pinctrl@30330000 { + compatible = "fsl,imx8mp-iomuxc"; + reg = <0x30330000 0x10000>; + pinctrl-names = "default"; + pinctrl-0 = <0x18>; + + hoggrp { + fsl,pins = <0x240 0x4a0 0x00 0x00 0x00 0x400001c3 0x244 0x4a4 0x00 0x00 0x00 0x400001c3 0x24c 0x4ac 0x00 0x00 0x00 0x40000019 0x248 0x4a8 0x00 0x00 0x00 0x40000019>; + phandle = <0x18>; + }; + + pwm1grp { + fsl,pins = <0x18 0x278 0x00 0x01 0x00 0x116>; + phandle = <0x20>; + }; + + pwm2grp { + fsl,pins = <0x40 0x2a0 0x00 0x02 0x00 0x116>; + phandle = <0x21>; + }; + + ecspi2grp { + fsl,pins = <0x1f0 0x450 0x568 0x00 0x01 0x82 0x1f4 0x454 0x570 0x00 0x01 0x82 0x1f8 0x458 0x56c 0x00 0x01 0x82>; + phandle = <0x23>; + }; + + ecspi2cs { + fsl,pins = <0x1fc 0x45c 0x00 0x05 0x00 0x40000>; + phandle = <0x24>; + }; + + eqosgrp { + fsl,pins = <0x54 0x2b4 0x00 0x00 0x00 0x03 0x58 0x2b8 0x590 0x00 0x01 0x03 0x7c 0x2dc 0x00 0x00 0x00 0x91 0x80 0x2e0 0x00 0x00 0x00 0x91 0x84 0x2e4 0x00 0x00 0x00 0x91 0x88 0x2e8 0x00 0x00 0x00 0x91 0x78 0x2d8 0x00 0x00 0x00 0x91 0x74 0x2d4 0x00 0x00 0x00 0x91 0x68 0x2c8 0x00 0x00 0x00 0x1f 0x64 0x2c4 0x00 0x00 0x00 0x1f 0x60 0x2c0 0x00 0x00 0x00 0x1f 0x5c 0x2bc 0x00 0x00 0x00 0x1f 0x6c 0x2cc 0x00 0x00 0x00 0x1f 0x70 0x2d0 0x00 0x00 0x00 0x1f 0x1dc 0x43c 0x00 0x05 0x00 0x19>; + phandle = <0x53>; + }; + + fecgrp { + fsl,pins = <0x158 0x3b8 0x00 0x04 0x00 0x03 0x15c 0x3bc 0x57c 0x04 0x01 0x03 0x160 0x3c0 0x580 0x04 0x01 0x91 0x164 0x3c4 0x584 0x04 0x01 0x91 0x168 0x3c8 0x00 0x04 0x00 0x91 0x16c 0x3cc 0x00 0x04 0x00 0x91 0x174 0x3d4 0x00 0x04 0x00 0x91 0x170 0x3d0 0x588 0x04 0x01 0x91 0x178 0x3d8 0x00 0x04 0x00 0x1f 0x17c 0x3dc 0x00 0x04 0x00 0x1f 0x180 0x3e0 0x00 0x04 0x00 0x1f 0x184 0x3e4 0x00 0x04 0x00 0x1f 0x188 0x3e8 0x00 0x04 0x00 0x1f 0x18c 0x3ec 0x00 0x04 0x00 0x1f 0x1d8 0x438 0x00 0x05 0x00 0x19>; + phandle = <0x50>; + }; + + flexcan1grp { + fsl,pins = <0x1ac 0x40c 0x54c 0x03 0x01 0x154 0x1a0 0x400 0x00 0x03 0x00 0x154>; + phandle = <0x2a>; + }; + + flexcan2grp { + fsl,pins = <0x1b4 0x414 0x550 0x03 0x01 0x154 0x1b0 0x410 0x00 0x03 0x00 0x154>; + phandle = <0x2b>; + }; + + flexspi0grp { + fsl,pins = <0xe0 0x340 0x00 0x01 0x00 0x1c2 0xe4 0x344 0x00 0x01 0x00 0x82 0xf8 0x358 0x00 0x01 0x00 0x82 0xfc 0x35c 0x00 0x01 0x00 0x82 0x100 0x360 0x00 0x01 0x00 0x82 0x104 0x364 0x00 0x01 0x00 0x82>; + phandle = <0x4e>; + }; + + gpioledgrp { + fsl,pins = <0x1e8 0x448 0x00 0x05 0x00 0x19 0x1ec 0x44c 0x00 0x05 0x00 0x19>; + phandle = <0x9d>; + }; + + gpiokeygrp { + fsl,pins = <0x1a8 0x408 0x00 0x05 0x00 0x159 0x190 0x3f0 0x00 0x05 0x00 0x159>; + phandle = <0x9e>; + }; + + i2c1grp { + fsl,pins = <0x200 0x460 0x5a4 0x00 0x02 0x400001c3 0x204 0x464 0x5a8 0x00 0x02 0x400001c3>; + phandle = <0x2c>; + }; + + i2c2grp { + fsl,pins = <0x208 0x468 0x5ac 0x00 0x02 0x400001c3 0x20c 0x46c 0x5b0 0x00 0x02 0x400001c3>; + phandle = <0x2f>; + }; + + i2c3grp { + fsl,pins = <0x210 0x470 0x5b4 0x00 0x04 0x400001c3 0x214 0x474 0x5b8 0x00 0x04 0x400001c3>; + phandle = <0x35>; + }; + + i2c4grp { + fsl,pins = <0x218 0x478 0x5bc 0x00 0x05 0x400001c3 0x21c 0x47c 0x5c0 0x00 0x05 0x400001c3>; + phandle = <0x3e>; + }; + + mipi_dsi_en { + fsl,pins = <0x30 0x290 0x00 0x00 0x00 0x16>; + phandle = <0x5d>; + }; + + lvds_panel_en { + fsl,pins = <0x48 0x2a8 0x00 0x00 0x00 0x16>; + phandle = <0xae>; + }; + + pciegrp { + fsl,pins = <0x34 0x294 0x00 0x00 0x00 0x41>; + phandle = <0x7c>; + }; + + pmicirq { + fsl,pins = <0x20 0x280 0x00 0x00 0x00 0x41>; + phandle = <0x2d>; + }; + + typec1grp { + fsl,pins = <0x194 0x3f4 0x00 0x05 0x00 0x1c4>; + phandle = <0x36>; + }; + + typec1muxgrp { + fsl,pins = <0x198 0x3f8 0x00 0x05 0x00 0x16>; + phandle = <0xa0>; + }; + + sai5grp { + fsl,pins = <0x138 0x398 0x510 0x03 0x00 0xd6 0x140 0x3a0 0x00 0x03 0x00 0xd6 0x144 0x3a4 0x4f0 0x00 0x00 0xd6 0x134 0x394 0x4f8 0x00 0x00 0xd6>; + phandle = <0x58>; + }; + + sai3grp { + fsl,pins = <0x1c4 0x424 0x4ec 0x00 0x01 0xd6 0x1c8 0x428 0x4e8 0x00 0x01 0xd6 0x1c0 0x420 0x4e4 0x00 0x01 0xd6 0x1cc 0x42c 0x00 0x00 0x00 0xd6 0x1d0 0x430 0x4e0 0x00 0x02 0xd6 0x1b8 0x418 0x00 0x05 0x00 0xd6 0x1bc 0x41c 0x00 0x05 0x00 0xd6>; + phandle = <0x57>; + }; + + ft5x16_int_iogrp { + fsl,pins = <0x44 0x2a4 0x00 0x00 0x00 0x16>; + phandle = <0x3f>; + }; + + gt928_int_iogrp { + fsl,pins = <0x14 0x274 0x00 0x00 0x00 0x16 0x3c 0x29c 0x00 0x00 0x00 0x16>; + phandle = <0x3d>; + }; + + uart1grp { + fsl,pins = <0x220 0x480 0x5e8 0x00 0x04 0x140 0x224 0x484 0x00 0x00 0x00 0x140 0x230 0x490 0x00 0x01 0x00 0x140 0x234 0x494 0x5e4 0x01 0x05 0x140>; + phandle = <0x26>; + }; + + uart2grp { + fsl,pins = <0x228 0x488 0x5f0 0x00 0x06 0x49 0x22c 0x48c 0x00 0x00 0x00 0x49>; + phandle = <0x28>; + }; + + uart3grp { + fsl,pins = <0x1e0 0x440 0x5f8 0x01 0x04 0x140 0x1e4 0x444 0x00 0x01 0x00 0x140>; + phandle = <0x27>; + }; + + uart4grp { + fsl,pins = <0x238 0x498 0x600 0x00 0x08 0x49 0x23c 0x49c 0x00 0x00 0x00 0x49>; + phandle = <0x29>; + }; + + usb1grp { + fsl,pins = <0x4c 0x2ac 0x00 0x00 0x00 0x19>; + phandle = <0x9f>; + }; + + usdhc1grp { + fsl,pins = <0x8c 0x2ec 0x00 0x00 0x00 0x190 0x90 0x2f0 0x00 0x00 0x00 0x1d0 0x94 0x2f4 0x00 0x00 0x00 0x1d0 0x98 0x2f8 0x00 0x00 0x00 0x1d0 0x9c 0x2fc 0x00 0x00 0x00 0x1d0 0xa0 0x300 0x00 0x00 0x00 0x1d0>; + phandle = <0x40>; + }; + + usdhc1grp-100mhz { + fsl,pins = <0x8c 0x2ec 0x00 0x00 0x00 0x194 0x90 0x2f0 0x00 0x00 0x00 0x1d4 0x94 0x2f4 0x00 0x00 0x00 0x1d4 0x98 0x2f8 0x00 0x00 0x00 0x1d4 0x9c 0x2fc 0x00 0x00 0x00 0x1d4 0xa0 0x300 0x00 0x00 0x00 0x1d4>; + phandle = <0x42>; + }; + + usdhc1grp-200mhz { + fsl,pins = <0x8c 0x2ec 0x00 0x00 0x00 0x196 0x90 0x2f0 0x00 0x00 0x00 0x1d6 0x94 0x2f4 0x00 0x00 0x00 0x1d6 0x98 0x2f8 0x00 0x00 0x00 0x1d6 0x9c 0x2fc 0x00 0x00 0x00 0x1d6 0xa0 0x300 0x00 0x00 0x00 0x1d6>; + phandle = <0x43>; + }; + + usdhc1grp-gpio { + fsl,pins = <0xac 0x30c 0x00 0x05 0x00 0x41>; + phandle = <0x41>; + }; + + usdhc2grp-gpio { + fsl,pins = <0xbc 0x31c 0x00 0x05 0x00 0x1c4 0xd8 0x338 0x00 0x05 0x00 0x41>; + phandle = <0x46>; + }; + + usdhc2grp { + fsl,pins = <0xc0 0x320 0x00 0x00 0x00 0x190 0xc4 0x324 0x00 0x00 0x00 0x1d0 0xc8 0x328 0x00 0x00 0x00 0x1d0 0xcc 0x32c 0x00 0x00 0x00 0x1d0 0xd0 0x330 0x00 0x00 0x00 0x1d0 0xd4 0x334 0x00 0x00 0x00 0x1d0 0x24 0x284 0x00 0x01 0x00 0xc1>; + phandle = <0x45>; + }; + + usdhc2grp-100mhz { + fsl,pins = <0xc0 0x320 0x00 0x00 0x00 0x194 0xc4 0x324 0x00 0x00 0x00 0x1d4 0xc8 0x328 0x00 0x00 0x00 0x1d4 0xcc 0x32c 0x00 0x00 0x00 0x1d4 0xd0 0x330 0x00 0x00 0x00 0x1d4 0xd4 0x334 0x00 0x00 0x00 0x1d4 0x24 0x284 0x00 0x01 0x00 0xc1>; + phandle = <0x47>; + }; + + usdhc2grp-200mhz { + fsl,pins = <0xc0 0x320 0x00 0x00 0x00 0x196 0xc4 0x324 0x00 0x00 0x00 0x1d6 0xc8 0x328 0x00 0x00 0x00 0x1d6 0xcc 0x32c 0x00 0x00 0x00 0x1d6 0xd0 0x330 0x00 0x00 0x00 0x1d6 0xd4 0x334 0x00 0x00 0x00 0x1d6 0x24 0x284 0x00 0x01 0x00 0xc1>; + phandle = <0x48>; + }; + + usdhc3grp { + fsl,pins = <0x124 0x384 0x604 0x02 0x01 0x190 0x128 0x388 0x60c 0x02 0x01 0x1d0 0x108 0x368 0x610 0x02 0x01 0x1d0 0x10c 0x36c 0x614 0x02 0x01 0x1d0 0x110 0x370 0x618 0x02 0x01 0x1d0 0x114 0x374 0x61c 0x02 0x01 0x1d0 0x11c 0x37c 0x620 0x02 0x01 0x1d0 0xec 0x34c 0x624 0x02 0x01 0x1d0 0xf0 0x350 0x628 0x02 0x01 0x1d0 0xf4 0x354 0x62c 0x02 0x01 0x1d0 0xe8 0x348 0x630 0x02 0x01 0x190>; + phandle = <0x4b>; + }; + + usdhc3grp-100mhz { + fsl,pins = <0x124 0x384 0x604 0x02 0x01 0x194 0x128 0x388 0x60c 0x02 0x01 0x1d4 0x108 0x368 0x610 0x02 0x01 0x1d4 0x10c 0x36c 0x614 0x02 0x01 0x1d4 0x110 0x370 0x618 0x02 0x01 0x1d4 0x114 0x374 0x61c 0x02 0x01 0x1d4 0x11c 0x37c 0x620 0x02 0x01 0x1d4 0xec 0x34c 0x624 0x02 0x01 0x1d4 0xf0 0x350 0x628 0x02 0x01 0x1d4 0xf4 0x354 0x62c 0x02 0x01 0x1d4 0xe8 0x348 0x630 0x02 0x01 0x194>; + phandle = <0x4c>; + }; + + usdhc3grp-200mhz { + fsl,pins = <0x124 0x384 0x604 0x02 0x01 0x196 0x128 0x388 0x60c 0x02 0x01 0x1d6 0x108 0x368 0x610 0x02 0x01 0x1d6 0x10c 0x36c 0x614 0x02 0x01 0x1d6 0x110 0x370 0x618 0x02 0x01 0x1d6 0x114 0x374 0x61c 0x02 0x01 0x1d6 0x11c 0x37c 0x620 0x02 0x01 0x1d6 0xec 0x34c 0x624 0x02 0x01 0x1d6 0xf0 0x350 0x628 0x02 0x01 0x1d6 0xf4 0x354 0x62c 0x02 0x01 0x1d6 0xe8 0x348 0x630 0x02 0x01 0x196>; + phandle = <0x4d>; + }; + + wdoggrp { + fsl,pins = <0x1c 0x27c 0x00 0x01 0x00 0xc6>; + phandle = <0x17>; + }; + + csi0_pwn_grp { + fsl,pins = <0x130 0x390 0x00 0x05 0x00 0x19>; + phandle = <0x30>; + }; + + csi0_rst_grp { + fsl,pins = <0x12c 0x38c 0x00 0x05 0x00 0x19>; + phandle = <0x31>; + }; + + csi_mclk_grp { + fsl,pins = <0x50 0x2b0 0x00 0x06 0x00 0x59>; + }; + }; + + // iomuxc-gpr@30340000 { + // compatible = "fsl,imx8mp-iomuxc-gpr\0fsl,imx7d-iomuxc-gpr\0fsl,imx6q-iomuxc-gpr\0syscon"; + // reg = <0x30340000 0x10000>; + // phandle = <0x29>; + // }; + + ocotp-ctrl@30350000 { + compatible = "fsl,imx8mp-ocotp\0fsl,imx8mm-ocotp\0syscon"; + reg = <0x30350000 0x10000>; + clocks = <0x03 0xd6>; + #address-cells = <0x01>; + #size-cells = <0x01>; + + speed-grade@10 { + reg = <0x10 0x04>; + phandle = <0x05>; + }; + + mac-address@640 { + reg = <0x90 0x06>; + phandle = <0x4f>; + }; + + mac-address@650 { + reg = <0x96 0x06>; + phandle = <0x52>; + }; + }; + + anatop@30360000 { + compatible = "fsl,imx8mp-anatop\0fsl,imx8mm-anatop\0syscon"; + reg = <0x30360000 0x10000>; + }; + + caam_secvio { + compatible = "fsl,imx6q-caam-secvio"; + interrupts = <0x00 0x14 0x04>; + jtag-tamper = "disabled"; + watchdog-tamper = "enabled"; + internal-boot-tamper = "enabled"; + external-pin-tamper = "disabled"; + }; + + caam-snvs@30370000 { + compatible = "fsl,imx6q-caam-snvs"; + reg = <0x30370000 0x10000>; + clocks = <0x03 0xf9>; + clock-names = "ipg"; + }; + + snvs@30370000 { + compatible = "fsl,sec-v4.0-mon\0syscon\0simple-mfd"; + reg = <0x30370000 0x10000>; + phandle = <0x19>; + + snvs-rtc-lp { + compatible = "fsl,sec-v4.0-mon-rtc-lp"; + regmap = <0x19>; + offset = <0x34>; + interrupts = <0x00 0x13 0x04 0x00 0x14 0x04>; + clocks = <0x03 0xf9>; + clock-names = "snvs-rtc"; + }; + + snvs-powerkey { + compatible = "fsl,sec-v4.0-pwrkey"; + regmap = <0x19>; + interrupts = <0x00 0x04 0x04>; + clocks = <0x03 0xf9>; + clock-names = "snvs"; + linux,keycode = <0x74>; + wakeup-source; + }; + }; + + clock-controller@30380000 { + compatible = "fsl,imx8mp-ccm"; + reg = <0x30380000 0x10000>; + #clock-cells = <0x01>; + clocks = <0x1a 0x1b 0x1c 0x1d 0x1e 0x1f>; + clock-names = "osc_32k\0osc_24m\0clk_ext1\0clk_ext2\0clk_ext3\0clk_ext4"; + assigned-clocks = <0x03 0x67 0x03 0x68 0x03 0x94 0x03 0x6c 0x03 0x48 0x03 0x6f 0x03 0x12 0x03 0x13 0x03 0x14>; + assigned-clock-parents = <0x03 0x41 0x03 0x38 0x03 0x40 0x03 0x38 0x03 0x38>; + assigned-clock-rates = <0x3b9aca00 0x2faf0800 0x1dcd6500 0x17d78400 0x2faf0800 0x17d78400 0x17700000 0x15888000 0x3df582e0>; + init-on-array = <0x115 0x5f 0x10c 0xfe 0xd6 0xed 0xe1 0x82 0x81 0xf8 0x58 0x65 + 0x66 0x116 0x63 0xa8 0x21 0x6f 0x6c 0x11c 0x111 0x10e 0x10d 0x112 0x06 0x64 0x01 + 0x03 0x05 0x09 0x0a 0x0b 0x0c 0x0d 0x07>; + phandle = <0x03>; + }; + + // src@30390000 { + // compatible = "fsl,imx8mp-src\0fsl,imx8mq-src\0syscon"; + // reg = <0x30390000 0x10000>; + // interrupts = <0x00 0x59 0x04>; + // #reset-cells = <0x01>; + // phandle = <0x79>; + // }; + }; + + bus@30800000 { + compatible = "simple-bus"; + reg = <0x30800000 0x400000>; + #address-cells = <0x01>; + #size-cells = <0x01>; + ranges; + + i2c@30a20000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "fsl,imx8mp-i2c\0fsl,imx21-i2c"; + reg = <0x30a20000 0x10000>; + interrupts = <0x00 0x23 0x04>; + clocks = <0x03 0xcd>; + status = "okay"; + clock-frequency = <0x186a0>; + pinctrl-names = "default"; + pinctrl-0 = <0x2d>; + + pca9450@25 { + reg = <0x25>; + compatible = "nxp,pca9450"; + pinctrl-0 = <0x2e>; + gpio_intr = <0x2f 0x03 0x01>; + + regulators { + #address-cells = <0x01>; + #size-cells = <0x00>; + pca9450,pmic-buck2-uses-i2c-dvs; + pca9450,pmic-buck2-dvs-voltage = <0xe7ef0 0xcf850>; + + regulator@0 { + reg = <0x00>; + regulator-compatible = "buck1"; + regulator-min-microvolt = <0x927c0>; + regulator-max-microvolt = <0x2160ec>; + regulator-boot-on; + regulator-always-on; + regulator-ramp-delay = <0xc35>; + }; + + regulator@1 { + reg = <0x01>; + regulator-compatible = "buck2"; + regulator-min-microvolt = <0x927c0>; + regulator-max-microvolt = <0x2160ec>; + regulator-boot-on; + regulator-always-on; + regulator-ramp-delay = <0xc35>; + phandle = <0x07>; + }; + + regulator@3 { + reg = <0x03>; + regulator-compatible = "buck4"; + regulator-min-microvolt = <0x927c0>; + regulator-max-microvolt = <0x33e140>; + regulator-boot-on; + regulator-always-on; + }; + + regulator@4 { + reg = <0x04>; + regulator-compatible = "buck5"; + regulator-min-microvolt = <0x927c0>; + regulator-max-microvolt = <0x33e140>; + regulator-boot-on; + regulator-always-on; + }; + + regulator@5 { + reg = <0x05>; + regulator-compatible = "buck6"; + regulator-min-microvolt = <0x927c0>; + regulator-max-microvolt = <0x33e140>; + regulator-boot-on; + regulator-always-on; + }; + + regulator@6 { + reg = <0x06>; + regulator-compatible = "ldo1"; + regulator-min-microvolt = <0x186a00>; + regulator-max-microvolt = <0x325aa0>; + regulator-boot-on; + regulator-always-on; + }; + + regulator@7 { + reg = <0x07>; + regulator-compatible = "ldo2"; + regulator-min-microvolt = "\0\f5"; + regulator-max-microvolt = <0x118c30>; + regulator-boot-on; + regulator-always-on; + }; + + regulator@8 { + reg = <0x08>; + regulator-compatible = "ldo3"; + regulator-min-microvolt = "\0\f5"; + regulator-max-microvolt = <0x325aa0>; + regulator-boot-on; + regulator-always-on; + }; + + regulator@9 { + reg = <0x09>; + regulator-compatible = "ldo4"; + regulator-min-microvolt = "\0\f5"; + regulator-max-microvolt = <0x325aa0>; + regulator-boot-on; + regulator-always-on; + }; + + regulator@10 { + reg = <0x0a>; + regulator-compatible = "ldo5"; + regulator-min-microvolt = <0x1b7740>; + regulator-max-microvolt = <0x325aa0>; + }; + }; + }; + }; + + // i2c@30a40000 { + // #address-cells = <0x01>; + // #size-cells = <0x00>; + // compatible = "fsl,imx8mp-i2c\0fsl,imx21-i2c"; + // reg = <0x30a40000 0x10000>; + // interrupts = <0x00 0x25 0x04>; + // clocks = <0x03 0xcf>; + // status = "okay"; + // clock-frequency = <0x186a0>; + // pinctrl-names = "default"; + // pinctrl-0 = <0x35>; + + // typec-portc@22 { + // compatible = "fcs,fusb302"; + // reg = <0x22>; + // pinctrl-names = "default"; + // pinctrl-0 = <0x36>; + // vbus-supply = <0x37>; + // interrupt-parent = <0x38>; + // interrupts = <0x13 0x08>; + // status = "okay"; + // phandle = <0x7f>; + + // port { + + // endpoint { + // remote-endpoint = <0x39>; + // phandle = <0x81>; + // }; + // }; + + // connector { + // compatible = "usb-c-connector"; + // label = "USB-C"; + // power-role = "dual"; + // data-role = "dual"; + // try-power-role = "sink"; + // source-pdos = <0x4019096>; + // sink-pdos = <0x4019096>; + // op-sink-microwatt = <0x7270e0>; + + // ports { + // #address-cells = <0x01>; + // #size-cells = <0x00>; + + // port@1 { + // reg = <0x01>; + + // endpoint { + // remote-endpoint = <0x3a>; + // phandle = <0xa1>; + // }; + // }; + // }; + // }; + // }; + + // wm8960@1a { + // compatible = "wlf,wm8960"; + // reg = <0x1a>; + // clocks = <0x3b 0x09>; + // clock-names = "mclk"; + // wlf,shared-lrclk; + // SPKVDD1-supply = <0x3c>; + // status = "disabled"; + // phandle = <0xa7>; + // }; + + // nau8822@1a { + // compatible = "nuvoton,nau8822"; + // reg = <0x1a>; + // clocks = <0x3b 0x09>; + // clock-names = "mclk"; + // wlf,shared-lrclk; + // SPKVDD1-supply = <0x3c>; + // phandle = <0xa9>; + // }; + + // pcf8563@51 { + // compatible = "nxp,pcf8563"; + // reg = <0x51>; + // #clock-cells = <0x00>; + // clock-output-names = "pcf8563-clkout"; + // }; + + // rx8010@32 { + // compatible = "epson,rx8010"; + // reg = <0x32>; + // status = "okay"; + // }; + // }; + + //mmc@30b40000 { + // compatible = "fsl,imx8mm-usdhc\0fsl,imx7d-usdhc"; + // reg = <0x30b40000 0x10000>; + // interrupts = <0x00 0x16 0x04>; + // clocks = <0x03 0x00 0x03 0x5f 0x03 0x101>; + // clock-names = "ipg\0ahb\0per"; + // assigned-clocks = <0x03 0x88>; + // assigned-clock-rates = <0x17d78400>; + // fsl,tuning-start-tap = <0x14>; + // fsl,tuning-step = <0x02>; + // bus-width = <0x04>; + // status = "okay"; + // pinctrl-names = "default\0state_100mhz\0state_200mhz"; + // pinctrl-0 = <0x40 0x41>; + // pinctrl-1 = <0x42 0x41>; + // pinctrl-2 = <0x43 0x41>; + // non-removable; + // pm-ignore-notify; + // keep-power-in-suspend; + // mmc-pwrseq = <0x44>; + //}; + + mmc@30b50000 { + compatible = "fsl,imx8mm-usdhc\0fsl,imx7d-usdhc"; + reg = <0x30b50000 0x10000>; + interrupts = <0x00 0x17 0x04>; + clocks = <0x03 0x00 0x03 0x5f 0x03 0x102>; + clock-names = "ipg\0ahb\0per"; + assigned-clocks = <0x03 0x89>; + assigned-clock-rates = <0x17d78400>; + fsl,tuning-start-tap = <0x14>; + fsl,tuning-step = <0x02>; + bus-width = <0x04>; + status = "okay"; + pinctrl-names = "default\0state_100mhz\0state_200mhz"; + pinctrl-0 = <0x4b 0x45 0x46>; + pinctrl-1 = <0x4b 0x47 0x46>; + pinctrl-2 = <0x4b 0x48 0x46>; + cd-gpios = <0x49 0x0c 0x01>; + vmmc-supply = <0x4a>; + }; + + mmc@30b60000 { + compatible = "fsl,imx8mm-usdhc\0fsl,imx7d-usdhc"; + reg = <0x30b60000 0x10000>; + interrupts = <0x00 0x18 0x04>; + clocks = <0x03 0x00 0x03 0x5f 0x03 0x115>; + clock-names = "ipg\0ahb\0per"; + assigned-clocks = <0x03 0xa9>; + assigned-clock-rates = <0x17d78400>; + fsl,tuning-start-tap = <0x14>; + fsl,tuning-step = <0x02>; + bus-width = <0x08>; + status = "disabled"; + pinctrl-names = "default\0state_100mhz\0state_200mhz"; + pinctrl-0 = <0x4b>; + pinctrl-1 = <0x4c>; + pinctrl-2 = <0x4d>; + non-removable; + }; + + serial@30a60000 { + compatible = "fsl,imx8mp-uart\0fsl,imx6q-uart"; + reg = <0x30a60000 0x10000>; + interrupts = <0x00 0x1d 0x04>; + clocks = <0x03 0xfe 0x03 0xfe>; + clock-names = "ipg\0per"; + // dmas = <0x22 0x1c 0x04 0x00 0x22 0x1d 0x04 0x00>; + // dma-names = "rx\0tx"; + status = "disabled"; + pinctrl-names = "default"; + pinctrl-0 = <0x29>; + }; + + serial@30890000 { + compatible = "fsl,imx8mp-uart\0fsl,imx6q-uart"; + reg = <0x30890000 0x10000>; + interrupts = <0x00 0x1b 0x04>; + clocks = <0x03 0xfc 0x03 0xfc>; + clock-names = "ipg\0per"; + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <0x28 0x29>; + assigned-clocks = <0x03 0x91>; + assigned-clock-parents = <0x03 0x02>; + //clock-frequency = <408000000>; + }; + + ethernet@30be0000 { + compatible = "fsl,imx8mm-fec\0fsl,imx8mq-fec\0fsl,imx6sx-fec"; + reg = <0x30be0000 0x10000>; + interrupts = <0x00 0x76 0x04 0x00 0x77 0x04 0x00 0x78 0x04>; + clocks = <0x03 0xc0 0x03 0xf2 0x03 0x84 0x03 0x83 0x03 0x85>; + clock-names = "ipg\0ahb\0ptp\0enet_clk_ref\0enet_out"; + assigned-clocks = <0x03 0x5e 0x03 0x84 0x03 0x83 0x03 0x84 0x03 0x82 0x03 0x81>; + assigned-clock-parents = <0x03 0x36 0x03 0x3a 0x03 0x3b 0x03 0x3a 0x03 0x3a 0x03 0x3b>; + assigned-clock-rates = <0x00 0x00 0x7735940 0x5f5e100 0x5f5e100 0x7735940> ; + fsl,num-tx-queues = <0x03>; + fsl,num-rx-queues = <0x03>; + nvmem-cells = <0x4f>; + nvmem-cell-names = "mac-address"; + nvmem_macaddr_swap; + stop-mode = <0x29 0x10 0x03>; + fsl,wakeup_irq = <0x02>; + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <0x53 0x50>; + reset-gpio = <0x25 0x04 0x01>; + phy-mode = "rgmii-id"; + phy-handle = <0x51>; + fsl,magic-packet; + + mdio { + #address-cells = <0x01>; + #size-cells = <0x00>; + + ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x01>; + eee-broken-1000t; + at803x,vddio-1p8v; + phandle = <0x51>; + }; + }; + }; + + // ethernet@30bf0000 { + // compatible = "nxp,imx8mp-dwmac-eqos\0snps,dwmac-5.10a"; + // reg = <0x30bf0000 0x10000>; + // interrupts = <0x00 0x86 0x04 0x00 0x87 0x04>; + // interrupt-names = "eth_wake_irq\0macirq"; + // clocks = <0x03 0xed 0x03 0xe1 0x03 0x82 0x03 0x81>; + // clock-names = "stmmaceth\0pclk\0ptp_ref\0tx"; + // assigned-clocks = <0x03 0x5e 0x03 0x82 0x03 0x81>; + // assigned-clock-parents = <0x03 0x36 0x03 0x3a 0x03 0x3b>; + // assigned-clock-rates = <0x00 0x5f5e100 0x7735940>; + // nvmem-cells = <0x52>; + // nvmem-cell-names = "mac-address"; + // nvmem_macaddr_swap; + // intf_mode = <0x29 0x04>; + // status = "okay"; + // pinctrl-names = "default"; + // pinctrl-0 = <0x53>; + // reset-gpio = <0x25 0x05 0x01>; + // phy-mode = "rgmii-id"; + // phy-handle = <0x54>; + + // mdio { + // compatible = "snps,dwmac-mdio"; + // #address-cells = <0x01>; + // #size-cells = <0x00>; + + // ethernet-phy@1 { + // compatible = "ethernet-phy-ieee802.3-c22"; + // reg = <0x01>; + // eee-broken-1000t; + // at803x,vddio-1p8v; + // at803x,hibernate-disable; + // phandle = <0x54>; + // }; + // }; + // }; + }; + }; + + usdhc1_pwrseq { + compatible = "mmc-pwrseq-simple"; + reset-gpios = <0x49 0x08 0x01>; + phandle = <0x44>; + }; + + regulator-usdhc2 { + compatible = "regulator-fixed"; + regulator-name = "VSD_3V3"; + regulator-min-microvolt = <0x325aa0>; + regulator-max-microvolt = <0x325aa0>; + gpio = <0x49 0x13 0x00>; + enable-active-high; + startup-delay-us = <0x64>; + off-on-delay-us = <0x2ee0>; + phandle = <0x4a>; + }; + + // mix_gpu_ml { + // compatible = "fsl,imx8mp-gpu\0fsl,imx8-gpu-ss"; + // cores = <0x8c 0x8d 0x8e>; + // reg = <0x00 0x80000000 0x00 0xc0000000 0x00 0x00 0x00 0x10000000>; + // reg-names = "phys_baseaddr\0contiguous_mem"; + // status = "okay"; + // }; + + // gpu3d@38000000 { + // compatible = "fsl,imx8-gpu"; + // reg = <0x00 0x38000000 0x00 0x8000>; + // interrupts = <0x00 0x03 0x04>; + // clocks = <0x03 0xf8 0x03 0x58 0x03 0x65 0x03 0x66>; + // clock-names = "core\0shader\0axi\0ahb"; + // assigned-clocks = <0x03 0x45 0x03 0x46 0x03 0x65 0x03 0x66>; + // assigned-clock-parents = <0x03 0x41 0x03 0x41 0x03 0x38 0x03 0x38>; + // assigned-clock-rates = <0x3b9aca00 0x3b9aca00 0x2faf0800 0x17d78400>; + // power-domains = <0x7d>; + // status = "okay"; + // phandle = <0x8c>; + // }; + + // gpu2d@38008000 { + // compatible = "fsl,imx8-gpu"; + // reg = <0x00 0x38008000 0x00 0x8000>; + // interrupts = <0x00 0x19 0x04>; + // clocks = <0x03 0xf7 0x03 0x65 0x03 0x66>; + // clock-names = "core\0axi\0ahb"; + // assigned-clocks = <0x03 0x47 0x03 0x65 0x03 0x66>; + // assigned-clock-parents = <0x03 0x41 0x03 0x38 0x03 0x38>; + // assigned-clock-rates = <0x3b9aca00 0x2faf0800 0x17d78400>; + // power-domains = <0x7e>; + // status = "okay"; + // phandle = <0x8e>; + // }; + + // vipsi@38500000 { + // compatible = "fsl,imx8-gpu\0fsl,imx8-vipsi"; + // reg = <0x00 0x38500000 0x00 0x20000>; + // interrupts = <0x00 0x0d 0x04>; + // clocks = <0x03 0x10b 0x03 0x10b 0x03 0x69 0x03 0x6a>; + // clock-names = "core\0shader\0axi\0ahb"; + // assigned-clocks = <0x03 0x44 0x03 0x69 0x03 0x6a>; + // assigned-clock-parents = <0x03 0x41 0x03 0x38 0x03 0x38>; + // assigned-clock-rates = <0x3b9aca00 0x2faf0800 0x17d78400>; + // power-domains = <0x86>; + // status = "okay"; + // phandle = <0x8d>; + // }; + + chosen { + //bootargs = "earlycon console=ttyS0"; + //bootargs = "earlycon clk_ignore_unused console=ttymxc1,115200 root=/dev/mmcblk1p1 rootwait rw"; + bootargs = "clk_ignore_unused console=ttymxc1,115200 earlycon=ec_imx6q,0x30890000,115200 root=/dev/mmcblk2p1 rootwait rw"; + stdout-path = "/soc@0/bus@30800000/serial@30890000"; + }; + + hvisor_device { + compatible = "hvisor"; + interrupt-parent = <0x01>; + interrupts = <0x00 0x20 0x01>; + }; + +}; diff --git a/platform/aarch64/imx8mp/image/dts/zone1-linux.dts b/platform/aarch64/imx8mp/image/dts/zone1-linux.dts new file mode 100644 index 00000000..ba50ad0b --- /dev/null +++ b/platform/aarch64/imx8mp/image/dts/zone1-linux.dts @@ -0,0 +1,863 @@ +/dts-v1/; + +/ { + compatible = "forlinx,ok8mp-c\0fsl,imx8mp-evk\0fsl,/home/lgw/Documents/xwechat_files/wxid_ugo1mwfw18zq12_d8dd/msg/file/2024-07/linux2.json"; + model = "Forlinx OK8MPlus-C board"; + interrupt-parent = <0x01>; + #address-cells = <0x02>; + #size-cells = <0x02>; + + aliases { + // serial1 = "/soc@0/bus@30800000/serial@30890000"; + serial3 = "/soc@0/bus@30800000/serial@30a60000"; + // mmc3 = "/soc@0/bus@30800000/mmc@30b60000"; + ethernet0 = "/soc@0/bus@30800000/ethernet@30bf0000"; + }; + + memory@50000000 { + device_type = "memory"; + reg = <0x00 0x50000000 0x00 0x30000000>; + }; + + reserved-memory { + #address-cells = <0x02>; + #size-cells = <0x02>; + ranges; + + linux,cma { + compatible = "shared-dma-pool"; + reusable; + size = <0x00 0x10000000>; + alloc-ranges = <0x00 0x60000000 0x00 0x80000000>; + linux,cma-default; + }; + }; + + cpus { + #address-cells = <0x01>; + #size-cells = <0x00>; + // TODO: 增加idle-states for cpu + // idle-states { + // entry-method = "psci"; + + // cpu-pd-wait { + // // compatible = "arm,idle-state"; + // arm,psci-suspend-param = <0x10033>; + // local-timer-stop; + // entry-latency-us = <0x3e8>; + // exit-latency-us = <0x2bc>; + // min-residency-us = <0xa8c>; + // wakeup-latency-us = <0x5dc>; + // phandle = <0x06>; + // }; + // }; + + cpu@2 { + device_type = "cpu"; + compatible = "arm,cortex-a53"; + reg = <0x02>; + clock-latency = <0xee6c>; + next-level-cache = <0x02>; + clocks = <0x08>; + operating-points-v2 = <0x04>; + enable-method = "psci"; + #cooling-cells = <0x02>; + cpu-idle-states = <0x06>; + phandle = <0x103>; + }; + + cpu@3 { + device_type = "cpu"; + compatible = "arm,cortex-a53"; + reg = <0x03>; + clock-latency = <0xee6c>; + next-level-cache = <0x02>; + clocks = <0x08>; + operating-points-v2 = <0x04>; + enable-method = "psci"; + #cooling-cells = <0x02>; + cpu-idle-states = <0x06>; + phandle = <0x104>; + }; + + l2-cache0 { + compatible = "cache"; + phandle = <0x02>; + }; + }; + + psci { + compatible = "arm,psci-1.0"; + method = "smc"; + }; + + + power-domains { + compatible = "simple-bus"; + + mlmix-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x04>; + domain-name = "mlmix"; + clocks = <0x0d 0x0e 0x0c>; + phandle = <0x86>; + }; + + gpumix-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x06>; + domain-name = "gpumix"; + clocks = <0x0d 0x0e 0x0d>; + phandle = <0x7c>; + }; + + gpu2d-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x07>; + domain-name = "gpu2d"; + parent-domains = <0x7c>; + clocks = <0x0c>; + phandle = <0x7e>; + }; + + gpu3d-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x08>; + domain-name = "gpu3d"; + parent-domains = <0x7c>; + clocks = <0x0c 0x0c>; + phandle = <0x7d>; + }; + + mediamix-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x0d>; + domain-name = "mediamix"; + rpm-always-on; + clocks = <0x11 0x08>; + phandle = <0x10f>; + }; + + power-domain@14 { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x0e>; + domain-name = "ispdwp"; + parent-domains = <0x10f>; + clocks = <0x11>; + phandle = <0x71>; + }; + + audiomix-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x05>; + domain-name = "audiomix"; + clocks = <0x0e 0x0d>; + phandle = <0x57>; + }; + + hdmimix-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x11>; + domain-name = "hdmimix"; + clocks = <0x11 0x08 0x05>; + // clocks = <0x116 0x63 0xa8>; + phandle = <0x100>; + }; + + hdmiphy-pd { + compatible = "fsl,imx8m-pm-domain"; + #power-domain-cells = <0x00>; + domain-index = <0x12>; + domain-name = "hdmi_phy"; + parent-domains = <0x100>; + phandle = <0x6f>; + }; + }; + + 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>; + }; + + + clock@7 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x00>; + clock-output-names = "clk_dummy"; + phandle = <0x06>; + }; + + clock@9 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0xfdad680>; + clock-output-names = "266m"; + phandle = <0x07>; + }; + + clock@8 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0xbebc200>; + clock-output-names = "200m"; + phandle = <0x08>; + }; + + clock@12 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x5f5e100>; + clock-output-names = "100m"; + phandle = <0x09>; + }; + + clock@11 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x7735940>; + clock-output-names = "125m"; + phandle = <0x0a>; + }; + + clock@10 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x3F940AB>; + clock-output-names = "80m"; + phandle = <0x0b>; + }; + + clock@13 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x3B9ACA00>; + clock-output-names = "1000m"; + phandle = <0x0c>; + }; + + clock@14 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x2FAF0800>; + clock-output-names = "800m"; + phandle = <0x0d>; + }; + + clock@15 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x17D78400>; + clock-output-names = "400m"; + phandle = <0x0e>; + }; + + clock@16 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x29B92700>; + clock-output-names = "700m"; + phandle = <0x0f>; + }; + + clock@17 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x2B1A185>; + clock-output-names = "45m"; + phandle = <0x10>; + }; + + clock@18 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x1DCD6500>; + clock-output-names = "500m"; + phandle = <0x11>; + }; + + clock@19 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x46CF710>; + clock-output-names = "74m"; + phandle = <0x12>; + }; + + clock@20 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x7ED6B40>; + clock-output-names = "133m"; + phandle = <0x13>; + }; + + clock@21 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x8000>; + clock-output-names = "32k"; + phandle = <0x14>; + }; + + clock@22 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x15888000>; + clock-output-names = "361m"; + phandle = <0x15>; + }; + + clock@23 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x23C34600>; + clock-output-names = "600m"; + phandle = <0x16>; + }; + + clock@24 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x47868C00>; + clock-output-names = "1200m"; + phandle = <0x17>; + }; + + clock@25 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x3DF582E0>; + clock-output-names = "1039m"; + phandle = <0x18>; + }; + + clock@26 { + compatible = "fixed-clock"; + #clock-cells = <0x00>; + clock-frequency = <0x17700000>; + clock-output-names = "393m"; + phandle = <0x19>; + }; + + soc@0 { + compatible = "simple-bus"; + #address-cells = <0x01>; + #size-cells = <0x01>; + ranges = <0x00 0x00 0x00 0x3e000000>; + // dma-ranges = <0x40000000 0x00 0x40000000 0xc0000000>; + + bus@30000000 { + compatible = "simple-bus"; + reg = <0x30000000 0x400000>; + #address-cells = <0x01>; + #size-cells = <0x01>; + ranges; + + iomuxc-gpr@30340000 { + compatible = "fsl,imx8mp-iomuxc-gpr\0fsl,imx7d-iomuxc-gpr\0fsl,imx6q-iomuxc-gpr\0syscon"; + reg = <0x30340000 0x10000>; + phandle = <0x29>; + }; + }; + + bus@30800000 { + compatible = "simple-bus"; + #address-cells = <0x01>; + #size-cells = <0x01>; + reg = <0x30800000 0x400000>; + ranges; + + // serial@30890000 { + // compatible = "fsl,imx8mq-uart\0fsl,imx6q-uart"; + // reg = <0x30890000 0x10000>; + // interrupts = <0x00 0x1b 0x04>; + // status = "okay"; + // clocks = <0x05 0x05>; + // clock-names = "ipg\0per"; + // }; + + 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"; + // dmas = <0x22 0x1c 0x04 0x00 0x22 0x1d 0x04 0x00>; + // dma-names = "rx\0tx"; + // status = "disabled"; + }; + // sd card + // mmc@30b50000 { + // compatible = "fsl,imx8mm-usdhc\0fsl,imx7d-usdhc"; + // reg = <0x30b50000 0x10000>; + // interrupts = <0x00 0x17 0x04>; + // clocks = <0x06 0x07 0x08>; + // clock-names = "ipg\0ahb\0per"; + // fsl,tuning-start-tap = <0x14>; + // fsl,tuning-step = <0x02>; + // bus-width = <0x04>; + // status = "okay"; + // }; + // emmc + // mmc@30b60000 { + // compatible = "fsl,imx8mm-usdhc\0fsl,imx7d-usdhc"; + // reg = <0x30b60000 0x10000>; + // interrupts = <0x00 0x18 0x04>; + // fsl,tuning-start-tap = <0x14>; + // fsl,tuning-step = <0x02>; + // status = "okay"; + // clocks = <0x06 0x07 0x08>; + // clock-names = "ipg\0ahb\0per"; + // bus-width = <0x08>; + // non-removable; + // }; + + + // ethernet@30bf0000 { + // compatible = "nxp,imx8mp-dwmac-eqos\0snps,dwmac-5.10a"; + // reg = <0x30bf0000 0x10000>; + // interrupts = <0x00 0x86 0x04 0x00 0x87 0x04>; + // interrupt-names = "eth_wake_irq\0macirq"; + // clocks = <0x07 0x0b 0x09 0x0a>; + // clock-names = "stmmaceth\0pclk\0ptp_ref\0tx"; + // // assigned-clocks = <0x03 0x5e 0x03 0x82 0x03 0x81>; + // // assigned-clock-parents = <0x03 0x36 0x03 0x3a 0x03 0x3b>; + // // assigned-clock-rates = <0x00 0x5f5e100 0x7735940>; + // // nvmem-cells = <0x52>; + // // nvmem-cell-names = "mac-address"; + // // nvmem_macaddr_swap; + // intf_mode = <0x29 0x04>; + // status = "okay"; + // // pinctrl-names = "default"; + // // pinctrl-0 = <0x53>; + // reset-gpio = <0x25 0x05 0x01>; + // phy-mode = "rgmii-id"; + // phy-handle = <0x54>; + + // mdio { + // compatible = "snps,dwmac-mdio"; + // #address-cells = <0x01>; + // #size-cells = <0x00>; + + // ethernet-phy@1 { + // compatible = "ethernet-phy-ieee802.3-c22"; + // reg = <0x01>; + // eee-broken-1000t; + // at803x,vddio-1p8v; + // at803x,hibernate-disable; + // phandle = <0x54>; + // }; + // }; + // }; + }; + + // hdmi + bus@30c00000 { + compatible = "simple-bus"; + reg = <0x30c00000 0x400000>; + #address-cells = <0x01>; + #size-cells = <0x01>; + ranges; + + spba-bus@30c00000 { + compatible = "fsl,spba-bus\0simple-bus"; + reg = <0x30c00000 0x100000>; + #address-cells = <0x01>; + #size-cells = <0x01>; + ranges; + + aud2htx@30cb0000 { + compatible = "fsl,imx8mp-aud2htx"; + reg = <0x30cb0000 0x10000>; + interrupts = <0x00 0x82 0x04>; + clocks = <0x0e>; + clock-names = "bus"; + dmas = <0x56 0x1a 0x02 0x00>; + dma-names = "tx"; + power-domains = <0x57>; + status = "okay"; + phandle = <0xa6>; + }; + }; + + dma-controller@30e10000 { + compatible = "fsl,imx8mp-sdma\0fsl,imx7d-sdma"; + reg = <0x30e10000 0x10000>; + interrupts = <0x00 0x67 0x04>; + clocks = <0x0e 0x0e>; + clock-names = "ipg\0ahb"; + #dma-cells = <0x03>; + fsl,sdma-ram-script-name = "imx/sdma/sdma-imx7d.bin"; + fsl,ratio-1-1; + power-domains = <0x57>; + status = "okay"; + phandle = <0x56>; + }; + + + audiomix@30e20000 { + compatible = "fsl,imx8mp-audiomix"; + reg = <0x30e20000 0x10000>; + + // clock-controller { + // compatible = "fsl,imx8mp-audiomix-clk"; + // #clock-cells = <0x01>; + // clocks = <0x0e>; + // clock-names = "audio_root"; + // power-domains = <0x57>; + // phandle = <0x3c>; + // }; + + reset-controller { + compatible = "fsl,imx8mp-audiomix-reset"; + power-domains = <0x57>; + #reset-cells = <0x01>; + phandle = <0x5a>; + }; + + audiomix_dsp { + compatible = "fsl,audiomix-dsp"; + }; + }; + }; + // hdmi + bus@32c00000 { + compatible = "simple-bus"; + reg = <0x32c00000 0x400000>; + #address-cells = <0x01>; + #size-cells = <0x01>; + ranges; + + lcd-controller@32e80000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "fsl,imx8mp-lcdif1"; + reg = <0x32e80000 0x10000>; + clocks = <0x10 0x11 0x08>; + clock-names = "pix\0disp-axi\0disp-apb"; + // assigned-clocks = <0x03 0xac 0x03 0x61 0x03 0x62>; + // assigned-clock-parents = <0x03 0x28 0x03 0x41 0x03 0x38>; + // assigned-clock-rates = <0x00 0x1dcd6500 0xbebc200>; + interrupts = <0x00 0x05 0x04>; + blk-ctl = <0x5c>; + power-domains = <0x10f>; + status = "okay"; + + port@0 { + reg = <0x00>; + phandle = <0x8a>; + + endpoint { + remote-endpoint = <0x61>; + phandle = <0x5d>; + }; + }; + }; + + lcd-controller@32e90000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "fsl,imx8mp-lcdif2"; + reg = <0x32e90000 0x10000>; + clocks = <0x12 0x11 0x08>; + clock-names = "pix\0disp-axi\0disp-apb"; + // assigned-clocks = <0x03 0x121 0x03 0x61 0x03 0x62>; + // assigned-clock-parents = <0x03 0x28 0x03 0x41 0x03 0x38>; + // assigned-clock-rates = <0x00 0x1dcd6500 0xbebc200>; + interrupts = <0x00 0x06 0x04>; + power-domains = <0x10f>; + status = "okay"; + + port@0 { + #address-cells = <0x01>; + #size-cells = <0x00>; + reg = <0x00>; + phandle = <0x8b>; + + endpoint@0 { + reg = <0x00>; + remote-endpoint = <0x62>; + phandle = <0x65>; + }; + + endpoint@1 { + reg = <0x01>; + remote-endpoint = <0x63>; + phandle = <0x68>; + }; + }; + }; + + blk-ctl@32ec0000 { + compatible = "fsl,imx8mp-mediamix-blk-ctl\0syscon"; + reg = <0x32ec0000 0x10000>; + clocks = <0x08>; + phandle = <0x5c>; + }; + + hdmi-blk@32fc0000 { + compatible = "syscon"; + reg = <0x32fc0000 0x1000>; + phandle = <0x6e>; + }; + + hdmimix@32fc0000 { + compatible = "fsl,imx8mp-audiomix\0fsl,imx8mp-hdmimix"; + reg = <0x32fc0000 0x1000>; + + // clock-controller { + // compatible = "fsl,imx8mp-hdmimix-clk"; + // #clock-cells = <0x01>; + // clocks = <0x06>; + // clock-names = "dummy"; + // status = "okay"; + // phandle = <0x69>; + // }; + + reset-controller { + compatible = "fsl,imx8mp-hdmimix-reset"; + #reset-cells = <0x01>; + status = "okay"; + phandle = <0x6a>; + }; + }; + // hdmi 用到的中断控制器 + irqsteer@32fc2000 { + compatible = "fsl,imx-irqsteer"; + reg = <0x32fc2000 0x1000>; + interrupts = <0x00 0x2b 0x04>; + interrupt-controller; + interrupt-parent = <0x01>; + #interrupt-cells = <0x01>; + fsl,channel = <0x01>; + fsl,num-irqs = <0x40>; + clocks = <0x08>; + clock-names = "ipg"; + // assigned-clocks = <0x03 0x63>; + // assigned-clock-parents = <0x03 0x38>; + // assigned-clock-rates = <0xbebc200>; + resets = <0x6a 0x05>; + status = "okay"; + phandle = <0x6c>; + }; + + hdmi-pai-pvi@32fc4000 { + compatible = "fsl,imx8mp-hdmi-pavi"; + reg = <0x32fc4000 0x1000>; + clocks = <0x06 0x08>; + clock-names = "pvi_clk\0pai_clk"; + resets = <0x6a 0x02 0x6a 0x03>; + reset-names = "pai_rst\0pvi_rst"; + status = "okay"; + }; + + lcd-controller@32fc6000 { + #address-cells = <0x01>; + #size-cells = <0x00>; + compatible = "fsl,imx8mp-lcdif3"; + reg = <0x32fc6000 0x10000>; + // clocks = <0x6b 0x00 0x03 0x64 0x03 0x63 0x69 0x00 0x69 0x01 0x69 0x03 0x69 0x05 0x69 0x09 0x69 0x0a 0x69 0x0b 0x69 0x0c 0x69 0x0d 0x69 0x07>; + clocks = <0x06 0x11 0x08 0x08 0x11 0x05 0x06 0x08 0x11 0x08 0x06 0x08 0x08>; + clock-names = "pix\0disp-axi\0disp-apb\0mix_apb\0mix_axi\0xtl_24m\0mix_pix\0lcdif_apb\0lcdif_axi\0lcdif_pdi\0lcdif_pix\0lcdif_spu\0noc_hdmi"; + // assigned-clocks = <0x03 0x64 0x03 0x63>; + // assigned-clock-parents = <0x03 0x40 0x03 0x38>; + // assigned-clock-rates = <0x1dcd6500 0xbebc200>; + interrupts = <0x08 0x04>; + interrupt-parent = <0x6c>; + resets = <0x6a 0x07>; + power-domains = <0x100>; + status = "okay"; + thres-low = <0x01 0x02>; + thres-high = <0x03 0x04>; + + port@0 { + reg = <0x00>; + phandle = <0x18c>; + + endpoint { + remote-endpoint = <0x6d>; + phandle = <0x70>; + }; + }; + }; + + hdmi@32fd8000 { + compatible = "fsl,imx8mp-hdmi"; + reg = <0x32fd8000 0x7eff>; + // 0x00表示它连到中断控制器的第0个引脚,该中断控制器是irqsteer,它连到GIC中断线代表32+0x2b号中断。因此hdmi发出中断,CPU收到的就是32+0x2b + interrupts = <0x00 0x04>; + interrupt-parent = <0x6c>; + clocks = <0x08 0x05 0x08 0x08 0x08 0x08 0x06 0x14 0x08 0x08 0x05 0x06>; + clock-names = "iahb\0isfr\0phy_int\0prep_clk\0skp_clk\0sfr_clk\0pix_clk\0cec_clk\0apb_clk\0hpi_clk\0fdcc_ref\0pipe_clk"; + // assigned-clocks = <0x03 0x63 0x03 0x64 0x03 0xa7>; + // assigned-clock-parents = <0x03 0x38 0x03 0x40 0x03 0x02>; + // assigned-clock-rates = <0xbebc200 0x1dcd6500 0x16e3600>; + phys = <0x6b>; + phy-names = "hdmi"; + resets = <0x6a 0x00>; + gpr = <0x6e>; + power-domains = <0x6f>; + status = "okay"; + + port@0 { + + endpoint { + remote-endpoint = <0x70>; + phandle = <0x6d>; + }; + }; + }; + + hdmiphy@32fdff00 { + compatible = "fsl,samsung-hdmi-phy"; + reg = <0x32fdff00 0x100>; + #clock-cells = <0x01>; + clocks = <0x06 0x05>; + clock-names = "apb\0ref"; + clock-output-names = "hdmi_phy"; + #phy-cells = <0x00>; + resets = <0x6a 0x01>; + status = "okay"; + phandle = <0x6b>; + }; + }; + }; + // virtio blk + virtio_mmio@a003c00 { + dma-coherent; + interrupt-parent = <0x01>; + interrupts = <0x0 0x2e 0x1>; + reg = <0x0 0xa003c00 0x0 0x200>; + compatible = "virtio,mmio"; + }; + // virtio net + 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"; + // }; + + mix_gpu_ml { + compatible = "fsl,imx8mp-gpu\0fsl,imx8-gpu-ss"; + cores = <0x8c 0x8d 0x8e>; + reg = <0x00 0x60000000 0x00 0x80000000 0x00 0x00 0x00 0x10000000>; + reg-names = "phys_baseaddr\0contiguous_mem"; + status = "okay"; + }; + + gpu3d@38000000 { + compatible = "fsl,imx8-gpu"; + reg = <0x00 0x38000000 0x00 0x8000>; + interrupts = <0x00 0x03 0x04>; + clocks = <0x0c 0x0c 0x0d 0x0e>; + clock-names = "core\0shader\0axi\0ahb"; + // to be config: + // assigned-clocks = <0x03 0x45 0x03 0x46 0x03 0x65 0x03 0x66>; + // assigned-clock-parents = <0x03 0x41 0x03 0x41 0x03 0x38 0x03 0x38>; + // assigned-clock-rates = <0x3b9aca00 0x3b9aca00 0x2faf0800 0x17d78400>; + power-domains = <0x7d>; + status = "okay"; + phandle = <0x8c>; + }; + + gpu2d@38008000 { + compatible = "fsl,imx8-gpu"; + reg = <0x00 0x38008000 0x00 0x8000>; + interrupts = <0x00 0x19 0x04>; + clocks = <0x0c 0x0d 0x0e>; + clock-names = "core\0axi\0ahb"; + // assigned-clocks = <0x03 0x47 0x03 0x65 0x03 0x66>; + // assigned-clock-parents = <0x03 0x41 0x03 0x38 0x03 0x38>; + // assigned-clock-rates = <0x3b9aca00 0x2faf0800 0x17d78400>; + power-domains = <0x7e>; + status = "okay"; + phandle = <0x8e>; + }; + + vipsi@38500000 { + compatible = "fsl,imx8-gpu\0fsl,imx8-vipsi"; + reg = <0x00 0x38500000 0x00 0x20000>; + interrupts = <0x00 0x0d 0x04>; + clocks = <0x0c 0x0c 0x0d 0x0e>; + clock-names = "core\0shader\0axi\0ahb"; + // assigned-clocks = <0x03 0x44 0x03 0x69 0x03 0x6a>; + // assigned-clock-parents = <0x03 0x41 0x03 0x38 0x03 0x38>; + // assigned-clock-rates = <0x3b9aca00 0x2faf0800 0x17d78400>; + power-domains = <0x86>; + status = "okay"; + phandle = <0x8d>; + }; + + forlinx_control { + status = "okay"; + video-hdmi = "on"; + video-mipi = "off"; + video-lvds = "off"; + }; + + display-subsystem { + compatible = "fsl,imx-display-subsystem"; + ports = <0x8a 0x8b 0x18c>; + }; + + chosen { + // real blk and real console: + // bootargs = "clk_ignore_unused console=ttymxc3,115200 earlycon=ec_imx6q3,0x30a60000,115200 root=/dev/mmcblk3p2 rootwait rw"; + // stdout-path = "/soc@0/bus@30800000/serial@30a60000"; + + // virtio blk and real console: + bootargs = "clk_ignore_unused console=ttymxc3,115200 earlycon=ec_imx6q3,0x30a60000,115200 root=/dev/vda rootwait rw"; + stdout-path = "/soc@0/bus@30800000/serial@30a60000"; + + // virtio blk and virtio console: + // bootargs = "clk_ignore_unused earlycon=virtio,mmio,0xa003800 console=hvc0 root=/dev/vda rootwait rw"; + // stdout-path = "/virtio_mmio@a003800"; + }; +}; \ No newline at end of file diff --git a/scripts/qemu-aarch64.ld b/platform/aarch64/imx8mp/linker.ld similarity index 100% rename from scripts/qemu-aarch64.ld rename to platform/aarch64/imx8mp/linker.ld diff --git a/scripts/qemu-aarch64.mk b/platform/aarch64/imx8mp/platform.mk similarity index 100% rename from scripts/qemu-aarch64.mk rename to platform/aarch64/imx8mp/platform.mk diff --git a/src/platform/qemu_aarch64.rs b/platform/aarch64/qemu-gicv2/board.rs similarity index 97% rename from src/platform/qemu_aarch64.rs rename to platform/aarch64/qemu-gicv2/board.rs index b97c243f..4e8a2fa5 100644 --- a/src/platform/qemu_aarch64.rs +++ b/platform/aarch64/qemu-gicv2/board.rs @@ -1,5 +1,7 @@ use crate::{arch::zone::HvArchZoneConfig, config::*}; +pub const BOARD_NAME: &str = "qemu"; + pub const ROOT_ZONE_DTB_ADDR: u64 = 0xa0000000; pub const ROOT_ZONE_KERNEL_ADDR: u64 = 0xa0400000; pub const ROOT_ZONE_ENTRY: u64 = 0xa0400000; diff --git a/platform/aarch64/qemu-gicv2/cargo/config.template.toml b/platform/aarch64/qemu-gicv2/cargo/config.template.toml new file mode 100644 index 00000000..9e6c399d --- /dev/null +++ b/platform/aarch64/qemu-gicv2/cargo/config.template.toml @@ -0,0 +1,7 @@ +[target.aarch64-unknown-none] +runner = "platform/__ARCH__/__BOARD__/test/runner.sh" +rustflags = [ + "-Clink-arg=-Tplatform/__ARCH__/__BOARD__/linker.ld", + "-Ctarget-feature=+a53,+v8a,+strict-align,-neon,-fp-armv8", + "-Cforce-frame-pointers=yes", +] \ No newline at end of file diff --git a/platform/aarch64/qemu-gicv2/cargo/features b/platform/aarch64/qemu-gicv2/cargo/features new file mode 100644 index 00000000..bd682521 --- /dev/null +++ b/platform/aarch64/qemu-gicv2/cargo/features @@ -0,0 +1,5 @@ +gicv2 +pl011 +iommu +pci +pt_layout_qemu \ No newline at end of file diff --git a/images/aarch64/bootloader/u-boot-v2.bin b/platform/aarch64/qemu-gicv2/image/bootloader/u-boot-v2.bin similarity index 100% rename from images/aarch64/bootloader/u-boot-v2.bin rename to platform/aarch64/qemu-gicv2/image/bootloader/u-boot-v2.bin diff --git a/platform/aarch64/qemu-gicv2/image/dts/Makefile b/platform/aarch64/qemu-gicv2/image/dts/Makefile new file mode 100644 index 00000000..2f795e7f --- /dev/null +++ b/platform/aarch64/qemu-gicv2/image/dts/Makefile @@ -0,0 +1,8 @@ +DTS_FILES := $(wildcard *.dts) +DTB_FILES := $(DTS_FILES:.dts=.dtb) + +all: $(DTB_FILES) +%.dtb: %.dts + dtc -I dts -O dtb $< -o $@ +clean: + rm -f $(DTB_FILES) \ No newline at end of file diff --git a/images/aarch64/devicetree/linux1-v2.dts b/platform/aarch64/qemu-gicv2/image/dts/zone0.dts similarity index 99% rename from images/aarch64/devicetree/linux1-v2.dts rename to platform/aarch64/qemu-gicv2/image/dts/zone0.dts index ce6b8dfa..6aad8f57 100644 --- a/images/aarch64/devicetree/linux1-v2.dts +++ b/platform/aarch64/qemu-gicv2/image/dts/zone0.dts @@ -94,4 +94,4 @@ bootargs = "earlycon console=ttyAMA0 root=/dev/vda mem=768M rw"; stdout-path = "/pl011@9000000"; }; -}; +}; \ No newline at end of file diff --git a/scripts/zcu102-aarch64.ld b/platform/aarch64/qemu-gicv2/linker.ld similarity index 100% rename from scripts/zcu102-aarch64.ld rename to platform/aarch64/qemu-gicv2/linker.ld diff --git a/platform/aarch64/qemu-gicv2/platform.mk b/platform/aarch64/qemu-gicv2/platform.mk new file mode 100644 index 00000000..274f8367 --- /dev/null +++ b/platform/aarch64/qemu-gicv2/platform.mk @@ -0,0 +1,46 @@ +QEMU := qemu-system-aarch64 + +UBOOT := $(image_dir)/bootloader/u-boot-v2.bin +zone0_dtb := $(image_dir)/dts/zone0.dtb +QEMU_ARGS := -machine virt,secure=on,gic-version=2,virtualization=on,iommu=smmuv3 +MESSAGE := "Note: Feature contains gicv2" + +FSIMG1 := $(image_dir)/virtdisk/rootfs1.ext4 +FSIMG2 := $(image_dir)/virtdisk/rootfs2.ext4 + +zone0_kernel := $(image_dir)/kernel/Image + +QEMU_ARGS += -global arm-smmuv3.stage=2 + +QEMU_ARGS += -cpu cortex-a72 +QEMU_ARGS += -smp 4 +QEMU_ARGS += -m 2G +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 += -drive if=none,file=$(FSIMG1),id=Xa003e000,format=raw +QEMU_ARGS += -device virtio-blk-device,drive=Xa003e000,bus=virtio-mmio-bus.31 + +$(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 + +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 \ No newline at end of file diff --git a/tools/cargo_test.sh b/platform/aarch64/qemu-gicv2/test/runner.sh similarity index 79% rename from tools/cargo_test.sh rename to platform/aarch64/qemu-gicv2/test/runner.sh index 381cfa18..36d0bf3b 100755 --- a/tools/cargo_test.sh +++ b/platform/aarch64/qemu-gicv2/test/runner.sh @@ -2,12 +2,6 @@ set -e -# for hvisor's unit test when running cargo test -# passed to .cargo/config -# runner = "___HVISOR_SRC___/_cargo_test.sh" -# ___HVISOR_SRC___ will be replaced dynamically by the Makefile and restored after the test -# wheatfox(wheatfox17@icloud.com) 2024.12 - PWD=$(pwd) THIS=$(basename $0) CARGO_BUILD_INPUT_ARG0=$1 @@ -18,9 +12,8 @@ ARCH=${ARCH} FEATURES=${FEATURES} BOARD=${BOARD} -UBOOT_GICV3=images/aarch64/bootloader/u-boot-atf.bin -UBOOT_GICV2=images/aarch64/bootloader/u-boot-v2.bin -# UBOOT=u-boot.bin +UBOOT_GICV3=u-boot-atf.bin +UBOOT_GICV2=u-boot-v2.bin HVISOR_ELF=$CARGO_BUILD_INPUT_ARG0 HVISOR_BIN_TMP=$HVISOR_ELF.bin.tmp @@ -71,25 +64,24 @@ if [ "$ARCH" == "aarch64" ]; then if [ $AARCH64_GIC_TEST_VERSION -eq 2 ]; then UBOOT=$UBOOT_GICV2 fi + UBOOT=$PWD/platform/$ARCH/$BOARD/image/bootloader/$UBOOT info "Using U-Boot: $UBOOT" + qemu-system-aarch64 \ -machine virt,secure=on,gic-version=${AARCH64_GIC_TEST_VERSION},virtualization=on,iommu=smmuv3 \ - -global arm-smmuv3.stage=2 \ -cpu cortex-a57 -smp 4 -m 3G -nographic \ -semihosting \ -bios $UBOOT \ -drive if=pflash,format=raw,index=1,file=flash.img \ - -device loader,file=$HVISOR_BIN,addr=0x40400000,force-raw=on + -device loader,file=$HVISOR_BIN,addr=0x40400000,force-raw=on \ + # -global arm-smmuv3.stage=2 - mv .cargo/config.bak .cargo/config exit 0 elif [ "$ARCH" == "riscv64" ]; then info "riscv64 auto test is not supported yet" - mv .cargo/config.bak .cargo/config exit 1 else info "Unsupported ARCH: $ARCH" - mv .cargo/config.bak .cargo/config exit 1 fi diff --git a/platform/aarch64/qemu-gicv3/board.rs b/platform/aarch64/qemu-gicv3/board.rs new file mode 100644 index 00000000..1ad99ee6 --- /dev/null +++ b/platform/aarch64/qemu-gicv3/board.rs @@ -0,0 +1,69 @@ +use crate::{arch::zone::HvArchZoneConfig, config::*}; + +pub const BOARD_NAME: &str = "qemu-givc3"; + +pub const ROOT_ZONE_DTB_ADDR: u64 = 0xa0000000; +pub const ROOT_ZONE_KERNEL_ADDR: u64 = 0xa0400000; +pub const ROOT_ZONE_ENTRY: u64 = 0xa0400000; +pub const ROOT_ZONE_CPUS: u64 = (1 << 0) | (1 << 1); + +pub const ROOT_ZONE_NAME: &str = "root-linux"; + +pub const ROOT_ZONE_MEMORY_REGIONS: [HvConfigMemoryRegion; 3] = [ + HvConfigMemoryRegion { + mem_type: MEM_TYPE_RAM, + physical_start: 0x50000000, + virtual_start: 0x50000000, + size: 0x70000000, + }, // ram + HvConfigMemoryRegion { + mem_type: MEM_TYPE_IO, + physical_start: 0x9000000, + virtual_start: 0x9000000, + size: 0x1000, + }, // serial + HvConfigMemoryRegion { + mem_type: MEM_TYPE_IO, + physical_start: 0xa000000, + virtual_start: 0xa000000, + size: 0x4000, + }, // virtio +]; + +// 35 36 37 38 -> pcie intx# +// 65 -> ivc +pub const ROOT_ZONE_IRQS: [u32; 9] = [33, 64, 77, 79, 35, 36, 37, 38, 65]; + +pub const ROOT_ARCH_ZONE_CONFIG: HvArchZoneConfig = HvArchZoneConfig { + gicd_base: 0x8000000, + gicd_size: 0x10000, + gicr_base: 0x80a0000, + gicr_size: 0xf60000, + gicc_base: 0x8010000, + gicc_size: 0x10000, + gicc_offset: 0x0, + gich_base: 0x8030000, + gich_size: 0x10000, + gicv_base: 0x8040000, + gicv_size: 0x10000, + gits_base: 0x8080000, + gits_size: 0x20000, +}; + +pub const ROOT_PCI_CONFIG: HvPciConfig = HvPciConfig { + 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, +}; + +pub const ROOT_ZONE_IVC_CONFIG: [HvIvcConfig; 0] = []; + +pub const ROOT_PCI_DEVS: [u64; 2] = [0, 1 << 3]; diff --git a/platform/aarch64/qemu-gicv3/cargo/config.template.toml b/platform/aarch64/qemu-gicv3/cargo/config.template.toml new file mode 100644 index 00000000..9e6c399d --- /dev/null +++ b/platform/aarch64/qemu-gicv3/cargo/config.template.toml @@ -0,0 +1,7 @@ +[target.aarch64-unknown-none] +runner = "platform/__ARCH__/__BOARD__/test/runner.sh" +rustflags = [ + "-Clink-arg=-Tplatform/__ARCH__/__BOARD__/linker.ld", + "-Ctarget-feature=+a53,+v8a,+strict-align,-neon,-fp-armv8", + "-Cforce-frame-pointers=yes", +] \ No newline at end of file diff --git a/platform/aarch64/qemu-gicv3/cargo/features b/platform/aarch64/qemu-gicv3/cargo/features new file mode 100644 index 00000000..942d603a --- /dev/null +++ b/platform/aarch64/qemu-gicv3/cargo/features @@ -0,0 +1,5 @@ +gicv3 +pl011 +iommu +pci +pt_layout_qemu \ No newline at end of file diff --git a/platform/aarch64/qemu-gicv3/configs/zone1-linux.json b/platform/aarch64/qemu-gicv3/configs/zone1-linux.json new file mode 100644 index 00000000..b5d615db --- /dev/null +++ b/platform/aarch64/qemu-gicv3/configs/zone1-linux.json @@ -0,0 +1,34 @@ +{ + "arch": "arm64", + "name": "linux2", + "zone_id": 1, + "cpus": [2, 3], + "memory_regions": [ + { + "type": "ram", + "physical_start": "0x50000000", + "virtual_start": "0x50000000", + "size": "0x30000000" + }, + { + "type": "io", + "physical_start": "0xa003000", + "virtual_start": "0xa003000", + "size": "0x1000" + } + ], + "interrupts": [75, 76, 78], + "ivc_configs": [], + "kernel_filepath": "Image", + "kernel_args": "", + "dtb_filepath": "zone1-linux.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" + } +} \ No newline at end of file diff --git a/images/aarch64/devicetree/qemu-ruxos.json b/platform/aarch64/qemu-gicv3/configs/zone1-ruxos.json similarity index 72% rename from images/aarch64/devicetree/qemu-ruxos.json rename to platform/aarch64/qemu-gicv3/configs/zone1-ruxos.json index edeac7dc..7d2855c6 100644 --- a/images/aarch64/devicetree/qemu-ruxos.json +++ b/platform/aarch64/qemu-gicv3/configs/zone1-ruxos.json @@ -17,9 +17,17 @@ } ], "interrupts": [], + "ivc_config": [], + "kernel_args": "", "kernel_filepath": "./helloworld_aarch64-qemu-virt.bin", "dtb_filepath": "./qemu-ruxos.dtb", "kernel_load_paddr": "0x50080000", "dtb_load_paddr": "0x50000000", - "entry_point": "0x40080000" + "entry_point": "0x40080000", + "arch_config": { + "gicd_base": "0x8000000", + "gicd_size": "0x10000", + "gicr_base": "0x80a0000", + "gicr_size": "0xf60000" + } } \ No newline at end of file diff --git a/images/aarch64/bootloader/u-boot-atf.bin b/platform/aarch64/qemu-gicv3/image/bootloader/u-boot-atf.bin similarity index 100% rename from images/aarch64/bootloader/u-boot-atf.bin rename to platform/aarch64/qemu-gicv3/image/bootloader/u-boot-atf.bin diff --git a/images/aarch64/bootloader/u-boot.bin b/platform/aarch64/qemu-gicv3/image/bootloader/u-boot.bin similarity index 100% rename from images/aarch64/bootloader/u-boot.bin rename to platform/aarch64/qemu-gicv3/image/bootloader/u-boot.bin diff --git a/platform/aarch64/qemu-gicv3/image/dts/Makefile b/platform/aarch64/qemu-gicv3/image/dts/Makefile new file mode 100644 index 00000000..2f795e7f --- /dev/null +++ b/platform/aarch64/qemu-gicv3/image/dts/Makefile @@ -0,0 +1,8 @@ +DTS_FILES := $(wildcard *.dts) +DTB_FILES := $(DTS_FILES:.dts=.dtb) + +all: $(DTB_FILES) +%.dtb: %.dts + dtc -I dts -O dtb $< -o $@ +clean: + rm -f $(DTB_FILES) \ No newline at end of file diff --git a/images/aarch64/devicetree/linux1.dts b/platform/aarch64/qemu-gicv3/image/dts/zone0.dts similarity index 99% rename from images/aarch64/devicetree/linux1.dts rename to platform/aarch64/qemu-gicv3/image/dts/zone0.dts index da2f225f..3b6d88fb 100644 --- a/images/aarch64/devicetree/linux1.dts +++ b/platform/aarch64/qemu-gicv3/image/dts/zone0.dts @@ -356,4 +356,4 @@ interrupt-parent = <0x01>; interrupts = <0x00 0x20 0x01>; }; -}; +}; \ No newline at end of file diff --git a/images/aarch64/devicetree/linux2.dts b/platform/aarch64/qemu-gicv3/image/dts/zone1-linux.dts similarity index 55% rename from images/aarch64/devicetree/linux2.dts rename to platform/aarch64/qemu-gicv3/image/dts/zone1-linux.dts index 9780b77f..083488d0 100644 --- a/images/aarch64/devicetree/linux2.dts +++ b/platform/aarch64/qemu-gicv3/image/dts/zone1-linux.dts @@ -14,9 +14,17 @@ cpu@2 { reg = <0x02>; enable-method = "psci"; - compatible = "arm,cortex-a72"; + compatible = "arm,cortex-a57"; device_type = "cpu"; }; + + cpu@3 { + reg = <0x03>; + enable-method = "psci"; + compatible = "arm,cortex-a57"; + device_type = "cpu"; + }; + }; psci { @@ -29,43 +37,12 @@ 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>; + gic@80000000 { 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"; + interrupt-controller; + reg = <0x00 0x8000000 0x00 0x10000 0x00 0x80a0000 0x00 0xf60000>; + phandle = <0x01>; }; apb-pclk { @@ -112,7 +89,14 @@ // reg = <0x0 0xa003400 0x0 0x200>; // compatible = "virtio,mmio"; // }; - + // virtio-net + // 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 { @@ -123,14 +107,6 @@ 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; @@ -149,7 +125,9 @@ // }; chosen { - bootargs = "earlycon=virtio,mmio,0xa003800 console=hvc0 root=/dev/vda rw"; + bootargs = "earlycon console=hvc0 root=/dev/vda rw"; + // bootargs = "root=/dev/vda mem=768M"; stdout-path = "/virtio_mmio@a003800"; }; + }; diff --git a/images/aarch64/devicetree/imx8mp-ruxos.dts b/platform/aarch64/qemu-gicv3/image/dts/zone1-ruxos.dts similarity index 100% rename from images/aarch64/devicetree/imx8mp-ruxos.dts rename to platform/aarch64/qemu-gicv3/image/dts/zone1-ruxos.dts diff --git a/platform/aarch64/qemu-gicv3/linker.ld b/platform/aarch64/qemu-gicv3/linker.ld new file mode 100644 index 00000000..4cd76ea3 --- /dev/null +++ b/platform/aarch64/qemu-gicv3/linker.ld @@ -0,0 +1,49 @@ +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/platform/aarch64/qemu-gicv3/platform.mk b/platform/aarch64/qemu-gicv3/platform.mk new file mode 100644 index 00000000..3f2f0c22 --- /dev/null +++ b/platform/aarch64/qemu-gicv3/platform.mk @@ -0,0 +1,46 @@ +QEMU := qemu-system-aarch64 + +UBOOT := $(image_dir)/bootloader/u-boot-atf.bin +zone0_dtb := $(image_dir)/dts/zone0.dtb +QEMU_ARGS := -machine virt,secure=on,gic-version=3,virtualization=on,iommu=smmuv3 +MESSAGE := "Note: Feature contains gicv3" + +FSIMG1 := $(image_dir)/virtdisk/rootfs1.ext4 +FSIMG2 := $(image_dir)/virtdisk/rootfs2.ext4 + +zone0_kernel := $(image_dir)/kernel/Image + +QEMU_ARGS += -global arm-smmuv3.stage=2 + +QEMU_ARGS += -cpu cortex-a72 +QEMU_ARGS += -smp 4 +QEMU_ARGS += -m 2G +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 += -drive if=none,file=$(FSIMG1),id=Xa003e000,format=raw +QEMU_ARGS += -device virtio-blk-device,drive=Xa003e000,bus=virtio-mmio-bus.31 + +$(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 + +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 \ No newline at end of file diff --git a/platform/aarch64/qemu-gicv3/test/runner.sh b/platform/aarch64/qemu-gicv3/test/runner.sh new file mode 100755 index 00000000..36d0bf3b --- /dev/null +++ b/platform/aarch64/qemu-gicv3/test/runner.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +set -e + +PWD=$(pwd) +THIS=$(basename $0) +CARGO_BUILD_INPUT_ARG0=$1 + +# capture env: FEATURES, ARCH + +ARCH=${ARCH} +FEATURES=${FEATURES} +BOARD=${BOARD} + +UBOOT_GICV3=u-boot-atf.bin +UBOOT_GICV2=u-boot-v2.bin + +HVISOR_ELF=$CARGO_BUILD_INPUT_ARG0 +HVISOR_BIN_TMP=$HVISOR_ELF.bin.tmp +HVISOR_BIN=$HVISOR_ELF.bin + +OBJCOPY=rust-objcopy + +YELLOW='\033[1;33m' +END='\033[0m' + +info() { + # echo "${YELLOW}[INFO | $THIS] $1${END}" + echo "[INFO | $THIS] $1" +} + +# check if mkimage is installed +if ! command -v mkimage &>/dev/null; then + if command -v apt &>/dev/null; then + sudo apt update && sudo apt install -y u-boot-tools + elif command -v brew &>/dev/null; then + brew install u-boot-tools + else + info "You need to install u-boot-tools to run this script (mkimage)" + exit 1 + fi +fi + +info "Running cargo test with env: ARCH=$ARCH, FEATURES=$FEATURES, BOARD=$BOARD" + +info "Building hvisor with $CARGO_BUILD_INPUT_ARG0" +info "PWD=$PWD, running cargo test" +$OBJCOPY $HVISOR_ELF --strip-all -O binary $HVISOR_BIN_TMP + +if [ "$ARCH" == "aarch64" ]; then + mkimage -n hvisor_img -A arm64 -O linux -C none -T kernel -a 0x40400000 \ + -e 0x40400000 -d $HVISOR_BIN_TMP $HVISOR_BIN + + info "Running QEMU with $HVISOR_BIN" + + # if we have gicv2,gicv3 in FEATURES, we get the number from it + AARCH64_GIC_TEST_VERSION=3 + if [[ $FEATURES == *"gicv2"* ]]; then + AARCH64_GIC_TEST_VERSION=2 + fi + info "Using GIC version: $AARCH64_GIC_TEST_VERSION" + + UBOOT=$UBOOT_GICV3 + if [ $AARCH64_GIC_TEST_VERSION -eq 2 ]; then + UBOOT=$UBOOT_GICV2 + fi + UBOOT=$PWD/platform/$ARCH/$BOARD/image/bootloader/$UBOOT + info "Using U-Boot: $UBOOT" + + + qemu-system-aarch64 \ + -machine virt,secure=on,gic-version=${AARCH64_GIC_TEST_VERSION},virtualization=on,iommu=smmuv3 \ + -cpu cortex-a57 -smp 4 -m 3G -nographic \ + -semihosting \ + -bios $UBOOT \ + -drive if=pflash,format=raw,index=1,file=flash.img \ + -device loader,file=$HVISOR_BIN,addr=0x40400000,force-raw=on \ + # -global arm-smmuv3.stage=2 + + exit 0 +elif [ "$ARCH" == "riscv64" ]; then + info "riscv64 auto test is not supported yet" + exit 1 +else + info "Unsupported ARCH: $ARCH" + exit 1 +fi diff --git a/test/tcompiledtb.sh b/platform/aarch64/qemu-gicv3/test/systemtest/tcompiledtb.sh similarity index 82% rename from test/tcompiledtb.sh rename to platform/aarch64/qemu-gicv3/test/systemtest/tcompiledtb.sh index df53fb73..e7aa7192 100755 --- a/test/tcompiledtb.sh +++ b/platform/aarch64/qemu-gicv3/test/systemtest/tcompiledtb.sh @@ -3,7 +3,7 @@ set -e # Exit immediately if any command fails # Compile device tree in a subshell to maintain working directory ( - cd images/aarch64/devicetree && + cd platform/aarch64/qemu-gicv3/image/dts make all ) # Subshell automatically returns to original directory after execution \ No newline at end of file diff --git a/test/tdownload_all.sh b/platform/aarch64/qemu-gicv3/test/systemtest/tdownload_all.sh similarity index 94% rename from test/tdownload_all.sh rename to platform/aarch64/qemu-gicv3/test/systemtest/tdownload_all.sh index dbcdd31e..6b89c96a 100755 --- a/test/tdownload_all.sh +++ b/platform/aarch64/qemu-gicv3/test/systemtest/tdownload_all.sh @@ -14,10 +14,10 @@ ZIP_PARTS=( "rootfs1.zip.003" ) ZIP_OUTPUT="rootfs1.zip" -UNZIP_DIR="images/aarch64/virtdisk" # Extraction directory - +UNZIP_DIR="platform/aarch64/qemu-gicv3/image/virtdisk" # Extraction directory +`` # Independent image configuration -TARGET_DIR="images/aarch64/kernel" # Target directory path +TARGET_DIR="platform/aarch64/qemu-gicv3/image/kernel" # Target directory path IMAGE_FILE="${TARGET_DIR}/Image" # Full image file path IMAGE_URL="$BASE_URL/Image" @@ -79,7 +79,7 @@ download_file() { main() { check_dependencies - # Check if final files exist + # Check if final files exist # TODO: check the files, not the directory - wheatfox if [ -d "$UNZIP_DIR" ] && [ -f "$IMAGE_FILE" ]; then echo -e "${GREEN}All files already exist:\n- Image file: $IMAGE_FILE\n- Extracted directory: $UNZIP_DIR${NC}" exit 0 diff --git a/test/testcase/tc_insmod.txt b/platform/aarch64/qemu-gicv3/test/systemtest/testcase/tc_insmod.txt similarity index 100% rename from test/testcase/tc_insmod.txt rename to platform/aarch64/qemu-gicv3/test/systemtest/testcase/tc_insmod.txt diff --git a/test/testcase/tc_ls.txt b/platform/aarch64/qemu-gicv3/test/systemtest/testcase/tc_ls.txt similarity index 100% rename from test/testcase/tc_ls.txt rename to platform/aarch64/qemu-gicv3/test/systemtest/testcase/tc_ls.txt diff --git a/test/testcase/tc_pwd.txt b/platform/aarch64/qemu-gicv3/test/systemtest/testcase/tc_pwd.txt similarity index 100% rename from test/testcase/tc_pwd.txt rename to platform/aarch64/qemu-gicv3/test/systemtest/testcase/tc_pwd.txt diff --git a/test/testcase/tc_zone1_ls.txt b/platform/aarch64/qemu-gicv3/test/systemtest/testcase/tc_zone1_ls.txt similarity index 100% rename from test/testcase/tc_zone1_ls.txt rename to platform/aarch64/qemu-gicv3/test/systemtest/testcase/tc_zone1_ls.txt diff --git a/test/testcase/tc_zone1_start.txt b/platform/aarch64/qemu-gicv3/test/systemtest/testcase/tc_zone1_start.txt similarity index 100% rename from test/testcase/tc_zone1_start.txt rename to platform/aarch64/qemu-gicv3/test/systemtest/testcase/tc_zone1_start.txt diff --git a/test/testcase/tc_zone_list1.txt b/platform/aarch64/qemu-gicv3/test/systemtest/testcase/tc_zone_list1.txt similarity index 100% rename from test/testcase/tc_zone_list1.txt rename to platform/aarch64/qemu-gicv3/test/systemtest/testcase/tc_zone_list1.txt diff --git a/test/testcase/tc_zone_list2.txt b/platform/aarch64/qemu-gicv3/test/systemtest/testcase/tc_zone_list2.txt similarity index 100% rename from test/testcase/tc_zone_list2.txt rename to platform/aarch64/qemu-gicv3/test/systemtest/testcase/tc_zone_list2.txt diff --git a/test/textract_dmesg.sh b/platform/aarch64/qemu-gicv3/test/systemtest/textract_dmesg.sh similarity index 100% rename from test/textract_dmesg.sh rename to platform/aarch64/qemu-gicv3/test/systemtest/textract_dmesg.sh diff --git a/test/tresult.sh b/platform/aarch64/qemu-gicv3/test/systemtest/tresult.sh similarity index 69% rename from test/tresult.sh rename to platform/aarch64/qemu-gicv3/test/systemtest/tresult.sh index 8e3a2431..8f9e4b7f 100755 --- a/test/tresult.sh +++ b/platform/aarch64/qemu-gicv3/test/systemtest/tresult.sh @@ -2,24 +2,28 @@ # set -x # Define two arrays to store filenames from two lists + +TESTCASE_DIR="./platform/aarch64/qemu-gicv3/test/systemtest/testcase" +TESTRESULT_DIR="./platform/aarch64/qemu-gicv3/test/systemtest/testresult" + testcase_file_list=( - ./test/testcase/tc_ls.txt - ./test/testcase/tc_pwd.txt - ./test/testcase/tc_insmod.txt - # ./test/testcase/tc_zone1_start.txt - ./test/testcase/tc_zone1_ls.txt - ./test/testcase/tc_zone_list2.txt - # ./test/testcase/tc_zone_list1.txt + $TESTCASE_DIR/tc_ls.txt + $TESTCASE_DIR/tc_pwd.txt + $TESTCASE_DIR/tc_insmod.txt + # $TESTCASE_DIR/tc_zone1_start.txt + $TESTCASE_DIR/tc_zone1_ls.txt + $TESTCASE_DIR/tc_zone_list2.txt + # $TESTCASE_DIR/tc_zone_list1.txt ) testresult_file_list=( - ./test/testresult/test_ls.txt - ./test/testresult/test_pwd.txt - ./test/testresult/test_insmod.txt - # ./test/testresult/test_zone1_start.txt - ./test/testresult/test_zone1_ls.txt - ./test/testresult/test_zone_list2.txt - # ./test/testresult/test_zone_list1.txt + $TESTRESULT_DIR/test_ls.txt + $TESTRESULT_DIR/test_pwd.txt + $TESTRESULT_DIR/test_insmod.txt + # $TESTRESULT_DIR/test_zone1_start.txt + $TESTRESULT_DIR/test_zone1_ls.txt + $TESTRESULT_DIR/test_zone_list2.txt + # $TESTRESULT_DIR/test_zone_list1.txt ) testcase_name_list=( @@ -56,15 +60,15 @@ for ((i = 0; i < testcase_file_list_len; i++)); do # Output the result based on the exit status if [ "$exit_status" -eq 0 ]; then - echo "$testcase_name $testresult_file PASS" >> ./test/result.txt + echo "$testcase_name $testresult_file PASS" >> ./result.txt else fail_count=$((fail_count+1)) # Increment fail_count - echo "$testcase_name $testresult_file FAIL" >> ./test/result.txt + echo "$testcase_name $testresult_file FAIL" >> ./result.txt fi done -cat ./test/result.txt +cat ./result.txt # Format the output file content printf "\n%-17s | %-40s | %s\n" "test name" "test result file" "result" # Read the file content @@ -78,12 +82,12 @@ while IFS= read -r line; do # Format the output printf "%-17s | %-40s | %s\n" "$testname" "$testcase" "$result" fi -done < "./test/result.txt" +done < "./result.txt" printf "\n" # Delete the generated files -rm -v ./test/testresult/test_*.txt -rm -v ./test/result.txt +rm -v $TESTRESULT_DIR/test_*.txt +rm -v ./result.txt # Check if failcount is greater than 0 if [ "$fail_count" -gt 0 ]; then diff --git a/test/tstart.sh b/platform/aarch64/qemu-gicv3/test/systemtest/tstart.sh similarity index 100% rename from test/tstart.sh rename to platform/aarch64/qemu-gicv3/test/systemtest/tstart.sh diff --git a/src/platform/zcu102_aarch64.rs b/platform/aarch64/zcu102/board.rs similarity index 100% rename from src/platform/zcu102_aarch64.rs rename to platform/aarch64/zcu102/board.rs diff --git a/platform/aarch64/zcu102/cargo/config.template.toml b/platform/aarch64/zcu102/cargo/config.template.toml new file mode 100644 index 00000000..0cb32013 --- /dev/null +++ b/platform/aarch64/zcu102/cargo/config.template.toml @@ -0,0 +1,6 @@ +[target.aarch64-unknown-none] +rustflags = [ + "-Clink-arg=-Tplatform/__ARCH__/__BOARD__/linker.ld", + "-Ctarget-feature=+a53,+v8a,+strict-align,-neon,-fp-armv8", + "-Cforce-frame-pointers=yes", +] \ No newline at end of file diff --git a/platform/aarch64/zcu102/cargo/features b/platform/aarch64/zcu102/cargo/features new file mode 100644 index 00000000..c5fd26a0 --- /dev/null +++ b/platform/aarch64/zcu102/cargo/features @@ -0,0 +1,2 @@ +gicv2 +xuartps \ No newline at end of file diff --git a/platform/aarch64/zcu102/image/dts/Makefile b/platform/aarch64/zcu102/image/dts/Makefile new file mode 100644 index 00000000..2f795e7f --- /dev/null +++ b/platform/aarch64/zcu102/image/dts/Makefile @@ -0,0 +1,8 @@ +DTS_FILES := $(wildcard *.dts) +DTB_FILES := $(DTS_FILES:.dts=.dtb) + +all: $(DTB_FILES) +%.dtb: %.dts + dtc -I dts -O dtb $< -o $@ +clean: + rm -f $(DTB_FILES) \ No newline at end of file diff --git a/images/aarch64/devicetree/zcu102-root-aarch64.dts b/platform/aarch64/zcu102/image/dts/zone0.dts similarity index 99% rename from images/aarch64/devicetree/zcu102-root-aarch64.dts rename to platform/aarch64/zcu102/image/dts/zone0.dts index 9accfe59..acb890cc 100644 --- a/images/aarch64/devicetree/zcu102-root-aarch64.dts +++ b/platform/aarch64/zcu102/image/dts/zone0.dts @@ -373,4 +373,4 @@ // linux,initrd-end = <0x4800000>; stdout-path = "serial0:115200n8"; }; -}; +}; \ No newline at end of file diff --git a/images/aarch64/devicetree/zcu102-nonroot-aarch64.dts b/platform/aarch64/zcu102/image/dts/zone1-linux.dts similarity index 99% rename from images/aarch64/devicetree/zcu102-nonroot-aarch64.dts rename to platform/aarch64/zcu102/image/dts/zone1-linux.dts index 28bc94d1..a779d080 100644 --- a/images/aarch64/devicetree/zcu102-nonroot-aarch64.dts +++ b/platform/aarch64/zcu102/image/dts/zone1-linux.dts @@ -123,4 +123,4 @@ bootargs = "earlycon=virtio,mmio,0xff9e0000 console=hvc0 root=/dev/vda rootwait rw"; stdout-path = "/virtio_mmio@0xff9e0000"; }; -}; +}; \ No newline at end of file diff --git a/scripts/zcu102-aarch64-fit.its b/platform/aarch64/zcu102/image/its/fitImage.its similarity index 99% rename from scripts/zcu102-aarch64-fit.its rename to platform/aarch64/zcu102/image/its/fitImage.its index 7e4bd392..e972f6c7 100644 --- a/scripts/zcu102-aarch64-fit.its +++ b/platform/aarch64/zcu102/image/its/fitImage.its @@ -53,4 +53,4 @@ fdt = "root_dtb"; }; }; -}; +}; \ No newline at end of file diff --git a/platform/aarch64/zcu102/linker.ld b/platform/aarch64/zcu102/linker.ld new file mode 100644 index 00000000..4cd76ea3 --- /dev/null +++ b/platform/aarch64/zcu102/linker.ld @@ -0,0 +1,49 @@ +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/zcu102-aarch64.mk b/platform/aarch64/zcu102/platform.mk similarity index 93% rename from scripts/zcu102-aarch64.mk rename to platform/aarch64/zcu102/platform.mk index dbd51c1b..6ac656a2 100644 --- a/scripts/zcu102-aarch64.mk +++ b/platform/aarch64/zcu102/platform.mk @@ -29,7 +29,7 @@ ROOT_LINUX_IMAGE = $(PETALINUX_PROJECT_PATH)/images/linux/vmlinux ROOT_LINUX_IMAGE_BIN = $(ROOT_LINUX_IMAGE).bin ROOT_LINUX_ROOTFS = $(PETALINUX_PROJECT_PATH)/images/linux/rootfs.cpio.gz.u-boot # ROOT_LINUX_DTB = $(PETALINUX_PROJECT_PATH)/images/linux/system.dtb -ROOT_LINUX_DTB = $(shell readlink -f ./images/aarch64/devicetree/zcu102-root-aarch64.dtb) +ROOT_LINUX_DTB = $(shell readlink -f $(image_dir)/dts/zone0.dtb) ROOT_LINUX_SD_IMG = $(shell readlink -f ./sd.img) # notes on uboot FIT: @@ -64,12 +64,12 @@ GCC_OBJCOPY = aarch64-linux-gnu-objcopy .PHONY: dtb dtb: - make -C ./images/aarch64/devicetree + make -C $(image_dir)/dts .PHONY: gen-fit gen-fit: $(hvisor_bin) dtb - @if [ ! -f scripts/zcu102-aarch64-fit.its ]; then \ - echo "Error: ITS file scripts/zcu102-aarch64-fit.its not found."; \ + @if [ ! -f $(image_dir)/its/fitImage.its ]; then \ + echo "Error: ITS file not found at $(image_dir)/its/fitImage.its"; \ exit 1; \ fi $(OBJCOPY) $(hvisor_elf) --strip-all -O binary $(HVISOR_TMP_PATH) @@ -80,8 +80,8 @@ gen-fit: $(hvisor_bin) dtb -e "s|__ROOT_LINUX_ROOTFS__|$(ROOT_LINUX_ROOTFS)|g" \ -e "s|__ROOT_LINUX_DTB__|$(ROOT_LINUX_DTB)|g" \ -e "s|__HVISOR_TMP_PATH__|$(HVISOR_TMP_PATH)|g" \ - scripts/zcu102-aarch64-fit.its > temp-fit.its - @mkimage -f temp-fit.its $(TARGET_FIT_IMAGE) + $(image_dir)/its/fitImage.its > temp-fit.its + mkimage -f temp-fit.its $(TARGET_FIT_IMAGE) @echo "Generated FIT image: $(TARGET_FIT_IMAGE)" # "pl" is short for "petalinux" diff --git a/src/platform/ls3a5000_loongarch64.rs b/platform/loongarch64/ls3a5000/board.rs similarity index 98% rename from src/platform/ls3a5000_loongarch64.rs rename to platform/loongarch64/ls3a5000/board.rs index 801c78c0..f2b994e3 100644 --- a/src/platform/ls3a5000_loongarch64.rs +++ b/platform/loongarch64/ls3a5000/board.rs @@ -1,5 +1,7 @@ use crate::{arch::zone::HvArchZoneConfig, config::*}; +pub const BOARD_NAME: &str = "3a5000"; + pub const ROOT_ZONE_DTB_ADDR: u64 = 0x10000f000; pub const ROOT_ZONE_KERNEL_ADDR: u64 = 0x200000; pub const ROOT_ZONE_ENTRY: u64 = 0x9000000000e71000; diff --git a/platform/loongarch64/ls3a5000/cargo/config.template.toml b/platform/loongarch64/ls3a5000/cargo/config.template.toml new file mode 100644 index 00000000..5f7fa378 --- /dev/null +++ b/platform/loongarch64/ls3a5000/cargo/config.template.toml @@ -0,0 +1,6 @@ +[target.loongarch64-unknown-none] +linker = "loongarch64-unknown-linux-gnu-gcc" +rustflags = [ + "-Clink-arg=-Tplatform/__ARCH__/__BOARD__/linker.ld", + "-Cforce-frame-pointers=yes", +] \ No newline at end of file diff --git a/platform/loongarch64/ls3a5000/cargo/features b/platform/loongarch64/ls3a5000/cargo/features new file mode 100644 index 00000000..af5ca2ae --- /dev/null +++ b/platform/loongarch64/ls3a5000/cargo/features @@ -0,0 +1,2 @@ +loongson_7a2000 +loongson_uart \ No newline at end of file diff --git a/platform/loongarch64/ls3a5000/configs/zone1-linux.json b/platform/loongarch64/ls3a5000/configs/zone1-linux.json new file mode 100644 index 00000000..91d1928a --- /dev/null +++ b/platform/loongarch64/ls3a5000/configs/zone1-linux.json @@ -0,0 +1,45 @@ +{ + "arch": "loongarch64", + "name": "linux2", + "zone_id": 3, + "cpus": [ + 3 + ], + "memory_regions": [ + { + "type": "ram", + "physical_start": "0xc0000000", + "virtual_start": "0x00000000", + "size": "0x10000000" + }, + { + "type": "ram", + "physical_start": "0xd0000000", + "virtual_start": "0x90000000", + "size": "0x10000000" + }, + { + "type": "io", + "physical_start": "0x1fe00000", + "virtual_start": "0x1fe00000", + "size": "0x4000" + }, + { + "type": "virtio", + "physical_start": "0x30001000", + "virtual_start": "0x30001000", + "size": "0x200" + } + ], + "interrupts": [ + 4 + ], + "kernel_filepath": "/tool/vmlinux.bin", + "dtb_filepath": "/tool/test.bin", + "kernel_load_paddr": "0xc0200000", + "dtb_load_paddr": "0xc0000000", + "entry_point": "0x9000000000e75000", + "arch_config": { + "dummy": "0x1234" + } +} \ No newline at end of file diff --git a/platform/loongarch64/ls3a5000/configs/zone1-virtio.json b/platform/loongarch64/ls3a5000/configs/zone1-virtio.json new file mode 100644 index 00000000..8435566b --- /dev/null +++ b/platform/loongarch64/ls3a5000/configs/zone1-virtio.json @@ -0,0 +1,28 @@ +{ + "zones": [ + { + "id": 3, + "memory_region": [ + { + "zone0_ipa": "0xc0000000", + "zonex_ipa": "0x00000000", + "size": "0x10000000" + }, + { + "zone0_ipa": "0xd0000000", + "zonex_ipa": "0x90000000", + "size": "0x10000000" + } + ], + "devices": [ + { + "type": "console", + "addr": "0x30001000", + "len": "0x200", + "irq": 4, + "status": "enable" + } + ] + } + ] +} \ No newline at end of file diff --git a/platform/loongarch64/ls3a5000/image/dts/zone0.dts b/platform/loongarch64/ls3a5000/image/dts/zone0.dts new file mode 100644 index 00000000..038403c6 --- /dev/null +++ b/platform/loongarch64/ls3a5000/image/dts/zone0.dts @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2023 Loongson Technology Corporation Limited +* Modified for hvisor by wheatfox(enkerewpo@hotmail.com) syswonder.org 2024 +*/ + +/dts-v1/; + +#include "loongson-3a5000.dtsi" + +/ { + compatible = "loongson,ls3a5000-root", "loongson,ls3a5000"; + model = "Loongson-3A5000 hvisor root zone board"; + + aliases { + serial0 = &uart0; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs = "earlycon console=ttyS0,115200n8 initramfs_async=false rootwait debug"; + }; + + memory@200000 { + device_type = "memory"; + reg = <0 0x00200000 0 0x0ee00000 + 0 0x90000000 0 0x10000000 + 0 0xf0000000 0 0x10000000 + 0 0xc0000000 0 0x30000000 + >; + }; + + hvisor_device { + compatible = "hvisor"; + interrupt-parent = <&cpuintc>; + interrupts = <4>; + }; + + reserved-memory { + #address-cells = <0x02>; + #size-cells = <0x02>; + ranges; + nonroot0xc0000000 { + no-map; + reg = <0x00 0xc0000000 0x00 0x30000000>; + }; + }; +}; + +&uart0 { + status = "okay"; +}; \ No newline at end of file diff --git a/platform/loongarch64/ls3a5000/image/dts/zone1-linux.dts b/platform/loongarch64/ls3a5000/image/dts/zone1-linux.dts new file mode 100644 index 00000000..377116b2 --- /dev/null +++ b/platform/loongarch64/ls3a5000/image/dts/zone1-linux.dts @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2023 Loongson Technology Corporation Limited +* Modified for hvisor by wheatfox(enkerewpo@hotmail.com) syswonder.org 2024 +*/ + +/dts-v1/; + +#include "loongson-3a5000.dtsi" + +/ { + compatible = "loongson,ls3a5000-root", "loongson,ls3a5000"; + model = "Loongson-3A5000 hvisor nonroot zone board"; + + aliases { + serial0 = &uart0; + }; + + chosen { + // stdout-path = "serial0:115200n8"; + bootargs = "earlycon console=ttyS0,115200n8 initramfs_async=false rootwait debug"; + // stdout-path = "/virtio_mmio@30001000"; + // bootargs = "earlycon console=hvc0 rootwait debug"; + }; + + memory@200000 { + device_type = "memory"; + reg = <0 0x00200000 0 0x0ee00000 + 0 0x90000000 0 0x10000000 + >; + }; + + // virtio console + virtio_mmio@30001000 { + dma-coherent; + compatible = "virtio,mmio"; + interrupt-parent = <&cpuintc>; + interrupts = <4>;// = hwirq + reg = <0x0 0x30001000 0x0 0x200>; + status = "okay"; + }; +}; + +&uart0 { + status = "okay"; +}; \ No newline at end of file diff --git a/scripts/3a5000-loongarch64.ld b/platform/loongarch64/ls3a5000/linker.ld similarity index 100% rename from scripts/3a5000-loongarch64.ld rename to platform/loongarch64/ls3a5000/linker.ld diff --git a/scripts/3a5000-loongarch64.mk b/platform/loongarch64/ls3a5000/platform.mk similarity index 70% rename from scripts/3a5000-loongarch64.mk rename to platform/loongarch64/ls3a5000/platform.mk index 999b7fe4..2121f29b 100644 --- a/scripts/3a5000-loongarch64.mk +++ b/platform/loongarch64/ls3a5000/platform.mk @@ -1,5 +1,5 @@ # hvisor for loongarch64 makefile -# wheatfox(wheatfox17@icloud.com) 2024.6 +# wheatfox(enkerewpo@hotmail.com) 2024.6 # HVISOR ENTRY HVISOR_ENTRY_PA := 0x9000000080000000 @@ -11,12 +11,13 @@ HVISOR_ENTRY_PA := 0x9000000080000000 # 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 += -smp 4 -QEMU_ARGS += -m 2G -QEMU_ARGS += -nographic -QEMU_ARGS += -kernel $(hvisor_elf) +# 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 diff --git a/platform/loongarch64/ls3a6000/.gitkeep b/platform/loongarch64/ls3a6000/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/src/platform/qemu_riscv64.rs b/platform/riscv64/qemu-aia/board.rs similarity index 98% rename from src/platform/qemu_riscv64.rs rename to platform/riscv64/qemu-aia/board.rs index 052c90be..850d6750 100644 --- a/src/platform/qemu_riscv64.rs +++ b/platform/riscv64/qemu-aia/board.rs @@ -1,5 +1,7 @@ use crate::{arch::zone::HvArchZoneConfig, config::*}; +pub const BOARD_NAME: &str = "qemu"; + pub const PLIC_BASE: usize = 0xc000000; pub const APLIC_BASE: usize = 0xc000000; pub const PLIC_MAX_IRQ: usize = 1024; diff --git a/platform/riscv64/qemu-aia/cargo/config.template.toml b/platform/riscv64/qemu-aia/cargo/config.template.toml new file mode 100644 index 00000000..f5d5b55c --- /dev/null +++ b/platform/riscv64/qemu-aia/cargo/config.template.toml @@ -0,0 +1,6 @@ +[target.riscv64gc-unknown-none-elf] +runner = "platform/__ARCH__/__BOARD__/test/runner.sh" +rustflags = [ + "-Clink-arg=-Tplatform/__ARCH__/__BOARD__/linker.ld", + "-Cforce-frame-pointers=yes", +] \ No newline at end of file diff --git a/platform/riscv64/qemu-aia/cargo/features b/platform/riscv64/qemu-aia/cargo/features new file mode 100644 index 00000000..69267280 --- /dev/null +++ b/platform/riscv64/qemu-aia/cargo/features @@ -0,0 +1 @@ +aia \ No newline at end of file diff --git a/platform/riscv64/qemu-aia/configs/zone1-linux.json b/platform/riscv64/qemu-aia/configs/zone1-linux.json new file mode 100644 index 00000000..5a3fbd98 --- /dev/null +++ b/platform/riscv64/qemu-aia/configs/zone1-linux.json @@ -0,0 +1,37 @@ +{ + "arch": "riscv", + "name": "linux2", + "zone_id": 1, + "cpus": [3], + "memory_regions": [ + { + "type": "ram", + "physical_start": "0x83000000", + "virtual_start": "0x83000000", + "size": "0x0C000000" + }, + { + "type": "io", + "physical_start": "0x10007000", + "virtual_start": "0x10007000", + "size": "0x1000" + }, + { + "type": "io", + "physical_start": "0x10006000", + "virtual_start": "0x10006000", + "size": "0x1000" + } + ], + "interrupts": [6,7], + "kernel_filepath": "./Image", + "dtb_filepath": "./linux2.dtb", + "kernel_load_paddr": "0x84000000", + "dtb_load_paddr": "0x83000000", + "entry_point": "0x84000000", + "arch_config": { + "plic_base": "0xc000000", + "plic_size": "0x4000000" + }, + "ivc_configs": [] +} \ No newline at end of file diff --git a/platform/riscv64/qemu-aia/image/dts/Makefile b/platform/riscv64/qemu-aia/image/dts/Makefile new file mode 100644 index 00000000..2f795e7f --- /dev/null +++ b/platform/riscv64/qemu-aia/image/dts/Makefile @@ -0,0 +1,8 @@ +DTS_FILES := $(wildcard *.dts) +DTB_FILES := $(DTS_FILES:.dts=.dtb) + +all: $(DTB_FILES) +%.dtb: %.dts + dtc -I dts -O dtb $< -o $@ +clean: + rm -f $(DTB_FILES) \ No newline at end of file diff --git a/images/riscv64/devicetree/linux1-aia.dts b/platform/riscv64/qemu-aia/image/dts/zone0.dts similarity index 100% rename from images/riscv64/devicetree/linux1-aia.dts rename to platform/riscv64/qemu-aia/image/dts/zone0.dts diff --git a/images/riscv64/devicetree/linux2.dts b/platform/riscv64/qemu-aia/image/dts/zone1-linux.dts similarity index 96% rename from images/riscv64/devicetree/linux2.dts rename to platform/riscv64/qemu-aia/image/dts/zone1-linux.dts index 487cfeca..5d08f24b 100644 --- a/images/riscv64/devicetree/linux2.dts +++ b/platform/riscv64/qemu-aia/image/dts/zone1-linux.dts @@ -101,7 +101,7 @@ soc{ }; chosen { - bootargs = "root=/dev/vda rw earlycon console=hvc0"; + bootargs = "root=/dev/vda rootfstype=ext4 rw earlycon console=hvc0"; }; }; \ No newline at end of file diff --git a/scripts/qemu-riscv64.ld b/platform/riscv64/qemu-aia/linker.ld similarity index 100% rename from scripts/qemu-riscv64.ld rename to platform/riscv64/qemu-aia/linker.ld diff --git a/scripts/qemu-riscv64.mk b/platform/riscv64/qemu-aia/platform.mk similarity index 73% rename from scripts/qemu-riscv64.mk rename to platform/riscv64/qemu-aia/platform.mk index 8a1e9aac..f32722b0 100644 --- a/scripts/qemu-riscv64.mk +++ b/platform/riscv64/qemu-aia/platform.mk @@ -5,21 +5,12 @@ 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-aia-6.10 -zone0_dtb := $(image_dir)/devicetree/linux1.dtb -zone0_aia_dtb := $(image_dir)/devicetree/linux1-aia.dtb +zone0_kernel := $(image_dir)/kernel/Image +zone0_dtb := $(image_dir)/dts/zone0.dtb # zone1_kernel := $(image_dir)/kernel/Image # zone1_dtb := $(image_dir)/devicetree/linux.dtb -ifeq ($(findstring aia, $(FEATURES)),aia) - QEMU_ARGS := -machine virt,aclint=on,aia=aplic-imsic,aia-guests=1 - QEMU_ARGS += -device loader,file="$(zone0_aia_dtb)",addr=0x8f000000,force-raw=on - MESSAGE := "Note: Feature contains AIA" -else - QEMU_ARGS := -machine virt - QEMU_ARGS += -device loader,file="$(zone0_dtb)",addr=0x8f000000,force-raw=on - MESSAGE := "Note: Feature contains PLIC" -endif +QEMU_ARGS := -machine virt,aia=aplic-imsic,aia-guests=1 QEMU_ARGS += -bios default QEMU_ARGS += -cpu rv64 QEMU_ARGS += -smp 4 @@ -28,8 +19,7 @@ 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="$(zone1_aia_kernel)",addr=0x84000000,force-raw=on -# QEMU_ARGS += -device loader,file="$(zone1_aia_dtb)",addr=0x83000000,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 diff --git a/platform/riscv64/qemu-aia/test/runner.sh b/platform/riscv64/qemu-aia/test/runner.sh new file mode 100644 index 00000000..e69de29b diff --git a/platform/riscv64/qemu-plic/board.rs b/platform/riscv64/qemu-plic/board.rs new file mode 100644 index 00000000..850d6750 --- /dev/null +++ b/platform/riscv64/qemu-plic/board.rs @@ -0,0 +1,86 @@ +use crate::{arch::zone::HvArchZoneConfig, config::*}; + +pub const BOARD_NAME: &str = "qemu"; + +pub const PLIC_BASE: usize = 0xc000000; +pub const APLIC_BASE: usize = 0xc000000; +pub const PLIC_MAX_IRQ: usize = 1024; +pub const PLIC_GLOBAL_SIZE: usize = 0x200000; +pub const PLIC_TOTAL_SIZE: usize = 0x400000; +pub const PLIC_MAX_CONTEXT: usize = 64; +pub const PLIC_PRIORITY_BASE: usize = 0x0000; +pub const PLIC_PENDING_BASE: usize = 0x1000; +pub const PLIC_ENABLE_BASE: usize = 0x2000; + +pub const ROOT_ZONE_DTB_ADDR: u64 = 0x8f000000; +pub const ROOT_ZONE_KERNEL_ADDR: u64 = 0x90000000; +pub const ROOT_ZONE_ENTRY: u64 = 0x90000000; +pub const ROOT_ZONE_CPUS: u64 = (1 << 0) | (1 << 1) | (1 << 2); + +pub const ROOT_ZONE_NAME: &str = "root-linux"; + +pub const ROOT_ZONE_MEMORY_REGIONS: [HvConfigMemoryRegion; 9] = [ + HvConfigMemoryRegion { + mem_type: MEM_TYPE_RAM, + physical_start: 0x83000000, + virtual_start: 0x83000000, + size: 0x1D000000, + }, // ram + HvConfigMemoryRegion { + mem_type: MEM_TYPE_IO, + physical_start: 0x10000000, + virtual_start: 0x10000000, + size: 0x1000, + }, // serial + HvConfigMemoryRegion { + mem_type: MEM_TYPE_IO, + physical_start: 0x30000000, + virtual_start: 0x30000000, + size: 0x10000000, + }, // pci + HvConfigMemoryRegion { + mem_type: MEM_TYPE_IO, + physical_start: 0x10001000, + virtual_start: 0x10001000, + size: 0x1000, + }, // virtio + HvConfigMemoryRegion { + mem_type: MEM_TYPE_IO, + physical_start: 0x10002000, + virtual_start: 0x10002000, + size: 0x1000, + }, // virtio + HvConfigMemoryRegion { + mem_type: MEM_TYPE_IO, + physical_start: 0x10003000, + virtual_start: 0x10003000, + size: 0x1000, + }, // virtio + HvConfigMemoryRegion { + mem_type: MEM_TYPE_IO, + physical_start: 0x10004000, + virtual_start: 0x10004000, + size: 0x1000, + }, // virtio + HvConfigMemoryRegion { + mem_type: MEM_TYPE_IO, + physical_start: 0x10005000, + virtual_start: 0x10005000, + size: 0x1000, + }, // virtio + HvConfigMemoryRegion { + mem_type: MEM_TYPE_IO, + physical_start: 0x10008000, + virtual_start: 0x10008000, + size: 0x1000, + }, // virtio +]; + +pub const ROOT_ZONE_IRQS: [u32; 11] = [1, 2, 3, 4, 5, 8, 10, 33, 34, 35, 36]; // ARCH= riscv .It doesn't matter temporarily. + +pub const ROOT_ARCH_ZONE_CONFIG: HvArchZoneConfig = HvArchZoneConfig { + plic_base: 0xc000000, + plic_size: 0x4000000, + aplic_base: 0xd000000, + aplic_size: 0x8000, +}; diff --git a/platform/riscv64/qemu-plic/cargo/config.template.toml b/platform/riscv64/qemu-plic/cargo/config.template.toml new file mode 100644 index 00000000..f5d5b55c --- /dev/null +++ b/platform/riscv64/qemu-plic/cargo/config.template.toml @@ -0,0 +1,6 @@ +[target.riscv64gc-unknown-none-elf] +runner = "platform/__ARCH__/__BOARD__/test/runner.sh" +rustflags = [ + "-Clink-arg=-Tplatform/__ARCH__/__BOARD__/linker.ld", + "-Cforce-frame-pointers=yes", +] \ No newline at end of file diff --git a/platform/riscv64/qemu-plic/cargo/features b/platform/riscv64/qemu-plic/cargo/features new file mode 100644 index 00000000..caebca78 --- /dev/null +++ b/platform/riscv64/qemu-plic/cargo/features @@ -0,0 +1 @@ +plic \ No newline at end of file diff --git a/platform/riscv64/qemu-plic/configs/zone1-linux.json b/platform/riscv64/qemu-plic/configs/zone1-linux.json new file mode 100644 index 00000000..5a3fbd98 --- /dev/null +++ b/platform/riscv64/qemu-plic/configs/zone1-linux.json @@ -0,0 +1,37 @@ +{ + "arch": "riscv", + "name": "linux2", + "zone_id": 1, + "cpus": [3], + "memory_regions": [ + { + "type": "ram", + "physical_start": "0x83000000", + "virtual_start": "0x83000000", + "size": "0x0C000000" + }, + { + "type": "io", + "physical_start": "0x10007000", + "virtual_start": "0x10007000", + "size": "0x1000" + }, + { + "type": "io", + "physical_start": "0x10006000", + "virtual_start": "0x10006000", + "size": "0x1000" + } + ], + "interrupts": [6,7], + "kernel_filepath": "./Image", + "dtb_filepath": "./linux2.dtb", + "kernel_load_paddr": "0x84000000", + "dtb_load_paddr": "0x83000000", + "entry_point": "0x84000000", + "arch_config": { + "plic_base": "0xc000000", + "plic_size": "0x4000000" + }, + "ivc_configs": [] +} \ No newline at end of file diff --git a/platform/riscv64/qemu-plic/image/dts/Makefile b/platform/riscv64/qemu-plic/image/dts/Makefile new file mode 100644 index 00000000..2f795e7f --- /dev/null +++ b/platform/riscv64/qemu-plic/image/dts/Makefile @@ -0,0 +1,8 @@ +DTS_FILES := $(wildcard *.dts) +DTB_FILES := $(DTS_FILES:.dts=.dtb) + +all: $(DTB_FILES) +%.dtb: %.dts + dtc -I dts -O dtb $< -o $@ +clean: + rm -f $(DTB_FILES) \ No newline at end of file diff --git a/images/riscv64/devicetree/linux1.dts b/platform/riscv64/qemu-plic/image/dts/zone0.dts similarity index 84% rename from images/riscv64/devicetree/linux1.dts rename to platform/riscv64/qemu-plic/image/dts/zone0.dts index 84cdb0ee..d0880d64 100644 --- a/images/riscv64/devicetree/linux1.dts +++ b/platform/riscv64/qemu-plic/image/dts/zone0.dts @@ -82,8 +82,9 @@ compatible = "simple-bus"; ranges; plic: interrupt-controller@c000000 { - riscv,ndev = <60>; - reg = <0x0 0xc000000 0x0 0x4000000>; + phandle = <0x03>; + riscv,ndev = <0x5f>; + reg = <0x00 0xc000000 0x00 0x600000>; interrupts-extended = < &cpu0_intc 11 &cpu0_intc 9 &cpu1_intc 11 &cpu1_intc 9 @@ -102,7 +103,7 @@ }; 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>; + 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 0x3000000 0x04 0x00 0x04 0x00 0x04 0x00>; reg = <0x00 0x30000000 0x00 0x10000000>; dma-coherent; @@ -170,7 +171,7 @@ }; }; chosen { - bootargs = "root=/dev/vda rw earlycon console=ttyS0 init=/bin/bash"; + bootargs = "root=/dev/vda rw earlycon console=ttyS0"; }; }; diff --git a/platform/riscv64/qemu-plic/image/dts/zone1-linux.dts b/platform/riscv64/qemu-plic/image/dts/zone1-linux.dts new file mode 100644 index 00000000..5d08f24b --- /dev/null +++ b/platform/riscv64/qemu-plic/image/dts/zone1-linux.dts @@ -0,0 +1,107 @@ +/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 rootfstype=ext4 rw earlycon console=hvc0"; + }; + +}; \ No newline at end of file diff --git a/platform/riscv64/qemu-plic/linker.ld b/platform/riscv64/qemu-plic/linker.ld new file mode 100644 index 00000000..eb62b0fe --- /dev/null +++ b/platform/riscv64/qemu-plic/linker.ld @@ -0,0 +1,50 @@ +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/platform/riscv64/qemu-plic/platform.mk b/platform/riscv64/qemu-plic/platform.mk new file mode 100644 index 00000000..0ae991bf --- /dev/null +++ b/platform/riscv64/qemu-plic/platform.mk @@ -0,0 +1,52 @@ +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)/dts/zone0.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/platform/riscv64/qemu-plic/test/runner.sh b/platform/riscv64/qemu-plic/test/runner.sh new file mode 100644 index 00000000..e69de29b diff --git a/platform/x86_64/qemu/board.rs b/platform/x86_64/qemu/board.rs new file mode 100644 index 00000000..6c4fd6f7 --- /dev/null +++ b/platform/x86_64/qemu/board.rs @@ -0,0 +1,107 @@ +use crate::{ + arch::zone::HvArchZoneConfig, + config::*, + memory::{GuestPhysAddr, HostPhysAddr}, +}; + +pub const ROOT_ZONE_DTB_ADDR: u64 = 0x00000000; +pub const ROOT_ZONE_ENTRY: u64 = 0x8000; // 0x10_0000; +pub const ROOT_ZONE_KERNEL_ADDR: u64 = 0x500_0000; // 0x500_0000; +pub const ROOT_ZONE_SETUP_ADDR: GuestPhysAddr = 0xd000; +pub const ROOT_ZONE_BOOT_STACK: GuestPhysAddr = 0x7000; +pub const ROOT_ZONE_INITRD_ADDR: GuestPhysAddr = 0x1500_0000; +pub const ROOT_ZONE_CMDLINE_ADDR: GuestPhysAddr = 0xc000; +pub const ROOT_ZONE_CPUS: u64 = (1 << 0); + +pub const ROOT_ZONE_NAME: &str = "root-linux"; + +pub const ROOT_ZONE_MEMORY_REGIONS: [HvConfigMemoryRegion; 7] = [ + HvConfigMemoryRegion { + mem_type: MEM_TYPE_RAM, + physical_start: 0x500_0000, + virtual_start: 0x0, + size: 0x1_0000, + }, // ram + HvConfigMemoryRegion { + mem_type: MEM_TYPE_RAM, + physical_start: 0x501_0000, + virtual_start: 0x1_0000, + size: 0x14ff_0000, + }, // ram + HvConfigMemoryRegion { + mem_type: MEM_TYPE_RAM, + physical_start: 0x2020_0000, + virtual_start: 0x1520_0000, + size: 0x4000_0000, + }, // ram + HvConfigMemoryRegion { + mem_type: MEM_TYPE_RAM, + physical_start: 0x2000_0000, + virtual_start: 0x1500_0000, + size: 0x20_0000, + }, // ram + HvConfigMemoryRegion { + mem_type: MEM_TYPE_IO, + physical_start: 0xfec0_0000, + virtual_start: 0xfec0_0000, + size: 0x1000, + }, // io apic + HvConfigMemoryRegion { + mem_type: MEM_TYPE_IO, + physical_start: 0xfed0_0000, + virtual_start: 0xfed0_0000, + size: 0x1000, + }, // hpet + HvConfigMemoryRegion { + mem_type: MEM_TYPE_IO, + physical_start: 0xfee0_0000, + virtual_start: 0xfee0_0000, + size: 0x1000, + }, // local apic +]; + +pub const ROOT_ZONE_IRQS: [u32; 32] = [0; 32]; +pub const ROOT_ARCH_ZONE_CONFIG: HvArchZoneConfig = HvArchZoneConfig {}; + +// TODO: temp +pub const GUEST_PT1: GuestPhysAddr = 0x1000; +pub const GUEST_PT2: GuestPhysAddr = 0x2000; +pub const GUEST_ENTRY: GuestPhysAddr = 0x10_0000; +pub const GUEST_STACK_TOP: GuestPhysAddr = 0x7000; +pub const GUEST_PHYS_MEMORY_START: HostPhysAddr = 0x100_0000; + +pub fn gpa_as_mut_ptr(guest_paddr: GuestPhysAddr) -> *mut u8 { + let offset = ROOT_ZONE_KERNEL_ADDR as usize; + let host_vaddr = guest_paddr + offset; + host_vaddr as *mut u8 +} + +#[naked] +pub unsafe extern "C" fn test_guest() -> ! { + core::arch::asm!( + " + mov rax, 0 + mov rdi, 2 + mov rsi, 3 + mov rdx, 3 + mov rcx, 3 + 2: + vmcall + add rax, 1 + jmp 2b", + options(noreturn), + ); +} + +pub unsafe extern "C" fn test_guest_2() -> ! { + core::arch::asm!( + "vmcall", + inout("rax") 0 => _, + in("rdi") 2, + in("rsi") 3, + in("rdx") 3, + in("rcx") 3, + ); + core::arch::asm!("mov qword ptr [$0xffff233], $2333"); // panic + loop {} +} \ No newline at end of file diff --git a/platform/x86_64/qemu/cargo/config.template.toml b/platform/x86_64/qemu/cargo/config.template.toml new file mode 100644 index 00000000..a454e986 --- /dev/null +++ b/platform/x86_64/qemu/cargo/config.template.toml @@ -0,0 +1,10 @@ +[target.x86_64-unknown-none] +linker = "rust-lld" +rustflags = [ + "-Clink-arg=-Tplatform/__ARCH__/__BOARD__/linker.ld", + "-Clink-arg=-no-pie", + "-Clinker-flavor=ld.lld", + "-Cforce-frame-pointers=yes", + "-Ctarget-feature=-mmx,-sse,+soft-float", + "-Cno-redzone=yes", +] \ No newline at end of file diff --git a/platform/x86_64/qemu/cargo/features b/platform/x86_64/qemu/cargo/features new file mode 100644 index 00000000..e69de29b diff --git a/platform/x86_64/qemu/image/acpi/hpet.asl b/platform/x86_64/qemu/image/acpi/hpet.asl new file mode 100644 index 00000000..ae7416bc --- /dev/null +++ b/platform/x86_64/qemu/image/acpi/hpet.asl @@ -0,0 +1,36 @@ +/* +* HPET template +*/ +[0004] Signature : "HPET" +[0004] Table Length : 00000000 +[0001] Revision : 01 +[0001] Checksum : 00 +[0006] Oem ID : "DM " +[0008] Oem Table ID : "DMHPET " +[0004] Oem Revision : 00000001 +/* iasl will fill in the compiler ID/revision fields */ +[0004] Asl Compiler ID : "xxxx" +[0004] Asl Compiler Revision : 00000000 + +/* +[31:16] = PCI Vendor ID of 1st Timer Block (0x8086) +[15] = LegacyReplacement IRQ Routing Capable (0) +[14] = Reserved (0) +[13] = COUNT_SIZE_CAP counter size (32-bit=0) +[12:8] = Number of Comparators in 1st Timer Block (3-1=2) +[7:0] = Hardware Rev ID (1) +*/ +[0004] Hardware Block ID : 80860201 + +[0012] Timer Block Register : [Generic Address Structure] + [0001] Space ID : 00 [SystemMemory] + [0001] Bit Width : 00 + [0001] Bit Offset : 00 + [0001] Encoded Access Width : 00 [Undefined/Legacy] + [0008] Address : 00000000fed00000 + +[0001] Sequence Number : 00 +[0002] Minimum Clock Ticks : 0000 +[0004] Flags (decoded below) : 00000001 + 4K Page Protect : 1 + 64K Page Protect : 0 \ No newline at end of file diff --git a/platform/x86_64/qemu/image/acpi/madt.asl b/platform/x86_64/qemu/image/acpi/madt.asl new file mode 100644 index 00000000..3d413454 --- /dev/null +++ b/platform/x86_64/qemu/image/acpi/madt.asl @@ -0,0 +1,54 @@ +/* +* MADT template +*/ +[0004] Signature : "APIC" +[0004] Table Length : 00000000 +[0001] Revision : 01 +[0001] Checksum : 00 +[0006] Oem ID : "DM " +[0008] Oem Table ID : "DMMADT " +[0004] Oem Revision : 00000001 +/* iasl will fill in the compiler ID/revision fields */ +[0004] Asl Compiler ID : "xxxx" +[0004] Asl Compiler Revision : 00000000 +[0004] Local Apic Address : fee00000 +[0004] Flags (decoded below) : 00000001 + PC-AT Compatibility : 1 + +/* Processor Local APIC */ +[0001] Subtable Type : 00 +[0001] Length : 08 +[0001] Processor ID : 00 +[0001] Local Apic ID : 00 +[0004] Flags (decoded below) : 00000001 + Processor Enabled : 1 + Runtime Online Capable : 0 + +/* IO APIC */ +[0001] Subtable Type : 01 +[0001] Length : 0C +[0001] I/O Apic ID : 00 +[0001] Reserved : 00 +[0004] Address : fec00000 +[0004] Interrupt : 00000000 + +/* Interrupt Source Override */ +/* Legacy IRQ0 is connected to pin 2 of the IOAPIC +[0001] Subtable Type : 02 +[0001] Length : 0A +[0001] Bus : 00 +[0001] Source : 00 +[0004] Interrupt : 00000002 +[0002] Flags (decoded below) : 0000 + Polarity : 0 + Trigger Mode : 0 */ + +/* Local APIC NMI Structure */ +/* Connected to LINT1 on all CPUs +[0001] Subtable Type : 04 +[0001] Length : 06 +[0001] Processor ID : ff +[0002] Flags (decoded below) : 0000 + Polarity : 0 + Trigger Mode : 0 +[0001] Interrupt Input LINT : 01 */ \ No newline at end of file diff --git a/platform/x86_64/qemu/image/acpi/rsdp.asl b/platform/x86_64/qemu/image/acpi/rsdp.asl new file mode 100644 index 00000000..cbf1120f --- /dev/null +++ b/platform/x86_64/qemu/image/acpi/rsdp.asl @@ -0,0 +1,12 @@ +/* +* RSDP template +*/ +[0008] Signature : "RSD PTR " +[0001] Checksum : 00 +[0006] Oem ID : "DM " +[0001] Revision : 02 +[0004] RSDT Address : 000f2440 +[0004] Length : 00000024 +[0008] XSDT Address : 00000000000f2480 +[0001] Extended Checksum : 00 +[0003] Reserved : 000000 \ No newline at end of file diff --git a/platform/x86_64/qemu/image/acpi/rsdt.asl b/platform/x86_64/qemu/image/acpi/rsdt.asl new file mode 100644 index 00000000..4d778ae7 --- /dev/null +++ b/platform/x86_64/qemu/image/acpi/rsdt.asl @@ -0,0 +1,18 @@ +/* +* RSDT template +*/ +[0004] Signature : "RSDT" +[0004] Table Length : 00000000 +[0001] Revision : 01 +[0001] Checksum : 00 +[0006] Oem ID : "DM " +[0008] Oem Table ID : "DMRSDT " +[0004] Oem Revision : 00000001 +/* iasl will fill in the compiler ID/revision fields */ +[0004] Asl Compiler ID : "xxxx" +[0004] Asl Compiler Revision : 00000000 + +/* MADT */ +[0004] ACPI Table Address : 000f2500 +/* HPET */ +[0004] ACPI Table Address : 000f2740 \ No newline at end of file diff --git a/platform/x86_64/qemu/image/acpi/xsdt.asl b/platform/x86_64/qemu/image/acpi/xsdt.asl new file mode 100644 index 00000000..f00ddf50 --- /dev/null +++ b/platform/x86_64/qemu/image/acpi/xsdt.asl @@ -0,0 +1,18 @@ +/* +* XSDT template +*/ +[0004] Signature : "XSDT" +[0004] Table Length : 00000000 +[0001] Revision : 01 +[0001] Checksum : 00 +[0006] Oem ID : "DM " +[0008] Oem Table ID : "DMXSDT " +[0004] Oem Revision : 00000001 +/* iasl will fill in the compiler ID/revision fields */ +[0004] Asl Compiler ID : "xxxx" +[0004] Asl Compiler Revision : 00000000 + +/* MADT */ +[0004] ACPI Table Address : 000f2500 +/* HPET */ +[0004] ACPI Table Address : 000f2740 \ No newline at end of file diff --git a/platform/x86_64/qemu/linker.ld b/platform/x86_64/qemu/linker.ld new file mode 100644 index 00000000..2b782f28 --- /dev/null +++ b/platform/x86_64/qemu/linker.ld @@ -0,0 +1,52 @@ +ENTRY(arch_entry) +BASE_ADDRESS = 0xffffff8000200000; + +SECTIONS +{ + . = BASE_ADDRESS; + skernel = .; + + stext = .; + .text : { + *(.text.entry) + *(.text.entry32) + *(.text.entry64) + *(.text .text.*) + } + + . = ALIGN(4K); + etext = .; + srodata = .; + .rodata : { + *(.rodata .rodata.*) + *(.srodata .srodata.*) + } + + . = ALIGN(4K); + erodata = .; + sdata = .; + .data : { + *(.data.entry_page_table) + *(.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/platform/x86_64/qemu/platform.mk b/platform/x86_64/qemu/platform.mk new file mode 100644 index 00000000..8abf8ebb --- /dev/null +++ b/platform/x86_64/qemu/platform.mk @@ -0,0 +1,50 @@ +QEMU := qemu-system-x86_64 + +acpi_asl_dir := scripts/x86_64/acpi +acpi_aml_dir := $(image_dir)/acpi + +zone0_bios := $(image_dir)/rvm-bios.bin +zone0_kernel := $(image_dir)/nimbos.bin + +zone0_image := $(image_dir)/bzImage +zone0_setup := $(image_dir)/setup.bin +zone0_vmlinux := $(image_dir)/vmlinux.bin +zone0_initrd := $(image_dir)/initramfs.cpio.gz +zone0_boot16 := $(image_dir)/boot16.bin + +aml_hpet := $(acpi_aml_dir)/hpet.aml +aml_madt := $(acpi_aml_dir)/madt.aml +aml_rsdp := $(acpi_aml_dir)/rsdp.aml +aml_rsdt := $(acpi_aml_dir)/rsdt.aml +aml_xsdt := $(acpi_aml_dir)/xsdt.aml + +QEMU_ARGS := -machine q35 +QEMU_ARGS += -cpu host,+x2apic -accel kvm +QEMU_ARGS += -smp 4 +QEMU_ARGS += -serial mon:stdio +QEMU_ARGS += -m 2G +QEMU_ARGS += -nographic + +QEMU_ARGS += -kernel $(hvisor_elf) +# QEMU_ARGS += -device loader,file="$(zone0_bios)",addr=0x5008000,force-raw=on +# QEMU_ARGS += -device loader,file="$(zone0_kernel)",addr=0x5200000,force-raw=on + +QEMU_ARGS += -device loader,file="$(zone0_boot16)",addr=0x5008000,force-raw=on +QEMU_ARGS += -device loader,file="$(zone0_setup)",addr=0x500d000,force-raw=on +QEMU_ARGS += -device loader,file="$(zone0_vmlinux)",addr=0x5100000,force-raw=on +QEMU_ARGS += -device loader,file="$(zone0_initrd)",addr=0x20000000,force-raw=on +QEMU_ARGS += -append "initrd_size=$(shell stat -c%s $(zone0_initrd))" + +QEMU_ARGS += -device loader,file="$(aml_rsdp)",addr=0x50f2400,force-raw=on +QEMU_ARGS += -device loader,file="$(aml_rsdt)",addr=0x50f2440,force-raw=on +QEMU_ARGS += -device loader,file="$(aml_xsdt)",addr=0x50f2480,force-raw=on +QEMU_ARGS += -device loader,file="$(aml_madt)",addr=0x50f2500,force-raw=on +QEMU_ARGS += -device loader,file="$(aml_hpet)",addr=0x50f2740,force-raw=on + +$(hvisor_bin): elf aml + $(OBJCOPY) $(hvisor_elf) --strip-all -O binary $@ + +aml: $(aml_hpet) $(aml_madt) $(aml_rsdp) $(aml_rsdt) $(aml_xsdt) + +$(acpi_aml_dir)/%.aml: $(acpi_asl_dir)/%.asl + iasl -p $@ $< \ No newline at end of file diff --git a/platform/x86_64/qemu/test/runner.sh b/platform/x86_64/qemu/test/runner.sh new file mode 100644 index 00000000..e69de29b diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 38e241c2..05f0010c 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,4 @@ [toolchain] profile = "minimal" -# use the nightly version of the last stable toolchain, see -channel = "nightly-2023-12-28" +channel = "nightly-2024-05-05" components = ["rust-src", "llvm-tools-preview", "rustfmt", "clippy"] \ No newline at end of file diff --git a/src/arch/aarch64/mmu.rs b/src/arch/aarch64/mmu.rs index c96478a5..1cd4fddb 100644 --- a/src/arch/aarch64/mmu.rs +++ b/src/arch/aarch64/mmu.rs @@ -144,7 +144,7 @@ pub extern "C" fn boot_pt_init(l0_pt: &mut PageTables, l1_pt: &mut PageTables) { memset(l1_pt_entry as *mut u8, 0, PAGE_SIZE); } cfg_if! { - if #[cfg(all(feature = "platform_qemu", target_arch = "aarch64"))] { + if #[cfg(feature = "pt_layout_qemu")] { l0_pt.entry[0] = PTEDescriptor::new(0x0, MemoryType::Device, PTEType::Block); for i in 1..ENTRY_PER_PAGE { l0_pt.entry[i] = PTEDescriptor::new(0x40000000*i, MemoryType::Normal, PTEType::Block); diff --git a/src/arch/riscv64/trap.rs b/src/arch/riscv64/trap.rs index 890dbb9c..97ec7ade 100644 --- a/src/arch/riscv64/trap.rs +++ b/src/arch/riscv64/trap.rs @@ -8,7 +8,7 @@ use crate::device::irqchip::aia::aplic::{host_aplic, vaplic_emul_handler}; use crate::device::irqchip::plic::{host_plic, vplic_global_emul_handler, vplic_hart_emul_handler}; use crate::event::check_events; use crate::memory::{GuestPhysAddr, HostPhysAddr}; -use crate::platform::qemu_riscv64::*; +use crate::platform::__board::*; use core::arch::{asm, global_asm}; use riscv::register::mtvec::TrapMode; use riscv::register::stvec; diff --git a/src/config.rs b/src/config.rs index 86916ba1..b1fae63d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -3,9 +3,6 @@ use spin::Once; use crate::{arch::zone::HvArchZoneConfig, platform}; -#[cfg(test)] -mod tests; - pub const MEM_TYPE_RAM: u32 = 0; pub const MEM_TYPE_IO: u32 = 1; pub const MEM_TYPE_VIRTIO: u32 = 2; diff --git a/src/config/tests.rs b/src/config/tests.rs deleted file mode 100644 index 46545be5..00000000 --- a/src/config/tests.rs +++ /dev/null @@ -1,6 +0,0 @@ -use super::*; - -#[test_case] -fn test_simple_config() { - // TODO: rewrite test with new gicv2 and gicv3 config system -} diff --git a/src/device/irqchip/plic/mod.rs b/src/device/irqchip/plic/mod.rs index 918cd52e..c6e11275 100644 --- a/src/device/irqchip/plic/mod.rs +++ b/src/device/irqchip/plic/mod.rs @@ -1,6 +1,6 @@ use crate::config::root_zone_config; use crate::memory::GuestPhysAddr; -use crate::platform::qemu_riscv64::*; +use crate::platform::__board::*; use crate::zone::Zone; use crate::{arch::cpu::ArchCpu, percpu::this_cpu_data}; use riscv::register::hvip; diff --git a/src/device/uart/mod.rs b/src/device/uart/mod.rs index 83788269..e1a81479 100644 --- a/src/device/uart/mod.rs +++ b/src/device/uart/mod.rs @@ -1,25 +1,24 @@ -#[cfg(all(feature = "platform_qemu", target_arch = "aarch64"))] -mod pl011; +// we specified the driver for each platform in the FEATURES environment variable. -#[cfg(all(feature = "platform_qemu", target_arch = "aarch64"))] +#[cfg(all(feature = "pl011", target_arch = "aarch64"))] +mod pl011; +#[cfg(all(feature = "pl011", target_arch = "aarch64"))] pub use pl011::{console_getchar, console_putchar}; -#[cfg(all(feature = "platform_imx8mp", target_arch = "aarch64"))] +#[cfg(all(feature = "imx_uart", target_arch = "aarch64"))] mod imx_uart; -#[cfg(all(feature = "platform_zcu102", target_arch = "aarch64"))] -mod xuartps; +#[cfg(all(feature = "imx_uart", target_arch = "aarch64"))] +pub use imx_uart::{console_getchar, console_putchar}; -#[cfg(all(feature = "platform_zcu102", target_arch = "aarch64"))] +#[cfg(all(feature = "xuartps", target_arch = "aarch64"))] +mod xuartps; +#[cfg(all(feature = "xuartps", target_arch = "aarch64"))] pub use xuartps::{console_getchar, console_putchar}; -#[cfg(all(feature = "platform_imx8mp", target_arch = "aarch64"))] -pub use imx_uart::{console_getchar, console_putchar}; - #[cfg(target_arch = "riscv64")] pub use crate::arch::riscv64::sbi::{console_getchar, console_putchar}; -#[cfg(target_arch = "loongarch64")] +#[cfg(all(feature = "loongson_uart", target_arch = "loongarch64"))] mod loongson_uart; - -#[cfg(target_arch = "loongarch64")] +#[cfg(all(feature = "loongson_uart", target_arch = "loongarch64"))] pub use loongson_uart::{console_getchar, console_putchar}; diff --git a/src/event.rs b/src/event.rs index 0ffb0ba7..47fe3c4a 100644 --- a/src/event.rs +++ b/src/event.rs @@ -9,9 +9,6 @@ use crate::{ use alloc::{collections::VecDeque, vec::Vec}; use spin::{Mutex, Once}; -#[cfg(test)] -mod tests; - pub const IPI_EVENT_WAKEUP: usize = 0; pub const IPI_EVENT_SHUTDOWN: usize = 1; pub const IPI_EVENT_VIRTIO_INJECT_IRQ: usize = 2; @@ -134,3 +131,10 @@ pub fn send_event(cpu_id: usize, ipi_int_id: usize, event_id: usize) { add_event(cpu_id, event_id); arch_send_event(cpu_id as _, ipi_int_id as _); } + +#[test_case] +fn test_simple_send_event() { + init(1); + send_event(0, 0, IPI_EVENT_WAKEUP); + assert_eq!(fetch_event(0), Some(IPI_EVENT_WAKEUP)); +} diff --git a/src/event/tests.rs b/src/event/tests.rs deleted file mode 100644 index 8ed94ce6..00000000 --- a/src/event/tests.rs +++ /dev/null @@ -1,8 +0,0 @@ -use super::*; - -#[test_case] -fn test_simple_send_event() { - init(1); - send_event(0, 0, IPI_EVENT_WAKEUP); - assert_eq!(fetch_event(0), Some(IPI_EVENT_WAKEUP)); -} diff --git a/src/main.rs b/src/main.rs index c46b45c9..5287c27e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,16 +8,13 @@ //! - [`device`]: Device management //! - [`arch`]: Architecture's related -#![no_std] // 禁用标准库链接 +#![no_std] #![no_main] -// 不使用main入口,使用自己定义实际入口_start,因为我们还没有初始化堆栈指针 #![feature(asm_const)] #![feature(naked_functions)] -// surpport naked function // #![feature(core_panic)] -// 支持内联汇编 -// #![deny(warnings, missing_docs)] // 将warnings作为error - +// #![deny(warnings, missing_docs)] +#![feature(proc_macro_hygiene)] // unittest #![feature(custom_test_frameworks)] #![test_runner(crate::tests::test_main)] @@ -50,6 +47,8 @@ mod zone; mod ivc; mod pci; + +#[cfg(test)] mod tests; #[cfg(target_arch = "aarch64")] @@ -61,7 +60,7 @@ use core::sync::atomic::{AtomicI32, AtomicU32, Ordering}; use percpu::PerCpu; use zone::zone_create; -#[cfg(all(feature = "platform_qemu", target_arch = "aarch64"))] +#[cfg(all(feature = "iommu", target_arch = "aarch64"))] use crate::arch::iommu::iommu_init; static INITED_CPUS: AtomicU32 = AtomicU32::new(0); @@ -118,7 +117,7 @@ fn primary_init_early() { device::irqchip::primary_init_early(); // crate::arch::mm::init_hv_page_table().unwrap(); - #[cfg(all(feature = "platform_qemu", target_arch = "aarch64"))] + #[cfg(all(feature = "iommu", target_arch = "aarch64"))] iommu_init(); #[cfg(not(test))] diff --git a/src/panic.rs b/src/panic.rs index a4618f35..93ebfa2c 100644 --- a/src/panic.rs +++ b/src/panic.rs @@ -1,13 +1,15 @@ +#[cfg(test)] use crate::tests::*; + use core::panic::PanicInfo; #[panic_handler] fn on_panic(info: &PanicInfo) -> ! { error!("panic occurred: {:#?}", info); - if cfg!(test) { + #[cfg(test)] + { error!("panic occurred when running cargo test, quitting qemu"); - #[cfg(test)] crate::tests::quit_qemu(HvUnitTestResult::Failed); } loop {} diff --git a/src/pci/pci.rs b/src/pci/pci.rs index 18fe304f..d27058b6 100644 --- a/src/pci/pci.rs +++ b/src/pci/pci.rs @@ -23,7 +23,7 @@ use super::{ NUM_BAR_REGS_TYPE1, PHANTOM_DEV_HEADER, }; -#[cfg(all(feature = "platform_qemu", target_arch = "aarch64"))] +#[cfg(all(feature = "iommu", target_arch = "aarch64"))] use crate::arch::iommu::iommu_add_device; #[derive(Debug)] @@ -138,7 +138,7 @@ impl Zone { self.id, alloc_pci_devs[idx] ); self.pciroot.alloc_devs.push(alloc_pci_devs[idx] as _); - #[cfg(all(feature = "platform_qemu", target_arch = "aarch64"))] + #[cfg(all(feature = "iommu", target_arch = "aarch64"))] if alloc_pci_devs[idx] != 0 { iommu_add_device(self.id, alloc_pci_devs[idx] as _); } diff --git a/src/percpu.rs b/src/percpu.rs index 911473a0..cb080ae4 100644 --- a/src/percpu.rs +++ b/src/percpu.rs @@ -12,9 +12,6 @@ use core::sync::atomic::Ordering; // global_asm!(include_str!("./arch/aarch64/page_table.S"),); -#[cfg(test)] -mod tests; - #[repr(C)] pub struct PerCpu { pub id: usize, @@ -122,3 +119,25 @@ impl CpuSet { (0..=self.max_cpu_id).filter(move |&i| self.contains_cpu(i) && i != id) } } + +#[test_case] +fn test_cpuset() { + let mut cpuset = CpuSet::new(3, 0b1010); + assert_eq!(cpuset.contains_cpu(0), false); + assert_eq!(cpuset.contains_cpu(1), true); + assert_eq!(cpuset.contains_cpu(2), false); + assert_eq!(cpuset.contains_cpu(3), true); + cpuset.set_bit(0); + assert_eq!(cpuset.contains_cpu(0), true); + assert_eq!(cpuset.contains_cpu(1), true); + assert_eq!(cpuset.contains_cpu(2), false); + assert_eq!(cpuset.contains_cpu(3), true); + cpuset.clear_bit(1); + assert_eq!(cpuset.contains_cpu(0), true); + assert_eq!(cpuset.contains_cpu(1), false); + assert_eq!(cpuset.contains_cpu(2), false); + assert_eq!(cpuset.contains_cpu(3), true); + assert_eq!(cpuset.first_cpu(), Some(0)); + assert_eq!(cpuset.iter().collect::>(), vec![0, 3]); + assert_eq!(cpuset.iter_except(0).collect::>(), vec![3]); +} diff --git a/src/percpu/tests.rs b/src/percpu/tests.rs deleted file mode 100644 index d718bfeb..00000000 --- a/src/percpu/tests.rs +++ /dev/null @@ -1,23 +0,0 @@ -use super::*; - -#[test_case] -fn test_cpuset() { - let mut cpuset = CpuSet::new(3, 0b1010); - assert_eq!(cpuset.contains_cpu(0), false); - assert_eq!(cpuset.contains_cpu(1), true); - assert_eq!(cpuset.contains_cpu(2), false); - assert_eq!(cpuset.contains_cpu(3), true); - cpuset.set_bit(0); - assert_eq!(cpuset.contains_cpu(0), true); - assert_eq!(cpuset.contains_cpu(1), true); - assert_eq!(cpuset.contains_cpu(2), false); - assert_eq!(cpuset.contains_cpu(3), true); - cpuset.clear_bit(1); - assert_eq!(cpuset.contains_cpu(0), true); - assert_eq!(cpuset.contains_cpu(1), false); - assert_eq!(cpuset.contains_cpu(2), false); - assert_eq!(cpuset.contains_cpu(3), true); - assert_eq!(cpuset.first_cpu(), Some(0)); - assert_eq!(cpuset.iter().collect::>(), vec![0, 3]); - assert_eq!(cpuset.iter_except(0).collect::>(), vec![3]); -} diff --git a/src/platform/mod.rs b/src/platform/mod.rs index d2a17cf2..fcf7f331 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -6,35 +6,8 @@ use crate::{ consts::INVALID_ADDRESS, }; -#[cfg(all(feature = "platform_qemu", target_arch = "riscv64"))] -pub mod qemu_riscv64; - -#[cfg(all(feature = "platform_qemu", target_arch = "riscv64"))] -use qemu_riscv64::*; - -#[cfg(all(feature = "platform_qemu", target_arch = "aarch64"))] -pub mod qemu_aarch64; - -#[cfg(all(feature = "platform_qemu", target_arch = "aarch64"))] -pub use qemu_aarch64::*; - -#[cfg(all(feature = "platform_imx8mp", target_arch = "aarch64"))] -pub mod imx8mp_aarch64; - -#[cfg(all(feature = "platform_imx8mp", target_arch = "aarch64"))] -use imx8mp_aarch64::*; - -#[cfg(all(feature = "platform_zcu102", target_arch = "aarch64"))] -pub mod zcu102_aarch64; - -#[cfg(all(feature = "platform_zcu102", target_arch = "aarch64"))] -pub use zcu102_aarch64::*; - -#[cfg(target_arch = "loongarch64")] -pub mod ls3a5000_loongarch64; - -#[cfg(target_arch = "loongarch64")] -pub use ls3a5000_loongarch64::*; +pub mod __board; // riscv64 uses some private PLIC constants in board.rs ... so we have to `pub` it - wheatfox +pub use __board::*; pub fn platform_root_zone_config() -> HvZoneConfig { // fill zero for memory regions and interrupts @@ -65,7 +38,7 @@ pub fn platform_root_zone_config() -> HvZoneConfig { let mut pci_devs = [0; CONFIG_MAX_PCI_DEV]; let mut root_pci_cfg = HvPciConfig::new_empty(); let mut num_pci_devs: u64 = 0; - #[cfg(all(feature = "platform_qemu", target_arch = "aarch64"))] + #[cfg(all(feature = "pci", target_arch = "aarch64"))] { pci_devs[..ROOT_PCI_DEVS.len()].copy_from_slice(&ROOT_PCI_DEVS); root_pci_cfg = ROOT_PCI_CONFIG; diff --git a/src/zone.rs b/src/zone.rs index f2db2ee5..de927046 100644 --- a/src/zone.rs +++ b/src/zone.rs @@ -16,9 +16,6 @@ use crate::memory::{MMIOConfig, MMIOHandler, MMIORegion, MemorySet}; use crate::percpu::{get_cpu_data, this_zone, CpuSet}; use core::panic; -#[cfg(test)] -pub mod tests; - pub struct Zone { pub name: [u8; CONFIG_NAME_MAXLEN], pub id: usize, @@ -187,7 +184,7 @@ pub fn zone_create(config: &HvZoneConfig) -> HvResult>> { zone.irq_bitmap_init(config.interrupts()); #[cfg(target_arch = "aarch64")] zone.ivc_init(config.ivc_config()); - #[cfg(all(feature = "platform_qemu", target_arch = "aarch64"))] + #[cfg(all(feature = "pci", target_arch = "aarch64"))] zone.pci_init( &config.pci_config, config.num_pci_devs as _, @@ -235,3 +232,18 @@ pub struct ZoneInfo { cpus: u64, name: [u8; CONFIG_NAME_MAXLEN], } + +#[test_case] +fn test_add_and_remove_zone() { + let zone_count = 50; + let zone_count_before = ZONE_LIST.read().len(); + for i in 0..zone_count { + let u8name_array = [i as u8; CONFIG_NAME_MAXLEN]; + let zone = Zone::new(i, &u8name_array); + ZONE_LIST.write().push(Arc::new(RwLock::new(zone))); + } + for i in 0..zone_count { + remove_zone(i); + } + assert_eq!(ZONE_LIST.read().len(), zone_count_before); +} diff --git a/src/zone/tests.rs b/src/zone/tests.rs deleted file mode 100644 index 1c2f39ff..00000000 --- a/src/zone/tests.rs +++ /dev/null @@ -1,18 +0,0 @@ -use super::*; -use alloc::sync::Arc; -use spin::RwLock; - -#[test_case] -fn test_add_and_remove_zone() { - let zone_count = 50; - let zone_count_before = ZONE_LIST.read().len(); - for i in 0..zone_count { - let u8name_array = [i as u8; CONFIG_NAME_MAXLEN]; - let zone = Zone::new(i, &u8name_array); - ZONE_LIST.write().push(Arc::new(RwLock::new(zone))); - } - for i in 0..zone_count { - remove_zone(i); - } - assert_eq!(ZONE_LIST.read().len(), zone_count_before); -} diff --git a/tools/gen_cargo_config.sh b/tools/gen_cargo_config.sh new file mode 100755 index 00000000..961b4be5 --- /dev/null +++ b/tools/gen_cargo_config.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +set -e + +CONFIG_TOML=".cargo/config.toml" +echo "" > $CONFIG_TOML + +function find_hvisor_src { + # get the directory which contains CHANGELOG.md and "hvisor" in the file contents + # this is the root of the hvisor source tree, return the absolute path + ret=$(find . -name CHANGELOG.md -exec grep -q hvisor {} \; -print -quit) + if [ -z "$ret" ]; then + echo "Could not find hvisor source tree" + exit 1 + fi + echo $(dirname $ret) +} + +CONFIG_TOML_TEMPLATE="platform/$ARCH/$BOARD/cargo/config.template.toml" +CONFIG_TOML_TEMPLATE=$(realpath $CONFIG_TOML_TEMPLATE) +TEMPLATE=$(cat $CONFIG_TOML_TEMPLATE) +LD_SCRIPT="platform/$ARCH/$BOARD/linker.ld" +LD_SCRIPT=$(realpath $LD_SCRIPT) +HVISOR_SRC=$(realpath $(find_hvisor_src)) +HOST_ARCH=$(uname -m) +OS=$(uname -s) +OS_VERSION=$(uname -r) +DISTRO=unknown +if [ -f /etc/os-release ]; then + DISTRO=$(grep '^ID=' /etc/os-release | cut -d= -f2) +fi + +echo "# Generated by gen_cargo_config.sh at $(date) ($(whoami)@$(hostname))" >> $CONFIG_TOML +echo "# BASH_VERSION = $BASH_VERSION" >> $CONFIG_TOML +echo "# HOST_ARCH = $HOST_ARCH" >> $CONFIG_TOML +echo "# OS_INFO = $OS $OS_VERSION $DISTRO" >> $CONFIG_TOML +echo "# ARCH = $ARCH" >> $CONFIG_TOML +echo "# BOARD = $BOARD" >> $CONFIG_TOML +echo "# FEATURES = $FEATURES" >> $CONFIG_TOML +echo "# HVISOR_SRC = $HVISOR_SRC" >> $CONFIG_TOML +echo "# LD_SCRIPT = $LD_SCRIPT" >> $CONFIG_TOML +echo "# TEMPLATE = $CONFIG_TOML_TEMPLATE" >> $CONFIG_TOML +echo "" >> $CONFIG_TOML + +# place holders: __XXX__ -> XXX +TEMPLATE=$(echo "$TEMPLATE" | sed -e 's/__ARCH__/'"$ARCH"'/g') +TEMPLATE=$(echo "$TEMPLATE" | sed -e 's/__BOARD__/'"$BOARD"'/g') + +echo "$TEMPLATE" >> $CONFIG_TOML + +# also generate a .config file in the HVISOR_SRC directory +CONFIG_FILE="$HVISOR_SRC/.config" +echo "ARCH=$ARCH" > $CONFIG_FILE +echo "BOARD=$BOARD" >> $CONFIG_FILE +echo "BID=$ARCH/$BOARD" >> $CONFIG_FILE +echo "FEATURES=$FEATURES" >> $CONFIG_FILE +echo "HVISOR_SRC=$HVISOR_SRC" >> $CONFIG_FILE +echo "LD_SCRIPT=$LD_SCRIPT" >> $CONFIG_FILE +echo "TEMPLATE=$CONFIG_TOML_TEMPLATE" >> $CONFIG_FILE \ No newline at end of file diff --git a/tools/read_features.sh b/tools/read_features.sh new file mode 100755 index 00000000..88a1dbe9 --- /dev/null +++ b/tools/read_features.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +ARCH=$1 +BOARD=$2 + +FEATURES="platform/$ARCH/$BOARD/cargo/features" +# read the contents of the features file +FEATURES=$(cat $FEATURES) +# post process the features, replace any newlines with spaces +FEATURES=$(echo $FEATURES | tr '\n' ' ') +FEATURES=$(echo $FEATURES | tr -d '\r') +# print the features +echo $FEATURES