Commit ebf7d7d3 authored by Stefan Lankes's avatar Stefan Lankes
Browse files

add options to disable pci and acpi support

- add also an C interface to determine the network configuration
parent 48992843
......@@ -5,7 +5,7 @@ set(HERMIT_RS "${CMAKE_BINARY_DIR}/hermit_rs/${HERMIT_ARCH}-unknown-hermit-kerne
add_custom_target(hermit_rs
COMMAND
${CMAKE_COMMAND} -E env CARGO_TARGET_DIR=${CMAKE_BINARY_DIR}/hermit_rs RUST_TARGET_PATH=${HERMIT_ROOT}/librs
cargo xbuild ${CARGO_BUILDTYPE_PARAMETER} --target ${HERMIT_ARCH}-unknown-hermit-kernel --features newlib
cargo xbuild ${CARGO_BUILDTYPE_PARAMETER} --target ${HERMIT_ARCH}-unknown-hermit-kernel.json --features newlib
WORKING_DIRECTORY
${CMAKE_CURRENT_LIST_DIR})
......
......@@ -24,8 +24,11 @@ crate-type = ["staticlib"]
name = "hermit"
[features]
default = ["pci", "acpi"]
vga = []
newlib = []
pci = []
acpi = []
[dependencies]
bitflags = "1.2"
......
......@@ -8,6 +8,7 @@
use alloc::boxed::Box;
use alloc::vec::Vec;
use arch;
#[cfg(feature = "acpi")]
use arch::x86_64::kernel::acpi;
use arch::x86_64::kernel::idt;
use arch::x86_64::kernel::irq;
......@@ -82,12 +83,14 @@ static mut CPU_LOCAL_APIC_IDS: Option<Vec<u8>> = None;
/// after 1 microsecond.
static mut CALIBRATED_COUNTER_VALUE: u64 = 0;
#[cfg(feature = "acpi")]
#[repr(C, packed)]
struct AcpiMadtHeader {
local_apic_address: u32,
flags: u32,
}
#[cfg(feature = "acpi")]
#[repr(C, packed)]
struct AcpiMadtRecordHeader {
entry_type: u8,
......@@ -110,6 +113,7 @@ impl fmt::Display for ProcessorLocalApicRecord {
}
}
#[cfg(feature = "acpi")]
const CPU_FLAG_ENABLED: u32 = 1 << 0;
#[repr(C, packed)]
......@@ -165,6 +169,13 @@ pub fn add_local_apic_id(id: u8) {
}
}
#[cfg(not(feature = "acpi"))]
fn detect_from_acpi() -> Result<usize, ()> {
// dummy implementation if acpi support is disabled
Err(())
}
#[cfg(feature = "acpi")]
fn detect_from_acpi() -> Result<usize, ()> {
// Get the Multiple APIC Description Table (MADT) from the ACPI information and its specific table header.
let madt = acpi::get_madt().expect("HermitCore requires a MADT in the ACPI tables");
......
......@@ -6,12 +6,15 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
#[cfg(feature = "acpi")]
pub mod acpi;
pub mod apic;
pub mod gdt;
pub mod idt;
pub mod irq;
#[cfg(feature = "pci")]
pub mod pci;
#[cfg(feature = "pci")]
mod pci_ids;
pub mod percore;
pub mod pic;
......@@ -31,7 +34,7 @@ mod vga;
use arch::x86_64::kernel::percore::*;
use arch::x86_64::kernel::serial::SerialPort;
use core::{intrinsics, ptr};
use core::{intrinsics, ptr, slice};
use environment;
use kernel_message_buffer;
......@@ -107,6 +110,27 @@ pub fn uhyve_get_mask() -> [u8; 4] {
unsafe { intrinsics::volatile_load(&(*BOOT_INFO).hcmask) }
}
#[no_mangle]
#[cfg(feature = "newlib")]
pub unsafe extern "C" fn uhyve_get_ip(ip: *mut u8) {
let data = intrinsics::volatile_load(&(*BOOT_INFO).hcip);
slice::from_raw_parts_mut(ip, 4).copy_from_slice(&data);
}
#[no_mangle]
#[cfg(feature = "newlib")]
pub unsafe extern "C" fn uhyve_get_gateway(gw: *mut u8) {
let data = intrinsics::volatile_load(&(*BOOT_INFO).hcgateway);
slice::from_raw_parts_mut(gw, 4).copy_from_slice(&data);
}
#[no_mangle]
#[cfg(feature = "newlib")]
pub unsafe extern "C" fn uhyve_get_mask(mask: *mut u8) {
let data = intrinsics::volatile_load(&(*BOOT_INFO).hcmask);
slice::from_raw_parts_mut(mask, 4).copy_from_slice(&data);
}
pub fn get_base_address() -> usize {
unsafe { intrinsics::volatile_load(&(*BOOT_INFO).base) as usize }
}
......@@ -241,9 +265,12 @@ pub fn boot_processor_init() {
systemtime::init();
if environment::is_single_kernel() {
#[cfg(feature = "pci")]
pci::init();
#[cfg(feature = "pci")]
pci::print_information();
if !environment::is_uhyve() {
#[cfg(feature = "acpi")]
acpi::init();
}
}
......
......@@ -8,6 +8,7 @@
#![allow(dead_code)]
#[cfg(feature = "acpi")]
use arch::x86_64::kernel::acpi;
use arch::x86_64::kernel::idt;
use arch::x86_64::kernel::irq;
......@@ -917,6 +918,7 @@ pub fn halt() {
/// Shutdown the system
pub fn shutdown() -> ! {
info!("Shutting down system");
#[cfg(feature = "acpi")]
acpi::poweroff();
loop {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment