forked from AbleOS/ableos
Moved allocator to the kernel
This commit is contained in:
parent
351236159f
commit
ae70548cc0
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -384,6 +384,7 @@ dependencies = [
|
|||
name = "kernel"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"linked_list_allocator",
|
||||
"log",
|
||||
"versioning",
|
||||
]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::allocator::{HEAP_SIZE, HEAP_START};
|
||||
use kernel::allocator::{HEAP_SIZE, HEAP_START};
|
||||
use alloc::alloc::{GlobalAlloc, Layout};
|
||||
use core::ptr::null_mut;
|
||||
use x86_64::{
|
||||
|
@ -39,7 +39,7 @@ pub fn init_heap(
|
|||
}
|
||||
|
||||
unsafe {
|
||||
crate::allocator::ALLOCATOR
|
||||
kernel::allocator::ALLOCATOR
|
||||
.lock()
|
||||
.init(HEAP_START, HEAP_SIZE);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use super::systeminfo::SystemMemory;
|
||||
use crate::{arch::drivers::sysinfo::master, ALLOCATOR};
|
||||
use crate::arch::drivers::sysinfo::master;
|
||||
use core::fmt::Display;
|
||||
use kernel::allocator::ALLOCATOR;
|
||||
use versioning::Version;
|
||||
use x86_64::instructions::interrupts::{disable, enable};
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ pub mod print;
|
|||
#[macro_use]
|
||||
pub mod serial_print;
|
||||
|
||||
pub mod allocator;
|
||||
pub mod boot_conf;
|
||||
pub mod devices;
|
||||
pub mod driver_traits;
|
||||
|
@ -68,7 +67,6 @@ mod unicode_utils;
|
|||
#[prelude_import]
|
||||
pub use prelude::rust_2021::*;
|
||||
|
||||
pub use allocator::*;
|
||||
pub use driver_traits::*;
|
||||
pub use experiments::*;
|
||||
pub use graphics::*;
|
||||
|
|
|
@ -2,13 +2,13 @@ use crate::arch::drivers::sysinfo::master;
|
|||
use crate::filesystem::FILE_SYSTEM;
|
||||
use crate::time::fetch_time;
|
||||
use crate::wasm_jumploader::interp;
|
||||
use crate::ALLOCATOR;
|
||||
use crate::{
|
||||
arch::{shutdown, sloop},
|
||||
systeminfo::{KERNEL_VERSION, RELEASE_TYPE},
|
||||
KERNEL_STATE,
|
||||
};
|
||||
use genfs::{Fs, OpenOptions};
|
||||
use kernel::allocator::ALLOCATOR;
|
||||
use rhai::Engine;
|
||||
use spin::Lazy;
|
||||
use x86_64::instructions::interrupts::{disable, enable};
|
||||
|
|
|
@ -4,7 +4,8 @@ name = "kernel"
|
|||
version = "0.1.2"
|
||||
|
||||
[dependencies]
|
||||
linked_list_allocator = "0.9"
|
||||
log = "0.4.14"
|
||||
|
||||
[dependencies.versioning]
|
||||
git = "https://git.ablecorp.us/able/aos_userland"
|
||||
git = "https://git.ablecorp.us/able/aos_userland"
|
||||
|
|
24
kernel/src/allocator.rs
Normal file
24
kernel/src/allocator.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
//! Memory allocator
|
||||
|
||||
use linked_list_allocator::LockedHeap;
|
||||
|
||||
///
|
||||
pub const HEAP_START: usize = 0x_4444_4444_0000;
|
||||
|
||||
///
|
||||
pub const HEAP_MULTIPLIER: usize = 100000;
|
||||
|
||||
///
|
||||
pub const HEAP_BASE: usize = 100;
|
||||
|
||||
///
|
||||
pub const HEAP_SIZE: usize = HEAP_BASE * HEAP_MULTIPLIER;
|
||||
|
||||
/// Global allocator
|
||||
#[global_allocator]
|
||||
pub static ALLOCATOR: LockedHeap = LockedHeap::empty();
|
||||
|
||||
#[alloc_error_handler]
|
||||
fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! {
|
||||
panic!("allocation error: {:?}", layout)
|
||||
}
|
|
@ -1,10 +1,14 @@
|
|||
//! The ableOS kernel.
|
||||
|
||||
#![deny(missing_docs)]
|
||||
#![no_std]
|
||||
#![feature(prelude_import)]
|
||||
#![feature(alloc_error_handler)]
|
||||
#![feature(arbitrary_enum_discriminant)]
|
||||
#![feature(prelude_import)]
|
||||
#![no_std]
|
||||
#![deny(missing_docs)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
pub mod allocator;
|
||||
pub mod device_interface;
|
||||
pub mod messaging;
|
||||
pub mod panic;
|
||||
|
|
Loading…
Reference in a new issue