added multiboot as a local crate
This commit is contained in:
parent
7d08ddf53c
commit
52af278a91
8 changed files with 54 additions and 71 deletions
3
kernel-rs/.gitmodules
vendored
Normal file
3
kernel-rs/.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "multiboot2-elf64"]
|
||||||
|
path = multiboot2-elf64
|
||||||
|
url = git@github.com:jzck/multiboot2-elf64.git
|
||||||
|
|
@ -8,4 +8,4 @@ crate-type = ["staticlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rlibc = "1.0"
|
rlibc = "1.0"
|
||||||
multiboot2 = "0.1.0"
|
multiboot2 = { path = "multiboot2-elf64" }
|
||||||
|
|
|
||||||
1
kernel-rs/multiboot2-elf64
Submodule
1
kernel-rs/multiboot2-elf64
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 4d6ad9cde926f2ad5d47041e3f3a2cda18f8e11e
|
||||||
|
|
@ -50,37 +50,37 @@ GDTR:
|
||||||
DB 0xCF ; [ Flags: C=1100b = (granularity)|(32bit)|(!64bit)|(0) ] / [ Limits: (bits 16-19): F=1111b ]
|
DB 0xCF ; [ Flags: C=1100b = (granularity)|(32bit)|(!64bit)|(0) ] / [ Limits: (bits 16-19): F=1111b ]
|
||||||
DB 0x0 ; Base ( bits 24 -31 )
|
DB 0x0 ; Base ( bits 24 -31 )
|
||||||
|
|
||||||
; .gdt_ss: equ $ - .gdt_top; the stack segment Aka KERNEL STACK
|
.gdt_ss: equ $ - .gdt_top; the stack segment Aka KERNEL STACK
|
||||||
; DW 0x0 ; Limit ( bits 0 -15 )
|
DW 0x0 ; Limit ( bits 0 -15 )
|
||||||
; DW 0x0 ; Base ( bits 0 -15 )
|
DW 0x0 ; Base ( bits 0 -15 )
|
||||||
; DB 0x0 ; Base ( bits 16 -23 )
|
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 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 0xCF ; [ Flags: C=1100b = (granularity)|(32bit)|(!64bit)|(0) ] / [ Limits: (bits 16-19): F=1111b ]
|
||||||
; DB 0x0 ; Base ( bits 24 -31 )
|
DB 0x0 ; Base ( bits 24 -31 )
|
||||||
|
|
||||||
; .gdt_es: equ $ - .gdt_top; the extra segment Aka USER CODE
|
.gdt_es: equ $ - .gdt_top; the extra segment Aka USER CODE
|
||||||
; DW 0xffff ; Limit ( bits 0 -15 )
|
DW 0xffff ; Limit ( bits 0 -15 )
|
||||||
; DW 0x0 ; Base ( bits 0 -15 )
|
DW 0x0 ; Base ( bits 0 -15 )
|
||||||
; DB 0x0 ; Base ( bits 16 -23 )
|
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 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 0xCF ; [ Flags: C=1100b = (granularity)|(32bit)|(!64bit)|(0) ] / [ Limits: (bits 16-19): F=1111b ]
|
||||||
; DB 0x0 ; Base ( bits 24 -31 )
|
DB 0x0 ; Base ( bits 24 -31 )
|
||||||
|
|
||||||
; .gdt_fs: equ $ - .gdt_top; the other segment Aka USER DATA
|
.gdt_fs: equ $ - .gdt_top; the other segment Aka USER DATA
|
||||||
; DW 0xffff ; Limit ( bits 0 -15 )
|
DW 0xffff ; Limit ( bits 0 -15 )
|
||||||
; DW 0x0 ; Base ( bits 0 -15 )
|
DW 0x0 ; Base ( bits 0 -15 )
|
||||||
; DB 0x0 ; Base ( bits 16 -23 )
|
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 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 0xCF ; [ Flags: C=1100b = (granularity)|(32bit)|(!64bit)|(0) ] / [ Limits: (bits 16-19): F=1111b ]
|
||||||
; DB 0x0 ; Base ( bits 24 -31 )
|
DB 0x0 ; Base ( bits 24 -31 )
|
||||||
|
|
||||||
; .gdt_gs: equ $ - .gdt_top; the other segment Aka USER STACK
|
.gdt_gs: equ $ - .gdt_top; the other segment Aka USER STACK
|
||||||
; DW 0x0 ; Limit ( bits 0 -15 )
|
DW 0x0 ; Limit ( bits 0 -15 )
|
||||||
; DW 0x0 ; Base ( bits 0 -15 )
|
DW 0x0 ; Base ( bits 0 -15 )
|
||||||
; DB 0x0 ; Base ( bits 16 -23 )
|
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 ; [ 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 0x00 ; [ Flags: C=1100b = (granularity)|(32bit)|(!64bit)|(0) ] / [ Limits: (bits 16-19): F=1111b ]
|
||||||
; DB 0x0 ; Base ( bits 24 -31 )
|
DB 0x0 ; Base ( bits 24 -31 )
|
||||||
|
|
||||||
.gdt_bottom:
|
.gdt_bottom:
|
||||||
.ptr:
|
.ptr:
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ section .text
|
||||||
bits 32
|
bits 32
|
||||||
x86_start:
|
x86_start:
|
||||||
mov ax, 0x10 ; 16 bytes (0x10) is where the offset for data section (gdt_ds)
|
mov ax, 0x10 ; 16 bytes (0x10) is where the offset for data section (gdt_ds)
|
||||||
mov ss, ax
|
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
|
mov ss, ax
|
||||||
mov es, ax
|
mov es, ax
|
||||||
mov fs, ax
|
mov fs, ax
|
||||||
mov gs, ax
|
mov gs, ax
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ fn is_control(c: char) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_line(line: &[u8], address: usize) {
|
fn print_line(line: &[u8], address: usize) {
|
||||||
print!("\n{:08x}: ", address);
|
print!("\n{:#08x}: ", address);
|
||||||
for byte in line {
|
for byte in line {
|
||||||
print!("{:02x} ", *byte);
|
print!("{:02x} ", *byte);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#![feature(asm)] //needed by cpuio for inline asm
|
#![feature(asm)] //needed by cpuio for inline asm
|
||||||
|
|
||||||
extern crate rlibc;
|
extern crate rlibc;
|
||||||
extern crate multiboot2;
|
extern crate multiboot2; //slightly modified fork from official 0.3.2
|
||||||
|
|
||||||
/// 80x25 screen and simplistic terminal driver
|
/// 80x25 screen and simplistic terminal driver
|
||||||
#[macro_use] pub mod vga;
|
#[macro_use] pub mod vga;
|
||||||
|
|
@ -23,51 +23,31 @@ pub mod cpuio;
|
||||||
use context::CONTEXT;
|
use context::CONTEXT;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern fn kmain(multiboot_information_address: usize) -> ! {
|
pub extern fn kmain(multiboot_info_addr: usize) -> ! {
|
||||||
// use vga::{Color, ColorCode};
|
let boot_info = unsafe { multiboot2::load(multiboot_info_addr) };
|
||||||
// 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()
|
||||||
// let memory_map_tag = boot_info.memory_map_tag()
|
.expect("Memory map tag required");
|
||||||
// .expect("Memory map tag required");
|
|
||||||
|
|
||||||
// println!("memory areas:");
|
println!("memory areas:");
|
||||||
// for area in memory_map_tag.memory_areas() {
|
for area in memory_map_tag.memory_areas() {
|
||||||
// println!(" start: 0x{:x}, length: 0x{:x}",
|
println!(" start: 0x{:x}, length: 0x{:x}",
|
||||||
// area.base_addr, area.length);
|
area.base_addr, area.length);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// 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");
|
||||||
|
|
||||||
// println!("kernel sections:");
|
println!("kernel sections:");
|
||||||
// for section in elf_sections_tag.sections() {
|
for section in elf_sections_tag.sections() {
|
||||||
// println!(" addr: 0x{:x}, size: 0x{:x}, flags: 0x{:x}",
|
println!(" addr: 0x{:x}, size: 0x{:x}, flags: 0x{:x}",
|
||||||
// section.addr, section.size, section.flags);
|
section.addr, section.size, section.flags);
|
||||||
// }
|
}
|
||||||
|
|
||||||
unsafe { CONTEXT.vga1.prompt();CONTEXT.vga1.flush(); }
|
unsafe { CONTEXT.vga1.prompt();CONTEXT.vga1.flush(); }
|
||||||
unsafe { CONTEXT.vga2.prompt(); }
|
unsafe { CONTEXT.vga2.prompt(); }
|
||||||
|
|
||||||
loop {
|
loop { keyboard::kbd_callback(); }
|
||||||
keyboard::kbd_callback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[lang = "eh_personality"] #[no_mangle]
|
#[lang = "eh_personality"] #[no_mangle]
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,6 @@ impl Writer {
|
||||||
self.color_code = ColorCode::new(Color::Blue, Color::Black);
|
self.color_code = ColorCode::new(Color::Blue, Color::Black);
|
||||||
self.write_str("> ");
|
self.write_str("> ");
|
||||||
self.color_code = color_code_save;
|
self.color_code = color_code_save;
|
||||||
// self.flush();
|
|
||||||
flush!();
|
flush!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue