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
2 changes: 1 addition & 1 deletion kernel-hal-bare/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description = "Kernel HAL implementation for bare metal environment."
log = "0.4"
spin = "0.5"
executor = { git = "https://github.com/PanQL/executor.git", rev="c86db90" }
trapframe = "0.1.6"
trapframe = "0.1.7"
kernel-hal = { path = "../kernel-hal" }
naive-timer= { git = "https://github.com/rcore-os/naive-timer.git", rev="cd44f4c" }
lazy_static = { version = "1.4", features = ["spin_no_std" ] }
Expand Down
2 changes: 1 addition & 1 deletion kernel-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ description = "Kernel HAL interface definations."

[dependencies]
bitflags = "1.2"
trapframe = "0.1.6"
trapframe = "0.1.7"
git-version = "0.3"
numeric-enum-macro = "0.2"
9 changes: 4 additions & 5 deletions zCore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ graphic = []
[dependencies]
log = "0.4"
spin = "0.5"
buddy_system_allocator = "0.3.9"
buddy_system_allocator = "0.4.0"
rlibc = "1.0"
rboot = { path = "../rboot", default-features = false }
kernel-hal-bare = { path = "../kernel-hal-bare" }
lazy_static = { version = "1.4", features = ["spin_no_std" ] }
bitmap-allocator = { git = "https://github.com/rcore-os/bitmap-allocator" }
trapframe = "0.1.6"
executor = { git = "https://github.com/PanQL/executor.git", rev="c86db90" }
bitmap-allocator = { git = "https://github.com/rcore-os/bitmap-allocator", rev = "03bd9909" }
trapframe = "0.1.7"
executor = { git = "https://github.com/PanQL/executor.git", rev = "c86db90" }
zircon-loader = { path = "../zircon-loader", default-features = false }
zircon-object = { path = "../zircon-object" }

[target.'cfg(target_arch = "x86_64")'.dependencies]
x86_64 = "0.10"
uart_16550 = "0.2"
34 changes: 3 additions & 31 deletions zCore/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use {
bitmap_allocator::BitAlloc,
buddy_system_allocator::{Heap, LockedHeapWithRescue},
buddy_system_allocator::LockedHeap,
rboot::{BootInfo, MemoryType},
spin::Mutex,
x86_64::structures::paging::page_table::{PageTable, PageTableFlags as EF},
Expand All @@ -17,7 +17,7 @@ static FRAME_ALLOCATOR: Mutex<FrameAlloc> = Mutex::new(FrameAlloc::DEFAULT);
const MEMORY_OFFSET: usize = 0;
const KERNEL_OFFSET: usize = 0xffffff00_00000000;
const PHYSICAL_MEMORY_OFFSET: usize = 0xffff8000_00000000;
const KERNEL_HEAP_SIZE: usize = 8 * 1024 * 1024; // 8 MB
const KERNEL_HEAP_SIZE: usize = 16 * 1024 * 1024; // 16 MB

const KERNEL_PM4: usize = (KERNEL_OFFSET >> 39) & 0o777;
const PHYSICAL_MEMORY_PM4: usize = (PHYSICAL_MEMORY_OFFSET >> 39) & 0o777;
Expand Down Expand Up @@ -79,36 +79,8 @@ pub extern "C" fn hal_pt_map_kernel(pt: &mut PageTable, current: &PageTable) {
pt[PHYSICAL_MEMORY_PM4].set_addr(ephysical.addr(), ephysical.flags() | EF::GLOBAL);
}

fn enlarge_heap(heap: &mut Heap) {
error!("Enlarging heap to avoid oom");

let mut addrs = [(0, 0); 32];
let mut addr_len = 0;
let va_offset = PMEM_BASE;
for _ in 0..16384 {
let page = hal_frame_alloc().unwrap();
let va = va_offset + page;
if addr_len > 0 {
let (ref mut addr, ref mut len) = addrs[addr_len - 1];
if *addr - PAGE_SIZE == va {
*len += PAGE_SIZE;
*addr -= PAGE_SIZE;
continue;
}
}
addrs[addr_len] = (va, PAGE_SIZE);
addr_len += 1;
}
for (addr, len) in addrs[..addr_len].iter() {
info!("Adding {:#X} {:#X} to heap", addr, len);
unsafe {
heap.init(*addr, *len);
}
}
}

/// Global heap allocator
///
/// Available after `memory::init_heap()`.
#[global_allocator]
static HEAP_ALLOCATOR: LockedHeapWithRescue = LockedHeapWithRescue::new(enlarge_heap);
static HEAP_ALLOCATOR: LockedHeap = LockedHeap::new();