This change adopts a new, more descriptive naming policy for workspace crates: `k23-<crate name>` rather than the previous much less helpful `k<crate name>`.
···2626 if #[cfg(target_arch = "riscv64")] {
2727 mod riscv64;
2828 pub use riscv64::*;
2929- pub use riscv::*;
2929+ pub use k23_riscv::*;
3030 } else if #[cfg(target_arch = "aarch64")] {
3131 mod aarch64;
3232 pub use aarch64::*;
+2-2
kernel/src/arch/riscv64/asid_allocator.rs
···99use alloc::vec::Vec;
1010use core::fmt;
11111212-use riscv::satp;
1313-use spin::OnceLock;
1212+use k23_riscv::satp;
1313+use k23_spin::OnceLock;
14141515// FIXME: A OnceLock to store a u16? yikes
1616static MAX_ASID: OnceLock<u16> = OnceLock::new();
···1818use anyhow::ensure;
1919pub use asid_allocator::AsidAllocator;
2020pub use block_on::block_on;
2121+use k23_riscv::sstatus::FS;
2222+use k23_riscv::{interrupt, scounteren, sie, sstatus};
2123use kmem::VirtualAddress;
2224pub use mem::{
2325 AddressSpace, DEFAULT_ASID, KERNEL_ASPACE_RANGE, PAGE_SHIFT, PAGE_SIZE, USER_ASPACE_RANGE,
2426 invalidate_range, is_canonical, is_kernel_address, is_user_address, phys_to_virt,
2527};
2626-use riscv::sstatus::FS;
2727-use riscv::{interrupt, scounteren, sie, sstatus};
2828pub use setjmp_longjmp::{JmpBuf, JmpBufStruct, call_with_setjmp, longjmp};
29293030use crate::arch::device::cpu::Cpu;
···3535/// Global RISC-V specific initialization.
3636#[cold]
3737pub fn init() -> state::Global {
3838- let supported = riscv::sbi::supported_extensions().unwrap();
3838+ let supported = k23_riscv::sbi::supported_extensions().unwrap();
3939 tracing::trace!("Supported SBI extensions: {supported:?}");
40404141 mem::init();
+1-1
kernel/src/arch/riscv64/setjmp_longjmp.rs
···4848use core::mem::{ManuallyDrop, MaybeUninit};
4949use core::ptr::addr_of_mut;
50505151-use riscv::{load_fp, load_gp, save_fp, save_gp};
5151+use k23_riscv::{load_fp, load_gp, save_fp, save_gp};
52525353/// A store for the register state used by `setjmp` and `longjmp`.
5454///
+8-8
kernel/src/arch/riscv64/trap_handler.rs
···99use core::arch::{asm, naked_asm};
1010use core::cell::Cell;
11111212-use cpu_local::cpu_local;
1313-use kmem::VirtualAddress;
1414-use riscv::scause::{Exception, Interrupt};
1515-use riscv::{
1212+use k23_cpu_local::cpu_local;
1313+use k23_riscv::scause::{Exception, Interrupt};
1414+use k23_riscv::{
1615 load_fp, load_gp, save_fp, save_gp, scause, sepc, sip, sscratch, sstatus, stval, stvec,
1716};
1717+use kmem::VirtualAddress;
18181919use crate::arch::PAGE_SIZE;
2020use crate::arch::trap::Trap;
···355355356356 tracing::error!("KERNEL TRAP {cause:?} epc={epc};tval={tval}");
357357358358- let mut regs = unwind2::Registers {
358358+ let mut regs = k23_unwind::Registers {
359359 gp: frame.gp,
360360 fp: frame.fp,
361361 };
···371371372372 // begin a panic on the original stack
373373 // Safety: we saved the register state at the beginning of the trap handler
374374- unsafe { panic_unwind2::begin_unwind(payload, regs, epc.add(1).get()) };
374374+ unsafe { k23_panic_unwind::begin_unwind(payload, regs, epc.add(1).get()) };
375375}
376376377377fn handle_recursive_fault(frame: &TrapFrame, epc: VirtualAddress) -> ! {
378378- let mut regs = unwind2::Registers {
378378+ let mut regs = k23_unwind::Registers {
379379 gp: frame.gp,
380380 fp: frame.fp,
381381 };
···390390 // begin a panic on the original stack
391391 // Safety: we saved the register state at the beginning of the trap handler
392392 unsafe {
393393- panic_unwind2::begin_unwind(payload, regs, epc.add(1).get());
393393+ k23_panic_unwind::begin_unwind(payload, regs, epc.add(1).get());
394394 }
395395}
···2323#![feature(asm_unwind)]
24242525extern crate alloc;
2626-extern crate panic_unwind2;
2626+extern crate k23_panic_unwind;
27272828mod allocator;
2929mod arch;
···4545use core::slice;
4646use core::time::Duration;
47474848-use abort::abort;
4949-use arrayvec::ArrayVec;
5048use cfg_if::cfg_if;
4949+use k23_abort::abort;
5050+use k23_arrayvec::ArrayVec;
5151+use k23_fastrand::FastRand;
5152use kasync::executor::{Executor, Worker};
5253use kasync::time::{Instant, Ticks, Timer};
5353-use kfastrand::FastRand;
5454use kmem::{AddressRangeExt, PhysicalAddress};
5555use loader_api::{BootInfo, LoaderConfig, MemoryRegionKind};
5656use mem::frame_alloc;
···86868787#[unsafe(no_mangle)]
8888fn _start(cpuid: usize, boot_info: &'static BootInfo, boot_ticks: u64) -> ! {
8989- panic_unwind2::set_hook(|info| {
8989+ k23_panic_unwind::set_hook(|info| {
9090 tracing::error!("CPU {info}");
91919292 // FIXME 32 seems adequate for unoptimized builds where the callstack can get quite deep
···107107 // Unwinding expects at least one landing pad in the callstack, but capturing all unwinds that
108108 // bubble up to this point is also a good idea since we can perform some last cleanup and
109109 // print an error message.
110110- let res = panic_unwind2::catch_unwind(|| {
110110+ let res = k23_panic_unwind::catch_unwind(|| {
111111 backtrace::__rust_begin_short_backtrace(|| kmain(cpuid, boot_info, boot_ticks));
112112 });
113113
+1-1
kernel/src/mem/address_space.rs
···714714 fn drop(&mut self) {
715715 if !self.actions.is_empty() {
716716 tracing::error!("batch was not flushed before dropping");
717717- // panic_unwind::panic_in_drop!("batch was not flushed before dropping");
717717+ // k23_panic_unwind::panic_in_drop!("batch was not flushed before dropping");
718718 }
719719 }
720720}
···55// http://opensource.org/licenses/MIT>, at your option. This file may not be
66// copied, modified, or distributed except according to those terms.
7788+use k23_spin::LazyLock;
89use log::Record;
99-use spin::LazyLock;
1010use tracing::field;
1111use tracing_core::{Callsite, Collect, Event, Kind, Level, Metadata, dispatch, identify_callsite};
1212
···140140141141#[cfg(test)]
142142mod tests {
143143- use kfastrand::FastRand;
143143+ use k23_fastrand::FastRand;
144144 use tracing_subscriber::EnvFilter;
145145 use tracing_subscriber::fmt::format::FmtSpan;
146146
···11-# ksharded-slab
22-33-This is a vendored copy of [hawkw/sharded-slab](https://github.com/hawkw/sharded-slab) made to be compatible with k23.
44-You should not use this, it is strictly worse than the original.
···11// This module exists only to provide a separate page for the implementation
22// documentation.
3344-//! Notes on `sharded-slab`'s implementation and design.
44+//! Notes on `k23-sharded-slab`'s implementation and design.
55//!
66//! # Design
77//!
···135135//! INITIAL_PAGE_SIZE.trailing_zeros() + 1;
136136//! ```
137137//!
138138-//! [`MAX_THREADS`]: https://docs.rs/sharded-slab/latest/sharded_slab/trait.Config.html#associatedconstant.MAX_THREADS
138138+//! [`MAX_THREADS`]: https://docs.rs/k23-sharded-slab/latest/sharded_slab/trait.Config.html#associatedconstant.MAX_THREADS
···949949 shard.clear_after_release(self.key);
950950 } else {
951951 log::trace!("-> shard={:?} does not exist! THIS IS A BUG", shard_idx);
952952- // debug_assert!(panic_unwind::panicking(), "[internal error] tried to drop an `OwnedRef` to a slot on a shard that never existed!");
952952+ // debug_assert!(k23_panic_unwind::panicking(), "[internal error] tried to drop an `OwnedRef` to a slot on a shard that never existed!");
953953 }
954954 }
955955 }
···10771077 shard.clear_after_release(self.key);
10781078 } else {
10791079 log::trace!("-> shard does not exist! THIS IS A BUG");
10801080- // debug_assert!(panic_unwind::panicking(), "[internal error] tried to drop an `OwnedRefMut` to a slot on a shard that never existed!");
10801080+ // debug_assert!(k23_panic_unwind::panicking(), "[internal error] tried to drop an `OwnedRefMut` to a slot on a shard that never existed!");
10811081 }
10821082 }
10831083 }
···2525use core::panic::{PanicPayload, UnwindSafe};
2626use core::{fmt, mem};
27272828-use abort::abort;
2928pub use hook::{set_hook, take_hook};
2929+use k23_abort::abort;
30303131use crate::hook::{HOOK, Hook, PanicHookInfo, default_hook};
3232use crate::panic_count::MustAbort;
···4646where
4747 F: FnOnce() -> R + UnwindSafe,
4848{
4949- unwind2::catch_unwind(f).inspect_err(|_| {
4949+ k23_unwind::catch_unwind(f).inspect_err(|_| {
5050 panic_count::decrease(); // decrease the panic count, since we caught it
5151 })
5252}
···5454/// Resume an unwind previously caught with [`catch_unwind`].
5555pub fn resume_unwind(payload: Box<dyn Any + Send>) -> ! {
5656 debug_assert!(panic_count::increase(false).is_none());
5757- unwind2::with_context(|regs, pc| rust_panic(payload, regs.clone(), pc))
5757+ k23_unwind::with_context(|regs, pc| rust_panic(payload, regs.clone(), pc))
5858}
59596060/// Begin unwinding from an externally captured set of registers (such as from a trap handler).
···6363///
6464/// This will start walking the stack and calling `Drop` implementations starting the the `pc` and
6565/// register set you provided. Be VERY careful that it is actually correctly captured.
6666-pub unsafe fn begin_unwind(payload: Box<dyn Any + Send>, regs: unwind2::Registers, pc: usize) -> ! {
6666+pub unsafe fn begin_unwind(
6767+ payload: Box<dyn Any + Send>,
6868+ regs: k23_unwind::Registers,
6969+ pc: usize,
7070+) -> ! {
6771 debug_assert!(panic_count::increase(false).is_none());
6872 rust_panic(payload, regs, pc)
6973}
···104108 abort();
105109 }
106110107107- unwind2::with_context(|regs, pc| rust_panic(payload, regs.clone(), pc))
111111+ k23_unwind::with_context(|regs, pc| rust_panic(payload, regs.clone(), pc))
108112}
109113110114/// Mirroring std, this is an unmangled function on which to slap
111115/// yer breakpoints for backtracing panics.
112116#[inline(never)]
113117#[unsafe(no_mangle)]
114114-fn rust_panic(payload: Box<dyn Any + Send>, regs: unwind2::Registers, pc: usize) -> ! {
118118+fn rust_panic(payload: Box<dyn Any + Send>, regs: k23_unwind::Registers, pc: usize) -> ! {
115119 // Safety: `begin_unwind` will either return an error or not return at all
116116- match unsafe { unwind2::begin_unwind_with(payload, regs, pc).unwrap_err_unchecked() } {
117117- unwind2::Error::EndOfStack => {
120120+ match unsafe { k23_unwind::begin_unwind_with(payload, regs, pc).unwrap_err_unchecked() } {
121121+ k23_unwind::Error::EndOfStack => {
118122 tracing::error!(
119123 "unwinding completed without finding a `catch_unwind` make sure there is at least a root level catch unwind wrapping the main function. aborting."
120124 );
···88use core::cell::Cell;
99use core::sync::atomic::{AtomicUsize, Ordering};
10101111-use cpu_local::cpu_local;
1111+use k23_cpu_local::cpu_local;
12121313/// A reason for forcing an immediate abort on panic.
1414#[derive(Debug)]
···11+# k23-sharded-slab
22+33+This is a vendored copy of [hawkw/k23-sharded-slab](https://github.com/hawkw/k23-sharded-slab) made to be compatible with k23.
44+You should not use this, it is strictly worse than the original.
···55// http://opensource.org/licenses/MIT>, at your option. This file may not be
66// copied, modified, or distributed except according to those terms.
7788-use util::loom_const_fn;
88+use k32_util::loom_const_fn;
991010use crate::{Backoff, Mutex};
1111
···275275276276/// An iterator over frames on the stack.
277277///
278278-/// This is the primary means for walking the stack in `unwind2`.
278278+/// This is the primary means for walking the stack in `k23_unwind`.
279279///
280280/// ```rust
281281-/// # use unwind2::FrameIter;
281281+/// # use k23_unwind::FrameIter;
282282/// use fallible_iterator::FallibleIterator;
283283///
284284/// let mut frames = FrameIter::new(); // start the stack walking at the current frame
···291291/// You can also construct a `FrameIter` from the raw register context and instruction pointer:
292292///
293293/// ```rust
294294-/// # use unwind2::FrameIter;
294294+/// # use k23_unwind::FrameIter;
295295/// use fallible_iterator::FallibleIterator;
296296///
297297/// // in a real scenario you would obtain these values from e.g. a signal/trap handler
298298-/// let regs = unwind2::Registers {gp: [0; 32],fp: [0; 32]};
298298+/// let regs = k23_unwind::Registers {gp: [0; 32],fp: [0; 32]};
299299/// let ip = 0;
300300///
301301/// let mut frames = FrameIter::from_registers(regs, ip);
···55// http://opensource.org/licenses/MIT>, at your option. This file may not be
66// copied, modified, or distributed except according to those terms.
7788-use abort::abort;
88+use k23_abort::abort;
991010use crate::exception::Exception;
1111use crate::utils::with_context;
···13131414/// In traditional unwinders the personality routine is responsible for determining the unwinders
1515/// behaviour for each frame (stop unwinding because a handler has been found, continue etc.)
1616-/// Since `unwind2` only cares about Rust code, the personality routine here is just a stub to make
1616+/// Since `k23_unwind` only cares about Rust code, the personality routine here is just a stub to make
1717/// the compiler happy and ensure we're not unwinding across language boundaries. The real unwinding
1818/// happens in [`raise_exception_phase2`].
1919#[lang = "eh_personality"]
+4-4
libs/unwind2/src/lib.rs
libs/unwind/src/lib.rs
···2828use core::panic::UnwindSafe;
2929use core::ptr::addr_of_mut;
30303131-use abort::abort;
3231pub use arch::Registers;
3332use eh_action::{EHAction, find_eh_action};
3433pub use eh_info::EhInfo;
···3635use exception::Exception;
3736use fallible_iterator::FallibleIterator;
3837pub use frame::{Frame, FrameIter};
3838+use k23_abort::abort;
3939use lang_items::ensure_rust_personality_routine;
4040pub use utils::with_context;
4141···100100///
101101/// Note that the traditional unwinding process has 2 phases, the first where the landing pad is discovered
102102/// and the second where the stack is actually unwound up to that landing pad.
103103-/// In `unwind2` we can get away with one phase because we bypass the language personality routine:
103103+/// In `k23_unwind` we can get away with one phase because we bypass the language personality routine:
104104/// Traditional unwinders call the personality routine on each frame to discover a landing pad, and
105105/// then during cleanup call the personality routine again to determine if control should actually be
106106/// transferred. This is done so that languages have maximum flexibility in how they treat exceptions.
107107///
108108-/// `unwind2` - being Rust-only - doesn't need that flexibility since Rust landing pads are called
109109-/// unconditionally. Furthermore, `unwind2` never actually calls the personality routine, instead
108108+/// `k23_unwind` - being Rust-only - doesn't need that flexibility since Rust landing pads are called
109109+/// unconditionally. Furthermore, `k23_unwind` never actually calls the personality routine, instead
110110/// parsing the [`EHAction`] for each frame directly.
111111///
112112/// The name `raise_exception_phase2` is kept though to make it easier to understand what this function
···55// http://opensource.org/licenses/MIT>, at your option. This file may not be
66// copied, modified, or distributed except according to those terms.
7788-use abort::abort;
88+use k23_abort::abort;
991010use crate::arch;
1111