Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
georglauterbach committed Oct 27, 2023
1 parent 7dc448e commit f5736af
Show file tree
Hide file tree
Showing 11 changed files with 308 additions and 257 deletions.
19 changes: 11 additions & 8 deletions code/src/runtime/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

//! Hols all functionality required for building, running, etc. `unCORE`.

use core::arch;

/// Specifies which sub-command are available, i.e. whether the user wants to build the
/// kernel, run the kernel, etc.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, clap::Subcommand)]
Expand Down Expand Up @@ -72,13 +70,15 @@ impl From<crate::runtime::arguments::Architecture> for ArchitectureSpecification
crate::runtime::arguments::Architecture::Riscv64 => Self {
target: "riscv64gc-unknown-none-elf",
qemu_command: "qemu-system-riscv64",
linker_script_path: base_dir.clone() + "/uncore/src/library/arch/risc_v/boot/memory.x",
linker_script_path: base_dir.clone() + "/uncore/src/library/arch/risc_v/ld/linker.x",
qemu_arguments: format!(
"-m 2G -machine virt -nographic -serial mon:stdio -kernel {}",
base_dir + "/target/riscv64gc-unknown-none-elf/debug/uncore"
"-machine virt -cpu rv64 -smp 1 -m 128M -nographic -serial mon:stdio -device virtio-rng-device \
-device virtio-gpu-device -device virtio-net-device -device virtio-tablet-device -device \
virtio-keyboard-device -kernel {}",
base_dir + "/target/riscv64gc-unknown-none-elf/debug/uncore"
)
.split(' ')
.map(|x| x.to_string())
.map(std::string::ToString::to_string)
.collect(),
},
}
Expand Down Expand Up @@ -158,7 +158,10 @@ fn build(arch_specification: &super::command::ArchitectureSpecification) -> anyh
let mut environment = super::environment::get_all_environment_variables_for_build()?;
environment.insert(
"RUSTFLAGS",
format!("-Clink-arg=-T{} -Clink-arg=-Tlink.x", arch_specification.linker_script_path),
format!(
"-Clink-arg=-T{}",
arch_specification.linker_script_path
),
);

run_command_and_check!(
Expand All @@ -178,7 +181,7 @@ fn build(arch_specification: &super::command::ArchitectureSpecification) -> anyh

/// Runs the kernel given an [`ArchitectureSpecification`].
fn run(arch_specification: &super::command::ArchitectureSpecification) -> anyhow::Result<()> {
log::info!("Running unCORE");
log::info!("Running unCORE now");
run_command_and_check!(
arch_specification.qemu_command,
&arch_specification.qemu_arguments
Expand Down
2 changes: 1 addition & 1 deletion code/src/runtime/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

//! This module provides functions to work efficiently with environment variables.

/// TODO
const CARGO_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR");

/// Returns the version of `rustc` used for compiling `unCORE`.
Expand Down Expand Up @@ -55,7 +56,6 @@ fn get_toolchain() -> anyhow::Result<String> {
/// Returns a [`std::collections::HashMap`] that contains environment variables names as
/// keys and their respective values are the values of the map. This is used when
/// building, as the map is provided to [`std::process::Command`].
#[must_use]
pub fn get_all_environment_variables_for_build(
) -> anyhow::Result<std::collections::HashMap<&'static str, String>> {
let mut environment = std::collections::HashMap::new();
Expand Down
1 change: 1 addition & 0 deletions code/uncore/src/library/arch/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// TODO
// #[cfg(target_arch = "riscv64")]
mod risc_v;
// #[cfg(target_arch = "riscv64")]
Expand Down
6 changes: 4 additions & 2 deletions code/uncore/src/library/arch/risc_v/drivers/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use core::fmt::Error;
/// TODO
#[derive(Debug)]
pub struct Uart {
/// TODO
base_address: usize,
}

Expand All @@ -27,6 +28,7 @@ impl Uart {
const fn new(base_address: usize) -> Self { Uart { base_address } }

/// TODO
#[must_use]
pub const fn new_well_known() -> Self {
Self::new(0x1000_0000)
}
Expand All @@ -41,8 +43,8 @@ impl Uart {
// We can easily write the value 3 here or 0b11, but I'm
// extending it so that it is clear we're setting two individual
// fields
// Word 0 Word 1
// ~~~~~~ ~~~~~~
// Word 0 Word 1
// ~~~~~~ ~~~~~~
ptr.add(3).write_volatile((1 << 0) | (1 << 1));

// Now, enable the FIFO, which is bit index 0 of the FIFO
Expand Down
231 changes: 0 additions & 231 deletions code/uncore/src/library/arch/risc_v/ld.ld

This file was deleted.

Loading

0 comments on commit f5736af

Please sign in to comment.