diff --git a/Makefile b/Makefile index 3263c47cee906983dc1a28e1f539892dbab36ffb..c073cc99902a83847ca810997b3464df25be98ae 100644 --- a/Makefile +++ b/Makefile @@ -182,7 +182,7 @@ else %.list: % objdump -C -M intel -D $< > $@ -$(KBUILD)/harddrive.bin: $(KBUILD)/kernel $(BUILD)/filesystem.bin bootloader/$(ARCH)/** +$(KBUILD)/harddrive.bin: $(KBUILD)/kernel bootloader/$(ARCH)/** $(BUILD)/filesystem.bin nasm -f bin -o $@ -D ARCH_$(ARCH) -ibootloader/$(ARCH)/ bootloader/$(ARCH)/harddrive.asm qemu: $(KBUILD)/harddrive.bin @@ -280,13 +280,13 @@ $(BUILD)/libopenlibm.a: libstd/openlibm/libopenlibm.a mkdir -p $(BUILD) cp $< $@ -$(BUILD)/libstd.rlib: libstd/Cargo.toml libstd/src/** $(BUILD)/libcore.rlib $(BUILD)/liballoc.rlib $(BUILD)/librustc_unicode.rlib $(BUILD)/libcollections.rlib $(BUILD)/librand.rlib $(BUILD)/libopenlibm.a - $(CARGO) rustc --verbose --manifest-path $< $(CARGOFLAGS) -o $@ - cp libstd/target/$(TARGET)/release/deps/*.rlib $(BUILD) - -#$(BUILD)/libstd.rlib: libstd_real/Cargo.toml rust/src/libstd/** $(BUILD)/libcore.rlib $(BUILD)/liballoc.rlib $(BUILD)/librustc_unicode.rlib $(BUILD)/libcollections.rlib $(BUILD)/librand.rlib $(BUILD)/libopenlibm.a +#$(BUILD)/libstd.rlib: libstd/Cargo.toml libstd/src/** $(BUILD)/libcore.rlib $(BUILD)/liballoc.rlib $(BUILD)/librustc_unicode.rlib $(BUILD)/libcollections.rlib $(BUILD)/librand.rlib $(BUILD)/libopenlibm.a # $(CARGO) rustc --verbose --manifest-path $< $(CARGOFLAGS) -o $@ -# cp libstd_real/target/$(TARGET)/release/deps/*.rlib $(BUILD) +# cp libstd/target/$(TARGET)/release/deps/*.rlib $(BUILD) + +$(BUILD)/libstd.rlib: libstd_real/Cargo.toml rust/src/libstd/** $(BUILD)/libcore.rlib $(BUILD)/liballoc.rlib $(BUILD)/librustc_unicode.rlib $(BUILD)/libcollections.rlib $(BUILD)/librand.rlib $(BUILD)/libopenlibm.a + $(CARGO) rustc --verbose --manifest-path $< $(CARGOFLAGS) -o $@ + cp libstd_real/target/$(TARGET)/release/deps/*.rlib $(BUILD) initfs/bin/%: drivers/%/Cargo.toml drivers/%/src/** $(BUILD)/libstd.rlib mkdir -p initfs/bin diff --git a/drivers/ahcid/src/main.rs b/drivers/ahcid/src/main.rs index 0bad32239aaef667ac50bf0df5a53d189cd57794..bd8f699a1a54af4bc148b78987950db3da1e8b6b 100644 --- a/drivers/ahcid/src/main.rs +++ b/drivers/ahcid/src/main.rs @@ -7,7 +7,7 @@ extern crate io; extern crate spin; extern crate syscall; -use std::{env, thread, usize}; +use std::{env, usize}; use std::fs::File; use std::io::{Read, Write}; use std::os::unix::io::{AsRawFd, FromRawFd}; @@ -29,7 +29,8 @@ fn main() { print!("{}", format!(" + AHCI on: {:X} IRQ: {}\n", bar, irq)); - thread::spawn(move || { + // Daemonize + if unsafe { syscall::clone(0).unwrap() } == 0 { let address = unsafe { syscall::physmap(bar, 4096, MAP_WRITE).expect("ahcid: failed to map address") }; { let socket_fd = syscall::open(":disk", syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK).expect("ahcid: failed to create disk scheme"); @@ -69,5 +70,5 @@ fn main() { } } unsafe { let _ = syscall::physunmap(address); } - }); + } } diff --git a/drivers/e1000d/src/main.rs b/drivers/e1000d/src/main.rs index f3baf1bbafde58ac8a1de5e1ec0c20fe725e0201..d199ff97a87cda9432c1a31b82cc28dbb98f8723 100644 --- a/drivers/e1000d/src/main.rs +++ b/drivers/e1000d/src/main.rs @@ -6,7 +6,7 @@ extern crate netutils; extern crate syscall; use std::cell::RefCell; -use std::{env, thread}; +use std::env; use std::fs::File; use std::io::{Read, Write, Result}; use std::os::unix::io::{AsRawFd, FromRawFd}; @@ -29,7 +29,8 @@ fn main() { print!("{}", format!(" + E1000 on: {:X}, IRQ: {}\n", bar, irq)); - thread::spawn(move || { + // Daemonize + if unsafe { syscall::clone(0).unwrap() } == 0 { let socket_fd = syscall::open(":network", syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK).expect("e1000d: failed to create network scheme"); let socket = Arc::new(RefCell::new(unsafe { File::from_raw_fd(socket_fd) })); @@ -128,5 +129,5 @@ fn main() { } } unsafe { let _ = syscall::physunmap(address); } - }); + } } diff --git a/drivers/ps2d/src/main.rs b/drivers/ps2d/src/main.rs index 8ff07331a628a2bc1b0d61848aba9d8f5fafd390..7c67bd3a2c7954ea240b605a26d1bd652c34df11 100644 --- a/drivers/ps2d/src/main.rs +++ b/drivers/ps2d/src/main.rs @@ -11,7 +11,7 @@ use std::env; use std::fs::File; use std::io::{Read, Write, Result}; use std::os::unix::io::AsRawFd; -use std::{mem, thread}; +use std::mem; use event::EventQueue; use orbclient::{KeyEvent, MouseEvent}; @@ -123,7 +123,8 @@ impl<'a> Ps2d<'a> { } fn main() { - thread::spawn(|| { + // Daemonize + if unsafe { syscall::clone(0).unwrap() } == 0 { unsafe { iopl(3).expect("ps2d: failed to get I/O permission"); asm!("cli" : : : : "intel", "volatile"); @@ -188,5 +189,5 @@ fn main() { let (keyboard, data) = event_queue.run().expect("ps2d: failed to handle events"); ps2d.handle(keyboard, data); } - }); + } } diff --git a/drivers/rtl8168d/src/main.rs b/drivers/rtl8168d/src/main.rs index 00d6f336783bb0efbfcc1152455aa8c696b3db44..1198286124aa7dc11836d49002304f31c5899118 100644 --- a/drivers/rtl8168d/src/main.rs +++ b/drivers/rtl8168d/src/main.rs @@ -7,7 +7,7 @@ extern crate netutils; extern crate syscall; use std::cell::RefCell; -use std::{env, thread}; +use std::env; use std::fs::File; use std::io::{Read, Write, Result}; use std::os::unix::io::{AsRawFd, FromRawFd}; @@ -30,7 +30,8 @@ fn main() { print!("{}", format!(" + RTL8168 on: {:X}, IRQ: {}\n", bar, irq)); - thread::spawn(move || { + // Daemonize + if unsafe { syscall::clone(0).unwrap() } == 0 { let socket_fd = syscall::open(":network", syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK).expect("rtl8168d: failed to create network scheme"); let socket = Arc::new(RefCell::new(unsafe { File::from_raw_fd(socket_fd) })); @@ -133,5 +134,5 @@ fn main() { } } unsafe { let _ = syscall::physunmap(address); } - }); + } } diff --git a/drivers/vesad/src/main.rs b/drivers/vesad/src/main.rs index b9defbf9955857a84c752200d1d165d2a00fcef9..7f4347a1e1c6a2b8efa463f1584d8e06060080eb 100644 --- a/drivers/vesad/src/main.rs +++ b/drivers/vesad/src/main.rs @@ -6,7 +6,7 @@ extern crate alloc; extern crate orbclient; extern crate syscall; -use std::{env, mem, thread}; +use std::{env, mem}; use std::fs::File; use std::io::{Read, Write}; use syscall::{physmap, physunmap, Packet, SchemeMut, EVENT_READ, MAP_WRITE, MAP_WRITE_COMBINE}; @@ -49,7 +49,8 @@ fn main() { } if physbaseptr > 0 { - thread::spawn(move || { + // Daemonize + if unsafe { syscall::clone(0).unwrap() } == 0 { let mut socket = File::create(":display").expect("vesad: failed to create display scheme"); let size = width * height; @@ -103,6 +104,6 @@ fn main() { } } } - }); + } } } diff --git a/schemes/ethernetd/src/main.rs b/schemes/ethernetd/src/main.rs index a238aee119635223c4006436b0a32b7b5d1acaf8..66357b690fb2122eac418534f18bc6d5206d5ea9 100644 --- a/schemes/ethernetd/src/main.rs +++ b/schemes/ethernetd/src/main.rs @@ -8,7 +8,6 @@ use std::fs::File; use std::io::{Result, Read, Write}; use std::os::unix::io::FromRawFd; use std::rc::Rc; -use std::thread; use syscall::{Packet, SchemeMut, EWOULDBLOCK}; @@ -17,7 +16,8 @@ use scheme::EthernetScheme; mod scheme; fn main() { - thread::spawn(move || { + // Daemonize + if unsafe { syscall::clone(0).unwrap() } == 0 { let network_fd = syscall::open("network:", syscall::O_RDWR | syscall::O_NONBLOCK).expect("ethernetd: failed to open network"); let network = unsafe { File::from_raw_fd(network_fd) }; @@ -90,5 +90,5 @@ fn main() { event_queue.trigger_all(0).expect("ethernetd: failed to trigger events"); event_queue.run().expect("ethernetd: failed to run event loop"); - }); + } } diff --git a/schemes/example/src/main.rs b/schemes/example/src/main.rs index 94db5d17601a60d39957017727528a0c1f3ae6b8..1ba8d59108b87c03d63f6487ed72fc611b056cff 100644 --- a/schemes/example/src/main.rs +++ b/schemes/example/src/main.rs @@ -3,7 +3,6 @@ extern crate syscall; use std::fs::File; use std::io::{Read, Write}; use std::str; -use std::thread; use syscall::{Packet, Result, Scheme}; @@ -25,7 +24,8 @@ impl Scheme for ExampleScheme { } fn main(){ - thread::spawn(move || { + // Daemonize + if unsafe { syscall::clone(0).unwrap() } == 0 { let mut socket = File::create(":example").expect("example: failed to create example scheme"); let scheme = ExampleScheme; loop { @@ -35,5 +35,5 @@ fn main(){ scheme.handle(&mut packet); socket.write(&packet).expect("example: failed to write responses to example scheme"); } - }); + } } diff --git a/schemes/ipd/src/main.rs b/schemes/ipd/src/main.rs index 96b6d62db6d1c793dbd3b35b3b7f80107c4c2f12..093dce5cba02ee3ec148c89533b5a8a340078b41 100644 --- a/schemes/ipd/src/main.rs +++ b/schemes/ipd/src/main.rs @@ -10,7 +10,7 @@ use std::fs::File; use std::io::{self, Read, Write}; use std::os::unix::io::FromRawFd; use std::rc::Rc; -use std::{slice, str, thread}; +use std::{slice, str}; use syscall::data::Packet; use syscall::error::{Error, Result, EACCES, EADDRNOTAVAIL, EBADF, EIO, EINVAL, ENOENT, EWOULDBLOCK}; use syscall::flag::{EVENT_READ, O_NONBLOCK}; @@ -326,7 +326,8 @@ impl SchemeMut for Ipd { } fn main() { - thread::spawn(move || { + // Daemonize + if unsafe { syscall::clone(0).unwrap() } == 0 { let scheme_fd = syscall::open(":ip", syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK).expect("ipd: failed to create :ip"); let scheme_file = unsafe { File::from_raw_fd(scheme_fd) }; @@ -367,5 +368,5 @@ fn main() { event_queue.trigger_all(0).expect("ipd: failed to trigger event queue"); event_queue.run().expect("ipd: failed to run event queue"); - }); + } } diff --git a/schemes/ptyd/src/main.rs b/schemes/ptyd/src/main.rs index 4d4c6494a7b72704156f7bd21e3d7b9660e9819b..28f058d0f9af5d8e87f3e4d681fb0a38e27afc82 100644 --- a/schemes/ptyd/src/main.rs +++ b/schemes/ptyd/src/main.rs @@ -7,7 +7,7 @@ use std::collections::{BTreeMap, VecDeque}; use std::fs::File; use std::io::{Read, Write}; use std::rc::{Rc, Weak}; -use std::{str, thread}; +use std::str; use syscall::data::Packet; use syscall::error::{Error, Result, EBADF, EINVAL, ENOENT, EPIPE, EWOULDBLOCK}; @@ -289,7 +289,8 @@ impl PtySlave { } fn main(){ - thread::spawn(move || { + // Daemonize + if unsafe { syscall::clone(0).unwrap() } == 0 { let mut socket = File::create(":pty").expect("pty: failed to create pty scheme"); let mut scheme = PtyScheme::new(); let mut todo = Vec::new(); @@ -375,5 +376,5 @@ fn main(){ } } } - }); + } } diff --git a/schemes/randd/src/main.rs b/schemes/randd/src/main.rs index b390414942e543d225273ec7ecd62fc41b95dd0d..116c66493cf4aad421963cdab5d3eda5f92e67af 100644 --- a/schemes/randd/src/main.rs +++ b/schemes/randd/src/main.rs @@ -7,7 +7,6 @@ extern crate rand; use std::fs::File; use std::io::{Read, Write}; -use std::thread; use rand::chacha::ChaChaRng; use rand::Rng; @@ -51,7 +50,8 @@ impl SchemeMut for RandScheme { fn main(){ let has_rdrand = CpuId::new().get_feature_info().unwrap().has_rdrand(); - thread::spawn(move || { + // Daemonize + if unsafe { syscall::clone(0).unwrap() } == 0 { let mut socket = File::create(":rand").expect("rand: failed to create rand scheme"); let mut rng = ChaChaRng::new_unseeded(); @@ -78,5 +78,5 @@ fn main(){ scheme.handle(&mut packet); socket.write(&packet).expect("rand: failed to write responses to rand scheme"); } - }); + } } diff --git a/schemes/redoxfs b/schemes/redoxfs index d058e56d6e9dbc2fb95bcdc335bf2da04c3d56eb..8449c5b6ad87ced01bcb82627cb85a8981337210 160000 --- a/schemes/redoxfs +++ b/schemes/redoxfs @@ -1 +1 @@ -Subproject commit d058e56d6e9dbc2fb95bcdc335bf2da04c3d56eb +Subproject commit 8449c5b6ad87ced01bcb82627cb85a8981337210 diff --git a/schemes/tcpd/src/main.rs b/schemes/tcpd/src/main.rs index 847acb14fcced2475734a8fd79a41b5e163ab895..8c7e16e9ab845c65b0c3c59470412cb8ecac5a74 100644 --- a/schemes/tcpd/src/main.rs +++ b/schemes/tcpd/src/main.rs @@ -8,7 +8,7 @@ use std::collections::{BTreeMap, VecDeque}; use std::cell::RefCell; use std::fs::File; use std::io::{self, Read, Write}; -use std::{mem, slice, str, thread}; +use std::{mem, slice, str}; use std::os::unix::io::FromRawFd; use std::rc::Rc; @@ -652,7 +652,8 @@ impl SchemeMut for Tcpd { } fn main() { - thread::spawn(move || { + // Daemonize + if unsafe { syscall::clone(0).unwrap() } == 0 { let scheme_fd = syscall::open(":tcp", O_RDWR | O_CREAT | O_NONBLOCK).expect("tcpd: failed to create :tcp"); let scheme_file = unsafe { File::from_raw_fd(scheme_fd) }; @@ -677,5 +678,5 @@ fn main() { event_queue.trigger_all(0).expect("tcpd: failed to trigger event queue"); event_queue.run().expect("tcpd: failed to run event queue"); - }); + } } diff --git a/schemes/udpd/src/main.rs b/schemes/udpd/src/main.rs index ba43abf49f677011814da13d1f066984d47139b1..7b39eecc6b43c08f741cbd796fc3661a909b4ad3 100644 --- a/schemes/udpd/src/main.rs +++ b/schemes/udpd/src/main.rs @@ -8,7 +8,7 @@ use std::collections::{BTreeMap, VecDeque}; use std::cell::RefCell; use std::fs::File; use std::io::{self, Read, Write}; -use std::{mem, slice, str, thread}; +use std::{mem, slice, str}; use std::os::unix::io::FromRawFd; use std::rc::Rc; @@ -319,7 +319,8 @@ impl SchemeMut for Udpd { } fn main() { - thread::spawn(move || { + // Daemonize + if unsafe { syscall::clone(0).unwrap() } == 0 { let scheme_fd = syscall::open(":udp", O_RDWR | O_CREAT | O_NONBLOCK).expect("udpd: failed to create :udp"); let scheme_file = unsafe { File::from_raw_fd(scheme_fd) }; @@ -344,5 +345,5 @@ fn main() { event_queue.trigger_all(0).expect("udpd: failed to trigger event queue"); event_queue.run().expect("udpd: failed to run event queue"); - }); + } } diff --git a/x86_64-unknown-redox.json b/x86_64-unknown-redox.json index 8878e06ed185e58a2d229cc0ac62ebdb24861583..49d7037fcc1548b4e09a939417ed9a2b5a2e15e0 100644 --- a/x86_64-unknown-redox.json +++ b/x86_64-unknown-redox.json @@ -22,5 +22,6 @@ "no-compiler-rt": true, "no-default-libraries": true, "position-independent-executables": false, - "has-elf-tls": true + "has-elf-tls": true, + "panic-strategy": "abort" }