forked from rcore-os/zCore
Compare commits
2 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
5cc704f0fe | |
|
|
c7ebbdd973 |
|
|
@ -299,6 +299,21 @@ pub fn irq_is_valid(irq: u32) -> bool {
|
|||
get_ioapic(irq).is_some()
|
||||
}
|
||||
|
||||
#[export_name = "hal_allow_ioport"]
|
||||
pub fn allow_ioport(_port: u16) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
#[export_name = "hal_allow_ioport"]
|
||||
pub fn allowed_ioport(_port: u16) -> u64 {
|
||||
// TODO
|
||||
}
|
||||
|
||||
#[export_name = "hal_deny_ioport"]
|
||||
pub fn deny_ioport(_port: u16) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
fn breakpoint() {
|
||||
panic!("\nEXCEPTION: Breakpoint");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -386,6 +386,24 @@ pub fn inpd(_port: u16) -> u32 {
|
|||
unimplemented!()
|
||||
}
|
||||
|
||||
#[linkage = "weak"]
|
||||
#[export_name = "hal_allow_ioport"]
|
||||
pub fn allow_ioport(_port: u16) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[linkage = "weak"]
|
||||
#[export_name = "hal_allowed_ioport"]
|
||||
pub fn allowed_ioport(_port: u16) -> u64 {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[linkage = "weak"]
|
||||
#[export_name = "hal_deny_ioport"]
|
||||
pub fn deny_ioport(_port: u16) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
/// Get local APIC ID
|
||||
#[linkage = "weak"]
|
||||
#[export_name = "hal_apic_local_id"]
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use {
|
|||
};
|
||||
|
||||
pub use self::thread_state::*;
|
||||
use kernel_hal::{allow_ioport, deny_ioport, allowed_ioport};
|
||||
|
||||
mod thread_state;
|
||||
|
||||
|
|
@ -188,7 +189,7 @@ impl Thread {
|
|||
context.general.rsp = stack;
|
||||
context.general.rdi = arg1;
|
||||
context.general.rsi = arg2;
|
||||
context.general.rflags |= 0x3202;
|
||||
context.general.rflags |= 0x202;
|
||||
}
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
{
|
||||
|
|
@ -216,7 +217,7 @@ impl Thread {
|
|||
context.general = regs;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
{
|
||||
context.general.rflags |= 0x3202;
|
||||
context.general.rflags |= 0x202;
|
||||
}
|
||||
inner.state = ThreadState::Running;
|
||||
self.base.signal_set(Signal::THREAD_RUNNING);
|
||||
|
|
@ -389,6 +390,18 @@ impl Thread {
|
|||
}
|
||||
ExceptionFuture
|
||||
}
|
||||
|
||||
pub fn allow_ioport(&self, port: u16) {
|
||||
allow_ioport(port);
|
||||
}
|
||||
|
||||
pub fn deny_ioport(&self, port: u16) {
|
||||
deny_ioport(port);
|
||||
}
|
||||
|
||||
pub fn allowed_ioport(&self, port: u16) -> u64 {
|
||||
allowed_ioport(port);
|
||||
}
|
||||
}
|
||||
|
||||
impl Task for Thread {
|
||||
|
|
|
|||
|
|
@ -247,6 +247,42 @@ impl Syscall<'_> {
|
|||
out.write_if_not_null(timestamp)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn sys_ioports_request(
|
||||
&self,
|
||||
resource: HandleValue,
|
||||
io_addr: u16,
|
||||
len: u32,
|
||||
) -> ZxResult {
|
||||
info!(
|
||||
"sys_ioports_request: resource={:?} io_addr={:?} len={:?}",
|
||||
resource, io_addr, len
|
||||
);
|
||||
let proc = self.thread.proc();
|
||||
let resource = proc.get_object::<Resource>(resource)?;
|
||||
resource.validate_ranged_resource(ResourceKind::IOPORT, io_addr as usize, len as usize)?;
|
||||
// TODO: mark in proc
|
||||
self.thread.allow_ioport(io_addr);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn sys_ioports_release(
|
||||
&self,
|
||||
resource: HandleValue,
|
||||
io_addr: u16,
|
||||
len: u32,
|
||||
) -> ZxResult {
|
||||
info!(
|
||||
"sys_ioports_release: resource={:?} io_addr={:?} len={:?}",
|
||||
resource, io_addr, len
|
||||
);
|
||||
let proc = self.thread.proc();
|
||||
let resource = proc.get_object::<Resource>(resource)?;
|
||||
resource.validate_ranged_resource(ResourceKind::IOPORT, io_addr as usize, len as usize)?;
|
||||
// TODO: mark in proc
|
||||
self.thread.deny_ioport(io_addr);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
const IOMMU_TYPE_DUMMY: u32 = 0;
|
||||
|
|
|
|||
|
|
@ -333,10 +333,8 @@ impl Syscall<'_> {
|
|||
Sys::INTERRUPT_ACK => self.sys_interrupt_ack(a0 as _),
|
||||
Sys::INTERRUPT_DESTROY => self.sys_interrupt_destroy(a0 as _),
|
||||
Sys::INTERRUPT_WAIT => self.sys_interrupt_wait(a0 as _, a1.into()).await,
|
||||
Sys::IOPORTS_REQUEST => {
|
||||
warn!("ioports.request: skip");
|
||||
Ok(())
|
||||
}
|
||||
Sys::IOPORTS_REQUEST => self.sys_ioports_request(a0 as _, a1 as _, a2 as _),
|
||||
Sys::IOPORTS_RELEASE => self.sys_ioports_release(a0 as _, a1 as _, a2 as _),
|
||||
_ => {
|
||||
error!("syscall unimplemented: {:?}", sys_type);
|
||||
Err(ZxError::NOT_SUPPORTED)
|
||||
|
|
|
|||
Loading…
Reference in New Issue