Skip to content

Commit

Permalink
ARM: Fix build, MMU Flags
Browse files Browse the repository at this point in the history
  • Loading branch information
pczarn committed Feb 20, 2014
1 parent 6aa1e32 commit 0067586
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
4 changes: 2 additions & 2 deletions arch/arm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ all: $(BDIR)/kernel.bin

# Library rust-core
$(LCORE):
$(RUSTC) $(RUSTCFLAGS) --dep-info $(@D)/core.d $(CORE_LIB) --emit bc,link --out-dir $(BDIR)
$(RUSTC) $(RUSTCFLAGS) --dep-info $(@D)/core.d $(CORE_LIB) --emit=bc,link --out-dir $(BDIR)

# Compile rustboot
$(BDIR)/main.bc: ../../lib.rs $(MODS) $(LCORE)
$(RUSTC) $(RUSTCFLAGS) --dep-info $(@D)/main.d -L $(BDIR) --emit ir ../../lib.rs --out-dir $(BDIR)
$(RUSTC) $(RUSTCFLAGS) --dep-info $(@D)/main.d -L $(BDIR) --emit=bc ../../lib.rs --out-dir $(BDIR)

%.s: %.bc
$(LLC) $(LLCFLAGS) $^ -o $@
Expand Down
27 changes: 24 additions & 3 deletions arch/arm/cpu/mmu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use core;
use kernel::memory::physical;

// kinda clever
define_flags!(Descriptor: u32 {
define_flags!(Flags: u32 {
SECTION = 0b10010,

BUFFER = 1 << 2,
Expand All @@ -15,6 +15,9 @@ define_flags!(Descriptor: u32 {
USER
})

#[packed]
struct Descriptor(u32);

#[packed]
struct PageTableCoarse {
pages: [Descriptor, ..256]
Expand All @@ -32,17 +35,35 @@ pub unsafe fn init() {
(*dir).enable();
}

pub unsafe fn map(page_ptr: *mut u8, flags: Descriptor) {
pub unsafe fn map(page_ptr: *mut u8, flags: Flags) {
// TODO
}

impl Descriptor {
fn section(base: u32, flags: Descriptor) -> Descriptor {
fn section(base: u32, flags: Flags) -> Descriptor {
// make a section descriptor
Descriptor(base) | flags | SECTION
}
}

impl core::ops::BitOr<Flags, Descriptor> for Descriptor {
#[inline(always)]
fn bitor(&self, other: &Flags) -> Descriptor {
match (self, other) {
(&Descriptor(p), &Flags(f)) => Descriptor(p | f)
}
}
}

impl core::ops::BitAnd<Flags, bool> for Descriptor {
#[inline(always)]
fn bitand(&self, other: &Flags) -> bool {
match (self, other) {
(&Descriptor(p), &Flags(f)) => p & f != 0
}
}
}

impl PageDirectory {
pub unsafe fn enable(&self) {
asm!("mov ip, 0
Expand Down

0 comments on commit 0067586

Please sign in to comment.