mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-20 10:06:31 +00:00
新的内存管理模块 (#301)
  实现了具有优秀架构设计的新的内存管理模块,对内核空间和用户空间的内存映射、分配、释放、管理等操作进行了封装,使得内核开发者可以更加方便地进行内存管理。   内存管理模块主要由以下类型的组件组成: - **硬件抽象层(MemoryManagementArch)** - 提供对具体处理器架构的抽象,使得内存管理模块可以在不同的处理器架构上运行 - **页面映射器(PageMapper)**- 提供对虚拟地址和物理地址的映射,以及页表的创建、填写、销毁、权限管理等操作。分为两种类型:内核页表映射器(KernelMapper)和用户页表映射器(位于具体的用户地址空间结构中) - **页面刷新器(PageFlusher)** - 提供对页表的刷新操作(整表刷新、单页刷新、跨核心刷新) - **页帧分配器(FrameAllocator)** - 提供对页帧的分配、释放、管理等操作。具体来说,包括BumpAllocator、BuddyAllocator - **小对象分配器** - 提供对小内存对象的分配、释放、管理等操作。指的是内核里面的SlabAllocator (SlabAllocator的实现目前还没有完成) - **MMIO空间管理器** - 提供对MMIO地址空间的分配、管理操作。(目前这个模块待进一步重构) - **用户地址空间管理机制** - 提供对用户地址空间的管理。 - VMA机制 - 提供对用户地址空间的管理,包括VMA的创建、销毁、权限管理等操作 - 用户映射管理 - 与VMA机制共同作用,管理用户地址空间的映射 - **系统调用层** - 提供对用户空间的内存管理系统调用,包括mmap、munmap、mprotect、mremap等 - **C接口兼容层** - 提供对原有的C代码的接口,是的C代码能够正常运行。 除上面的新增内容以外,其它的更改内容: - 新增二进制加载器,以及elf的解析器 - 解决由于local_irq_save、local_irq_restore函数的汇编不规范导致影响栈行为的bug。 - 解决local_irq_save未关中断的错误。 - 修复sys_gettimeofday对timezone参数的处理的bug
This commit is contained in:
@ -1,13 +1,18 @@
|
||||
#![no_std] // <1>
|
||||
#![no_main] // <1>
|
||||
#![feature(alloc_error_handler)]
|
||||
#![feature(allocator_api)]
|
||||
#![feature(arbitrary_self_types)]
|
||||
#![feature(const_mut_refs)]
|
||||
#![feature(core_intrinsics)] // <2>
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(c_void_variant)]
|
||||
#![feature(drain_filter)] // 允许Vec的drain_filter特性
|
||||
#![feature(drain_filter)]
|
||||
#![feature(panic_info_message)]
|
||||
#![feature(ptr_internals)]
|
||||
#![feature(trait_upcasting)]
|
||||
#![feature(slice_ptr_get)]
|
||||
#![feature(vec_into_raw_parts)]
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(non_snake_case)]
|
||||
@ -37,6 +42,7 @@ mod time;
|
||||
extern crate alloc;
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
extern crate elf;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
extern crate num;
|
||||
@ -44,11 +50,10 @@ extern crate num;
|
||||
extern crate num_derive;
|
||||
extern crate smoltcp;
|
||||
extern crate thingbuf;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
extern crate x86;
|
||||
|
||||
use mm::allocator::KernelAllocator;
|
||||
use crate::mm::allocator::kernel_allocator::KernelAllocator;
|
||||
|
||||
// <3>
|
||||
use crate::{
|
||||
@ -59,7 +64,7 @@ use crate::{
|
||||
|
||||
// 声明全局的slab分配器
|
||||
#[cfg_attr(not(test), global_allocator)]
|
||||
pub static KERNEL_ALLOCATOR: KernelAllocator = KernelAllocator {};
|
||||
pub static KERNEL_ALLOCATOR: KernelAllocator = KernelAllocator;
|
||||
|
||||
/// 全局的panic处理函数
|
||||
#[panic_handler]
|
||||
|
Reference in New Issue
Block a user