Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming of env.rs to runtime_params.rs #1292

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/arch/aarch64/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use hermit_entry::boot_info::{BootInfo, RawBootInfo};
use crate::arch::aarch64::kernel::core_local::*;
use crate::arch::aarch64::kernel::serial::SerialPort;
use crate::arch::aarch64::mm::{PhysAddr, VirtAddr};
use crate::env;
use crate::runtime_params;

const SERIAL_PORT_BAUDRATE: u32 = 115200;

Expand Down Expand Up @@ -144,7 +144,7 @@ pub fn boot_processor_init() {
crate::mm::init();
crate::mm::print_information();
CoreLocal::get().add_irq_counter();
env::init();
runtime_params::init();
interrupts::init();
interrupts::enable();
processor::detect_frequency();
Expand Down
4 changes: 2 additions & 2 deletions src/arch/aarch64/kernel/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use hermit_dtb::Dtb;
use hermit_sync::{without_interrupts, Lazy};

use crate::arch::aarch64::kernel::boot_info;
use crate::env;
use crate::runtime_params;

// System counter frequency in Hz
static CPU_FREQUENCY: Lazy<CpuFrequency> = Lazy::new(|| {
Expand Down Expand Up @@ -63,7 +63,7 @@ impl CpuFrequency {
}

unsafe fn detect_from_cmdline(&mut self) -> Result<(), ()> {
let mhz = env::freq().ok_or(())?;
let mhz = runtime_params::freq().ok_or(())?;
self.set_detected_cpu_frequency(u32::from(mhz) * 1000000, CpuFrequencySources::CommandLine)
}

Expand Down
2 changes: 1 addition & 1 deletion src/arch/aarch64/mm/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::arch::aarch64::kernel::{
get_base_address, get_boot_info_address, get_image_size, get_ram_address, processor,
};
use crate::arch::aarch64::mm::{physicalmem, virtualmem, PhysAddr, VirtAddr};
use crate::env::is_uhyve;
use crate::runtime_params::is_uhyve;
use crate::{mm, scheduler, KERNEL_STACK_SIZE};

/// Pointer to the root page table (called "Level 0" in ARM terminology).
Expand Down
6 changes: 3 additions & 3 deletions src/arch/riscv64/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub use crate::arch::riscv64::kernel::devicetree::init_drivers;
use crate::arch::riscv64::kernel::processor::lsb;
use crate::arch::riscv64::mm::{physicalmem, PhysAddr, VirtAddr};
use crate::config::KERNEL_STACK_SIZE;
use crate::env;
use crate::runtime_params;

// Used to store information about available harts. The index of the hart in the vector
// represents its CpuId and does not need to match its hart_id
Expand Down Expand Up @@ -134,7 +134,7 @@ pub fn boot_processor_init() {
devicetree::init();
crate::mm::init();
crate::mm::print_information();
env::init();
runtime_params::init();
interrupts::install();

finish_processor_init();
Expand Down Expand Up @@ -199,7 +199,7 @@ fn finish_processor_init() {
CPU_ONLINE.fetch_add(1, Ordering::Release);

//When running bare-metal/QEMU we use the firmware to start the next hart
if !env::is_uhyve() {
if !runtime_params::is_uhyve() {
sbi_rt::hart_start(
next_hart_id as usize,
start::_start as usize,
Expand Down
6 changes: 3 additions & 3 deletions src/arch/x86_64/kernel/apic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::arch::x86_64::mm::{paging, virtualmem, PhysAddr, VirtAddr};
use crate::arch::x86_64::swapgs;
use crate::config::*;
use crate::scheduler::CoreId;
use crate::{arch, env, scheduler};
use crate::{arch, runtime_params, scheduler};

const MP_FLT_SIGNATURE: u32 = 0x5f504d5f;
const MP_CONFIG_SIGNATURE: u32 = 0x504d4350;
Expand Down Expand Up @@ -448,7 +448,7 @@ fn default_apic() -> PhysAddr {
let default_address = PhysAddr(0xFEE0_0000);

// currently, uhyve doesn't support an IO-APIC
if !env::is_uhyve() {
if !runtime_params::is_uhyve() {
init_ioapic_address(default_address);
}

Expand Down Expand Up @@ -515,7 +515,7 @@ pub fn init() {
}

// currently, IO-APIC isn't supported by uhyve
if !env::is_uhyve() {
if !runtime_params::is_uhyve() {
// initialize IO-APIC
init_ioapic();
}
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86_64/kernel/mmio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::arch::x86_64::mm::{paging, PhysAddr};
use crate::drivers::net::virtio::VirtioNetDriver;
use crate::drivers::virtio::transport::mmio as mmio_virtio;
use crate::drivers::virtio::transport::mmio::VirtioDriver;
use crate::env;
use crate::runtime_params;

pub const MAGIC_VALUE: u32 = 0x74726976;

Expand Down Expand Up @@ -179,7 +179,7 @@ fn guess_device() -> Result<(VolatileRef<'static, DeviceRegisters>, u8), &'stati
/// Tries to find the network device within the specified address range.
/// Returns a reference to it within the Ok() if successful or an Err() on failure.
fn detect_network() -> Result<(VolatileRef<'static, DeviceRegisters>, u8), &'static str> {
let linux_mmio = env::mmio();
let linux_mmio = runtime_params::mmio();

if !linux_mmio.is_empty() {
check_linux_args(linux_mmio)
Expand Down
10 changes: 5 additions & 5 deletions src/arch/x86_64/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use x86::controlregs::{cr0, cr0_write, cr4, Cr0};
use self::serial::SerialPort;
use crate::arch::mm::{PhysAddr, VirtAddr};
use crate::arch::x86_64::kernel::core_local::*;
use crate::env::{self, is_uhyve};
use crate::runtime_params::{self, is_uhyve};

#[cfg(feature = "acpi")]
pub mod acpi;
Expand Down Expand Up @@ -157,15 +157,15 @@ pub fn boot_processor_init() {
processor::detect_features();
processor::configure();

if cfg!(feature = "vga") && !env::is_uhyve() {
if cfg!(feature = "vga") && !runtime_params::is_uhyve() {
#[cfg(feature = "vga")]
vga::init();
}

crate::mm::init();
crate::mm::print_information();
CoreLocal::get().add_irq_counter();
env::init();
runtime_params::init();
gdt::add_current_core();
interrupts::load_idt();
pic::init();
Expand All @@ -182,7 +182,7 @@ pub fn boot_processor_init() {
#[cfg(feature = "pci")]
pci::init();
}
if !env::is_uhyve() {
if !runtime_params::is_uhyve() {
#[cfg(feature = "acpi")]
acpi::init();
}
Expand Down Expand Up @@ -220,7 +220,7 @@ pub fn application_processor_init() {
}

fn finish_processor_init() {
if env::is_uhyve() {
if runtime_params::is_uhyve() {
// uhyve does not use apic::detect_from_acpi and therefore does not know the number of processors and
// their APIC IDs in advance.
// Therefore, we have to add each booted processor into the CPU_LOCAL_APIC_IDS vector ourselves.
Expand Down
8 changes: 4 additions & 4 deletions src/arch/x86_64/kernel/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use x86_64::VirtAddr;
#[cfg(feature = "acpi")]
use crate::arch::x86_64::kernel::acpi;
use crate::arch::x86_64::kernel::{boot_info, interrupts, pic, pit};
use crate::env;
use crate::runtime_params;

const IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP: u64 = 1 << 16;
const IA32_MISC_ENABLE_SPEEDSTEP_LOCK: u64 = 1 << 20;
Expand Down Expand Up @@ -313,7 +313,7 @@ impl CpuFrequency {
}

unsafe fn detect_from_cmdline(&mut self) -> Result<(), ()> {
let mhz = env::freq().ok_or(())?;
let mhz = runtime_params::freq().ok_or(())?;
self.set_detected_cpu_frequency(mhz, CpuFrequencySources::CommandLine)
}

Expand Down Expand Up @@ -406,7 +406,7 @@ impl CpuFrequency {
use crate::arch::x86_64::kernel::interrupts::IDT;

// The PIC is not initialized for uhyve, so we cannot measure anything.
if env::is_uhyve() {
if runtime_params::is_uhyve() {
return Err(());
}

Expand Down Expand Up @@ -672,7 +672,7 @@ impl fmt::Display for CpuFeaturePrinter {
}

pub(crate) fn run_on_hypervisor() -> bool {
env::is_uhyve() || FEATURES.run_on_hypervisor
runtime_params::is_uhyve() || FEATURES.run_on_hypervisor
}

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/arch/x86_64/kernel/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct SerialPort {

impl SerialPort {
pub unsafe fn new(base: u16) -> Self {
if crate::env::is_uhyve() {
if crate::runtime_params::is_uhyve() {
let serial = Port::new(base);
Self {
inner: SerialInner::Uhyve(serial),
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86_64/mm/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use x86_64::structures::paging::{

use crate::arch::x86_64::kernel::processor;
use crate::arch::x86_64::mm::{physicalmem, PhysAddr, VirtAddr};
use crate::{env, mm, scheduler};
use crate::{mm, runtime_params, scheduler};

pub trait PageTableEntryFlagsExt {
fn device(&mut self) -> &mut Self;
Expand Down Expand Up @@ -303,7 +303,7 @@ pub(crate) extern "x86-interrupt" fn page_fault_handler(
pub fn init() {}

pub fn init_page_tables() {
if env::is_uhyve() {
if runtime_params::is_uhyve() {
// Uhyve identity-maps the first Gibibyte of memory (512 page table entries * 2MiB pages)
// We now unmap all memory after the kernel image, so that we can remap it ourselves later for the heap.
// Ideally, uhyve would only map as much memory as necessary, but this requires a hermit-entry ABI jump.
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86_64/mm/physicalmem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use multiboot::information::{MemoryType, Multiboot};
use crate::arch::x86_64::kernel::{get_fdt, get_limit, get_mbinfo};
use crate::arch::x86_64::mm::paging::{BasePageSize, PageSize};
use crate::arch::x86_64::mm::{MultibootMemory, PhysAddr, VirtAddr};
use crate::{env, mm};
use crate::{mm, runtime_params};

pub static PHYSICAL_FREE_LIST: InterruptTicketMutex<FreeList<16>> =
InterruptTicketMutex::new(FreeList::new());
Expand Down Expand Up @@ -106,7 +106,7 @@ fn detect_from_multiboot_info() -> Result<(), ()> {
}

fn detect_from_uhyve() -> Result<(), ()> {
if !env::is_uhyve() {
if !runtime_params::is_uhyve() {
return Err(());
}

Expand Down
2 changes: 1 addition & 1 deletion src/fs/uhyve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ use async_trait::async_trait;
use x86::io::outl;

use crate::arch::mm::{paging, PhysAddr, VirtAddr};
use crate::env::is_uhyve;
use crate::executor::block_on;
use crate::fd::IoError;
use crate::fs::{
self, AccessPermission, FileAttr, NodeKind, ObjectInterface, OpenOption, SeekWhence, VfsNode,
};
use crate::runtime_params::is_uhyve;

/// forward a request to the hypervisor uhyve
#[inline]
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ use core::sync::atomic::{AtomicU32, Ordering};
use arch::core_local::*;
// Used for integration test status.
#[doc(hidden)]
pub use env::is_uhyve as _is_uhyve;
pub use runtime_params::is_uhyve as _is_uhyve;

pub(crate) use crate::arch::*;
pub use crate::config::DEFAULT_STACK_SIZE;
Expand All @@ -80,13 +80,13 @@ mod config;
pub mod console;
mod drivers;
mod entropy;
mod env;
pub mod errno;
mod executor;
pub mod fd;
pub mod fs;
pub mod io;
mod mm;
mod runtime_params;
pub mod scheduler;
#[cfg(all(feature = "shell", target_arch = "x86_64"))]
mod shell;
Expand Down Expand Up @@ -133,7 +133,7 @@ extern "C" fn initd(_arg: usize) {
fn main(argc: i32, argv: *const *const u8, env: *const *const u8);
}

if !env::is_uhyve() {
if !runtime_params::is_uhyve() {
info!("Hermit is running on common system!");
} else {
info!("Hermit is running on uhyve!");
Expand Down Expand Up @@ -192,7 +192,7 @@ fn boot_processor_main() -> ! {
}

info!("Welcome to Hermit {}", env!("CARGO_PKG_VERSION"));
info!("Kernel starts at {:p}", env::get_base_address());
info!("Kernel starts at {:p}", runtime_params::get_base_address());

#[cfg(target_arch = "x86_64")]
if let Some(fdt) = kernel::get_fdt() {
Expand All @@ -211,7 +211,7 @@ fn boot_processor_main() -> ! {
#[cfg(not(target_arch = "riscv64"))]
scheduler::add_current_core();

if !env::is_uhyve() {
if !runtime_params::is_uhyve() {
arch::boot_application_processors();
}

Expand All @@ -227,7 +227,7 @@ fn boot_processor_main() -> ! {
#[cfg(feature = "smp")]
info!("Compiled with SMP support");

if is_uhyve_with_pci() || !env::is_uhyve() {
if is_uhyve_with_pci() || !runtime_params::is_uhyve() {
#[cfg(feature = "pci")]
crate::drivers::pci::print_information();
}
Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ macro_rules! hermit_var {
($name:expr) => {{
use alloc::borrow::Cow;

match crate::env::var($name) {
match crate::runtime_params::var($name) {
Some(val) => Some(Cow::from(val)),
None => option_env!($name).map(Cow::Borrowed),
}
Expand Down
11 changes: 6 additions & 5 deletions src/mm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::arch::mm::virtualmem::kernel_heap_end;
#[cfg(feature = "pci")]
use crate::arch::mm::PhysAddr;
use crate::arch::mm::VirtAddr;
use crate::{arch, env};
use crate::{arch, runtime_params};

#[cfg(target_os = "none")]
#[global_allocator]
Expand All @@ -31,8 +31,9 @@ pub static ALLOCATOR: LockedAllocator = LockedAllocator::new();
static KERNEL_ADDR_RANGE: Lazy<Range<VirtAddr>> = Lazy::new(|| {
if cfg!(target_os = "none") {
// Calculate the start and end addresses of the 2 MiB page(s) that map the kernel.
env::get_base_address().align_down_to_large_page()
..(env::get_base_address() + env::get_image_size()).align_up_to_large_page()
runtime_params::get_base_address().align_down_to_large_page()
..(runtime_params::get_base_address() + runtime_params::get_image_size())
.align_up_to_large_page()
} else {
VirtAddr::zero()..VirtAddr::zero()
}
Expand Down Expand Up @@ -94,7 +95,7 @@ pub(crate) fn init() {
//info!("reserved space {} KB", reserved_space >> 10);

if total_memory_size()
< kernel_end_address().as_usize() - env::get_ram_address().as_usize()
< kernel_end_address().as_usize() - runtime_params::get_ram_address().as_usize()
+ reserved_space
+ LargePageSize::SIZE as usize
{
Expand All @@ -105,7 +106,7 @@ pub(crate) fn init() {
let mut map_size: usize;

let available_memory = (total_memory_size()
- (kernel_end_address().as_usize() - env::get_ram_address().as_usize())
- (kernel_end_address().as_usize() - runtime_params::get_ram_address().as_usize())
- reserved_space)
.align_down(LargePageSize::SIZE as usize);

Expand Down
Loading
Loading