Skip to content
Merged
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
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ members = [
"awkernel_async_lib",
"awkernel_async_lib_verified",
"awkernel_lib",
"awkernel_aarch64",
"awkernel_drivers",
"applications/awkernel_services",
"applications/awkernel_shell",
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ $ cargo binstall mdbook-mermaid
- [awkernel_macros](./awkernel_macros/)
- `#[awkernel::main]` entry-point macro
- [awkernel_drivers](./awkernel_drivers/)
- [awkernel_aarch64](./awkernel_aarch64/)
- [userland](./userland/)
- applications
- [awkernel_shell](./applications/awkernel_shell/)
Expand All @@ -53,13 +52,11 @@ $ cargo binstall mdbook-mermaid
graph TD;
awkernel_async_lib-->awkernel_async_lib_verified;
awkernel_async_lib-->awkernel_futures_macro;
awkernel_lib-->awkernel_aarch64;
awkernel_async_lib-->awkernel_lib;
awkernel_lib-->awkernel_sync;
userland-->awkernel_async_lib;
kernel-->awkernel_lib;
kernel-->awkernel_async_lib;
kernel-->awkernel_aarch64;
kernel-->awkernel_drivers;
awkernel_drivers-->awkernel_lib;
userland-->kernel;
Expand Down
8 changes: 0 additions & 8 deletions awkernel_aarch64/Cargo.toml

This file was deleted.

38 changes: 19 additions & 19 deletions awkernel_drivers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ default-features = false
[dependencies.awkernel_async_lib_verified]
path = "../awkernel_async_lib_verified"

[dependencies.awkernel_aarch64]
path = "../awkernel_aarch64"
optional = true

[dependencies.bootloader_api]
version = "0.11"
optional = true
Expand All @@ -73,12 +69,7 @@ features = [
default = []
x86 = ["awkernel_lib/x86", "dep:acpi", "dep:x86_64", "dep:bootloader_api"]
rv32 = ["awkernel_lib/rv32"]
aarch64 = [
"awkernel_lib/aarch64",
"dep:awkernel_aarch64",
"dep:embedded-hal",
"dep:embedded-hal-nb",
]
aarch64 = ["awkernel_lib/aarch64", "dep:embedded-hal", "dep:embedded-hal-nb"]
spinlock = ["awkernel_lib/spinlock"]
std = ["awkernel_lib/std"]

Expand All @@ -99,12 +90,21 @@ genet = ["mii"] # Broadcom GENET for Raspberry Pi

## PCIe
pcie = []
all_pcie = ["pcie", "igb", "ixgbe", "igc", "rp1", "bcm2712", "virtio-net", "virtio-blk"]
igb = ["dep:memoffset"] # Intel Gigabit Ethernet
igc = [] # Intel 2.5 Gigabit Ethernet
ixgbe = ["dep:rand"] # Intel 10 Gigabit Ethernet
rp1 = [] # RP1 of Raspberry Pi 5
bcm2712 = [] # Broadcom BCM2712 for Raspberry Pi 5
virtio-net = [] # VirtIO Network Card
virtio-blk = [] # VirtIO Block Device
xhci = ["pcie"] # xHCI USB host controller
all_pcie = [
"pcie",
"igb",
"ixgbe",
"igc",
"rp1",
"bcm2712",
"virtio-net",
"virtio-blk",
]
igb = ["dep:memoffset"] # Intel Gigabit Ethernet
igc = [] # Intel 2.5 Gigabit Ethernet
ixgbe = ["dep:rand"] # Intel 10 Gigabit Ethernet
rp1 = [] # RP1 of Raspberry Pi 5
bcm2712 = [] # Broadcom BCM2712 for Raspberry Pi 5
virtio-net = [] # VirtIO Network Card
virtio-blk = [] # VirtIO Block Device
xhci = ["pcie"] # xHCI USB host controller
2 changes: 1 addition & 1 deletion awkernel_drivers/src/ic/raspi/mbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Protocol details are as documented by the Mailbox property interface reference:
//! <https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface>

use awkernel_aarch64::cache::{clean_dcache_range, invalidate_dcache_range};
use awkernel_lib::arch::aarch64::cache::{clean_dcache_range, invalidate_dcache_range};
use core::{
ptr::read_volatile,
sync::atomic::{AtomicUsize, Ordering},
Expand Down
26 changes: 12 additions & 14 deletions awkernel_drivers/src/interrupt_controller/gicv3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use alloc::{boxed::Box, collections::BTreeMap};
use awkernel_lib::{
addr::{virt_addr::VirtAddr, Addr},
arch::aarch64::{current_affinity, get_affinity},
arch::aarch64::{current_affinity, get_affinity, utils},
cpu::NUM_MAX_CPU,
dma_pool::DMAPool,
interrupt::InterruptController,
Expand Down Expand Up @@ -283,9 +283,9 @@ impl GICv3 {
wait_gicr_rwp(gicr_base);

// Enable system register access.
let sre = awkernel_aarch64::icc_sre_el1::get();
let sre = utils::icc_sre_el1::get();
if sre & 1 == 0 {
unsafe { awkernel_aarch64::icc_sre_el1::set(sre & 1) };
unsafe { utils::icc_sre_el1::set(sre & 1) };
}

registers::GICR_ISENABLER0.write(!0, sgi_base);
Expand All @@ -312,17 +312,17 @@ impl GICv3 {
/// EOImode (0): ICC_EOIR0 and ICC_EOIR1 provide both priority drop and interrupt deactivation functionality
fn init_eoi_mode_zero() {
let eoi_mode = 1 << 1;
let icc_ctlr = awkernel_aarch64::icc_ctlr_el1::get();
unsafe { awkernel_aarch64::icc_ctlr_el1::set(icc_ctlr & !eoi_mode) };
let icc_ctlr = utils::icc_ctlr_el1::get();
unsafe { utils::icc_ctlr_el1::set(icc_ctlr & !eoi_mode) };
}

/// Enable signaling of the interrupt group 1.
fn enable_igrp() {
unsafe { awkernel_aarch64::icc_igrpen1_el1::set(1) };
unsafe { utils::icc_igrpen1_el1::set(1) };
}

fn init_priority_mask() {
unsafe { awkernel_aarch64::icc_pmr_el1::set(0xf0) };
unsafe { utils::icc_pmr_el1::set(0xf0) };
}
}

Expand Down Expand Up @@ -389,7 +389,7 @@ impl InterruptController for GICv3 {
return;
};

let (rs, target_list) = if (awkernel_aarch64::icc_ctlr_el1::get() & ICC_CTLR_RSS) != 0
let (rs, target_list) = if (utils::icc_ctlr_el1::get() & ICC_CTLR_RSS) != 0
&& registers::GICD_TYPER.read(self.gicd_base) & GICD_TYPER_RSS != 0
{
// Targeted SGIs with affinity level 0 values of 0 - 255 are supported.
Expand All @@ -406,7 +406,7 @@ impl InterruptController for GICv3 {
| (aff1 as u64) << 16
| target_list;

unsafe { awkernel_aarch64::icc_sgi1r_el1::set(reg) }
unsafe { utils::icc_sgi1r_el1::set(reg) }
}

fn send_ipi_broadcast(&mut self, irq: u16) {
Expand All @@ -417,9 +417,7 @@ impl InterruptController for GICv3 {

fn send_ipi_broadcast_without_self(&mut self, irq: u16) {
const ICC_SGI1R_EL1_IRM: u64 = 1 << 40;
unsafe {
awkernel_aarch64::icc_sgi1r_el1::set(ICC_SGI1R_EL1_IRM | ((irq as u64) & 0x0f) << 24)
}
unsafe { utils::icc_sgi1r_el1::set(ICC_SGI1R_EL1_IRM | ((irq as u64) & 0x0f) << 24) }
}

fn pending_irqs<'a>(&self) -> Box<dyn Iterator<Item = u16>> {
Expand Down Expand Up @@ -456,12 +454,12 @@ impl Iterator for PendingInterruptIterator {
type Item = u16;

fn next(&mut self) -> Option<Self::Item> {
let id = awkernel_aarch64::icc_iar1_el1::get() as u16;
let id = utils::icc_iar1_el1::get() as u16;

if id == ID_SPURIOUS {
None
} else {
unsafe { awkernel_aarch64::icc_eoir1_el1::set(id as u64) };
unsafe { utils::icc_eoir1_el1::set(id as u64) };
Some(id)
}
}
Expand Down
6 changes: 1 addition & 5 deletions awkernel_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ optional = true
version = "0.11"
optional = true

[dependencies.awkernel_aarch64]
path = "../awkernel_aarch64"
optional = true

[dependencies.unwinding]
version = "0.2"
# git = "https://github.com/nbdd0121/unwinding.git"
Expand Down Expand Up @@ -93,7 +89,7 @@ x86 = [
"awkernel_sync/x86",
"awkernel_sync/x86_mwait",
]
aarch64 = ["dep:awkernel_aarch64", "awkernel_sync/aarch64"]
aarch64 = ["awkernel_sync/aarch64"]
rv32 = ["dep:riscv", "awkernel_sync/rv32"]
rv64 = ["dep:riscv", "awkernel_sync/rv64"]
std = ["dep:libc", "dep:socket2", "awkernel_sync/std"]
Expand Down
2 changes: 2 additions & 0 deletions awkernel_lib/src/arch/aarch64.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod armv8_timer;
pub mod barrier;
pub mod cache;
pub(super) mod cpu;
pub(super) mod delay;
pub(super) mod dvfs;
Expand All @@ -9,6 +10,7 @@ pub mod page_allocator;
pub mod page_table;
pub(super) mod paging;
pub(super) mod power;
pub mod utils;

pub use cpu::*;

Expand Down
8 changes: 4 additions & 4 deletions awkernel_lib/src/arch/aarch64/armv8_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl Armv8Timer {

impl crate::timer::Timer for Armv8Timer {
fn reset(&self, dur: Duration) {
let hz = awkernel_aarch64::cntfrq_el0::get() as u128;
let hz = super::utils::cntfrq_el0::get() as u128;

let ns = dur.as_nanos();

Expand All @@ -69,8 +69,8 @@ impl crate::timer::Timer for Armv8Timer {
};

unsafe {
awkernel_aarch64::cntv_tval_el0::set(tval);
awkernel_aarch64::cntv_ctl_el0::set(1); // Enable interrupt.
super::utils::cntv_tval_el0::set(tval);
super::utils::cntv_ctl_el0::set(1); // Enable interrupt.
}
}

Expand All @@ -79,6 +79,6 @@ impl crate::timer::Timer for Armv8Timer {
}

fn disable(&self) {
unsafe { awkernel_aarch64::cntv_ctl_el0::set(0) };
unsafe { super::utils::cntv_ctl_el0::set(0) };
}
}
2 changes: 1 addition & 1 deletion awkernel_lib/src/arch/aarch64/barrier.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Memory barrier implementations for AArch64 architecture
use awkernel_aarch64::{dmb_ld, dmb_st, dmb_sy};
use super::utils::{dmb_ld, dmb_st, dmb_sy};

pub const BUS_SPACE_BARRIER_READ: u32 = 0x01;
pub const BUS_SPACE_BARRIER_WRITE: u32 = 0x02;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Data cache maintenance by virtual address.

use crate::{ctr_el0, dsb_sy};
use super::utils::{ctr_el0, dsb_sy};
use core::arch::asm;

/// Smallest D-cache line size, in bytes, as reported by `CTR_EL0.DminLine`.
Expand Down
4 changes: 2 additions & 2 deletions awkernel_lib/src/arch/aarch64/cpu.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::utils::mpidr_el1;
use crate::cpu::{CPU, NUM_MAX_CPU};
use awkernel_aarch64::mpidr_el1;

#[no_mangle]
pub static mut AFF0_MAX: u64 = 0;
Expand Down Expand Up @@ -73,7 +73,7 @@ pub const AFF0_MASK: u64 = 0xff;

/// Get the current CPU affinity.
pub fn current_affinity() -> (u8, u8, u8, u8) {
let mpidr_el1 = awkernel_aarch64::mpidr_el1::get();
let mpidr_el1 = mpidr_el1::get();
(
((mpidr_el1 & AFF3_MASK) >> 32) as u8,
((mpidr_el1 & AFF2_MASK) >> 16) as u8,
Expand Down
34 changes: 17 additions & 17 deletions awkernel_lib/src/arch/aarch64/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ impl Delay for super::AArch64 {
}

fn wait_microsec(usec: u64) {
let frq = awkernel_aarch64::cntfrq_el0::get();
let t = awkernel_aarch64::cntvct_el0::get();
let frq = super::utils::cntfrq_el0::get();
let t = super::utils::cntvct_el0::get();

let end = t + ((frq / 1000) * usec) / 1000;

while awkernel_aarch64::cntvct_el0::get() < end {
awkernel_aarch64::isb();
while super::utils::cntvct_el0::get() < end {
super::utils::isb();
}
}

fn uptime() -> u64 {
let start = unsafe { read_volatile(addr_of!(COUNT_START)) };

let frq = awkernel_aarch64::cntfrq_el0::get();
let now = awkernel_aarch64::cntvct_el0::get();
let frq = super::utils::cntfrq_el0::get();
let now = super::utils::cntvct_el0::get();

let diff = now - start;

Expand All @@ -34,44 +34,44 @@ impl Delay for super::AArch64 {
fn uptime_nano() -> u128 {
let start = unsafe { read_volatile(addr_of!(COUNT_START)) };

let frq = awkernel_aarch64::cntfrq_el0::get();
let now = awkernel_aarch64::cntvct_el0::get();
let frq = super::utils::cntfrq_el0::get();
let now = super::utils::cntvct_el0::get();

let diff = now - start;

diff as u128 * 1_000_000_000 / frq as u128
}

fn cpu_counter() -> u64 {
awkernel_aarch64::pmccntr_el0::get()
super::utils::pmccntr_el0::get()
}
}

pub(super) unsafe fn init_primary() {
init_pmc();

let count = awkernel_aarch64::cntvct_el0::get();
let count = super::utils::cntvct_el0::get();
write_volatile(addr_of_mut!(COUNT_START), count);
}

/// Initialize performance monitor counter.
unsafe fn init_pmc() {
// Enable user-mode access to cycle counters.
awkernel_aarch64::pmuserenr_el0::set(0b1101);
super::utils::pmuserenr_el0::set(0b1101);

// Disable the cycle counter overflow interrupt.
awkernel_aarch64::pmintenset_el1::set(0);
super::utils::pmintenset_el1::set(0);

// Enable the cycle counter.
awkernel_aarch64::pmcntenset_el0::set(1 << 31);
super::utils::pmcntenset_el0::set(1 << 31);

// Clear the cycle counter and start.
let pmcr_el0 = awkernel_aarch64::pmcr_el0::get();
let pmcr_el0 = super::utils::pmcr_el0::get();
let pmcr_el0 = pmcr_el0 | 0b111;
awkernel_aarch64::isb();
awkernel_aarch64::pmcr_el0::set(pmcr_el0);
super::utils::isb();
super::utils::pmcr_el0::set(pmcr_el0);

awkernel_aarch64::pmccfiltr_el0::set(1 << 27);
super::utils::pmccfiltr_el0::set(1 << 27);
}

pub(super) unsafe fn init_non_primary() {
Expand Down
6 changes: 3 additions & 3 deletions awkernel_lib/src/arch/aarch64/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::interrupt::Interrupt;

impl Interrupt for super::AArch64 {
fn get_flag() -> usize {
awkernel_aarch64::daif::get() as usize
super::utils::daif::get() as usize
}

fn disable() {
Expand All @@ -14,11 +14,11 @@ impl Interrupt for super::AArch64 {
}

fn are_enabled() -> bool {
let daif = awkernel_aarch64::daif::get();
let daif = super::utils::daif::get();
(daif & (1 << 7)) == 0
}

fn set_flag(flag: usize) {
unsafe { awkernel_aarch64::daif::set(flag as u64) };
unsafe { super::utils::daif::set(flag as u64) };
}
}
Loading
Loading