@gz merged rust-cpuid PR so i can get rid of my fork

This commit is contained in:
Jack Halford 2018-04-05 19:04:05 +02:00
parent 24fa39d45c
commit b7855ae56c
9 changed files with 33 additions and 28 deletions

View file

@ -4,6 +4,3 @@
[submodule "x86"] [submodule "x86"]
path = x86 path = x86
url = https://github.com/jzck/x86.git url = https://github.com/jzck/x86.git
[submodule "rust-cpuid"]
path = rust-cpuid
url = https://github.com/jzck/rust-cpuid

View file

@ -13,10 +13,12 @@ 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 x86 = { path = "x86" } # forked for IA32
raw-cpuid = { path = "rust-cpuid" } # forked for IA32
[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.lazy_static] [dependencies.lazy_static]
version = "1.0.0" version = "1.0.0"
features = ["spin_no_std"] features = ["spin_no_std"]

@ -1 +0,0 @@
Subproject commit 07299b93df57fcee2b6aec61502a5135b99967f8

View file

@ -1 +1,3 @@
// we only support a single architecture at the moment
// more specifically IA-32 (aka i386) but we name it x86 here.
pub mod x86; pub mod x86;

View file

@ -1,9 +1,13 @@
// https://wiki.osdev.org/Exceptions // https://wiki.osdev.org/Exceptions
use ::arch::x86::pti;
macro_rules! exception { macro_rules! exception {
($name:ident, $func:block) => { ($name:ident, $func:block) => {
pub extern "x86-interrupt" fn $name(stack_frame: &mut ExceptionStackFrame) pub extern "x86-interrupt" fn $name(stack_frame: &mut ExceptionStackFrame)
{ {
// unsafe { pti::map(); }
println!("Exception: {}", stringify!($name)); println!("Exception: {}", stringify!($name));
println!("{:#?}", stack_frame); println!("{:#?}", stack_frame);
flush!(); flush!();
@ -13,6 +17,8 @@ macro_rules! exception {
$func $func
} }
inner(stack_frame); inner(stack_frame);
// unsafe { pti::unmap(); }
} }
} }
} }
@ -37,13 +43,13 @@ macro_rules! exception_err {
use x86::structures::idt::*; use x86::structures::idt::*;
exception!(divide_by_zero, {}); exception!(divide_by_zero, {
panic!("CPU exception: division by zero");
});
exception!(debug, {}); exception!(debug, {});
exception!(non_maskable, {}); exception!(non_maskable, {});
exception!(breakpoint, { exception!(breakpoint, {});
println!("testing here dont mind me");
flush!();
});
exception!(overflow, {}); exception!(overflow, {});
exception!(bound_range, {}); exception!(bound_range, {});
exception!(invalid_opcode, {}); exception!(invalid_opcode, {});

View file

@ -4,6 +4,7 @@ extern crate x86;
pub mod paging; pub mod paging;
pub mod interrupt; pub mod interrupt;
pub mod device; pub mod device;
pub mod pti;
pub mod idt; pub mod idt;

View file

@ -20,7 +20,7 @@ fn dispatch(command: &str) -> Result <(), &'static str> {
"reboot" => self::reboot(), "reboot" => self::reboot(),
"shutdown" | "halt" | "q" => self::shutdown(), "shutdown" | "halt" | "q" => self::shutdown(),
// others // x86 specific
"stack" => self::print_stack(), "stack" => self::print_stack(),
"regs" => self::regs(), "regs" => self::regs(),
"cpu" => self::cpu(), "cpu" => self::cpu(),
@ -117,7 +117,6 @@ fn print_line(line: &[u8], address: usize) {
} }
/// Print the kernel stack /// Print the kernel stack
///
fn print_stack() -> Result <(), &'static str> { fn print_stack() -> Result <(), &'static str> {
let esp: usize; let esp: usize;
let ebp: usize; let ebp: usize;
@ -130,7 +129,7 @@ fn print_stack() -> Result <(), &'static str> {
} }
// fn mb2_memory() -> Result <(), &'static str> { // fn mb2_memory() -> Result <(), &'static str> {
// let boot_info = context::boot_info(); // let boot_info = ::multiboot2::boot_info();
// let memory_map_tag = boot_info.memory_map_tag() // let memory_map_tag = boot_info.memory_map_tag()
// .expect("Memory map tag required"); // .expect("Memory map tag required");
@ -144,7 +143,7 @@ fn print_stack() -> Result <(), &'static str> {
// } // }
// fn mb2_sections() -> Result <(), &'static str> { // fn mb2_sections() -> Result <(), &'static str> {
// let boot_info = context::boot_info(); // let boot_info = ::multiboot2::boot_info();
// let elf_sections_tag = boot_info.elf_sections_tag() // let elf_sections_tag = boot_info.elf_sections_tag()
// .expect("Elf-sections tag required"); // .expect("Elf-sections tag required");
@ -178,15 +177,17 @@ pub fn acpi_info() -> Result <(), &'static str> {
Ok(()) Ok(())
} }
/// Dump control registers
pub fn regs() -> Result <(), &'static str> { pub fn regs() -> Result <(), &'static str> {
use ::x86::registers::control::*; use ::x86::registers::control::*;
println!("cr0={:#b}", Cr0::read()); println!("cr0 = {:?}", Cr0::read());
println!("cr3={:?}", Cr3::read()); println!("cr3 = {:?}", Cr3::read());
println!("cr4={:?}", Cr4::read()); println!("cr4 = {:?}", Cr4::read());
flush!(); flush!();
Ok(()) Ok(())
} }
/// Dump cpu info, should add power management info
pub fn cpu() -> Result <(), &'static str> { pub fn cpu() -> Result <(), &'static str> {
use ::arch::x86::device::cpu; use ::arch::x86::device::cpu;
cpu::cpu_info().expect("cpu info not available"); cpu::cpu_info().expect("cpu info not available");

View file

@ -91,11 +91,6 @@ pub fn kbd_callback() {
0x2A | 0x36 => {SHIFT = !is_release}, 0x2A | 0x36 => {SHIFT = !is_release},
0x38 => {ALT = !is_release}, 0x38 => {ALT = !is_release},
0x1D => {CTRL = !is_release}, 0x1D => {CTRL = !is_release},
// terminal switching
// 0x0F if !is_release => {
// context::switch_term();
// context::current_term().flush();
// },
0x0E if !is_release => { 0x0E if !is_release => {
vga::VGA.backspace(); vga::VGA.backspace();
} }

View file

@ -1,23 +1,25 @@
//! project hosted on [github](https://github.com/jzck/kernel) //! project hosted on [github](https://github.com/jzck/kernel)
//! exclusively x86
//! // nightly stuff we need
#![no_std] #![no_std]
#![feature(lang_items)] #![feature(lang_items)]
#![feature(const_fn)] #![feature(const_fn)]
#![feature(ptr_internals)] #![feature(ptr_internals)]
#![feature(asm)] #![feature(asm)]
#![feature(thread_local)]
// home made heap
#![feature(alloc)] #![feature(alloc)]
#![feature(allocator_api)] #![feature(allocator_api)]
#![feature(global_allocator)] #![feature(global_allocator)]
// x86 specific
#![feature(abi_x86_interrupt)] #![feature(abi_x86_interrupt)]
extern crate rlibc; extern crate rlibc;
// #[macro_use]
extern crate alloc; extern crate alloc;
#[macro_use] extern crate lazy_static;
extern crate spin; extern crate spin;
#[macro_use] extern crate lazy_static;
extern crate multiboot2; extern crate multiboot2;
extern crate slab_allocator; extern crate slab_allocator;
extern crate raw_cpuid; extern crate raw_cpuid;