Enable SSE and FPU

This commit is contained in:
Jeremy Soller 2016-09-22 16:14:45 -06:00
parent e3df5194fe
commit bc1b503d25
7 changed files with 37 additions and 4 deletions

View file

@ -25,6 +25,8 @@ pub struct Context {
pub running: bool,
/// The architecture specific context
pub arch: arch::context::Context,
/// Kernel FX
pub kfx: Option<Box<[u8]>>,
/// Kernel stack
pub kstack: Option<Box<[u8]>>,
/// Executable image
@ -49,6 +51,7 @@ impl Context {
status: Status::Blocked,
running: false,
arch: arch::context::Context::new(),
kfx: None,
kstack: None,
image: Vec::new(),
heap: None,

View file

@ -1,4 +1,5 @@
use alloc::arc::Arc;
use alloc::boxed::Box;
use collections::BTreeMap;
use core::mem;
use core::sync::atomic::Ordering;
@ -64,6 +65,10 @@ impl ContextList {
let context_lock = self.new_context()?;
{
let mut context = context_lock.write();
let mut fx = unsafe { Box::from_raw(::alloc::heap::allocate(512, 16) as *mut [u8; 512]) };
for b in fx.iter_mut() {
*b = 0;
}
let mut stack = vec![0; 65536].into_boxed_slice();
let offset = stack.len() - mem::size_of::<usize>();
unsafe {
@ -72,7 +77,9 @@ impl ContextList {
*(func_ptr as *mut usize) = func as usize;
}
context.arch.set_page_table(unsafe { arch::paging::ActivePageTable::new().address() });
context.arch.set_fx(fx.as_ptr() as usize);
context.arch.set_stack(stack.as_ptr() as usize + offset);
context.kfx = Some(fx);
context.kstack = Some(stack);
}
Ok(context_lock)

View file

@ -1,5 +1,5 @@
//! Context management
use alloc::boxed::Box;
use core::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
use spin::{Once, RwLock, RwLockReadGuard, RwLockWriteGuard};
@ -38,6 +38,13 @@ pub fn init() {
let mut contexts = contexts_mut();
let context_lock = contexts.new_context().expect("could not initialize first context");
let mut context = context_lock.write();
let mut fx = unsafe { Box::from_raw(::alloc::heap::allocate(512, 16) as *mut [u8; 512]) };
for b in fx.iter_mut() {
*b = 0;
}
context.arch.set_fx(fx.as_ptr() as usize);
context.kfx = Some(fx);
context.status = Status::Runnable;
context.running = true;
CONTEXT_ID.store(context.id, Ordering::SeqCst);

View file

@ -69,6 +69,7 @@
#![feature(collections)]
#![feature(const_fn)]
#![feature(drop_types_in_const)]
#![feature(heap_api)]
#![feature(question_mark)]
#![feature(never_type)]
#![feature(thread_local)]

View file

@ -1,6 +1,6 @@
///! Process syscalls
use alloc::arc::Arc;
use alloc::boxed::Box;
use collections::Vec;
use core::mem;
use core::str;
@ -58,6 +58,7 @@ pub fn clone(flags: usize, stack_base: usize) -> Result<usize> {
let pid;
{
let arch;
let mut kfx_option = None;
let mut kstack_option = None;
let mut offset = 0;
let mut image = vec![];
@ -77,6 +78,14 @@ pub fn clone(flags: usize, stack_base: usize) -> Result<usize> {
arch = context.arch.clone();
if let Some(ref fx) = context.kfx {
let mut new_fx = unsafe { Box::from_raw(::alloc::heap::allocate(512, 16) as *mut [u8; 512]) };
for (new_b, b) in new_fx.iter_mut().zip(fx.iter()) {
*new_b = *b;
}
kfx_option = Some(new_fx);
}
if let Some(ref stack) = context.kstack {
offset = stack_base - stack.as_ptr() as usize - mem::size_of::<usize>(); // Add clone ret
let mut new_stack = stack.clone();
@ -238,6 +247,11 @@ pub fn clone(flags: usize, stack_base: usize) -> Result<usize> {
});
}
if let Some(fx) = kfx_option.take() {
context.arch.set_fx(fx.as_ptr() as usize);
context.kfx = Some(fx);
}
// Set kernel stack
if let Some(stack) = kstack_option.take() {
context.arch.set_stack(stack.as_ptr() as usize + offset);

2
libstd

@ -1 +1 @@
Subproject commit a5a6e9fe349d80918d6fc233d23530c4bf3b4f96
Subproject commit 552fab1400b4eb7b4dbe14adf109d167db5ac082

View file

@ -9,7 +9,8 @@
"vendor": "unknown",
"target-family": "redox",
"pre-link-args": ["-m64", "-nostdlib", "-static"],
"features": "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float",
"post-link-args": ["build/userspace/libopenlibm.a"],
"features": "-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2",
"dynamic-linking": false,
"executables": true,
"relocation-model": "static",