Cleanup warnings
Implement interrupt on signal in pipe:
This commit is contained in:
@@ -276,7 +276,7 @@ fn parse_def_create_dword_field(data: &[u8],
|
||||
|
||||
let local_scope_string = get_namespace_string(ctx.scope.clone(), name.val)?;
|
||||
|
||||
ctx.add_to_namespace(local_scope_string, AmlValue::BufferField(BufferField {
|
||||
let _ = ctx.add_to_namespace(local_scope_string, AmlValue::BufferField(BufferField {
|
||||
source_buf: Box::new(source_buf.val),
|
||||
index: Box::new(bit_index.val),
|
||||
length: Box::new(AmlValue::IntegerConstant(32))
|
||||
|
||||
@@ -132,12 +132,12 @@ pub enum AmlValue {
|
||||
String(String),
|
||||
PowerResource(PowerResource),
|
||||
Processor(Processor),
|
||||
RawDataBuffer(Vec<u8>),
|
||||
//RawDataBuffer(Vec<u8>),
|
||||
ThermalZone(ThermalZone)
|
||||
}
|
||||
|
||||
impl Debug for AmlValue {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> { Ok(()) }
|
||||
fn fmt(&self, _f: &mut Formatter) -> Result<(), Error> { Ok(()) }
|
||||
}
|
||||
|
||||
impl AmlValue {
|
||||
@@ -373,12 +373,14 @@ impl AmlValue {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
pub fn get_as_operation_region(&self) -> Result<OperationRegion, AmlError> {
|
||||
match *self {
|
||||
AmlValue::OperationRegion(ref p) => Ok(p.clone()),
|
||||
_ => Err(AmlError::AmlValueError)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
pub fn get_as_package(&self) -> Result<Vec<AmlValue>, AmlError> {
|
||||
match *self {
|
||||
@@ -435,7 +437,7 @@ impl Method {
|
||||
let mut ctx = AmlExecutionContext::new(scope);
|
||||
ctx.init_arg_vars(parameters);
|
||||
|
||||
parse_term_list(&self.term_list[..], &mut ctx);
|
||||
let _ = parse_term_list(&self.term_list[..], &mut ctx);
|
||||
ctx.clean_namespace();
|
||||
|
||||
match ctx.state {
|
||||
|
||||
@@ -364,12 +364,12 @@ impl AmlExecutionContext {
|
||||
let mut idx = indices[0];
|
||||
idx += b.index.get_as_integer()?;
|
||||
|
||||
self.modify(AmlValue::ObjectReference(ObjectReference::Index(b.source_buf.clone(), Box::new(AmlValue::Integer(idx.clone())))), value);
|
||||
let _ = self.modify(AmlValue::ObjectReference(ObjectReference::Index(b.source_buf.clone(), Box::new(AmlValue::Integer(idx.clone())))), value);
|
||||
|
||||
Ok(AmlValue::BufferField(b.clone()))
|
||||
},
|
||||
AmlValue::Package(ref p) => {
|
||||
if indices.len() < 0 {
|
||||
if indices.len() == 0 {
|
||||
return Err(AmlError::AmlValueError);
|
||||
}
|
||||
|
||||
@@ -491,7 +491,7 @@ impl AmlExecutionContext {
|
||||
Ok(AmlValue::Integer(b.source_buf.get_as_buffer()?[idx as usize] as u64))
|
||||
},
|
||||
AmlValue::Package(ref p) => {
|
||||
if indices.len() < 0 {
|
||||
if indices.len() == 0 {
|
||||
return Err(AmlError::AmlValueError);
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ fn parse_def_load(data: &[u8],
|
||||
if is_aml_table(sdt) {
|
||||
load_table(get_sdt_signature(sdt));
|
||||
let delta = parse_aml_table(sdt)?;
|
||||
ctx.modify(ddb_handle_object.val, AmlValue::DDBHandle((delta, get_sdt_signature(sdt))));
|
||||
let _ = ctx.modify(ddb_handle_object.val, AmlValue::DDBHandle((delta, get_sdt_signature(sdt))));
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: AmlValue::None,
|
||||
@@ -229,7 +229,7 @@ fn parse_def_release(data: &[u8],
|
||||
parser_opcode_extended!(data, 0x27);
|
||||
|
||||
let obj = parse_super_name(&data[2..], ctx)?;
|
||||
ctx.release_mutex(obj.val);
|
||||
let _ = ctx.release_mutex(obj.val);
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: AmlValue::None,
|
||||
@@ -252,7 +252,7 @@ fn parse_def_reset(data: &[u8],
|
||||
let object = parse_super_name(&data[2..], ctx)?;
|
||||
ctx.get(object.val.clone())?.get_as_event()?;
|
||||
|
||||
ctx.modify(object.val.clone(), AmlValue::Event(0));
|
||||
let _ = ctx.modify(object.val.clone(), AmlValue::Event(0));
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: AmlValue::None,
|
||||
|
||||
@@ -367,9 +367,9 @@ fn parse_def_increment(data: &[u8],
|
||||
|
||||
let obj = parse_super_name(&data[1..], ctx)?;
|
||||
|
||||
let mut _namespace = ctx.prelock();
|
||||
let _namespace = ctx.prelock();
|
||||
let value = AmlValue::Integer(ctx.get(obj.val.clone())?.get_as_integer()? + 1);
|
||||
ctx.modify(obj.val, value.clone());
|
||||
let _ = ctx.modify(obj.val, value.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: value,
|
||||
@@ -394,7 +394,7 @@ fn parse_def_index(data: &[u8],
|
||||
let target = parse_target(&data[1 + obj.len + idx.len..], ctx)?;
|
||||
|
||||
let reference = AmlValue::ObjectReference(ObjectReference::Index(Box::new(obj.val), Box::new(idx.val)));
|
||||
ctx.modify(target.val, reference.clone());
|
||||
let _ = ctx.modify(target.val, reference.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: reference,
|
||||
@@ -571,7 +571,7 @@ fn parse_def_to_hex_string(data: &[u8],
|
||||
_ => return Err(AmlError::AmlValueError)
|
||||
};
|
||||
|
||||
ctx.modify(target.val, res.clone());
|
||||
let _ = ctx.modify(target.val, res.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: res,
|
||||
@@ -595,7 +595,7 @@ fn parse_def_to_buffer(data: &[u8],
|
||||
let target = parse_target(&data[2 + operand.len..], ctx)?;
|
||||
|
||||
let res = AmlValue::Buffer(operand.val.get_as_buffer()?);
|
||||
ctx.modify(target.val, res.clone());
|
||||
let _ = ctx.modify(target.val, res.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: res,
|
||||
@@ -628,7 +628,7 @@ fn parse_def_to_bcd(data: &[u8],
|
||||
}
|
||||
|
||||
let result = AmlValue::Integer(result);
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -668,7 +668,7 @@ fn parse_def_to_decimal_string(data: &[u8],
|
||||
_ => return Err(AmlError::AmlValueError)
|
||||
};
|
||||
|
||||
ctx.modify(target.val, res.clone());
|
||||
let _ = ctx.modify(target.val, res.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: res,
|
||||
@@ -693,7 +693,7 @@ fn parse_def_to_integer(data: &[u8],
|
||||
|
||||
let res = AmlValue::Integer(operand.val.get_as_integer()?);
|
||||
|
||||
ctx.modify(target.val, res.clone());
|
||||
let _ = ctx.modify(target.val, res.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: res,
|
||||
@@ -726,7 +726,7 @@ fn parse_def_to_string(data: &[u8],
|
||||
string.truncate(length.val.get_as_integer()? as usize);
|
||||
let res = AmlValue::String(string);
|
||||
|
||||
ctx.modify(target.val, res.clone());
|
||||
let _ = ctx.modify(target.val, res.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: res,
|
||||
@@ -752,7 +752,7 @@ fn parse_def_subtract(data: &[u8],
|
||||
|
||||
let result = AmlValue::Integer(lhs.val.get_as_integer()? - rhs.val.get_as_integer()?);
|
||||
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -803,7 +803,7 @@ fn parse_def_store(data: &[u8],
|
||||
let operand = parse_term_arg(&data[1..], ctx)?;
|
||||
let target = parse_super_name(&data[1 + operand.len..], ctx)?;
|
||||
|
||||
ctx.modify(target.val.clone(), operand.val);
|
||||
let _ = ctx.modify(target.val.clone(), operand.val);
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: target.val,
|
||||
@@ -829,7 +829,7 @@ fn parse_def_or(data: &[u8],
|
||||
|
||||
let result = AmlValue::Integer(lhs.val.get_as_integer()? | rhs.val.get_as_integer()?);
|
||||
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -855,7 +855,7 @@ fn parse_def_shift_left(data: &[u8],
|
||||
|
||||
let result = AmlValue::Integer(lhs.val.get_as_integer()? >> rhs.val.get_as_integer()?);
|
||||
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -881,7 +881,7 @@ fn parse_def_shift_right(data: &[u8],
|
||||
|
||||
let result = AmlValue::Integer(lhs.val.get_as_integer()? << rhs.val.get_as_integer()?);
|
||||
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -907,7 +907,7 @@ fn parse_def_add(data: &[u8],
|
||||
|
||||
let result = AmlValue::Integer(lhs.val.get_as_integer()? + rhs.val.get_as_integer()?);
|
||||
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -933,7 +933,7 @@ fn parse_def_and(data: &[u8],
|
||||
|
||||
let result = AmlValue::Integer(lhs.val.get_as_integer()? & rhs.val.get_as_integer()?);
|
||||
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -959,7 +959,7 @@ fn parse_def_xor(data: &[u8],
|
||||
|
||||
let result = AmlValue::Integer(lhs.val.get_as_integer()? ^ rhs.val.get_as_integer()?);
|
||||
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -1093,7 +1093,7 @@ fn parse_def_cond_ref_of(data: &[u8],
|
||||
_ => return Err(AmlError::AmlValueError)
|
||||
};
|
||||
|
||||
ctx.modify(target.val, AmlValue::ObjectReference(res));
|
||||
let _ = ctx.modify(target.val, AmlValue::ObjectReference(res));
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: AmlValue::Integer(1),
|
||||
@@ -1208,9 +1208,9 @@ fn parse_def_decrement(data: &[u8],
|
||||
|
||||
let obj = parse_super_name(&data[1..], ctx)?;
|
||||
|
||||
let namespace = ctx.prelock();
|
||||
let _namespace = ctx.prelock();
|
||||
let value = AmlValue::Integer(ctx.get(obj.val.clone())?.get_as_integer()? - 1);
|
||||
ctx.modify(obj.val, value.clone());
|
||||
let _ = ctx.modify(obj.val, value.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: value,
|
||||
@@ -1241,8 +1241,8 @@ fn parse_def_divide(data: &[u8],
|
||||
let remainder = numerator % denominator;
|
||||
let quotient = (numerator - remainder) / denominator;
|
||||
|
||||
ctx.modify(target_remainder.val, AmlValue::Integer(remainder));
|
||||
ctx.modify(target_quotient.val, AmlValue::Integer(quotient));
|
||||
let _ = ctx.modify(target_remainder.val, AmlValue::Integer(remainder));
|
||||
let _ = ctx.modify(target_quotient.val, AmlValue::Integer(quotient));
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: AmlValue::Integer(quotient),
|
||||
@@ -1278,7 +1278,7 @@ fn parse_def_find_set_left_bit(data: &[u8],
|
||||
}
|
||||
|
||||
let result = AmlValue::Integer(first_bit);
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -1318,7 +1318,7 @@ fn parse_def_find_set_right_bit(data: &[u8],
|
||||
}
|
||||
|
||||
let result = AmlValue::Integer(first_bit);
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -1364,7 +1364,7 @@ fn parse_def_load_table(data: &[u8],
|
||||
|
||||
if let Some(sdt) = sdt {
|
||||
let hdl = parse_aml_with_scope(sdt, root_path.val.get_as_string()?)?;
|
||||
ctx.modify(parameter_path.val, parameter_data.val);
|
||||
let _ = ctx.modify(parameter_path.val, parameter_data.val);
|
||||
|
||||
return Ok(AmlParseType {
|
||||
val: AmlValue::DDBHandle((hdl, sdt_signature)),
|
||||
@@ -1553,7 +1553,7 @@ fn parse_def_from_bcd(data: &[u8],
|
||||
|
||||
let result = AmlValue::Integer(result);
|
||||
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -1615,7 +1615,7 @@ fn parse_def_mid(data: &[u8],
|
||||
}
|
||||
};
|
||||
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -1645,7 +1645,7 @@ fn parse_def_mod(data: &[u8],
|
||||
|
||||
let result = AmlValue::Integer(lhs.val.get_as_integer()? % rhs.val.get_as_integer()?);
|
||||
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -1672,7 +1672,7 @@ fn parse_def_multiply(data: &[u8],
|
||||
|
||||
let result = AmlValue::Integer(lhs.val.get_as_integer()? * rhs.val.get_as_integer()?);
|
||||
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -1698,7 +1698,7 @@ fn parse_def_nand(data: &[u8],
|
||||
|
||||
let result = AmlValue::Integer(!(lhs.val.get_as_integer()? & rhs.val.get_as_integer()?));
|
||||
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -1724,7 +1724,7 @@ fn parse_def_nor(data: &[u8],
|
||||
|
||||
let result = AmlValue::Integer(!(lhs.val.get_as_integer()? | rhs.val.get_as_integer()?));
|
||||
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
@@ -1749,7 +1749,7 @@ fn parse_def_not(data: &[u8],
|
||||
|
||||
let result = AmlValue::Integer(!operand.val.get_as_integer()?);
|
||||
|
||||
ctx.modify(target.val, result.clone());
|
||||
let _ = ctx.modify(target.val, result.clone());
|
||||
|
||||
Ok(AmlParseType {
|
||||
val: result,
|
||||
|
||||
@@ -145,7 +145,7 @@ pub unsafe fn init(active_table: &mut ActivePageTable) {
|
||||
rxsdt.map_all(active_table);
|
||||
|
||||
for sdt_address in rxsdt.iter() {
|
||||
let sdt = unsafe { &*(sdt_address as *const Sdt) };
|
||||
let sdt = &*(sdt_address as *const Sdt);
|
||||
|
||||
let signature = get_sdt_signature(sdt);
|
||||
if let Some(ref mut ptrs) = *(SDT_POINTERS.write()) {
|
||||
|
||||
@@ -53,7 +53,7 @@ interrupt!(pit, {
|
||||
pic::MASTER.ack();
|
||||
|
||||
if PIT_TICKS.fetch_add(1, Ordering::SeqCst) >= 10 {
|
||||
context::switch();
|
||||
let _ = context::switch();
|
||||
}
|
||||
|
||||
// Any better way of doing this?
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
/// Offset to kernel heap
|
||||
pub const KERNEL_HEAP_OFFSET: usize = KERNEL_OFFSET + PML4_SIZE/2;
|
||||
/// Size of kernel heap
|
||||
pub const KERNEL_HEAP_SIZE: usize = 64 * 1024 * 1024; // 64 MB
|
||||
pub const KERNEL_HEAP_SIZE: usize = 256 * 1024 * 1024; // 256 MB
|
||||
|
||||
/// Offset to kernel percpu variables
|
||||
//TODO: Use 64-bit fs offset to enable this pub const KERNEL_PERCPU_OFFSET: usize = KERNEL_HEAP_OFFSET - PML4_SIZE;
|
||||
|
||||
@@ -7,7 +7,7 @@ use spin::{Once, RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
|
||||
pub use self::context::{Context, ContextId, Status};
|
||||
pub use self::list::ContextList;
|
||||
pub use self::switch::switch;
|
||||
pub use self::switch::{switch, SwitchResult};
|
||||
|
||||
#[path = "arch/x86_64.rs"]
|
||||
mod arch;
|
||||
|
||||
@@ -10,12 +10,22 @@ use interrupt::irq::PIT_TICKS;
|
||||
use syscall;
|
||||
use time;
|
||||
|
||||
#[must_use]
|
||||
pub enum SwitchResult {
|
||||
/// No context to switch to
|
||||
None,
|
||||
/// Received a signal
|
||||
Signal,
|
||||
/// Switched correctly
|
||||
Normal,
|
||||
}
|
||||
|
||||
/// Switch to the next context
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Do not call this while holding locks!
|
||||
pub unsafe fn switch() -> bool {
|
||||
pub unsafe fn switch() -> SwitchResult {
|
||||
use core::ops::DerefMut;
|
||||
|
||||
//set PIT Interrupt counter to 0, giving each process same amount of PIT ticks
|
||||
@@ -122,23 +132,26 @@ pub unsafe fn switch() -> bool {
|
||||
}
|
||||
};
|
||||
|
||||
if to_ptr as usize == 0 {
|
||||
// Unset global lock if no context found
|
||||
arch::CONTEXT_SWITCH_LOCK.store(false, Ordering::SeqCst);
|
||||
return false;
|
||||
// Switch process states, TSS stack pointer, and store new context ID
|
||||
if to_ptr as usize != 0 {
|
||||
(&mut *from_ptr).running = false;
|
||||
(&mut *to_ptr).running = true;
|
||||
if let Some(ref stack) = (*to_ptr).kstack {
|
||||
gdt::TSS.rsp[0] = (stack.as_ptr() as usize + stack.len() - 256) as u64;
|
||||
}
|
||||
CONTEXT_ID.store((&mut *to_ptr).id, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
(&mut *from_ptr).running = false;
|
||||
(&mut *to_ptr).running = true;
|
||||
if let Some(ref stack) = (*to_ptr).kstack {
|
||||
gdt::TSS.rsp[0] = (stack.as_ptr() as usize + stack.len() - 256) as u64;
|
||||
}
|
||||
CONTEXT_ID.store((&mut *to_ptr).id, Ordering::SeqCst);
|
||||
|
||||
// Unset global lock before switch, as arch is only usable by the current CPU at this time
|
||||
arch::CONTEXT_SWITCH_LOCK.store(false, Ordering::SeqCst);
|
||||
|
||||
if let Some(sig) = to_sig {
|
||||
if to_ptr as usize == 0 {
|
||||
// No target was found, return
|
||||
|
||||
SwitchResult::None
|
||||
} else if let Some(sig) = to_sig {
|
||||
// Signal was found, run signal handler
|
||||
|
||||
//TODO: Allow nested signals
|
||||
assert!((&mut *to_ptr).ksig.is_none());
|
||||
|
||||
@@ -147,11 +160,17 @@ pub unsafe fn switch() -> bool {
|
||||
let kstack = (&mut *to_ptr).kstack.clone();
|
||||
(&mut *to_ptr).ksig = Some((arch, kfx, kstack));
|
||||
(&mut *to_ptr).arch.signal_stack(signal_handler, sig);
|
||||
|
||||
(&mut *from_ptr).arch.switch_to(&mut (&mut *to_ptr).arch);
|
||||
|
||||
SwitchResult::Signal
|
||||
} else {
|
||||
// Found a target, had no signals
|
||||
|
||||
(&mut *from_ptr).arch.switch_to(&mut (&mut *to_ptr).arch);
|
||||
|
||||
SwitchResult::Normal
|
||||
}
|
||||
|
||||
(&mut *from_ptr).arch.switch_to(&mut (&mut *to_ptr).arch);
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
extern "C" fn signal_handler(sig: usize) {
|
||||
|
||||
@@ -57,7 +57,7 @@ impl SerialPort<Pio<u8>> {
|
||||
}
|
||||
|
||||
impl SerialPort<Mmio<u8>> {
|
||||
pub fn new(base: usize) -> SerialPort<Mmio<u8>> {
|
||||
pub fn new(_base: usize) -> SerialPort<Mmio<u8>> {
|
||||
SerialPort {
|
||||
data: Mmio::new(),
|
||||
int_en: Mmio::new(),
|
||||
|
||||
28
src/lib.rs
28
src/lib.rs
@@ -14,7 +14,6 @@
|
||||
#![feature(const_fn)]
|
||||
#![feature(const_max_value)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(drop_types_in_const)]
|
||||
#![feature(global_allocator)]
|
||||
#![feature(integer_atomics)]
|
||||
#![feature(lang_items)]
|
||||
@@ -41,6 +40,7 @@ use alloc::arc::Arc;
|
||||
use core::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
||||
use spin::Mutex;
|
||||
|
||||
use context::SwitchResult;
|
||||
use scheme::{FileHandle, SchemeNamespace};
|
||||
|
||||
pub use consts::*;
|
||||
@@ -171,11 +171,14 @@ pub fn kmain(cpus: usize, env: &[u8]) -> ! {
|
||||
loop {
|
||||
unsafe {
|
||||
interrupt::disable();
|
||||
if context::switch() {
|
||||
interrupt::enable_and_nop();
|
||||
} else {
|
||||
// Enable interrupts, then halt CPU (to save power) until the next interrupt is actually fired.
|
||||
interrupt::enable_and_halt();
|
||||
match context::switch() {
|
||||
SwitchResult::None => {
|
||||
// Enable interrupts, then halt CPU (to save power) until the next interrupt is actually fired.
|
||||
interrupt::enable_and_halt();
|
||||
}
|
||||
_ => {
|
||||
interrupt::enable_and_nop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,11 +198,14 @@ pub fn kmain_ap(id: usize) -> ! {
|
||||
loop {
|
||||
unsafe {
|
||||
interrupt::disable();
|
||||
if context::switch() {
|
||||
interrupt::enable_and_nop();
|
||||
} else {
|
||||
// Enable interrupts, then halt CPU (to save power) until the next interrupt is actually fired.
|
||||
interrupt::enable_and_halt();
|
||||
match context::switch() {
|
||||
SwitchResult::None => {
|
||||
// Enable interrupts, then halt CPU (to save power) until the next interrupt is actually fired.
|
||||
interrupt::enable_and_halt();
|
||||
}
|
||||
_ => {
|
||||
interrupt::enable_and_nop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ use collections::{BTreeMap, VecDeque};
|
||||
use core::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
||||
use spin::{Mutex, Once, RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
|
||||
use context;
|
||||
use context::{self, SwitchResult};
|
||||
use scheme::{AtomicSchemeId, ATOMIC_SCHEMEID_INIT, SchemeId};
|
||||
use sync::WaitCondition;
|
||||
use syscall::error::{Error, Result, EAGAIN, EBADF, EINVAL, EPIPE, ESPIPE};
|
||||
use syscall::error::{Error, Result, EAGAIN, EBADF, EINTR, EINVAL, EPIPE, ESPIPE};
|
||||
use syscall::flag::{EVENT_READ, F_GETFL, F_SETFL, O_ACCMODE, O_NONBLOCK, MODE_FIFO};
|
||||
use syscall::scheme::Scheme;
|
||||
use syscall::data::Stat;
|
||||
@@ -236,7 +236,13 @@ impl PipeRead {
|
||||
} else if self.flags.load(Ordering::SeqCst) & O_NONBLOCK == O_NONBLOCK {
|
||||
return Err(Error::new(EAGAIN));
|
||||
} else {
|
||||
self.condition.wait();
|
||||
match self.condition.wait() {
|
||||
SwitchResult::Signal => {
|
||||
println!("Received signal during pipe read");
|
||||
return Err(Error::new(EINTR));
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use alloc::arc::Arc;
|
||||
use collections::Vec;
|
||||
use spin::{Mutex, RwLock};
|
||||
|
||||
use context::{self, Context};
|
||||
use context::{self, Context, SwitchResult};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct WaitCondition {
|
||||
@@ -25,7 +25,7 @@ impl WaitCondition {
|
||||
len
|
||||
}
|
||||
|
||||
pub fn wait(&self) {
|
||||
pub fn wait(&self) -> SwitchResult {
|
||||
{
|
||||
let context_lock = {
|
||||
let contexts = context::contexts();
|
||||
@@ -37,7 +37,8 @@ impl WaitCondition {
|
||||
|
||||
self.contexts.lock().push(context_lock);
|
||||
}
|
||||
unsafe { context::switch(); }
|
||||
|
||||
unsafe { context::switch() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ impl<K, V> WaitMap<K, V> where K: Clone + Ord {
|
||||
if let Some(value) = self.receive_nonblock(key) {
|
||||
return value;
|
||||
}
|
||||
self.condition.wait();
|
||||
let _ = self.condition.wait();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ impl<K, V> WaitMap<K, V> where K: Clone + Ord {
|
||||
if let Some(entry) = self.receive_any_nonblock() {
|
||||
return entry;
|
||||
}
|
||||
self.condition.wait();
|
||||
let _ = self.condition.wait();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ impl<T> WaitQueue<T> {
|
||||
if let Some(value) = self.inner.lock().pop_front() {
|
||||
return value;
|
||||
}
|
||||
self.condition.wait();
|
||||
let _ = self.condition.wait();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,10 +78,10 @@ pub fn setregid(rgid: u32, egid: u32) -> Result<usize> {
|
||||
// Allow changing RGID if root
|
||||
true
|
||||
} else if rgid == context.egid {
|
||||
/// Allow changing RGID if used for EGID
|
||||
// Allow changing RGID if used for EGID
|
||||
true
|
||||
} else if rgid == context.rgid {
|
||||
/// Allow changing RGID if used for RGID
|
||||
// Allow changing RGID if used for RGID
|
||||
true
|
||||
} else if rgid as i32 == -1 {
|
||||
// Ignore RGID if -1 is passed
|
||||
@@ -96,10 +96,10 @@ pub fn setregid(rgid: u32, egid: u32) -> Result<usize> {
|
||||
// Allow changing EGID if root
|
||||
true
|
||||
} else if egid == context.egid {
|
||||
/// Allow changing EGID if used for EGID
|
||||
// Allow changing EGID if used for EGID
|
||||
true
|
||||
} else if egid == context.rgid {
|
||||
/// Allow changing EGID if used for RGID
|
||||
// Allow changing EGID if used for RGID
|
||||
true
|
||||
} else if egid as i32 == -1 {
|
||||
// Ignore EGID if -1 is passed
|
||||
|
||||
@@ -473,7 +473,7 @@ pub fn clone(flags: usize, stack_base: usize) -> Result<ContextId> {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe { context::switch(); }
|
||||
let _ = unsafe { context::switch() };
|
||||
|
||||
Ok(pid)
|
||||
}
|
||||
@@ -919,7 +919,7 @@ pub fn exit(status: usize) -> ! {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe { context::switch(); }
|
||||
let _ = unsafe { context::switch() };
|
||||
|
||||
unreachable!();
|
||||
}
|
||||
@@ -1098,7 +1098,7 @@ pub fn sigreturn() -> Result<usize> {
|
||||
context.block();
|
||||
}
|
||||
|
||||
unsafe { context::switch(); }
|
||||
let _ = unsafe { context::switch() };
|
||||
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user