Update to modern Rust syntax
This commit is contained in:
parent
7fa1bdadb9
commit
74317be64b
20
rust/Cargo.lock
generated
20
rust/Cargo.lock
generated
@ -1,12 +1,5 @@
|
|||||||
[root]
|
# This file is automatically @generated by Cargo.
|
||||||
name = "pH"
|
# It is not intended for manual editing.
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"termios 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
@ -17,6 +10,15 @@ name = "libc"
|
|||||||
version = "0.2.32"
|
version = "0.2.32"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pH"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"termios 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "termios"
|
name = "termios"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
name = "pH"
|
name = "pH"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Bruce Leidl <bruce@subgraph.com>"]
|
authors = ["Bruce Leidl <bruce@subgraph.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name="pH"
|
name="pH"
|
||||||
|
@ -2,7 +2,7 @@ use std::sync::{Arc,RwLock};
|
|||||||
use std::mem;
|
use std::mem;
|
||||||
use libc;
|
use libc;
|
||||||
|
|
||||||
use vm::io::{IoDispatcher,IoPortOps};
|
use crate::vm::io::{IoDispatcher,IoPortOps};
|
||||||
|
|
||||||
const RTC_SECONDS: u8 = 0x00;
|
const RTC_SECONDS: u8 = 0x00;
|
||||||
const RTC_MINUTES: u8 = 0x02;
|
const RTC_MINUTES: u8 = 0x02;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
|
|
||||||
use vm::io::{IoPortOps,IoDispatcher};
|
use crate::vm::io::{IoPortOps,IoDispatcher};
|
||||||
use kvm::Kvm;
|
use crate::kvm::Kvm;
|
||||||
|
|
||||||
const UART_TX: u16 = 0;
|
const UART_TX: u16 = 0;
|
||||||
const UART_RX: u16 = 0;
|
const UART_RX: u16 = 0;
|
||||||
|
@ -6,7 +6,7 @@ use std::fs;
|
|||||||
|
|
||||||
use libc;
|
use libc;
|
||||||
|
|
||||||
use memory::GuestRam;
|
use crate::memory::GuestRam;
|
||||||
use super::pdu::{PduParser,P9Attr};
|
use super::pdu::{PduParser,P9Attr};
|
||||||
use super::fid::FidCache;
|
use super::fid::FidCache;
|
||||||
use super::filesystem::{FileSystem,FsTouch,FileSystemOps};
|
use super::filesystem::{FileSystem,FsTouch,FileSystemOps};
|
||||||
|
@ -3,9 +3,9 @@ use std::thread;
|
|||||||
|
|
||||||
use std::path::{Path,PathBuf};
|
use std::path::{Path,PathBuf};
|
||||||
|
|
||||||
use memory::GuestRam;
|
use crate::memory::GuestRam;
|
||||||
use virtio::{self,VirtioBus,VirtioDeviceOps, VirtQueue};
|
use crate::virtio::{self,VirtioBus,VirtioDeviceOps, VirtQueue};
|
||||||
use vm::Result;
|
use crate::vm::Result;
|
||||||
|
|
||||||
mod fid;
|
mod fid;
|
||||||
mod pdu;
|
mod pdu;
|
||||||
|
@ -5,8 +5,8 @@ use std::io::{self,Read,Write};
|
|||||||
use std::os::linux::fs::MetadataExt;
|
use std::os::linux::fs::MetadataExt;
|
||||||
use std::os::unix::ffi::OsStrExt;
|
use std::os::unix::ffi::OsStrExt;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use memory::GuestRam;
|
use crate::memory::GuestRam;
|
||||||
use virtio::Chain;
|
use crate::virtio::Chain;
|
||||||
|
|
||||||
use super::filesystem::StatFs;
|
use super::filesystem::StatFs;
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@ use std::sync::{Arc,RwLock};
|
|||||||
use std::thread;
|
use std::thread;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|
||||||
use virtio::{VirtioDeviceOps,VirtioBus,VirtQueue};
|
use crate::virtio::{VirtioDeviceOps,VirtioBus,VirtQueue};
|
||||||
use memory::GuestRam;
|
use crate::memory::GuestRam;
|
||||||
use vm::Result;
|
use crate::vm::Result;
|
||||||
|
|
||||||
|
|
||||||
const VIRTIO_ID_RANDOM: u16 = 4;
|
const VIRTIO_ID_RANDOM: u16 = 4;
|
||||||
|
@ -3,9 +3,9 @@ use std::io::{self,Write,Read};
|
|||||||
use std::thread::spawn;
|
use std::thread::spawn;
|
||||||
use termios::*;
|
use termios::*;
|
||||||
|
|
||||||
use virtio::{VirtioDeviceOps,VirtioBus, VirtQueue};
|
use crate::virtio::{VirtioDeviceOps,VirtioBus, VirtQueue};
|
||||||
use memory::GuestRam;
|
use crate::memory::GuestRam;
|
||||||
use vm::Result;
|
use crate::vm::Result;
|
||||||
|
|
||||||
const VIRTIO_ID_CONSOLE: u16 = 3;
|
const VIRTIO_ID_CONSOLE: u16 = 3;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ impl VirtioSerial {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use system::ioctl;
|
use crate::system::ioctl;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -3,9 +3,9 @@ use std::os::unix::io::RawFd;
|
|||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use system::ioctl::{ioctl_with_val,ioctl_with_ref,ioctl_with_mut_ref};
|
use crate::system::ioctl::{ioctl_with_val,ioctl_with_ref,ioctl_with_mut_ref};
|
||||||
|
|
||||||
use vm::{Result,Error,ErrorKind};
|
use crate::vm::{Result,Error,ErrorKind};
|
||||||
|
|
||||||
|
|
||||||
const KVMIO: u64 = 0xAE;
|
const KVMIO: u64 = 0xAE;
|
||||||
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
mod ioctl;
|
mod ioctl;
|
||||||
|
|
||||||
use vm::{Result,Error,ErrorKind};
|
use crate::vm::{Result,Error,ErrorKind};
|
||||||
pub use self::ioctl::{KvmCpuIdEntry,KvmLapicState, KvmSRegs, KvmRegs, KvmFpu, KvmMsrs, KvmSegment};
|
pub use self::ioctl::{KvmCpuIdEntry,KvmLapicState, KvmSRegs, KvmRegs, KvmFpu, KvmMsrs, KvmSegment};
|
||||||
|
|
||||||
pub const KVM_CAP_IRQCHIP: u32 = 0;
|
pub const KVM_CAP_IRQCHIP: u32 = 0;
|
||||||
|
@ -5,7 +5,7 @@ use std::mem;
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::os::unix::io::RawFd;
|
use std::os::unix::io::RawFd;
|
||||||
|
|
||||||
use vm::{Result,Error,ErrorKind};
|
use crate::vm::{Result,Error,ErrorKind};
|
||||||
|
|
||||||
pub struct Mapping {
|
pub struct Mapping {
|
||||||
ptr: *mut u8,
|
ptr: *mut u8,
|
||||||
|
@ -2,12 +2,12 @@ use std::sync::Arc;
|
|||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use memory::Mapping;
|
use crate::memory::Mapping;
|
||||||
use memory::mmap::Serializable;
|
use crate::memory::mmap::Serializable;
|
||||||
use memory::AddressRange;
|
use crate::memory::AddressRange;
|
||||||
|
|
||||||
use kvm::Kvm;
|
use crate::kvm::Kvm;
|
||||||
use vm::{Result,Error,ErrorKind};
|
use crate::vm::{Result,Error,ErrorKind};
|
||||||
|
|
||||||
pub const HIMEM_BASE: u64 = (1 << 32);
|
pub const HIMEM_BASE: u64 = (1 << 32);
|
||||||
pub const PCI_MMIO_RESERVED_SIZE: usize = (512 << 20);
|
pub const PCI_MMIO_RESERVED_SIZE: usize = (512 << 20);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use libc::{self, c_ulong, c_void};
|
use libc::{self, c_ulong, c_void};
|
||||||
use std::os::unix::io::RawFd;
|
use std::os::unix::io::RawFd;
|
||||||
use vm::{Error,Result};
|
use crate::vm::{Error,Result};
|
||||||
|
|
||||||
pub const IOC_SIZEBITS: u64 = 14;
|
pub const IOC_SIZEBITS: u64 = 14;
|
||||||
pub const IOC_DIRBITS: u64 = 2;
|
pub const IOC_DIRBITS: u64 = 2;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use std::sync::{Arc,RwLock};
|
use std::sync::{Arc,RwLock};
|
||||||
use vm::io::IoDispatcher;
|
use crate::vm::io::IoDispatcher;
|
||||||
use kvm::Kvm;
|
use crate::kvm::Kvm;
|
||||||
use memory::{GuestRam,AddressRange};
|
use crate::memory::{GuestRam,AddressRange};
|
||||||
use super::{VirtioDevice,VirtioDeviceOps,PciIrq};
|
use super::{VirtioDevice,VirtioDeviceOps,PciIrq};
|
||||||
use super::consts::*;
|
use super::consts::*;
|
||||||
use super::pci::PciBus;
|
use super::pci::PciBus;
|
||||||
use vm::Result;
|
use crate::vm::Result;
|
||||||
|
|
||||||
|
|
||||||
pub struct VirtioBus {
|
pub struct VirtioBus {
|
||||||
@ -27,7 +27,7 @@ impl VirtioBus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_virtio_device(&mut self, device_type: u16, ops: Arc<RwLock<VirtioDeviceOps>>) -> VirtioDeviceConfig {
|
pub fn new_virtio_device(&mut self, device_type: u16, ops: Arc<RwLock<dyn VirtioDeviceOps>>) -> VirtioDeviceConfig {
|
||||||
VirtioDeviceConfig::new(self, device_type, ops)
|
VirtioDeviceConfig::new(self, device_type, ops)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ pub struct VirtioDeviceConfig<'a> {
|
|||||||
device_type: u16,
|
device_type: u16,
|
||||||
irq: u8,
|
irq: u8,
|
||||||
kvm: Kvm,
|
kvm: Kvm,
|
||||||
ops: Arc<RwLock<VirtioDeviceOps>>,
|
ops: Arc<RwLock<dyn VirtioDeviceOps>>,
|
||||||
mmio: AddressRange,
|
mmio: AddressRange,
|
||||||
num_queues: usize,
|
num_queues: usize,
|
||||||
config_size: usize,
|
config_size: usize,
|
||||||
@ -51,7 +51,7 @@ pub struct VirtioDeviceConfig<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl <'a> VirtioDeviceConfig<'a> {
|
impl <'a> VirtioDeviceConfig<'a> {
|
||||||
fn new(virtio_bus: &mut VirtioBus, device_type: u16, ops: Arc<RwLock<VirtioDeviceOps>>) -> VirtioDeviceConfig {
|
fn new(virtio_bus: &mut VirtioBus, device_type: u16, ops: Arc<RwLock<dyn VirtioDeviceOps>>) -> VirtioDeviceConfig {
|
||||||
let kvm = virtio_bus.kvm.clone();
|
let kvm = virtio_bus.kvm.clone();
|
||||||
let mmio = virtio_bus.pci_bus.write().unwrap().allocate_mmio_space(VIRTIO_MMIO_AREA_SIZE);
|
let mmio = virtio_bus.pci_bus.write().unwrap().allocate_mmio_space(VIRTIO_MMIO_AREA_SIZE);
|
||||||
VirtioDeviceConfig {
|
VirtioDeviceConfig {
|
||||||
@ -70,7 +70,7 @@ impl <'a> VirtioDeviceConfig<'a> {
|
|||||||
|
|
||||||
pub fn kvm(&self) -> &Kvm { &self.kvm }
|
pub fn kvm(&self) -> &Kvm { &self.kvm }
|
||||||
|
|
||||||
pub fn ops(&self) -> Arc<RwLock<VirtioDeviceOps>> {
|
pub fn ops(&self) -> Arc<RwLock<dyn VirtioDeviceOps>> {
|
||||||
self.ops.clone()
|
self.ops.clone()
|
||||||
}
|
}
|
||||||
pub fn irq(&self) -> u8 { self.irq }
|
pub fn irq(&self) -> u8 { self.irq }
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
use std::io::{self,Read,Write};
|
use std::io::{self,Read,Write};
|
||||||
|
|
||||||
use memory::GuestRam;
|
use crate::memory::GuestRam;
|
||||||
use super::VirtQueue;
|
use super::VirtQueue;
|
||||||
use super::vring::Descriptor;
|
use super::vring::Descriptor;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use memory::GuestRam;
|
use crate::memory::GuestRam;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use vm::Result;
|
use crate::vm::Result;
|
||||||
|
|
||||||
use super::VirtQueue;
|
use super::VirtQueue;
|
||||||
use super::eventfd::IoEventFd;
|
use super::eventfd::IoEventFd;
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
use std::sync::{Arc,RwLock};
|
use std::sync::{Arc,RwLock};
|
||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
|
|
||||||
use memory::{GuestRam,AddressRange};
|
use crate::memory::{GuestRam,AddressRange};
|
||||||
use super::bus::VirtioDeviceConfig;
|
use super::bus::VirtioDeviceConfig;
|
||||||
use super::VirtQueue;
|
use super::VirtQueue;
|
||||||
use super::config::VirtQueueConfig;
|
use super::config::VirtQueueConfig;
|
||||||
use super::consts::*;
|
use super::consts::*;
|
||||||
use vm::io::MmioOps;
|
use crate::vm::io::MmioOps;
|
||||||
use vm::Result;
|
use crate::vm::Result;
|
||||||
|
|
||||||
pub trait VirtioDeviceOps: Send+Sync {
|
pub trait VirtioDeviceOps: Send+Sync {
|
||||||
fn reset(&mut self) {}
|
fn reset(&mut self) {}
|
||||||
@ -24,7 +24,7 @@ pub struct VirtioDevice {
|
|||||||
isr_mmio: AddressRange,
|
isr_mmio: AddressRange,
|
||||||
notify_mmio: AddressRange,
|
notify_mmio: AddressRange,
|
||||||
device_cfg_mmio: Option<AddressRange>,
|
device_cfg_mmio: Option<AddressRange>,
|
||||||
device_ops: Arc<RwLock<VirtioDeviceOps>>,
|
device_ops: Arc<RwLock<dyn VirtioDeviceOps>>,
|
||||||
dfselect: u32,
|
dfselect: u32,
|
||||||
gfselect: u32,
|
gfselect: u32,
|
||||||
device_features: u64,
|
device_features: u64,
|
||||||
@ -182,7 +182,7 @@ impl VirtioDevice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn with_ops<U,F>(&self, f: F) -> U
|
fn with_ops<U,F>(&self, f: F) -> U
|
||||||
where F: FnOnce(&mut VirtioDeviceOps) -> U {
|
where F: FnOnce(&mut dyn VirtioDeviceOps) -> U {
|
||||||
let mut ops = self.device_ops.write().unwrap();
|
let mut ops = self.device_ops.write().unwrap();
|
||||||
f(ops.deref_mut())
|
f(ops.deref_mut())
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ use std::os::unix::io::RawFd;
|
|||||||
|
|
||||||
use libc;
|
use libc;
|
||||||
|
|
||||||
use vm::{Result,Error,ErrorKind};
|
use crate::vm::{Result,Error,ErrorKind};
|
||||||
use kvm::Kvm;
|
use crate::kvm::Kvm;
|
||||||
|
|
||||||
pub struct EventFd(RawFd);
|
pub struct EventFd(RawFd);
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ impl EventFd {
|
|||||||
}
|
}
|
||||||
return Err(Error::new(ErrorKind::EventFdError, "read failed"));
|
return Err(Error::new(ErrorKind::EventFdError, "read failed"));
|
||||||
}
|
}
|
||||||
Ok((v))
|
Ok(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use std::sync::{Arc,RwLock};
|
use std::sync::{Arc,RwLock};
|
||||||
use byteorder::{ByteOrder,LittleEndian};
|
use byteorder::{ByteOrder,LittleEndian};
|
||||||
|
|
||||||
use vm::io::{IoDispatcher,IoPortOps};
|
use crate::vm::io::{IoDispatcher,IoPortOps};
|
||||||
use memory::PCI_MMIO_RESERVED_BASE;
|
use crate::memory::PCI_MMIO_RESERVED_BASE;
|
||||||
use memory::AddressRange;
|
use crate::memory::AddressRange;
|
||||||
use super::consts::*;
|
use super::consts::*;
|
||||||
|
|
||||||
struct PciConfigAddress(u32);
|
struct PciConfigAddress(u32);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use std::sync::atomic::{Ordering, AtomicUsize, AtomicBool};
|
use std::sync::atomic::{Ordering, AtomicUsize, AtomicBool};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use memory::GuestRam;
|
use crate::memory::GuestRam;
|
||||||
use kvm::Kvm;
|
use crate::kvm::Kvm;
|
||||||
use vm::Result;
|
use crate::vm::Result;
|
||||||
|
|
||||||
use super::eventfd::{EventFd,IoEventFd};
|
use super::eventfd::{EventFd,IoEventFd};
|
||||||
use super::consts::*;
|
use super::consts::*;
|
||||||
|
@ -4,10 +4,10 @@ use std::fmt;
|
|||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::io::{self, Read};
|
use std::io::{self, Read};
|
||||||
|
|
||||||
use memory::GuestRam;
|
use crate::memory::GuestRam;
|
||||||
use super::consts::*;
|
use super::consts::*;
|
||||||
|
|
||||||
use vm::{Result,Error,ErrorKind};
|
use crate::vm::{Result,Error,ErrorKind};
|
||||||
|
|
||||||
///
|
///
|
||||||
/// A convenience wrapper around `AtomicUsize`
|
/// A convenience wrapper around `AtomicUsize`
|
||||||
|
@ -68,7 +68,7 @@ enum Repr {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct General {
|
struct General {
|
||||||
kind: ErrorKind,
|
kind: ErrorKind,
|
||||||
error: Box<error::Error+Send+Sync>,
|
error: Box<dyn error::Error+Send+Sync>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -78,11 +78,11 @@ pub struct Error {
|
|||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
pub fn new<E>(kind: ErrorKind, error: E) -> Error
|
pub fn new<E>(kind: ErrorKind, error: E) -> Error
|
||||||
where E: Into<Box<error::Error+Send+Sync>> {
|
where E: Into<Box<dyn error::Error+Send+Sync>> {
|
||||||
Self::_new(kind, error.into())
|
Self::_new(kind, error.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _new(kind: ErrorKind, error: Box<error::Error+Send+Sync>) -> Error {
|
fn _new(kind: ErrorKind, error: Box<dyn error::Error+Send+Sync>) -> Error {
|
||||||
Error {
|
Error {
|
||||||
repr: Repr::General(Box::new(General{
|
repr: Repr::General(Box::new(General{
|
||||||
kind, error
|
kind, error
|
||||||
@ -159,7 +159,7 @@ impl error::Error for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cause(&self) -> Option<&error::Error> {
|
fn cause(&self) -> Option<&dyn error::Error> {
|
||||||
match self.repr {
|
match self.repr {
|
||||||
Repr::Errno(..) => None,
|
Repr::Errno(..) => None,
|
||||||
Repr::Simple(..) => None,
|
Repr::Simple(..) => None,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use std::sync::{Arc,RwLock,RwLockWriteGuard};
|
use std::sync::{Arc,RwLock,RwLockWriteGuard};
|
||||||
use memory::AddressRange;
|
use crate::memory::AddressRange;
|
||||||
|
|
||||||
pub trait IoPortOps: Send+Sync {
|
pub trait IoPortOps: Send+Sync {
|
||||||
fn io_in(&mut self, port: u16, size: usize) -> u32 {
|
fn io_in(&mut self, port: u16, size: usize) -> u32 {
|
||||||
@ -55,11 +55,11 @@ impl IoPortOps for IoPortFakeI8042 {
|
|||||||
struct IoPortEntry {
|
struct IoPortEntry {
|
||||||
port: u16,
|
port: u16,
|
||||||
count: usize,
|
count: usize,
|
||||||
device: Arc<RwLock<IoPortOps>>,
|
device: Arc<RwLock<dyn IoPortOps>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IoPortEntry {
|
impl IoPortEntry {
|
||||||
fn new(port: u16, count: usize, device: Arc<RwLock<IoPortOps>>) -> IoPortEntry {
|
fn new(port: u16, count: usize, device: Arc<RwLock<dyn IoPortOps>>) -> IoPortEntry {
|
||||||
IoPortEntry{ port: port, count: count, device: device }
|
IoPortEntry{ port: port, count: count, device: device }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,11 +80,11 @@ impl IoPortEntry {
|
|||||||
|
|
||||||
struct MmioEntry {
|
struct MmioEntry {
|
||||||
range: AddressRange,
|
range: AddressRange,
|
||||||
device: Arc<RwLock<MmioOps>>,
|
device: Arc<RwLock<dyn MmioOps>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MmioEntry {
|
impl MmioEntry {
|
||||||
fn new(range: AddressRange, device: Arc<RwLock<MmioOps>>) -> MmioEntry {
|
fn new(range: AddressRange, device: Arc<RwLock<dyn MmioOps>>) -> MmioEntry {
|
||||||
MmioEntry{ range, device }
|
MmioEntry{ range, device }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,11 +117,11 @@ impl IoDispatcher {
|
|||||||
self.state.write().unwrap()
|
self.state.write().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register_ioports(&self, port: u16, count: usize, dev: Arc<RwLock<IoPortOps>>) {
|
pub fn register_ioports(&self, port: u16, count: usize, dev: Arc<RwLock<dyn IoPortOps>>) {
|
||||||
self.state_mut().register_ioports(port, count, dev)
|
self.state_mut().register_ioports(port, count, dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register_mmio(&self, range: AddressRange, device: Arc<RwLock<MmioOps>>) {
|
pub fn register_mmio(&self, range: AddressRange, device: Arc<RwLock<dyn MmioOps>>) {
|
||||||
self.state_mut().register_mmio(range, device);
|
self.state_mut().register_mmio(range, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,11 +159,11 @@ impl IoDispatcherState {
|
|||||||
st
|
st
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_ioports(&mut self, port: u16, count: usize, dev: Arc<RwLock<IoPortOps>>) {
|
fn register_ioports(&mut self, port: u16, count: usize, dev: Arc<RwLock<dyn IoPortOps>>) {
|
||||||
self.ioport_entries.push(IoPortEntry::new(port, count, dev));
|
self.ioport_entries.push(IoPortEntry::new(port, count, dev));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_mmio(&mut self, range: AddressRange, device: Arc<RwLock<MmioOps>>) {
|
fn register_mmio(&mut self, range: AddressRange, device: Arc<RwLock<dyn MmioOps>>) {
|
||||||
self.mmio_entries.push(MmioEntry::new(range, device));
|
self.mmio_entries.push(MmioEntry::new(range, device));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::os::unix::ffi::OsStrExt;
|
use std::os::unix::ffi::OsStrExt;
|
||||||
|
|
||||||
use memory::{GuestRam,KERNEL_CMDLINE_ADDRESS};
|
use crate::memory::{GuestRam,KERNEL_CMDLINE_ADDRESS};
|
||||||
use super::Result;
|
use super::Result;
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,11 +5,11 @@ use std::env;
|
|||||||
|
|
||||||
use self::io::IoDispatcher;
|
use self::io::IoDispatcher;
|
||||||
|
|
||||||
use virtio::VirtioBus;
|
use crate::virtio::VirtioBus;
|
||||||
use devices;
|
use crate::devices;
|
||||||
|
|
||||||
use memory::{GuestRam,KVM_KERNEL_LOAD_ADDRESS};
|
use crate::memory::{GuestRam,KVM_KERNEL_LOAD_ADDRESS};
|
||||||
use kvm::*;
|
use crate::kvm::*;
|
||||||
|
|
||||||
|
|
||||||
mod run;
|
mod run;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use kvm::KvmVcpu;
|
use crate::kvm::KvmVcpu;
|
||||||
use memory::Mapping;
|
use crate::memory::Mapping;
|
||||||
use super::Result;
|
use super::Result;
|
||||||
use super::io::IoDispatcher;
|
use super::io::IoDispatcher;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use vm::Result;
|
use crate::vm::Result;
|
||||||
|
|
||||||
use kvm::{KvmVcpu,KvmRegs,KvmFpu, KvmMsrs, KvmSegment};
|
use crate::kvm::{KvmVcpu,KvmRegs,KvmFpu, KvmMsrs, KvmSegment};
|
||||||
use memory::{GuestRam,KERNEL_ZERO_PAGE};
|
use crate::memory::{GuestRam,KERNEL_ZERO_PAGE};
|
||||||
|
|
||||||
|
|
||||||
const MSR_IA32_SYSENTER_CS: u32 = 0x00000174;
|
const MSR_IA32_SYSENTER_CS: u32 = 0x00000174;
|
||||||
|
@ -4,8 +4,8 @@ use std::fs::{File};
|
|||||||
use std::io::{self, Read,SeekFrom,Seek};
|
use std::io::{self, Read,SeekFrom,Seek};
|
||||||
use byteorder::{LittleEndian,ReadBytesExt};
|
use byteorder::{LittleEndian,ReadBytesExt};
|
||||||
|
|
||||||
use memory::{self,GuestRam,KERNEL_ZERO_PAGE};
|
use crate::memory::{self,GuestRam,KERNEL_ZERO_PAGE};
|
||||||
use vm::{Result,Error,ErrorKind};
|
use crate::vm::{Result,Error,ErrorKind};
|
||||||
|
|
||||||
|
|
||||||
// Documentation/x86/boot.txt
|
// Documentation/x86/boot.txt
|
||||||
|
@ -2,9 +2,9 @@ use byteorder::{LittleEndian, WriteBytesExt};
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
use memory::GuestRam;
|
use crate::memory::GuestRam;
|
||||||
use virtio::PciIrq;
|
use crate::virtio::PciIrq;
|
||||||
use vm::Result;
|
use crate::vm::Result;
|
||||||
|
|
||||||
const APIC_DEFAULT_PHYS_BASE: u32 = 0xfee00000;
|
const APIC_DEFAULT_PHYS_BASE: u32 = 0xfee00000;
|
||||||
const IO_APIC_DEFAULT_PHYS_BASE: u32 = 0xfec00000;
|
const IO_APIC_DEFAULT_PHYS_BASE: u32 = 0xfec00000;
|
||||||
|
Loading…
Reference in New Issue
Block a user