Skip to content

Commit

Permalink
Merge branch 'theseus_main' into sync-condvar
Browse files Browse the repository at this point in the history
Signed-off-by: Klimenty Tsoutsman <klim@tsoutsman.com>
  • Loading branch information
tsoutsman committed May 25, 2023
2 parents f48419b + fb27c24 commit 9d4809b
Show file tree
Hide file tree
Showing 18 changed files with 263 additions and 290 deletions.
13 changes: 6 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions kernel/captain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ log = "0.4.8"
irq_safety = { git = "https://github.com/theseus-os/irq_safety" }
dfqueue = { path = "../../libs/dfqueue", version = "0.1.0" }
multicore_bringup = { path = "../multicore_bringup" }
device_manager = { path = "../device_manager" }
early_printer = { path = "../early_printer" }
tlb_shootdown = { path = "../tlb_shootdown" }
kernel_config = { path = "../kernel_config" }
interrupts = { path = "../interrupts" }
scheduler = { path = "../scheduler" }
mod_mgmt = { path = "../mod_mgmt" }
no_drop = { path = "../no_drop" }
console = { path = "../console" }
task_fs = { path = "../task_fs" }
memory = { path = "../memory" }
logger = { path = "../logger" }
Expand All @@ -35,9 +37,7 @@ multiple_heaps = { path = "../multiple_heaps" }
tsc = { path = "../tsc" }
acpi = { path = "../acpi" }
page_attribute_table = { path = "../page_attribute_table" }
device_manager = { path = "../device_manager" }
e1000 = { path = "../e1000" }
console = { path = "../console" }
app_io = { path = "../app_io" }
network_manager = { path = "../network_manager" }
ota_update_client = { path = "../ota_update_client" }
Expand Down
14 changes: 6 additions & 8 deletions kernel/captain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,12 @@ pub fn init(
#[cfg(target_arch = "x86_64")]
let (key_producer, mouse_producer) = window_manager::init()?;

// initialize the rest of our drivers
// arch-gate: device_manager currently detects PCI & PS2 devices,
// which are unsupported on aarch64 at this point
#[cfg(target_arch = "x86_64")]
device_manager::init(key_producer, mouse_producer)?;
device_manager::init(
#[cfg(target_arch = "x86_64")]
key_producer,
#[cfg(target_arch = "x86_64")]
mouse_producer,
)?;

task_fs::init()?;

Expand All @@ -202,9 +203,6 @@ pub fn init(
drop_after_init.drop_all();

// 2. Spawn various system tasks/daemons,
// arch-gate: no windowing/input support on aarch64 at the moment,
// which prevent using any graphical apps such as the console
#[cfg(target_arch = "x86_64")]
console::start_connection_detection()?;

// 3. Start the first application(s).
Expand Down
52 changes: 17 additions & 35 deletions kernel/console/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,23 @@ edition = "2021"

[dependencies]
log = "0.4.8"

[dependencies.core2]
version = "0.4.0"
default-features = false
features = ["alloc", "nightly"]

[dependencies.async_channel]
path = "../async_channel"

[dependencies.app_io]
path = "../app_io"

[dependencies.serial_port]
path = "../serial_port"

[dependencies.io]
path = "../io"

[dependencies.task]
path = "../task"

[dependencies.spawn]
path = "../spawn"

[dependencies.tty]
path = "../tty"

[dependencies.mod_mgmt]
path = "../mod_mgmt"

[dependencies.path]
path = "../path"

[dependencies.irq_safety]
git = "https://github.com/theseus-os/irq_safety"
irq_safety = { git = "https://github.com/theseus-os/irq_safety" }
core2 = { version = "0.4.0", default-features = false, features = ["alloc", "nightly"] }

async_channel = { path = "../async_channel" }
serial_port = { path = "../serial_port" }
app_io = { path = "../app_io" }
spawn = { path = "../spawn" }
task = { path = "../task" }
tty = { path = "../tty" }
io = { path = "../io" }

[target.'cfg(target_arch = "x86_64")'.dependencies]
path = { path = "../path" }
mod_mgmt = { path = "../mod_mgmt" }

[target.'cfg(target_arch = "aarch64")'.dependencies]
hull = { path = "../../applications/hull" }

[lib]
crate-type = ["rlib"]
30 changes: 20 additions & 10 deletions kernel/console/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use task::{JoinableTaskRef, KillReason};

/// The serial port being used for the default system logger can optionally
/// ignore inputs.
static IGNORED_SERIAL_PORT_INPUT: AtomicU16 = AtomicU16::new(0);
static IGNORED_SERIAL_PORT_INPUT: AtomicU16 = AtomicU16::new(u16::MAX);

/// Configures the console connection listener to ignore inputs from the given
/// serial port.
Expand Down Expand Up @@ -109,17 +109,27 @@ fn shell_loop(
.name(format!("{address:?}_to_tty"))
.spawn()?;

let new_app_ns = mod_mgmt::create_application_namespace(None)?;

let (app_file, _ns) =
mod_mgmt::CrateNamespace::get_crate_object_file_starting_with(&new_app_ns, "hull-")
.expect("Couldn't find shell in default app namespace");
let task;
#[cfg(target_arch = "x86_64")] {
let new_app_ns = mod_mgmt::create_application_namespace(None)?;

let path = path::Path::new(app_file.lock().get_absolute_path());
let task = spawn::new_application_task_builder(path, Some(new_app_ns))?
.name(format!("{address:?}_shell"))
.block()
.spawn()?;
let (app_file, _ns) =
mod_mgmt::CrateNamespace::get_crate_object_file_starting_with(&new_app_ns, "hull-")
.expect("Couldn't find shell in default app namespace");

let path = path::Path::new(app_file.lock().get_absolute_path());
task = spawn::new_application_task_builder(path, Some(new_app_ns))?
.name(format!("{address:?}_shell"))
.block()
.spawn()?;
}
#[cfg(target_arch = "aarch64")] {
task = spawn::new_task_builder(hull::main, alloc::vec::Vec::new())
.name(alloc::format!("{address:?}_shell"))
.block()
.spawn()?;
}

let id = task.id;
let stream = Arc::new(tty.slave());
Expand Down
20 changes: 6 additions & 14 deletions kernel/deferred_interrupt_tasks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,16 @@ authors = ["Kevin Boos <kevinaboos@gmail.com>"]
name = "deferred_interrupt_tasks"
description = "Abstractions for deferred interrupt handler tasks"
version = "0.1.0"
edition = "2021"

[dependencies]
log = "0.4.8"

[dependencies.task]
path = "../task"

[dependencies.scheduler]
path = "../scheduler"

[dependencies.spawn]
path = "../spawn"

[dependencies.interrupts]
path = "../interrupts"

[dependencies.debugit]
path = "../../libs/debugit"
task = { path = "../task" }
scheduler = { path = "../scheduler" }
spawn = { path = "../spawn" }
interrupts = { path = "../interrupts" }
debugit = { path = "../../libs/debugit" }

[lib]
crate-type = ["rlib"]
21 changes: 10 additions & 11 deletions kernel/deferred_interrupt_tasks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,23 @@
//!

#![no_std]
#![feature(abi_x86_interrupt)]
#![cfg_attr(target_arch = "x86_64", feature(abi_x86_interrupt))]

extern crate alloc;
#[macro_use] extern crate log;
extern crate task;
extern crate spawn;
extern crate scheduler;
#[macro_use] extern crate debugit;
extern crate interrupts;

use log::error;
use debugit::debugit;
use alloc::string::String;
use task::{get_my_current_task, JoinableTaskRef};
use interrupts::InterruptHandler;
use interrupts::{InterruptHandler, InterruptNumber};

/// The errors that may occur in [`register_interrupt_handler()`].
#[derive(Debug)]
pub enum InterruptRegistrationError {
/// The given `irq` number was already in use and is registered to
/// the interrupt handler at the given `existing_handler_address`.
IrqInUse {
irq: u8,
irq: InterruptNumber,
existing_handler_address: usize
},
/// The given error occurred when spawning the deferred interrupt task.
Expand Down Expand Up @@ -105,7 +101,7 @@ pub enum InterruptRegistrationError {
/// long-running loop that repeatedly invokes the given `deferred_interrupt_action`.
/// * `Err(existing_handler_address)` if the given `interrupt_number` was already in use.
pub fn register_interrupt_handler<DIA, Arg, Success, Failure, S>(
interrupt_number: u8,
interrupt_number: InterruptNumber,
interrupt_handler: InterruptHandler,
deferred_interrupt_action: DIA,
deferred_action_argument: Arg,
Expand All @@ -116,8 +112,11 @@ pub fn register_interrupt_handler<DIA, Arg, Success, Failure, S>(
S: Into<String>,
{
// First, attempt to register the interrupt handler.
interrupts::register_interrupt(interrupt_number, interrupt_handler)
interrupts::register_interrupt(interrupt_number as _, interrupt_handler)
.map_err(|existing_handler_address| {
#[cfg(target_arch = "aarch64")]
let existing_handler_address = existing_handler_address as usize;

error!("Interrupt number {:#X} was already taken by handler at {:#X}! Sharing IRQs is currently unsupported.",
interrupt_number, existing_handler_address
);
Expand Down
87 changes: 24 additions & 63 deletions kernel/device_manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,41 @@ authors = ["Kevin Boos <kevinaboos@gmail.com>"]
name = "device_manager"
description = "Code for handling the sequence required to manage and initialize each driver"
version = "0.1.0"
edition = "2021"

[dependencies]
spin = "0.9.4"
core2 = { version = "0.4.0", default-features = false, features = ["alloc", "nightly"] }
event_types = { path = "../event_types" }
serial_port = { path = "../serial_port" }
console = { path = "../console" }
logger = { path = "../logger" }
derive_more = "0.99.0"
mpmc = "0.1.6"
log = "0.4.8"

[target.'cfg(target_arch = "x86_64")'.dependencies]
memory = { path = "../memory" }
e1000 = { path = "../e1000" }
acpi = { path = "../acpi" }
pci = { path = "../pci" }
ps2 = { path = "../ps2" }
keyboard = { path = "../keyboard" }
mouse = { path = "../mouse" }
storage_manager = { path = "../storage_manager" }
network_manager = { path = "../network_manager" }
ethernet_smoltcp_device = { path = "../ethernet_smoltcp_device" }
ixgbe = { path = "../ixgbe" }
io = { path = "../io" }
mlx5 = { path = "../mlx5" }
iommu = { path = "../iommu" }
net = { path = "../net" }
apic = { path = "../apic" }

[dependencies.fatfs]
git = "https://github.com/rafalh/rust-fatfs"
default-features = false
features = [ "alloc", "lfn", "unicode", "log_level_warn" ]

[dependencies.log]
version = "0.4.8"

[dependencies.event_types]
path = "../event_types"

[dependencies.memory]
path = "../memory"

[dependencies.apic]
path = "../apic"

[dependencies.serial_port]
path = "../serial_port"

[dependencies.console]
path = "../console"

[dependencies.logger]
path = "../logger"

[dependencies.e1000]
path = "../e1000"

[dependencies.acpi]
path = "../acpi"

[dependencies.pci]
path = "../pci"

[dependencies.ps2]
path = "../ps2"

[dependencies.keyboard]
path = "../keyboard"

[dependencies.mouse]
path = "../mouse"

[dependencies.storage_manager]
path = "../storage_manager"

[dependencies.network_manager]
path = "../network_manager"

[dependencies.ethernet_smoltcp_device]
path = "../ethernet_smoltcp_device"

[dependencies.ixgbe]
path = "../ixgbe"

[dependencies.io]
path = "../io"

[dependencies.mlx5]
path = "../mlx5"

[dependencies.iommu]
path = "../iommu"

[dependencies.net]
path = "../net"

[lib]
crate-type = ["rlib"]
Loading

0 comments on commit 9d4809b

Please sign in to comment.