Skip to content

Commit 3250e0e

Browse files
authored
Merge branch 'theseus_main' into theseus_main
2 parents 742528b + 27429e5 commit 3250e0e

File tree

28 files changed

+1545
-958
lines changed

28 files changed

+1545
-958
lines changed

Cargo.lock

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ exclude = [
7979

8080
## Exclude application crates used for testing specific Theseus functionality.
8181
## TODO: move these to a specific "tests" folder so we can exclude that entire folder.
82+
"applications/test_aligned_page_allocation",
8283
"applications/test_backtrace",
8384
"applications/test_block_io",
8485
"applications/test_channel",

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,9 @@ else ifeq ($(ARCH),aarch64)
933933
QEMU_FLAGS += -machine virt,gic-version=3
934934
QEMU_FLAGS += -device ramfb
935935
QEMU_FLAGS += -cpu cortex-a72
936+
QEMU_FLAGS += -usb
937+
QEMU_FLAGS += -device usb-ehci,id=ehci
938+
QEMU_FLAGS += -device usb-kbd
936939
else
937940
QEMU_FLAGS += -cpu Broadwell
938941
endif
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "test_aligned_page_allocation"
3+
version = "0.1.0"
4+
description = "Tests the `AllocationRequest::AlignedTo` variant, which is needed for huge pages"
5+
authors = ["Kevin Boos <[email protected]>"]
6+
edition = "2021"
7+
8+
[dependencies]
9+
log = "0.4.8"
10+
11+
[dependencies.memory]
12+
path = "../../kernel/memory"
13+
14+
[dependencies.app_io]
15+
path = "../../kernel/app_io"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//! A set of basic tests for the [`AllocationRequest::AlignedTo`] variant.
2+
3+
#![no_std]
4+
5+
extern crate alloc;
6+
7+
use alloc::{
8+
vec::Vec,
9+
string::String,
10+
};
11+
use app_io::println;
12+
use memory::AllocationRequest;
13+
14+
static TEST_SET: [usize; 9] = [1, 2, 4, 8, 27, 48, 256, 512, 1024];
15+
16+
pub fn main(_args: Vec<String>) -> isize {
17+
match rmain() {
18+
Ok(_) => 0,
19+
Err(e) => {
20+
println!("Error: {}", e);
21+
-1
22+
}
23+
}
24+
}
25+
26+
fn rmain() -> Result<(), &'static str> {
27+
for num_pages in TEST_SET.into_iter() {
28+
for alignment in TEST_SET.into_iter() {
29+
println!("Attempting to allocate {num_pages} pages with alignment of {alignment} 4K pages...");
30+
match memory::allocate_pages_deferred(
31+
AllocationRequest::AlignedTo { alignment_4k_pages: alignment },
32+
num_pages,
33+
) {
34+
Ok((ap, _action)) => {
35+
assert_eq!(ap.start().number() % alignment, 0);
36+
assert_eq!(ap.size_in_pages(), num_pages);
37+
println!(" Success: {ap:?}");
38+
}
39+
Err(e) => println!(" !! FAILURE: {e:?}"),
40+
}
41+
}
42+
}
43+
44+
Ok(())
45+
}

kernel/arm_boards/src/boards/qemu_virt.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use super::{
44
InterruptControllerConfig::GicV3, GicV3InterruptControllerConfig,
5-
BoardConfig, mpidr::DefinedMpidrValue,
5+
BoardConfig, mpidr::DefinedMpidrValue, PciEcamConfig,
66
};
77
use memory_structs::PhysicalAddress;
88

@@ -38,4 +38,11 @@ pub const BOARD_CONFIG: BoardConfig = BoardConfig {
3838
pl011_base_addresses: [ PhysicalAddress::new_canonical(0x09000000) ],
3939
pl011_rx_spi: 33,
4040
cpu_local_timer_ppi: 30,
41+
42+
// obtained via internal qemu debugging
43+
// todo: will this always be correct?
44+
pci_ecam: PciEcamConfig {
45+
base_address: PhysicalAddress::new_canonical(0x4010000000),
46+
size_bytes: 0x10000000,
47+
}
4148
};

kernel/arm_boards/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ pub struct GicV3InterruptControllerConfig {
1919
pub redistributor_base_addresses: [PhysicalAddress; NUM_CPUS],
2020
}
2121

22+
#[derive(Debug, Copy, Clone)]
23+
pub struct PciEcamConfig {
24+
pub base_address: PhysicalAddress,
25+
pub size_bytes: usize,
26+
}
27+
28+
/// This excludes GICv2 because there's no way to send IPIs
29+
/// with GICv2 via the current driver API.
2230
#[derive(Debug, Copy, Clone)]
2331
pub enum InterruptControllerConfig {
2432
GicV3(GicV3InterruptControllerConfig),
@@ -46,6 +54,8 @@ pub struct BoardConfig {
4654
//
4755
// aarch64 manuals define the default timer IRQ number to be 30.
4856
pub cpu_local_timer_ppi: u8,
57+
58+
pub pci_ecam: PciEcamConfig,
4959
}
5060

5161
// by default & on x86_64, the default.rs file is used

kernel/device_manager/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ event_types = { path = "../event_types" }
1212
serial_port = { path = "../serial_port" }
1313
console = { path = "../console" }
1414
logger = { path = "../logger" }
15+
pci = { path = "../pci" }
1516
derive_more = "0.99.0"
1617
mpmc = "0.1.6"
1718
log = "0.4.8"
@@ -20,7 +21,6 @@ log = "0.4.8"
2021
memory = { path = "../memory" }
2122
e1000 = { path = "../e1000" }
2223
acpi = { path = "../acpi" }
23-
pci = { path = "../pci" }
2424
ps2 = { path = "../ps2" }
2525
keyboard = { path = "../keyboard" }
2626
mouse = { path = "../mouse" }

kernel/device_manager/src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
extern crate alloc;
55

6-
use log::info;
6+
use log::{info, debug};
77

88
#[cfg(target_arch = "x86_64")]
99
use {
10-
log::{error, debug, warn},
10+
log::{error, warn},
1111
mpmc::Queue,
1212
event_types::Event,
1313
memory::MemoryManagementInfo,
@@ -86,19 +86,20 @@ pub fn init(
8686
mouse::init(ps2_controller.mouse_ref(), mouse_producer)?;
8787
}
8888

89-
// No PCI support on aarch64 at the moment
90-
#[cfg(target_arch = "x86_64")] {
9189
// Initialize/scan the PCI bus to discover PCI devices
92-
for dev in pci::pci_device_iter() {
93-
debug!("Found pci device: {:X?}", dev);
90+
for dev in pci::pci_device_iter()? {
91+
debug!("Found PCI device: {:X?}", dev);
9492
}
9593

94+
// No NIC support on aarch64 at the moment
95+
#[cfg(target_arch = "x86_64")] {
96+
9697
// store all the initialized ixgbe NICs here to be added to the network interface list
9798
let mut ixgbe_devs = Vec::new();
9899

99100
// Iterate over all PCI devices and initialize the drivers for the devices we support.
100101

101-
for dev in pci::pci_device_iter() {
102+
for dev in pci::pci_device_iter()? {
102103
// Currently we skip Bridge devices, since we have no use for them yet.
103104
if dev.class == 0x06 {
104105
continue;

kernel/gic/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ edition = "2021"
66
name = "gic"
77

88
[dependencies]
9-
static_assertions = "1.1.0"
109
zerocopy = "0.5.0"
10+
volatile = "0.2.7"
11+
spin = "0.9.4"
1112
log = "0.4.8"
1213

1314
memory = { path = "../memory" }

0 commit comments

Comments
 (0)