nothing important
This commit is contained in:
parent
ffcb85dd5b
commit
d64c01d2b1
6 changed files with 28 additions and 19 deletions
|
|
@ -12,14 +12,16 @@ bitflags = "1.0.1"
|
|||
spin = "0.4"
|
||||
slab_allocator = "0.3.1"
|
||||
multiboot2 = { path = "multiboot2-elf64" } # added rsdp tag
|
||||
x86 = { path = "x86" } # forked for IA32
|
||||
# raw-cpuid = { path = "rust-cpuid" }
|
||||
|
||||
[dependencies.raw-cpuid]
|
||||
# need to use github/master because of features not yet on crates.io
|
||||
git = "https://github.com/gz/rust-cpuid"
|
||||
features = ["nightly"]
|
||||
|
||||
[dependencies.x86]
|
||||
# forked for IA32 compat
|
||||
path = "x86"
|
||||
|
||||
[dependencies.lazy_static]
|
||||
version = "1.0.0"
|
||||
features = ["spin_no_std"]
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ static GDT: Once<gdt::Gdt> = Once::new();
|
|||
static TSS: Once<tss::TaskStateSegment> = Once::new();
|
||||
|
||||
pub fn init() {
|
||||
let tss = tss::TaskStateSegment::new();
|
||||
let tss = TSS.call_once(|| {
|
||||
let tss = tss::TaskStateSegment::new();
|
||||
tss
|
||||
|
|
@ -39,6 +38,7 @@ pub fn init() {
|
|||
// reload code segment register
|
||||
set_cs(code_selector);
|
||||
// load TSS
|
||||
println!("loading tss {:?}", tss_selector);
|
||||
load_tss(tss_selector);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ exception!(overflow, {});
|
|||
exception!(bound_range, {});
|
||||
exception!(invalid_opcode, {});
|
||||
exception!(device_not_available, {});
|
||||
exception_err!(double_fault, {});
|
||||
exception_err!(double_fault, { panic!("double fault non recoverable") });
|
||||
exception!(coprocessor_segment_overrun, {});
|
||||
exception_err!(invalid_tss, {});
|
||||
exception_err!(segment_not_present, {});
|
||||
|
|
|
|||
|
|
@ -53,13 +53,17 @@ pub fn kmain() -> ! {
|
|||
|
||||
// x86::instructions::interrupts::int3();
|
||||
|
||||
// fn stack_overflow() { stack_overflow(); }
|
||||
// fn stack_overflow() {
|
||||
// stack_overflow();
|
||||
// }
|
||||
// stack_overflow();
|
||||
|
||||
// unsafe {
|
||||
// *(0xdead as *mut u32) = 42;
|
||||
// };
|
||||
|
||||
println!("tss: {:?}");
|
||||
|
||||
// vga is *not* cpu specific
|
||||
vga::init();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
mod bump;
|
||||
mod recycle;
|
||||
// mod stack_allocator;
|
||||
|
||||
use multiboot2;
|
||||
use x86::structures::paging::*;
|
||||
|
|
@ -7,6 +8,7 @@ use spin::Mutex;
|
|||
|
||||
use self::bump::BumpFrameAllocator;
|
||||
use self::recycle::RecycleAllocator;
|
||||
// use self::stack_allocator::StackAllocator;
|
||||
|
||||
pub trait FrameAllocator {
|
||||
fn allocate_frames(&mut self, size: usize) -> Option<PhysFrame>;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use x86::structures::paging::*;
|
||||
use memory::paging::{ActivePageTable};
|
||||
use memory::paging::ActivePageTable;
|
||||
use memory::*;
|
||||
use core::ops::Range;
|
||||
|
||||
|
|
@ -10,12 +10,9 @@ pub struct Stack {
|
|||
}
|
||||
|
||||
impl Stack {
|
||||
fn new (top: usize, bottom: usize) -> Stack {
|
||||
fn new(top: usize, bottom: usize) -> Stack {
|
||||
assert!(top > bottom);
|
||||
Stack {
|
||||
top,
|
||||
bottom,
|
||||
}
|
||||
Stack { top, bottom }
|
||||
}
|
||||
|
||||
pub fn top(&self) -> usize {
|
||||
|
|
@ -29,7 +26,7 @@ impl Stack {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct StackAllocator {
|
||||
range: Range<Page>
|
||||
range: Range<Page>,
|
||||
}
|
||||
|
||||
impl StackAllocator {
|
||||
|
|
@ -37,10 +34,12 @@ impl StackAllocator {
|
|||
StackAllocator { range }
|
||||
}
|
||||
|
||||
pub fn alloc_stack<FA: FrameAllocator>(&mut self,
|
||||
pub fn alloc_stack<FA: FrameAllocator>(
|
||||
&mut self,
|
||||
active_table: &mut ActivePageTable,
|
||||
frame_allocator: &mut FA,
|
||||
size_in_pages: usize) -> Option<Stack> {
|
||||
size_in_pages: usize,
|
||||
) -> Option<Stack> {
|
||||
if size_in_pages == 0 {
|
||||
return None; /* a zero sized stack makes no sense */
|
||||
}
|
||||
|
|
@ -71,8 +70,10 @@ impl StackAllocator {
|
|||
|
||||
// create a new stack
|
||||
let top_of_stack = end.start_address().as_u32() + PAGE_SIZE as u32;
|
||||
Some(Stack::new(top_of_stack as usize,
|
||||
start.start_address().as_u32() as usize))
|
||||
Some(Stack::new(
|
||||
top_of_stack as usize,
|
||||
start.start_address().as_u32() as usize,
|
||||
))
|
||||
}
|
||||
_ => None, /* not enough pages */
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue