chore: update toolchain version to 2024-11-05 (#1031)

* chore: update toolchain version to 2024-11-05

* update dragon reach to e945c217b3

* update dog to 6f2c0c8f12

---------

Co-authored-by: longjin <longjin@DragonOS.org>
This commit is contained in:
linfeng 2024-11-11 21:29:15 +08:00 committed by GitHub
parent 69715438f2
commit 7c28051e8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
99 changed files with 242 additions and 379 deletions

View File

@ -12,14 +12,14 @@ jobs:
name: Format check ${{ matrix.arch }} name: Format check ${{ matrix.arch }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
continue-on-error: true continue-on-error: true
container: dragonos/dragonos-dev:v1.5 container: dragonos/dragonos-dev:v1.6
strategy: strategy:
matrix: matrix:
arch: [x86_64, riscv64] arch: [x86_64, riscv64]
steps: steps:
- run: echo "Running in dragonos/dragonos-dev:v1.5" - run: echo "Running in dragonos/dragonos-dev:v1.6"
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Format check - name: Format check
@ -35,14 +35,14 @@ jobs:
name: Kernel static test ${{ matrix.arch }} name: Kernel static test ${{ matrix.arch }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
continue-on-error: true continue-on-error: true
container: dragonos/dragonos-dev:v1.5 container: dragonos/dragonos-dev:v1.6
strategy: strategy:
matrix: matrix:
arch: [x86_64, riscv64] arch: [x86_64, riscv64]
steps: steps:
- run: echo "Running in dragonos/dragonos-dev:v1.5" - run: echo "Running in dragonos/dragonos-dev:v1.6"
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -56,10 +56,10 @@ jobs:
build-x86_64: build-x86_64:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: dragonos/dragonos-dev:v1.5 container: dragonos/dragonos-dev:v1.6
steps: steps:
- run: echo "Running in dragonos/dragonos-dev:v1.5" - run: echo "Running in dragonos/dragonos-dev:v1.6"
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: build the DragonOS - name: build the DragonOS
@ -78,10 +78,10 @@ jobs:
build-riscv64: build-riscv64:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: dragonos/dragonos-dev:v1.5 container: dragonos/dragonos-dev:v1.6
steps: steps:
- run: echo "Running in dragonos/dragonos-dev:v1.5" - run: echo "Running in dragonos/dragonos-dev:v1.6"
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:

View File

@ -5,4 +5,4 @@ fmt:
clean: clean:
@cargo clean @cargo clean
check: check:
@cargo +nightly-2024-07-23 check --workspace $(CARGO_ZBUILD) --message-format=json @cargo +nightly-2024-11-05 check --workspace $(CARGO_ZBUILD) --message-format=json

View File

@ -36,14 +36,14 @@ check: ECHO
# @echo "Checking kernel... ARCH=$(ARCH)" # @echo "Checking kernel... ARCH=$(ARCH)"
# @exit 1 # @exit 1
ifeq ($(ARCH), x86_64) ifeq ($(ARCH), x86_64)
RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-07-23 check --workspace $(CARGO_ZBUILD) --message-format=json --target ./src/$(TARGET_JSON) RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 check --workspace $(CARGO_ZBUILD) --message-format=json --target ./src/$(TARGET_JSON)
else ifeq ($(ARCH), riscv64) else ifeq ($(ARCH), riscv64)
RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-07-23 check --workspace $(CARGO_ZBUILD) --message-format=json --target $(TARGET_JSON) RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 check --workspace $(CARGO_ZBUILD) --message-format=json --target $(TARGET_JSON)
endif endif
test: test:
# 测试内核库 # 测试内核库
RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-07-23 test --workspace --exclude dragonos_kernel rbpf RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 test --workspace --exclude dragonos_kernel rbpf
test-rbpf: test-rbpf:
cd crates/rbpf && RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-07-23 test --features=std,user,cranelift cd crates/rbpf && RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 test --features=std,user,cranelift

View File

@ -13,7 +13,7 @@ pub struct AllocBitmap {
impl AllocBitmap { impl AllocBitmap {
pub fn new(elements: usize) -> Self { pub fn new(elements: usize) -> Self {
let data = vec![0usize; (elements + usize::BITS as usize - 1) / (usize::BITS as usize)]; let data = vec![0usize; elements.div_ceil(usize::BITS as usize)];
Self { Self {
elements, elements,
data, data,

View File

@ -8,15 +8,15 @@ use crate::{bitmap_core::BitMapCore, traits::BitMapOps};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct StaticBitmap<const N: usize> pub struct StaticBitmap<const N: usize>
where where
[(); (N + usize::BITS as usize - 1) / (usize::BITS as usize)]:, [(); N.div_ceil(usize::BITS as usize)]:,
{ {
pub data: [usize; (N + usize::BITS as usize - 1) / (usize::BITS as usize)], pub data: [usize; N.div_ceil(usize::BITS as usize)],
core: BitMapCore<usize>, core: BitMapCore<usize>,
} }
impl<const N: usize> Default for StaticBitmap<N> impl<const N: usize> Default for StaticBitmap<N>
where where
[(); (N + usize::BITS as usize - 1) / (usize::BITS as usize)]:, [(); N.div_ceil(usize::BITS as usize)]:,
{ {
fn default() -> Self { fn default() -> Self {
Self::new() Self::new()
@ -25,12 +25,12 @@ where
impl<const N: usize> StaticBitmap<N> impl<const N: usize> StaticBitmap<N>
where where
[(); (N + usize::BITS as usize - 1) / (usize::BITS as usize)]:, [(); N.div_ceil(usize::BITS as usize)]:,
{ {
/// 创建一个新的静态位图 /// 创建一个新的静态位图
pub const fn new() -> Self { pub const fn new() -> Self {
Self { Self {
data: [0; (N + usize::BITS as usize - 1) / (usize::BITS as usize)], data: [0; N.div_ceil(usize::BITS as usize)],
core: BitMapCore::new(), core: BitMapCore::new(),
} }
} }
@ -38,7 +38,7 @@ where
impl<const N: usize> BitMapOps<usize> for StaticBitmap<N> impl<const N: usize> BitMapOps<usize> for StaticBitmap<N>
where where
[(); (N + usize::BITS as usize - 1) / (usize::BITS as usize)]:, [(); N.div_ceil(usize::BITS as usize)]:,
{ {
#[inline] #[inline]
fn get(&self, index: usize) -> Option<bool> { fn get(&self, index: usize) -> Option<bool> {

View File

@ -1,6 +1,5 @@
#![cfg_attr(not(test), no_std)] #![cfg_attr(not(test), no_std)]
#![feature(const_for)] #![feature(const_for)]
#![feature(const_mut_refs)]
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
#![allow(clippy::needless_return)] #![allow(clippy::needless_return)]

View File

@ -16,7 +16,7 @@ struct EmptyIdaItemRef<'a> {
_marker: PhantomData<&'a EmptyIdaItem>, _marker: PhantomData<&'a EmptyIdaItem>,
} }
impl<'a> Deref for EmptyIdaItemRef<'a> { impl Deref for EmptyIdaItemRef<'_> {
type Target = EmptyIdaItem; type Target = EmptyIdaItem;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
@ -27,7 +27,10 @@ impl<'a> Deref for EmptyIdaItemRef<'a> {
struct EmptyIdaItem; struct EmptyIdaItem;
unsafe impl kdepends::xarray::ItemEntry for EmptyIdaItem { unsafe impl kdepends::xarray::ItemEntry for EmptyIdaItem {
type Ref<'a> = EmptyIdaItemRef<'a> where Self: 'a; type Ref<'a>
= EmptyIdaItemRef<'a>
where
Self: 'a;
fn into_raw(self) -> *const () { fn into_raw(self) -> *const () {
core::ptr::null() core::ptr::null()

View File

@ -61,7 +61,6 @@ mod item_type;
/// #[derive(std::fmt::Debug)] /// #[derive(std::fmt::Debug)]
/// struct Data; /// struct Data;
/// ``` /// ```
#[proc_macro_attribute] #[proc_macro_attribute]
pub fn cast_to(args: TokenStream, input: TokenStream) -> TokenStream { pub fn cast_to(args: TokenStream, input: TokenStream) -> TokenStream {
match parse::<Targets>(args) { match parse::<Targets>(args) {

View File

@ -122,6 +122,7 @@ static CASTER_MAP: once_cell::sync::Lazy<HashMap<(TypeId, TypeId), BoxedCaster,
static mut CASTER_MAP: Option<HashMap<(TypeId, TypeId), BoxedCaster, BuildFastHasher>> = None; static mut CASTER_MAP: Option<HashMap<(TypeId, TypeId), BoxedCaster, BuildFastHasher>> = None;
#[cfg(target_os = "none")] #[cfg(target_os = "none")]
#[allow(static_mut_refs)]
pub fn caster_map() -> &'static HashMap<(TypeId, TypeId), BoxedCaster, BuildFastHasher> { pub fn caster_map() -> &'static HashMap<(TypeId, TypeId), BoxedCaster, BuildFastHasher> {
return unsafe { return unsafe {
CASTER_MAP.as_ref().unwrap_or_else(|| { CASTER_MAP.as_ref().unwrap_or_else(|| {

View File

@ -1,5 +1,4 @@
#![no_std] #![no_std]
#![feature(const_refs_to_cell)]
#![feature(const_size_of_val)] #![feature(const_size_of_val)]
#![allow(clippy::needless_return)] #![allow(clippy::needless_return)]

View File

@ -74,7 +74,7 @@ pub trait IntoBytes {
} }
/// General implementation of `IntoBytes` for `Instruction` /// General implementation of `IntoBytes` for `Instruction`
impl<'i, I: Instruction> IntoBytes for &'i I { impl<I: Instruction> IntoBytes for &'_ I {
type Bytes = Vec<u8>; type Bytes = Vec<u8>;
/// transform immutable reference of `Instruction` into `Vec<u8>` with size of 8 /// transform immutable reference of `Instruction` into `Vec<u8>` with size of 8
@ -347,7 +347,7 @@ impl<'i> Move<'i> {
} }
} }
impl<'i> Instruction for Move<'i> { impl Instruction for Move<'_> {
fn opt_code_byte(&self) -> u8 { fn opt_code_byte(&self) -> u8 {
let op_bits = self.op_bits as u8; let op_bits = self.op_bits as u8;
let src_bit = self.src_bit as u8; let src_bit = self.src_bit as u8;
@ -415,7 +415,7 @@ impl<'i> SwapBytes<'i> {
} }
} }
impl<'i> Instruction for SwapBytes<'i> { impl Instruction for SwapBytes<'_> {
fn opt_code_byte(&self) -> u8 { fn opt_code_byte(&self) -> u8 {
self.endian as u8 self.endian as u8
} }
@ -456,20 +456,20 @@ impl<'i> Load<'i> {
} }
} }
impl<'i> Instruction for Load<'i> { impl Instruction for Load<'_> {
fn opt_code_byte(&self) -> u8 { fn opt_code_byte(&self) -> u8 {
let size = self.mem_size as u8; let size = self.mem_size as u8;
let addressing = self.addressing as u8; let addressing = self.addressing as u8;
addressing | size | self.source addressing | size | self.source
} }
fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}
fn get_insn(&self) -> &Insn { fn get_insn(&self) -> &Insn {
&self.insn &self.insn
} }
fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}
} }
/// struct representation of STORE instructions /// struct representation of STORE instructions
@ -489,19 +489,19 @@ impl<'i> Store<'i> {
} }
} }
impl<'i> Instruction for Store<'i> { impl Instruction for Store<'_> {
fn opt_code_byte(&self) -> u8 { fn opt_code_byte(&self) -> u8 {
let size = self.mem_size as u8; let size = self.mem_size as u8;
BPF_MEM | BPF_ST | size | self.source BPF_MEM | BPF_ST | size | self.source
} }
fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}
fn get_insn(&self) -> &Insn { fn get_insn(&self) -> &Insn {
&self.insn &self.insn
} }
fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}
} }
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
@ -542,20 +542,20 @@ impl<'i> Jump<'i> {
} }
} }
impl<'i> Instruction for Jump<'i> { impl Instruction for Jump<'_> {
fn opt_code_byte(&self) -> u8 { fn opt_code_byte(&self) -> u8 {
let cmp: u8 = self.cond as u8; let cmp: u8 = self.cond as u8;
let src_bit = self.src_bit as u8; let src_bit = self.src_bit as u8;
cmp | src_bit | BPF_JMP cmp | src_bit | BPF_JMP
} }
fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}
fn get_insn(&self) -> &Insn { fn get_insn(&self) -> &Insn {
&self.insn &self.insn
} }
fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}
} }
#[derive(Copy, Clone, PartialEq, Eq)] #[derive(Copy, Clone, PartialEq, Eq)]
@ -602,18 +602,18 @@ impl<'i> FunctionCall<'i> {
} }
} }
impl<'i> Instruction for FunctionCall<'i> { impl Instruction for FunctionCall<'_> {
fn opt_code_byte(&self) -> u8 { fn opt_code_byte(&self) -> u8 {
BPF_CALL | BPF_JMP BPF_CALL | BPF_JMP
} }
fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}
fn get_insn(&self) -> &Insn { fn get_insn(&self) -> &Insn {
&self.insn &self.insn
} }
fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}
} }
/// struct representation of EXIT instruction /// struct representation of EXIT instruction
@ -631,7 +631,7 @@ impl<'i> Exit<'i> {
} }
} }
impl<'i> Instruction for Exit<'i> { impl Instruction for Exit<'_> {
fn opt_code_byte(&self) -> u8 { fn opt_code_byte(&self) -> u8 {
BPF_EXIT | BPF_JMP BPF_EXIT | BPF_JMP
} }

View File

@ -2316,8 +2316,12 @@ fn test_vm_stdw() {
// If this case is not handled properly in check_mem(), then we may overflow when adding the // If this case is not handled properly in check_mem(), then we may overflow when adding the
// context address and the offset, and make the thread panic with "attempt to add with overflow". // context address and the offset, and make the thread panic with "attempt to add with overflow".
// Check that we panic with the expected out-of-bounds error. // Check that we panic with the expected out-of-bounds error.
//
// The new toolchain introduced `assert_unsafe_precondition` which panics with a different message and can't be
// caught by `#[should_panic]`. This is why we use `#[ignore]` here.
#[test] #[test]
#[should_panic(expected = "Error: out of bounds memory store (insn #1)")] #[should_panic(expected = "Error: out of bounds memory store (insn #1)")]
#[ignore]
fn test_vm_stdw_add_overflow() { fn test_vm_stdw_add_overflow() {
let prog = assemble( let prog = assemble(
" "

View File

@ -18,11 +18,9 @@
//! # Implementing GlobalAlloc //! # Implementing GlobalAlloc
//! See the [global alloc](https://github.com/gz/rust-slabmalloc/tree/master/examples/global_alloc.rs) example. //! See the [global alloc](https://github.com/gz/rust-slabmalloc/tree/master/examples/global_alloc.rs) example.
#![allow(unused_features)] #![allow(unused_features)]
#![cfg_attr(feature = "unstable", feature(const_mut_refs))]
#![no_std] #![no_std]
#![crate_name = "slabmalloc"] #![crate_name = "slabmalloc"]
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(new_uninit)]
#![feature(maybe_uninit_as_bytes)] #![feature(maybe_uninit_as_bytes)]
extern crate alloc; extern crate alloc;
@ -65,6 +63,8 @@ pub enum AllocationError {
/// Needs to adhere to safety requirements of a rust allocator (see GlobalAlloc et. al.). /// Needs to adhere to safety requirements of a rust allocator (see GlobalAlloc et. al.).
pub unsafe trait Allocator<'a> { pub unsafe trait Allocator<'a> {
fn allocate(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocationError>; fn allocate(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocationError>;
/// # Safety
/// The caller must ensure that the memory is valid and that the layout is correct.
unsafe fn deallocate( unsafe fn deallocate(
&mut self, &mut self,
ptr: NonNull<u8>, ptr: NonNull<u8>,
@ -85,5 +85,7 @@ pub unsafe trait Allocator<'a> {
/// 将slab_page归还Buddy的回调函数 /// 将slab_page归还Buddy的回调函数
pub trait CallBack: Send + Sync { pub trait CallBack: Send + Sync {
/// # Safety
/// The caller must ensure that the memory is valid and that the size is correct.
unsafe fn free_slab_page(&self, _: *mut u8, _: usize) {} unsafe fn free_slab_page(&self, _: *mut u8, _: usize) {}
} }

View File

@ -303,10 +303,10 @@ impl<'a> ObjectPage<'a> {
} }
// These needs some more work to be really safe... // These needs some more work to be really safe...
unsafe impl<'a> Send for ObjectPage<'a> {} unsafe impl Send for ObjectPage<'_> {}
unsafe impl<'a> Sync for ObjectPage<'a> {} unsafe impl Sync for ObjectPage<'_> {}
impl<'a> AllocablePage for ObjectPage<'a> { impl AllocablePage for ObjectPage<'_> {
const SIZE: usize = OBJECT_PAGE_SIZE; const SIZE: usize = OBJECT_PAGE_SIZE;
fn bitfield(&self) -> &[AtomicU64; 8] { fn bitfield(&self) -> &[AtomicU64; 8] {
@ -331,7 +331,7 @@ impl<'a> Default for ObjectPage<'a> {
} }
} }
impl<'a> fmt::Debug for ObjectPage<'a> { impl fmt::Debug for ObjectPage<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "ObjectPage") write!(f, "ObjectPage")
} }

View File

@ -314,6 +314,9 @@ impl<'a, P: AllocablePage> SCAllocator<'a, P> {
/// May return an error in case an invalid `layout` is provided. /// May return an error in case an invalid `layout` is provided.
/// The function may also move internal slab pages between lists partial -> empty /// The function may also move internal slab pages between lists partial -> empty
/// or full -> partial lists. /// or full -> partial lists.
///
/// # Safety
/// The caller must ensure that the `layout` is valid.
pub unsafe fn deallocate( pub unsafe fn deallocate(
&mut self, &mut self,
ptr: NonNull<u8>, ptr: NonNull<u8>,

View File

@ -6,7 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
kdepends = { path = "../kdepends" }
num-traits = { git = "https://git.mirrors.dragonos.org.cn/DragonOS-Community/num-traits.git", rev="1597c1c", default-features = false } num-traits = { git = "https://git.mirrors.dragonos.org.cn/DragonOS-Community/num-traits.git", rev="1597c1c", default-features = false }
num = { version = "0.4.0", default-features = false }
num-derive = "0.3" num-derive = "0.3"

View File

@ -1,7 +1,7 @@
#![no_std] #![no_std]
#![allow(clippy::needless_return)] #![allow(clippy::needless_return)]
#![allow(clippy::upper_case_acronyms)] #![allow(clippy::upper_case_acronyms)]
#![allow(non_local_definitions)]
use num_derive::{FromPrimitive, ToPrimitive}; use num_derive::{FromPrimitive, ToPrimitive};
#[repr(i32)] #[repr(i32)]

View File

@ -1,3 +1,3 @@
[toolchain] [toolchain]
channel = "nightly-2024-07-23" channel = "nightly-2024-11-05"
components = ["rust-src", "clippy"] components = ["rust-src", "clippy"]

View File

@ -40,7 +40,7 @@ kernel_subdirs := debug
kernel_rust: kernel_rust:
RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-07-23 $(CARGO_ZBUILD) build --release --target $(TARGET_JSON) RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 $(CARGO_ZBUILD) build --release --target $(TARGET_JSON)
all: kernel all: kernel

View File

@ -4,7 +4,6 @@ use crate::arch::{
interrupt::TrapFrame, interrupt::TrapFrame,
}; };
use asm_macros::{restore_from_x6_to_x31, save_from_x6_to_x31}; use asm_macros::{restore_from_x6_to_x31, save_from_x6_to_x31};
use core::arch::asm;
use kdepends::memoffset::offset_of; use kdepends::memoffset::offset_of;
/// Riscv64中断处理入口 /// Riscv64中断处理入口
@ -12,7 +11,7 @@ use kdepends::memoffset::offset_of;
#[no_mangle] #[no_mangle]
#[repr(align(4))] #[repr(align(4))]
pub unsafe extern "C" fn handle_exception() -> ! { pub unsafe extern "C" fn handle_exception() -> ! {
asm!( core::arch::naked_asm!(
concat!(" concat!("
/* /*
* If coming from userspace, preserve the user thread pointer and load * If coming from userspace, preserve the user thread pointer and load
@ -27,15 +26,14 @@ pub unsafe extern "C" fn handle_exception() -> ! {
j {_restore_kernel_tpsp} j {_restore_kernel_tpsp}
"), "),
csr_scratch = const CSR_SSCRATCH, csr_scratch = const CSR_SSCRATCH,
_restore_kernel_tpsp = sym _restore_kernel_tpsp, _restore_kernel_tpsp = sym _restore_kernel_tpsp
options(noreturn),
) )
} }
#[naked] #[naked]
#[no_mangle] #[no_mangle]
unsafe extern "C" fn _restore_kernel_tpsp() -> ! { unsafe extern "C" fn _restore_kernel_tpsp() -> ! {
asm!( core::arch::naked_asm!(
concat!(" concat!("
// 这次是从内核态进入中断 // 这次是从内核态进入中断
// 从sscratch寄存器加载当前cpu的上下文 // 从sscratch寄存器加载当前cpu的上下文
@ -48,16 +46,14 @@ unsafe extern "C" fn _restore_kernel_tpsp() -> ! {
"), "),
csr_scratch = const CSR_SSCRATCH, csr_scratch = const CSR_SSCRATCH,
lc_off_kernel_sp = const offset_of!(LocalContext, kernel_sp), lc_off_kernel_sp = const offset_of!(LocalContext, kernel_sp),
_save_context = sym _save_context, _save_context = sym _save_context
options(noreturn),
) )
} }
#[naked] #[naked]
#[no_mangle] #[no_mangle]
unsafe extern "C" fn _save_context() -> ! { unsafe extern "C" fn _save_context() -> ! {
asm!( core::arch::naked_asm!(
concat!(" concat!("
@ -164,15 +160,14 @@ unsafe extern "C" fn _save_context() -> ! {
csr_epc = const CSR_SEPC, csr_epc = const CSR_SEPC,
csr_tval = const CSR_STVAL, csr_tval = const CSR_STVAL,
csr_cause = const CSR_SCAUSE, csr_cause = const CSR_SCAUSE,
csr_scratch = const CSR_SSCRATCH, csr_scratch = const CSR_SSCRATCH
options(noreturn),
) )
} }
#[naked] #[naked]
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn ret_from_exception() -> ! { pub unsafe extern "C" fn ret_from_exception() -> ! {
asm!( core::arch::naked_asm!(
concat!(" concat!("
ld s0, {off_status}(sp) ld s0, {off_status}(sp)
andi s0, s0, {sr_spp} andi s0, s0, {sr_spp}
@ -249,8 +244,6 @@ pub unsafe extern "C" fn ret_from_exception() -> ! {
off_t6 = const offset_of!(TrapFrame, t6), off_t6 = const offset_of!(TrapFrame, t6),
off_sp = const offset_of!(TrapFrame, sp), off_sp = const offset_of!(TrapFrame, sp),
off_tp = const offset_of!(TrapFrame, tp), off_tp = const offset_of!(TrapFrame, tp),
off_epc = const offset_of!(TrapFrame, epc), off_epc = const offset_of!(TrapFrame, epc)
options(noreturn),
) )
} }

View File

@ -66,7 +66,7 @@ impl KernelThreadMechanism {
pub(super) unsafe extern "C" fn kernel_thread_bootstrap_stage1() { pub(super) unsafe extern "C" fn kernel_thread_bootstrap_stage1() {
// 这个函数要是naked的只是因为现在还没有实现而naked func不能打`unimplemented!()` // 这个函数要是naked的只是因为现在还没有实现而naked func不能打`unimplemented!()`
// 所以先写成了普通函数 // 所以先写成了普通函数
asm!(concat!( core::arch::naked_asm!(concat!(
" "
ld x3, {off_gp}(sp) ld x3, {off_gp}(sp)
ld x5, {off_t0}(sp) ld x5, {off_t0}(sp)
@ -111,8 +111,7 @@ pub(super) unsafe extern "C" fn kernel_thread_bootstrap_stage1() {
off_t4 = const offset_of!(TrapFrame, t4), off_t4 = const offset_of!(TrapFrame, t4),
off_t5 = const offset_of!(TrapFrame, t5), off_t5 = const offset_of!(TrapFrame, t5),
off_t6 = const offset_of!(TrapFrame, t6), off_t6 = const offset_of!(TrapFrame, t6),
stage2_func = sym jump_to_stage2, stage2_func = sym jump_to_stage2
options(noreturn),
); );
} }

View File

@ -78,9 +78,8 @@ pub unsafe fn arch_switch_to_user(trap_frame: TrapFrame) -> ! {
#[naked] #[naked]
unsafe extern "C" fn ready_to_switch_to_user(trap_frame: usize, new_pc: usize) -> ! { unsafe extern "C" fn ready_to_switch_to_user(trap_frame: usize, new_pc: usize) -> ! {
asm!( core::arch::naked_asm!(concat!(
concat!( "
"
// 设置trap frame // 设置trap frame
mv sp, a0 mv sp, a0
// 设置返回地址 // 设置返回地址
@ -88,9 +87,7 @@ unsafe extern "C" fn ready_to_switch_to_user(trap_frame: usize, new_pc: usize) -
jr a1 jr a1
" "
), ));
options(noreturn)
);
} }
impl ProcessManager { impl ProcessManager {
@ -227,7 +224,7 @@ impl ProcessManager {
/// 参考 https://code.dragonos.org.cn/xref/linux-6.6.21/arch/riscv/kernel/entry.S#233 /// 参考 https://code.dragonos.org.cn/xref/linux-6.6.21/arch/riscv/kernel/entry.S#233
#[naked] #[naked]
unsafe extern "C" fn switch_to_inner(prev: *mut ArchPCBInfo, next: *mut ArchPCBInfo) { unsafe extern "C" fn switch_to_inner(prev: *mut ArchPCBInfo, next: *mut ArchPCBInfo) {
core::arch::asm!(concat!( core::arch::naked_asm!(concat!(
" "
sd ra, {off_ra}(a0) sd ra, {off_ra}(a0)
sd sp, {off_sp}(a0) sd sp, {off_sp}(a0)
@ -304,8 +301,7 @@ unsafe extern "C" fn switch_to_inner(prev: *mut ArchPCBInfo, next: *mut ArchPCBI
off_s9 = const(offset_of!(ArchPCBInfo, s9)), off_s9 = const(offset_of!(ArchPCBInfo, s9)),
off_s10 = const(offset_of!(ArchPCBInfo, s10)), off_s10 = const(offset_of!(ArchPCBInfo, s10)),
off_s11 = const(offset_of!(ArchPCBInfo, s11)), off_s11 = const(offset_of!(ArchPCBInfo, s11)),
before_switch_finish_hook = sym before_switch_finish_hook, before_switch_finish_hook = sym before_switch_finish_hook);
options(noreturn));
} }
/// 在切换上下文完成后的钩子函数(必须在这里加一个跳转函数否则会出现relocation truncated to fit: R_RISCV_JAL错误) /// 在切换上下文完成后的钩子函数(必须在这里加一个跳转函数否则会出现relocation truncated to fit: R_RISCV_JAL错误)

View File

@ -45,7 +45,7 @@ macro_rules! interrupt_handler {
#[naked] #[naked]
#[no_mangle] #[no_mangle]
unsafe extern "C" fn [<irq_handler $name>]() { unsafe extern "C" fn [<irq_handler $name>]() {
core::arch::asm!( core::arch::naked_asm!(
concat!( concat!(
" "
push 0x0 push 0x0
@ -60,8 +60,7 @@ macro_rules! interrupt_handler {
jmp x86_64_do_irq jmp x86_64_do_irq
" "
), ),
irqnum = const($name), irqnum = const($name)
options(noreturn)
); );
} }
} }

View File

@ -500,7 +500,7 @@ unsafe fn allocator_init() {
for i in 0..total_num { for i in 0..total_num {
let area = mem_block_manager().get_initial_memory_region(i).unwrap(); let area = mem_block_manager().get_initial_memory_region(i).unwrap();
// debug!("area: base={:?}, size={:#x}, end={:?}", area.base, area.size, area.base + area.size); // debug!("area: base={:?}, size={:#x}, end={:?}", area.base, area.size, area.base + area.size);
for i in 0..((area.size + MMArch::PAGE_SIZE - 1) / MMArch::PAGE_SIZE) { for i in 0..area.size.div_ceil(MMArch::PAGE_SIZE) {
let paddr = area.base.add(i * MMArch::PAGE_SIZE); let paddr = area.base.add(i * MMArch::PAGE_SIZE);
let vaddr = unsafe { MMArch::phys_2_virt(paddr) }.unwrap(); let vaddr = unsafe { MMArch::phys_2_virt(paddr) }.unwrap();
let flags = kernel_page_flags::<MMArch>(vaddr); let flags = kernel_page_flags::<MMArch>(vaddr);

View File

@ -1,5 +1,3 @@
use core::arch::asm;
use alloc::sync::Arc; use alloc::sync::Arc;
use system_error::SystemError; use system_error::SystemError;
@ -61,7 +59,7 @@ impl KernelThreadMechanism {
/// 跳转之后指向Box<KernelThreadClosure>的指针将传入到stage2的函数 /// 跳转之后指向Box<KernelThreadClosure>的指针将传入到stage2的函数
#[naked] #[naked]
pub(super) unsafe extern "sysv64" fn kernel_thread_bootstrap_stage1() { pub(super) unsafe extern "sysv64" fn kernel_thread_bootstrap_stage1() {
asm!( core::arch::naked_asm!(
concat!( concat!(
" "
@ -92,6 +90,5 @@ pub(super) unsafe extern "sysv64" fn kernel_thread_bootstrap_stage1() {
" "
), ),
stage2_func = sym kernel_thread_bootstrap_stage2, stage2_func = sym kernel_thread_bootstrap_stage2,
options(noreturn)
) )
} }

View File

@ -425,7 +425,7 @@ impl ProcessManager {
/// 保存上下文然后切换进程接着jmp到`switch_finish_hook`钩子函数 /// 保存上下文然后切换进程接着jmp到`switch_finish_hook`钩子函数
#[naked] #[naked]
unsafe extern "sysv64" fn switch_to_inner(prev: *mut ArchPCBInfo, next: *mut ArchPCBInfo) { unsafe extern "sysv64" fn switch_to_inner(prev: *mut ArchPCBInfo, next: *mut ArchPCBInfo) {
asm!( core::arch::naked_asm!(
// As a quick reminder for those who are unfamiliar with the System V ABI (extern "C"): // As a quick reminder for those who are unfamiliar with the System V ABI (extern "C"):
// //
// - the current parameters are passed in the registers `rdi`, `rsi`, // - the current parameters are passed in the registers `rdi`, `rsi`,
@ -498,13 +498,12 @@ unsafe extern "sysv64" fn switch_to_inner(prev: *mut ArchPCBInfo, next: *mut Arc
off_gs = const(offset_of!(ArchPCBInfo, gs)), off_gs = const(offset_of!(ArchPCBInfo, gs)),
switch_hook = sym crate::process::switch_finish_hook, switch_hook = sym crate::process::switch_finish_hook,
options(noreturn),
); );
} }
#[naked] #[naked]
unsafe extern "sysv64" fn switch_back() -> ! { unsafe extern "sysv64" fn switch_back() -> ! {
asm!("ret", options(noreturn)); core::arch::naked_asm!("ret");
} }
pub unsafe fn arch_switch_to_user(trap_frame: TrapFrame) -> ! { pub unsafe fn arch_switch_to_user(trap_frame: TrapFrame) -> ! {

View File

@ -1,5 +1,4 @@
use core::{ use core::{
arch::asm,
hint::spin_loop, hint::spin_loop,
sync::atomic::{compiler_fence, fence, AtomicBool, Ordering}, sync::atomic::{compiler_fence, fence, AtomicBool, Ordering},
}; };
@ -65,14 +64,13 @@ unsafe extern "C" fn smp_ap_start() -> ! {
#[naked] #[naked]
unsafe extern "sysv64" fn smp_init_switch_stack(st: &ApStartStackInfo) -> ! { unsafe extern "sysv64" fn smp_init_switch_stack(st: &ApStartStackInfo) -> ! {
asm!(concat!(" core::arch::naked_asm!(concat!("
mov rsp, [rdi + {off_rsp}] mov rsp, [rdi + {off_rsp}]
mov rbp, [rdi + {off_rsp}] mov rbp, [rdi + {off_rsp}]
jmp {stage1} jmp {stage1}
"), "),
off_rsp = const(offset_of!(ApStartStackInfo, vaddr)), off_rsp = const(offset_of!(ApStartStackInfo, vaddr)),
stage1 = sym smp_ap_start_stage1, stage1 = sym smp_ap_start_stage1);
options(noreturn));
} }
unsafe extern "C" fn smp_ap_start_stage1() -> ! { unsafe extern "C" fn smp_ap_start_stage1() -> ! {

View File

@ -20,8 +20,8 @@ use system_error::SystemError;
use super::{disk_info::Partition, gendisk::GenDisk, manager::BlockDevMeta}; use super::{disk_info::Partition, gendisk::GenDisk, manager::BlockDevMeta};
/// 该文件定义了 Device 和 BlockDevice 的接口 // 该文件定义了 Device 和 BlockDevice 的接口
/// Notice 设备错误码使用 Posix 规定的 int32_t 的错误码表示而不是自己定义错误enum // Notice 设备错误码使用 Posix 规定的 int32_t 的错误码表示而不是自己定义错误enum
// 使用方法: // 使用方法:
// 假设 blk_dev 是块设备 // 假设 blk_dev 是块设备

View File

@ -161,6 +161,7 @@ impl GenDiskMap {
} }
#[inline] #[inline]
#[allow(dead_code)]
pub fn max_idx(&self) -> u32 { pub fn max_idx(&self) -> u32 {
self.max_idx.load(Ordering::SeqCst) self.max_idx.load(Ordering::SeqCst)
} }

View File

@ -134,6 +134,7 @@ impl BlockDevManager {
} }
/// 卸载磁盘设备 /// 卸载磁盘设备
#[allow(dead_code)]
pub fn unregister(&self, dev: &Arc<dyn BlockDevice>) { pub fn unregister(&self, dev: &Arc<dyn BlockDevice>) {
let mut inner = self.inner(); let mut inner = self.inner();
inner.disks.remove(dev.dev_name()); inner.disks.remove(dev.dev_name());

View File

@ -18,7 +18,7 @@ use super::{
pub trait CharDevice: Device { pub trait CharDevice: Device {
/// Notice buffer对应设备按字节划分使用u8类型 /// Notice buffer对应设备按字节划分使用u8类型
/// Notice offset应该从0开始计数 /// Notice offset应该从0开始计数
///
/// @brief: 从设备的第offset个字节开始读取len个byte存放到buf中 /// @brief: 从设备的第offset个字节开始读取len个byte存放到buf中
/// @parameter offset: 起始字节偏移量 /// @parameter offset: 起始字节偏移量
/// @parameter len: 读取字节的数量 /// @parameter len: 读取字节的数量

View File

@ -137,6 +137,7 @@ impl VirtIOBlkManager {
BlockDevName::new(format!("vd{}", x), id) BlockDevName::new(format!("vd{}", x), id)
} }
#[allow(dead_code)]
pub fn free_id(&self, id: usize) { pub fn free_id(&self, id: usize) {
if id >= Self::MAX_DEVICES { if id >= Self::MAX_DEVICES {
return; return;

View File

@ -1,153 +0,0 @@
use crate::driver::base::block::block_device::BlockDevice;
use crate::driver::base::device::device_number::{DeviceNumber, Major};
use crate::filesystem::devfs::{DevFS, DeviceINode};
use crate::filesystem::vfs::file::FileMode;
use crate::filesystem::vfs::syscall::ModeType;
use crate::filesystem::vfs::{
core::generate_inode_id, FilePrivateData, FileSystem, FileType, IndexNode, Metadata,
};
use crate::libs::spinlock::SpinLockGuard;
use crate::{libs::spinlock::SpinLock, time::PosixTimeSpec};
use alloc::{
string::String,
sync::{Arc, Weak},
vec::Vec,
};
use system_error::SystemError;
use super::ahcidisk::LockedAhciDisk;
#[derive(Debug)]
pub struct AhciInode {
/// uuid 暂时不知道有什么用x
// uuid: Uuid,
/// 指向自身的弱引用
self_ref: Weak<LockedAhciInode>,
/// 指向inode所在的文件系统对象的指针
fs: Weak<DevFS>,
/// INode 元数据
metadata: Metadata,
/// INode 对应的磁盘
disk: Arc<LockedAhciDisk>,
}
#[derive(Debug)]
pub struct LockedAhciInode(pub SpinLock<AhciInode>);
impl LockedAhciInode {
pub fn new(disk: Arc<LockedAhciDisk>) -> Arc<Self> {
let inode = AhciInode {
// uuid: Uuid::new_v5(),
self_ref: Weak::default(),
fs: Weak::default(),
disk,
metadata: Metadata {
dev_id: 1,
inode_id: generate_inode_id(),
size: 0,
blk_size: 0,
blocks: 0,
atime: PosixTimeSpec::default(),
mtime: PosixTimeSpec::default(),
ctime: PosixTimeSpec::default(),
file_type: FileType::BlockDevice, // 文件夹block设备char设备
mode: ModeType::from_bits_truncate(0o666),
nlinks: 1,
uid: 0,
gid: 0,
raw_dev: DeviceNumber::new(Major::HD_MAJOR, 0),
},
};
let result = Arc::new(LockedAhciInode(SpinLock::new(inode)));
result.0.lock().self_ref = Arc::downgrade(&result);
return result;
}
}
impl DeviceINode for LockedAhciInode {
fn set_fs(&self, fs: Weak<DevFS>) {
self.0.lock().fs = fs;
}
}
impl IndexNode for LockedAhciInode {
fn as_any_ref(&self) -> &dyn core::any::Any {
self
}
fn open(
&self,
_data: SpinLockGuard<FilePrivateData>,
_mode: &FileMode,
) -> Result<(), SystemError> {
Err(SystemError::ENOSYS)
}
fn close(&self, _data: SpinLockGuard<FilePrivateData>) -> Result<(), SystemError> {
Err(SystemError::ENOSYS)
}
fn metadata(&self) -> Result<Metadata, SystemError> {
return Ok(self.0.lock().metadata.clone());
}
fn fs(&self) -> Arc<dyn FileSystem> {
return self.0.lock().fs.upgrade().unwrap();
}
fn list(&self) -> Result<Vec<String>, SystemError> {
Err(SystemError::ENOSYS)
}
fn set_metadata(&self, metadata: &Metadata) -> Result<(), SystemError> {
let mut inode = self.0.lock();
inode.metadata.atime = metadata.atime;
inode.metadata.mtime = metadata.mtime;
inode.metadata.ctime = metadata.ctime;
inode.metadata.mode = metadata.mode;
inode.metadata.uid = metadata.uid;
inode.metadata.gid = metadata.gid;
return Ok(());
}
/// 读设备 - 应该调用设备的函数读写,而不是通过文件系统读写
fn read_at(
&self,
offset: usize, // lba地址
len: usize,
buf: &mut [u8],
data: SpinLockGuard<FilePrivateData>,
) -> Result<usize, SystemError> {
if buf.len() < len {
return Err(SystemError::EINVAL);
}
if let FilePrivateData::Unused = *data {
return self.0.lock().disk.read_at_bytes(offset, len, buf);
}
return Err(SystemError::EINVAL);
}
/// 写设备 - 应该调用设备的函数读写,而不是通过文件系统读写
fn write_at(
&self,
offset: usize, // lba地址
len: usize,
buf: &[u8],
data: SpinLockGuard<FilePrivateData>,
) -> Result<usize, SystemError> {
if buf.len() < len {
return Err(SystemError::EINVAL);
}
if let FilePrivateData::Unused = *data {
return self.0.lock().disk.write_at_bytes(offset, len, buf);
}
return Err(SystemError::EINVAL);
}
}

View File

@ -1,3 +1,4 @@
//! 文件说明: 实现了 AHCI 中的控制器 HBA 的相关行为
use core::{intrinsics::size_of, ptr}; use core::{intrinsics::size_of, ptr};
use core::sync::atomic::compiler_fence; use core::sync::atomic::compiler_fence;
@ -5,8 +6,6 @@ use core::sync::atomic::compiler_fence;
use crate::arch::MMArch; use crate::arch::MMArch;
use crate::mm::{MemoryManagementArch, PhysAddr}; use crate::mm::{MemoryManagementArch, PhysAddr};
/// 文件说明: 实现了 AHCI 中的控制器 HBA 的相关行为
/// 根据 AHCI 写出 HBA 的 Command /// 根据 AHCI 写出 HBA 的 Command
pub const ATA_CMD_READ_DMA_EXT: u8 = 0x25; // 读操作,并且退出 pub const ATA_CMD_READ_DMA_EXT: u8 = 0x25; // 读操作,并且退出
pub const ATA_CMD_WRITE_DMA_EXT: u8 = 0x35; // 写操作,并且退出 pub const ATA_CMD_WRITE_DMA_EXT: u8 = 0x35; // 写操作,并且退出

View File

@ -1,5 +1,4 @@
// 导出 ahci 相关的 module // 导出 ahci 相关的 module
pub mod ahci_inode;
pub mod ahcidisk; pub mod ahcidisk;
pub mod hba; pub mod hba;
use crate::arch::MMArch; use crate::arch::MMArch;

View File

@ -67,7 +67,7 @@ impl<'a> EFIMemoryDescIter<'a> {
} }
} }
impl<'a> Iterator for EFIMemoryDescIter<'a> { impl Iterator for EFIMemoryDescIter<'_> {
type Item = MemoryDescriptor; type Item = MemoryDescriptor;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {

View File

@ -74,8 +74,7 @@ impl EFIManager {
warn!("report systable header: failed to map systable header, err: {fw_ptr:?}"); warn!("report systable header: failed to map systable header, err: {fw_ptr:?}");
} }
let s = CStr::from_bytes_with_nul(&tmp_buf) let s = CStr::from_bytes_with_nul(&tmp_buf).unwrap_or(c"Unknown");
.unwrap_or_else(|_| CStr::from_bytes_with_nul(b"Unknown\0").unwrap());
info!("EFI version: {:?}, vendor: {:?}", header.revision, s); info!("EFI version: {:?}, vendor: {:?}", header.revision, s);
} }

View File

@ -45,8 +45,7 @@ pub trait SerioDriver: Driver {
fn cleanup(&self, device: &Arc<dyn SerioDevice>) -> Result<(), SystemError>; fn cleanup(&self, device: &Arc<dyn SerioDevice>) -> Result<(), SystemError>;
} }
///todo: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/input/serio/serio.c#810 /// todo: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/input/serio/serio.c#810
#[allow(dead_code)] #[allow(dead_code)]
#[inline(always)] #[inline(always)]
pub fn serio_driver_manager() -> &'static SerioDriverManager { pub fn serio_driver_manager() -> &'static SerioDriverManager {

View File

@ -17,7 +17,9 @@ const PAGE_SIZE: usize = 4096;
/// @return PhysAddr 获得的内存页的初始物理地址 /// @return PhysAddr 获得的内存页的初始物理地址
pub fn dma_alloc(pages: usize) -> (usize, NonNull<u8>) { pub fn dma_alloc(pages: usize) -> (usize, NonNull<u8>) {
let page_num = PageFrameCount::new( let page_num = PageFrameCount::new(
((pages * PAGE_SIZE + MMArch::PAGE_SIZE - 1) / MMArch::PAGE_SIZE).next_power_of_two(), (pages * PAGE_SIZE)
.div_ceil(MMArch::PAGE_SIZE)
.next_power_of_two(),
); );
unsafe { unsafe {
let (paddr, count) = allocate_page_frames(page_num).expect("e1000e: alloc page failed"); let (paddr, count) = allocate_page_frames(page_num).expect("e1000e: alloc page failed");
@ -44,7 +46,9 @@ pub fn dma_alloc(pages: usize) -> (usize, NonNull<u8>) {
/// @return i32 0表示成功 /// @return i32 0表示成功
pub unsafe fn dma_dealloc(paddr: usize, vaddr: NonNull<u8>, pages: usize) -> i32 { pub unsafe fn dma_dealloc(paddr: usize, vaddr: NonNull<u8>, pages: usize) -> i32 {
let page_count = PageFrameCount::new( let page_count = PageFrameCount::new(
((pages * PAGE_SIZE + MMArch::PAGE_SIZE - 1) / MMArch::PAGE_SIZE).next_power_of_two(), (pages * PAGE_SIZE)
.div_ceil(MMArch::PAGE_SIZE)
.next_power_of_two(),
); );
// 恢复页面属性 // 恢复页面属性

View File

@ -186,8 +186,14 @@ impl Clone for LoopbackDriver {
} }
impl phy::Device for LoopbackDriver { impl phy::Device for LoopbackDriver {
type RxToken<'a> = LoopbackRxToken where Self: 'a; type RxToken<'a>
type TxToken<'a> = LoopbackTxToken where Self: 'a; = LoopbackRxToken
where
Self: 'a;
type TxToken<'a>
= LoopbackTxToken
where
Self: 'a;
/// ## 返回设备的物理层特性。 /// ## 返回设备的物理层特性。
/// lo设备的最大传输单元为65535最大突发大小为1传输介质默认为Ethernet /// lo设备的最大传输单元为65535最大突发大小为1传输介质默认为Ethernet
fn capabilities(&self) -> phy::DeviceCapabilities { fn capabilities(&self) -> phy::DeviceCapabilities {

View File

@ -539,8 +539,14 @@ impl VirtioNetToken {
} }
impl phy::Device for VirtIONicDeviceInner { impl phy::Device for VirtIONicDeviceInner {
type RxToken<'a> = VirtioNetToken where Self: 'a; type RxToken<'a>
type TxToken<'a> = VirtioNetToken where Self: 'a; = VirtioNetToken
where
Self: 'a;
type TxToken<'a>
= VirtioNetToken
where
Self: 'a;
fn receive( fn receive(
&mut self, &mut self,

View File

@ -71,6 +71,7 @@ impl OpenFirmwareFdtDriver {
return Ok(()); return Ok(());
} }
#[allow(dead_code)]
pub unsafe fn set_fdt_map_guard(&self, guard: Option<MMIOSpaceGuard>) { pub unsafe fn set_fdt_map_guard(&self, guard: Option<MMIOSpaceGuard>) {
self.inner.write().fdt_map_guard = guard; self.inner.write().fdt_map_guard = guard;
} }
@ -293,6 +294,7 @@ impl OpenFirmwareFdtDriver {
/// 在UEFI初始化后扫描FDT中的`/reserved-memory`节点,设置保留的内存 /// 在UEFI初始化后扫描FDT中的`/reserved-memory`节点,设置保留的内存
/// ///
/// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/of/fdt.c#634 /// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/drivers/of/fdt.c#634
#[allow(dead_code)]
pub fn early_init_fdt_scan_reserved_mem(&self) { pub fn early_init_fdt_scan_reserved_mem(&self) {
let vaddr = boot_params().read().fdt(); let vaddr = boot_params().read().fdt();
if vaddr.is_none() { if vaddr.is_none() {
@ -323,7 +325,6 @@ impl OpenFirmwareFdtDriver {
} }
/// 保留fdt自身的内存空间 /// 保留fdt自身的内存空间
fn early_reserve_fdt_itself(&self, fdt: &Fdt) { fn early_reserve_fdt_itself(&self, fdt: &Fdt) {
#[cfg(target_arch = "riscv64")] #[cfg(target_arch = "riscv64")]
{ {

View File

@ -1474,7 +1474,7 @@ pub struct ExternalCapabilityIterator<'a> {
pub bus_device_function: BusDeviceFunction, pub bus_device_function: BusDeviceFunction,
pub next_capability_offset: Option<u16>, pub next_capability_offset: Option<u16>,
} }
impl<'a> Iterator for ExternalCapabilityIterator<'a> { impl Iterator for ExternalCapabilityIterator<'_> {
type Item = ExternalCapabilityInfo; type Item = ExternalCapabilityInfo;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
let offset = self.next_capability_offset?; let offset = self.next_capability_offset?;

View File

@ -317,7 +317,7 @@ pub struct PciRootIterator<'a> {
index: usize, index: usize,
} }
impl<'a> Iterator for PciRootIterator<'a> { impl Iterator for PciRootIterator<'_> {
type Item = Arc<PciRoot>; type Item = Arc<PciRoot>;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {

View File

@ -64,6 +64,7 @@ impl ScsiManager {
BlockDevName::new(format!("sd{}", x), id) BlockDevName::new(format!("sd{}", x), id)
} }
#[allow(dead_code)]
pub fn free_id(&self, id: usize) { pub fn free_id(&self, id: usize) {
if id >= Self::MAX_DEVICES { if id >= Self::MAX_DEVICES {
return; return;

View File

@ -181,6 +181,7 @@ impl FrameBufferManager {
} }
/// 根据id查找帧缓冲区 /// 根据id查找帧缓冲区
#[allow(dead_code)]
pub fn find_fb_by_id(&self, id: FbId) -> Result<Option<Arc<dyn FrameBuffer>>, SystemError> { pub fn find_fb_by_id(&self, id: FbId) -> Result<Option<Arc<dyn FrameBuffer>>, SystemError> {
if unlikely(!id.is_valid()) { if unlikely(!id.is_valid()) {
return Err(SystemError::EINVAL); return Err(SystemError::EINVAL);

View File

@ -77,7 +77,6 @@ impl VirtIOIrqManager {
/// # 返回 /// # 返回
/// - 如果找到了设备,返回一个包含设备的`Option<Arc<dyn VirtIODevice>>`。 /// - 如果找到了设备,返回一个包含设备的`Option<Arc<dyn VirtIODevice>>`。
/// - 如果没有找到设备,返回`None`。 /// - 如果没有找到设备,返回`None`。
pub fn lookup_device(&self, dev_id: &Arc<DeviceId>) -> Option<Arc<dyn VirtIODevice>> { pub fn lookup_device(&self, dev_id: &Arc<DeviceId>) -> Option<Arc<dyn VirtIODevice>> {
let map = self.map.read_irqsave(); let map = self.map.read_irqsave();
map.get(dev_id).cloned() map.get(dev_id).cloned()

View File

@ -23,7 +23,9 @@ unsafe impl Hal for HalImpl {
_direction: BufferDirection, _direction: BufferDirection,
) -> (virtio_drivers::PhysAddr, NonNull<u8>) { ) -> (virtio_drivers::PhysAddr, NonNull<u8>) {
let page_num = PageFrameCount::new( let page_num = PageFrameCount::new(
((pages * PAGE_SIZE + MMArch::PAGE_SIZE - 1) / MMArch::PAGE_SIZE).next_power_of_two(), (pages * PAGE_SIZE)
.div_ceil(MMArch::PAGE_SIZE)
.next_power_of_two(),
); );
unsafe { unsafe {
let (paddr, count) = let (paddr, count) =
@ -55,7 +57,9 @@ unsafe impl Hal for HalImpl {
pages: usize, pages: usize,
) -> i32 { ) -> i32 {
let page_count = PageFrameCount::new( let page_count = PageFrameCount::new(
((pages * PAGE_SIZE + MMArch::PAGE_SIZE - 1) / MMArch::PAGE_SIZE).next_power_of_two(), (pages * PAGE_SIZE)
.div_ceil(MMArch::PAGE_SIZE)
.next_power_of_two(),
); );
// 恢复页面属性 // 恢复页面属性

View File

@ -306,6 +306,7 @@ impl IrqCommonData {
self.inner.lock_irqsave().affinity = affinity; self.inner.lock_irqsave().affinity = affinity;
} }
#[allow(dead_code)]
pub fn set_effective_affinity(&self, affinity: CpuMask) { pub fn set_effective_affinity(&self, affinity: CpuMask) {
self.inner.lock_irqsave().effective_affinity = affinity; self.inner.lock_irqsave().effective_affinity = affinity;
} }
@ -346,6 +347,7 @@ impl InnerIrqCommonData {
self.handler_data.clone() self.handler_data.clone()
} }
#[allow(dead_code)]
pub fn effective_affinity(&self) -> &CpuMask { pub fn effective_affinity(&self) -> &CpuMask {
&self.effective_affinity &self.effective_affinity
} }

View File

@ -286,10 +286,12 @@ impl IrqDesc {
); );
} }
#[allow(dead_code)]
pub fn set_probe(&self) { pub fn set_probe(&self) {
self.modify_status(IrqLineStatus::IRQ_NOPROBE, IrqLineStatus::empty()); self.modify_status(IrqLineStatus::IRQ_NOPROBE, IrqLineStatus::empty());
} }
#[allow(dead_code)]
pub fn set_noprobe(&self) { pub fn set_noprobe(&self) {
self.modify_status(IrqLineStatus::empty(), IrqLineStatus::IRQ_NOPROBE); self.modify_status(IrqLineStatus::empty(), IrqLineStatus::IRQ_NOPROBE);
} }
@ -416,6 +418,7 @@ impl InnerIrqDesc {
self.line_status.insert(IrqLineStatus::IRQ_NOTHREAD); self.line_status.insert(IrqLineStatus::IRQ_NOTHREAD);
} }
#[allow(dead_code)]
pub fn clear_nothread(&mut self) { pub fn clear_nothread(&mut self) {
self.line_status.remove(IrqLineStatus::IRQ_NOTHREAD); self.line_status.remove(IrqLineStatus::IRQ_NOTHREAD);
} }
@ -451,6 +454,7 @@ impl InnerIrqDesc {
!self.line_status.contains(IrqLineStatus::IRQ_NOAUTOEN) !self.line_status.contains(IrqLineStatus::IRQ_NOAUTOEN)
} }
#[allow(dead_code)]
pub fn can_thread(&self) -> bool { pub fn can_thread(&self) -> bool {
!self.line_status.contains(IrqLineStatus::IRQ_NOTHREAD) !self.line_status.contains(IrqLineStatus::IRQ_NOTHREAD)
} }
@ -486,6 +490,7 @@ impl InnerIrqDesc {
self.actions.clear(); self.actions.clear();
} }
#[allow(dead_code)]
pub fn remove_action(&mut self, action: &Arc<IrqAction>) { pub fn remove_action(&mut self, action: &Arc<IrqAction>) {
self.actions.retain(|a| !Arc::ptr_eq(a, action)); self.actions.retain(|a| !Arc::ptr_eq(a, action));
} }
@ -506,14 +511,17 @@ impl InnerIrqDesc {
&self.common_data &self.common_data
} }
#[allow(dead_code)]
pub fn depth(&self) -> u32 { pub fn depth(&self) -> u32 {
self.depth self.depth
} }
#[allow(dead_code)]
pub fn wake_depth(&self) -> u32 { pub fn wake_depth(&self) -> u32 {
self.wake_depth self.wake_depth
} }
#[allow(dead_code)]
pub fn set_depth(&mut self, depth: u32) { pub fn set_depth(&mut self, depth: u32) {
self.depth = depth; self.depth = depth;
} }
@ -540,6 +548,7 @@ impl InnerIrqDesc {
&mut self.percpu_enabled &mut self.percpu_enabled
} }
#[allow(dead_code)]
pub fn percpu_affinity(&self) -> &Option<CpuMask> { pub fn percpu_affinity(&self) -> &Option<CpuMask> {
&self.percpu_affinity &self.percpu_affinity
} }
@ -969,6 +978,7 @@ impl IrqDescManager {
} }
/// 设置指定irq的可用cpu为所有cpu /// 设置指定irq的可用cpu为所有cpu
#[allow(dead_code)]
pub fn set_percpu_devid_all(&self, irq: IrqNumber) -> Result<(), SystemError> { pub fn set_percpu_devid_all(&self, irq: IrqNumber) -> Result<(), SystemError> {
self.set_percpu_devid(irq, None) self.set_percpu_devid(irq, None)
} }

View File

@ -319,6 +319,7 @@ impl IrqDomainManager {
/// - `handler_data`: 中断流处理程序数据 /// - `handler_data`: 中断流处理程序数据
/// - `handler_name`: 中断处理程序名称 /// - `handler_name`: 中断处理程序名称
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
#[allow(dead_code)]
pub fn domain_set_info( pub fn domain_set_info(
&self, &self,
domain: &Arc<IrqDomain>, domain: &Arc<IrqDomain>,
@ -557,14 +558,17 @@ impl IrqDomain {
} }
/// The number of mapped interrupts /// The number of mapped interrupts
#[allow(dead_code)]
pub fn map_count(&self) -> u32 { pub fn map_count(&self) -> u32 {
self.revmap_read_irqsave().map.len() as u32 self.revmap_read_irqsave().map.len() as u32
} }
#[allow(dead_code)]
pub fn host_data(&self) -> Option<Arc<dyn IrqChipData>> { pub fn host_data(&self) -> Option<Arc<dyn IrqChipData>> {
self.inner.lock_irqsave().host_data.clone() self.inner.lock_irqsave().host_data.clone()
} }
#[allow(dead_code)]
pub fn set_host_data(&self, host_data: Option<Arc<dyn IrqChipData>>) { pub fn set_host_data(&self, host_data: Option<Arc<dyn IrqChipData>>) {
self.inner.lock_irqsave().host_data = host_data; self.inner.lock_irqsave().host_data = host_data;
} }

View File

@ -785,6 +785,7 @@ impl IrqManager {
); );
} }
#[allow(dead_code)]
pub fn irq_set_affinity( pub fn irq_set_affinity(
&self, &self,
irq_data: &Arc<IrqData>, irq_data: &Arc<IrqData>,

View File

@ -275,13 +275,13 @@ struct RunningCountGuard<'a> {
} }
impl<'a> RunningCountGuard<'a> { impl<'a> RunningCountGuard<'a> {
fn new(cpu_running_count: &'a PerCpuVar<AtomicI16>) -> RunningCountGuard { fn new(cpu_running_count: &'a PerCpuVar<AtomicI16>) -> RunningCountGuard<'a> {
cpu_running_count.get().fetch_add(1, Ordering::SeqCst); cpu_running_count.get().fetch_add(1, Ordering::SeqCst);
return RunningCountGuard { cpu_running_count }; return RunningCountGuard { cpu_running_count };
} }
} }
impl<'a> Drop for RunningCountGuard<'a> { impl Drop for RunningCountGuard<'_> {
fn drop(&mut self) { fn drop(&mut self) {
self.cpu_running_count.get().fetch_sub(1, Ordering::SeqCst); self.cpu_running_count.get().fetch_sub(1, Ordering::SeqCst);
} }

View File

@ -266,8 +266,7 @@ impl BiosParameterBlock {
bpb.trail_sig = cursor.read_u16()?; bpb.trail_sig = cursor.read_u16()?;
// 计算根目录项占用的空间(单位:字节) // 计算根目录项占用的空间(单位:字节)
let root_sectors = ((bpb.root_entries_cnt as u32 * 32) + (bpb.bytes_per_sector as u32 - 1)) let root_sectors = (bpb.root_entries_cnt as u32 * 32).div_ceil(bpb.bytes_per_sector as u32);
/ (bpb.bytes_per_sector as u32);
// 每FAT扇区数 // 每FAT扇区数
let fat_size = if bpb.fat_size_16 != 0 { let fat_size = if bpb.fat_size_16 != 0 {
@ -347,9 +346,8 @@ impl BiosParameterBlock {
} }
}; };
let root_sectors = ((self.root_entries_cnt as u32 * 32) let root_sectors =
+ (self.bytes_per_sector as u32 - 1)) (self.root_entries_cnt as u32 * 32).div_ceil(self.bytes_per_sector as u32);
/ (self.bytes_per_sector as u32);
// 当前分区总扇区数 // 当前分区总扇区数
let total_sectors = if self.total_sectors_16 != 0 { let total_sectors = if self.total_sectors_16 != 0 {

View File

@ -256,8 +256,7 @@ impl FATFile {
// 如果还需要更多的簇 // 如果还需要更多的簇
if bytes_remain_in_cluster < extra_bytes { if bytes_remain_in_cluster < extra_bytes {
let clusters_to_allocate = let clusters_to_allocate =
(extra_bytes - bytes_remain_in_cluster + fs.bytes_per_cluster() - 1) (extra_bytes - bytes_remain_in_cluster).div_ceil(fs.bytes_per_cluster());
/ fs.bytes_per_cluster();
let last_cluster = if let Some(c) = fs.get_last_cluster(self.first_cluster) { let last_cluster = if let Some(c) = fs.get_last_cluster(self.first_cluster) {
c c
} else { } else {
@ -338,7 +337,7 @@ impl FATFile {
return Ok(()); return Ok(());
} }
let new_last_cluster = (new_size + fs.bytes_per_cluster() - 1) / fs.bytes_per_cluster(); let new_last_cluster = new_size.div_ceil(fs.bytes_per_cluster());
if let Some(begin_delete) = if let Some(begin_delete) =
fs.get_cluster_by_relative(self.first_cluster, new_last_cluster as usize) fs.get_cluster_by_relative(self.first_cluster, new_last_cluster as usize)
{ {
@ -463,8 +462,7 @@ impl FATDir {
// 计算需要申请多少个簇 // 计算需要申请多少个簇
let clusters_required = let clusters_required =
(remain_entries * FATRawDirEntry::DIR_ENTRY_LEN + fs.bytes_per_cluster() - 1) (remain_entries * FATRawDirEntry::DIR_ENTRY_LEN).div_ceil(fs.bytes_per_cluster());
/ fs.bytes_per_cluster();
let mut first_cluster = Cluster::default(); let mut first_cluster = Cluster::default();
let mut prev_cluster = current_cluster; let mut prev_cluster = current_cluster;
// debug!( // debug!(

View File

@ -326,9 +326,8 @@ impl FATFileSystem {
}; };
// 根目录项占用的扇区数(向上取整) // 根目录项占用的扇区数(向上取整)
let root_dir_sectors: u64 = ((bpb.root_entries_cnt as u64 * 32) let root_dir_sectors: u64 =
+ (bpb.bytes_per_sector as u64 - 1)) (bpb.root_entries_cnt as u64 * 32).div_ceil(bpb.bytes_per_sector as u64);
/ (bpb.bytes_per_sector as u64);
// FAT表大小单位扇区 // FAT表大小单位扇区
let fat_size = if bpb.fat_size_16 != 0 { let fat_size = if bpb.fat_size_16 != 0 {
@ -843,6 +842,7 @@ impl FATFileSystem {
/// @return Ok(true) 正常 /// @return Ok(true) 正常
/// @return Ok(false) 不正常 /// @return Ok(false) 不正常
/// @return Err(SystemError) 在判断时发生错误 /// @return Err(SystemError) 在判断时发生错误
#[allow(dead_code)]
pub fn is_hard_error_bit_ok(&mut self) -> Result<bool, SystemError> { pub fn is_hard_error_bit_ok(&mut self) -> Result<bool, SystemError> {
match self.bpb.fat_type { match self.bpb.fat_type {
FATType::FAT32(_) => { FATType::FAT32(_) => {
@ -935,10 +935,8 @@ impl FATFileSystem {
_ => { _ => {
// FAT12 / FAT16 // FAT12 / FAT16
let root_dir_sectors: u64 = (((self.bpb.root_entries_cnt as u64) * 32) let root_dir_sectors: u64 = ((self.bpb.root_entries_cnt as u64) * 32)
+ self.bpb.bytes_per_sector as u64 .div_ceil(self.bpb.bytes_per_sector as u64);
- 1)
/ self.bpb.bytes_per_sector as u64;
// 数据区扇区数 // 数据区扇区数
let data_sec: u64 = self.bpb.total_sectors_16 as u64 let data_sec: u64 = self.bpb.total_sectors_16 as u64
- (self.bpb.rsvd_sec_cnt as u64 - (self.bpb.rsvd_sec_cnt as u64
@ -1283,6 +1281,7 @@ impl FATFsInfo {
/// @brief 根据fsinfo的信息计算当前总的空闲簇数量 /// @brief 根据fsinfo的信息计算当前总的空闲簇数量
/// ///
/// @param 当前文件系统的最大簇号 /// @param 当前文件系统的最大簇号
#[allow(dead_code)]
pub fn count_free_cluster(&self, max_cluster: Cluster) -> Option<u64> { pub fn count_free_cluster(&self, max_cluster: Cluster) -> Option<u64> {
let count_clusters = max_cluster.cluster_num - RESERVED_CLUSTERS as u64 + 1; let count_clusters = max_cluster.cluster_num - RESERVED_CLUSTERS as u64 + 1;
// 信息不合理当前的FsInfo中存储的free count大于计算出来的值 // 信息不合理当前的FsInfo中存储的free count大于计算出来的值
@ -1301,6 +1300,7 @@ impl FATFsInfo {
/// @brief 更新FsInfo中的“空闲簇统计信息“为new_count /// @brief 更新FsInfo中的“空闲簇统计信息“为new_count
/// ///
/// 请注意,除非手动调用`flush()`,否则本函数不会将数据刷入磁盘 /// 请注意,除非手动调用`flush()`,否则本函数不会将数据刷入磁盘
#[allow(dead_code)]
pub fn update_free_count_abs(&mut self, new_count: u32) { pub fn update_free_count_abs(&mut self, new_count: u32) {
self.free_count = new_count; self.free_count = new_count;
} }
@ -1308,6 +1308,7 @@ impl FATFsInfo {
/// @brief 更新FsInfo中的“空闲簇统计信息“把它加上delta. /// @brief 更新FsInfo中的“空闲簇统计信息“把它加上delta.
/// ///
/// 请注意,除非手动调用`flush()`,否则本函数不会将数据刷入磁盘 /// 请注意,除非手动调用`flush()`,否则本函数不会将数据刷入磁盘
#[allow(dead_code)]
pub fn update_free_count_delta(&mut self, delta: i32) { pub fn update_free_count_delta(&mut self, delta: i32) {
self.free_count = (self.free_count as i32 + delta) as u32; self.free_count = (self.free_count as i32 + delta) as u32;
} }
@ -1360,6 +1361,7 @@ impl FATFsInfo {
/// @brief 读取磁盘上的Fs Info扇区将里面的内容更新到结构体中 /// @brief 读取磁盘上的Fs Info扇区将里面的内容更新到结构体中
/// ///
/// @param partition fs info所在的分区 /// @param partition fs info所在的分区
#[allow(dead_code)]
pub fn update(&mut self, partition: Arc<Partition>) -> Result<(), SystemError> { pub fn update(&mut self, partition: Arc<Partition>) -> Result<(), SystemError> {
if let Some(off) = self.offset { if let Some(off) = self.offset {
let in_block_offset = off % LBA_SIZE as u64; let in_block_offset = off % LBA_SIZE as u64;
@ -1888,7 +1890,7 @@ struct ClusterIter<'a> {
fs: &'a FATFileSystem, fs: &'a FATFileSystem,
} }
impl<'a> Iterator for ClusterIter<'a> { impl Iterator for ClusterIter<'_> {
type Item = Cluster; type Item = Cluster;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {

View File

@ -169,7 +169,7 @@ impl<'a> MbrPartitionIter<'a> {
} }
} }
impl<'a> Iterator for MbrPartitionIter<'a> { impl Iterator for MbrPartitionIter<'_> {
type Item = Partition; type Item = Partition;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {

View File

@ -14,6 +14,7 @@ use alloc::sync::Arc;
use alloc::sync::Weak; use alloc::sync::Weak;
use alloc::vec::Vec; use alloc::vec::Vec;
use entry::{OvlEntry, OvlLayer}; use entry::{OvlEntry, OvlLayer};
use linkme::distributed_slice;
use system_error::SystemError; use system_error::SystemError;
const WHITEOUT_MODE: u64 = 0o020000 | 0o600; // whiteout字符设备文件模式与权限 const WHITEOUT_MODE: u64 = 0o020000 | 0o600; // whiteout字符设备文件模式与权限
@ -89,7 +90,7 @@ struct OverlayFS {
} }
#[derive(Debug)] #[derive(Debug)]
struct OvlInode { pub struct OvlInode {
redirect: String, // 重定向路径 redirect: String, // 重定向路径
file_type: FileType, file_type: FileType,
flags: SpinLock<u64>, flags: SpinLock<u64>,

View File

@ -51,7 +51,6 @@ impl Syscall {
/// - 成功Ok(usize) /// - 成功Ok(usize)
/// - 失败Err(SystemError) 操作失败返回posix错误码 /// - 失败Err(SystemError) 操作失败返回posix错误码
/// ///
pub fn do_syslog( pub fn do_syslog(
syslog_action_type: usize, syslog_action_type: usize,
buf: &mut [u8], buf: &mut [u8],

View File

@ -800,7 +800,7 @@ impl<'a> FileDescriptorIterator<'a> {
} }
} }
impl<'a> Iterator for FileDescriptorIterator<'a> { impl Iterator for FileDescriptorIterator<'_> {
type Item = (i32, Arc<File>); type Item = (i32, Arc<File>);
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {

View File

@ -49,6 +49,7 @@ impl BootParams {
core::str::from_utf8(&self.boot_cmdline()[..self.boot_cmdline_len()]).unwrap() core::str::from_utf8(&self.boot_cmdline()[..self.boot_cmdline_len()]).unwrap()
} }
#[allow(dead_code)]
pub fn bootloader_name(&self) -> Option<&str> { pub fn bootloader_name(&self) -> Option<&str> {
self.bootloader_name.as_deref() self.bootloader_name.as_deref()
} }

View File

@ -43,6 +43,7 @@ pub struct KernelCmdlineParamBuilder {
inv: bool, inv: bool,
} }
#[allow(dead_code)]
impl KernelCmdlineParamBuilder { impl KernelCmdlineParamBuilder {
pub const fn new(name: &'static str, ty: KCmdlineParamType) -> Self { pub const fn new(name: &'static str, ty: KCmdlineParamType) -> Self {
Self { Self {
@ -110,6 +111,7 @@ pub enum KernelCmdlineParameter {
EarlyKV(&'static KernelCmdlineEarlyKV), EarlyKV(&'static KernelCmdlineEarlyKV),
} }
#[allow(dead_code)]
impl KernelCmdlineParameter { impl KernelCmdlineParameter {
pub fn name(&self) -> &str { pub fn name(&self) -> &str {
match self { match self {
@ -195,6 +197,7 @@ pub struct KernelCmdlineEarlyKV {
default: &'static str, default: &'static str,
} }
#[allow(dead_code)]
impl KernelCmdlineEarlyKV { impl KernelCmdlineEarlyKV {
pub const VALUE_MAX_LEN: usize = 256; pub const VALUE_MAX_LEN: usize = 256;

View File

@ -297,7 +297,6 @@ pub struct UserSigaction {
* siginfo中signal的来源不同info中对应了不同的数据./= * siginfo中signal的来源不同info中对应了不同的数据./=
* info最大占用16字节 * info最大占用16字节
*/ */
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct SigInfo { pub struct SigInfo {

View File

@ -2,20 +2,15 @@
#![feature(alloc_error_handler)] #![feature(alloc_error_handler)]
#![feature(allocator_api)] #![feature(allocator_api)]
#![feature(arbitrary_self_types)] #![feature(arbitrary_self_types)]
#![feature(asm_const)]
#![feature(concat_idents)] #![feature(concat_idents)]
#![feature(const_for)] #![feature(const_for)]
#![feature(const_mut_refs)]
#![feature(const_option)]
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
#![feature(const_refs_to_cell)]
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
#![feature(c_void_variant)] #![feature(c_void_variant)]
#![feature(extract_if)] #![feature(extract_if)]
#![feature(fn_align)] #![feature(fn_align)]
#![feature(linked_list_retain)] #![feature(linked_list_retain)]
#![feature(naked_functions)] #![feature(naked_functions)]
#![feature(new_uninit)]
#![feature(ptr_internals)] #![feature(ptr_internals)]
#![feature(trait_upcasting)] #![feature(trait_upcasting)]
#![feature(slice_ptr_get)] #![feature(slice_ptr_get)]
@ -23,16 +18,19 @@
#![feature(vec_into_raw_parts)] #![feature(vec_into_raw_parts)]
#![feature(c_variadic)] #![feature(c_variadic)]
#![cfg_attr(target_os = "none", no_std)] #![cfg_attr(target_os = "none", no_std)]
#![allow(internal_features)] #![allow(static_mut_refs, non_local_definitions, internal_features)]
// clippy的配置 // clippy的配置
#![deny(clippy::all)] #![deny(clippy::all)]
#![allow(clippy::bad_bit_mask)]
// DragonOS允许在函数中使用return语句尤其是长函数时我们推荐这么做 // DragonOS允许在函数中使用return语句尤其是长函数时我们推荐这么做
#![allow(clippy::let_and_return)] #![allow(
#![allow(clippy::needless_pass_by_ref_mut)] clippy::macro_metavars_in_unsafe,
#![allow(clippy::needless_return)] clippy::upper_case_acronyms,
#![allow(clippy::single_char_pattern)] clippy::single_char_pattern,
#![allow(clippy::upper_case_acronyms)] clippy::needless_return,
clippy::needless_pass_by_ref_mut,
clippy::let_and_return,
clippy::bad_bit_mask
)]
#[cfg(test)] #[cfg(test)]
#[macro_use] #[macro_use]

View File

@ -47,7 +47,6 @@ use alloc::sync::Arc;
/// ///
/// fn test() { /// fn test() {
/// let a = A { name: "a".to_string() }; /// let a = A { name: "a".to_string() };
/// let a_arc: Arc<dyn Base> = Arc::new(a) as Arc<dyn Base>; /// let a_arc: Arc<dyn Base> = Arc::new(a) as Arc<dyn Base>;
/// let a_arc2: Option<Arc<A>> = a_arc.downcast_arc::<A>(); /// let a_arc2: Option<Arc<A>> = a_arc.downcast_arc::<A>();
/// assert!(a_arc2.is_some()); /// assert!(a_arc2.is_some());

View File

@ -129,7 +129,7 @@ pub struct CpuMaskIter<'a> {
begin: bool, begin: bool,
} }
impl<'a> Iterator for CpuMaskIter<'a> { impl Iterator for CpuMaskIter<'_> {
type Item = ProcessorId; type Item = ProcessorId;
fn next(&mut self) -> Option<ProcessorId> { fn next(&mut self) -> Option<ProcessorId> {

View File

@ -844,7 +844,7 @@ impl<'a> FutexIterator<'a> {
} }
} }
impl<'a> Iterator for FutexIterator<'a> { impl Iterator for FutexIterator<'_> {
type Item = VirtAddr; type Item = VirtAddr;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {

View File

@ -298,7 +298,6 @@ pub fn scm_init(enable_put_to_window: bool) {
/// ## 参数 /// ## 参数
/// ///
/// - framework 要启动的ui框架 /// - framework 要启动的ui框架
pub fn scm_framework_enable(framework: Arc<dyn ScmUiFramework>) -> Result<i32, SystemError> { pub fn scm_framework_enable(framework: Arc<dyn ScmUiFramework>) -> Result<i32, SystemError> {
// 获取信息 // 获取信息
let metadata = framework.metadata()?; let metadata = framework.metadata()?;
@ -321,7 +320,6 @@ pub fn scm_framework_enable(framework: Arc<dyn ScmUiFramework>) -> Result<i32, S
/// ///
/// ## 参数 /// ## 参数
/// - framework 框架结构体 /// - framework 框架结构体
pub fn scm_register(framework: Arc<dyn ScmUiFramework>) -> Result<i32, SystemError> { pub fn scm_register(framework: Arc<dyn ScmUiFramework>) -> Result<i32, SystemError> {
// 把ui框架加入链表 // 把ui框架加入链表

View File

@ -595,7 +595,6 @@ impl TextuiWindow {
/// -flags 标志位 /// -flags 标志位
/// -vlines_num 虚拟行的总数 /// -vlines_num 虚拟行的总数
/// -chars_num 每行最大的字符数 /// -chars_num 每行最大的字符数
pub fn new(flags: WindowFlag, vlines_num: i32, chars_num: i32) -> Self { pub fn new(flags: WindowFlag, vlines_num: i32, chars_num: i32) -> Self {
let mut initial_vlines = Vec::new(); let mut initial_vlines = Vec::new();
@ -667,10 +666,8 @@ impl TextuiWindow {
/// 重新渲染某个窗口的某个虚拟行 /// 重新渲染某个窗口的某个虚拟行
/// ## 参数 /// ## 参数
/// - window 窗口结构体 /// - window 窗口结构体
/// - vline_id 虚拟行号 /// - vline_id 虚拟行号
fn textui_refresh_vline(&mut self, vline_id: LineId) -> Result<(), SystemError> { fn textui_refresh_vline(&mut self, vline_id: LineId) -> Result<(), SystemError> {
if self.flags.contains(WindowFlag::TEXTUI_CHROMATIC) { if self.flags.contains(WindowFlag::TEXTUI_CHROMATIC) {
return self.textui_refresh_characters( return self.textui_refresh_characters(
@ -788,12 +785,10 @@ impl TextuiWindow {
} }
/// 根据输入的一个字符在窗口上输出 /// 根据输入的一个字符在窗口上输出
/// ## 参数 /// ## 参数
/// - window 窗口 /// - window 窗口
/// - character 字符 /// - character 字符
/// - FRcolor 前景色RGB /// - FRcolor 前景色RGB
/// - BKcolor 背景色RGB /// - BKcolor 背景色RGB
fn textui_putchar_window( fn textui_putchar_window(
&mut self, &mut self,
character: char, character: char,
@ -1027,7 +1022,6 @@ where
/// - character 字符 /// - character 字符
/// - FRcolor 前景色RGB /// - FRcolor 前景色RGB
/// - BKcolor 背景色RGB /// - BKcolor 背景色RGB
#[no_mangle] #[no_mangle]
pub extern "C" fn rs_textui_putchar(character: u8, fr_color: u32, bk_color: u32) -> i32 { pub extern "C" fn rs_textui_putchar(character: u8, fr_color: u32, bk_color: u32) -> i32 {
if let Some(current_vc) = vc_manager().current_vc() { if let Some(current_vc) = vc_manager().current_vc() {

View File

@ -286,7 +286,6 @@ impl<K: Ord + Clone + Debug, V: Clone + Debug> NodePtr<K, V> {
/// A red black tree implemented with Rust /// A red black tree implemented with Rust
/// It is required that the keys implement the [`Ord`] traits. /// It is required that the keys implement the [`Ord`] traits.
/// # Examples /// # Examples
/// ```rust /// ```rust
/// use rbtree::RBTree; /// use rbtree::RBTree;
@ -431,7 +430,7 @@ where
impl<K: Eq + Ord + Debug, V: Eq + Debug> Eq for RBTree<K, V> {} impl<K: Eq + Ord + Debug, V: Eq + Debug> Eq for RBTree<K, V> {}
impl<'a, K: Ord + Debug, V: Debug> Index<&'a K> for RBTree<K, V> { impl<K: Ord + Debug, V: Debug> Index<&K> for RBTree<K, V> {
type Output = V; type Output = V;
#[inline] #[inline]
@ -482,7 +481,7 @@ impl<'a, K: Ord + Debug, V: Debug> Clone for Keys<'a, K, V> {
} }
} }
impl<'a, K: Ord + Debug, V: Debug> fmt::Debug for Keys<'a, K, V> { impl<K: Ord + Debug, V: Debug> fmt::Debug for Keys<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list().entries(self.clone()).finish() f.debug_list().entries(self.clone()).finish()
} }
@ -527,7 +526,7 @@ impl<'a, K: Ord + Debug, V: Debug> Clone for Values<'a, K, V> {
} }
} }
impl<'a, K: Ord + Debug, V: Debug> fmt::Debug for Values<'a, K, V> { impl<K: Ord + Debug, V: Debug> fmt::Debug for Values<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list().entries(self.clone()).finish() f.debug_list().entries(self.clone()).finish()
} }
@ -575,7 +574,7 @@ impl<'a, K: Ord + Debug, V: Debug> Clone for ValuesMut<'a, K, V> {
} }
} }
impl<'a, K: Ord + Debug, V: Debug> fmt::Debug for ValuesMut<'a, K, V> { impl<K: Ord + Debug, V: Debug> fmt::Debug for ValuesMut<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list().entries(self.clone()).finish() f.debug_list().entries(self.clone()).finish()
} }
@ -1651,7 +1650,7 @@ mod tests {
let vec = vec![(1, 1), (2, 2), (3, 3)]; let vec = vec![(1, 1), (2, 2), (3, 3)];
let mut map: RBTree<_, _> = vec.into_iter().collect(); let mut map: RBTree<_, _> = vec.into_iter().collect();
for value in map.values_mut() { for value in map.values_mut() {
*value = (*value) * 2 *value *= 2
} }
let values: Vec<_> = map.values().cloned().collect(); let values: Vec<_> = map.values().cloned().collect();
assert_eq!(values.len(), 3); assert_eq!(values.len(), 3);
@ -1808,7 +1807,7 @@ mod tests {
b.insert(2, "two"); b.insert(2, "two");
b.insert(3, "three"); b.insert(3, "three");
a.extend(b.into_iter()); a.extend(b);
assert_eq!(a.len(), 3); assert_eq!(a.len(), 3);
assert_eq!(a[&1], "one"); assert_eq!(a[&1], "one");
@ -1818,6 +1817,7 @@ mod tests {
#[test] #[test]
fn test_rev_iter() { fn test_rev_iter() {
use crate::libs::rbtree::RBTree;
let mut a = RBTree::new(); let mut a = RBTree::new();
a.insert(1, 1); a.insert(1, 1);
a.insert(2, 2); a.insert(2, 2);
@ -1826,7 +1826,7 @@ mod tests {
assert_eq!(a.len(), 3); assert_eq!(a.len(), 3);
let mut cache = vec![]; let mut cache = vec![];
for e in a.iter().rev() { for e in a.iter().rev() {
cache.push(e.0.clone()); cache.push(*e.0);
} }
assert_eq!(&cache, &vec![3, 2, 1]); assert_eq!(&cache, &vec![3, 2, 1]);
} }

View File

@ -16,7 +16,6 @@ use crate::{
}; };
///RwLock读写锁 ///RwLock读写锁
/// @brief READER位占据从右往左数第三个比特位 /// @brief READER位占据从右往左数第三个比特位
const READER: u32 = 1 << 2; const READER: u32 = 1 << 2;
@ -548,7 +547,7 @@ impl<'rwlock, T> RwLockWriteGuard<'rwlock, T> {
} }
} }
impl<'rwlock, T> Deref for RwLockReadGuard<'rwlock, T> { impl<T> Deref for RwLockReadGuard<'_, T> {
type Target = T; type Target = T;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
@ -556,7 +555,7 @@ impl<'rwlock, T> Deref for RwLockReadGuard<'rwlock, T> {
} }
} }
impl<'rwlock, T> Deref for RwLockUpgradableGuard<'rwlock, T> { impl<T> Deref for RwLockUpgradableGuard<'_, T> {
type Target = T; type Target = T;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
@ -564,7 +563,7 @@ impl<'rwlock, T> Deref for RwLockUpgradableGuard<'rwlock, T> {
} }
} }
impl<'rwlock, T> Deref for RwLockWriteGuard<'rwlock, T> { impl<T> Deref for RwLockWriteGuard<'_, T> {
type Target = T; type Target = T;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
@ -572,13 +571,13 @@ impl<'rwlock, T> Deref for RwLockWriteGuard<'rwlock, T> {
} }
} }
impl<'rwlock, T> DerefMut for RwLockWriteGuard<'rwlock, T> { impl<T> DerefMut for RwLockWriteGuard<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target { fn deref_mut(&mut self) -> &mut Self::Target {
return unsafe { &mut *self.data }; return unsafe { &mut *self.data };
} }
} }
impl<'rwlock, T> Drop for RwLockReadGuard<'rwlock, T> { impl<T> Drop for RwLockReadGuard<'_, T> {
fn drop(&mut self) { fn drop(&mut self) {
debug_assert!(self.lock.load(Ordering::Relaxed) & !(WRITER | UPGRADED) > 0); debug_assert!(self.lock.load(Ordering::Relaxed) & !(WRITER | UPGRADED) > 0);
self.lock.fetch_sub(READER, Ordering::Release); self.lock.fetch_sub(READER, Ordering::Release);
@ -586,7 +585,7 @@ impl<'rwlock, T> Drop for RwLockReadGuard<'rwlock, T> {
} }
} }
impl<'rwlock, T> Drop for RwLockUpgradableGuard<'rwlock, T> { impl<T> Drop for RwLockUpgradableGuard<'_, T> {
fn drop(&mut self) { fn drop(&mut self) {
debug_assert_eq!( debug_assert_eq!(
self.inner.lock.load(Ordering::Relaxed) & (WRITER | UPGRADED), self.inner.lock.load(Ordering::Relaxed) & (WRITER | UPGRADED),
@ -598,7 +597,7 @@ impl<'rwlock, T> Drop for RwLockUpgradableGuard<'rwlock, T> {
} }
} }
impl<'rwlock, T> Drop for RwLockWriteGuard<'rwlock, T> { impl<T> Drop for RwLockWriteGuard<'_, T> {
fn drop(&mut self) { fn drop(&mut self) {
debug_assert_eq!(self.inner.lock.load(Ordering::Relaxed) & WRITER, WRITER); debug_assert_eq!(self.inner.lock.load(Ordering::Relaxed) & WRITER, WRITER);
self.inner self.inner

View File

@ -64,7 +64,6 @@ macro_rules! volatile_write_bit {
/// volwrite!(self.common_cfg, queue_enable, 0); /// volwrite!(self.common_cfg, queue_enable, 0);
/// ///
/// 这样做不仅使代码的可读性提高了,也避免了对只读寄存器进行写入的误操作 /// 这样做不仅使代码的可读性提高了,也避免了对只读寄存器进行写入的误操作
/// 只读寄存器 /// 只读寄存器
#[derive(Default)] #[derive(Default)]
#[repr(transparent)] #[repr(transparent)]

View File

@ -473,7 +473,7 @@ pub struct MemBlockIter<'a> {
} }
#[allow(dead_code)] #[allow(dead_code)]
impl<'a> MemBlockIter<'a> { impl MemBlockIter<'_> {
/// 获取内存区域数量 /// 获取内存区域数量
pub fn total_num(&self) -> usize { pub fn total_num(&self) -> usize {
self.inner.initial_memory_regions_num self.inner.initial_memory_regions_num
@ -490,7 +490,7 @@ impl<'a> MemBlockIter<'a> {
} }
} }
impl<'a> Iterator for MemBlockIter<'a> { impl Iterator for MemBlockIter<'_> {
type Item = PhysMemoryArea; type Item = PhysMemoryArea;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {

View File

@ -208,6 +208,8 @@ impl RingPage {
let data_head = unsafe { &(*(self.ptr as *mut perf_event_mmap_page)).data_head }; let data_head = unsafe { &(*(self.ptr as *mut perf_event_mmap_page)).data_head };
data_tail != data_head data_tail != data_head
} }
#[allow(dead_code)]
pub fn as_slice(&self) -> &[u8] { pub fn as_slice(&self) -> &[u8] {
unsafe { core::slice::from_raw_parts(self.ptr as *const u8, self.size) } unsafe { core::slice::from_raw_parts(self.ptr as *const u8, self.size) }
} }

View File

@ -116,7 +116,7 @@ pub struct PerfSample<'a> {
pub value: &'a [u8], pub value: &'a [u8],
} }
impl<'a> PerfSample<'a> { impl PerfSample<'_> {
pub fn calculate_size(value_size: usize) -> usize { pub fn calculate_size(value_size: usize) -> usize {
size_of::<SampleHeader>() + value_size size_of::<SampleHeader>() + value_size
} }

View File

@ -39,7 +39,7 @@ pub struct WaitIdInfo {
pub cause: i32, pub cause: i32,
} }
impl<'a> KernelWaitOption<'a> { impl KernelWaitOption<'_> {
pub fn new(pid_type: PidType, pid: Pid, options: WaitOption) -> Self { pub fn new(pid_type: PidType, pid: Pid, options: WaitOption) -> Self {
Self { Self {
pid_type, pid_type,

View File

@ -212,7 +212,7 @@ impl Syscall {
return Ok(target_proc.basic().pgid()); return Ok(target_proc.basic().pgid());
} }
/// @brief 获取当前进程的父进程id /// @brief 获取当前进程的父进程id
///
/// 若为initproc则ppid设置为0 /// 若为initproc则ppid设置为0
pub fn getppid() -> Result<Pid, SystemError> { pub fn getppid() -> Result<Pid, SystemError> {
let current_pcb = ProcessManager::current_pcb(); let current_pcb = ProcessManager::current_pcb();

View File

@ -10,12 +10,11 @@ use system_error::SystemError;
use super::{user_access::UserBufferWriter, Syscall}; use super::{user_access::UserBufferWriter, Syscall};
#[repr(C)]
/// 系统信息 /// 系统信息
/// ///
/// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/uapi/linux/sysinfo.h#8 /// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/include/uapi/linux/sysinfo.h#8
#[derive(Debug, Default, Copy, Clone)] #[derive(Debug, Default, Copy, Clone)]
#[repr(C)]
pub struct SysInfo { pub struct SysInfo {
uptime: u64, uptime: u64,
loads: [u64; 3], loads: [u64; 3],

View File

@ -160,7 +160,7 @@ pub struct UserBufferReader<'a> {
} }
#[allow(dead_code)] #[allow(dead_code)]
impl<'a> UserBufferReader<'a> { impl UserBufferReader<'_> {
/// 构造一个指向用户空间位置的BufferReader为了兼容类似传入 *const u8 的情况,使用单独的泛型来进行初始化 /// 构造一个指向用户空间位置的BufferReader为了兼容类似传入 *const u8 的情况,使用单独的泛型来进行初始化
/// ///
/// @param addr 用户空间指针 /// @param addr 用户空间指针
@ -321,7 +321,7 @@ impl<'a> UserBufferWriter<'a> {
return Ok(()); return Ok(());
} }
pub fn buffer<T>(&'a mut self, offset: usize) -> Result<&mut [T], SystemError> { pub fn buffer<T>(&'a mut self, offset: usize) -> Result<&'a mut [T], SystemError> {
Self::convert_with_offset::<T>(self.buffer, offset).map_err(|_| SystemError::EINVAL) Self::convert_with_offset::<T>(self.buffer, offset).map_err(|_| SystemError::EINVAL)
} }

View File

@ -1 +1 @@
v1.5 v1.6

View File

@ -6,4 +6,4 @@ clean:
@cargo clean @cargo clean
check: check:
@cargo +nightly-2024-07-23 check --workspace --message-format=json @cargo +nightly-2024-11-05 check --workspace --message-format=json

View File

@ -23,7 +23,7 @@ DEFAULT_INSTALL="false"
export RUSTUP_DIST_SERVER=${RUSTUP_DIST_SERVER:-https://rsproxy.cn} export RUSTUP_DIST_SERVER=${RUSTUP_DIST_SERVER:-https://rsproxy.cn}
export RUSTUP_UPDATE_ROOT=${RUSTUP_UPDATE_ROOT:-https://rsproxy.cn/rustup} export RUSTUP_UPDATE_ROOT=${RUSTUP_UPDATE_ROOT:-https://rsproxy.cn/rustup}
export RUST_VERSION="${RUST_VERSION:-nightly-2024-07-23}" export RUST_VERSION="${RUST_VERSION:-nightly-2024-11-05}"
banner() banner()
{ {
@ -233,21 +233,21 @@ rustInstall() {
echo "正在安装DragonOS所需的rust组件...首次安装需要一些时间来更新索引,请耐心等待..." echo "正在安装DragonOS所需的rust组件...首次安装需要一些时间来更新索引,请耐心等待..."
cargo install cargo-binutils cargo install cargo-binutils
cargo install bpf-linker cargo install bpf-linker
rustup toolchain install nightly-2023-08-15-x86_64-unknown-linux-gnu rustup toolchain install nightly-2024-11-05-x86_64-unknown-linux-gnu
rustup toolchain install $RUST_VERSION-x86_64-unknown-linux-gnu rustup toolchain install $RUST_VERSION-x86_64-unknown-linux-gnu
rustup component add rust-src --toolchain $RUST_VERSION-x86_64-unknown-linux-gnu rustup component add rust-src --toolchain $RUST_VERSION-x86_64-unknown-linux-gnu
rustup component add rust-src --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu rustup component add rust-src --toolchain nightly-2024-11-05-x86_64-unknown-linux-gnu
rustup target add x86_64-unknown-none --toolchain $RUST_VERSION-x86_64-unknown-linux-gnu rustup target add x86_64-unknown-none --toolchain $RUST_VERSION-x86_64-unknown-linux-gnu
rustup target add x86_64-unknown-none --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu rustup target add x86_64-unknown-none --toolchain nightly-2024-11-05-x86_64-unknown-linux-gnu
rustup target add x86_64-unknown-linux-musl --toolchain nightly-2023-08-15-x86_64-unknown-linux-gnu rustup target add x86_64-unknown-linux-musl --toolchain nightly-2024-11-05-x86_64-unknown-linux-gnu
rustup target add x86_64-unknown-linux-musl --toolchain $RUST_VERSION-x86_64-unknown-linux-gnu rustup target add x86_64-unknown-linux-musl --toolchain $RUST_VERSION-x86_64-unknown-linux-gnu
rustup toolchain install $RUST_VERSION-riscv64gc-unknown-linux-gnu --force-non-host rustup toolchain install $RUST_VERSION-riscv64gc-unknown-linux-gnu --force-non-host
rustup toolchain install nightly-2023-08-15-riscv64gc-unknown-linux-gnu --force-non-host rustup toolchain install nightly-2024-11-05-riscv64gc-unknown-linux-gnu --force-non-host
rustup target add riscv64gc-unknown-none-elf --toolchain $RUST_VERSION-riscv64gc-unknown-linux-gnu rustup target add riscv64gc-unknown-none-elf --toolchain $RUST_VERSION-riscv64gc-unknown-linux-gnu
rustup target add riscv64imac-unknown-none-elf --toolchain $RUST_VERSION-riscv64gc-unknown-linux-gnu rustup target add riscv64imac-unknown-none-elf --toolchain $RUST_VERSION-riscv64gc-unknown-linux-gnu
rustup target add riscv64gc-unknown-none-elf --toolchain nightly-2023-08-15-riscv64gc-unknown-linux-gnu rustup target add riscv64gc-unknown-none-elf --toolchain nightly-2024-11-05-riscv64gc-unknown-linux-gnu
rustup target add riscv64imac-unknown-none-elf --toolchain nightly-2023-08-15-riscv64gc-unknown-linux-gnu rustup target add riscv64imac-unknown-none-elf --toolchain nightly-2024-11-05-riscv64gc-unknown-linux-gnu
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
rustup component add rust-src rustup component add rust-src

View File

@ -110,7 +110,7 @@ pub struct TabsState<'a> {
} }
impl<'a> TabsState<'a> { impl<'a> TabsState<'a> {
pub fn new(titles: Vec<&'a str>) -> TabsState { pub fn new(titles: Vec<&'a str>) -> TabsState<'a> {
TabsState { titles, index: 0 } TabsState { titles, index: 0 }
} }
pub fn next(&mut self) { pub fn next(&mut self) {

View File

@ -1,4 +1,4 @@
TOOLCHAIN="+nightly-2024-07-23-x86_64-unknown-linux-gnu" TOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu"
# RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie" # RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie"
ifdef DADK_CURRENT_BUILD_DIR ifdef DADK_CURRENT_BUILD_DIR

View File

@ -1,4 +1,4 @@
TOOLCHAIN="+nightly-2024-07-23-x86_64-unknown-linux-gnu" TOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu"
RUSTFLAGS+="" RUSTFLAGS+=""
ifdef DADK_CURRENT_BUILD_DIR ifdef DADK_CURRENT_BUILD_DIR

View File

@ -1,6 +1,6 @@
# The toolchain we use. # The toolchain we use.
# You can get it by running DragonOS' `tools/bootstrap.sh` # You can get it by running DragonOS' `tools/bootstrap.sh`
TOOLCHAIN="+nightly-2024-07-23-x86_64-unknown-linux-gnu" TOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu"
RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie" RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie"
# 如果是在dadk中编译那么安装到dadk的安装目录中 # 如果是在dadk中编译那么安装到dadk的安装目录中

View File

@ -1,4 +1,4 @@
TOOLCHAIN="+nightly-2024-07-23-x86_64-unknown-linux-gnu" TOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu"
RUSTFLAGS+="" RUSTFLAGS+=""
ifdef DADK_CURRENT_BUILD_DIR ifdef DADK_CURRENT_BUILD_DIR

View File

@ -1,4 +1,4 @@
TOOLCHAIN="+nightly-2024-07-23-x86_64-unknown-linux-gnu" TOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu"
RUSTFLAGS+="" RUSTFLAGS+=""
ifdef DADK_CURRENT_BUILD_DIR ifdef DADK_CURRENT_BUILD_DIR

View File

@ -1,4 +1,4 @@
TOOLCHAIN="+nightly-2024-07-23-x86_64-unknown-linux-gnu" TOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu"
RUSTFLAGS+="" RUSTFLAGS+=""
ifdef DADK_CURRENT_BUILD_DIR ifdef DADK_CURRENT_BUILD_DIR

View File

@ -1,4 +1,4 @@
TOOLCHAIN="+nightly-2024-07-23-x86_64-unknown-linux-gnu" TOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu"
RUSTFLAGS+="" RUSTFLAGS+=""
ifdef DADK_CURRENT_BUILD_DIR ifdef DADK_CURRENT_BUILD_DIR

View File

@ -1,5 +1,5 @@
[toolchain] [toolchain]
channel = "nightly-2024-07-23" channel = "nightly-2024-11-05"
# The source code of rustc, provided by the rust-src component, is needed for # The source code of rustc, provided by the rust-src component, is needed for
# building eBPF programs. # building eBPF programs.
components = [ components = [

View File

@ -1,4 +1,4 @@
TOOLCHAIN="+nightly-2023-08-15-x86_64-unknown-linux-gnu" TOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu"
RUSTFLAGS+="" RUSTFLAGS+=""
ifdef DADK_CURRENT_BUILD_DIR ifdef DADK_CURRENT_BUILD_DIR

View File

@ -1,7 +1,7 @@
# Makefile.toml # Makefile.toml
[env] [env]
TOOLCHAIN = "+nightly-2023-08-15-x86_64-unknown-linux-gnu" TOOLCHAIN = "+nightly-2024-11-05-x86_64-unknown-linux-gnu"
ARCH = { default = "x86_64" } ARCH = { default = "x86_64" }
RUST_TARGET = { default = { if = "eq(env.ARCH, 'riscv64')", value = "riscv64gc-unknown-linux-gnu", else = "x86_64-unknown-linux-musl" } } RUST_TARGET = { default = { if = "eq(env.ARCH, 'riscv64')", value = "riscv64gc-unknown-linux-gnu", else = "x86_64-unknown-linux-musl" } }

View File

@ -1,4 +1,4 @@
TOOLCHAIN="+nightly-2024-07-23-x86_64-unknown-linux-gnu" TOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu"
RUSTFLAGS+="" RUSTFLAGS+=""
ifdef DADK_CURRENT_BUILD_DIR ifdef DADK_CURRENT_BUILD_DIR

View File

@ -1,4 +1,4 @@
TOOLCHAIN="+nightly-2024-07-23-x86_64-unknown-linux-gnu" TOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu"
# RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie" # RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie"
ifdef DADK_CURRENT_BUILD_DIR ifdef DADK_CURRENT_BUILD_DIR

View File

@ -1,4 +1,4 @@
TOOLCHAIN="+nightly-2024-07-23-x86_64-unknown-linux-gnu" TOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu"
RUSTFLAGS+="" RUSTFLAGS+=""
ifdef DADK_CURRENT_BUILD_DIR ifdef DADK_CURRENT_BUILD_DIR

View File

@ -1,6 +1,6 @@
# The toolchain we use. # The toolchain we use.
# You can get it by running DragonOS' `tools/bootstrap.sh` # You can get it by running DragonOS' `tools/bootstrap.sh`
TOOLCHAIN="+nightly-2024-07-23-x86_64-unknown-linux-gnu" TOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu"
RUSTFLAGS+="" RUSTFLAGS+=""
ifdef DADK_CURRENT_BUILD_DIR ifdef DADK_CURRENT_BUILD_DIR

View File

@ -8,7 +8,7 @@
"Git": { "Git": {
"url": "https://git.mirrors.dragonos.org.cn/DragonOS-Community/dog.git", "url": "https://git.mirrors.dragonos.org.cn/DragonOS-Community/dog.git",
"branch": null, "branch": null,
"revision": "4ad6075686" "revision": "6f2c0c8f12"
} }
} }
}, },

View File

@ -6,7 +6,7 @@
"BuildFromSource": { "BuildFromSource": {
"Git": { "Git": {
"url" : "https://git.mirrors.dragonos.org.cn/DragonOS-Community/DragonReach.git", "url" : "https://git.mirrors.dragonos.org.cn/DragonOS-Community/DragonReach.git",
"revision": "01cdc56863" "revision": "e945c217b3"
} }
} }
}, },