nothing important

This commit is contained in:
Jack Halford 2018-04-15 11:48:51 +02:00
parent ffcb85dd5b
commit d64c01d2b1
6 changed files with 28 additions and 19 deletions

View file

@ -11,15 +11,17 @@ rlibc = "1.0"
bitflags = "1.0.1" bitflags = "1.0.1"
spin = "0.4" spin = "0.4"
slab_allocator = "0.3.1" slab_allocator = "0.3.1"
multiboot2 = { path = "multiboot2-elf64" } # added rsdp tag multiboot2 = { path = "multiboot2-elf64" } # added rsdp tag
x86 = { path = "x86" } # forked for IA32
# raw-cpuid = { path = "rust-cpuid" }
[dependencies.raw-cpuid] [dependencies.raw-cpuid]
# need to use github/master because of features not yet on crates.io # need to use github/master because of features not yet on crates.io
git = "https://github.com/gz/rust-cpuid" git = "https://github.com/gz/rust-cpuid"
features = ["nightly"] features = ["nightly"]
[dependencies.x86]
# forked for IA32 compat
path = "x86"
[dependencies.lazy_static] [dependencies.lazy_static]
version = "1.0.0" version = "1.0.0"
features = ["spin_no_std"] features = ["spin_no_std"]

View file

@ -8,7 +8,6 @@ static GDT: Once<gdt::Gdt> = Once::new();
static TSS: Once<tss::TaskStateSegment> = Once::new(); static TSS: Once<tss::TaskStateSegment> = Once::new();
pub fn init() { pub fn init() {
let tss = tss::TaskStateSegment::new();
let tss = TSS.call_once(|| { let tss = TSS.call_once(|| {
let tss = tss::TaskStateSegment::new(); let tss = tss::TaskStateSegment::new();
tss tss
@ -39,6 +38,7 @@ pub fn init() {
// reload code segment register // reload code segment register
set_cs(code_selector); set_cs(code_selector);
// load TSS // load TSS
println!("loading tss {:?}", tss_selector);
load_tss(tss_selector); load_tss(tss_selector);
} }
} }

View file

@ -54,7 +54,7 @@ exception!(overflow, {});
exception!(bound_range, {}); exception!(bound_range, {});
exception!(invalid_opcode, {}); exception!(invalid_opcode, {});
exception!(device_not_available, {}); exception!(device_not_available, {});
exception_err!(double_fault, {}); exception_err!(double_fault, { panic!("double fault non recoverable") });
exception!(coprocessor_segment_overrun, {}); exception!(coprocessor_segment_overrun, {});
exception_err!(invalid_tss, {}); exception_err!(invalid_tss, {});
exception_err!(segment_not_present, {}); exception_err!(segment_not_present, {});

View file

@ -53,13 +53,17 @@ pub fn kmain() -> ! {
// x86::instructions::interrupts::int3(); // x86::instructions::interrupts::int3();
// fn stack_overflow() { stack_overflow(); } // fn stack_overflow() {
// stack_overflow();
// }
// stack_overflow(); // stack_overflow();
// unsafe { // unsafe {
// *(0xdead as *mut u32) = 42; // *(0xdead as *mut u32) = 42;
// }; // };
println!("tss: {:?}");
// vga is *not* cpu specific // vga is *not* cpu specific
vga::init(); vga::init();

View file

@ -1,5 +1,6 @@
mod bump; mod bump;
mod recycle; mod recycle;
// mod stack_allocator;
use multiboot2; use multiboot2;
use x86::structures::paging::*; use x86::structures::paging::*;
@ -7,6 +8,7 @@ use spin::Mutex;
use self::bump::BumpFrameAllocator; use self::bump::BumpFrameAllocator;
use self::recycle::RecycleAllocator; use self::recycle::RecycleAllocator;
// use self::stack_allocator::StackAllocator;
pub trait FrameAllocator { pub trait FrameAllocator {
fn allocate_frames(&mut self, size: usize) -> Option<PhysFrame>; fn allocate_frames(&mut self, size: usize) -> Option<PhysFrame>;

View file

@ -1,5 +1,5 @@
use x86::structures::paging::*; use x86::structures::paging::*;
use memory::paging::{ActivePageTable}; use memory::paging::ActivePageTable;
use memory::*; use memory::*;
use core::ops::Range; use core::ops::Range;
@ -10,12 +10,9 @@ pub struct Stack {
} }
impl Stack { impl Stack {
fn new (top: usize, bottom: usize) -> Stack { fn new(top: usize, bottom: usize) -> Stack {
assert!(top > bottom); assert!(top > bottom);
Stack { Stack { top, bottom }
top,
bottom,
}
} }
pub fn top(&self) -> usize { pub fn top(&self) -> usize {
@ -29,7 +26,7 @@ impl Stack {
#[derive(Debug)] #[derive(Debug)]
pub struct StackAllocator { pub struct StackAllocator {
range: Range<Page> range: Range<Page>,
} }
impl StackAllocator { impl StackAllocator {
@ -37,10 +34,12 @@ impl StackAllocator {
StackAllocator { range } StackAllocator { range }
} }
pub fn alloc_stack<FA: FrameAllocator>(&mut self, pub fn alloc_stack<FA: FrameAllocator>(
active_table: &mut ActivePageTable, &mut self,
frame_allocator: &mut FA, active_table: &mut ActivePageTable,
size_in_pages: usize) -> Option<Stack> { frame_allocator: &mut FA,
size_in_pages: usize,
) -> Option<Stack> {
if size_in_pages == 0 { if size_in_pages == 0 {
return None; /* a zero sized stack makes no sense */ return None; /* a zero sized stack makes no sense */
} }
@ -71,8 +70,10 @@ impl StackAllocator {
// create a new stack // create a new stack
let top_of_stack = end.start_address().as_u32() + PAGE_SIZE as u32; let top_of_stack = end.start_address().as_u32() + PAGE_SIZE as u32;
Some(Stack::new(top_of_stack as usize, Some(Stack::new(
start.start_address().as_u32() as usize)) top_of_stack as usize,
start.start_address().as_u32() as usize,
))
} }
_ => None, /* not enough pages */ _ => None, /* not enough pages */
} }