Skip to content

Commit ac9ed0d

Browse files
committed
更新 axplat-aarch64-dyn 平台的依赖项,添加驱动程序注册功能,优化内存管理,完善电源管理接口。
1 parent a5b4eb5 commit ac9ed0d

File tree

9 files changed

+334
-18
lines changed

9 files changed

+334
-18
lines changed

Cargo.lock

Lines changed: 182 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platforms/axplat-aarch64-dyn/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ axcpu = {workspace = true}
1616
axplat = {workspace = true}
1717
fdt-parser = "0.4"
1818
heapless = "0.8"
19+
log = "0.4"
1920
memory_addr = "0.3"
20-
pie-boot = {version = "0.2.6"}
21+
pie-boot = {version = "0.2.7"}
22+
rdrive = "0.14"
23+
smccc = "0.2"
2124
spin = "0.10"

platforms/axplat-aarch64-dyn/link.ld

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ SECTIONS
3737
_sdata = .;
3838
*(.data.boot_page_table)
3939
. = ALIGN(4K);
40+
41+
__sdriver_register = .;
42+
KEEP(*(.driver.register*))
43+
__edriver_register = .;
44+
4045
*(.data .data.*)
4146
*(.sdata .sdata.*)
4247
*(.got .got.*)

platforms/axplat-aarch64-dyn/src/console.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use core::ptr::NonNull;
2-
31
use any_uart::{Receiver, Sender};
42
use axplat::console::ConsoleIf;
53
use fdt_parser::Fdt;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use core::ops::Deref;
2+
3+
use pie_boot::boot_info;
4+
use rdrive::{
5+
Platform, init,
6+
register::{DriverRegister, DriverRegisterSlice},
7+
register_append,
8+
};
9+
10+
pub fn setup() {
11+
let fdt = boot_info().fdt.expect("FDT must be present");
12+
13+
init(Platform::Fdt { addr: fdt }).unwrap();
14+
15+
register_append(&driver_registers());
16+
}
17+
18+
fn driver_registers() -> impl Deref<Target = [DriverRegister]> {
19+
unsafe extern "C" {
20+
fn __sdriver_register();
21+
fn __edriver_register();
22+
}
23+
24+
unsafe {
25+
let len = __edriver_register as usize - __sdriver_register as usize;
26+
27+
if len == 0 {
28+
return DriverRegisterSlice::empty();
29+
}
30+
31+
let data = core::slice::from_raw_parts(__sdriver_register as _, len);
32+
33+
DriverRegisterSlice::from_raw(data)
34+
}
35+
}

platforms/axplat-aarch64-dyn/src/init.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use axplat::init::InitIf;
22

3-
use crate::console;
3+
use crate::{console, driver};
44

55
struct InitIfImpl;
66

@@ -68,13 +68,11 @@ impl InitIf for InitIfImpl {
6868
/// * Timer interrupts are enabled (if applicable).
6969
/// * Other platform devices are initialized.
7070
fn init_later(cpu_id: usize, arg: usize) {
71-
71+
driver::setup();
7272
}
7373

7474
/// Initializes the platform at the later stage for secondary cores.
7575
///
7676
/// See [`init_later`] for details.
77-
fn init_later_secondary(cpu_id: usize) {
78-
79-
}
77+
fn init_later_secondary(cpu_id: usize) {}
8078
}

platforms/axplat-aarch64-dyn/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33

44
#[macro_use]
55
extern crate axplat;
6+
extern crate alloc;
67

78
use pie_boot::BootInfo;
89

910
mod console;
11+
mod driver;
1012
mod init;
1113
mod irq;
1214
mod mem;
@@ -19,8 +21,5 @@ mod config {
1921

2022
#[pie_boot::entry]
2123
fn main(args: &BootInfo) -> ! {
22-
axplat::call_main(
23-
args.cpu_id,
24-
args.fdt.map(|p| p.as_ptr() as usize).unwrap_or_default(),
25-
);
24+
axplat::call_main(0, args.fdt.map(|p| p.as_ptr() as usize).unwrap_or_default());
2625
}

platforms/axplat-aarch64-dyn/src/mem.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use axplat::mem::{MemIf, RawRange};
44
use heapless::Vec;
55
use memory_addr::{MemoryAddr, PhysAddr, VirtAddr};
66
use pie_boot::{KIMAGE_VADDR, KLINER_OFFSET, MemoryRegionKind, boot_info};
7-
use spin::{Mutex, Once, RwLock};
7+
use spin::Once;
88

99
struct MemIfImpl;
1010

@@ -47,7 +47,7 @@ pub fn setup() {
4747
MemoryRegionKind::Reserved | MemoryRegionKind::Bootloader
4848
)
4949
})
50-
.map(|one| (one.start, one.end - one.start))
50+
.map(|one| (one.start, one.end.align_up_4k() - one.start))
5151
{
5252
let _ = ram_list.push(region);
5353
}

0 commit comments

Comments
 (0)