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
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
- uses: actions/checkout@v3

- name: Install Rust nightly
run: rustup toolchain install nightly-2025-05-22
run: rustup toolchain install nightly-2025-11-16
- name: Use Rust nightly
run: rustup default nightly-2025-05-22
run: rustup default nightly-2025-11-16
- name: Add Rust components
run: rustup component add rust-src llvm-tools-preview clippy rustfmt
- name: Add Rust targets
Expand Down
12 changes: 6 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
// For AArch64 Virt
// "rust-analyzer.cargo.buildScripts.overrideCommand": [
// "cargo",
// "+nightly-2025-05-22",
// "+nightly-2025-11-16",
// "check_no_std",
// "--target=targets/aarch64-kernel.json",
// ],
// "rust-analyzer.check.overrideCommand": [
// "cargo",
// "+nightly-2025-05-22",
// "+nightly-2025-11-16",
// "check_no_std",
// "--target=targets/aarch64-kernel.json",
// ],
Expand All @@ -21,13 +21,13 @@
// For x86_64
"rust-analyzer.cargo.buildScripts.overrideCommand": [
"cargo",
"+nightly-2025-05-22",
"+nightly-2025-11-16",
"check_no_std",
"--target=targets/x86_64-kernel.json",
],
"rust-analyzer.check.overrideCommand": [
"cargo",
"+nightly-2025-05-22",
"+nightly-2025-11-16",
"check_no_std",
"--target=targets/x86_64-kernel.json",
],
Expand All @@ -37,14 +37,14 @@
// For Linux
// "rust-analyzer.cargo.buildScripts.overrideCommand": [
// "cargo",
// "+nightly-2025-05-22",
// "+nightly-2025-11-16",
// "check_std",
// "--quiet",
// "--message-format=json"
// ],
// "rust-analyzer.check.overrideCommand": [
// "cargo",
// "+nightly-2025-05-22",
// "+nightly-2025-11-16",
// "check_std",
// "--quiet",
// "--message-format=json"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ X86_64_LD=$(LINKERDIR)/x86_64-link.lds
RV32_LD=$(LINKERDIR)/rv32-link.lds
RV64_LD=$(LINKERDIR)/rv64-link.lds

RUSTV=nightly-2025-05-22
RUSTV=nightly-2025-11-16

all: aarch64 x86_64 riscv32 riscv64 std

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ It can execute async/await applications in kernel space safely.

```text
$ sudo apt install clang qemu-system-arm qemu-system-x86 qemu-system-misc python3-pyelftools
$ rustup toolchain install nightly-2025-05-22
$ rustup default nightly-2025-05-22
$ rustup toolchain install nightly-2025-11-16
$ rustup default nightly-2025-11-16
$ rustup component add rust-src llvm-tools-preview
$ rustup target add x86_64-unknown-none aarch64-unknown-none riscv64gc-unknown-none-elf riscv32imac-unknown-none-elf
```
Expand Down
33 changes: 5 additions & 28 deletions awkernel_async_lib/src/dag/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ where
/// not borrow from the graph.
///
/// [1]: struct.Neighbors.html#method.detach
pub fn neighbors(&self, a: NodeIndex<Ix>) -> Neighbors<E, Ix> {
pub fn neighbors(&self, a: NodeIndex<Ix>) -> Neighbors<'_, E, Ix> {
self.neighbors_directed(a, Outgoing)
}

Expand All @@ -546,7 +546,7 @@ where
/// not borrow from the graph.
///
/// [1]: struct.Neighbors.html#method.detach
pub fn neighbors_directed(&self, a: NodeIndex<Ix>, dir: Direction) -> Neighbors<E, Ix> {
pub fn neighbors_directed(&self, a: NodeIndex<Ix>, dir: Direction) -> Neighbors<'_, E, Ix> {
let mut iter = self.neighbors_undirected(a);
let k = dir.index();
iter.next[1 - k] = EdgeIndex::end();
Expand All @@ -567,7 +567,7 @@ where
/// not borrow from the graph.
///
/// [1]: struct.Neighbors.html#method.detach
pub fn neighbors_undirected(&self, a: NodeIndex<Ix>) -> Neighbors<E, Ix> {
pub fn neighbors_undirected(&self, a: NodeIndex<Ix>) -> Neighbors<'_, E, Ix> {
Neighbors {
skip_start: a,
edges: &self.edges,
Expand All @@ -589,7 +589,7 @@ where
/// just the nodes without edges.
///
/// The whole iteration computes in **O(|V|)** time where V is the set of nodes.
pub fn externals(&self, dir: Direction) -> Externals<N, Ix> {
pub fn externals(&self, dir: Direction) -> Externals<'_, N, Ix> {
Externals {
iter: self.nodes.iter().enumerate(),
dir,
Expand All @@ -607,7 +607,7 @@ where
/// Create an iterator over all edges, in indexed order.
///
/// Iterator element type is `EdgeReference<E, Ix>`.
pub fn edge_references(&self) -> EdgeReferences<E, Ix> {
pub fn edge_references(&self) -> EdgeReferences<'_, E, Ix> {
EdgeReferences {
iter: self.edges.iter().enumerate(),
}
Expand Down Expand Up @@ -691,29 +691,6 @@ where
clone_fields!(Neighbors, skip_start, edges, next,);
}

/// A “walker” object that can be used to step through the edge list of a node.
///
/// Created with [`.detach()`](struct.Neighbors.html#method.detach).
///
/// The walker does not borrow from the graph, so it lets you step through
/// neighbors or incident edges while also mutating graph weights.
pub struct WalkNeighbors<Ix> {
skip_start: NodeIndex<Ix>,
next: [EdgeIndex<Ix>; 2],
}

impl<Ix> Clone for WalkNeighbors<Ix>
where
Ix: IndexType,
{
fn clone(&self) -> Self {
WalkNeighbors {
skip_start: self.skip_start,
next: self.next,
}
}
}

/// Iterator over the node indices of a graph.
#[derive(Clone, Debug)]
pub struct NodeIndices<Ix = DefaultIx> {
Expand Down
2 changes: 1 addition & 1 deletion awkernel_async_lib/src/dag/graph/iter_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub struct Format<'a, I> {
}

pub trait IterFormatExt: Iterator {
fn format(self, separator: &str) -> Format<Self>
fn format(self, separator: &str) -> Format<'_, Self>
where
Self: Sized,
{
Expand Down
6 changes: 3 additions & 3 deletions awkernel_async_lib/src/dag/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ IntoEdgeReferences! {delegate_impl [] }

trait_template! {
/// The graph’s `NodeId`s map to indices
#[allow(clippy::needless_arbitrary_self_type)]
#[allow(clippy::needless_arbitrary_self_type, dead_code)]
pub trait NodeIndexable : GraphBase {
@section self
/// Return an upper bound of the node indices in the graph
Expand All @@ -150,7 +150,7 @@ NodeIndexable! {delegate_impl []}

trait_template! {
/// A graph with a known node count.
#[allow(clippy::needless_arbitrary_self_type)]
#[allow(clippy::needless_arbitrary_self_type, dead_code)]
pub trait NodeCount : GraphBase {
@section self
fn node_count(self: &Self) -> usize;
Expand Down Expand Up @@ -244,7 +244,7 @@ where

trait_template! {
/// A graph that can create a map that tracks the visited status of its nodes.
#[allow(clippy::needless_arbitrary_self_type)]
#[allow(clippy::needless_arbitrary_self_type, dead_code)]
pub trait Visitable : GraphBase {
@section type
/// The associated map type
Expand Down
9 changes: 2 additions & 7 deletions awkernel_async_lib/src/time_interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use core::{
use futures::Stream;
use futures::StreamExt;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
#[allow(unused)]
pub enum MissedTickBehavior {
/// Ticks as fast as possible until caught up.
Expand All @@ -50,6 +50,7 @@ pub enum MissedTickBehavior {
/// Expected ticks: | 1 | 2 | 3 | 4 | 5 | 6 |
/// Actual ticks: | work -----| delay | work | work | work -| work -----|
/// ```
#[default]
Burst,

/// Ticks at the next available interval after the delay.
Expand All @@ -71,12 +72,6 @@ pub enum MissedTickBehavior {
Skip,
}

impl Default for MissedTickBehavior {
fn default() -> Self {
Self::Burst
}
}

/// Creates a new interval that ticks at the specified `period`.
/// The first tick completes immediately.
///
Expand Down
2 changes: 1 addition & 1 deletion awkernel_async_lib_verified/src/ringq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<T> RingQ<T> {

/// Get a iterator.
#[inline(always)]
pub fn iter(&self) -> IterRingQ<T> {
pub fn iter(&self) -> IterRingQ<'_, T> {
IterRingQ {
ringq: self,
pos: self.head,
Expand Down
7 changes: 3 additions & 4 deletions awkernel_drivers/src/pcie/intel/igb/igb_hw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6005,9 +6005,8 @@ impl IgbHw {
// operation, while the smaller eeproms are capable of an
// 8-byte PAGE WRITE operation. Break the inner loop to pass
// new address
if (((offset + widx as u32) * 2)
% self.eeprom.page_size.ok_or(IgbDriverErr::EEPROM)? as u32)
== 0
if ((offset + widx as u32) * 2)
.is_multiple_of(self.eeprom.page_size.ok_or(IgbDriverErr::EEPROM)? as u32)
{
self.standby_eeprom(info)?;
break;
Expand Down Expand Up @@ -6215,7 +6214,7 @@ impl IgbHw {
let mut i = 0;
let mut add;
while i < data.len() {
let act_offset = if (offset + i as u32) % 2 != 0 {
let act_offset = if !(offset + i as u32).is_multiple_of(2) {
add = 1;
bank_offset as u32 + (offset + i as u32 - 1) * 2
} else {
Expand Down
4 changes: 2 additions & 2 deletions awkernel_drivers/src/pcie/intel/igc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,8 +1024,8 @@ fn igc_allocate_queues(
info: &PCIeInfo,
irqs: &[IRQ],
) -> Result<(Vec<Queue>, BTreeMap<u16, usize>), PCIeDeviceErr> {
assert!(core::mem::size_of::<RxRing>() % PAGESIZE == 0);
assert!(core::mem::size_of::<TxRing>() % PAGESIZE == 0);
assert!(core::mem::size_of::<RxRing>().is_multiple_of(PAGESIZE));
assert!(core::mem::size_of::<TxRing>().is_multiple_of(PAGESIZE));

let mut irq_to_queue = BTreeMap::new();
let mut que = Vec::with_capacity(irqs.len());
Expand Down
2 changes: 1 addition & 1 deletion awkernel_drivers/src/pcie/intel/ixgbe/ixgbe_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2251,7 +2251,7 @@ pub fn hic_unlocked(
}

// Calculate length in DWORDs. We must be DWORD aligned
if length % (core::mem::size_of::<u32>() as u32) != 0 {
if !length.is_multiple_of(core::mem::size_of::<u32>() as u32) {
log::debug!("Buffer length failure, not aligned to dword");
return Err(InvalidArgument);
}
Expand Down
15 changes: 8 additions & 7 deletions awkernel_drivers/src/pcie/nvme/nvme_regs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ pub const NVME_VS: usize = 0x0008; /* Version */
pub const NVME_INTMC: usize = 0x0010; /* Interrupt Mask Clear */

pub const NVME_CC: usize = 0x0014; /* Controller Configuration */
pub const NVME_CC_IOCQES: fn(u32) -> u32 = |_v| (((_v) & 0xf) << 20);
pub const NVME_CC_IOCQES: fn(u32) -> u32 = |_v| ((_v) & 0xf) << 20;
pub const NVME_CC_IOCQES_MASK: u32 = 0xf << 20;
pub const NVME_CC_IOSQES: fn(u32) -> u32 = |_v| (((_v) & 0xf) << 16);
pub const NVME_CC_IOSQES: fn(u32) -> u32 = |_v| ((_v) & 0xf) << 16;
pub const NVME_CC_IOSQES_MASK: u32 = 0xf << 16;
pub const NVME_CC_SHN: fn(u32) -> u32 = |_v| (((_v) & 0x3) << 14);
pub const NVME_CC_SHN: fn(u32) -> u32 = |_v| ((_v) & 0x3) << 14;
pub const NVME_CC_SHN_MASK: u32 = 0x3 << 14;
pub const NVME_CC_SHN_NONE: u32 = 0;
pub const NVME_CC_AMS: fn(u32) -> u32 = |_v| (((_v) & 0x7) << 11);
pub const NVME_CC_AMS: fn(u32) -> u32 = |_v| ((_v) & 0x7) << 11;
pub const NVME_CC_AMS_MASK: u32 = 0x7 << 11;
pub const NVME_CC_AMS_RR: u32 = 0; /* round-robin */
pub const NVME_CC_MPS: fn(u32) -> u32 = |_v| ((((_v) - 12) & 0xf) << 7);
pub const NVME_CC_MPS: fn(u32) -> u32 = |_v| (((_v) - 12) & 0xf) << 7;
pub const NVME_CC_MPS_MASK: u32 = 0xf << 7;
pub const NVME_CC_CSS: fn(u32) -> u32 = |_v| (((_v) & 0x7) << 4);
pub const NVME_CC_CSS: fn(u32) -> u32 = |_v| ((_v) & 0x7) << 4;
pub const NVME_CC_CSS_MASK: u32 = 0x7 << 4;
pub const NVME_CC_CSS_NVM: u32 = 0;
pub const NVME_CC_EN: u32 = 1 << 0;
Expand All @@ -34,7 +34,7 @@ pub const NVME_CSTS_RDY: u32 = 1 << 0;

pub const NVME_AQA: usize = 0x0024; /* Admin Queue Attributes */
/* Admin Completion Queue Size */
pub const NVME_AQA_ACQS: fn(u32) -> u32 = |_v| (((_v) - 1) << 16);
pub const NVME_AQA_ACQS: fn(u32) -> u32 = |_v| ((_v) - 1) << 16;
/* Admin Submission Queue Size */
pub const NVME_AQA_ASQS: fn(u32) -> u32 = |_v| (_v) - 1;
pub const NVME_ASQ: usize = 0x0028; /* Admin Submission Queue Base Address */
Expand Down Expand Up @@ -249,6 +249,7 @@ pub struct ComQueue {
pub _phase: u16,
}

#[allow(dead_code)] // may be used in the future, remove this line if used
#[repr(C)]
#[derive(Debug, Clone, Copy, Default)]
pub struct SubQueueEntryIo {
Expand Down
2 changes: 1 addition & 1 deletion awkernel_drivers/src/pcie/virtio/virtio_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ impl VirtioNetInner {
let should_kick = {
let queue_idx = (vq_idx / 2) as usize;
let mut node = MCSNode::new();
let vq = if vq_idx % 2 == 0 {
let vq = if vq_idx.is_multiple_of(2) {
&mut self.virtqueues[queue_idx].rx.lock(&mut node)
} else {
&mut self.virtqueues[queue_idx].tx.lock(&mut node)
Expand Down
2 changes: 1 addition & 1 deletion awkernel_lib/src/arch/rv32/frame_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn init_page_allocator() {
}
if let Some(allocator_ref) = allocator.as_mut() {
allocator_ref.init(
PhyAddr::from_usize(ekernel as usize).ceil(),
PhyAddr::from_usize(ekernel as *const () as usize).ceil(),
PhyAddr::from_usize(MEMORY_END as usize).floor(),
);
} else {
Expand Down
18 changes: 9 additions & 9 deletions awkernel_lib/src/arch/rv32/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ impl MemorySet {
}
memory_set.push(
MapArea::new(
VirtAddr::from_usize(stext as usize),
VirtAddr::from_usize(etext as usize),
VirtAddr::from_usize(stext as *const () as usize),
VirtAddr::from_usize(etext as *const () as usize),
MapType::Identical,
MapPermission::R | MapPermission::X,
),
Expand All @@ -214,8 +214,8 @@ impl MemorySet {
}
memory_set.push(
MapArea::new(
VirtAddr::from_usize(srodata as usize),
VirtAddr::from_usize(erodata as usize),
VirtAddr::from_usize(srodata as *const () as usize),
VirtAddr::from_usize(erodata as *const () as usize),
MapType::Identical,
MapPermission::R,
),
Expand All @@ -227,8 +227,8 @@ impl MemorySet {
}
memory_set.push(
MapArea::new(
VirtAddr::from_usize(sdata as usize),
VirtAddr::from_usize(edata as usize),
VirtAddr::from_usize(sdata as *const () as usize),
VirtAddr::from_usize(edata as *const () as usize),
MapType::Identical,
MapPermission::R | MapPermission::W,
),
Expand All @@ -240,8 +240,8 @@ impl MemorySet {
}
memory_set.push(
MapArea::new(
VirtAddr::from_usize(sbss_with_stack as usize),
VirtAddr::from_usize(ebss as usize),
VirtAddr::from_usize(sbss_with_stack as *const () as usize),
VirtAddr::from_usize(ebss as *const () as usize),
MapType::Identical,
MapPermission::R | MapPermission::W,
),
Expand All @@ -253,7 +253,7 @@ impl MemorySet {
}
memory_set.push(
MapArea::new(
VirtAddr::from_usize(ekernel as usize),
VirtAddr::from_usize(ekernel as *const () as usize),
VirtAddr::from_usize(super::address::MEMORY_END as usize),
MapType::Identical,
MapPermission::R | MapPermission::W,
Expand Down
2 changes: 1 addition & 1 deletion awkernel_lib/src/arch/rv64/frame_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn init_page_allocator() {
}
if let Some(allocator_ref) = allocator.as_mut() {
allocator_ref.init(
PhyAddr::from_usize(ekernel as usize).ceil(),
PhyAddr::from_usize(ekernel as *const () as usize).ceil(),
PhyAddr::from_usize(MEMORY_END as usize).floor(),
);
} else {
Expand Down
Loading