From 884e18f3703c126add2dc18615a3c3b28b7f1da3 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 15 Oct 2016 20:55:42 -0600 Subject: [PATCH 01/12] Use own openlibm --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index f7f04bf..ff962e1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 From 90d3a79fd9061d9c4cbf23e5e81260c2b042e89a Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 15 Oct 2016 20:56:03 -0600 Subject: [PATCH 02/12] Fix building on OS X --- Makefile | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 19de26e..dcad69c 100644 --- a/Makefile +++ b/Makefile @@ -91,11 +91,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 +110,24 @@ else UNAME := $(shell uname) ifeq ($(UNAME),Darwin) + CC=$(ARCH)-elf-gcc + CXX=$(ARCH)-elf-g++ + ECHO=/bin/echo 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 + LD=ld + LDFLAGS=--gc-sections + ifneq ($(kvm),no) + QEMUFLAGS+=-enable-kvm -cpu host + endif endif %.list: % @@ -151,10 +164,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 +187,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 + CC=$(CC) CFLAGS=-fno-stack-protector make -C openlibm $(BUILD)/libopenlibm.a: openlibm/libopenlibm.a mkdir -p $(BUILD) @@ -213,7 +226,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 From e42e5bac66a559138a5aa60db5e2b327147db78d Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 15 Oct 2016 20:56:19 -0600 Subject: [PATCH 03/12] Update openlibm --- openlibm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlibm b/openlibm index 1581174..3fc0160 160000 --- a/openlibm +++ b/openlibm @@ -1 +1 @@ -Subproject commit 1581174c85f7b645b15ba1ac1c3a98fb601f0fe7 +Subproject commit 3fc016023b0dd6b30dbd4e4942361c47d9b55779 From d16692665e5399934efe387a7fc6fde50e648c61 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 15 Oct 2016 20:56:32 -0600 Subject: [PATCH 04/12] Remove question mark where not required --- drivers/ahcid/src/main.rs | 1 - drivers/e1000d/src/main.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/ahcid/src/main.rs b/drivers/ahcid/src/main.rs index 880177b..fba2503 100644 --- a/drivers/ahcid/src/main.rs +++ b/drivers/ahcid/src/main.rs @@ -1,5 +1,4 @@ #![feature(asm)] -#![feature(question_mark)] #[macro_use] extern crate bitflags; diff --git a/drivers/e1000d/src/main.rs b/drivers/e1000d/src/main.rs index 3b097df..00b31db 100644 --- a/drivers/e1000d/src/main.rs +++ b/drivers/e1000d/src/main.rs @@ -1,5 +1,4 @@ #![feature(asm)] -#![feature(question_mark)] extern crate dma; extern crate event; From 77c6978a55c18801ae604a977b52b2a6250ab3af Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 15 Oct 2016 21:08:57 -0600 Subject: [PATCH 05/12] Update openlibm --- Makefile | 2 +- openlibm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index dcad69c..145459b 100644 --- a/Makefile +++ b/Makefile @@ -187,7 +187,7 @@ $(BUILD)/libcollections.rlib: rust/src/libcollections/lib.rs $(BUILD)/libcore.rl $(RUSTC) $(RUSTCFLAGS) -o $@ $< openlibm/libopenlibm.a: - CC=$(CC) 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) diff --git a/openlibm b/openlibm index 3fc0160..3c837e7 160000 --- a/openlibm +++ b/openlibm @@ -1 +1 @@ -Subproject commit 3fc016023b0dd6b30dbd4e4942361c47d9b55779 +Subproject commit 3c837e79655c4be724efb945a6345ec97c07635c From 6f189bd7582a887f5ac60098dc1e3bb40ed954ac Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 15 Oct 2016 21:12:40 -0600 Subject: [PATCH 06/12] Update libc --- libstd | 2 +- programs/extrautils | 2 +- programs/ion | 2 +- programs/orbutils | 2 +- programs/userutils | 2 +- ralloc | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libstd b/libstd index dccb2ab..61ba409 160000 --- a/libstd +++ b/libstd @@ -1 +1 @@ -Subproject commit dccb2ab0edfa87653786fc865dc4fcbb9bce863b +Subproject commit 61ba4092b0d4bf9ab0346dbb51ef489a182a84a2 diff --git a/programs/extrautils b/programs/extrautils index ee284d8..7339814 160000 --- a/programs/extrautils +++ b/programs/extrautils @@ -1 +1 @@ -Subproject commit ee284d86473467b3a3acf11199476612114a3d0a +Subproject commit 7339814a20c78077b484e2bf89708293ec8e1111 diff --git a/programs/ion b/programs/ion index ad2580c..100ed07 160000 --- a/programs/ion +++ b/programs/ion @@ -1 +1 @@ -Subproject commit ad2580cd35c6f6be0f09dfe279ffd93882e6b074 +Subproject commit 100ed07adfc02143dfa6b4ba81f988cfd2c7a835 diff --git a/programs/orbutils b/programs/orbutils index 2212c9b..fa9156d 160000 --- a/programs/orbutils +++ b/programs/orbutils @@ -1 +1 @@ -Subproject commit 2212c9b4822c44af90164bffeef29d903e6b39da +Subproject commit fa9156dee23d6da5b20a76f596c9ed263c7bd408 diff --git a/programs/userutils b/programs/userutils index 3b7448c..a05b8f4 160000 --- a/programs/userutils +++ b/programs/userutils @@ -1 +1 @@ -Subproject commit 3b7448c8fdb15857b813a90b2fba81393ef043be +Subproject commit a05b8f4d258929af777041f1362c0b9fca4ad090 diff --git a/ralloc b/ralloc index 65495da..be2a916 160000 --- a/ralloc +++ b/ralloc @@ -1 +1 @@ -Subproject commit 65495da00fc74e40b0047749a5d498547a07dfaa +Subproject commit be2a916a257344ed09345177f01b8fb367542185 From a37103fe47c686c8025f88a1d94616f4398540c6 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 15 Oct 2016 21:25:56 -0600 Subject: [PATCH 07/12] Correct umount on OS X --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 145459b..2ce68ae 100644 --- a/Makefile +++ b/Makefile @@ -113,6 +113,7 @@ else CC=$(ARCH)-elf-gcc CXX=$(ARCH)-elf-g++ ECHO=/bin/echo + FUMOUNT=fusermount -u LD=$(ARCH)-elf-ld LDFLAGS=--gc-sections KRUSTCFLAGS+=-C linker=$(CC) @@ -123,6 +124,7 @@ else CC=gcc CXX=g++ ECHO=echo + FUMOUNT=sudo umount LD=ld LDFLAGS=--gc-sections ifneq ($(kvm),no) @@ -387,7 +389,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 @@ -397,7 +399,7 @@ mount: FORCE unmount: FORCE sync - -fusermount -u $(KBUILD)/harddrive/ + -$(FUMOUNT) $(KBUILD)/harddrive/ rm -rf $(KBUILD)/harddrive/ wireshark: FORCE From 25fb1427abc188082dcebffd41373e69b42696f5 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sun, 16 Oct 2016 13:58:45 -0600 Subject: [PATCH 08/12] Fix for new goblin, fix of accidental swap of fusermount -u and sudo umount --- Cargo.toml | 2 +- Makefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 097d7d6..82ebf7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } diff --git a/Makefile b/Makefile index 2ce68ae..09202dc 100644 --- a/Makefile +++ b/Makefile @@ -113,7 +113,7 @@ else CC=$(ARCH)-elf-gcc CXX=$(ARCH)-elf-g++ ECHO=/bin/echo - FUMOUNT=fusermount -u + FUMOUNT=sudo umount LD=$(ARCH)-elf-ld LDFLAGS=--gc-sections KRUSTCFLAGS+=-C linker=$(CC) @@ -124,7 +124,7 @@ else CC=gcc CXX=g++ ECHO=echo - FUMOUNT=sudo umount + FUMOUNT=fusermount -u LD=ld LDFLAGS=--gc-sections ifneq ($(kvm),no) From 2e575db3dbee69e1beaa395e184106ab0e8f9d2c Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sun, 16 Oct 2016 14:06:01 -0600 Subject: [PATCH 09/12] Allow rustdoc --- Makefile | 11 ++++++++--- krustdoc.sh | 2 ++ rustdoc.sh | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100755 krustdoc.sh create mode 100755 rustdoc.sh diff --git a/Makefile b/Makefile index 09202dc..0629938 100644 --- a/Makefile +++ b/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 diff --git a/krustdoc.sh b/krustdoc.sh new file mode 100755 index 0000000..de4cdb6 --- /dev/null +++ b/krustdoc.sh @@ -0,0 +1,2 @@ +#!/bin/bash +RUST_BACKTRACE=1 rustdoc -L build/kernel --cfg redox $* diff --git a/rustdoc.sh b/rustdoc.sh new file mode 100755 index 0000000..4eff5a2 --- /dev/null +++ b/rustdoc.sh @@ -0,0 +1,2 @@ +#!/bin/bash +RUST_BACKTRACE=1 rustdoc -L build/userspace --cfg redox $* From 9c2a45d0bf87c83a7749d0fbaa9c4f8aa19d67da Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sun, 16 Oct 2016 16:18:01 -0600 Subject: [PATCH 10/12] Mark kernel memory global --- arch/x86_64/src/context.rs | 2 ++ arch/x86_64/src/interrupt/irq.rs | 4 ++-- arch/x86_64/src/paging/mod.rs | 20 ++++++++++---------- arch/x86_64/src/start.rs | 2 +- bootloader/x86_64/initialize.asm | 2 +- bootloader/x86_64/startup-x86_64.asm | 8 ++++---- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/arch/x86_64/src/context.rs b/arch/x86_64/src/context.rs index 8482ec3..9f62366 100644 --- a/arch/x86_64/src/context.rs +++ b/arch/x86_64/src/context.rs @@ -70,6 +70,7 @@ impl Context { #[inline(never)] #[naked] pub unsafe fn switch_to(&mut self, next: &mut Context) { + /* asm!("fxsave [$0]" : : "r"(self.fx) : "memory" : "intel", "volatile"); self.loadable = true; if next.loadable { @@ -77,6 +78,7 @@ impl Context { }else{ asm!("fninit" : : : "memory" : "intel", "volatile"); } + */ asm!("mov $0, cr3" : "=r"(self.cr3) : : "memory" : "intel", "volatile"); if next.cr3 != self.cr3 { diff --git a/arch/x86_64/src/interrupt/irq.rs b/arch/x86_64/src/interrupt/irq.rs index ad9151d..c6a8733 100644 --- a/arch/x86_64/src/interrupt/irq.rs +++ b/arch/x86_64/src/interrupt/irq.rs @@ -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; diff --git a/arch/x86_64/src/paging/mod.rs b/arch/x86_64/src/paging/mod.rs index 5ebfe11..352c390 100644 --- a/arch/x86_64/src/paging/mod.rs +++ b/arch/x86_64/src/paging/mod.rs @@ -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); diff --git a/arch/x86_64/src/start.rs b/arch/x86_64/src/start.rs index ba51fe5..aebd865 100644 --- a/arch/x86_64/src/start.rs +++ b/arch/x86_64/src/start.rs @@ -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 diff --git a/bootloader/x86_64/initialize.asm b/bootloader/x86_64/initialize.asm index 1d468a1..e723d37 100644 --- a/bootloader/x86_64/initialize.asm +++ b/bootloader/x86_64/initialize.asm @@ -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 diff --git a/bootloader/x86_64/startup-x86_64.asm b/bootloader/x86_64/startup-x86_64.asm index abe600f..d49c532 100644 --- a/bootloader/x86_64/startup-x86_64.asm +++ b/bootloader/x86_64/startup-x86_64.asm @@ -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 From 2868b3098a4786e2f2a1b4916f5f680dd8215bfe Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sun, 16 Oct 2016 16:25:24 -0600 Subject: [PATCH 11/12] Reenable fx --- arch/x86_64/src/context.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/x86_64/src/context.rs b/arch/x86_64/src/context.rs index 9f62366..8482ec3 100644 --- a/arch/x86_64/src/context.rs +++ b/arch/x86_64/src/context.rs @@ -70,7 +70,6 @@ impl Context { #[inline(never)] #[naked] pub unsafe fn switch_to(&mut self, next: &mut Context) { - /* asm!("fxsave [$0]" : : "r"(self.fx) : "memory" : "intel", "volatile"); self.loadable = true; if next.loadable { @@ -78,7 +77,6 @@ impl Context { }else{ asm!("fninit" : : : "memory" : "intel", "volatile"); } - */ asm!("mov $0, cr3" : "=r"(self.cr3) : : "memory" : "intel", "volatile"); if next.cr3 != self.cr3 { From c81388d92940c4820cbbcf351f638f318668a6f4 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 17 Oct 2016 11:00:55 -0600 Subject: [PATCH 12/12] Allow init to change stdio --- programs/init/Cargo.toml | 3 +++ programs/init/src/main.rs | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/programs/init/Cargo.toml b/programs/init/Cargo.toml index cd1a1ed..dd47c74 100644 --- a/programs/init/Cargo.toml +++ b/programs/init/Cargo.toml @@ -1,3 +1,6 @@ [package] name = "init" version = "0.1.0" + +[dependencies] +syscall = { path = "../../syscall" } diff --git a/programs/init/src/main.rs b/programs/init/src/main.rs index 09c64f6..f6e6a98 100644 --- a/programs/init/src/main.rs +++ b/programs/init/src/main.rs @@ -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 {