Merge branch 'master' of https://github.com/redox-os/kernel
This commit is contained in:
commit
502b7bf89b
2
.gitmodules
vendored
2
.gitmodules
vendored
|
@ -12,7 +12,7 @@
|
|||
url = https://github.com/redox-os/ion.git
|
||||
[submodule "openlibm"]
|
||||
path = openlibm
|
||||
url = https://github.com/JuliaLang/openlibm.git
|
||||
url = https://github.com/redox-os/openlibm.git
|
||||
[submodule "programs/coreutils"]
|
||||
path = programs/coreutils
|
||||
url = https://github.com/redox-os/coreutils.git
|
||||
|
|
|
@ -15,7 +15,7 @@ syscall = { path = "syscall/" }
|
|||
[dependencies.goblin]
|
||||
git = "https://github.com/m4b/goblin.git"
|
||||
default-features = false
|
||||
features = ["no_mach", "no_mach32", "no_pe", "no_pe32", "no_endian_fd", "pure"]
|
||||
features = ["elf32", "elf64"]
|
||||
|
||||
[dev-dependencies]
|
||||
arch_test = { path = "arch/test" }
|
||||
|
|
46
Makefile
46
Makefile
|
@ -5,7 +5,8 @@ KTARGET=$(ARCH)-unknown-none
|
|||
KBUILD=build/kernel
|
||||
KRUSTC=./krustc.sh
|
||||
KRUSTCFLAGS=--target $(KTARGET).json -C opt-level=s -C soft-float
|
||||
KCARGO=RUSTC="$(KRUSTC)" cargo
|
||||
KRUSTDOC=./krustdoc.sh
|
||||
KCARGO=RUSTC="$(KRUSTC)" RUSTDOC="$(KRUSTDOC)" cargo
|
||||
KCARGOFLAGS=--target $(KTARGET).json -- -C opt-level=s -C soft-float
|
||||
|
||||
# Userspace variables
|
||||
|
@ -13,11 +14,12 @@ TARGET=$(ARCH)-unknown-redox
|
|||
BUILD=build/userspace
|
||||
RUSTC=./rustc.sh
|
||||
RUSTCFLAGS=--target $(TARGET).json -C opt-level=s --cfg redox
|
||||
CARGO=RUSTC="$(RUSTC)" cargo
|
||||
RUSTDOC=./rustdoc.sh
|
||||
CARGO=RUSTC="$(RUSTC)" RUSTDOC="$(RUSTDOC)" cargo
|
||||
CARGOFLAGS=--target $(TARGET).json -- -C opt-level=s --cfg redox
|
||||
|
||||
# Default targets
|
||||
.PHONY: all clean update qemu bochs drivers schemes coreutils extrautils netutils userutils wireshark FORCE
|
||||
.PHONY: all clean doc update qemu bochs drivers schemes coreutils extrautils netutils userutils wireshark FORCE
|
||||
|
||||
all: $(KBUILD)/harddrive.bin
|
||||
|
||||
|
@ -48,6 +50,9 @@ clean:
|
|||
rm -rf filesystem/bin
|
||||
rm -rf build
|
||||
|
||||
doc: $(KBUILD)/libkernel.a
|
||||
$(KCARGO) doc --target $(KTARGET).json
|
||||
|
||||
update:
|
||||
cargo update
|
||||
cargo update --manifest-path libstd/Cargo.toml
|
||||
|
@ -91,11 +96,7 @@ $(KBUILD)/harddrive.bin: $(KBUILD)/kernel
|
|||
qemu: $(KBUILD)/harddrive.bin
|
||||
$(QEMU) $(QEMUFLAGS) -kernel $<
|
||||
else
|
||||
LD=ld
|
||||
QEMUFLAGS+=-machine q35 -smp 4 -m 1024
|
||||
ifneq ($(kvm),no)
|
||||
QEMUFLAGS+=-enable-kvm -cpu host
|
||||
endif
|
||||
ifeq ($(net),no)
|
||||
QEMUFLAGS+=-net none
|
||||
else
|
||||
|
@ -114,7 +115,26 @@ else
|
|||
|
||||
UNAME := $(shell uname)
|
||||
ifeq ($(UNAME),Darwin)
|
||||
CC=$(ARCH)-elf-gcc
|
||||
CXX=$(ARCH)-elf-g++
|
||||
ECHO=/bin/echo
|
||||
FUMOUNT=sudo umount
|
||||
LD=$(ARCH)-elf-ld
|
||||
LDFLAGS=--gc-sections
|
||||
KRUSTCFLAGS+=-C linker=$(CC)
|
||||
KCARGOFLAGS+=-C linker=$(CC)
|
||||
RUSTCFLAGS+=-C linker=$(CC)
|
||||
CARGOFLAGS+=-C linker=$(CC)
|
||||
else
|
||||
CC=gcc
|
||||
CXX=g++
|
||||
ECHO=echo
|
||||
FUMOUNT=fusermount -u
|
||||
LD=ld
|
||||
LDFLAGS=--gc-sections
|
||||
ifneq ($(kvm),no)
|
||||
QEMUFLAGS+=-enable-kvm -cpu host
|
||||
endif
|
||||
endif
|
||||
|
||||
%.list: %
|
||||
|
@ -151,10 +171,10 @@ $(KBUILD)/libcollections.rlib: rust/src/libcollections/lib.rs $(KBUILD)/libcore.
|
|||
$(KRUSTC) $(KRUSTCFLAGS) -o $@ $<
|
||||
|
||||
$(KBUILD)/libkernel.a: kernel/** $(KBUILD)/libcore.rlib $(KBUILD)/liballoc.rlib $(KBUILD)/libcollections.rlib $(BUILD)/initfs.rs
|
||||
$(KCARGO) rustc $(KCARGOFLAGS) -C opt-level=s -C lto -o $@
|
||||
$(KCARGO) rustc $(KCARGOFLAGS) -C lto -o $@
|
||||
|
||||
$(KBUILD)/kernel: $(KBUILD)/libkernel.a
|
||||
$(LD) --gc-sections -z max-page-size=0x1000 -T arch/$(ARCH)/src/linker.ld -o $@ $<
|
||||
$(LD) $(LDFLAGS) -z max-page-size=0x1000 -T arch/$(ARCH)/src/linker.ld -o $@ $<
|
||||
|
||||
# Userspace recipes
|
||||
$(BUILD)/libcore.rlib: rust/src/libcore/lib.rs
|
||||
|
@ -174,7 +194,7 @@ $(BUILD)/libcollections.rlib: rust/src/libcollections/lib.rs $(BUILD)/libcore.rl
|
|||
$(RUSTC) $(RUSTCFLAGS) -o $@ $<
|
||||
|
||||
openlibm/libopenlibm.a:
|
||||
CFLAGS=-fno-stack-protector make -C openlibm
|
||||
CROSSCC=$(CC) CFLAGS=-fno-stack-protector make -C openlibm libopenlibm.a
|
||||
|
||||
$(BUILD)/libopenlibm.a: openlibm/libopenlibm.a
|
||||
mkdir -p $(BUILD)
|
||||
|
@ -213,7 +233,7 @@ $(BUILD)/initfs.rs: \
|
|||
echo ' let mut files: BTreeMap<&'"'"'static [u8], (&'"'"'static [u8], bool)> = BTreeMap::new();' >> $@
|
||||
for folder in `find initfs -type d | sort`; do \
|
||||
name=$$(echo $$folder | sed 's/initfs//' | cut -d '/' -f2-) ; \
|
||||
echo -n ' files.insert(b"'$$name'", (b"' >> $@ ; \
|
||||
$(ECHO) -n ' files.insert(b"'$$name'", (b"' >> $@ ; \
|
||||
ls -1 $$folder | sort | awk 'NR > 1 {printf("\\n")} {printf("%s", $$0)}' >> $@ ; \
|
||||
echo '", true));' >> $@ ; \
|
||||
done
|
||||
|
@ -379,7 +399,7 @@ $(BUILD)/filesystem.bin: \
|
|||
chmod +s $(BUILD)/filesystem/bin/su
|
||||
chmod +s $(BUILD)/filesystem/bin/sudo
|
||||
sync
|
||||
-fusermount -u $(BUILD)/filesystem/
|
||||
-$(FUMOUNT) $(BUILD)/filesystem/
|
||||
rm -rf $(BUILD)/filesystem/
|
||||
|
||||
mount: FORCE
|
||||
|
@ -389,7 +409,7 @@ mount: FORCE
|
|||
|
||||
unmount: FORCE
|
||||
sync
|
||||
-fusermount -u $(KBUILD)/harddrive/
|
||||
-$(FUMOUNT) $(KBUILD)/harddrive/
|
||||
rm -rf $(KBUILD)/harddrive/
|
||||
|
||||
wireshark: FORCE
|
||||
|
|
|
@ -27,10 +27,10 @@ pub unsafe fn acknowledge(irq: usize) {
|
|||
}
|
||||
|
||||
interrupt!(pit, {
|
||||
irq_trigger(0);
|
||||
// Saves CPU time by not sending IRQ event irq_trigger(0);
|
||||
|
||||
{
|
||||
const PIT_RATE: u64 = 46500044;
|
||||
const PIT_RATE: u64 = 2250286;
|
||||
|
||||
let mut offset = time::OFFSET.lock();
|
||||
let sum = offset.1 + PIT_RATE;
|
||||
|
|
|
@ -7,7 +7,7 @@ use x86::{msr, tlb};
|
|||
|
||||
use memory::{allocate_frame, Frame};
|
||||
|
||||
use self::entry::{EntryFlags, PRESENT, WRITABLE, NO_EXECUTE};
|
||||
use self::entry::{EntryFlags, PRESENT, GLOBAL, WRITABLE, NO_EXECUTE};
|
||||
use self::mapper::Mapper;
|
||||
use self::temporary_page::TemporaryPage;
|
||||
|
||||
|
@ -129,7 +129,7 @@ pub unsafe fn init(cpu_id: usize, stack_start: usize, stack_end: usize) -> (Acti
|
|||
let start_page = Page::containing_address(VirtualAddress::new(start));
|
||||
let end_page = Page::containing_address(VirtualAddress::new(end - 1));
|
||||
for page in Page::range_inclusive(start_page, end_page) {
|
||||
mapper.map(page, PRESENT | NO_EXECUTE | WRITABLE);
|
||||
mapper.map(page, PRESENT | GLOBAL | NO_EXECUTE | WRITABLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,22 +145,22 @@ pub unsafe fn init(cpu_id: usize, stack_start: usize, stack_end: usize) -> (Acti
|
|||
};
|
||||
|
||||
// Remap stack writable, no execute
|
||||
remap(stack_start - ::KERNEL_OFFSET, stack_end - ::KERNEL_OFFSET, PRESENT | NO_EXECUTE | WRITABLE);
|
||||
remap(stack_start - ::KERNEL_OFFSET, stack_end - ::KERNEL_OFFSET, PRESENT | GLOBAL | NO_EXECUTE | WRITABLE);
|
||||
|
||||
// Remap a section with `flags`
|
||||
let mut remap_section = |start: &u8, end: &u8, flags: EntryFlags| {
|
||||
remap(start as *const _ as usize - ::KERNEL_OFFSET, end as *const _ as usize - ::KERNEL_OFFSET, flags);
|
||||
};
|
||||
// Remap text read-only
|
||||
remap_section(& __text_start, & __text_end, PRESENT);
|
||||
remap_section(& __text_start, & __text_end, PRESENT | GLOBAL);
|
||||
// Remap rodata read-only, no execute
|
||||
remap_section(& __rodata_start, & __rodata_end, PRESENT | NO_EXECUTE);
|
||||
remap_section(& __rodata_start, & __rodata_end, PRESENT | GLOBAL | NO_EXECUTE);
|
||||
// Remap data writable, no execute
|
||||
remap_section(& __data_start, & __data_end, PRESENT | NO_EXECUTE | WRITABLE);
|
||||
remap_section(& __data_start, & __data_end, PRESENT | GLOBAL | NO_EXECUTE | WRITABLE);
|
||||
// Remap tdata master writable, no execute
|
||||
remap_section(& __tdata_start, & __tdata_end, PRESENT | NO_EXECUTE);
|
||||
remap_section(& __tdata_start, & __tdata_end, PRESENT | GLOBAL | NO_EXECUTE);
|
||||
// Remap bss writable, no execute
|
||||
remap_section(& __bss_start, & __bss_end, PRESENT | NO_EXECUTE | WRITABLE);
|
||||
remap_section(& __bss_start, & __bss_end, PRESENT | GLOBAL | NO_EXECUTE | WRITABLE);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -207,7 +207,7 @@ pub unsafe fn init_ap(cpu_id: usize, stack_start: usize, stack_end: usize, kerne
|
|||
let start_page = Page::containing_address(VirtualAddress::new(start));
|
||||
let end_page = Page::containing_address(VirtualAddress::new(end - 1));
|
||||
for page in Page::range_inclusive(start_page, end_page) {
|
||||
mapper.map(page, PRESENT | NO_EXECUTE | WRITABLE);
|
||||
mapper.map(page, PRESENT | GLOBAL | NO_EXECUTE | WRITABLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ pub unsafe fn init_ap(cpu_id: usize, stack_start: usize, stack_end: usize, kerne
|
|||
};
|
||||
|
||||
// Remap stack writable, no execute
|
||||
remap(stack_start - ::KERNEL_OFFSET, stack_end - ::KERNEL_OFFSET, PRESENT | NO_EXECUTE | WRITABLE);
|
||||
remap(stack_start - ::KERNEL_OFFSET, stack_end - ::KERNEL_OFFSET, PRESENT | GLOBAL | NO_EXECUTE | WRITABLE);
|
||||
});
|
||||
|
||||
active_table.switch(new_table);
|
||||
|
|
|
@ -101,7 +101,7 @@ pub unsafe extern fn kstart() -> ! {
|
|||
let heap_start_page = Page::containing_address(VirtualAddress::new(::KERNEL_HEAP_OFFSET));
|
||||
let heap_end_page = Page::containing_address(VirtualAddress::new(::KERNEL_HEAP_OFFSET + ::KERNEL_HEAP_SIZE-1));
|
||||
for page in Page::range_inclusive(heap_start_page, heap_end_page) {
|
||||
active_table.map(page, entry::WRITABLE | entry::NO_EXECUTE);
|
||||
active_table.map(page, entry::PRESENT | entry::GLOBAL | entry::WRITABLE | entry::NO_EXECUTE);
|
||||
}
|
||||
|
||||
// Init the allocator
|
||||
|
|
|
@ -38,7 +38,7 @@ initialize:
|
|||
|
||||
.pit:
|
||||
;initialize the PIT
|
||||
mov ax, 55483 ;5370 ;this is the divider for the PIT
|
||||
mov ax, 2685 ;this is the divider for the PIT
|
||||
out 0x40, al
|
||||
rol ax, 8
|
||||
out 0x40, al
|
||||
|
|
|
@ -26,9 +26,9 @@ startup_ap:
|
|||
mov edi, 0x70000
|
||||
mov cr3, edi
|
||||
|
||||
;enable Page Address Extension and Page Size Extension
|
||||
;enable Page Global, Page Address Extension, and Page Size Extension
|
||||
mov eax, cr4
|
||||
or eax, 1 << 5 | 1 << 4
|
||||
or eax, 1 << 7 | 1 << 5 | 1 << 4
|
||||
mov cr4, eax
|
||||
|
||||
; load protected mode GDT
|
||||
|
@ -91,9 +91,9 @@ startup_arch:
|
|||
mov edi, 0x70000
|
||||
mov cr3, edi
|
||||
|
||||
;enable Page Address Extension and Page Size Extension
|
||||
;enable Page Global, Page Address Extension, and Page Size Extension
|
||||
mov eax, cr4
|
||||
or eax, 1 << 5 | 1 << 4
|
||||
or eax, 1 << 7 | 1 << 5 | 1 << 4
|
||||
mov cr4, eax
|
||||
|
||||
; load protected mode GDT
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#![feature(asm)]
|
||||
#![feature(question_mark)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#![feature(asm)]
|
||||
#![feature(question_mark)]
|
||||
|
||||
extern crate dma;
|
||||
extern crate event;
|
||||
|
|
2
krustdoc.sh
Executable file
2
krustdoc.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
RUST_BACKTRACE=1 rustdoc -L build/kernel --cfg redox $*
|
2
libstd
2
libstd
|
@ -1 +1 @@
|
|||
Subproject commit dccb2ab0edfa87653786fc865dc4fcbb9bce863b
|
||||
Subproject commit 61ba4092b0d4bf9ab0346dbb51ef489a182a84a2
|
2
openlibm
2
openlibm
|
@ -1 +1 @@
|
|||
Subproject commit 1581174c85f7b645b15ba1ac1c3a98fb601f0fe7
|
||||
Subproject commit 3c837e79655c4be724efb945a6345ec97c07635c
|
|
@ -1 +1 @@
|
|||
Subproject commit ee284d86473467b3a3acf11199476612114a3d0a
|
||||
Subproject commit 7339814a20c78077b484e2bf89708293ec8e1111
|
|
@ -1,3 +1,6 @@
|
|||
[package]
|
||||
name = "init"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
syscall = { path = "../../syscall" }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
extern crate syscall;
|
||||
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::{BufRead, BufReader, Result};
|
||||
|
@ -50,6 +52,17 @@ pub fn run(file: &str) -> Result<()> {
|
|||
} else {
|
||||
println!("init: failed to run: no argument");
|
||||
},
|
||||
"stdio" => if let Some(stdio) = args.next() {
|
||||
let _ = syscall::close(2);
|
||||
let _ = syscall::close(1);
|
||||
let _ = syscall::close(0);
|
||||
|
||||
let _ = syscall::open(&stdio, syscall::flag::O_RDWR);
|
||||
let _ = syscall::open(&stdio, syscall::flag::O_RDWR);
|
||||
let _ = syscall::open(&stdio, syscall::flag::O_RDWR);
|
||||
} else {
|
||||
println!("init: failed to set stdio: no argument");
|
||||
},
|
||||
_ => {
|
||||
let mut command = Command::new(cmd);
|
||||
for arg in args {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ad2580cd35c6f6be0f09dfe279ffd93882e6b074
|
||||
Subproject commit 100ed07adfc02143dfa6b4ba81f988cfd2c7a835
|
|
@ -1 +1 @@
|
|||
Subproject commit 2212c9b4822c44af90164bffeef29d903e6b39da
|
||||
Subproject commit fa9156dee23d6da5b20a76f596c9ed263c7bd408
|
|
@ -1 +1 @@
|
|||
Subproject commit 3b7448c8fdb15857b813a90b2fba81393ef043be
|
||||
Subproject commit a05b8f4d258929af777041f1362c0b9fca4ad090
|
2
ralloc
2
ralloc
|
@ -1 +1 @@
|
|||
Subproject commit 65495da00fc74e40b0047749a5d498547a07dfaa
|
||||
Subproject commit be2a916a257344ed09345177f01b8fb367542185
|
2
rustdoc.sh
Executable file
2
rustdoc.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
RUST_BACKTRACE=1 rustdoc -L build/userspace --cfg redox $*
|
Loading…
Reference in a new issue