~kameliya/syso

eeb5de2c4446f4fb10e11e7c8c836b1a3dec37a5 — Yuki Izumi 4 years ago e1e59ca
wip
6 files changed, 52 insertions(+), 6 deletions(-)

M Cargo.lock
M Cargo.toml
M entry.s
A src/desc.rs
M src/lib.rs
M src/mem.rs
M Cargo.lock => Cargo.lock +23 -0
@@ 6,6 6,7 @@ dependencies = [
 "hole_list_allocator 0.0.1",
 "multiboot2 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "rlibc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "x86 0.9.0 (git+https://github.com/gz/rust-x86.git)",
]

[[package]]


@@ 14,6 15,11 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "bitflags"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "cpuio"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 39,13 45,30 @@ dependencies = [
]

[[package]]
name = "raw-cpuid"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "rlibc"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "x86"
version = "0.9.0"
source = "git+https://github.com/gz/rust-x86.git#bb86b201ddc4164beb4a8539fe8d912d37e21a22"
dependencies = [
 "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "raw-cpuid 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
]

[metadata]
"checksum bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
"checksum cpuio 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "22b8e308ccfc5acf3b82f79c0eac444cf6114cb2ac67a230ca6c177210068daa"
"checksum linked_list_allocator 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "58bc6078c53efb4976165df37d3b3c7b9eddd7091d2ec2a2062eed524e20052e"
"checksum multiboot2 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88aedb52b616203e987bf9cd0c2779e281eefcfa23bd23dc9734f2dcf54079ad"
"checksum raw-cpuid 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7bc8e963398e6244e1d51c42dd68394f273d39ed8afc9238b74f56041b23dbd3"
"checksum rlibc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe"
"checksum x86 0.9.0 (git+https://github.com/gz/rust-x86.git)" = "<none>"

M Cargo.toml => Cargo.toml +1 -0
@@ 10,6 10,7 @@ crate-type = ["staticlib"]
rlibc = "1.0.0"
cpuio = "0.2.0"
multiboot2 = "0.3.1"
x86 = { git = "https://github.com/gz/rust-x86.git", default-features = false }

[dependencies.hole_list_allocator]
path = "libs/hole_list_allocator"

M entry.s => entry.s +18 -0
@@ 11,9 11,27 @@ header_end:

.section .rodata
gdt64:
  # nul
  .quad 0
  # code (0)
  .quad (1<<44) | (1<<47) | (1<<41) | (1<<43) | (1<<53)
  # data (0)
  .quad (1<<44) | (1<<47) | (1<<41)
  # clear (1)
  .quad 0
  # clear (1)
  .quad 0
  # clear (2)
  .quad 0
  # clear (2)
  .quad 0
  # code (3)
	.quad (1<<44) | (1<<47) | (1<<41) | (1<<43) | (1<<53) | (3<<45)
  # data (3)
  .quad (1<<44) | (1<<47) | (1<<41) | (1<<45) | (1<<46)
  # TSS (TODO)
  .quad 0

gdt64pointer:
  .short . - gdt64 - 1
  .quad gdt64

A src/desc.rs => src/desc.rs +6 -0
@@ 0,0 1,6 @@
use x86::bits64::irq::IdtEntry;
use x86::shared::dtables::DescriptorTablePointer;

pub fn init() {
    let entries: [IdtEntry; 256] = [IdtEntry::MISSING; 256];
}

M src/lib.rs => src/lib.rs +3 -1
@@ 1,5 1,4 @@
#![feature(alloc)]
#![feature(bit_set)]
#![feature(collections)]
#![feature(lang_items)]
#![feature(asm)]


@@ 13,6 12,7 @@ extern crate rlibc;
extern crate cpuio;
extern crate multiboot2;
extern crate hole_list_allocator;
extern crate x86;

use core::fmt::Write;



@@ 21,6 21,7 @@ pub mod support;
mod console;
mod debug;
mod mem;
mod desc;

#[no_mangle]
pub extern fn rust_entry(multiboot_addr: usize) {


@@ 31,6 32,7 @@ pub extern fn rust_entry(multiboot_addr: usize) {

    let multiboot = unsafe { multiboot2::load(multiboot_addr) };
    mem::init(&multiboot);
    desc::init();

    write!(console, "> ").unwrap();


M src/mem.rs => src/mem.rs +1 -5
@@ 1,12 1,8 @@
use core::fmt::Write;
use collections::{BTreeSet, Vec};
use multiboot2::BootInformation;
use hole_list_allocator;

use debug::DEBUG;

pub fn init(multiboot: &BootInformation) {
    let memory_map_tag = multiboot.memory_map_tag().expect("Memory map tag required");
//    let memory_map_tag = multiboot.memory_map_tag().expect("Memory map tag required");
    let elf_sections_tag = multiboot.elf_sections_tag().expect("ELF sections tag required");

    let kernel_end = elf_sections_tag.sections().map(|s| s.addr + s.size)