Global allocator, page table - protected by spinlock
This commit is contained in:
parent
617516b949
commit
fda1ab2327
|
@ -5,6 +5,7 @@ version = "0.1.0"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "*"
|
bitflags = "*"
|
||||||
hole_list_allocator = { path = "../../alloc/hole_list_allocator"}
|
hole_list_allocator = { path = "../../alloc/hole_list_allocator"}
|
||||||
|
spin = "*"
|
||||||
|
|
||||||
[dependencies.x86]
|
[dependencies.x86]
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
|
@ -10,11 +10,13 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
extern crate hole_list_allocator as allocator;
|
extern crate hole_list_allocator as allocator;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
|
extern crate spin;
|
||||||
extern crate x86;
|
extern crate x86;
|
||||||
|
|
||||||
|
use spin::Mutex;
|
||||||
|
|
||||||
/// Print to console
|
/// Print to console
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! print {
|
macro_rules! print {
|
||||||
|
@ -106,3 +108,6 @@ pub mod start;
|
||||||
|
|
||||||
/// Task state segment
|
/// Task state segment
|
||||||
pub mod tss;
|
pub mod tss;
|
||||||
|
|
||||||
|
pub static ALLOCATOR: Mutex<Option<memory::AreaFrameAllocator>> = Mutex::new(None);
|
||||||
|
pub static PAGE_TABLE: Mutex<Option<paging::ActivePageTable>> = Mutex::new(None);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
pub use paging::{PAGE_SIZE, PhysicalAddress};
|
pub use paging::{PAGE_SIZE, PhysicalAddress};
|
||||||
|
|
||||||
use self::area_frame_alloc::AreaFrameAllocator;
|
pub use self::area_frame_alloc::AreaFrameAllocator;
|
||||||
|
|
||||||
pub mod area_frame_alloc;
|
pub mod area_frame_alloc;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ extern {
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern fn kstart() -> ! {
|
pub unsafe extern fn kstart() -> ! {
|
||||||
|
{
|
||||||
extern {
|
extern {
|
||||||
/// The starting byte of the _.bss_ (uninitialized data) segment.
|
/// The starting byte of the _.bss_ (uninitialized data) segment.
|
||||||
static mut __bss_start: u8;
|
static mut __bss_start: u8;
|
||||||
|
@ -63,6 +64,13 @@ pub unsafe extern fn kstart() -> ! {
|
||||||
active_table.map(page, paging::entry::WRITABLE, &mut allocator);
|
active_table.map(page, paging::entry::WRITABLE, &mut allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set global allocator
|
||||||
|
*::ALLOCATOR.lock() = Some(allocator);
|
||||||
|
|
||||||
|
// Set global page table
|
||||||
|
*::PAGE_TABLE.lock() = Some(active_table);
|
||||||
|
}
|
||||||
|
|
||||||
asm!("xchg bx, bx" : : : : "intel", "volatile");
|
asm!("xchg bx, bx" : : : : "intel", "volatile");
|
||||||
kmain();
|
kmain();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue