Commit 50062e5b authored by John Hodge's avatar John Hodge
Browse files

All - Nightly fixes

parent 15660e2c
......@@ -39,7 +39,7 @@ impl<T> Spinlock<T>
/// Create a new spinning lock
pub const fn new(val: T) -> Spinlock<T> {
Spinlock {
lock: ::core::sync::atomic::ATOMIC_BOOL_INIT, //AtomicBool::new(false),
lock: AtomicBool::new(false),
value: ::core::cell::UnsafeCell::new(val),
}
}
......
......@@ -30,7 +30,7 @@ extern "C" {
fn task_switch(oldrsp: &mut u64, newrsp: &u64, tlsbase: u64, cr3: u64);
}
pub static S_IRQS_ENABLED: ::core::sync::atomic::AtomicBool = ::core::sync::atomic::ATOMIC_BOOL_INIT;
pub static S_IRQS_ENABLED: ::core::sync::atomic::AtomicBool = ::core::sync::atomic::AtomicBool::new(false);
static mut S_IDLE_THREAD: *mut ::threads::Thread = 0 as *mut _;
#[repr(C)]
......
......@@ -5,7 +5,7 @@
//! Asynchronous event waiter
#[allow(unused_imports)]
use prelude::*;
use core::sync::atomic::{AtomicBool,ATOMIC_BOOL_INIT,Ordering};
use core::sync::atomic::{AtomicBool,Ordering};
use core::fmt;
/// A general-purpose wait event (when flag is set, waiters will be informed)
......@@ -34,15 +34,15 @@ pub struct Waiter<'a>
source: Option<&'a Source>,
}
//static S_EVENT_NONE: Source = Source { flag: ATOMIC_BOOL_INIT, waiter: mutex_init!(None) };
//static S_EVENT_NONE: Source = Source { flag: AtomicBool::new(false), waiter: mutex_init!(None) };
impl Source
{
/// Create a new event source
pub fn new() -> Source
pub const fn new() -> Source
{
Source {
flag: ATOMIC_BOOL_INIT,
flag: AtomicBool::new(false),
waiter: ::sync::mutex::Mutex::new(None),
}
}
......
......@@ -133,7 +133,7 @@ impl<T: ?Sized + Any> ArefBorrow<T> {
pub fn downcast<U: Any>(self) -> Result<ArefBorrow<U>,Self> {
// SAFE: Transmute validity is checked by checking that the type IDs match
unsafe {
if (*self).get_type_id() == ::core::any::TypeId::of::<U>() {
if (*self).type_id() == ::core::any::TypeId::of::<U>() {
let ptr = self.__ptr.as_ptr() as *const ArefInner<U>;
::core::mem::forget(self);
Ok(ArefBorrow { __ptr: NonNull::new_unchecked(ptr as *mut _) })
......
......@@ -22,7 +22,7 @@ pub use self::pod::{as_byte_slice, as_byte_slice_mut};
pub use self::collections::vec_map;
pub mod collections;
pub mod thunk;
//pub mod thunk;
pub mod borrow;
pub mod ascii;
......
......@@ -16,8 +16,7 @@
#![feature(slice_patterns)] // Slice (array) destructuring patterns, used by multiboot code
#![feature(linkage)] // allows using #[linkage="external"]
#![feature(const_fn)] // Allows defining `const fn`
#![feature(get_type_id)] // used by process_local's "AnyMap" hackery
#![feature(integer_atomics)] // AtomicU8
//#![feature(integer_atomics)] // AtomicU8
#![feature(dropck_eyepatch)]
#![feature(panic_info_message)]
......
......@@ -4,7 +4,7 @@
// Core/metadevs/storage.rs
// - Storage (block device) subsystem
use prelude::*;
use core::sync::atomic::{AtomicUsize,ATOMIC_USIZE_INIT};
use core::sync::atomic::{AtomicUsize};
use sync::mutex::LazyMutex;
use lib::{VecMap};
use lib::mem::Arc;
......@@ -157,9 +157,9 @@ struct PhysicalRegion
first_block: u64,
}
static S_NEXT_PV_IDX: AtomicUsize = ATOMIC_USIZE_INIT;
static S_NEXT_PV_IDX: AtomicUsize = AtomicUsize::new(0);
static S_PHYSICAL_VOLUMES: LazyMutex<VecMap<usize,PhysicalVolumeInfo>> = lazymutex_init!();
static S_NEXT_LV_IDX: AtomicUsize = ATOMIC_USIZE_INIT;
static S_NEXT_LV_IDX: AtomicUsize = AtomicUsize::new(0);
static S_LOGICAL_VOLUMES: LazyMutex<VecMap<usize,Arc<LogicalVolume>>> = lazymutex_init!();
static S_MAPPERS: LazyMutex<Vec<&'static Mapper>> = lazymutex_init!();
......
......@@ -120,8 +120,8 @@ impl Rect
/// Obtain the closest Pos in this Rect
pub fn clamp_pos(&self, pos: Pos) -> Pos {
let x = ::core::cmp::min( ::core::cmp::max(pos.x, self.left()), self.right() );
let y = ::core::cmp::min( ::core::cmp::max(pos.y, self.top() ), self.bottom() );
let x = ::core::cmp::min( ::core::cmp::max(pos.x, self.left()), self.right() - 1 );
let y = ::core::cmp::min( ::core::cmp::max(pos.y, self.top() ), self.bottom() - 1 );
Pos::new(x, y)
}
......
......@@ -286,9 +286,11 @@ fn get_closest_visible_pos(pos: Pos) -> Pos
}
/// Returns the display region that contains the given point
pub fn get_display_for_pos(pos: Pos) -> Option<Rect>
pub fn get_display_for_pos(pos: Pos) -> Result<Rect,Rect>
{
with_display_at_pos(pos, |s| s.region)
// If the position is outside of any displays, return the closest display to it
.ok_or_else( || with_display_at_pos(get_closest_visible_pos(pos), |s| s.region).unwrap() )
}
/// Write part of a single scanline to the screen
......
......@@ -32,7 +32,7 @@ impl EventChannel
EventChannel {
lock: Spinlock::new( false ),
queue: UnsafeCell::new( WaitQueue::new() ),
pending_wakes: ::core::sync::atomic::ATOMIC_USIZE_INIT,
pending_wakes: ::core::sync::atomic::AtomicUsize::new(0),
}
}
......
......@@ -198,8 +198,8 @@ pub fn get_process_local<T: Send+Sync+::core::any::Any+Default+'static>() -> Are
for s in pld.read().iter()
{
let item_ref: &::core::any::Any = &**s;
//log_debug!("{:?} ?== {:?}", item_ref.get_type_id(), ::core::any::TypeId::of::<T>());
if item_ref.get_type_id() == ::core::any::TypeId::of::<T>() {
//log_debug!("{:?} ?== {:?}", item_ref.type_id(), ::core::any::TypeId::of::<T>());
if item_ref.type_id() == ::core::any::TypeId::of::<T>() {
return s.borrow().downcast::<T>().ok().unwrap();
}
}
......@@ -208,8 +208,8 @@ pub fn get_process_local<T: Send+Sync+::core::any::Any+Default+'static>() -> Are
let mut lh = pld.write();
for s in lh.iter() {
let item_ref: &::core::any::Any = &**s;
//log_debug!("{:?} ?== {:?}", item_ref.get_type_id(), ::core::any::TypeId::of::<T>());
if item_ref.get_type_id() == ::core::any::TypeId::of::<T>() {
//log_debug!("{:?} ?== {:?}", item_ref.type_id(), ::core::any::TypeId::of::<T>());
if item_ref.type_id() == ::core::any::TypeId::of::<T>() {
return s.borrow().downcast::<T>().ok().unwrap();
}
}
......
......@@ -85,9 +85,9 @@ pub struct Thread
assert_trait!{Thread : Send}
/// Last allocated TID (because TID0 is allocated differently)
static S_LAST_TID: ::core::sync::atomic::AtomicUsize = ::core::sync::atomic::ATOMIC_USIZE_INIT;
static S_LAST_TID: ::core::sync::atomic::AtomicUsize = ::core::sync::atomic::AtomicUsize::new(0);
const C_MAX_TID: usize = 0x7FFF_FFF0; // Leave 16 TIDs spare at end of 31 bit number
static S_LAST_PID: ::core::sync::atomic::AtomicUsize = ::core::sync::atomic::ATOMIC_USIZE_INIT;
static S_LAST_PID: ::core::sync::atomic::AtomicUsize = ::core::sync::atomic::AtomicUsize::new(0);
const C_MAX_PID: usize = 0x007F_FFF0; // Leave 16 PIDs spare at end of 23 bit number
fn allocate_tid() -> ThreadID
......@@ -195,7 +195,7 @@ impl ProcessHandle
for s in pld.read().iter()
{
let item_ref: &::core::any::Any = &**s;
if item_ref.get_type_id() == ::core::any::TypeId::of::<T>() {
if item_ref.type_id() == ::core::any::TypeId::of::<T>() {
return Some( s.borrow().downcast::<T>().ok().unwrap() );
}
}
......@@ -211,7 +211,7 @@ impl ProcessHandle
for s in pld.read().iter()
{
let item_ref: &::core::any::Any = &**s;
if item_ref.get_type_id() == ::core::any::TypeId::of::<T>() {
if item_ref.type_id() == ::core::any::TypeId::of::<T>() {
return s.borrow().downcast::<T>().ok().unwrap();
}
}
......@@ -220,7 +220,7 @@ impl ProcessHandle
for s in lh.iter()
{
let item_ref: &::core::any::Any = &**s;
if item_ref.get_type_id() == ::core::any::TypeId::of::<T>() {
if item_ref.type_id() == ::core::any::TypeId::of::<T>() {
return s.borrow().downcast::<T>().ok().unwrap();
}
}
......
......@@ -75,7 +75,7 @@ pub extern fn rust_begin_unwind(info: &::core::panic::PanicInfo) -> ! {
}
fn begin_panic_fmt(msg: &::core::fmt::Arguments, (file, line): (&str, u32)) -> !
{
static NESTED: ::core::sync::atomic::AtomicBool = ::core::sync::atomic::ATOMIC_BOOL_INIT;
static NESTED: ::core::sync::atomic::AtomicBool = ::core::sync::atomic::AtomicBool::new(false);
::arch::puts("\nERROR: rust_begin_unwind: ");
::arch::puts(file);
::arch::puts(":");
......
......@@ -246,7 +246,7 @@ $(OBJDIR)libcore.rlib: $(LIBCORESRC)lib.rs $(TARGET_FILE)
$(OBJDIR)libcompiler_builtins.rlib: $(RUSTUP_SRC_DIR)libcompiler_builtins/src/lib.rs $(TARGET_FILE)
@echo [RUSTC] -o [email protected]
@mkdir -p $(dir [email protected])
$V$(ENV) $(RUSTC) $(RUSTFLAGS) --emit=link,dep-info --out-dir $(dir [email protected]) --cfg feature=\"compiler-builtins\" $<
$V$(ENV) $(RUSTC) $(RUSTFLAGS) --emit=link,dep-info --out-dir $(dir [email protected]) --cfg feature=\"compiler-builtins\" $< --cfg stage0
@cp $(OBJDIR)core.d $(OBJDIR)libcore.d
$(OBJDIR)acpica.a: ../acpica/Makefile $(wildcard ../acpica/patches/source/include/platform/*)
......
......@@ -6,7 +6,7 @@
#[allow(unused_imports)]
use kernel::prelude::*;
use self::keyboard::KeyCode;
use core::sync::atomic::{AtomicUsize,ATOMIC_USIZE_INIT,Ordering};
use core::sync::atomic::{AtomicUsize,Ordering};
use kernel::sync::atomic::AtomicValue;
use kernel::sync::Mutex;
......@@ -286,7 +286,7 @@ impl InputChannel
impl ModKeyPair {
const fn new() -> ModKeyPair {
ModKeyPair(ATOMIC_USIZE_INIT)
ModKeyPair(AtomicUsize::new(0))
}
fn set_l(&self) { self.0.fetch_or(1, Ordering::Relaxed); }
fn set_r(&self) { self.0.fetch_or(2, Ordering::Relaxed); }
......
......@@ -81,8 +81,8 @@ impl KernelLog
// - Is this particular call bad for bypassing the GUI? Or is this acceptable
let max_dims = match ::kernel::metadevs::video::get_display_for_pos( Pos::new(0,0) )
{
Some(display) => display.dims(),
None => {
Ok(display) => display.dims(),
Err(_) => {
log_warning!("No display at (0,0)");
Dims::new(0,0)
},
......
......@@ -72,7 +72,7 @@ struct CursorPos {
// - 13 sessions, #0 is fixed to be the kernel's log 1-12 are bound to F1-F12
const C_MAX_SESSIONS: usize = 13;
static S_WINDOW_GROUPS: LazyMutex<SparseVec< Arc<Mutex<WindowGroup>> >> = lazymutex_init!();
static S_CURRENT_GROUP: ::core::sync::atomic::AtomicUsize = ::core::sync::atomic::ATOMIC_USIZE_INIT;
static S_CURRENT_GROUP: ::core::sync::atomic::AtomicUsize = ::core::sync::atomic::AtomicUsize::new(0);
static S_RENDER_REQUEST: ::kernel::sync::EventChannel = ::kernel::sync::EventChannel::new();
static S_RENDER_NEEDED: atomic::AtomicBool = atomic::AtomicBool::new(false);
......@@ -102,20 +102,36 @@ pub fn update_dims()
let mut lh = grp.lock();
for &mut (ref mut pos, ref win) in lh.windows.iter_mut()
{
// Locate screen for the upper-left corner
let screen = match ::kernel::metadevs::video::get_display_for_pos(*pos)
{
Some(x) => x,
// TODO: If now off-screen, warp to a visible position (with ~20px leeway)
None => todo!("update_dims: Handle window moving off display area"),
};
// if window is maximised, keep it that way
if win.flags.lock().maximised
{
// Locate screen for the upper-left corner
let screen = match ::kernel::metadevs::video::get_display_for_pos(*pos)
{
Ok(x) => x,
// TODO: If now off-screen, warp to a visible position (with ~20px leeway)
Err(r) => {
todo!("update_dims: Handle full-screen window moving off display area - {:?} - {:?}", *pos, r)
},
};
// Re-maximise
*pos = screen.pos();
win.resize(screen.dims());
}
else
{
// Otherwise, ensure that the window stays visible
match ::kernel::metadevs::video::get_display_for_pos(*pos)
{
Ok(x) => {
// TODO: Crop window's display area to fit on-screen?
},
// TODO: If now off-screen, warp to a visible position (with ~20px leeway)
Err(r) => {
todo!("update_dims: Handle window moving off display area - {:?} - {:?}", *pos, r)
},
}
}
}
// Recalculate all visibilities
let count = lh.render_order.len();
......@@ -476,9 +492,9 @@ impl WindowGroup
let &mut(ref mut pos, ref win_rc) = &mut self.windows[idx as usize];
let rect = match ::kernel::metadevs::video::get_display_for_pos(*pos)
{
Some(x) => x,
None => {
log_error!("TODO: Handle window being off-screen");
Ok(x) => x,
Err(r) => {
log_error!("TODO: Handle window being off-screen - closest {:?}", r);
Rect::new(0,0, 0,0)
},
};
......
......@@ -66,7 +66,7 @@ impl Window
name: name,
buf: Default::default(),
dirty_rects: Default::default(),
is_dirty: atomic::ATOMIC_BOOL_INIT,
is_dirty: atomic::AtomicBool::new(false),
flags: Default::default(),
input: WindowInput {
queue: Mutex::new(RingBuf::new(16)),
......
......@@ -5,7 +5,6 @@
//! Realtek 8139 driver
#![no_std]
#![feature(linkage)] // for module_define!
#![feature(integer_atomics)] // AtomicU8
use kernel::prelude::*;
use kernel::sync::Mutex;
use kernel::_async3 as async;
......
......@@ -4,7 +4,6 @@
// Core/syscalls/mod.rs
//! Userland system-call interface
#![no_std]
#![feature(integer_atomics)]
#[allow(unused_imports)]
use kernel::prelude::*;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment