Support compilation on more architectures
This commit is contained in:
Generated
+2
-2
@@ -1107,9 +1107,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.15"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "534cfe58d6a18cc17120fbf4635d53d14691c1fe4d951064df9bd326178d7d5a"
|
||||
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
+1
-1
@@ -13,5 +13,5 @@ num-traits = "0.2"
|
||||
parking_lot = "0.11.1"
|
||||
plain = "0.2.3"
|
||||
redox-log = "0.1.1"
|
||||
redox_syscall = "0.2.12"
|
||||
redox_syscall = "0.2.16"
|
||||
thiserror = "1"
|
||||
|
||||
@@ -14,6 +14,12 @@ use super::aml::AmlValue;
|
||||
pub mod dmar;
|
||||
use self::dmar::Dmar;
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
pub const PAGE_SIZE: usize = 4096;
|
||||
|
||||
#[cfg(target_arch = "x86")]
|
||||
pub const PAGE_SIZE: usize = 4096;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub const PAGE_SIZE: usize = 4096;
|
||||
|
||||
|
||||
@@ -112,9 +112,9 @@ impl HbaPort {
|
||||
}
|
||||
|
||||
self.clb[0].write(clb.physical() as u32);
|
||||
self.clb[1].write((clb.physical() >> 32) as u32);
|
||||
self.clb[1].write(((clb.physical() as u64) >> 32) as u32);
|
||||
self.fb[0].write(fb.physical() as u32);
|
||||
self.fb[1].write((fb.physical() >> 32) as u32);
|
||||
self.fb[1].write(((fb.physical() as u64) >> 32) as u32);
|
||||
let is = self.is.read();
|
||||
self.is.write(is);
|
||||
self.ie.write(0 /*TODO: Enable interrupts: 0b10111*/);
|
||||
|
||||
@@ -51,6 +51,7 @@ pub struct AllocatedBars(pub [Mutex<Option<Bar>>; 6]);
|
||||
/// Get the most optimal yet functional interrupt mechanism: either (in the order of preference):
|
||||
/// MSI-X, MSI, and INTx# pin. Returns both runtime interrupt structures (MSI/MSI-X capability
|
||||
/// structures), and the handles to the interrupts.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn get_int_method(
|
||||
pcid_handle: &mut PcidServerHandle,
|
||||
function: &PciFunction,
|
||||
@@ -214,6 +215,15 @@ fn get_int_method(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "x86_64"))]
|
||||
fn get_int_method(
|
||||
pcid_handle: &mut PcidServerHandle,
|
||||
function: &PciFunction,
|
||||
allocated_bars: &AllocatedBars,
|
||||
) -> Result<(InterruptMethod, InterruptSources)> {
|
||||
todo!("handling of interrupts on non-x86_64")
|
||||
}
|
||||
|
||||
fn setup_logging() -> Option<&'static RedoxLogger> {
|
||||
let mut logger = RedoxLogger::new()
|
||||
.with_output(
|
||||
|
||||
+14
-2
@@ -22,6 +22,18 @@ pub use self::queues::{NvmeCmd, NvmeCmdQueue, NvmeComp, NvmeCompQueue};
|
||||
use pcid_interface::msi::{MsiCapability, MsixCapability, MsixTableEntry};
|
||||
use pcid_interface::PcidServerHandle;
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
#[inline(always)]
|
||||
pub(crate) unsafe fn pause() { std::arch::x86::__yield(); }
|
||||
|
||||
#[cfg(target_arch = "x86")]
|
||||
#[inline(always)]
|
||||
pub(crate) unsafe fn pause() { std::arch::x86::_mm_pause(); }
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[inline(always)]
|
||||
pub(crate) unsafe fn pause() { std::arch::x86_64::_mm_pause(); }
|
||||
|
||||
/// Used in conjunction with `InterruptMethod`, primarily by the CQ reactor.
|
||||
#[derive(Debug)]
|
||||
pub enum InterruptSources {
|
||||
@@ -264,7 +276,7 @@ impl Nvme {
|
||||
let csts = self.regs.get_mut().unwrap().csts.read();
|
||||
log::trace!("CSTS: {:X}", csts);
|
||||
if csts & 1 == 1 {
|
||||
std::arch::x86_64::_mm_pause();
|
||||
pause();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -318,7 +330,7 @@ impl Nvme {
|
||||
let csts = self.regs.get_mut().unwrap().csts.read();
|
||||
log::debug!("CSTS: {:X}", csts);
|
||||
if csts & 1 == 0 {
|
||||
std::arch::x86_64::_mm_pause();
|
||||
pause();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ impl NvmeCompQueue {
|
||||
if let Some(some) = self.complete() {
|
||||
return some;
|
||||
} else {
|
||||
unsafe { std::arch::x86_64::_mm_pause() }
|
||||
unsafe { super::pause(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -26,6 +26,7 @@ pub const LEFT_BUTTON: u32 = 0x20;
|
||||
pub const RIGHT_BUTTON: u32 = 0x10;
|
||||
pub const MIDDLE_BUTTON: u32 = 0x08;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
global_asm!("
|
||||
.globl cmd_inner
|
||||
cmd_inner:
|
||||
@@ -54,7 +55,7 @@ cmd_inner:
|
||||
PORT = const PORT,
|
||||
);
|
||||
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub unsafe fn cmd(cmd: u32, arg: u32) -> (u32, u32, u32, u32, u32, u32) {
|
||||
extern "sysv64" {
|
||||
fn cmd_inner(array_ptr: *mut u32, cmd: u32, arg: u32);
|
||||
@@ -68,6 +69,13 @@ pub unsafe fn cmd(cmd: u32, arg: u32) -> (u32, u32, u32, u32, u32, u32) {
|
||||
(a, b, c, d, e, f)
|
||||
}
|
||||
|
||||
//TODO: is it possible to enable this on non-x86_64?
|
||||
#[cfg(not(target_arch = "x86_64"))]
|
||||
pub unsafe fn cmd(_cmd: u32, _arg: u32) -> (u32, u32, u32, u32, u32, u32) {
|
||||
(0, 0, 0, 0, 0, 0)
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub fn enable(relative: bool) -> bool {
|
||||
eprintln!("ps2d: Enable vmmouse");
|
||||
|
||||
|
||||
+21
-9
@@ -2,11 +2,9 @@
|
||||
extern crate rusttype;
|
||||
|
||||
use std::alloc::{Allocator, Global, Layout};
|
||||
use std::{cmp, slice};
|
||||
use std::{cmp, ptr, slice};
|
||||
use std::ptr::NonNull;
|
||||
|
||||
use crate::primitive::{fast_set32, fast_copy};
|
||||
|
||||
#[cfg(feature="rusttype")]
|
||||
use self::rusttype::{Font, FontCollection, Scale, point};
|
||||
|
||||
@@ -96,9 +94,17 @@ impl Display {
|
||||
|
||||
for _y in 0..cmp::min(height, self.height) {
|
||||
unsafe {
|
||||
fast_copy(new_ptr as *mut u8, old_ptr as *const u8, cmp::min(width, self.width) * 4);
|
||||
ptr::copy(
|
||||
old_ptr as *const u8,
|
||||
new_ptr as *mut u8,
|
||||
cmp::min(width, self.width) * 4
|
||||
);
|
||||
if width > self.width {
|
||||
fast_set32(new_ptr.offset(self.width as isize), 0, width - self.width);
|
||||
ptr::write_bytes(
|
||||
new_ptr.offset(self.width as isize),
|
||||
0,
|
||||
width - self.width
|
||||
);
|
||||
}
|
||||
old_ptr = old_ptr.offset(self.width as isize);
|
||||
new_ptr = new_ptr.offset(width as isize);
|
||||
@@ -108,7 +114,7 @@ impl Display {
|
||||
if height > self.height {
|
||||
for _y in self.height..height {
|
||||
unsafe {
|
||||
fast_set32(new_ptr, 0, width);
|
||||
ptr::write_bytes(new_ptr, 0, width);
|
||||
new_ptr = new_ptr.offset(width as isize);
|
||||
}
|
||||
}
|
||||
@@ -145,8 +151,10 @@ impl Display {
|
||||
|
||||
let mut rows = end_y - start_y;
|
||||
while rows > 0 {
|
||||
unsafe {
|
||||
fast_set32(offscreen_ptr as *mut u32, color, len);
|
||||
for i in 0..len {
|
||||
unsafe {
|
||||
*(offscreen_ptr as *mut u32).add(i) = color;
|
||||
}
|
||||
}
|
||||
offscreen_ptr += stride;
|
||||
rows -= 1;
|
||||
@@ -279,7 +287,11 @@ impl Display {
|
||||
let mut rows = end_y - start_y;
|
||||
while rows > 0 {
|
||||
unsafe {
|
||||
fast_copy(onscreen_ptr as *mut u8, offscreen_ptr as *const u8, len);
|
||||
ptr::copy(
|
||||
offscreen_ptr as *const u8,
|
||||
onscreen_ptr as *mut u8,
|
||||
len
|
||||
);
|
||||
}
|
||||
offscreen_ptr += stride;
|
||||
onscreen_ptr += stride;
|
||||
|
||||
+2
-4
@@ -3,17 +3,15 @@
|
||||
extern crate orbclient;
|
||||
extern crate syscall;
|
||||
|
||||
use std::{env, process};
|
||||
use std::{env, process, ptr};
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::os::unix::io::{RawFd, FromRawFd};
|
||||
use syscall::{physmap, physunmap, Packet, SchemeMut, EVENT_READ, PHYSMAP_WRITE, PHYSMAP_WRITE_COMBINE};
|
||||
|
||||
use crate::primitive::fast_set64;
|
||||
use crate::scheme::{DisplayScheme, HandleKind};
|
||||
|
||||
pub mod display;
|
||||
pub mod primitive;
|
||||
pub mod scheme;
|
||||
pub mod screen;
|
||||
|
||||
@@ -74,7 +72,7 @@ fn main() {
|
||||
//TODO: Remap on resize
|
||||
let largest_size = 8 * 1024 * 1024;
|
||||
let onscreen = unsafe { physmap(physbaseptr, largest_size * 4, PHYSMAP_WRITE | PHYSMAP_WRITE_COMBINE).expect("vesad: failed to map VBE LFB") };
|
||||
unsafe { fast_set64(onscreen as *mut u64, 0, size/2) };
|
||||
unsafe { ptr::write_bytes(onscreen as *mut u32, 0, size); }
|
||||
|
||||
let mut scheme = DisplayScheme::new(width, height, onscreen, &spec);
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
use core::arch::asm;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[inline(always)]
|
||||
pub unsafe fn fast_copy(dst: *mut u8, src: *const u8, len: usize) {
|
||||
// direction flag must always be cleared, as per the System V ABI
|
||||
asm!("rep movsb",
|
||||
inout("rdi") dst as usize => _, inout("rsi") src as usize => _, inout("rcx") len => _,
|
||||
options(nostack, preserves_flags),
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[inline(always)]
|
||||
pub unsafe fn fast_copy64(dst: *mut u64, src: *const u64, len: usize) {
|
||||
asm!("rep movsq",
|
||||
inout("rdi") dst as usize => _, inout("rsi") src as usize => _, inout("rcx") len => _,
|
||||
options(nostack, preserves_flags),
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[inline(always)]
|
||||
pub unsafe fn fast_set32(dst: *mut u32, src: u32, len: usize) {
|
||||
asm!("rep stosd",
|
||||
inout("rdi") dst as usize => _, in("eax") src, inout("rcx") len => _,
|
||||
options(nostack, preserves_flags),
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[inline(always)]
|
||||
pub unsafe fn fast_set64(dst: *mut u64, src: u64, len: usize) {
|
||||
asm!("rep stosq",
|
||||
inout("rdi") dst as usize => _, in("rax") src, inout("rcx") len => _,
|
||||
options(nostack, preserves_flags),
|
||||
);
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
use std::collections::VecDeque;
|
||||
use std::{cmp, mem, slice};
|
||||
use std::{cmp, mem, ptr, slice};
|
||||
|
||||
use orbclient::{Event, ResizeEvent};
|
||||
use syscall::error::*;
|
||||
use syscall::flag::{SEEK_SET, SEEK_CUR, SEEK_END};
|
||||
|
||||
use crate::display::Display;
|
||||
use crate::primitive::fast_copy;
|
||||
use crate::screen::Screen;
|
||||
|
||||
pub struct GraphicScreen {
|
||||
@@ -81,9 +80,17 @@ impl Screen for GraphicScreen {
|
||||
|
||||
if size > 0 {
|
||||
unsafe {
|
||||
fast_copy(self.display.offscreen.as_mut_ptr().offset(self.seek as isize) as *mut u8, buf.as_ptr(), size * 4);
|
||||
ptr::copy(
|
||||
buf.as_ptr(),
|
||||
self.display.offscreen.as_mut_ptr().offset(self.seek as isize) as *mut u8,
|
||||
size * 4
|
||||
);
|
||||
if sync {
|
||||
fast_copy(self.display.onscreen.as_mut_ptr().offset(self.seek as isize) as *mut u8, buf.as_ptr(), size * 4);
|
||||
ptr::copy(
|
||||
buf.as_ptr(),
|
||||
self.display.onscreen.as_mut_ptr().offset(self.seek as isize) as *mut u8,
|
||||
size * 4
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user