mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-21 00:06:32 +00:00
feat: 添加对内核引导协议的抽象 (#913)
* 添加multiboot header * head.S传参增加bootloader类型 * feat: 添加引导加载协议的抽象,并为multiboot2实现这个抽象. * 把framebuffer的映射地址改为从early ioremap和mmio pool分配 * riscv64能运行
This commit is contained in:
@ -684,6 +684,34 @@ impl MMIOSpaceGuard {
|
||||
return r;
|
||||
}
|
||||
|
||||
/// 将物理地址填写到虚拟地址空间中
|
||||
///
|
||||
/// ## Safety
|
||||
///
|
||||
/// 传入的物理地址【一定要是设备的物理地址】。
|
||||
/// 如果物理地址是从内存分配器中分配的,那么会造成内存泄露。因为mmio_release的时候,只取消映射,不会释放内存。
|
||||
pub unsafe fn map_phys_with_flags(
|
||||
&self,
|
||||
paddr: PhysAddr,
|
||||
length: usize,
|
||||
flags: EntryFlags<MMArch>,
|
||||
) -> Result<(), SystemError> {
|
||||
if length > self.size {
|
||||
return Err(SystemError::EINVAL);
|
||||
}
|
||||
|
||||
let check = self
|
||||
.mapped
|
||||
.compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst);
|
||||
if check.is_err() {
|
||||
return Err(SystemError::EINVAL);
|
||||
}
|
||||
|
||||
let mut kernel_mapper = KernelMapper::lock();
|
||||
let r = kernel_mapper.map_phys_with_size(self.vaddr, paddr, length, flags, true);
|
||||
return r;
|
||||
}
|
||||
|
||||
/// # map_any_phys - 将任意物理地址映射到虚拟地址
|
||||
///
|
||||
/// 将指定的物理地址和长度映射到虚拟地址空间。
|
||||
|
Reference in New Issue
Block a user