Skip to content

Commit b145688

Browse files
committed
更新内存管理逻辑,修复保留列表的初始化,调整 CPU 启动信息的日志格式,并启用定时器中断
1 parent b06c6e7 commit b145688

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,15 @@ pub fn setup() {
3636
});
3737

3838
RESERVED_LIST.call_once(|| {
39-
let mut ram_list = Vec::new();
39+
let mut rsv_list = Vec::new();
40+
41+
unsafe extern "C" {
42+
fn _skernel();
43+
}
44+
let head_start = boot_info().kimage_start_lma as usize;
45+
let head_section = (head_start, (_skernel as usize) - va_offset() - head_start);
46+
47+
rsv_list.push(head_section);
4048

4149
for region in boot_info()
4250
.memory_regions
@@ -49,9 +57,9 @@ pub fn setup() {
4957
})
5058
.map(|one| (one.start, one.end.align_up_4k() - one.start))
5159
{
52-
let _ = ram_list.push(region);
60+
let _ = rsv_list.push(region);
5361
}
54-
ram_list
62+
rsv_list
5563
});
5664

5765
MMIO.call_once(|| {
@@ -110,11 +118,10 @@ impl MemIf for MemIfImpl {
110118

111119
fn kimage_range_phys() -> Range<PhysAddr> {
112120
unsafe extern "C" {
113-
fn _skernel();
114121
fn _ekernel();
115122
}
116123

117-
let start = PhysAddr::from_usize(KIMAGE_VADDR - va_offset());
124+
let start = PhysAddr::from_usize(boot_info().kimage_start_lma as usize);
118125
let end = PhysAddr::from_usize(_ekernel as usize - va_offset());
119126
start..end
120127
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ impl PowerIf for PowerImpl {
2727
let cpu_id = crate::smp::cpu_idx_to_id(cpu_idx);
2828
let entry = crate::smp::secondary_entry_phys_addr();
2929
info!(
30-
"booting CPU {cpu_id} with entry {:#x} and stack top {:#x}",
31-
entry, stack_top_paddr
30+
"booting CPU{cpu_idx} id {cpu_id:#x} with entry {entry:#x} and stack top {stack_top_paddr:#x}",
3231
);
3332
dcache_all(CacheOp::CleanAndInvalidate);
3433
cpu_on(cpu_id as _, entry.as_usize() as _, stack_top_paddr as _).unwrap();

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use aarch64_cpu_ext::cache::{CacheOp, dcache_all};
12
use alloc::vec::Vec;
23
use axplat::mem::{PhysAddr, va, virt_to_phys};
34
use fdt_parser::Status;
@@ -25,19 +26,19 @@ pub fn init() {
2526
ls
2627
});
2728

28-
debug!("CPU ID list: {:?}", CPU_ID_LIST.wait());
29+
debug!("CPU ID list: {:#x?}", CPU_ID_LIST.wait());
2930

3031
if CPU_ID_LIST.wait().len() < CPU_NUM {
3132
panic!(
32-
"CPU count {} is less than expected `cpu_num` in `.axconfig.toml`{}",
33+
"CPU count {} is less than expected `cpu_num` in `.axconfig.toml` is {}",
3334
CPU_ID_LIST.wait().len(),
3435
CPU_NUM
3536
);
3637
}
3738

3839
if CPU_ID_LIST.wait().len() > CPU_NUM {
3940
info!(
40-
"CPU count {} is more than expected `cpu_num` in `.axconfig.toml`{}",
41+
"CPU count {} is more than expected `cpu_num` in `.axconfig.toml` is {}",
4142
CPU_ID_LIST.wait().len(),
4243
CPU_NUM
4344
);
@@ -128,6 +129,7 @@ unsafe extern "C" fn _start_secondary() -> ! {
128129
}
129130

130131
fn _secondary_main(cpu_id: usize) -> ! {
132+
dcache_all(CacheOp::CleanAndInvalidate);
131133
let cpu_idx = cpu_id_to_idx(cpu_id);
132134
axplat::call_secondary_main(cpu_idx)
133135
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub fn enable_irqs() {
7171
"axconfig.toml `timer-irq` must match the IRQ number used in the driver"
7272
);
7373

74-
crate::irq::set_enable(irq_raw, Some(TIMER_IRQ_CONFIG.trigger), false);
74+
crate::irq::set_enable(irq_raw, Some(TIMER_IRQ_CONFIG.trigger), true);
7575
}
7676

7777
module_driver!(

0 commit comments

Comments
 (0)