added multiboot as a local crate

This commit is contained in:
Jack Halford 2018-02-28 15:10:17 +01:00
parent 7d08ddf53c
commit 52af278a91
8 changed files with 54 additions and 71 deletions

3
kernel-rs/.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "multiboot2-elf64"]
path = multiboot2-elf64
url = git@github.com:jzck/multiboot2-elf64.git

View file

@ -8,4 +8,4 @@ crate-type = ["staticlib"]
[dependencies]
rlibc = "1.0"
multiboot2 = "0.1.0"
multiboot2 = { path = "multiboot2-elf64" }

@ -0,0 +1 @@
Subproject commit 4d6ad9cde926f2ad5d47041e3f3a2cda18f8e11e

View file

@ -50,37 +50,37 @@ GDTR:
DB 0xCF ; [ Flags: C=1100b = (granularity)|(32bit)|(!64bit)|(0) ] / [ Limits: (bits 16-19): F=1111b ]
DB 0x0 ; Base ( bits 24 -31 )
; .gdt_ss: equ $ - .gdt_top; the stack segment Aka KERNEL STACK
; DW 0x0 ; Limit ( bits 0 -15 )
; DW 0x0 ; Base ( bits 0 -15 )
; DB 0x0 ; Base ( bits 16 -23 )
; DB 0x96 ; [ Access Flags: 0x96=10010110b = (present)|(Privilege Ring 0=00b)|(1)|(data => 0)|(expand up => 1)|(readable)|(0) ]
; DB 0xCF ; [ Flags: C=1100b = (granularity)|(32bit)|(!64bit)|(0) ] / [ Limits: (bits 16-19): F=1111b ]
; DB 0x0 ; Base ( bits 24 -31 )
.gdt_ss: equ $ - .gdt_top; the stack segment Aka KERNEL STACK
DW 0x0 ; Limit ( bits 0 -15 )
DW 0x0 ; Base ( bits 0 -15 )
DB 0x0 ; Base ( bits 16 -23 )
DB 0x96 ; [ Access Flags: 0x96=10010110b = (present)|(Privilege Ring 0=00b)|(1)|(data => 0)|(expand up => 1)|(readable)|(0) ]
DB 0xCF ; [ Flags: C=1100b = (granularity)|(32bit)|(!64bit)|(0) ] / [ Limits: (bits 16-19): F=1111b ]
DB 0x0 ; Base ( bits 24 -31 )
; .gdt_es: equ $ - .gdt_top; the extra segment Aka USER CODE
; DW 0xffff ; Limit ( bits 0 -15 )
; DW 0x0 ; Base ( bits 0 -15 )
; DB 0x0 ; Base ( bits 16 -23 )
; DB 0xFE ; [ Access Flags: 0x9A=11111110b = (present)|(Privilege Ring 3=11b)|(1)|(code => 1)|(expand up => 1)|(readable)|(0) ]
; DB 0xCF ; [ Flags: C=1100b = (granularity)|(32bit)|(!64bit)|(0) ] / [ Limits: (bits 16-19): F=1111b ]
; DB 0x0 ; Base ( bits 24 -31 )
.gdt_es: equ $ - .gdt_top; the extra segment Aka USER CODE
DW 0xffff ; Limit ( bits 0 -15 )
DW 0x0 ; Base ( bits 0 -15 )
DB 0x0 ; Base ( bits 16 -23 )
DB 0xFE ; [ Access Flags: 0x9A=11111110b = (present)|(Privilege Ring 3=11b)|(1)|(code => 1)|(expand up => 1)|(readable)|(0) ]
DB 0xCF ; [ Flags: C=1100b = (granularity)|(32bit)|(!64bit)|(0) ] / [ Limits: (bits 16-19): F=1111b ]
DB 0x0 ; Base ( bits 24 -31 )
; .gdt_fs: equ $ - .gdt_top; the other segment Aka USER DATA
; DW 0xffff ; Limit ( bits 0 -15 )
; DW 0x0 ; Base ( bits 0 -15 )
; DB 0x0 ; Base ( bits 16 -23 )
; DB 0xF2 ; [ Access Flags: 0x9A=11110010b = (present)|(Privilege Ring 3=11b)|(1)|(data => 0)|(expand down => 0)|(readable)|(0) ]
; DB 0xCF ; [ Flags: C=1100b = (granularity)|(32bit)|(!64bit)|(0) ] / [ Limits: (bits 16-19): F=1111b ]
; DB 0x0 ; Base ( bits 24 -31 )
.gdt_fs: equ $ - .gdt_top; the other segment Aka USER DATA
DW 0xffff ; Limit ( bits 0 -15 )
DW 0x0 ; Base ( bits 0 -15 )
DB 0x0 ; Base ( bits 16 -23 )
DB 0xF2 ; [ Access Flags: 0x9A=11110010b = (present)|(Privilege Ring 3=11b)|(1)|(data => 0)|(expand down => 0)|(readable)|(0) ]
DB 0xCF ; [ Flags: C=1100b = (granularity)|(32bit)|(!64bit)|(0) ] / [ Limits: (bits 16-19): F=1111b ]
DB 0x0 ; Base ( bits 24 -31 )
; .gdt_gs: equ $ - .gdt_top; the other segment Aka USER STACK
; DW 0x0 ; Limit ( bits 0 -15 )
; DW 0x0 ; Base ( bits 0 -15 )
; DB 0x0 ; Base ( bits 16 -23 )
; DB 0x00 ; [ Access Flags: 0x9A=11110110b = (present)|(Privilege Ring 3=11b)|(1)|(data => 0)|(expand up => 1)|(readable)|(0) ]
; DB 0x00 ; [ Flags: C=1100b = (granularity)|(32bit)|(!64bit)|(0) ] / [ Limits: (bits 16-19): F=1111b ]
; DB 0x0 ; Base ( bits 24 -31 )
.gdt_gs: equ $ - .gdt_top; the other segment Aka USER STACK
DW 0x0 ; Limit ( bits 0 -15 )
DW 0x0 ; Base ( bits 0 -15 )
DB 0x0 ; Base ( bits 16 -23 )
DB 0x00 ; [ Access Flags: 0x9A=11110110b = (present)|(Privilege Ring 3=11b)|(1)|(data => 0)|(expand up => 1)|(readable)|(0) ]
DB 0x00 ; [ Flags: C=1100b = (granularity)|(32bit)|(!64bit)|(0) ] / [ Limits: (bits 16-19): F=1111b ]
DB 0x0 ; Base ( bits 24 -31 )
.gdt_bottom:
.ptr:

View file

@ -5,8 +5,8 @@ section .text
bits 32
x86_start:
mov ax, 0x10 ; 16 bytes (0x10) is where the offset for data section (gdt_ds)
mov ss, ax
mov ds, ax
mov ss, ax
mov es, ax
mov fs, ax
mov gs, ax

View file

@ -49,7 +49,7 @@ fn is_control(c: char) -> bool {
}
fn print_line(line: &[u8], address: usize) {
print!("\n{:08x}: ", address);
print!("\n{:#08x}: ", address);
for byte in line {
print!("{:02x} ", *byte);
}

View file

@ -7,7 +7,7 @@
#![feature(asm)] //needed by cpuio for inline asm
extern crate rlibc;
extern crate multiboot2;
extern crate multiboot2; //slightly modified fork from official 0.3.2
/// 80x25 screen and simplistic terminal driver
#[macro_use] pub mod vga;
@ -23,51 +23,31 @@ pub mod cpuio;
use context::CONTEXT;
#[no_mangle]
pub extern fn kmain(multiboot_information_address: usize) -> ! {
// use vga::{Color, ColorCode};
// unsafe { CONTEXT.current_term().color_code = ColorCode::new(Color::White, Color::Cyan); }
// print!("{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
// format_args!("{: ^80}", r#" ,--, "#),
// format_args!("{: ^80}", r#" ,--.'| ,----, "#),
// format_args!("{: ^80}", r#" ,--, | : .' .' \ "#),
// format_args!("{: ^80}", r#",---.'| : ' ,----,' | "#),
// format_args!("{: ^80}", r#"; : | | ; | : . ; "#),
// format_args!("{: ^80}", r#"| | : _' | ; |.' / "#),
// format_args!("{: ^80}", r#": : |.' | `----'/ ; "#),
// format_args!("{: ^80}", r#"| ' ' ; : / ; / "#),
// format_args!("{: ^80}", r#"\ \ .'. | ; / /-, "#),
// format_args!("{: ^80}", r#" `---`: | ' / / /.`| "#),
// format_args!("{: ^80}", r#" ' ; |./__; : "#),
// format_args!("{: ^80}", r#" | : ;| : .' "#),
// format_args!("{: ^80}", r#" ' ,/ ; | .' "#),
// format_args!("{: ^80}", r#" '--' `---' "#));
// unsafe { CONTEXT.current_term().color_code = ColorCode::new(Color::White, Color::Black); }
// let boot_info = unsafe{ multiboot2::load(multiboot_information_address) };
// let memory_map_tag = boot_info.memory_map_tag()
// .expect("Memory map tag required");
pub extern fn kmain(multiboot_info_addr: usize) -> ! {
let boot_info = unsafe { multiboot2::load(multiboot_info_addr) };
// println!("memory areas:");
// for area in memory_map_tag.memory_areas() {
// println!(" start: 0x{:x}, length: 0x{:x}",
// area.base_addr, area.length);
// }
let memory_map_tag = boot_info.memory_map_tag()
.expect("Memory map tag required");
// let elf_sections_tag = boot_info.elf_sections_tag()
// .expect("Elf-sections tag required");
println!("memory areas:");
for area in memory_map_tag.memory_areas() {
println!(" start: 0x{:x}, length: 0x{:x}",
area.base_addr, area.length);
}
// println!("kernel sections:");
// for section in elf_sections_tag.sections() {
// println!(" addr: 0x{:x}, size: 0x{:x}, flags: 0x{:x}",
// section.addr, section.size, section.flags);
// }
let elf_sections_tag = boot_info.elf_sections_tag()
.expect("Elf-sections tag required");
println!("kernel sections:");
for section in elf_sections_tag.sections() {
println!(" addr: 0x{:x}, size: 0x{:x}, flags: 0x{:x}",
section.addr, section.size, section.flags);
}
unsafe { CONTEXT.vga1.prompt();CONTEXT.vga1.flush(); }
unsafe { CONTEXT.vga2.prompt(); }
loop {
keyboard::kbd_callback();
}
loop { keyboard::kbd_callback(); }
}
#[lang = "eh_personality"] #[no_mangle]

View file

@ -62,7 +62,6 @@ impl Writer {
self.color_code = ColorCode::new(Color::Blue, Color::Black);
self.write_str("> ");
self.color_code = color_code_save;
// self.flush();
flush!();
}