├── coleopter_os ├── target │ ├── release │ │ ├── .cargo-lock │ │ ├── .fingerprint │ │ │ ├── coleopter_os-89a26310827f7e81 │ │ │ │ ├── build-script-build-script-build │ │ │ │ ├── dep-build-script-build-script-build │ │ │ │ ├── invoked.timestamp │ │ │ │ └── build-script-build-script-build.json │ │ │ └── coleopter_os-ae62ba4030d81d47 │ │ │ │ ├── build-script-build-script-build │ │ │ │ ├── dep-build-script-build-script-build │ │ │ │ ├── invoked.timestamp │ │ │ │ └── build-script-build-script-build.json │ │ └── build │ │ │ ├── coleopter_os-89a26310827f7e81 │ │ │ ├── build-script-build │ │ │ ├── build_script_build-89a26310827f7e81 │ │ │ └── build_script_build-89a26310827f7e81.d │ │ │ └── coleopter_os-ae62ba4030d81d47 │ │ │ ├── build-script-build │ │ │ ├── build_script_build-ae62ba4030d81d47 │ │ │ └── build_script_build-ae62ba4030d81d47.d │ ├── aarch64-unknown-none-softfloat │ │ ├── release │ │ │ ├── .cargo-lock │ │ │ ├── build │ │ │ │ ├── coleopter_os-09621a322af1479d │ │ │ │ │ ├── stderr │ │ │ │ │ ├── invoked.timestamp │ │ │ │ │ ├── output │ │ │ │ │ └── root-output │ │ │ │ ├── coleopter_os-2223d65579ccc977 │ │ │ │ │ ├── stderr │ │ │ │ │ ├── invoked.timestamp │ │ │ │ │ ├── output │ │ │ │ │ └── root-output │ │ │ │ └── coleopter_os-fbb395413661221c │ │ │ │ │ ├── stderr │ │ │ │ │ ├── invoked.timestamp │ │ │ │ │ ├── output │ │ │ │ │ └── root-output │ │ │ ├── .fingerprint │ │ │ │ ├── cortex-a-64607851b942a163 │ │ │ │ │ ├── dep-lib-cortex-a │ │ │ │ │ ├── lib-cortex-a │ │ │ │ │ ├── invoked.timestamp │ │ │ │ │ └── lib-cortex-a.json │ │ │ │ ├── coleopter_os-d7ed0874d9fa21d4 │ │ │ │ │ ├── bin-kernel │ │ │ │ │ ├── invoked.timestamp │ │ │ │ │ ├── dep-bin-kernel │ │ │ │ │ └── bin-kernel.json │ │ │ │ ├── tock-registers-6b8d427195479bd9 │ │ │ │ │ ├── dep-lib-tock-registers │ │ │ │ │ ├── lib-tock-registers │ │ │ │ │ ├── invoked.timestamp │ │ │ │ │ └── lib-tock-registers.json │ │ │ │ ├── tock-registers-9cf3f8727549a940 │ │ │ │ │ ├── dep-lib-tock-registers │ │ │ │ │ ├── lib-tock-registers │ │ │ │ │ ├── invoked.timestamp │ │ │ │ │ └── lib-tock-registers.json │ │ │ │ ├── coleopter_os-09621a322af1479d │ │ │ │ │ ├── run-build-script-build-script-build │ │ │ │ │ └── run-build-script-build-script-build.json │ │ │ │ ├── coleopter_os-2223d65579ccc977 │ │ │ │ │ ├── run-build-script-build-script-build │ │ │ │ │ └── run-build-script-build-script-build.json │ │ │ │ ├── coleopter_os-fbb395413661221c │ │ │ │ │ ├── run-build-script-build-script-build │ │ │ │ │ └── run-build-script-build-script-build.json │ │ │ │ ├── tock-registers-63781f6d4d8c6446 │ │ │ │ │ ├── invoked.timestamp │ │ │ │ │ └── output-lib-tock-registers │ │ │ │ ├── tock-registers-b269457a9053085f │ │ │ │ │ └── invoked.timestamp │ │ │ │ └── tock-registers-31f008dbdd5c3fd1 │ │ │ │ │ └── output-doc-lib-tock-registers │ │ │ ├── kernel │ │ │ ├── deps │ │ │ │ ├── kernel-d7ed0874d9fa21d4 │ │ │ │ ├── libcortex_a-64607851b942a163.rlib │ │ │ │ ├── libcortex_a-64607851b942a163.rmeta │ │ │ │ ├── libtock_registers-6b8d427195479bd9.rlib │ │ │ │ ├── libtock_registers-6b8d427195479bd9.rmeta │ │ │ │ ├── libtock_registers-9cf3f8727549a940.rlib │ │ │ │ ├── libtock_registers-9cf3f8727549a940.rmeta │ │ │ │ ├── tock_registers-6b8d427195479bd9.d │ │ │ │ ├── tock_registers-b269457a9053085f.d │ │ │ │ ├── kernel-d7ed0874d9fa21d4.d │ │ │ │ ├── tock_registers-63781f6d4d8c6446.d │ │ │ │ ├── tock_registers-9cf3f8727549a940.d │ │ │ │ └── cortex_a-64607851b942a163.d │ │ │ └── kernel.d │ │ └── CACHEDIR.TAG │ ├── CACHEDIR.TAG │ ├── .rustdoc_fingerprint.json │ └── .rustc_info.json ├── kernel8.img ├── tests │ └── boot_test_string.rb ├── utils │ ├── color.mk.in │ ├── update_copyright.rb │ ├── devtool │ │ └── copyright.rb │ ├── minipush │ │ └── progressbar_patch.rb │ ├── diff_tut_folders.bash │ ├── miniterm.rb │ ├── minipush.rb │ └── devtool.rb ├── build.rs ├── src │ ├── cpu │ │ └── boot.rs │ ├── bsp │ │ ├── device_driver │ │ │ ├── bcm.rs │ │ │ ├── common.rs │ │ │ └── bcm │ │ │ │ ├── bcm2xxx_gpio.rs │ │ │ │ └── bcm2xxx_pl011_uart.rs │ │ ├── device_driver.rs │ │ ├── raspberrypi │ │ │ ├── cpu.rs │ │ │ ├── memory.rs │ │ │ ├── console.rs │ │ │ ├── driver.rs │ │ │ └── link.ld │ │ └── raspberrypi.rs │ ├── bsp.rs │ ├── cpu.rs │ ├── _arch │ │ └── aarch64 │ │ │ ├── cpu.rs │ │ │ └── cpu │ │ │ ├── boot.rs │ │ │ └── boot.s │ ├── print.rs │ ├── panic_wait.rs │ ├── console.rs │ ├── driver.rs │ ├── synchronization.rs │ └── main.rs ├── Cargo.lock ├── Cargo.toml └── Makefile ├── .gitignore ├── common ├── color.mk.in ├── serial │ ├── minipush │ │ └── progressbar_patch.rb │ ├── miniterm.rb │ └── minipush.rb └── tests │ ├── dispatch.rb │ ├── console_io_test.rb │ ├── exit_code_test.rb │ ├── test.rb │ └── boot_test.rb ├── rust-toolchain ├── Learning ├── destroy │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── newname │ ├── Cargo.toml │ └── src │ │ └── main.rs └── shell_assignments.md ├── .github └── workflows │ └── rust.yml ├── LICENSE └── README.md /coleopter_os/target/release/.cargo-lock: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.cargo-lock: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /coleopter_os/kernel8.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arsaev/ColeopteraOS/HEAD/coleopter_os/kernel8.img -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/build/coleopter_os-09621a322af1479d/stderr: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/build/coleopter_os-2223d65579ccc977/stderr: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/build/coleopter_os-fbb395413661221c/stderr: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /coleopter_os/tests/boot_test_string.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | EXPECTED_PRINT = 'Echoing input now' -------------------------------------------------------------------------------- /coleopter_os/target/release/.fingerprint/coleopter_os-89a26310827f7e81/build-script-build-script-build: -------------------------------------------------------------------------------- 1 | df714947c75f59ce -------------------------------------------------------------------------------- /coleopter_os/target/release/.fingerprint/coleopter_os-ae62ba4030d81d47/build-script-build-script-build: -------------------------------------------------------------------------------- 1 | 820cf8e68cc6e607 -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/cortex-a-64607851b942a163/dep-lib-cortex-a: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/coleopter_os-d7ed0874d9fa21d4/bin-kernel: -------------------------------------------------------------------------------- 1 | 80e6933723b129e7 -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/cortex-a-64607851b942a163/lib-cortex-a: -------------------------------------------------------------------------------- 1 | fe2570eddee84b7f -------------------------------------------------------------------------------- /coleopter_os/target/release/.fingerprint/coleopter_os-89a26310827f7e81/dep-build-script-build-script-build: -------------------------------------------------------------------------------- 1 | build.rs -------------------------------------------------------------------------------- /coleopter_os/target/release/.fingerprint/coleopter_os-ae62ba4030d81d47/dep-build-script-build-script-build: -------------------------------------------------------------------------------- 1 | build.rs -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/tock-registers-6b8d427195479bd9/dep-lib-tock-registers: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/tock-registers-6b8d427195479bd9/lib-tock-registers: -------------------------------------------------------------------------------- 1 | 2e2305161656c4fa -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/tock-registers-9cf3f8727549a940/dep-lib-tock-registers: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/tock-registers-9cf3f8727549a940/lib-tock-registers: -------------------------------------------------------------------------------- 1 | 06128c37c85cbe53 -------------------------------------------------------------------------------- /coleopter_os/target/release/.fingerprint/coleopter_os-89a26310827f7e81/invoked.timestamp: -------------------------------------------------------------------------------- 1 | This file has an mtime of when this was started. -------------------------------------------------------------------------------- /coleopter_os/target/release/.fingerprint/coleopter_os-ae62ba4030d81d47/invoked.timestamp: -------------------------------------------------------------------------------- 1 | This file has an mtime of when this was started. -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/coleopter_os-09621a322af1479d/run-build-script-build-script-build: -------------------------------------------------------------------------------- 1 | 7c8a17a12bff3df2 -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/coleopter_os-2223d65579ccc977/run-build-script-build-script-build: -------------------------------------------------------------------------------- 1 | 3caa735eb01c0b0a -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/coleopter_os-fbb395413661221c/run-build-script-build-script-build: -------------------------------------------------------------------------------- 1 | 8c78f35e25fff95f -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | /Learning/destroy/Cargo.lock 3 | /Learning/destroy/target/ 4 | */.idea 5 | */.DS_store 6 | .DS_store 7 | .idea 8 | ./coleopter_os/target -------------------------------------------------------------------------------- /common/color.mk.in: -------------------------------------------------------------------------------- 1 | define colorecho 2 | @tput setaf 6 2> /dev/null || true 3 | @echo $1 4 | @tput sgr0 2> /dev/null || true 5 | endef 6 | -------------------------------------------------------------------------------- /rust-toolchain: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "nightly-2021-07-12" 3 | components = ["llvm-tools-preview"] 4 | targets = ["aarch64-unknown-none-softfloat"] 5 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/cortex-a-64607851b942a163/invoked.timestamp: -------------------------------------------------------------------------------- 1 | This file has an mtime of when this was started. -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/build/coleopter_os-09621a322af1479d/invoked.timestamp: -------------------------------------------------------------------------------- 1 | This file has an mtime of when this was started. -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/build/coleopter_os-2223d65579ccc977/invoked.timestamp: -------------------------------------------------------------------------------- 1 | This file has an mtime of when this was started. -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/build/coleopter_os-fbb395413661221c/invoked.timestamp: -------------------------------------------------------------------------------- 1 | This file has an mtime of when this was started. -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/coleopter_os-d7ed0874d9fa21d4/invoked.timestamp: -------------------------------------------------------------------------------- 1 | This file has an mtime of when this was started. -------------------------------------------------------------------------------- /coleopter_os/utils/color.mk.in: -------------------------------------------------------------------------------- 1 | define colorecho 2 | @tput setaf 6 2> /dev/null || true 3 | @echo $1 4 | @tput sgr0 2> /dev/null || true 5 | endef 6 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/tock-registers-63781f6d4d8c6446/invoked.timestamp: -------------------------------------------------------------------------------- 1 | This file has an mtime of when this was started. -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/tock-registers-6b8d427195479bd9/invoked.timestamp: -------------------------------------------------------------------------------- 1 | This file has an mtime of when this was started. -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/tock-registers-9cf3f8727549a940/invoked.timestamp: -------------------------------------------------------------------------------- 1 | This file has an mtime of when this was started. -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/tock-registers-b269457a9053085f/invoked.timestamp: -------------------------------------------------------------------------------- 1 | This file has an mtime of when this was started. -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/kernel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arsaev/ColeopteraOS/HEAD/coleopter_os/target/aarch64-unknown-none-softfloat/release/kernel -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/build/coleopter_os-09621a322af1479d/output: -------------------------------------------------------------------------------- 1 | cargo:rerun-if-changed=src/bsp/raspberrypi/link.ld 2 | cargo:rerun-if-changed=build.rs 3 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/build/coleopter_os-2223d65579ccc977/output: -------------------------------------------------------------------------------- 1 | cargo:rerun-if-changed=src/bsp/raspberrypi/link.ld 2 | cargo:rerun-if-changed=build.rs 3 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/build/coleopter_os-fbb395413661221c/output: -------------------------------------------------------------------------------- 1 | cargo:rerun-if-changed=src/bsp/raspberrypi/link.ld 2 | cargo:rerun-if-changed=build.rs 3 | -------------------------------------------------------------------------------- /coleopter_os/target/CACHEDIR.TAG: -------------------------------------------------------------------------------- 1 | Signature: 8a477f597d28d172789f06886806bc55 2 | # This file is a cache directory tag created by cargo. 3 | # For information about cache directory tags see https://bford.info/cachedir/ 4 | -------------------------------------------------------------------------------- /coleopter_os/target/release/build/coleopter_os-89a26310827f7e81/build-script-build: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arsaev/ColeopteraOS/HEAD/coleopter_os/target/release/build/coleopter_os-89a26310827f7e81/build-script-build -------------------------------------------------------------------------------- /coleopter_os/target/release/build/coleopter_os-ae62ba4030d81d47/build-script-build: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arsaev/ColeopteraOS/HEAD/coleopter_os/target/release/build/coleopter_os-ae62ba4030d81d47/build-script-build -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/kernel-d7ed0874d9fa21d4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arsaev/ColeopteraOS/HEAD/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/kernel-d7ed0874d9fa21d4 -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/build/coleopter_os-09621a322af1479d/root-output: -------------------------------------------------------------------------------- 1 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/build/coleopter_os-09621a322af1479d/out -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/build/coleopter_os-2223d65579ccc977/root-output: -------------------------------------------------------------------------------- 1 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/build/coleopter_os-2223d65579ccc977/out -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/build/coleopter_os-fbb395413661221c/root-output: -------------------------------------------------------------------------------- 1 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/build/coleopter_os-fbb395413661221c/out -------------------------------------------------------------------------------- /coleopter_os/build.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | 3 | fn main() { 4 | let linker_file = env::var("LINKER_FILE").unwrap_or_default(); 5 | 6 | println!("cargo:rerun-if-changed={}", linker_file); 7 | println!("cargo:rerun-if-changed=build.rs"); 8 | } -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/CACHEDIR.TAG: -------------------------------------------------------------------------------- 1 | Signature: 8a477f597d28d172789f06886806bc55 2 | # This file is a cache directory tag created by cargo. 3 | # For information about cache directory tags see https://bford.info/cachedir/ 4 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libcortex_a-64607851b942a163.rlib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arsaev/ColeopteraOS/HEAD/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libcortex_a-64607851b942a163.rlib -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libcortex_a-64607851b942a163.rmeta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arsaev/ColeopteraOS/HEAD/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libcortex_a-64607851b942a163.rmeta -------------------------------------------------------------------------------- /coleopter_os/target/release/build/coleopter_os-89a26310827f7e81/build_script_build-89a26310827f7e81: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arsaev/ColeopteraOS/HEAD/coleopter_os/target/release/build/coleopter_os-89a26310827f7e81/build_script_build-89a26310827f7e81 -------------------------------------------------------------------------------- /coleopter_os/target/release/build/coleopter_os-ae62ba4030d81d47/build_script_build-ae62ba4030d81d47: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arsaev/ColeopteraOS/HEAD/coleopter_os/target/release/build/coleopter_os-ae62ba4030d81d47/build_script_build-ae62ba4030d81d47 -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libtock_registers-6b8d427195479bd9.rlib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arsaev/ColeopteraOS/HEAD/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libtock_registers-6b8d427195479bd9.rlib -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libtock_registers-6b8d427195479bd9.rmeta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arsaev/ColeopteraOS/HEAD/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libtock_registers-6b8d427195479bd9.rmeta -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libtock_registers-9cf3f8727549a940.rlib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arsaev/ColeopteraOS/HEAD/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libtock_registers-9cf3f8727549a940.rlib -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libtock_registers-9cf3f8727549a940.rmeta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Arsaev/ColeopteraOS/HEAD/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libtock_registers-9cf3f8727549a940.rmeta -------------------------------------------------------------------------------- /coleopter_os/target/.rustdoc_fingerprint.json: -------------------------------------------------------------------------------- 1 | {"rustc_vv":"rustc 1.53.0-nightly (42816d61e 2021-04-24)\nbinary: rustc\ncommit-hash: 42816d61ead7e46d462df997958ccfd514f8c21c\ncommit-date: 2021-04-24\nhost: aarch64-apple-darwin\nrelease: 1.53.0-nightly\nLLVM version: 12.0.0\n"} -------------------------------------------------------------------------------- /Learning/destroy/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "destroy" 3 | version = "0.1.0" 4 | authors = ["lukas "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /Learning/newname/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "newname" 3 | version = "0.1.0" 4 | authors = ["lukas "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /coleopter_os/src/cpu/boot.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2021 Andre Richter 4 | 5 | //! Boot code. 6 | 7 | #[cfg(target_arch = "aarch64")] 8 | #[path = "../_arch/aarch64/cpu/boot.rs"] 9 | mod arch_boot; 10 | -------------------------------------------------------------------------------- /coleopter_os/src/bsp/device_driver/bcm.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | //! BCM driver top level. 6 | 7 | mod bcm2xxx_gpio; 8 | mod bcm2xxx_pl011_uart; 9 | 10 | pub use bcm2xxx_gpio::*; 11 | pub use bcm2xxx_pl011_uart::*; -------------------------------------------------------------------------------- /coleopter_os/src/bsp/device_driver.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | //! Device driver. 6 | 7 | #[cfg(any(feature = "bsp_rpi3", feature = "bsp_rpi4"))] 8 | mod bcm; 9 | mod common; 10 | 11 | #[cfg(any(feature = "bsp_rpi3", feature = "bsp_rpi4"))] 12 | pub use bcm::*; -------------------------------------------------------------------------------- /Learning/destroy/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use std::fs; 3 | 4 | fn main() { 5 | for arg in env::args().skip(1) { 6 | delete_file(&arg); 7 | } 8 | } 9 | 10 | fn delete_file(filename: &String) { 11 | match fs::remove_file(&filename) { 12 | Ok(_) => (), 13 | Err(e) => println!("{}: {}", &filename, e.to_string()) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /coleopter_os/target/release/build/coleopter_os-89a26310827f7e81/build_script_build-89a26310827f7e81.d: -------------------------------------------------------------------------------- 1 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/release/build/coleopter_os-89a26310827f7e81/build_script_build-89a26310827f7e81: build.rs 2 | 3 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/release/build/coleopter_os-89a26310827f7e81/build_script_build-89a26310827f7e81.d: build.rs 4 | 5 | build.rs: 6 | -------------------------------------------------------------------------------- /coleopter_os/target/release/build/coleopter_os-ae62ba4030d81d47/build_script_build-ae62ba4030d81d47.d: -------------------------------------------------------------------------------- 1 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/release/build/coleopter_os-ae62ba4030d81d47/build_script_build-ae62ba4030d81d47: build.rs 2 | 3 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/release/build/coleopter_os-ae62ba4030d81d47/build_script_build-ae62ba4030d81d47.d: build.rs 4 | 5 | build.rs: 6 | -------------------------------------------------------------------------------- /coleopter_os/src/bsp.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | //! Conditional reexporting of Board Support Packages. 6 | mod device_driver; 7 | 8 | #[cfg(any(feature = "bsp_rpi3", feature = "bsp_rpi4"))] 9 | mod raspberrypi; 10 | 11 | #[cfg(any(feature = "bsp_rpi3", feature = "bsp_rpi4"))] 12 | pub use raspberrypi::*; 13 | -------------------------------------------------------------------------------- /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: Rust 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Build 20 | run: cargo build --verbose 21 | - name: Run tests 22 | run: cargo test --verbose 23 | -------------------------------------------------------------------------------- /coleopter_os/target/release/.fingerprint/coleopter_os-ae62ba4030d81d47/build-script-build-script-build.json: -------------------------------------------------------------------------------- 1 | {"rustc":12032562286912904725,"features":"[\"bsp_rpi3\", \"default\", \"tock-registers\"]","target":10429514197457385088,"profile":12451846938369515351,"path":4820456077575211582,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/coleopter_os-ae62ba4030d81d47/dep-build-script-build-script-build"}}],"rustflags":[],"metadata":13005208980623204145,"config":0,"compile_kind":0} -------------------------------------------------------------------------------- /coleopter_os/target/release/.fingerprint/coleopter_os-89a26310827f7e81/build-script-build-script-build.json: -------------------------------------------------------------------------------- 1 | {"rustc":10368338703276244575,"features":"[\"bsp_rpi3\", \"default\", \"tock-registers\"]","target":10429514197457385088,"profile":12451846938369515351,"path":4820456077575211582,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/coleopter_os-89a26310827f7e81/dep-build-script-build-script-build"}}],"rustflags":[],"metadata":13005208980623204145,"config":2202906307356721367,"compile_kind":0} -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/coleopter_os-09621a322af1479d/run-build-script-build-script-build.json: -------------------------------------------------------------------------------- 1 | {"rustc":12032562286912904725,"features":"","target":0,"profile":0,"path":0,"deps":[[13326324396917802648,"build_script_build",false,569360711381683330]],"local":[{"RerunIfChanged":{"output":"aarch64-unknown-none-softfloat/release/build/coleopter_os-09621a322af1479d/output","paths":["src/bsp/raspberrypi/link.ld","build.rs"]}}],"rustflags":[],"metadata":0,"config":0,"compile_kind":0} -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/coleopter_os-fbb395413661221c/run-build-script-build-script-build.json: -------------------------------------------------------------------------------- 1 | {"rustc":12032562286912904725,"features":"","target":0,"profile":0,"path":0,"deps":[[13326324396917802648,"build_script_build",false,569360711381683330]],"local":[{"RerunIfChanged":{"output":"aarch64-unknown-none-softfloat/release/build/coleopter_os-fbb395413661221c/output","paths":["src/bsp/raspberrypi/link.ld","build.rs"]}}],"rustflags":[],"metadata":0,"config":0,"compile_kind":0} -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/coleopter_os-2223d65579ccc977/run-build-script-build-script-build.json: -------------------------------------------------------------------------------- 1 | {"rustc":10368338703276244575,"features":"","target":0,"profile":0,"path":0,"deps":[[13326324396917802648,"build_script_build",false,14869020954239529439]],"local":[{"RerunIfChanged":{"output":"aarch64-unknown-none-softfloat/release/build/coleopter_os-2223d65579ccc977/output","paths":["src/bsp/raspberrypi/link.ld","build.rs"]}}],"rustflags":[],"metadata":0,"config":0,"compile_kind":0} -------------------------------------------------------------------------------- /coleopter_os/utils/update_copyright.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # SPDX-License-Identifier: MIT OR Apache-2.0 5 | # 6 | # Copyright (c) 2021 Andre Richter 7 | 8 | require 'date' 9 | 10 | files = `git ls-files`.split("\n") 11 | files = files.delete_if { |f| File.symlink?(f) } 12 | files = files.join(' ') 13 | 14 | year = Date.today.year 15 | 16 | `sed -i -- 's,\\(Copyright .* 20..\\)-20..,\\1-#{year},g' #{files}` 17 | `sed -i -- 's,\\(Copyright .* #{year - 1}\\) ,\\1-#{year} ,g' #{files}` 18 | -------------------------------------------------------------------------------- /Learning/newname/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use std::fs; 3 | 4 | fn main() { 5 | 6 | let args: Vec = env::args().collect(); 7 | match args.len() { 8 | 3 => rename_file(&args[1], &args[2]), 9 | _ => show_usage(), 10 | } 11 | 12 | } 13 | 14 | fn show_usage() { 15 | println!("Usage: newname TARGET NEWNAME") 16 | } 17 | 18 | fn rename_file(filename: &String, new_name: &String) { 19 | match fs::rename(filename, new_name) { 20 | Ok(res) => (), 21 | Err(e) => println!("{}", e.to_string()), 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /coleopter_os/src/bsp/raspberrypi/cpu.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | //! BSP Processor code. 6 | 7 | //-------------------------------------------------------------------------------------------------- 8 | // Public Definitions 9 | //-------------------------------------------------------------------------------------------------- 10 | 11 | /// Used by `arch` code to find the early boot core. 12 | #[no_mangle] 13 | #[link_section = ".text._start_arguments"] 14 | pub static BOOT_CORE_ID: u64 = 0; 15 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/tock-registers-6b8d427195479bd9/lib-tock-registers.json: -------------------------------------------------------------------------------- 1 | {"rustc":12032562286912904725,"features":"[]","target":16159444847253251162,"profile":10547654501055675003,"path":10107531820109748812,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"aarch64-unknown-none-softfloat/release/.fingerprint/tock-registers-6b8d427195479bd9/dep-lib-tock-registers"}}],"rustflags":["-C","link-arg=-Tsrc/bsp/raspberrypi/link.ld","-C","target-cpu=cortex-a53","-D","warnings","-D","missing_docs"],"metadata":14802257381519961638,"config":0,"compile_kind":1982563971889329545} -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/tock-registers-9cf3f8727549a940/lib-tock-registers.json: -------------------------------------------------------------------------------- 1 | {"rustc":10368338703276244575,"features":"[\"register_types\"]","target":16159444847253251162,"profile":10547654501055675003,"path":4466007951479713254,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"aarch64-unknown-none-softfloat/release/.fingerprint/tock-registers-9cf3f8727549a940/dep-lib-tock-registers"}}],"rustflags":["-C","link-arg=-Tsrc/bsp/raspberrypi/link.ld","-C","target-cpu=cortex-a53","-D","warnings","-D","missing_docs"],"metadata":14802257381519961638,"config":2202906307356721367,"compile_kind":1982563971889329545} -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/cortex-a-64607851b942a163/lib-cortex-a.json: -------------------------------------------------------------------------------- 1 | {"rustc":10368338703276244575,"features":"[]","target":8621575058499405009,"profile":10547654501055675003,"path":2773670128091477448,"deps":[[12270252143238556457,"tock_registers",false,6034362565718184454]],"local":[{"CheckDepInfo":{"dep_info":"aarch64-unknown-none-softfloat/release/.fingerprint/cortex-a-64607851b942a163/dep-lib-cortex-a"}}],"rustflags":["-C","link-arg=-Tsrc/bsp/raspberrypi/link.ld","-C","target-cpu=cortex-a53","-D","warnings","-D","missing_docs"],"metadata":17839302030240515123,"config":2202906307356721367,"compile_kind":1982563971889329545} -------------------------------------------------------------------------------- /coleopter_os/src/cpu.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2020-2021 Andre Richter 4 | 5 | //! Processor code. 6 | 7 | #[cfg(target_arch = "aarch64")] 8 | #[path = "_arch/aarch64/cpu.rs"] 9 | mod arch_cpu; 10 | 11 | mod boot; 12 | 13 | //-------------------------------------------------------------------------------------------------- 14 | // Architectural Public Reexports 15 | //-------------------------------------------------------------------------------------------------- 16 | pub use arch_cpu::{nop, wait_forever}; 17 | 18 | #[cfg(feature = "bsp_rpi3")] 19 | pub use arch_cpu::spin_for_cycles; -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/coleopter_os-d7ed0874d9fa21d4/dep-bin-kernel: -------------------------------------------------------------------------------- 1 |  src/main.rs 2 | src/bsp.rssrc/bsp/device_driver.rssrc/bsp/device_driver/bcm.rs)src/bsp/device_driver/bcm/bcm2xxx_gpio.rs/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rssrc/bsp/device_driver/common.rssrc/bsp/raspberrypi.rssrc/bsp/raspberrypi/console.rssrc/bsp/raspberrypi/cpu.rssrc/bsp/raspberrypi/driver.rssrc/bsp/raspberrypi/memory.rssrc/console.rs 3 | src/cpu.rssrc/_arch/aarch64/cpu.rssrc/cpu/boot.rssrc/_arch/aarch64/cpu/boot.rs src/driver.rssrc/panic_wait.rs src/print.rssrc/synchronization.rssrc/_arch/aarch64/cpu/boot.s -------------------------------------------------------------------------------- /coleopter_os/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "coleopter_os" 7 | version = "0.4.0" 8 | dependencies = [ 9 | "cortex-a", 10 | "tock-registers", 11 | ] 12 | 13 | [[package]] 14 | name = "cortex-a" 15 | version = "6.1.0" 16 | source = "registry+https://github.com/rust-lang/crates.io-index" 17 | checksum = "509fc35485a2b4ddbacabe0bf2212cdfff88da93658608e5cc651afcb75b7733" 18 | dependencies = [ 19 | "tock-registers", 20 | ] 21 | 22 | [[package]] 23 | name = "tock-registers" 24 | version = "0.7.0" 25 | source = "registry+https://github.com/rust-lang/crates.io-index" 26 | checksum = "4ee8fba06c1f4d0b396ef61a54530bb6b28f0dc61c38bc8bc5a5a48161e6282e" 27 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/coleopter_os-d7ed0874d9fa21d4/bin-kernel.json: -------------------------------------------------------------------------------- 1 | {"rustc":10368338703276244575,"features":"[\"bsp_rpi3\", \"default\", \"tock-registers\"]","target":7763845399380775888,"profile":8705735312582202685,"path":1036222786711178230,"deps":[[7977216493687914955,"cortex_a",false,9172681110234080766],[12270252143238556457,"tock_registers",false,6034362565718184454],[13326324396917802648,"build_script_build",false,723703708947556924]],"local":[{"CheckDepInfo":{"dep_info":"aarch64-unknown-none-softfloat/release/.fingerprint/coleopter_os-d7ed0874d9fa21d4/dep-bin-kernel"}}],"rustflags":["-C","link-arg=-Tsrc/bsp/raspberrypi/link.ld","-C","target-cpu=cortex-a53","-D","warnings","-D","missing_docs"],"metadata":13005208980623204145,"config":2202906307356721367,"compile_kind":1982563971889329545} -------------------------------------------------------------------------------- /coleopter_os/utils/devtool/copyright.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # SPDX-License-Identifier: MIT OR Apache-2.0 4 | # 5 | # Copyright (c) 2018-2021 Andre Richter 6 | 7 | require 'colorize' 8 | 9 | def copyright_check_files(source_files) 10 | source_files.sort.each do |f| 11 | puts 'Checking for copyright: '.light_blue + f.to_s 12 | 13 | years = copyright_years(f) 14 | unless years.include?(Time.now.year) 15 | puts "\tOnly found years: #{years}".red 16 | return false 17 | end 18 | end 19 | 20 | true 21 | end 22 | 23 | def copyright_years(file) 24 | years = [] 25 | File.readlines(file).grep(/.*Copyright.*/).each do |x| 26 | years << x.scan(/\d\d\d\d/).map!(&:to_i) 27 | end 28 | 29 | years.flatten 30 | end 31 | -------------------------------------------------------------------------------- /coleopter_os/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "coleopter_os" 3 | version = "0.4.0" 4 | authors = ["Magomed Arsaev "] 5 | edition = "2018" 6 | 7 | [profile.release] 8 | lto = true 9 | 10 | [features] 11 | default = [] 12 | bsp_rpi3 = ["tock-registers"] 13 | bsp_rpi4 = ["tock-registers"] 14 | 15 | [[bin]] 16 | name = "kernel" 17 | path = "src/main.rs" 18 | 19 | ##-------------------------------------------------------------------------------------------------- 20 | ## Dependencies 21 | ##-------------------------------------------------------------------------------------------------- 22 | 23 | [dependencies] 24 | # Optional dependencies 25 | tock-registers = { version = "0.7.x", default-features = false, features = ["register_types"], optional = true } 26 | 27 | # Platform specific dependencies 28 | [target.'cfg(target_arch = "aarch64")'.dependencies] 29 | cortex-a = { version = "6.x.x" } 30 | -------------------------------------------------------------------------------- /common/serial/minipush/progressbar_patch.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # SPDX-License-Identifier: MIT OR Apache-2.0 4 | # 5 | # Copyright (c) 2020-2021 Andre Richter 6 | 7 | # Monkey-patch ruby-progressbar so that it supports reporting the progress in KiB instead of Byte. 8 | 9 | class ProgressBar 10 | # Add kibi version of progress 11 | class Progress 12 | def progress_kibi 13 | @progress / 1024 14 | end 15 | end 16 | 17 | module Format 18 | # Add new formatting option 19 | class Molecule 20 | MOLECULES_EXTENDED = MOLECULES.dup 21 | MOLECULES_EXTENDED[:k] = %i[progressable progress_kibi] 22 | 23 | def initialize(letter) 24 | self.key = letter 25 | self.method_name = MOLECULES_EXTENDED.fetch(key.to_sym) 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /coleopter_os/utils/minipush/progressbar_patch.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # SPDX-License-Identifier: MIT OR Apache-2.0 4 | # 5 | # Copyright (c) 2020-2021 Andre Richter 6 | 7 | # Monkey-patch ruby-progressbar so that it supports reporting the progress in KiB instead of Byte. 8 | 9 | class ProgressBar 10 | # Add kibi version of progress 11 | class Progress 12 | def progress_kibi 13 | @progress / 1024 14 | end 15 | end 16 | 17 | module Format 18 | # Add new formatting option 19 | class Molecule 20 | MOLECULES_EXTENDED = MOLECULES.dup 21 | MOLECULES_EXTENDED[:k] = %i[progressable progress_kibi] 22 | 23 | def initialize(letter) 24 | self.key = letter 25 | self.method_name = MOLECULES_EXTENDED.fetch(key.to_sym) 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /coleopter_os/utils/diff_tut_folders.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # SPDX-License-Identifier: MIT OR Apache-2.0 4 | # 5 | # Copyright (c) 2018-2021 Andre Richter 6 | 7 | DIFF=$( 8 | diff -uNr \ 9 | -x README.md \ 10 | -x README.CN.md \ 11 | -x kernel \ 12 | -x kernel8.img \ 13 | -x Cargo.lock \ 14 | -x target \ 15 | $1 $2 \ 16 | | sed -r "s/[12][90][127][0-9]-[0-9][0-9]-[0-9][0-9] .*//g" \ 17 | | sed -r "s/[[:space:]]*$//g" \ 18 | | sed -r "s/%/modulo/g" \ 19 | | sed -r "s/diff -uNr -x README.md -x README.CN.md -x kernel -x kernel8.img -x Cargo.lock -x target/\ndiff -uNr/g" 20 | ) 21 | 22 | HEADER="## Diff to previous" 23 | ORIGINAL=$( 24 | cat $2/README.md \ 25 | | sed -rn "/$HEADER/q;p" 26 | ) 27 | 28 | echo "$ORIGINAL" > "$2/README.md" 29 | printf "\n$HEADER\n" >> "$2/README.md" 30 | printf "\`\`\`diff\n" >> "$2/README.md" 31 | echo "$DIFF" >> "$2/README.md" 32 | printf "\n\`\`\`\n" >> "$2/README.md" 33 | -------------------------------------------------------------------------------- /coleopter_os/src/_arch/aarch64/cpu.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | //! Architectural processor code. 6 | //! 7 | //! # Orientation 8 | //! 9 | //! Since arch modules are imported into generic modules using the path attribute, the path of this 10 | //! file is: 11 | //! 12 | //! crate::cpu::arch_cpu 13 | 14 | use cortex_a::asm; 15 | 16 | //-------------------------------------------------------------------------------------------------- 17 | // Public Code 18 | //-------------------------------------------------------------------------------------------------- 19 | pub use asm::nop; 20 | 21 | /// Spin for `n` cycles. 22 | #[cfg(feature = "bsp_rpi3")] 23 | #[inline(always)] 24 | pub fn spin_for_cycles(n: usize) { 25 | for _ in 0..n { 26 | asm::nop(); 27 | } 28 | } 29 | 30 | /// Pause execution on the core. 31 | #[inline(always)] 32 | pub fn wait_forever() -> ! { 33 | loop { 34 | asm::wfe() 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /coleopter_os/src/_arch/aarch64/cpu/boot.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2021 Andre Richter 4 | 5 | //! Architectural boot code. 6 | //! 7 | //! # Orientation 8 | //! 9 | //! Since arch modules are imported into generic modules using the path attribute, the path of this 10 | //! file is: 11 | //! 12 | //! crate::cpu::boot::arch_boot 13 | 14 | // Assembly counterpart to this file. 15 | global_asm!(include_str!("boot.s")); 16 | 17 | //-------------------------------------------------------------------------------------------------- 18 | // Public Code 19 | //-------------------------------------------------------------------------------------------------- 20 | 21 | /// The Rust entry of the `kernel` binary. 22 | /// 23 | /// The function is called from the assembly `_start` function. 24 | /// 25 | /// # Safety 26 | /// 27 | /// - The `bss` section is not initialized yet. The code must not use or reference it in any way. 28 | #[no_mangle] 29 | pub unsafe fn _start_rust() -> ! { 30 | crate::kernel_init() 31 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Magomed Arsaev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /common/tests/dispatch.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # SPDX-License-Identifier: MIT OR Apache-2.0 5 | # 6 | # Copyright (c) 2019-2021 Andre Richter 7 | 8 | require_relative 'boot_test' 9 | require_relative 'console_io_test' 10 | require_relative 'exit_code_test' 11 | 12 | qemu_cmd = ARGV.join(' ') 13 | binary = ARGV.last 14 | test_name = binary.gsub(%r{.*deps/}, '').split('-')[0] 15 | 16 | case test_name 17 | when 'kernel8.img' 18 | load 'tests/boot_test_string.rb' # provides 'EXPECTED_PRINT' 19 | BootTest.new(qemu_cmd, EXPECTED_PRINT).run # Doesn't return 20 | 21 | when 'libkernel' 22 | ExitCodeTest.new(qemu_cmd, 'Kernel library unit tests').run # Doesn't return 23 | 24 | else 25 | console_test_file = "tests/#{test_name}.rb" 26 | test_name.concat('.rs') 27 | test = if File.exist?(console_test_file) 28 | load console_test_file # provides 'subtest_collection' 29 | ConsoleIOTest.new(qemu_cmd, test_name, subtest_collection) 30 | else 31 | ExitCodeTest.new(qemu_cmd, test_name) 32 | end 33 | 34 | test.run # Doesn't return 35 | end 36 | -------------------------------------------------------------------------------- /coleopter_os/src/print.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | //! Printing. 6 | 7 | use crate::{bsp, console}; 8 | use core::fmt; 9 | 10 | //-------------------------------------------------------------------------------------------------- 11 | // Public Code 12 | //-------------------------------------------------------------------------------------------------- 13 | 14 | #[doc(hidden)] 15 | pub fn _print(args: fmt::Arguments) { 16 | use console::interface::Write; 17 | 18 | bsp::console::console().write_fmt(args).unwrap(); 19 | } 20 | 21 | /// Prints without a newline. 22 | /// 23 | /// Carbon copy from 24 | #[macro_export] 25 | macro_rules! print { 26 | ($($arg:tt)*) => ($crate::print::_print(format_args!($($arg)*))); 27 | } 28 | 29 | /// Prints with a newline. 30 | /// 31 | /// Carbon copy from 32 | #[macro_export] 33 | macro_rules! println { 34 | () => ($crate::print!("\n")); 35 | ($($arg:tt)*) => ({ 36 | $crate::print::_print(format_args_nl!($($arg)*)); 37 | }) 38 | } 39 | -------------------------------------------------------------------------------- /coleopter_os/src/panic_wait.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | //! A panic handler that infinitely waits. 6 | 7 | use crate::{bsp, cpu}; 8 | use core::{fmt, panic::PanicInfo}; 9 | 10 | //-------------------------------------------------------------------------------------------------- 11 | // Private Code 12 | //-------------------------------------------------------------------------------------------------- 13 | 14 | fn _panic_print(args: fmt::Arguments) { 15 | use fmt::Write; 16 | 17 | unsafe { bsp::console::panic_console_out().write_fmt(args).unwrap() }; 18 | } 19 | 20 | /// Prints with a newline - only use from the panic handler. 21 | /// 22 | /// Carbon copy from 23 | #[macro_export] 24 | macro_rules! panic_println { 25 | ($($arg:tt)*) => ({ 26 | _panic_print(format_args_nl!($($arg)*)); 27 | }) 28 | } 29 | 30 | #[panic_handler] 31 | fn panic(info: &PanicInfo) -> ! { 32 | if let Some(args) = info.message() { 33 | panic_println!("\nKernel panic: {}", args); 34 | } else { 35 | panic_println!("\nKernel panic!"); 36 | } 37 | 38 | cpu::wait_forever() 39 | } -------------------------------------------------------------------------------- /coleopter_os/src/bsp/device_driver/common.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2020-2021 Andre Richter 4 | 5 | //! Common device driver code. 6 | 7 | use core::{marker::PhantomData, ops}; 8 | 9 | //-------------------------------------------------------------------------------------------------- 10 | // Public Definitions 11 | //-------------------------------------------------------------------------------------------------- 12 | 13 | pub struct MMIODerefWrapper { 14 | start_addr: usize, 15 | phantom: PhantomData T>, 16 | } 17 | 18 | //-------------------------------------------------------------------------------------------------- 19 | // Public Code 20 | //-------------------------------------------------------------------------------------------------- 21 | 22 | impl MMIODerefWrapper { 23 | /// Create an instance. 24 | pub const unsafe fn new(start_addr: usize) -> Self { 25 | Self { 26 | start_addr, 27 | phantom: PhantomData, 28 | } 29 | } 30 | } 31 | 32 | impl ops::Deref for MMIODerefWrapper { 33 | type Target = T; 34 | 35 | fn deref(&self) -> &Self::Target { 36 | unsafe { &*(self.start_addr as *const _) } 37 | } 38 | } -------------------------------------------------------------------------------- /coleopter_os/src/bsp/raspberrypi.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | //! Top-level BSP file for the Raspberry Pi 3 and 4. 6 | 7 | pub mod console; 8 | pub mod cpu; 9 | pub mod driver; 10 | pub mod memory; 11 | 12 | //-------------------------------------------------------------------------------------------------- 13 | // Global instances 14 | //-------------------------------------------------------------------------------------------------- 15 | use super::device_driver; 16 | 17 | static GPIO: device_driver::GPIO = 18 | unsafe { device_driver::GPIO::new(memory::map::mmio::GPIO_START) }; 19 | 20 | static PL011_UART: device_driver::PL011Uart = 21 | unsafe { device_driver::PL011Uart::new(memory::map::mmio::PL011_UART_START) }; 22 | 23 | //-------------------------------------------------------------------------------------------------- 24 | // Public Code 25 | //-------------------------------------------------------------------------------------------------- 26 | 27 | /// Board identification. 28 | pub fn board_name() -> &'static str { 29 | #[cfg(feature = "bsp_rpi3")] 30 | { 31 | "Raspberry Pi 3" 32 | } 33 | 34 | #[cfg(feature = "bsp_rpi4")] 35 | { 36 | "Raspberry Pi 4" 37 | } 38 | } -------------------------------------------------------------------------------- /coleopter_os/src/bsp/raspberrypi/memory.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | //! BSP Memory Management. 6 | 7 | //-------------------------------------------------------------------------------------------------- 8 | // Public Definitions 9 | //-------------------------------------------------------------------------------------------------- 10 | 11 | /// The board's physical memory map. 12 | #[rustfmt::skip] 13 | pub(super) mod map { 14 | 15 | pub const GPIO_OFFSET: usize = 0x0020_0000; 16 | pub const UART_OFFSET: usize = 0x0020_1000; 17 | 18 | /// Physical devices. 19 | #[cfg(feature = "bsp_rpi3")] 20 | pub mod mmio { 21 | use super::*; 22 | 23 | pub const START: usize = 0x3F00_0000; 24 | pub const GPIO_START: usize = START + GPIO_OFFSET; 25 | pub const PL011_UART_START: usize = START + UART_OFFSET; 26 | } 27 | 28 | /// Physical devices. 29 | #[cfg(feature = "bsp_rpi4")] 30 | pub mod mmio { 31 | use super::*; 32 | 33 | pub const START: usize = 0xFE00_0000; 34 | pub const GPIO_START: usize = START + GPIO_OFFSET; 35 | pub const PL011_UART_START: usize = START + UART_OFFSET; 36 | } 37 | } -------------------------------------------------------------------------------- /common/tests/console_io_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # SPDX-License-Identifier: MIT OR Apache-2.0 4 | # 5 | # Copyright (c) 2019-2021 Andre Richter 6 | 7 | require 'pty' 8 | require_relative 'test' 9 | 10 | # A test doing console I/O with the QEMU binary. 11 | class ConsoleIOTest < Test 12 | def initialize(qemu_cmd, test_name, console_subtests) 13 | super() 14 | 15 | @qemu_cmd = qemu_cmd 16 | @console_subtests = console_subtests 17 | 18 | @test_name = test_name 19 | @test_description = "Running #{@console_subtests.length} console I/O tests" 20 | @test_output = [] 21 | @test_error = nil 22 | end 23 | 24 | private 25 | 26 | def format_test_name(number, name) 27 | formatted_name = "#{number.to_s.rjust(3)}. #{name}" 28 | formatted_name.ljust(63, '.') 29 | end 30 | 31 | def run_subtest(subtest, test_id, qemu_out, qemu_in) 32 | @test_output << format_test_name(test_id, subtest.name) 33 | subtest.run(qemu_out, qemu_in) 34 | @test_output.last.concat('[ok]') 35 | end 36 | 37 | def run_concrete_test 38 | @test_error = false 39 | 40 | PTY.spawn(@qemu_cmd) do |qemu_out, qemu_in| 41 | @console_subtests.each_with_index do |t, i| 42 | run_subtest(t, i + 1, qemu_out, qemu_in) 43 | end 44 | rescue StandardError => e 45 | @test_error = e.message 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /coleopter_os/src/bsp/raspberrypi/console.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | //! BSP console facilities. 6 | 7 | use super::memory; 8 | use crate::{bsp::device_driver, console}; 9 | use core::fmt; 10 | 11 | //-------------------------------------------------------------------------------------------------- 12 | // Public Code 13 | //-------------------------------------------------------------------------------------------------- 14 | 15 | /// In case of a panic, the panic handler uses this function to take a last shot at printing 16 | /// something before the system is halted. 17 | /// 18 | /// We try to init panic-versions of the GPIO and the UART. The panic versions are not protected 19 | /// with synchronization primitives, which increases chances that we get to print something, even 20 | /// when the kernel's default GPIO or UART instances happen to be locked at the time of the panic. 21 | /// 22 | /// # Safety 23 | /// 24 | /// - Use only for printing during a panic. 25 | pub unsafe fn panic_console_out() -> impl fmt::Write { 26 | let mut panic_gpio = device_driver::PanicGPIO::new(memory::map::mmio::GPIO_START); 27 | let mut panic_uart = device_driver::PanicUart::new(memory::map::mmio::PL011_UART_START); 28 | 29 | panic_gpio.map_pl011_uart(); 30 | panic_uart.init(); 31 | panic_uart 32 | } 33 | 34 | /// Return a reference to the console. 35 | pub fn console() -> &'static impl console::interface::All { 36 | &super::PL011_UART 37 | } 38 | -------------------------------------------------------------------------------- /common/tests/exit_code_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # SPDX-License-Identifier: MIT OR Apache-2.0 4 | # 5 | # Copyright (c) 2019-2021 Andre Richter 6 | 7 | require 'English' 8 | require_relative 'test' 9 | 10 | # A test that only inspects the exit code of the QEMU binary. 11 | class ExitCodeTest < Test 12 | MAX_WAIT_SECS = 5 13 | 14 | def initialize(qemu_cmd, test_name) 15 | super() 16 | 17 | @qemu_cmd = qemu_cmd 18 | 19 | @test_name = test_name 20 | @test_description = nil 21 | @test_output = [] 22 | @test_error = nil 23 | end 24 | 25 | private 26 | 27 | # Convert the recorded output to an array of lines, and extract the test description. 28 | def post_process_output 29 | @test_output = @test_output.join.split("\n") 30 | @test_description = @test_output.shift 31 | end 32 | 33 | # override 34 | def setup 35 | @qemu_serial = IO.popen(@qemu_cmd) 36 | end 37 | 38 | def run_concrete_test 39 | Timeout.timeout(MAX_WAIT_SECS) do 40 | @test_output << @qemu_serial.read_nonblock(1024) while IO.select([@qemu_serial]) 41 | end 42 | rescue EOFError 43 | @qemu_serial.close 44 | @test_error = $CHILD_STATUS.to_i.zero? ? false : 'QEMU exit status != 0' 45 | rescue Timeout::Error 46 | @test_error = 'Timed out waiting for test' 47 | rescue StandardError => e 48 | @test_error = e.message 49 | ensure 50 | post_process_output 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/tock_registers-6b8d427195479bd9.d: -------------------------------------------------------------------------------- 1 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/tock_registers-6b8d427195479bd9.rmeta: /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.6.0/src/lib.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.6.0/src/macros.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.6.0/src/registers.rs 2 | 3 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libtock_registers-6b8d427195479bd9.rlib: /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.6.0/src/lib.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.6.0/src/macros.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.6.0/src/registers.rs 4 | 5 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/tock_registers-6b8d427195479bd9.d: /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.6.0/src/lib.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.6.0/src/macros.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.6.0/src/registers.rs 6 | 7 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.6.0/src/lib.rs: 8 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.6.0/src/macros.rs: 9 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.6.0/src/registers.rs: 10 | -------------------------------------------------------------------------------- /coleopter_os/src/console.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | //! System console. 6 | 7 | //-------------------------------------------------------------------------------------------------- 8 | // Public Definitions 9 | //-------------------------------------------------------------------------------------------------- 10 | 11 | /// Console interfaces. 12 | pub mod interface { 13 | use core::fmt; 14 | /// Console write functions. 15 | pub trait Write { 16 | /// Write a single character. 17 | fn write_char(&self, c: char); 18 | 19 | /// Write a Rust format string. 20 | fn write_fmt(&self, args: fmt::Arguments) -> fmt::Result; 21 | 22 | /// Block until the last buffered character has been physically put on the TX wire. 23 | fn flush(&self); 24 | } 25 | 26 | /// Console read functions. 27 | pub trait Read { 28 | /// Read a single character. 29 | fn read_char(&self) -> char { 30 | ' ' 31 | } 32 | 33 | /// Clear RX buffers, if any. 34 | fn clear_rx(&self); 35 | } 36 | 37 | /// Console statistics. 38 | pub trait Statistics { 39 | /// Return the number of characters written. 40 | fn chars_written(&self) -> usize { 41 | 0 42 | } 43 | 44 | /// Return the number of characters read. 45 | fn chars_read(&self) -> usize { 46 | 0 47 | } 48 | } 49 | 50 | /// Trait alias for a full-fledged console. 51 | pub trait All = Write + Read + Statistics; 52 | } 53 | -------------------------------------------------------------------------------- /coleopter_os/src/driver.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | //! Driver support. 6 | 7 | //-------------------------------------------------------------------------------------------------- 8 | // Public Definitions 9 | //-------------------------------------------------------------------------------------------------- 10 | 11 | /// Driver interfaces. 12 | pub mod interface { 13 | /// Device Driver functions. 14 | pub trait DeviceDriver { 15 | /// Return a compatibility string for identifying the driver. 16 | fn compatible(&self) -> &'static str; 17 | 18 | /// Called by the kernel to bring up the device. 19 | /// 20 | /// # Safety 21 | /// 22 | /// - During init, drivers might do stuff with system-wide impact. 23 | unsafe fn init(&self) -> Result<(), &'static str> { 24 | Ok(()) 25 | } 26 | } 27 | 28 | /// Device driver management functions. 29 | /// 30 | /// The `BSP` is supposed to supply one global instance. 31 | pub trait DriverManager { 32 | /// Return a slice of references to all `BSP`-instantiated drivers. 33 | /// 34 | /// # Safety 35 | /// 36 | /// - The order of devices is the order in which `DeviceDriver::init()` is called. 37 | fn all_device_drivers(&self) -> &[&'static (dyn DeviceDriver + Sync)]; 38 | 39 | /// Initialization code that runs after driver init. 40 | /// 41 | /// For example, device driver code that depends on other drivers already being online. 42 | fn post_device_driver_init(&self); 43 | } 44 | } -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/kernel.d: -------------------------------------------------------------------------------- 1 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/kernel: /Users/mago/Projects/ColeopteraOS/coleopter_os/build.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/_arch/aarch64/cpu/boot.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/_arch/aarch64/cpu/boot.s /Users/mago/Projects/ColeopteraOS/coleopter_os/src/_arch/aarch64/cpu.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/bsp/device_driver/bcm/bcm2xxx_gpio.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/bsp/device_driver/bcm.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/bsp/device_driver/common.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/bsp/device_driver.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/bsp/raspberrypi/console.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/bsp/raspberrypi/cpu.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/bsp/raspberrypi/driver.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/bsp/raspberrypi/link.ld /Users/mago/Projects/ColeopteraOS/coleopter_os/src/bsp/raspberrypi/memory.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/bsp/raspberrypi.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/bsp.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/console.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/cpu/boot.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/cpu.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/driver.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/main.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/panic_wait.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/print.rs /Users/mago/Projects/ColeopteraOS/coleopter_os/src/synchronization.rs 2 | -------------------------------------------------------------------------------- /coleopter_os/src/_arch/aarch64/cpu/boot.s: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2021 Andre Richter 4 | 5 | //-------------------------------------------------------------------------------------------------- 6 | // Definitions 7 | //-------------------------------------------------------------------------------------------------- 8 | 9 | // Load the address of a symbol into a register, PC-relative. 10 | // 11 | // The symbol must lie within +/- 4 GiB of the Program Counter. 12 | // 13 | // # Resources 14 | // 15 | // - https://sourceware.org/binutils/docs-2.36/as/AArch64_002dRelocations.html 16 | .macro ADR_REL register, symbol 17 | adrp \register, \symbol 18 | add \register, \register, #:lo12:\symbol 19 | .endm 20 | 21 | .equ _core_id_mask, 0b11 22 | 23 | //-------------------------------------------------------------------------------------------------- 24 | // Public Code 25 | //-------------------------------------------------------------------------------------------------- 26 | .section .text._start 27 | 28 | //------------------------------------------------------------------------------ 29 | // fn _start() 30 | //------------------------------------------------------------------------------ 31 | _start: 32 | // Only proceed on the boot core. Park it otherwise. 33 | mrs x1, MPIDR_EL1 34 | and x1, x1, _core_id_mask 35 | ldr x2, BOOT_CORE_ID // provided by bsp/__board_name__/cpu.rs 36 | cmp x1, x2 37 | b.ne 1f 38 | 39 | // If execution reaches here, it is the boot core. Now, prepare the jump to Rust code. 40 | 41 | // Set the stack pointer. 42 | ADR_REL x0, __boot_core_stack_end_exclusive 43 | mov sp, x0 44 | 45 | // Jump to Rust code. 46 | b _start_rust 47 | 48 | // Infinitely wait for events (aka "park the core"). 49 | 1: wfe 50 | b 1b 51 | 52 | .size _start, . - _start 53 | .type _start, function 54 | .global _start 55 | -------------------------------------------------------------------------------- /coleopter_os/src/bsp/raspberrypi/driver.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | //! BSP driver support. 6 | 7 | use crate::driver; 8 | 9 | //-------------------------------------------------------------------------------------------------- 10 | // Private Definitions 11 | //-------------------------------------------------------------------------------------------------- 12 | 13 | /// Device Driver Manager type. 14 | struct BSPDriverManager { 15 | device_drivers: [&'static (dyn DeviceDriver + Sync); 2], 16 | } 17 | 18 | //-------------------------------------------------------------------------------------------------- 19 | // Global instances 20 | //-------------------------------------------------------------------------------------------------- 21 | 22 | static BSP_DRIVER_MANAGER: BSPDriverManager = BSPDriverManager { 23 | device_drivers: [&super::GPIO, &super::PL011_UART], 24 | }; 25 | 26 | //-------------------------------------------------------------------------------------------------- 27 | // Public Code 28 | //-------------------------------------------------------------------------------------------------- 29 | 30 | /// Return a reference to the driver manager. 31 | pub fn driver_manager() -> &'static impl driver::interface::DriverManager { 32 | &BSP_DRIVER_MANAGER 33 | } 34 | 35 | //------------------------------------------------------------------------------ 36 | // OS Interface Code 37 | //------------------------------------------------------------------------------ 38 | use driver::interface::DeviceDriver; 39 | 40 | impl driver::interface::DriverManager for BSPDriverManager { 41 | fn all_device_drivers(&self) -> &[&'static (dyn DeviceDriver + Sync)] { 42 | &self.device_drivers[..] 43 | } 44 | 45 | fn post_device_driver_init(&self) { 46 | // Configure PL011Uart's output pins. 47 | super::GPIO.map_pl011_uart(); 48 | } 49 | } -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/tock-registers-31f008dbdd5c3fd1/output-doc-lib-tock-registers: -------------------------------------------------------------------------------- 1 | {"message":"unknown feature `const_fn_trait_bound`","code":{"code":"E0635","explanation":"The `#![feature]` attribute specified an unknown feature.\n\nErroneous code example:\n\n```compile_fail,E0635\n#![feature(nonexistent_rust_feature)] // error: unknown feature\n```\n"},"level":"error","spans":[{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/lib.rs","byte_start":1539,"byte_end":1559,"line_start":56,"line_end":56,"column_start":12,"column_end":32,"is_primary":true,"text":[{"text":"#![feature(const_fn_trait_bound)]","highlight_start":12,"highlight_end":32}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0635]\u001b[0m\u001b[0m\u001b[1m: unknown feature `const_fn_trait_bound`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/lib.rs:56:12\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m56\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m#![feature(const_fn_trait_bound)]\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^^^^^^^^^^^^^^^\u001b[0m\n\n"} 2 | {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: aborting due to previous error\u001b[0m\n\n"} 3 | {"message":"For more information about this error, try `rustc --explain E0635`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1mFor more information about this error, try `rustc --explain E0635`.\u001b[0m\n"} 4 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/tock_registers-b269457a9053085f.d: -------------------------------------------------------------------------------- 1 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/tock_registers-b269457a9053085f.rmeta: /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/lib.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/interfaces.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/macros.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/registers.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/local_register.rs 2 | 3 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/tock_registers-b269457a9053085f.d: /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/lib.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/interfaces.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/macros.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/registers.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/local_register.rs 4 | 5 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/lib.rs: 6 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs: 7 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/interfaces.rs: 8 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/macros.rs: 9 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/registers.rs: 10 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/local_register.rs: 11 | -------------------------------------------------------------------------------- /common/tests/test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # SPDX-License-Identifier: MIT OR Apache-2.0 4 | # 5 | # Copyright (c) 2019-2021 Andre Richter 6 | 7 | # Test base class. 8 | class Test 9 | INDENT = ' ' 10 | 11 | def initialize 12 | # Template instance variables. 13 | # @test_name 14 | # @test_description 15 | # @test_output 16 | # @test_error 17 | end 18 | 19 | private 20 | 21 | def print_border(content) 22 | puts "#{INDENT}-------------------------------------------------------------------" 23 | puts content 24 | puts "#{INDENT}-------------------------------------------------------------------" 25 | end 26 | 27 | def print_header 28 | print_border("#{INDENT}🦀 #{@test_description}") 29 | puts 30 | end 31 | 32 | def print_footer_error(error) 33 | puts 34 | print_border("#{INDENT}❌ Failure: #{@test_name}: #{error}") 35 | puts 36 | puts 37 | end 38 | 39 | def print_footer_success 40 | puts 41 | print_border("#{INDENT}✅ Success: #{@test_name}") 42 | puts 43 | puts 44 | end 45 | 46 | # Expects @test_output the be an array of lines, without '\n' 47 | def print_output 48 | @test_output.each { |x| print "#{INDENT}#{x}\n" } 49 | end 50 | 51 | # Template method. 52 | def setup; end 53 | 54 | # Template method. 55 | def cleanup; end 56 | 57 | # Template method. 58 | def run_concrete_test 59 | raise('Not implemented') 60 | end 61 | 62 | public 63 | 64 | def run 65 | setup 66 | run_concrete_test 67 | cleanup 68 | 69 | print_header 70 | print_output 71 | 72 | exit_code = if @test_error 73 | print_footer_error(@test_error) 74 | false 75 | else 76 | print_footer_success 77 | true 78 | end 79 | 80 | exit(exit_code) 81 | end 82 | end 83 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/kernel-d7ed0874d9fa21d4.d: -------------------------------------------------------------------------------- 1 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/kernel-d7ed0874d9fa21d4: src/main.rs src/bsp.rs src/bsp/device_driver.rs src/bsp/device_driver/bcm.rs src/bsp/device_driver/bcm/bcm2xxx_gpio.rs src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs src/bsp/device_driver/common.rs src/bsp/raspberrypi.rs src/bsp/raspberrypi/console.rs src/bsp/raspberrypi/cpu.rs src/bsp/raspberrypi/driver.rs src/bsp/raspberrypi/memory.rs src/console.rs src/cpu.rs src/_arch/aarch64/cpu.rs src/cpu/boot.rs src/cpu/../_arch/aarch64/cpu/boot.rs src/driver.rs src/panic_wait.rs src/print.rs src/synchronization.rs src/cpu/../_arch/aarch64/cpu/boot.s 2 | 3 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/kernel-d7ed0874d9fa21d4.d: src/main.rs src/bsp.rs src/bsp/device_driver.rs src/bsp/device_driver/bcm.rs src/bsp/device_driver/bcm/bcm2xxx_gpio.rs src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs src/bsp/device_driver/common.rs src/bsp/raspberrypi.rs src/bsp/raspberrypi/console.rs src/bsp/raspberrypi/cpu.rs src/bsp/raspberrypi/driver.rs src/bsp/raspberrypi/memory.rs src/console.rs src/cpu.rs src/_arch/aarch64/cpu.rs src/cpu/boot.rs src/cpu/../_arch/aarch64/cpu/boot.rs src/driver.rs src/panic_wait.rs src/print.rs src/synchronization.rs src/cpu/../_arch/aarch64/cpu/boot.s 4 | 5 | src/main.rs: 6 | src/bsp.rs: 7 | src/bsp/device_driver.rs: 8 | src/bsp/device_driver/bcm.rs: 9 | src/bsp/device_driver/bcm/bcm2xxx_gpio.rs: 10 | src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs: 11 | src/bsp/device_driver/common.rs: 12 | src/bsp/raspberrypi.rs: 13 | src/bsp/raspberrypi/console.rs: 14 | src/bsp/raspberrypi/cpu.rs: 15 | src/bsp/raspberrypi/driver.rs: 16 | src/bsp/raspberrypi/memory.rs: 17 | src/console.rs: 18 | src/cpu.rs: 19 | src/_arch/aarch64/cpu.rs: 20 | src/cpu/boot.rs: 21 | src/cpu/../_arch/aarch64/cpu/boot.rs: 22 | src/driver.rs: 23 | src/panic_wait.rs: 24 | src/print.rs: 25 | src/synchronization.rs: 26 | src/cpu/../_arch/aarch64/cpu/boot.s: 27 | 28 | # env-dep:CARGO_PKG_NAME=coleopter_os 29 | # env-dep:CARGO_PKG_VERSION=0.4.0 30 | -------------------------------------------------------------------------------- /coleopter_os/src/bsp/raspberrypi/link.ld: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT OR Apache-2.0 2 | * 3 | * Copyright (c) 2018-2021 Andre Richter 4 | */ 5 | 6 | /* The address at which the the kernel binary will be loaded by the Raspberry's firmware */ 7 | __rpi_load_addr = 0x80000; 8 | 9 | ENTRY(__rpi_load_addr) 10 | 11 | PHDRS 12 | { 13 | segment_rx PT_LOAD FLAGS(5); /* 5 == RX */ 14 | segment_rw PT_LOAD FLAGS(6); /* 6 == RW */ 15 | } 16 | 17 | SECTIONS 18 | { 19 | . = __rpi_load_addr; 20 | /* ^ */ 21 | /* | stack */ 22 | /* | growth */ 23 | /* | direction */ 24 | __boot_core_stack_end_exclusive = .; /* | */ 25 | 26 | /*********************************************************************************************** 27 | * Code + RO Data + Global Offset Table 28 | ***********************************************************************************************/ 29 | .text : 30 | { 31 | KEEP(*(.text._start)) 32 | *(.text._start_arguments) /* Constants (or statics in Rust speak) read by _start(). */ 33 | *(.text._start_rust) /* The Rust entry point */ 34 | *(.text*) /* Everything else */ 35 | } :segment_rx 36 | 37 | .rodata : ALIGN(8) { *(.rodata*) } :segment_rx 38 | .got : ALIGN(8) { *(.got) } :segment_rx 39 | 40 | /*********************************************************************************************** 41 | * Data + BSS 42 | ***********************************************************************************************/ 43 | .data : { *(.data*) } :segment_rw 44 | 45 | /* Section is zeroed in u64 chunks, align start and end to 8 bytes */ 46 | .bss : ALIGN(8) 47 | { 48 | __bss_start = .; 49 | *(.bss*); 50 | . = ALIGN(8); 51 | 52 | . += 8; /* Fill for the bss == 0 case, so that __bss_start <= __bss_end_inclusive holds */ 53 | __bss_end_inclusive = . - 8; 54 | } :NONE 55 | } 56 | -------------------------------------------------------------------------------- /Learning/shell_assignments.md: -------------------------------------------------------------------------------- 1 | # Shell Assignment 1 2 | 3 | ## What shell command produces each of the following outputs? 4 | 5 | * Listing of all files in a directory, including "hidden" files. 6 | 7 | `ls -a` `-a` do not ignore hidden files 8 | * A long-list of files in a directory, with file sizes in the most appropriate of the following: Byte, Kilobyte, 9 | Megabyte, Gigabyte, Terabyte and Petabyte 10 | 11 | `ls -lh` `-l` long list format, `-h` human readable format 12 | * The first fifteen lines of a file. 13 | 14 | `head -n 15` 15 | * The last fifteen lines of a file. 16 | 17 | `tail -n 15` 18 | * Every line in a file containing the word "red". 19 | 20 | `grep red file.txt` 21 | * All files in a directory ending with "txt". 22 | 23 | `ls -da $DIRECTORY/*.txt` 24 | 25 | # Shell Assignment 2 26 | 27 | ## What shell command produces each of the following outputs? 28 | 29 | * The five most recently modified files in the current directory. 30 | 31 | `ls -lat |head -n 6` `-t` sort by time. pipe the output to head 32 | * The five least recently modified files in the current directory. 33 | 34 | `ls -lat |tail -n 5` 35 | * The number of files in the current directory. 36 | 37 | `ls -ld |wc -l` In unix everything is a file, so I counted also directories 38 | * All Python files in the current directory or any of its recursive subdirectories. 39 | 40 | `find -name "*.py"` 41 | * All Python files in the current directory that import the math module. Do not include the text from the file, only the 42 | filename. 43 | 44 | `grep -rnwl . -e 'import math' |grep '[.]py'` 45 | * All currently executing Python programs. 46 | 47 | `ps -e |grep python` 48 | * All files in the current directory, sorted from the largest number of lines to the smallest. Include the number of 49 | lines in the output. 50 | 51 | `find . -maxdepth 1 -name '*' -type f|xargs wc -l |sort -nr|tail -n +2` Way too complicated... may have to reiterate on this question 52 | * All files in the current directory, sorted from the smallest number of characters to the largest. Include the number 53 | of characters in the output. 54 | 55 | `find . -maxdepth 1 -name '*' -type f|xargs wc -c |sort -n|head -n -1` See above... -------------------------------------------------------------------------------- /common/tests/boot_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # SPDX-License-Identifier: MIT OR Apache-2.0 4 | # 5 | # Copyright (c) 2021 Andre Richter 6 | 7 | require_relative 'test' 8 | require 'timeout' 9 | 10 | # Check for an expected string when booting the kernel in QEMU. 11 | class BootTest < Test 12 | MAX_WAIT_SECS = 5 13 | 14 | def initialize(qemu_cmd, expected_print) 15 | super() 16 | 17 | @qemu_cmd = qemu_cmd 18 | @expected_print = expected_print 19 | 20 | @test_name = 'Boot test' 21 | @test_description = "Checking for the string: '#{@expected_print}'" 22 | @test_output = [] 23 | @test_error = nil 24 | end 25 | 26 | private 27 | 28 | def expected_string_observed?(qemu_output) 29 | qemu_output.join.include?(@expected_print) 30 | end 31 | 32 | # Convert the recorded output to an array of lines. 33 | def post_process_and_add_output(qemu_output) 34 | @test_output += qemu_output.join.split("\n") 35 | end 36 | 37 | # override 38 | def setup 39 | @qemu_serial = IO.popen(@qemu_cmd, err: '/dev/null') 40 | @qemu_pid = @qemu_serial.pid 41 | end 42 | 43 | # override 44 | def cleanup 45 | Timeout.timeout(MAX_WAIT_SECS) do 46 | Process.kill('TERM', @qemu_pid) 47 | Process.wait 48 | end 49 | rescue StandardError => e 50 | puts 'QEMU graceful shutdown didn\'t work. Skipping it.' 51 | puts e 52 | end 53 | 54 | def run_concrete_test 55 | qemu_output = [] 56 | Timeout.timeout(MAX_WAIT_SECS) do 57 | while IO.select([@qemu_serial]) 58 | qemu_output << @qemu_serial.read_nonblock(1024) 59 | 60 | if expected_string_observed?(qemu_output) 61 | @test_error = false 62 | break 63 | end 64 | end 65 | end 66 | rescue EOFError 67 | @test_error = 'QEMU quit unexpectedly' 68 | rescue Timeout::Error 69 | @test_error = 'Timed out waiting for magic string' 70 | rescue StandardError => e 71 | @test_error = e.message 72 | ensure 73 | post_process_and_add_output(qemu_output) 74 | end 75 | end 76 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ColeopteraOS 2 | 3 | **OS for RaspberryPi based on Rust using CSCI 320 course** 4 | 5 | ## Already available: 6 | 7 | - Freestanding Rust binary code 8 | How to compile for ARM embedded system 9 | 1. Add target 10 | `rustup target add thumbv7em-none-eabihf` 11 | 2. Build for target 12 | `cargo build --target thumbv7em-none-eabihf` 13 | 14 | Learning/Overview: 15 | 16 | | Ressource | URL | 17 | | --------------------------------------------- | -------------------------------------------- | 18 | | CSCI 320 | http://ozark.hendrix.edu/~ferrer/courses/os/ | 19 | | CSCI 320 (newer Version) | https://hendrix-cs.github.io/csci320/ | 20 | | Writing an OS in Rust (mentioned by CSCI 320) | https://os.phil-opp.com/ | 21 | 22 | Example Code: 23 | 24 | | Ressource | URL | 25 | | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | 26 | | Bare Program using VGA Buf | https://github.com/gjf2a/bare_metal_1 | 27 | | Pacman(?) Clone using VGA Buf | https://github.com/gjf2a/ghost_hunter // https://github.com/gjf2a/ghost_hunter_core // Doc: https://hendrix-cs.github.io/csci320/projects/baremetalgame | 28 | | Writing an OS in Rust (mentioned by CSCI 320) | https://github.com/phil-opp/blog_os | 29 | | Another OS for RPI in Rust tutorial/repo | https://github.com/rust-embedded/rust-raspberrypi-OS-tutorials | 30 | 31 | Useful Tools: 32 | 33 | | Ressource | URL | 34 | | -------------- | ---------------------------------- | 35 | | RasPi Emulator | https://github.com/jhhoward/Faux86 | 36 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/tock_registers-63781f6d4d8c6446.d: -------------------------------------------------------------------------------- 1 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/tock_registers-63781f6d4d8c6446.rmeta: /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/lib.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/interfaces.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/macros.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/registers.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/local_register.rs 2 | 3 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libtock_registers-63781f6d4d8c6446.rlib: /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/lib.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/interfaces.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/macros.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/registers.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/local_register.rs 4 | 5 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/tock_registers-63781f6d4d8c6446.d: /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/lib.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/interfaces.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/macros.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/registers.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/local_register.rs 6 | 7 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/lib.rs: 8 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs: 9 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/interfaces.rs: 10 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/macros.rs: 11 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/registers.rs: 12 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/local_register.rs: 13 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/tock_registers-9cf3f8727549a940.d: -------------------------------------------------------------------------------- 1 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/tock_registers-9cf3f8727549a940.rmeta: /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/lib.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/interfaces.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/macros.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/registers.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/local_register.rs 2 | 3 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libtock_registers-9cf3f8727549a940.rlib: /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/lib.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/interfaces.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/macros.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/registers.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/local_register.rs 4 | 5 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/tock_registers-9cf3f8727549a940.d: /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/lib.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/interfaces.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/macros.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/registers.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/local_register.rs 6 | 7 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/lib.rs: 8 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs: 9 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/interfaces.rs: 10 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/macros.rs: 11 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/registers.rs: 12 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/local_register.rs: 13 | -------------------------------------------------------------------------------- /coleopter_os/src/synchronization.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2020-2021 Andre Richter 4 | 5 | //! Synchronization primitives. 6 | //! 7 | //! # Resources 8 | //! 9 | //! - 10 | //! - 11 | //! - 12 | 13 | use core::cell::UnsafeCell; 14 | 15 | //-------------------------------------------------------------------------------------------------- 16 | // Public Definitions 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | /// Synchronization interfaces. 20 | pub mod interface { 21 | 22 | /// Any object implementing this trait guarantees exclusive access to the data wrapped within 23 | /// the Mutex for the duration of the provided closure. 24 | pub trait Mutex { 25 | /// The type of the data that is wrapped by this mutex. 26 | type Data; 27 | 28 | /// Locks the mutex and grants the closure temporary mutable access to the wrapped data. 29 | fn lock(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R; 30 | } 31 | } 32 | 33 | /// A pseudo-lock for teaching purposes. 34 | /// 35 | /// In contrast to a real Mutex implementation, does not protect against concurrent access from 36 | /// other cores to the contained data. This part is preserved for later lessons. 37 | /// 38 | /// The lock will only be used as long as it is safe to do so, i.e. as long as the kernel is 39 | /// executing single-threaded, aka only running on a single core with interrupts disabled. 40 | pub struct NullLock 41 | where 42 | T: ?Sized, 43 | { 44 | data: UnsafeCell, 45 | } 46 | 47 | //-------------------------------------------------------------------------------------------------- 48 | // Public Code 49 | //-------------------------------------------------------------------------------------------------- 50 | 51 | unsafe impl Send for NullLock where T: ?Sized + Send {} 52 | unsafe impl Sync for NullLock where T: ?Sized + Send {} 53 | 54 | impl NullLock { 55 | /// Create an instance. 56 | pub const fn new(data: T) -> Self { 57 | Self { 58 | data: UnsafeCell::new(data), 59 | } 60 | } 61 | } 62 | 63 | //------------------------------------------------------------------------------ 64 | // OS Interface Code 65 | //------------------------------------------------------------------------------ 66 | 67 | impl interface::Mutex for NullLock { 68 | type Data = T; 69 | 70 | fn lock(&self, f: impl FnOnce(&mut Self::Data) -> R) -> R { 71 | // In a real lock, there would be code encapsulating this line that ensures that this 72 | // mutable reference will ever only be given out once at a time. 73 | let data = unsafe { &mut *self.data.get() }; 74 | 75 | f(data) 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /coleopter_os/target/.rustc_info.json: -------------------------------------------------------------------------------- 1 | {"rustc_fingerprint":18239276821063510185,"outputs":{"931469667778813386":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/mago/.rustup/toolchains/nightly-2021-07-12-aarch64-apple-darwin\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"aarch64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"aes\"\ntarget_feature=\"crc\"\ntarget_feature=\"crypto\"\ntarget_feature=\"dpb\"\ntarget_feature=\"fcma\"\ntarget_feature=\"fp\"\ntarget_feature=\"fp16\"\ntarget_feature=\"jsconv\"\ntarget_feature=\"lse\"\ntarget_feature=\"neon\"\ntarget_feature=\"ras\"\ntarget_feature=\"rcpc\"\ntarget_feature=\"rdm\"\ntarget_feature=\"sha2\"\ntarget_feature=\"v8.1a\"\ntarget_feature=\"v8.2a\"\ntarget_feature=\"v8.3a\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"128\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store=\"128\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"apple\"\nunix\n","stderr":""},"17598535894874457435":{"success":true,"status":"","code":0,"stdout":"rustc 1.55.0-nightly (7a16cfcff 2021-07-11)\nbinary: rustc\ncommit-hash: 7a16cfcffc58cd6994984a2c014b0cc27ed8f66b\ncommit-date: 2021-07-11\nhost: aarch64-apple-darwin\nrelease: 1.55.0-nightly\nLLVM version: 12.0.1\n","stderr":""},"2797684049618456168":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n","stderr":""},"7532513168237495677":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.a\n/Users/mago/.rustup/toolchains/nightly-2021-07-12-aarch64-apple-darwin\ndebug_assertions\npanic=\"abort\"\nproc_macro\ntarget_arch=\"aarch64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_feature=\"crc\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"128\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store=\"128\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"none\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\n","stderr":"warning: dropping unsupported crate type `dylib` for target `aarch64-unknown-none-softfloat`\n\nwarning: dropping unsupported crate type `cdylib` for target `aarch64-unknown-none-softfloat`\n\nwarning: dropping unsupported crate type `proc-macro` for target `aarch64-unknown-none-softfloat`\n\nwarning: 3 warnings emitted\n\n"},"6088743920132632476":{"success":false,"status":"exit status: 1","code":1,"stdout":"","stderr":"error: `-Csplit-debuginfo` is unstable on this platform\n\n"}},"successes":{}} -------------------------------------------------------------------------------- /coleopter_os/utils/miniterm.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # SPDX-License-Identifier: MIT OR Apache-2.0 5 | # 6 | # Copyright (c) 2020-2021 Andre Richter 7 | 8 | require 'rubygems' 9 | require 'bundler/setup' 10 | require 'io/console' 11 | require 'colorize' 12 | require 'serialport' 13 | 14 | SERIAL_BAUD = 921_600 15 | 16 | class ConnectionError < StandardError; end 17 | 18 | # The main class 19 | class MiniTerm 20 | def initialize(serial_name) 21 | @name_short = 'MT' 22 | @target_serial_name = serial_name 23 | @target_serial = nil 24 | @host_console = IO.console 25 | end 26 | 27 | private 28 | 29 | def serial_connected? 30 | File.exist?(@target_serial_name) 31 | end 32 | 33 | def wait_for_serial 34 | return if serial_connected? 35 | 36 | puts "[#{@name_short}] ⏳ Waiting for #{@target_serial_name}" 37 | loop do 38 | sleep(1) 39 | break if serial_connected? 40 | end 41 | end 42 | 43 | def open_serial 44 | wait_for_serial 45 | 46 | @target_serial = SerialPort.new(@target_serial_name, SERIAL_BAUD, 8, 1, SerialPort::NONE) 47 | 48 | # Ensure all output is immediately flushed to the device. 49 | @target_serial.sync = true 50 | rescue Errno::EACCES => e 51 | puts "[#{@name_short}] 🚫 #{e.message} - Maybe try with 'sudo'" 52 | exit 53 | else 54 | puts "[#{@name_short}] ✅ Serial connected" 55 | end 56 | 57 | def terminal 58 | @host_console.raw! 59 | 60 | Thread.abort_on_exception = true 61 | Thread.report_on_exception = false 62 | 63 | # Receive from target and print on host console. 64 | target_to_host = Thread.new do 65 | loop do 66 | char = @target_serial.getc 67 | 68 | raise ConnectionError if char.nil? 69 | 70 | # Translate incoming newline to newline + carriage return. 71 | @host_console.putc("\r") if char == "\n" 72 | @host_console.putc(char) 73 | end 74 | end 75 | 76 | # Transmit host console input to target. 77 | loop do 78 | c = @host_console.getc 79 | 80 | # CTRL + C in raw mode was pressed. 81 | if c == "\u{3}" 82 | target_to_host.kill 83 | break 84 | end 85 | 86 | @target_serial.putc(c) 87 | end 88 | end 89 | 90 | def connetion_reset 91 | @target_serial&.close 92 | @target_serial = nil 93 | @host_console.cooked! 94 | end 95 | 96 | # When the serial lost power or was removed during R/W operation. 97 | def handle_reconnect(_error) 98 | connetion_reset 99 | 100 | puts 101 | puts "[#{@name_short}] ⚡ #{'Connection Error: Reinsert the USB serial again'.light_red}" 102 | end 103 | 104 | def handle_unexpected(error) 105 | connetion_reset 106 | 107 | puts 108 | puts "[#{@name_short}] ⚡ #{"Unexpected Error: #{error.inspect}".light_red}" 109 | end 110 | 111 | public 112 | 113 | def run 114 | open_serial 115 | terminal 116 | rescue ConnectionError, EOFError, Errno::EIO => e 117 | handle_reconnect(e) 118 | retry 119 | rescue StandardError => e 120 | handle_unexpected(e) 121 | ensure 122 | connetion_reset 123 | puts 124 | puts "[#{@name_short}] Bye 👋" 125 | end 126 | end 127 | 128 | ##-------------------------------------------------------------------------------------------------- 129 | ## Execution starts here 130 | ##-------------------------------------------------------------------------------------------------- 131 | if __FILE__ == $PROGRAM_NAME 132 | puts 133 | puts 'Miniterm 1.0'.cyan 134 | puts 135 | 136 | # CTRL + C handler. Only here to suppress Ruby's default exception print. 137 | trap('INT') do 138 | # The `ensure` block from `MiniTerm::run` will run after exit, restoring console state. 139 | exit 140 | end 141 | 142 | MiniTerm.new(ARGV[0]).run 143 | end 144 | -------------------------------------------------------------------------------- /common/serial/miniterm.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # SPDX-License-Identifier: MIT OR Apache-2.0 5 | # 6 | # Copyright (c) 2020-2021 Andre Richter 7 | 8 | require 'rubygems' 9 | require 'bundler/setup' 10 | 11 | require 'colorize' 12 | require 'io/console' 13 | require 'serialport' 14 | 15 | SERIAL_BAUD = 921_600 16 | 17 | class ConnectionError < StandardError; end 18 | 19 | # The main class 20 | class MiniTerm 21 | def initialize(serial_name) 22 | @name_short = 'MT' 23 | @target_serial_name = serial_name 24 | @target_serial = nil 25 | @host_console = IO.console 26 | end 27 | 28 | private 29 | 30 | def serial_connected? 31 | File.exist?(@target_serial_name) 32 | end 33 | 34 | def wait_for_serial 35 | return if serial_connected? 36 | 37 | puts "[#{@name_short}] ⏳ Waiting for #{@target_serial_name}" 38 | loop do 39 | sleep(1) 40 | break if serial_connected? 41 | end 42 | end 43 | 44 | def open_serial 45 | wait_for_serial 46 | 47 | @target_serial = SerialPort.new(@target_serial_name, SERIAL_BAUD, 8, 1, SerialPort::NONE) 48 | 49 | # Ensure all output is immediately flushed to the device. 50 | @target_serial.sync = true 51 | rescue Errno::EACCES => e 52 | puts "[#{@name_short}] 🚫 #{e.message} - Maybe try with 'sudo'" 53 | exit 54 | else 55 | puts "[#{@name_short}] ✅ Serial connected" 56 | end 57 | 58 | def terminal 59 | @host_console.raw! 60 | 61 | Thread.abort_on_exception = true 62 | Thread.report_on_exception = false 63 | 64 | # Receive from target and print on host console. 65 | target_to_host = Thread.new do 66 | loop do 67 | char = @target_serial.getc 68 | 69 | raise ConnectionError if char.nil? 70 | 71 | # Translate incoming newline to newline + carriage return. 72 | @host_console.putc("\r") if char == "\n" 73 | @host_console.putc(char) 74 | end 75 | end 76 | 77 | # Transmit host console input to target. 78 | loop do 79 | c = @host_console.getc 80 | 81 | # CTRL + C in raw mode was pressed. 82 | if c == "\u{3}" 83 | target_to_host.kill 84 | break 85 | end 86 | 87 | @target_serial.putc(c) 88 | end 89 | end 90 | 91 | def connetion_reset 92 | @target_serial&.close 93 | @target_serial = nil 94 | @host_console.cooked! 95 | end 96 | 97 | # When the serial lost power or was removed during R/W operation. 98 | def handle_reconnect(_error) 99 | connetion_reset 100 | 101 | puts 102 | puts "[#{@name_short}] ⚡ #{'Connection Error: Reinsert the USB serial again'.light_red}" 103 | end 104 | 105 | def handle_unexpected(error) 106 | connetion_reset 107 | 108 | puts 109 | puts "[#{@name_short}] ⚡ #{"Unexpected Error: #{error.inspect}".light_red}" 110 | end 111 | 112 | public 113 | 114 | def run 115 | open_serial 116 | terminal 117 | rescue ConnectionError, EOFError, Errno::EIO => e 118 | handle_reconnect(e) 119 | retry 120 | rescue StandardError => e 121 | handle_unexpected(e) 122 | ensure 123 | connetion_reset 124 | puts 125 | puts "[#{@name_short}] Bye 👋" 126 | end 127 | end 128 | 129 | ##-------------------------------------------------------------------------------------------------- 130 | ## Execution starts here 131 | ##-------------------------------------------------------------------------------------------------- 132 | if __FILE__ == $PROGRAM_NAME 133 | puts 134 | puts 'Miniterm 1.0'.cyan 135 | puts 136 | 137 | # CTRL + C handler. Only here to suppress Ruby's default exception print. 138 | trap('INT') do 139 | # The `ensure` block from `MiniTerm::run` will run after exit, restoring console state. 140 | exit 141 | end 142 | 143 | MiniTerm.new(ARGV[0]).run 144 | end 145 | -------------------------------------------------------------------------------- /coleopter_os/utils/minipush.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # SPDX-License-Identifier: MIT OR Apache-2.0 5 | # 6 | # Copyright (c) 2020-2021 Andre Richter 7 | 8 | require_relative 'miniterm' 9 | require 'ruby-progressbar' 10 | require_relative 'minipush/progressbar_patch' 11 | require 'timeout' 12 | 13 | class ProtocolError < StandardError; end 14 | 15 | # The main class 16 | class MiniPush < MiniTerm 17 | def initialize(serial_name, binary_image_path) 18 | super(serial_name) 19 | 20 | @name_short = 'MP' # override 21 | @binary_image_path = binary_image_path 22 | @binary_size = nil 23 | @binary_image = nil 24 | end 25 | 26 | private 27 | 28 | # The three characters signaling the request token form the consecutive sequence "\x03\x03\x03". 29 | def wait_for_binary_request 30 | puts "[#{@name_short}] 🔌 Please power the target now" 31 | 32 | # Timeout for the request token starts after the first sign of life was received. 33 | received = @target_serial.readpartial(4096) 34 | Timeout.timeout(10) do 35 | count = 0 36 | 37 | loop do 38 | raise ProtocolError if received.nil? 39 | 40 | received.chars.each do |c| 41 | if c == "\u{3}" 42 | count += 1 43 | return true if count == 3 44 | else 45 | # A normal character resets token counting. 46 | count = 0 47 | 48 | print c 49 | end 50 | end 51 | 52 | received = @target_serial.readpartial(4096) 53 | end 54 | end 55 | end 56 | 57 | def load_binary 58 | @binary_size = File.size(@binary_image_path) 59 | @binary_image = File.binread(@binary_image_path) 60 | end 61 | 62 | def send_size 63 | @target_serial.print([@binary_size].pack('L<')) 64 | raise ProtocolError if @target_serial.read(2) != 'OK' 65 | end 66 | 67 | def send_binary 68 | pb = ProgressBar.create( 69 | total: @binary_size, 70 | format: "[#{@name_short}] ⏩ Pushing %k KiB %b🦀%i %p%% %r KiB/s %a", 71 | rate_scale: ->(rate) { rate / 1024 }, 72 | length: 92 73 | ) 74 | 75 | # Send in 512 byte chunks. 76 | while pb.progress < pb.total 77 | part = @binary_image.slice(pb.progress, 512) 78 | pb.progress += @target_serial.write(part) 79 | end 80 | end 81 | 82 | # override 83 | def handle_reconnect(_error) 84 | connetion_reset 85 | 86 | puts 87 | puts "[#{@name_short}] ⚡ " \ 88 | "#{'Connection or protocol Error: '.light_red}" \ 89 | "#{'Remove power and USB serial. Reinsert serial first, then power'.light_red}" 90 | sleep(1) while serial_connected? 91 | end 92 | 93 | public 94 | 95 | # override 96 | def run 97 | open_serial 98 | wait_for_binary_request 99 | load_binary 100 | send_size 101 | send_binary 102 | terminal 103 | rescue ConnectionError, EOFError, Errno::EIO, ProtocolError, Timeout::Error => e 104 | handle_reconnect(e) 105 | retry 106 | rescue StandardError => e 107 | handle_unexpected(e) 108 | ensure 109 | connetion_reset 110 | puts 111 | puts "[#{@name_short}] Bye 👋" 112 | end 113 | end 114 | 115 | ##-------------------------------------------------------------------------------------------------- 116 | ## Execution starts here 117 | ##-------------------------------------------------------------------------------------------------- 118 | if __FILE__ == $PROGRAM_NAME 119 | puts 120 | puts 'Minipush 1.0'.cyan 121 | puts 122 | 123 | # CTRL + C handler. Only here to suppress Ruby's default exception print. 124 | trap('INT') do 125 | # The `ensure` block from `MiniPush::run` will run after exit, restoring console state. 126 | exit 127 | end 128 | 129 | MiniPush.new(ARGV[0], ARGV[1]).run 130 | end 131 | -------------------------------------------------------------------------------- /common/serial/minipush.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # SPDX-License-Identifier: MIT OR Apache-2.0 5 | # 6 | # Copyright (c) 2020-2021 Andre Richter 7 | 8 | require_relative 'miniterm' 9 | require 'ruby-progressbar' 10 | require_relative 'minipush/progressbar_patch' 11 | require 'timeout' 12 | 13 | class ProtocolError < StandardError; end 14 | 15 | # The main class 16 | class MiniPush < MiniTerm 17 | def initialize(serial_name, payload_path) 18 | super(serial_name) 19 | 20 | @name_short = 'MP' # override 21 | @payload_path = payload_path 22 | @payload_size = nil 23 | @payload_data = nil 24 | end 25 | 26 | private 27 | 28 | # The three characters signaling the request token form the consecutive sequence "\x03\x03\x03". 29 | def wait_for_payload_request 30 | puts "[#{@name_short}] 🔌 Please power the target now" 31 | 32 | # Timeout for the request token starts after the first sign of life was received. 33 | received = @target_serial.readpartial(4096) 34 | Timeout.timeout(10) do 35 | count = 0 36 | 37 | loop do 38 | raise ProtocolError if received.nil? 39 | 40 | received.chars.each do |c| 41 | if c == "\u{3}" 42 | count += 1 43 | return true if count == 3 44 | else 45 | # A normal character resets token counting. 46 | count = 0 47 | 48 | print c 49 | end 50 | end 51 | 52 | received = @target_serial.readpartial(4096) 53 | end 54 | end 55 | end 56 | 57 | def load_payload 58 | @payload_size = File.size(@payload_path) 59 | @payload_data = File.binread(@payload_path) 60 | end 61 | 62 | def send_size 63 | @target_serial.print([@payload_size].pack('L<')) 64 | raise ProtocolError if @target_serial.read(2) != 'OK' 65 | end 66 | 67 | def send_payload 68 | pb = ProgressBar.create( 69 | total: @payload_size, 70 | format: "[#{@name_short}] ⏩ Pushing %k KiB %b🦀%i %p%% %r KiB/s %a", 71 | rate_scale: ->(rate) { rate / 1024 }, 72 | length: 92, 73 | output: $stdout 74 | ) 75 | 76 | # Send in 512 byte chunks. 77 | while pb.progress < pb.total 78 | part = @payload_data.slice(pb.progress, 512) 79 | pb.progress += @target_serial.write(part) 80 | end 81 | end 82 | 83 | # override 84 | def handle_reconnect(_error) 85 | connetion_reset 86 | 87 | puts 88 | puts "[#{@name_short}] ⚡ " \ 89 | "#{'Connection or protocol Error: '.light_red}" \ 90 | "#{'Remove power and USB serial. Reinsert serial first, then power'.light_red}" 91 | sleep(1) while serial_connected? 92 | end 93 | 94 | public 95 | 96 | # override 97 | def run 98 | open_serial 99 | wait_for_payload_request 100 | load_payload 101 | send_size 102 | send_payload 103 | terminal 104 | rescue ConnectionError, EOFError, Errno::EIO, ProtocolError, Timeout::Error => e 105 | handle_reconnect(e) 106 | retry 107 | rescue StandardError => e 108 | handle_unexpected(e) 109 | ensure 110 | connetion_reset 111 | puts 112 | puts "[#{@name_short}] Bye 👋" 113 | end 114 | end 115 | 116 | ##-------------------------------------------------------------------------------------------------- 117 | ## Execution starts here 118 | ##-------------------------------------------------------------------------------------------------- 119 | if __FILE__ == $PROGRAM_NAME 120 | puts 121 | puts 'Minipush 1.0'.cyan 122 | puts 123 | 124 | # CTRL + C handler. Only here to suppress Ruby's default exception print. 125 | trap('INT') do 126 | # The `ensure` block from `MiniPush::run` will run after exit, restoring console state. 127 | exit 128 | end 129 | 130 | MiniPush.new(ARGV[0], ARGV[1]).run 131 | end 132 | -------------------------------------------------------------------------------- /coleopter_os/src/bsp/device_driver/bcm/bcm2xxx_gpio.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | //! GPIO Driver. 6 | 7 | use crate::{ 8 | bsp::device_driver::common::MMIODerefWrapper, driver, synchronization, 9 | synchronization::NullLock, 10 | }; 11 | use tock_registers::{ 12 | interfaces::{ReadWriteable, Writeable}, 13 | register_bitfields, register_structs, 14 | registers::ReadWrite, 15 | }; 16 | 17 | //-------------------------------------------------------------------------------------------------- 18 | // Private Definitions 19 | //-------------------------------------------------------------------------------------------------- 20 | 21 | // GPIO registers. 22 | // 23 | // Descriptions taken from 24 | // - https://github.com/raspberrypi/documentation/files/1888662/BCM2837-ARM-Peripherals.-.Revised.-.V2-1.pdf 25 | // - https://datasheets.raspberrypi.org/bcm2711/bcm2711-peripherals.pdf 26 | register_bitfields! { 27 | u32, 28 | 29 | /// GPIO Function Select 1 30 | GPFSEL1 [ 31 | /// Pin 15 32 | FSEL15 OFFSET(15) NUMBITS(3) [ 33 | Input = 0b000, 34 | Output = 0b001, 35 | AltFunc0 = 0b100 // PL011 UART RX 36 | 37 | ], 38 | 39 | /// Pin 14 40 | FSEL14 OFFSET(12) NUMBITS(3) [ 41 | Input = 0b000, 42 | Output = 0b001, 43 | AltFunc0 = 0b100 // PL011 UART TX 44 | ] 45 | ], 46 | 47 | /// GPIO Pull-up/down Register 48 | /// 49 | /// BCM2837 only. 50 | GPPUD [ 51 | /// Controls the actuation of the internal pull-up/down control line to ALL the GPIO pins. 52 | PUD OFFSET(0) NUMBITS(2) [ 53 | Off = 0b00, 54 | PullDown = 0b01, 55 | PullUp = 0b10 56 | ] 57 | ], 58 | 59 | /// GPIO Pull-up/down Clock Register 0 60 | /// 61 | /// BCM2837 only. 62 | GPPUDCLK0 [ 63 | /// Pin 15 64 | PUDCLK15 OFFSET(15) NUMBITS(1) [ 65 | NoEffect = 0, 66 | AssertClock = 1 67 | ], 68 | 69 | /// Pin 14 70 | PUDCLK14 OFFSET(14) NUMBITS(1) [ 71 | NoEffect = 0, 72 | AssertClock = 1 73 | ] 74 | ], 75 | 76 | /// GPIO Pull-up / Pull-down Register 0 77 | /// 78 | /// BCM2711 only. 79 | GPIO_PUP_PDN_CNTRL_REG0 [ 80 | /// Pin 15 81 | GPIO_PUP_PDN_CNTRL15 OFFSET(30) NUMBITS(2) [ 82 | NoResistor = 0b00, 83 | PullUp = 0b01 84 | ], 85 | 86 | /// Pin 14 87 | GPIO_PUP_PDN_CNTRL14 OFFSET(28) NUMBITS(2) [ 88 | NoResistor = 0b00, 89 | PullUp = 0b01 90 | ] 91 | ] 92 | } 93 | 94 | register_structs! { 95 | #[allow(non_snake_case)] 96 | RegisterBlock { 97 | (0x00 => _reserved1), 98 | (0x04 => GPFSEL1: ReadWrite), 99 | (0x08 => _reserved2), 100 | (0x94 => GPPUD: ReadWrite), 101 | (0x98 => GPPUDCLK0: ReadWrite), 102 | (0x9C => _reserved3), 103 | (0xE4 => GPIO_PUP_PDN_CNTRL_REG0: ReadWrite), 104 | (0xE8 => @END), 105 | } 106 | } 107 | 108 | /// Abstraction for the associated MMIO registers. 109 | type Registers = MMIODerefWrapper; 110 | 111 | //-------------------------------------------------------------------------------------------------- 112 | // Public Definitions 113 | //-------------------------------------------------------------------------------------------------- 114 | 115 | pub struct GPIOInner { 116 | registers: Registers, 117 | } 118 | 119 | // Export the inner struct so that BSPs can use it for the panic handler. 120 | pub use GPIOInner as PanicGPIO; 121 | 122 | /// Representation of the GPIO HW. 123 | pub struct GPIO { 124 | inner: NullLock, 125 | } 126 | 127 | //-------------------------------------------------------------------------------------------------- 128 | // Public Code 129 | //-------------------------------------------------------------------------------------------------- 130 | 131 | impl GPIOInner { 132 | /// Create an instance. 133 | /// 134 | /// # Safety 135 | /// 136 | /// - The user must ensure to provide a correct MMIO start address. 137 | pub const unsafe fn new(mmio_start_addr: usize) -> Self { 138 | Self { 139 | registers: Registers::new(mmio_start_addr), 140 | } 141 | } 142 | 143 | /// Disable pull-up/down on pins 14 and 15. 144 | #[cfg(feature = "bsp_rpi3")] 145 | fn disable_pud_14_15_bcm2837(&mut self) { 146 | use crate::cpu; 147 | 148 | // Make an educated guess for a good delay value (Sequence described in the BCM2837 149 | // peripherals PDF). 150 | // 151 | // - According to Wikipedia, the fastest Pi3 clocks around 1.4 GHz. 152 | // - The Linux 2837 GPIO driver waits 1 µs between the steps. 153 | // 154 | // So lets try to be on the safe side and default to 2000 cycles, which would equal 1 µs 155 | // would the CPU be clocked at 2 GHz. 156 | const DELAY: usize = 2000; 157 | 158 | self.registers.GPPUD.write(GPPUD::PUD::Off); 159 | cpu::spin_for_cycles(DELAY); 160 | 161 | self.registers 162 | .GPPUDCLK0 163 | .write(GPPUDCLK0::PUDCLK15::AssertClock + GPPUDCLK0::PUDCLK14::AssertClock); 164 | cpu::spin_for_cycles(DELAY); 165 | 166 | self.registers.GPPUD.write(GPPUD::PUD::Off); 167 | self.registers.GPPUDCLK0.set(0); 168 | } 169 | 170 | /// Disable pull-up/down on pins 14 and 15. 171 | #[cfg(feature = "bsp_rpi4")] 172 | fn disable_pud_14_15_bcm2711(&mut self) { 173 | self.registers.GPIO_PUP_PDN_CNTRL_REG0.write( 174 | GPIO_PUP_PDN_CNTRL_REG0::GPIO_PUP_PDN_CNTRL15::PullUp 175 | + GPIO_PUP_PDN_CNTRL_REG0::GPIO_PUP_PDN_CNTRL14::PullUp, 176 | ); 177 | } 178 | 179 | /// Map PL011 UART as standard output. 180 | /// 181 | /// TX to pin 14 182 | /// RX to pin 15 183 | pub fn map_pl011_uart(&mut self) { 184 | // Select the UART on pins 14 and 15. 185 | self.registers 186 | .GPFSEL1 187 | .modify(GPFSEL1::FSEL15::AltFunc0 + GPFSEL1::FSEL14::AltFunc0); 188 | 189 | // Disable pull-up/down on pins 14 and 15. 190 | #[cfg(feature = "bsp_rpi3")] 191 | self.disable_pud_14_15_bcm2837(); 192 | 193 | #[cfg(feature = "bsp_rpi4")] 194 | self.disable_pud_14_15_bcm2711(); 195 | } 196 | } 197 | 198 | impl GPIO { 199 | /// Create an instance. 200 | /// 201 | /// # Safety 202 | /// 203 | /// - The user must ensure to provide a correct MMIO start address. 204 | pub const unsafe fn new(mmio_start_addr: usize) -> Self { 205 | Self { 206 | inner: NullLock::new(GPIOInner::new(mmio_start_addr)), 207 | } 208 | } 209 | 210 | /// Concurrency safe version of `GPIOInner.map_pl011_uart()` 211 | pub fn map_pl011_uart(&self) { 212 | self.inner.lock(|inner| inner.map_pl011_uart()) 213 | } 214 | } 215 | 216 | //------------------------------------------------------------------------------ 217 | // OS Interface Code 218 | //------------------------------------------------------------------------------ 219 | use synchronization::interface::Mutex; 220 | 221 | impl driver::interface::DeviceDriver for GPIO { 222 | fn compatible(&self) -> &'static str { 223 | "BCM GPIO" 224 | } 225 | } -------------------------------------------------------------------------------- /coleopter_os/src/main.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | // Rust embedded logo for `make doc`. 6 | #![doc(html_logo_url = "https://git.io/JeGIp")] 7 | 8 | //! The `kernel` binary. 9 | //! 10 | //! # Code organization and architecture 11 | //! 12 | //! The code is divided into different *modules*, each representing a typical **subsystem** of the 13 | //! `kernel`. Top-level module files of subsystems reside directly in the `src` folder. For example, 14 | //! 15 | //! ## Visibility of processor architecture code 16 | //! 17 | //! Some of the `kernel`'s subsystems depend on low-level code that is specific to the target 18 | //! processor architecture. For each supported processor architecture, there exists a subfolder in 19 | //! `src/_arch`, for example, `src/_arch/aarch64`. 20 | //! 21 | //! The architecture folders mirror the subsystem modules laid out in `src`. For example, 22 | //! architectural code that belongs to the `kernel`'s MMU subsystem (`src/memory/mmu.rs`) would go 23 | //! into `src/_arch/aarch64/memory/mmu.rs`. The latter file is loaded as a module in 24 | //! `src/memory/mmu.rs` using the `path attribute`. Usually, the chosen module name is the generic 25 | //! module's name prefixed with `arch_`. 26 | //! 27 | //! For example, this is the top of `src/memory/mmu.rs`: 28 | //! 29 | //! ``` 30 | //! #[cfg(target_arch = "aarch64")] 31 | //! #[path = "../_arch/aarch64/memory/mmu.rs"] 32 | //! mod arch_mmu; 33 | //! ``` 34 | //! 35 | //! Often times, items from the `arch_ module` will be publicly reexported by the parent module. 36 | //! This way, each architecture specific module can provide its implementation of an item, while the 37 | //! caller must not be concerned which architecture has been conditionally compiled. 38 | //! 39 | //! ## BSP code 40 | //! 41 | //! `BSP` stands for Board Support Package. `BSP` code is organized under `src/bsp.rs` and contains 42 | //! target board specific definitions and functions. These are things such as the board's memory map 43 | //! or instances of drivers for devices that are featured on the respective board. 44 | //! 45 | //! Just like processor architecture code, the `BSP` code's module structure tries to mirror the 46 | //! `kernel`'s subsystem modules, but there is no reexporting this time. That means whatever is 47 | //! provided must be called starting from the `bsp` namespace, e.g. `bsp::driver::driver_manager()`. 48 | //! 49 | //! ## Kernel interfaces 50 | //! 51 | //! Both `arch` and `bsp` contain code that is conditionally compiled depending on the actual target 52 | //! and board for which the kernel is compiled. For example, the `interrupt controller` hardware of 53 | //! the `Raspberry Pi 3` and the `Raspberry Pi 4` is different, but we want the rest of the `kernel` 54 | //! code to play nicely with any of the two without much hassle. 55 | //! 56 | //! In order to provide a clean abstraction between `arch`, `bsp` and `generic kernel code`, 57 | //! `interface` traits are provided *whenever possible* and *where it makes sense*. They are defined 58 | //! in the respective subsystem module and help to enforce the idiom of *program to an interface, 59 | //! not an implementation*. For example, there will be a common IRQ handling interface which the two 60 | //! different interrupt controller `drivers` of both Raspberrys will implement, and only export the 61 | //! interface to the rest of the `kernel`. 62 | //! 63 | //! ``` 64 | //! +-------------------+ 65 | //! | Interface (Trait) | 66 | //! | | 67 | //! +--+-------------+--+ 68 | //! ^ ^ 69 | //! | | 70 | //! | | 71 | //! +----------+--+ +--+----------+ 72 | //! | kernel code | | bsp code | 73 | //! | | | arch code | 74 | //! +-------------+ +-------------+ 75 | //! ``` 76 | //! 77 | //! # Summary 78 | //! 79 | //! For a logical `kernel` subsystem, corresponding code can be distributed over several physical 80 | //! locations. Here is an example for the **memory** subsystem: 81 | //! 82 | //! - `src/memory.rs` and `src/memory/**/*` 83 | //! - Common code that is agnostic of target processor architecture and `BSP` characteristics. 84 | //! - Example: A function to zero a chunk of memory. 85 | //! - Interfaces for the memory subsystem that are implemented by `arch` or `BSP` code. 86 | //! - Example: An `MMU` interface that defines `MMU` function prototypes. 87 | //! - `src/bsp/__board_name__/memory.rs` and `src/bsp/__board_name__/memory/**/*` 88 | //! - `BSP` specific code. 89 | //! - Example: The board's memory map (physical addresses of DRAM and MMIO devices). 90 | //! - `src/_arch/__arch_name__/memory.rs` and `src/_arch/__arch_name__/memory/**/*` 91 | //! - Processor architecture specific code. 92 | //! - Example: Implementation of the `MMU` interface for the `__arch_name__` processor 93 | //! architecture. 94 | //! 95 | //! From a namespace perspective, **memory** subsystem code lives in: 96 | //! 97 | //! - `crate::memory::*` 98 | //! - `crate::bsp::memory::*` 99 | //! 100 | //! # Boot flow 101 | //! 102 | //! 1. The kernel's entry point is the function `cpu::boot::arch_boot::_start()`. 103 | //! - It is implemented in `src/_arch/__arch_name__/cpu/boot.s`. 104 | //! 2. Once finished with architectural setup, the arch code calls [`runtime_init::runtime_init()`]. 105 | //! 106 | //! [`runtime_init::runtime_init()`]: runtime_init/fn.runtime_init.html 107 | 108 | #![allow(clippy::upper_case_acronyms)] 109 | #![feature(const_fn_fn_ptr_basics)] 110 | #![feature(format_args_nl)] 111 | #![feature(global_asm)] 112 | #![feature(panic_info_message)] 113 | #![no_main] 114 | #![no_std] 115 | #![feature(trait_alias)] 116 | 117 | mod bsp; 118 | mod console; 119 | mod cpu; 120 | mod driver; 121 | mod panic_wait; 122 | mod print; 123 | mod synchronization; 124 | /// Early init code. 125 | /// 126 | /// # Safety 127 | /// 128 | /// - Only a single core must be active and running this function. 129 | /// - The init calls in this function must appear in the correct order. 130 | /// 131 | unsafe fn kernel_init() -> ! { 132 | use driver::interface::DriverManager; 133 | 134 | for i in bsp::driver::driver_manager().all_device_drivers().iter() { 135 | if let Err(x) = i.init() { 136 | panic!("Error loading driver: {}: {}", i.compatible(), x); 137 | } 138 | } 139 | bsp::driver::driver_manager().post_device_driver_init(); 140 | // println! is usable from here on. 141 | 142 | // Transition from unsafe to safe. 143 | kernel_main() 144 | } 145 | 146 | 147 | /// The main function running after the early init. 148 | fn kernel_main() -> ! { 149 | use bsp::console::console; 150 | use console::interface::All; 151 | use driver::interface::DriverManager; 152 | 153 | println!( 154 | "[0] {} version {}", 155 | env!("CARGO_PKG_NAME"), 156 | env!("CARGO_PKG_VERSION") 157 | ); 158 | println!("[1] Booting on: {}", bsp::board_name()); 159 | 160 | println!("[2] Drivers loaded:"); 161 | for (i, driver) in bsp::driver::driver_manager() 162 | .all_device_drivers() 163 | .iter() 164 | .enumerate() 165 | { 166 | println!(" {}. {}", i + 1, driver.compatible()); 167 | } 168 | 169 | println!( 170 | "[3] Chars written: {}", 171 | bsp::console::console().chars_written() 172 | ); 173 | println!("[4] Echoing input now"); 174 | 175 | // Discard any spurious received characters before going into echo mode. 176 | console().clear_rx(); 177 | loop { 178 | let c = bsp::console::console().read_char(); 179 | bsp::console::console().write_char(c); 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /coleopter_os/utils/devtool.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # SPDX-License-Identifier: MIT OR Apache-2.0 5 | # 6 | # Copyright (c) 2020-2021 Andre Richter 7 | 8 | require 'rubygems' 9 | require 'bundler/setup' 10 | require 'colorize' 11 | require 'fileutils' 12 | require_relative 'devtool/copyright' 13 | 14 | # Actions for tutorial folders 15 | class TutorialCrate 16 | attr_reader :folder 17 | 18 | def initialize(folder) 19 | @folder = folder 20 | end 21 | 22 | def tutorial? 23 | /[0-9]/.match?(@folder[0]) 24 | end 25 | 26 | def clean 27 | puts 'Cleaning '.light_blue + @folder 28 | 29 | Dir.chdir(@folder) { system('make clean') } 30 | end 31 | 32 | def update 33 | puts 'Updating '.light_blue + @folder 34 | 35 | Dir.chdir(@folder) { system('cargo update') } 36 | end 37 | 38 | def clippy(bsp) 39 | puts "Clippy #{@folder} - BSP: #{bsp}".light_blue 40 | 41 | Dir.chdir(@folder) { exit(1) unless system("BSP=#{bsp} make clippy") } 42 | end 43 | 44 | def fmt_cargo_rust(args) 45 | Dir.chdir(@folder) { exit(1) unless system("cargo fmt #{args}") } 46 | end 47 | 48 | def make(bsp) 49 | puts "Make #{@folder} - BSP: #{bsp}".light_blue 50 | 51 | Dir.chdir(@folder) { exit(1) unless system("BSP=#{bsp} make") } 52 | end 53 | 54 | def test_unit 55 | return unless kernel_tests? 56 | 57 | puts "Unit Tests #{@folder}".light_blue 58 | 59 | Dir.chdir(@folder) { exit(1) unless system('TEST=unit make test') } 60 | end 61 | 62 | def test_integration 63 | return unless kernel_tests? 64 | 65 | puts "Integration Tests #{@folder}".light_blue 66 | 67 | Dir.chdir(@folder) do 68 | Dir['tests/*.rs'].sort.each do |t| 69 | t = t.delete_prefix('tests/').delete_suffix('.rs') 70 | exit(1) unless system("TEST=#{t} make test") 71 | end 72 | end 73 | end 74 | 75 | private 76 | 77 | def kernel_tests? 78 | File.exist?("#{@folder}/tests/runner.rb") 79 | end 80 | end 81 | 82 | # Forks commands to all applicable receivers 83 | class DevTool 84 | def initialize 85 | @user_has_supplied_crates = false 86 | @bsp = bsp_from_env || SUPPORTED_BSPS.first 87 | 88 | cl = user_supplied_crate_list || Dir['*/Cargo.toml'].sort 89 | @crates = cl.map { |c| TutorialCrate.new(c.delete_suffix('/Cargo.toml')) } 90 | end 91 | 92 | def clean 93 | @crates.each(&:clean) 94 | end 95 | 96 | def update 97 | @crates.each(&:update) 98 | end 99 | 100 | def clippy(bsp = nil) 101 | bsp ||= @bsp 102 | 103 | @crates.each do |c| 104 | c.clippy(bsp) 105 | puts 106 | puts 107 | end 108 | end 109 | 110 | def diff 111 | tuts = tutorials.map(&:folder) 112 | padding = tuts.map(&:length).max 113 | 114 | tuts[0..-2].each_with_index do |original, i| 115 | update = tuts[i + 1] 116 | diff_pair(original, update, padding) 117 | end 118 | end 119 | 120 | def fmt 121 | fmt_cargo_rust(check: false) 122 | puts 123 | fmt_prettier(check: false) 124 | end 125 | 126 | def fmt_check 127 | fmt_cargo_rust(check: true) 128 | puts 129 | fmt_prettier(check: true) 130 | end 131 | 132 | def make(bsp = nil) 133 | bsp ||= @bsp 134 | 135 | @crates.each do |c| 136 | c.make(bsp) 137 | puts 138 | puts 139 | end 140 | end 141 | 142 | def make_xtra 143 | return if @user_has_supplied_crates 144 | 145 | puts 'Make Xtra stuff'.light_blue 146 | system('cd *_uart_chainloader && bash update.sh') 147 | system('cd X1_JTAG_boot && bash update.sh') 148 | end 149 | 150 | def test_xtra 151 | return if @user_has_supplied_crates 152 | 153 | puts 'Test Xtra stuff'.light_blue 154 | exit(1) unless system('cd *_uart_chainloader && make test') 155 | end 156 | 157 | def test_unit 158 | @crates.each(&:test_unit) 159 | end 160 | 161 | def test_integration 162 | @crates.each(&:test_integration) 163 | end 164 | 165 | def copyright 166 | exit(1) unless copyright_check_files(copyright_source_files) 167 | end 168 | 169 | def misspell 170 | puts 'Misspell'.light_blue 171 | exit(1) unless system(".vendor/misspell -error #{tracked_files.join(' ')}") 172 | end 173 | 174 | def rubocop 175 | puts 'Rubocop'.light_blue 176 | exit(1) unless system('bundle exec rubocop') 177 | end 178 | 179 | def ready_for_publish 180 | clean 181 | fmt 182 | misspell 183 | rubocop 184 | clippy('rpi4') 185 | clippy('rpi3') 186 | copyright 187 | diff 188 | 189 | clean 190 | make_xtra 191 | test_xtra 192 | test_unit 193 | test_integration 194 | clean 195 | end 196 | 197 | def ready_for_publish_no_rust 198 | clean 199 | fmt 200 | misspell 201 | rubocop 202 | copyright 203 | diff 204 | clean 205 | end 206 | 207 | private 208 | 209 | SUPPORTED_BSPS = %w[rpi3 rpi4].freeze 210 | 211 | def bsp_from_env 212 | bsp = ENV['BSP'] 213 | 214 | return bsp if SUPPORTED_BSPS.include?(bsp) 215 | 216 | nil 217 | end 218 | 219 | def fmt_cargo_rust(check: false) 220 | args = '-- --check' if check 221 | 222 | @crates.each do |c| 223 | print 'Rust cargo fmt '.light_blue 224 | print "#{args} ".light_blue unless args.nil? 225 | puts c.folder 226 | 227 | Process.fork { c.fmt_cargo_rust(args) } 228 | end 229 | Process.waitall 230 | end 231 | 232 | def fmt_prettier(check: false) 233 | args = if check 234 | '--check' 235 | else 236 | '--write' 237 | end 238 | 239 | args += if @user_has_supplied_crates 240 | " #{@crates.map(&:folder).join(' ')}" 241 | else 242 | ' .' 243 | end 244 | 245 | puts 'Prettier:'.light_blue 246 | exit(1) unless system("./node_modules/.bin/prettier #{args}") 247 | end 248 | 249 | def user_supplied_crate_list 250 | folders = ARGV.drop(1) 251 | 252 | return nil if folders.empty? 253 | 254 | crates = folders.map { |d| "#{d}/Cargo.toml" }.sort 255 | crates.each do |c| 256 | unless File.exist?(c) 257 | puts "Crate not found: #{c}" 258 | exit(1) 259 | end 260 | end 261 | 262 | @user_has_supplied_crates = true 263 | crates 264 | end 265 | 266 | def tutorials 267 | @crates.select(&:tutorial?) 268 | end 269 | 270 | def tracked_files 271 | crate_list = @crates.map(&:folder).join(' ') if @user_has_supplied_crates 272 | 273 | `git ls-files #{crate_list}`.split("\n") # crates_list == nil means all files 274 | end 275 | 276 | def diff_pair(original, update, padding) 277 | # Only diff adjacent tutorials. This checks the numbers of the tutorial folders. 278 | return unless original[0..1].to_i + 1 == update[0..1].to_i 279 | 280 | puts 'Diffing '.light_blue + original.ljust(padding) + " -> #{update}" 281 | system("bash utils/diff_tut_folders.bash #{original} #{update}") 282 | end 283 | 284 | def copyright_source_files 285 | extensions = ['.S', '.rs', '.rb'] 286 | 287 | # NOTE: The selection result is the return value of the function. 288 | tracked_files.select do |f| 289 | next unless File.exist?(f) 290 | next if f.include?('build.rs') 291 | 292 | f.include?('Makefile') || 293 | f.include?('Dockerfile') || 294 | extensions.include?(File.extname(f)) 295 | end 296 | end 297 | end 298 | 299 | ##-------------------------------------------------------------------------------------------------- 300 | ## Execution starts here 301 | ##-------------------------------------------------------------------------------------------------- 302 | tool = DevTool.new 303 | cmd = ARGV[0] 304 | commands = tool.public_methods(false).sort 305 | 306 | if commands.include?(cmd&.to_sym) 307 | tool.public_send(cmd) 308 | else 309 | puts "Usage: ./#{__FILE__.split('/').last} COMMAND [optional list of folders]" 310 | puts 311 | puts 'Commands:' 312 | commands.each { |m| puts " #{m}" } 313 | end 314 | -------------------------------------------------------------------------------- /coleopter_os/Makefile: -------------------------------------------------------------------------------- 1 | ## SPDX-License-Identifier: MIT OR Apache-2.0 2 | ## 3 | ## Copyright (c) 2018-2021 Andre Richter 4 | 5 | include ../common/color.mk.in 6 | 7 | ##-------------------------------------------------------------------------------------------------- 8 | ## Optional, user-provided configuration values 9 | ##-------------------------------------------------------------------------------------------------- 10 | 11 | # Default to the RPi3. 12 | BSP ?= rpi3 13 | 14 | # Default to a serial device name that is common in Linux. 15 | DEV_SERIAL ?= /dev/ttyUSB0 16 | 17 | 18 | 19 | ##-------------------------------------------------------------------------------------------------- 20 | ## Hardcoded configuration values 21 | ##-------------------------------------------------------------------------------------------------- 22 | 23 | # BSP-specific arguments. 24 | ifeq ($(BSP),rpi3) 25 | TARGET = aarch64-unknown-none-softfloat 26 | KERNEL_BIN = kernel8.img 27 | QEMU_BINARY = qemu-system-aarch64 28 | QEMU_MACHINE_TYPE = raspi3 29 | QEMU_RELEASE_ARGS = -serial stdio -display none 30 | OBJDUMP_BINARY = aarch64-none-elf-objdump 31 | NM_BINARY = aarch64-none-elf-nm 32 | READELF_BINARY = aarch64-none-elf-readelf 33 | LINKER_FILE = src/bsp/raspberrypi/link.ld 34 | RUSTC_MISC_ARGS = -C target-cpu=cortex-a53 35 | else ifeq ($(BSP),rpi4) 36 | TARGET = aarch64-unknown-none-softfloat 37 | KERNEL_BIN = kernel8.img 38 | QEMU_BINARY = qemu-system-aarch64 39 | QEMU_MACHINE_TYPE = 40 | QEMU_RELEASE_ARGS = -serial stdio -display none 41 | OBJDUMP_BINARY = aarch64-none-elf-objdump 42 | NM_BINARY = aarch64-none-elf-nm 43 | READELF_BINARY = aarch64-none-elf-readelf 44 | LINKER_FILE = src/bsp/raspberrypi/link.ld 45 | RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 46 | endif 47 | 48 | QEMU_MISSING_STRING = "This board is not yet supported for QEMU." 49 | 50 | # Export for build.rs. 51 | export LINKER_FILE 52 | 53 | KERNEL_ELF = target/$(TARGET)/release/kernel 54 | 55 | 56 | 57 | ##-------------------------------------------------------------------------------------------------- 58 | ## Command building blocks 59 | ##-------------------------------------------------------------------------------------------------- 60 | RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) 61 | RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs 62 | 63 | FEATURES = --features bsp_$(BSP) 64 | COMPILER_ARGS = --target=$(TARGET) \ 65 | $(FEATURES) \ 66 | --release 67 | 68 | RUSTC_CMD = cargo rustc $(COMPILER_ARGS) 69 | DOC_CMD = cargo doc $(COMPILER_ARGS) 70 | CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) 71 | CHECK_CMD = cargo check $(COMPILER_ARGS) 72 | OBJCOPY_CMD = rust-objcopy \ 73 | --strip-all \ 74 | -O binary 75 | 76 | EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) 77 | EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb 78 | EXEC_MINITERM = ruby ../common/serial/miniterm.rb 79 | 80 | ##------------------------------------------------------------------------------ 81 | ## Dockerization 82 | ##------------------------------------------------------------------------------ 83 | DOCKER_IMAGE = rustembedded/osdev-utils 84 | DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial 85 | DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i 86 | DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common 87 | DOCKER_ARG_DEV = --privileged -v /dev:/dev 88 | 89 | DOCKER_QEMU = $(DOCKER_CMD_INTERACT) $(DOCKER_IMAGE) 90 | DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE) 91 | DOCKER_TEST = $(DOCKER_CMD) $(DOCKER_ARG_DIR_COMMON) $(DOCKER_IMAGE) 92 | 93 | # Dockerize commands, which require USB device passthrough, only on Linux. 94 | ifeq ($(shell uname -s),Linux) 95 | DOCKER_CMD_DEV = $(DOCKER_CMD_INTERACT) $(DOCKER_ARG_DEV) 96 | 97 | DOCKER_MINITERM = $(DOCKER_CMD_DEV) $(DOCKER_ARG_DIR_COMMON) $(DOCKER_IMAGE) 98 | endif 99 | 100 | 101 | 102 | ##-------------------------------------------------------------------------------------------------- 103 | ## Targets 104 | ##-------------------------------------------------------------------------------------------------- 105 | .PHONY: all $(KERNEL_ELF) $(KERNEL_BIN) doc qemu miniterm clippy clean readelf objdump nm check 106 | 107 | all: $(KERNEL_BIN) 108 | 109 | ##------------------------------------------------------------------------------ 110 | ## Build the kernel ELF 111 | ##------------------------------------------------------------------------------ 112 | $(KERNEL_ELF): 113 | $(call colorecho, "\nCompiling kernel - $(BSP)") 114 | @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) 115 | 116 | ##------------------------------------------------------------------------------ 117 | ## Build the stripped kernel binary 118 | ##------------------------------------------------------------------------------ 119 | $(KERNEL_BIN): $(KERNEL_ELF) 120 | @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) 121 | 122 | ##------------------------------------------------------------------------------ 123 | ## Build the documentation 124 | ##------------------------------------------------------------------------------ 125 | doc: 126 | $(call colorecho, "\nGenerating docs") 127 | @$(DOC_CMD) --document-private-items --open 128 | 129 | ##------------------------------------------------------------------------------ 130 | ## Run the kernel in QEMU 131 | ##------------------------------------------------------------------------------ 132 | ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. 133 | 134 | qemu: 135 | $(call colorecho, "\n$(QEMU_MISSING_STRING)") 136 | 137 | else # QEMU is supported. 138 | 139 | qemu: $(KERNEL_BIN) 140 | $(call colorecho, "\nLaunching QEMU") 141 | @$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) 142 | endif 143 | 144 | ##------------------------------------------------------------------------------ 145 | ## Connect to the target's serial 146 | ##------------------------------------------------------------------------------ 147 | miniterm: 148 | @$(DOCKER_MINITERM) $(EXEC_MINITERM) $(DEV_SERIAL) 149 | 150 | ##------------------------------------------------------------------------------ 151 | ## Run clippy 152 | ##------------------------------------------------------------------------------ 153 | clippy: 154 | @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) 155 | 156 | ##------------------------------------------------------------------------------ 157 | ## Clean 158 | ##------------------------------------------------------------------------------ 159 | clean: 160 | rm -rf target $(KERNEL_BIN) 161 | 162 | ##------------------------------------------------------------------------------ 163 | ## Run readelf 164 | ##------------------------------------------------------------------------------ 165 | readelf: $(KERNEL_ELF) 166 | $(call colorecho, "\nLaunching readelf") 167 | @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) 168 | 169 | ##------------------------------------------------------------------------------ 170 | ## Run objdump 171 | ##------------------------------------------------------------------------------ 172 | objdump: $(KERNEL_ELF) 173 | $(call colorecho, "\nLaunching objdump") 174 | @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ 175 | --section .text \ 176 | --section .rodata \ 177 | --section .got \ 178 | $(KERNEL_ELF) | rustfilt 179 | 180 | ##------------------------------------------------------------------------------ 181 | ## Run nm 182 | ##------------------------------------------------------------------------------ 183 | nm: $(KERNEL_ELF) 184 | $(call colorecho, "\nLaunching nm") 185 | @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt 186 | 187 | ##------------------------------------------------------------------------------ 188 | ## Helper target for rust-analyzer 189 | ##------------------------------------------------------------------------------ 190 | check: 191 | @RUSTFLAGS="$(RUSTFLAGS)" $(CHECK_CMD) --message-format=json 192 | 193 | 194 | 195 | ##-------------------------------------------------------------------------------------------------- 196 | ## Testing targets 197 | ##-------------------------------------------------------------------------------------------------- 198 | .PHONY: test test_boot 199 | 200 | ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. 201 | 202 | test_boot test : 203 | $(call colorecho, "\n$(QEMU_MISSING_STRING)") 204 | 205 | else # QEMU is supported. 206 | 207 | ##------------------------------------------------------------------------------ 208 | ## Run boot test 209 | ##------------------------------------------------------------------------------ 210 | test_boot: $(KERNEL_BIN) 211 | $(call colorecho, "\nBoot test - $(BSP)") 212 | @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) 213 | 214 | test: test_boot 215 | 216 | endif -------------------------------------------------------------------------------- /coleopter_os/src/bsp/device_driver/bcm/bcm2xxx_pl011_uart.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2018-2021 Andre Richter 4 | 5 | //! PL011 UART driver. 6 | //! 7 | //! # Resources 8 | //! 9 | //! - 10 | //! - 11 | 12 | use crate::{ 13 | bsp::device_driver::common::MMIODerefWrapper, console, cpu, driver, synchronization, 14 | synchronization::NullLock, 15 | }; 16 | use core::fmt; 17 | use tock_registers::{ 18 | interfaces::{Readable, Writeable}, 19 | register_bitfields, register_structs, 20 | registers::{ReadOnly, ReadWrite, WriteOnly}, 21 | }; 22 | 23 | //-------------------------------------------------------------------------------------------------- 24 | // Private Definitions 25 | //-------------------------------------------------------------------------------------------------- 26 | 27 | // PL011 UART registers. 28 | // 29 | // Descriptions taken from "PrimeCell UART (PL011) Technical Reference Manual" r1p5. 30 | register_bitfields! { 31 | u32, 32 | 33 | /// Flag Register. 34 | FR [ 35 | /// Transmit FIFO empty. The meaning of this bit depends on the state of the FEN bit in the 36 | /// Line Control Register, LCR_H. 37 | /// 38 | /// - If the FIFO is disabled, this bit is set when the transmit holding register is empty. 39 | /// - If the FIFO is enabled, the TXFE bit is set when the transmit FIFO is empty. 40 | /// - This bit does not indicate if there is data in the transmit shift register. 41 | TXFE OFFSET(7) NUMBITS(1) [], 42 | 43 | /// Transmit FIFO full. The meaning of this bit depends on the state of the FEN bit in the 44 | /// LCR_H Register. 45 | /// 46 | /// - If the FIFO is disabled, this bit is set when the transmit holding register is full. 47 | /// - If the FIFO is enabled, the TXFF bit is set when the transmit FIFO is full. 48 | TXFF OFFSET(5) NUMBITS(1) [], 49 | 50 | /// Receive FIFO empty. The meaning of this bit depends on the state of the FEN bit in the 51 | /// LCR_H Register. 52 | /// 53 | /// If the FIFO is disabled, this bit is set when the receive holding register is empty. If 54 | /// the FIFO is enabled, the RXFE bit is set when the receive FIFO is empty. 55 | 56 | /// Receive FIFO empty. The meaning of this bit depends on the state of the FEN bit in the 57 | /// LCR_H Register. 58 | /// 59 | /// - If the FIFO is disabled, this bit is set when the receive holding register is empty. 60 | /// - If the FIFO is enabled, the RXFE bit is set when the receive FIFO is empty. 61 | RXFE OFFSET(4) NUMBITS(1) [], 62 | 63 | /// UART busy. If this bit is set to 1, the UART is busy transmitting data. This bit remains 64 | /// set until the complete byte, including all the stop bits, has been sent from the shift 65 | /// register. 66 | /// 67 | /// This bit is set as soon as the transmit FIFO becomes non-empty, regardless of whether 68 | /// the UART is enabled or not. 69 | BUSY OFFSET(3) NUMBITS(1) [] 70 | ], 71 | 72 | /// Integer Baud Rate Divisor. 73 | IBRD [ 74 | /// The integer baud rate divisor. 75 | BAUD_DIVINT OFFSET(0) NUMBITS(16) [] 76 | ], 77 | 78 | /// Fractional Baud Rate Divisor. 79 | FBRD [ 80 | /// The fractional baud rate divisor. 81 | BAUD_DIVFRAC OFFSET(0) NUMBITS(6) [] 82 | ], 83 | 84 | /// Line Control Register. 85 | LCR_H [ 86 | /// Word length. These bits indicate the number of data bits transmitted or received in a 87 | /// frame. 88 | #[allow(clippy::enum_variant_names)] 89 | WLEN OFFSET(5) NUMBITS(2) [ 90 | FiveBit = 0b00, 91 | SixBit = 0b01, 92 | SevenBit = 0b10, 93 | EightBit = 0b11 94 | ], 95 | 96 | /// Enable FIFOs: 97 | /// 98 | /// 0 = FIFOs are disabled (character mode) that is, the FIFOs become 1-byte-deep holding 99 | /// registers. 100 | /// 101 | /// 1 = Transmit and receive FIFO buffers are enabled (FIFO mode). 102 | FEN OFFSET(4) NUMBITS(1) [ 103 | FifosDisabled = 0, 104 | FifosEnabled = 1 105 | ] 106 | ], 107 | 108 | /// Control Register. 109 | CR [ 110 | /// Receive enable. If this bit is set to 1, the receive section of the UART is enabled. 111 | /// Data reception occurs for either UART signals or SIR signals depending on the setting of 112 | /// the SIREN bit. When the UART is disabled in the middle of reception, it completes the 113 | /// current character before stopping. 114 | RXE OFFSET(9) NUMBITS(1) [ 115 | Disabled = 0, 116 | Enabled = 1 117 | ], 118 | 119 | /// Transmit enable. If this bit is set to 1, the transmit section of the UART is enabled. 120 | /// Data transmission occurs for either UART signals, or SIR signals depending on the 121 | /// setting of the SIREN bit. When the UART is disabled in the middle of transmission, it 122 | /// completes the current character before stopping. 123 | TXE OFFSET(8) NUMBITS(1) [ 124 | Disabled = 0, 125 | Enabled = 1 126 | ], 127 | 128 | /// UART enable: 129 | /// 130 | /// 0 = UART is disabled. If the UART is disabled in the middle of transmission or 131 | /// reception, it completes the current character before stopping. 132 | /// 133 | /// 1 = The UART is enabled. Data transmission and reception occurs for either UART signals 134 | /// or SIR signals depending on the setting of the SIREN bit 135 | UARTEN OFFSET(0) NUMBITS(1) [ 136 | /// If the UART is disabled in the middle of transmission or reception, it completes the 137 | /// current character before stopping. 138 | Disabled = 0, 139 | Enabled = 1 140 | ] 141 | ], 142 | 143 | /// Interrupt Clear Register. 144 | ICR [ 145 | /// Meta field for all pending interrupts. 146 | ALL OFFSET(0) NUMBITS(11) [] 147 | ] 148 | } 149 | 150 | register_structs! { 151 | #[allow(non_snake_case)] 152 | pub RegisterBlock { 153 | (0x00 => DR: ReadWrite), 154 | (0x04 => _reserved1), 155 | (0x18 => FR: ReadOnly), 156 | (0x1c => _reserved2), 157 | (0x24 => IBRD: WriteOnly), 158 | (0x28 => FBRD: WriteOnly), 159 | (0x2c => LCR_H: WriteOnly), 160 | (0x30 => CR: WriteOnly), 161 | (0x34 => _reserved3), 162 | (0x44 => ICR: WriteOnly), 163 | (0x48 => @END), 164 | } 165 | } 166 | 167 | /// Abstraction for the associated MMIO registers. 168 | type Registers = MMIODerefWrapper; 169 | 170 | #[derive(PartialEq)] 171 | enum BlockingMode { 172 | Blocking, 173 | NonBlocking, 174 | } 175 | 176 | //-------------------------------------------------------------------------------------------------- 177 | // Public Definitions 178 | //-------------------------------------------------------------------------------------------------- 179 | 180 | pub struct PL011UartInner { 181 | registers: Registers, 182 | chars_written: usize, 183 | chars_read: usize, 184 | } 185 | 186 | // Export the inner struct so that BSPs can use it for the panic handler. 187 | pub use PL011UartInner as PanicUart; 188 | 189 | /// Representation of the UART. 190 | pub struct PL011Uart { 191 | inner: NullLock, 192 | } 193 | 194 | //-------------------------------------------------------------------------------------------------- 195 | // Public Code 196 | //-------------------------------------------------------------------------------------------------- 197 | 198 | impl PL011UartInner { 199 | /// Create an instance. 200 | /// 201 | /// # Safety 202 | /// 203 | /// - The user must ensure to provide a correct MMIO start address. 204 | pub const unsafe fn new(mmio_start_addr: usize) -> Self { 205 | Self { 206 | registers: Registers::new(mmio_start_addr), 207 | chars_written: 0, 208 | chars_read: 0, 209 | } 210 | } 211 | 212 | /// Set up baud rate and characteristics. 213 | /// 214 | /// This results in 8N1 and 921_600 baud. 215 | /// 216 | /// The calculation for the BRD is (we set the clock to 48 MHz in config.txt): 217 | /// `(48_000_000 / 16) / 921_600 = 3.2552083`. 218 | /// 219 | /// This means the integer part is `3` and goes into the `IBRD`. 220 | /// The fractional part is `0.2552083`. 221 | /// 222 | /// `FBRD` calculation according to the PL011 Technical Reference Manual: 223 | /// `INTEGER((0.2552083 * 64) + 0.5) = 16`. 224 | /// 225 | /// Therefore, the generated baud rate divider is: `3 + 16/64 = 3.25`. Which results in a 226 | /// genrated baud rate of `48_000_000 / (16 * 3.25) = 923_077`. 227 | /// 228 | /// Error = `((923_077 - 921_600) / 921_600) * 100 = 0.16%`. 229 | pub fn init(&mut self) { 230 | // Execution can arrive here while there are still characters queued in the TX FIFO and 231 | // actively being sent out by the UART hardware. If the UART is turned off in this case, 232 | // those queued characters would be lost. 233 | // 234 | // For example, this can happen during runtime on a call to panic!(), because panic!() 235 | // initializes its own UART instance and calls init(). 236 | // 237 | // Hence, flush first to ensure all pending characters are transmitted. 238 | self.flush(); 239 | 240 | // Turn the UART off temporarily. 241 | self.registers.CR.set(0); 242 | 243 | // Clear all pending interrupts. 244 | self.registers.ICR.write(ICR::ALL::CLEAR); 245 | 246 | // From the PL011 Technical Reference Manual: 247 | // 248 | // The LCR_H, IBRD, and FBRD registers form the single 30-bit wide LCR Register that is 249 | // updated on a single write strobe generated by a LCR_H write. So, to internally update the 250 | // contents of IBRD or FBRD, a LCR_H write must always be performed at the end. 251 | // 252 | // Set the baud rate, 8N1 and FIFO enabled. 253 | self.registers.IBRD.write(IBRD::BAUD_DIVINT.val(3)); 254 | self.registers.FBRD.write(FBRD::BAUD_DIVFRAC.val(16)); 255 | self.registers 256 | .LCR_H 257 | .write(LCR_H::WLEN::EightBit + LCR_H::FEN::FifosEnabled); 258 | 259 | // Turn the UART on. 260 | self.registers 261 | .CR 262 | .write(CR::UARTEN::Enabled + CR::TXE::Enabled + CR::RXE::Enabled); 263 | } 264 | 265 | /// Send a character. 266 | fn write_char(&mut self, c: char) { 267 | // Spin while TX FIFO full is set, waiting for an empty slot. 268 | while self.registers.FR.matches_all(FR::TXFF::SET) { 269 | cpu::nop(); 270 | } 271 | 272 | // Write the character to the buffer. 273 | self.registers.DR.set(c as u32); 274 | 275 | self.chars_written += 1; 276 | } 277 | 278 | /// Block execution until the last buffered character has been physically put on the TX wire. 279 | fn flush(&self) { 280 | // Spin until the busy bit is cleared. 281 | while self.registers.FR.matches_all(FR::BUSY::SET) { 282 | cpu::nop(); 283 | } 284 | } 285 | 286 | /// Retrieve a character. 287 | fn read_char_converting(&mut self, blocking_mode: BlockingMode) -> Option { 288 | // If RX FIFO is empty, 289 | if self.registers.FR.matches_all(FR::RXFE::SET) { 290 | // immediately return in non-blocking mode. 291 | if blocking_mode == BlockingMode::NonBlocking { 292 | return None; 293 | } 294 | 295 | // Otherwise, wait until a char was received. 296 | while self.registers.FR.matches_all(FR::RXFE::SET) { 297 | cpu::nop(); 298 | } 299 | } 300 | 301 | // Read one character. 302 | let mut ret = self.registers.DR.get() as u8 as char; 303 | 304 | // Convert carrige return to newline. 305 | if ret == '\r' { 306 | ret = '\n' 307 | } 308 | 309 | // Update statistics. 310 | self.chars_read += 1; 311 | 312 | Some(ret) 313 | } 314 | } 315 | 316 | /// Implementing `core::fmt::Write` enables usage of the `format_args!` macros, which in turn are 317 | /// used to implement the `kernel`'s `print!` and `println!` macros. By implementing `write_str()`, 318 | /// we get `write_fmt()` automatically. 319 | /// 320 | /// The function takes an `&mut self`, so it must be implemented for the inner struct. 321 | /// 322 | /// See [`src/print.rs`]. 323 | /// 324 | /// [`src/print.rs`]: ../../print/index.html 325 | impl fmt::Write for PL011UartInner { 326 | fn write_str(&mut self, s: &str) -> fmt::Result { 327 | for c in s.chars() { 328 | self.write_char(c); 329 | } 330 | 331 | Ok(()) 332 | } 333 | } 334 | 335 | impl PL011Uart { 336 | /// Create an instance. 337 | /// 338 | /// # Safety 339 | /// 340 | /// - The user must ensure to provide a correct MMIO start address. 341 | pub const unsafe fn new(mmio_start_addr: usize) -> Self { 342 | Self { 343 | inner: NullLock::new(PL011UartInner::new(mmio_start_addr)), 344 | } 345 | } 346 | } 347 | 348 | //------------------------------------------------------------------------------ 349 | // OS Interface Code 350 | //------------------------------------------------------------------------------ 351 | use synchronization::interface::Mutex; 352 | 353 | impl driver::interface::DeviceDriver for PL011Uart { 354 | fn compatible(&self) -> &'static str { 355 | "BCM PL011 UART" 356 | } 357 | 358 | unsafe fn init(&self) -> Result<(), &'static str> { 359 | self.inner.lock(|inner| inner.init()); 360 | 361 | Ok(()) 362 | } 363 | } 364 | 365 | impl console::interface::Write for PL011Uart { 366 | /// Passthrough of `args` to the `core::fmt::Write` implementation, but guarded by a Mutex to 367 | /// serialize access. 368 | fn write_char(&self, c: char) { 369 | self.inner.lock(|inner| inner.write_char(c)); 370 | } 371 | 372 | fn write_fmt(&self, args: core::fmt::Arguments) -> fmt::Result { 373 | // Fully qualified syntax for the call to `core::fmt::Write::write:fmt()` to increase 374 | // readability. 375 | self.inner.lock(|inner| fmt::Write::write_fmt(inner, args)) 376 | } 377 | 378 | fn flush(&self) { 379 | // Spin until TX FIFO empty is set. 380 | self.inner.lock(|inner| inner.flush()); 381 | } 382 | } 383 | 384 | impl console::interface::Read for PL011Uart { 385 | fn read_char(&self) -> char { 386 | self.inner 387 | .lock(|inner| inner.read_char_converting(BlockingMode::Blocking).unwrap()) 388 | } 389 | 390 | fn clear_rx(&self) { 391 | // Read from the RX FIFO until it is indicating empty. 392 | while self 393 | .inner 394 | .lock(|inner| inner.read_char_converting(BlockingMode::NonBlocking)) 395 | .is_some() 396 | {} 397 | } 398 | } 399 | 400 | impl console::interface::Statistics for PL011Uart { 401 | fn chars_written(&self) -> usize { 402 | self.inner.lock(|inner| inner.chars_written) 403 | } 404 | 405 | fn chars_read(&self) -> usize { 406 | self.inner.lock(|inner| inner.chars_read) 407 | } 408 | } -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/cortex_a-64607851b942a163.d: -------------------------------------------------------------------------------- 1 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/cortex_a-64607851b942a163.rmeta: /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/lib.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/asm.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/asm/barrier.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/macros.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntfrq_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cnthctl_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntp_ctl_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntp_tval_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntpct_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntv_ctl_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntv_tval_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntvct_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntvoff_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/currentel.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/daif.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/elr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/elr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/elr_el3.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/esr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/esr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/far_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/far_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/hcr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/id_aa64mmfr0_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/lr.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/mair_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/mair_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/midr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/mpidr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/par_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/scr_el3.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sctlr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sctlr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sp.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sp_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sp_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsel.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsr_el3.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tcr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tcr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tpidr_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tpidr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tpidrro_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/ttbr0_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/ttbr0_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/ttbr1_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/vbar_el1.rs 2 | 3 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/libcortex_a-64607851b942a163.rlib: /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/lib.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/asm.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/asm/barrier.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/macros.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntfrq_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cnthctl_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntp_ctl_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntp_tval_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntpct_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntv_ctl_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntv_tval_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntvct_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntvoff_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/currentel.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/daif.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/elr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/elr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/elr_el3.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/esr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/esr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/far_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/far_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/hcr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/id_aa64mmfr0_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/lr.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/mair_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/mair_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/midr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/mpidr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/par_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/scr_el3.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sctlr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sctlr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sp.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sp_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sp_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsel.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsr_el3.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tcr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tcr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tpidr_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tpidr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tpidrro_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/ttbr0_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/ttbr0_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/ttbr1_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/vbar_el1.rs 4 | 5 | /Users/mago/Projects/ColeopteraOS/coleopter_os/target/aarch64-unknown-none-softfloat/release/deps/cortex_a-64607851b942a163.d: /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/lib.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/asm.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/asm/barrier.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/macros.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntfrq_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cnthctl_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntp_ctl_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntp_tval_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntpct_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntv_ctl_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntv_tval_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntvct_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntvoff_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/currentel.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/daif.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/elr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/elr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/elr_el3.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/esr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/esr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/far_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/far_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/hcr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/id_aa64mmfr0_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/lr.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/mair_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/mair_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/midr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/mpidr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/par_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/scr_el3.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sctlr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sctlr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sp.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sp_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sp_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsel.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsr_el3.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tcr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tcr_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tpidr_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tpidr_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tpidrro_el0.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/ttbr0_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/ttbr0_el2.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/ttbr1_el1.rs /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/vbar_el1.rs 6 | 7 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/lib.rs: 8 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/asm.rs: 9 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/asm/barrier.rs: 10 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers.rs: 11 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/macros.rs: 12 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntfrq_el0.rs: 13 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cnthctl_el2.rs: 14 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntp_ctl_el0.rs: 15 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntp_tval_el0.rs: 16 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntpct_el0.rs: 17 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntv_ctl_el0.rs: 18 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntv_tval_el0.rs: 19 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntvct_el0.rs: 20 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/cntvoff_el2.rs: 21 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/currentel.rs: 22 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/daif.rs: 23 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/elr_el1.rs: 24 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/elr_el2.rs: 25 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/elr_el3.rs: 26 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/esr_el1.rs: 27 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/esr_el2.rs: 28 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/far_el1.rs: 29 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/far_el2.rs: 30 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/hcr_el2.rs: 31 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/id_aa64mmfr0_el1.rs: 32 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/lr.rs: 33 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/mair_el1.rs: 34 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/mair_el2.rs: 35 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/midr_el1.rs: 36 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/mpidr_el1.rs: 37 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/par_el1.rs: 38 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/scr_el3.rs: 39 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sctlr_el1.rs: 40 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sctlr_el2.rs: 41 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sp.rs: 42 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sp_el0.rs: 43 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/sp_el1.rs: 44 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsel.rs: 45 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsr_el1.rs: 46 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsr_el2.rs: 47 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/spsr_el3.rs: 48 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tcr_el1.rs: 49 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tcr_el2.rs: 50 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tpidr_el0.rs: 51 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tpidr_el1.rs: 52 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/tpidrro_el0.rs: 53 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/ttbr0_el1.rs: 54 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/ttbr0_el2.rs: 55 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/ttbr1_el1.rs: 56 | /Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-a-6.1.0/src/registers/vbar_el1.rs: 57 | -------------------------------------------------------------------------------- /coleopter_os/target/aarch64-unknown-none-softfloat/release/.fingerprint/tock-registers-63781f6d4d8c6446/output-lib-tock-registers: -------------------------------------------------------------------------------- 1 | {"message":"trait bounds other than `Sized` on const fn parameters are unstable","code":{"code":"E0723","explanation":"An unstable feature in `const` contexts was used.\n\nErroneous code example:\n\n```compile_fail,E0723\nconst fn foo(_: T) { // error!\n // ...\n}\n```\n\nTo enable this feature on a nightly version of rustc, add the `const_fn`\nfeature flag:\n\n```\n#![feature(const_fn)]\n\nconst fn foo(_: T) { // ok!\n // ...\n}\n```\n"},"level":"error","spans":[{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":3103,"byte_end":3104,"line_start":82,"line_end":82,"column_start":6,"column_end":7,"is_primary":true,"text":[{"text":"impl Field {","highlight_start":6,"highlight_end":7}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"see issue #57563 for more information","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add `#![feature(const_fn)]` to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0723]\u001b[0m\u001b[0m\u001b[1m: trait bounds other than `Sized` on const fn parameters are unstable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs:82:6\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m82\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0mimpl Field {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: see issue #57563 for more information\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mhelp\u001b[0m\u001b[0m: add `#![feature(const_fn)]` to the crate attributes to enable\u001b[0m\n\n"} 2 | {"message":"trait bounds other than `Sized` on const fn parameters are unstable","code":{"code":"E0723","explanation":"An unstable feature in `const` contexts was used.\n\nErroneous code example:\n\n```compile_fail,E0723\nconst fn foo(_: T) { // error!\n // ...\n}\n```\n\nTo enable this feature on a nightly version of rustc, add the `const_fn`\nfeature flag:\n\n```\n#![feature(const_fn)]\n\nconst fn foo(_: T) { // ok!\n // ...\n}\n```\n"},"level":"error","spans":[{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":3116,"byte_end":3117,"line_start":82,"line_end":82,"column_start":19,"column_end":20,"is_primary":true,"text":[{"text":"impl Field {","highlight_start":19,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"see issue #57563 for more information","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add `#![feature(const_fn)]` to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0723]\u001b[0m\u001b[0m\u001b[1m: trait bounds other than `Sized` on const fn parameters are unstable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs:82:19\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m82\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0mimpl Field {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: see issue #57563 for more information\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mhelp\u001b[0m\u001b[0m: add `#![feature(const_fn)]` to the crate attributes to enable\u001b[0m\n\n"} 3 | {"message":"trait bounds other than `Sized` on const fn parameters are unstable","code":{"code":"E0723","explanation":"An unstable feature in `const` contexts was used.\n\nErroneous code example:\n\n```compile_fail,E0723\nconst fn foo(_: T) { // error!\n // ...\n}\n```\n\nTo enable this feature on a nightly version of rustc, add the `const_fn`\nfeature flag:\n\n```\n#![feature(const_fn)]\n\nconst fn foo(_: T) { // ok!\n // ...\n}\n```\n"},"level":"error","spans":[{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":5815,"byte_end":5816,"line_start":169,"line_end":169,"column_start":14,"column_end":15,"is_primary":true,"text":[{"text":" impl FieldValue<$type, R> {","highlight_start":14,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":6548,"byte_end":6573,"line_start":189,"line_end":189,"column_start":1,"column_end":26,"is_primary":false,"text":[{"text":"FieldValue_impl_for!(u8);","highlight_start":1,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"FieldValue_impl_for!","def_site_span":{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":5529,"byte_end":6546,"line_start":164,"line_end":187,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"macro_rules! FieldValue_impl_for {","highlight_start":1,"highlight_end":35},{"text":" ($type:ty) => {","highlight_start":1,"highlight_end":20},{"text":" // Necessary to split the implementation of new() out because the bitwise","highlight_start":1,"highlight_end":82},{"text":" // math isn't treated as const when the type is generic.","highlight_start":1,"highlight_end":65},{"text":" // Tracking issue: https://github.com/rust-lang/rfcs/pull/2632","highlight_start":1,"highlight_end":71},{"text":" impl FieldValue<$type, R> {","highlight_start":1,"highlight_end":57},{"text":" pub const fn new(mask: $type, shift: usize, value: $type) -> Self {","highlight_start":1,"highlight_end":80},{"text":" FieldValue {","highlight_start":1,"highlight_end":29},{"text":" mask: mask << shift,","highlight_start":1,"highlight_end":41},{"text":" value: (value & mask) << shift,","highlight_start":1,"highlight_end":52},{"text":" associated_register: PhantomData,","highlight_start":1,"highlight_end":54},{"text":" }","highlight_start":1,"highlight_end":18},{"text":" }","highlight_start":1,"highlight_end":14},{"text":" }","highlight_start":1,"highlight_end":10},{"text":"","highlight_start":1,"highlight_end":1},{"text":" // Necessary to split the implementation of From<> out because of the orphan rule","highlight_start":1,"highlight_end":90},{"text":" // for foreign trait implementation (see [E0210](https://doc.rust-lang.org/error-index.html#E0210)).","highlight_start":1,"highlight_end":109},{"text":" impl From> for $type {","highlight_start":1,"highlight_end":73},{"text":" fn from(val: FieldValue<$type, R>) -> $type {","highlight_start":1,"highlight_end":58},{"text":" val.value","highlight_start":1,"highlight_end":26},{"text":" }","highlight_start":1,"highlight_end":14},{"text":" }","highlight_start":1,"highlight_end":10},{"text":" };","highlight_start":1,"highlight_end":7},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"see issue #57563 for more information","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add `#![feature(const_fn)]` to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0723]\u001b[0m\u001b[0m\u001b[1m: trait bounds other than `Sized` on const fn parameters are unstable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs:169:14\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m169\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m impl FieldValue<$type, R> {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m...\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m189\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0mFieldValue_impl_for!(u8);\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-------------------------\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12min this macro invocation\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: see issue #57563 for more information\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mhelp\u001b[0m\u001b[0m: add `#![feature(const_fn)]` to the crate attributes to enable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\u001b[0m\n\n"} 4 | {"message":"trait bounds other than `Sized` on const fn parameters are unstable","code":{"code":"E0723","explanation":"An unstable feature in `const` contexts was used.\n\nErroneous code example:\n\n```compile_fail,E0723\nconst fn foo(_: T) { // error!\n // ...\n}\n```\n\nTo enable this feature on a nightly version of rustc, add the `const_fn`\nfeature flag:\n\n```\n#![feature(const_fn)]\n\nconst fn foo(_: T) { // ok!\n // ...\n}\n```\n"},"level":"error","spans":[{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":5815,"byte_end":5816,"line_start":169,"line_end":169,"column_start":14,"column_end":15,"is_primary":true,"text":[{"text":" impl FieldValue<$type, R> {","highlight_start":14,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":6574,"byte_end":6600,"line_start":190,"line_end":190,"column_start":1,"column_end":27,"is_primary":false,"text":[{"text":"FieldValue_impl_for!(u16);","highlight_start":1,"highlight_end":27}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"FieldValue_impl_for!","def_site_span":{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":5529,"byte_end":6546,"line_start":164,"line_end":187,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"macro_rules! FieldValue_impl_for {","highlight_start":1,"highlight_end":35},{"text":" ($type:ty) => {","highlight_start":1,"highlight_end":20},{"text":" // Necessary to split the implementation of new() out because the bitwise","highlight_start":1,"highlight_end":82},{"text":" // math isn't treated as const when the type is generic.","highlight_start":1,"highlight_end":65},{"text":" // Tracking issue: https://github.com/rust-lang/rfcs/pull/2632","highlight_start":1,"highlight_end":71},{"text":" impl FieldValue<$type, R> {","highlight_start":1,"highlight_end":57},{"text":" pub const fn new(mask: $type, shift: usize, value: $type) -> Self {","highlight_start":1,"highlight_end":80},{"text":" FieldValue {","highlight_start":1,"highlight_end":29},{"text":" mask: mask << shift,","highlight_start":1,"highlight_end":41},{"text":" value: (value & mask) << shift,","highlight_start":1,"highlight_end":52},{"text":" associated_register: PhantomData,","highlight_start":1,"highlight_end":54},{"text":" }","highlight_start":1,"highlight_end":18},{"text":" }","highlight_start":1,"highlight_end":14},{"text":" }","highlight_start":1,"highlight_end":10},{"text":"","highlight_start":1,"highlight_end":1},{"text":" // Necessary to split the implementation of From<> out because of the orphan rule","highlight_start":1,"highlight_end":90},{"text":" // for foreign trait implementation (see [E0210](https://doc.rust-lang.org/error-index.html#E0210)).","highlight_start":1,"highlight_end":109},{"text":" impl From> for $type {","highlight_start":1,"highlight_end":73},{"text":" fn from(val: FieldValue<$type, R>) -> $type {","highlight_start":1,"highlight_end":58},{"text":" val.value","highlight_start":1,"highlight_end":26},{"text":" }","highlight_start":1,"highlight_end":14},{"text":" }","highlight_start":1,"highlight_end":10},{"text":" };","highlight_start":1,"highlight_end":7},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"see issue #57563 for more information","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add `#![feature(const_fn)]` to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0723]\u001b[0m\u001b[0m\u001b[1m: trait bounds other than `Sized` on const fn parameters are unstable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs:169:14\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m169\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m impl FieldValue<$type, R> {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m...\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m190\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0mFieldValue_impl_for!(u16);\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--------------------------\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12min this macro invocation\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: see issue #57563 for more information\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mhelp\u001b[0m\u001b[0m: add `#![feature(const_fn)]` to the crate attributes to enable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\u001b[0m\n\n"} 5 | {"message":"trait bounds other than `Sized` on const fn parameters are unstable","code":{"code":"E0723","explanation":"An unstable feature in `const` contexts was used.\n\nErroneous code example:\n\n```compile_fail,E0723\nconst fn foo(_: T) { // error!\n // ...\n}\n```\n\nTo enable this feature on a nightly version of rustc, add the `const_fn`\nfeature flag:\n\n```\n#![feature(const_fn)]\n\nconst fn foo(_: T) { // ok!\n // ...\n}\n```\n"},"level":"error","spans":[{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":5815,"byte_end":5816,"line_start":169,"line_end":169,"column_start":14,"column_end":15,"is_primary":true,"text":[{"text":" impl FieldValue<$type, R> {","highlight_start":14,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":6601,"byte_end":6627,"line_start":191,"line_end":191,"column_start":1,"column_end":27,"is_primary":false,"text":[{"text":"FieldValue_impl_for!(u32);","highlight_start":1,"highlight_end":27}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"FieldValue_impl_for!","def_site_span":{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":5529,"byte_end":6546,"line_start":164,"line_end":187,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"macro_rules! FieldValue_impl_for {","highlight_start":1,"highlight_end":35},{"text":" ($type:ty) => {","highlight_start":1,"highlight_end":20},{"text":" // Necessary to split the implementation of new() out because the bitwise","highlight_start":1,"highlight_end":82},{"text":" // math isn't treated as const when the type is generic.","highlight_start":1,"highlight_end":65},{"text":" // Tracking issue: https://github.com/rust-lang/rfcs/pull/2632","highlight_start":1,"highlight_end":71},{"text":" impl FieldValue<$type, R> {","highlight_start":1,"highlight_end":57},{"text":" pub const fn new(mask: $type, shift: usize, value: $type) -> Self {","highlight_start":1,"highlight_end":80},{"text":" FieldValue {","highlight_start":1,"highlight_end":29},{"text":" mask: mask << shift,","highlight_start":1,"highlight_end":41},{"text":" value: (value & mask) << shift,","highlight_start":1,"highlight_end":52},{"text":" associated_register: PhantomData,","highlight_start":1,"highlight_end":54},{"text":" }","highlight_start":1,"highlight_end":18},{"text":" }","highlight_start":1,"highlight_end":14},{"text":" }","highlight_start":1,"highlight_end":10},{"text":"","highlight_start":1,"highlight_end":1},{"text":" // Necessary to split the implementation of From<> out because of the orphan rule","highlight_start":1,"highlight_end":90},{"text":" // for foreign trait implementation (see [E0210](https://doc.rust-lang.org/error-index.html#E0210)).","highlight_start":1,"highlight_end":109},{"text":" impl From> for $type {","highlight_start":1,"highlight_end":73},{"text":" fn from(val: FieldValue<$type, R>) -> $type {","highlight_start":1,"highlight_end":58},{"text":" val.value","highlight_start":1,"highlight_end":26},{"text":" }","highlight_start":1,"highlight_end":14},{"text":" }","highlight_start":1,"highlight_end":10},{"text":" };","highlight_start":1,"highlight_end":7},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"see issue #57563 for more information","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add `#![feature(const_fn)]` to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0723]\u001b[0m\u001b[0m\u001b[1m: trait bounds other than `Sized` on const fn parameters are unstable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs:169:14\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m169\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m impl FieldValue<$type, R> {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m...\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m191\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0mFieldValue_impl_for!(u32);\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--------------------------\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12min this macro invocation\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: see issue #57563 for more information\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mhelp\u001b[0m\u001b[0m: add `#![feature(const_fn)]` to the crate attributes to enable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\u001b[0m\n\n"} 6 | {"message":"trait bounds other than `Sized` on const fn parameters are unstable","code":{"code":"E0723","explanation":"An unstable feature in `const` contexts was used.\n\nErroneous code example:\n\n```compile_fail,E0723\nconst fn foo(_: T) { // error!\n // ...\n}\n```\n\nTo enable this feature on a nightly version of rustc, add the `const_fn`\nfeature flag:\n\n```\n#![feature(const_fn)]\n\nconst fn foo(_: T) { // ok!\n // ...\n}\n```\n"},"level":"error","spans":[{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":5815,"byte_end":5816,"line_start":169,"line_end":169,"column_start":14,"column_end":15,"is_primary":true,"text":[{"text":" impl FieldValue<$type, R> {","highlight_start":14,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":6628,"byte_end":6654,"line_start":192,"line_end":192,"column_start":1,"column_end":27,"is_primary":false,"text":[{"text":"FieldValue_impl_for!(u64);","highlight_start":1,"highlight_end":27}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"FieldValue_impl_for!","def_site_span":{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":5529,"byte_end":6546,"line_start":164,"line_end":187,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"macro_rules! FieldValue_impl_for {","highlight_start":1,"highlight_end":35},{"text":" ($type:ty) => {","highlight_start":1,"highlight_end":20},{"text":" // Necessary to split the implementation of new() out because the bitwise","highlight_start":1,"highlight_end":82},{"text":" // math isn't treated as const when the type is generic.","highlight_start":1,"highlight_end":65},{"text":" // Tracking issue: https://github.com/rust-lang/rfcs/pull/2632","highlight_start":1,"highlight_end":71},{"text":" impl FieldValue<$type, R> {","highlight_start":1,"highlight_end":57},{"text":" pub const fn new(mask: $type, shift: usize, value: $type) -> Self {","highlight_start":1,"highlight_end":80},{"text":" FieldValue {","highlight_start":1,"highlight_end":29},{"text":" mask: mask << shift,","highlight_start":1,"highlight_end":41},{"text":" value: (value & mask) << shift,","highlight_start":1,"highlight_end":52},{"text":" associated_register: PhantomData,","highlight_start":1,"highlight_end":54},{"text":" }","highlight_start":1,"highlight_end":18},{"text":" }","highlight_start":1,"highlight_end":14},{"text":" }","highlight_start":1,"highlight_end":10},{"text":"","highlight_start":1,"highlight_end":1},{"text":" // Necessary to split the implementation of From<> out because of the orphan rule","highlight_start":1,"highlight_end":90},{"text":" // for foreign trait implementation (see [E0210](https://doc.rust-lang.org/error-index.html#E0210)).","highlight_start":1,"highlight_end":109},{"text":" impl From> for $type {","highlight_start":1,"highlight_end":73},{"text":" fn from(val: FieldValue<$type, R>) -> $type {","highlight_start":1,"highlight_end":58},{"text":" val.value","highlight_start":1,"highlight_end":26},{"text":" }","highlight_start":1,"highlight_end":14},{"text":" }","highlight_start":1,"highlight_end":10},{"text":" };","highlight_start":1,"highlight_end":7},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"see issue #57563 for more information","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add `#![feature(const_fn)]` to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0723]\u001b[0m\u001b[0m\u001b[1m: trait bounds other than `Sized` on const fn parameters are unstable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs:169:14\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m169\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m impl FieldValue<$type, R> {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m...\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m192\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0mFieldValue_impl_for!(u64);\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--------------------------\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12min this macro invocation\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: see issue #57563 for more information\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mhelp\u001b[0m\u001b[0m: add `#![feature(const_fn)]` to the crate attributes to enable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\u001b[0m\n\n"} 7 | {"message":"trait bounds other than `Sized` on const fn parameters are unstable","code":{"code":"E0723","explanation":"An unstable feature in `const` contexts was used.\n\nErroneous code example:\n\n```compile_fail,E0723\nconst fn foo(_: T) { // error!\n // ...\n}\n```\n\nTo enable this feature on a nightly version of rustc, add the `const_fn`\nfeature flag:\n\n```\n#![feature(const_fn)]\n\nconst fn foo(_: T) { // ok!\n // ...\n}\n```\n"},"level":"error","spans":[{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":5815,"byte_end":5816,"line_start":169,"line_end":169,"column_start":14,"column_end":15,"is_primary":true,"text":[{"text":" impl FieldValue<$type, R> {","highlight_start":14,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":6655,"byte_end":6682,"line_start":193,"line_end":193,"column_start":1,"column_end":28,"is_primary":false,"text":[{"text":"FieldValue_impl_for!(u128);","highlight_start":1,"highlight_end":28}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"FieldValue_impl_for!","def_site_span":{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":5529,"byte_end":6546,"line_start":164,"line_end":187,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"macro_rules! FieldValue_impl_for {","highlight_start":1,"highlight_end":35},{"text":" ($type:ty) => {","highlight_start":1,"highlight_end":20},{"text":" // Necessary to split the implementation of new() out because the bitwise","highlight_start":1,"highlight_end":82},{"text":" // math isn't treated as const when the type is generic.","highlight_start":1,"highlight_end":65},{"text":" // Tracking issue: https://github.com/rust-lang/rfcs/pull/2632","highlight_start":1,"highlight_end":71},{"text":" impl FieldValue<$type, R> {","highlight_start":1,"highlight_end":57},{"text":" pub const fn new(mask: $type, shift: usize, value: $type) -> Self {","highlight_start":1,"highlight_end":80},{"text":" FieldValue {","highlight_start":1,"highlight_end":29},{"text":" mask: mask << shift,","highlight_start":1,"highlight_end":41},{"text":" value: (value & mask) << shift,","highlight_start":1,"highlight_end":52},{"text":" associated_register: PhantomData,","highlight_start":1,"highlight_end":54},{"text":" }","highlight_start":1,"highlight_end":18},{"text":" }","highlight_start":1,"highlight_end":14},{"text":" }","highlight_start":1,"highlight_end":10},{"text":"","highlight_start":1,"highlight_end":1},{"text":" // Necessary to split the implementation of From<> out because of the orphan rule","highlight_start":1,"highlight_end":90},{"text":" // for foreign trait implementation (see [E0210](https://doc.rust-lang.org/error-index.html#E0210)).","highlight_start":1,"highlight_end":109},{"text":" impl From> for $type {","highlight_start":1,"highlight_end":73},{"text":" fn from(val: FieldValue<$type, R>) -> $type {","highlight_start":1,"highlight_end":58},{"text":" val.value","highlight_start":1,"highlight_end":26},{"text":" }","highlight_start":1,"highlight_end":14},{"text":" }","highlight_start":1,"highlight_end":10},{"text":" };","highlight_start":1,"highlight_end":7},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"see issue #57563 for more information","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add `#![feature(const_fn)]` to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0723]\u001b[0m\u001b[0m\u001b[1m: trait bounds other than `Sized` on const fn parameters are unstable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs:169:14\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m169\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m impl FieldValue<$type, R> {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m...\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m193\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0mFieldValue_impl_for!(u128);\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m---------------------------\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12min this macro invocation\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: see issue #57563 for more information\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mhelp\u001b[0m\u001b[0m: add `#![feature(const_fn)]` to the crate attributes to enable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\u001b[0m\n\n"} 8 | {"message":"trait bounds other than `Sized` on const fn parameters are unstable","code":{"code":"E0723","explanation":"An unstable feature in `const` contexts was used.\n\nErroneous code example:\n\n```compile_fail,E0723\nconst fn foo(_: T) { // error!\n // ...\n}\n```\n\nTo enable this feature on a nightly version of rustc, add the `const_fn`\nfeature flag:\n\n```\n#![feature(const_fn)]\n\nconst fn foo(_: T) { // ok!\n // ...\n}\n```\n"},"level":"error","spans":[{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":5815,"byte_end":5816,"line_start":169,"line_end":169,"column_start":14,"column_end":15,"is_primary":true,"text":[{"text":" impl FieldValue<$type, R> {","highlight_start":14,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":6683,"byte_end":6711,"line_start":194,"line_end":194,"column_start":1,"column_end":29,"is_primary":false,"text":[{"text":"FieldValue_impl_for!(usize);","highlight_start":1,"highlight_end":29}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"FieldValue_impl_for!","def_site_span":{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs","byte_start":5529,"byte_end":6546,"line_start":164,"line_end":187,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"macro_rules! FieldValue_impl_for {","highlight_start":1,"highlight_end":35},{"text":" ($type:ty) => {","highlight_start":1,"highlight_end":20},{"text":" // Necessary to split the implementation of new() out because the bitwise","highlight_start":1,"highlight_end":82},{"text":" // math isn't treated as const when the type is generic.","highlight_start":1,"highlight_end":65},{"text":" // Tracking issue: https://github.com/rust-lang/rfcs/pull/2632","highlight_start":1,"highlight_end":71},{"text":" impl FieldValue<$type, R> {","highlight_start":1,"highlight_end":57},{"text":" pub const fn new(mask: $type, shift: usize, value: $type) -> Self {","highlight_start":1,"highlight_end":80},{"text":" FieldValue {","highlight_start":1,"highlight_end":29},{"text":" mask: mask << shift,","highlight_start":1,"highlight_end":41},{"text":" value: (value & mask) << shift,","highlight_start":1,"highlight_end":52},{"text":" associated_register: PhantomData,","highlight_start":1,"highlight_end":54},{"text":" }","highlight_start":1,"highlight_end":18},{"text":" }","highlight_start":1,"highlight_end":14},{"text":" }","highlight_start":1,"highlight_end":10},{"text":"","highlight_start":1,"highlight_end":1},{"text":" // Necessary to split the implementation of From<> out because of the orphan rule","highlight_start":1,"highlight_end":90},{"text":" // for foreign trait implementation (see [E0210](https://doc.rust-lang.org/error-index.html#E0210)).","highlight_start":1,"highlight_end":109},{"text":" impl From> for $type {","highlight_start":1,"highlight_end":73},{"text":" fn from(val: FieldValue<$type, R>) -> $type {","highlight_start":1,"highlight_end":58},{"text":" val.value","highlight_start":1,"highlight_end":26},{"text":" }","highlight_start":1,"highlight_end":14},{"text":" }","highlight_start":1,"highlight_end":10},{"text":" };","highlight_start":1,"highlight_end":7},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"see issue #57563 for more information","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add `#![feature(const_fn)]` to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0723]\u001b[0m\u001b[0m\u001b[1m: trait bounds other than `Sized` on const fn parameters are unstable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/fields.rs:169:14\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m169\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m impl FieldValue<$type, R> {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m...\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m194\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0mFieldValue_impl_for!(usize);\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m----------------------------\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12min this macro invocation\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: see issue #57563 for more information\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mhelp\u001b[0m\u001b[0m: add `#![feature(const_fn)]` to the crate attributes to enable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\u001b[0m\n\n"} 9 | {"message":"trait bounds other than `Sized` on const fn parameters are unstable","code":{"code":"E0723","explanation":"An unstable feature in `const` contexts was used.\n\nErroneous code example:\n\n```compile_fail,E0723\nconst fn foo(_: T) { // error!\n // ...\n}\n```\n\nTo enable this feature on a nightly version of rustc, add the `const_fn`\nfeature flag:\n\n```\n#![feature(const_fn)]\n\nconst fn foo(_: T) { // ok!\n // ...\n}\n```\n"},"level":"error","spans":[{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/registers.rs","byte_start":5267,"byte_end":5268,"line_start":156,"line_end":156,"column_start":6,"column_end":7,"is_primary":true,"text":[{"text":"impl InMemoryRegister {","highlight_start":6,"highlight_end":7}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"see issue #57563 for more information","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add `#![feature(const_fn)]` to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0723]\u001b[0m\u001b[0m\u001b[1m: trait bounds other than `Sized` on const fn parameters are unstable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/registers.rs:156:6\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m156\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0mimpl InMemoryRegister {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: see issue #57563 for more information\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mhelp\u001b[0m\u001b[0m: add `#![feature(const_fn)]` to the crate attributes to enable\u001b[0m\n\n"} 10 | {"message":"trait bounds other than `Sized` on const fn parameters are unstable","code":{"code":"E0723","explanation":"An unstable feature in `const` contexts was used.\n\nErroneous code example:\n\n```compile_fail,E0723\nconst fn foo(_: T) { // error!\n // ...\n}\n```\n\nTo enable this feature on a nightly version of rustc, add the `const_fn`\nfeature flag:\n\n```\n#![feature(const_fn)]\n\nconst fn foo(_: T) { // ok!\n // ...\n}\n```\n"},"level":"error","spans":[{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/registers.rs","byte_start":5280,"byte_end":5281,"line_start":156,"line_end":156,"column_start":19,"column_end":20,"is_primary":true,"text":[{"text":"impl InMemoryRegister {","highlight_start":19,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"see issue #57563 for more information","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add `#![feature(const_fn)]` to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0723]\u001b[0m\u001b[0m\u001b[1m: trait bounds other than `Sized` on const fn parameters are unstable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/registers.rs:156:19\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m156\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0mimpl InMemoryRegister {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: see issue #57563 for more information\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mhelp\u001b[0m\u001b[0m: add `#![feature(const_fn)]` to the crate attributes to enable\u001b[0m\n\n"} 11 | {"message":"trait bounds other than `Sized` on const fn parameters are unstable","code":{"code":"E0723","explanation":"An unstable feature in `const` contexts was used.\n\nErroneous code example:\n\n```compile_fail,E0723\nconst fn foo(_: T) { // error!\n // ...\n}\n```\n\nTo enable this feature on a nightly version of rustc, add the `const_fn`\nfeature flag:\n\n```\n#![feature(const_fn)]\n\nconst fn foo(_: T) { // ok!\n // ...\n}\n```\n"},"level":"error","spans":[{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/local_register.rs","byte_start":1587,"byte_end":1588,"line_start":36,"line_end":36,"column_start":6,"column_end":7,"is_primary":true,"text":[{"text":"impl LocalRegisterCopy {","highlight_start":6,"highlight_end":7}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"see issue #57563 for more information","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add `#![feature(const_fn)]` to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0723]\u001b[0m\u001b[0m\u001b[1m: trait bounds other than `Sized` on const fn parameters are unstable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/local_register.rs:36:6\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m36\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0mimpl LocalRegisterCopy {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: see issue #57563 for more information\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mhelp\u001b[0m\u001b[0m: add `#![feature(const_fn)]` to the crate attributes to enable\u001b[0m\n\n"} 12 | {"message":"trait bounds other than `Sized` on const fn parameters are unstable","code":{"code":"E0723","explanation":"An unstable feature in `const` contexts was used.\n\nErroneous code example:\n\n```compile_fail,E0723\nconst fn foo(_: T) { // error!\n // ...\n}\n```\n\nTo enable this feature on a nightly version of rustc, add the `const_fn`\nfeature flag:\n\n```\n#![feature(const_fn)]\n\nconst fn foo(_: T) { // ok!\n // ...\n}\n```\n"},"level":"error","spans":[{"file_name":"/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/local_register.rs","byte_start":1600,"byte_end":1601,"line_start":36,"line_end":36,"column_start":19,"column_end":20,"is_primary":true,"text":[{"text":"impl LocalRegisterCopy {","highlight_start":19,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"see issue #57563 for more information","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add `#![feature(const_fn)]` to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0723]\u001b[0m\u001b[0m\u001b[1m: trait bounds other than `Sized` on const fn parameters are unstable\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m/Users/mago/.cargo/registry/src/github.com-1ecc6299db9ec823/tock-registers-0.7.0/src/local_register.rs:36:19\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m36\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0mimpl LocalRegisterCopy {\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: see issue #57563 for more information\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mhelp\u001b[0m\u001b[0m: add `#![feature(const_fn)]` to the crate attributes to enable\u001b[0m\n\n"} 13 | {"message":"aborting due to 12 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: aborting due to 12 previous errors\u001b[0m\n\n"} 14 | {"message":"For more information about this error, try `rustc --explain E0723`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1mFor more information about this error, try `rustc --explain E0723`.\u001b[0m\n"} 15 | --------------------------------------------------------------------------------