Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions kernel/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ uefi-raw = "=0.5.0"
riscv = { git = "https://git.mirrors.dragonos.org.cn/DragonOS-Community/riscv.git", rev = "4241a97", features = [
"s-mode",
] }
byte-slice-cast = { version = "1.2.2", default-features = false }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我测试了一下,貌似这个不是必须的?在mmc.rs那,用到的地方,直接core::str::from_utf8就可以了?

sbi-rt = { version = "=0.0.3", features = ["legacy"] }
uefi = { version = "=0.26.0", features = ["alloc"] }
uefi-raw = "=0.5.0"
Expand Down
1 change: 1 addition & 0 deletions kernel/src/arch/riscv64/driver/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod of;
pub mod sbi;
pub mod vf2;
26 changes: 17 additions & 9 deletions kernel/src/arch/riscv64/driver/sbi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,23 @@ use core::ptr::addr_of;
/// console_putstr(message);
/// ```
pub fn console_putstr(s: &[u8]) {
if SbiDriver::extensions().contains(SBIExtensions::CONSOLE) {
for c in s {
sbi_rt::console_write_byte(*c);
}
return;
} else {
for c in s {
#[allow(deprecated)]
sbi_rt::legacy::console_putchar(*c as usize);
// 原本的是适配opensbi的, 但是对rustsbi的适配存在问题, 不能正确的解析'\r'
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be written in English to align with codebase documentation standards.

Suggested change
// 原本的是适配opensbi的, 但是对rustsbi的适配存在问题, 不能正确的解析'\r'
// The original implementation was adapted for OpenSBI, but there are compatibility issues with RustSBI, which cannot correctly parse '\r'

Copilot uses AI. Check for mistakes.
for &c in s {
match c {
b'\n' => {
#[allow(deprecated)]
sbi_rt::legacy::console_putchar(b'\r' as usize);
#[allow(deprecated)]
sbi_rt::legacy::console_putchar(b'\n' as usize);
}
b'\r' => {
#[allow(deprecated)]
sbi_rt::legacy::console_putchar(b'\r' as usize);
}
_ => {
#[allow(deprecated)]
sbi_rt::legacy::console_putchar(c as usize);
}
}
}
}
Expand Down
63 changes: 63 additions & 0 deletions kernel/src/arch/riscv64/driver/vf2/dw_mshc/dma.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
use bitfield_struct::bitfield;

#[bitfield(u32)]
pub struct DES0 {
_reserved0: bool,
disable_interrupt_on_completion: bool,
last_decriptor: bool,
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'decriptor' to 'descriptor'.

Suggested change
last_decriptor: bool,
last_descriptor: bool,

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JensenWei007 这里需要小改一下

first_descriptor: bool,
second_address_chained: bool,
end_of_ring: bool,
#[bits(24)]
_reserved1: usize,
card_error_summary: bool,

// Is owned by the card.
own: bool,
}
#[bitfield(u32)]
pub struct DES1 {
#[bits(13)]
buffer_1_size: usize,
#[bits(13)]
buffer_2_size: usize,
#[bits(6)]
_reserved0: usize,
}
#[bitfield(u32)]
pub struct DES2 {
#[bits(32)]
pub buffer_addr1: usize,
}
#[bitfield(u32)]
pub struct DES3 {
#[bits(32)]
pub buffer_addr2: usize,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Descriptor {
pub des0: DES0,
pub des1: DES1,
pub des2: DES2,
pub des3: DES3,
}

#[allow(dead_code)]
impl Descriptor {
pub fn new(size: usize, buffer_paddr: usize, next_paddr: usize) -> Self {
Descriptor {
des0: DES0::new().with_second_address_chained(true).with_own(true),
des1: DES1::new().with_buffer_1_size(size),
des2: DES2::new().with_buffer_addr1(buffer_paddr),
des3: DES3::new().with_buffer_addr2(next_paddr),
}
}
pub fn own_by_card(&self) -> bool {
self.des0.own()
}
pub fn set_own_by_card(&mut self) {
self.des0.set_own(true);
}
}
Loading