aboutsummaryrefslogtreecommitdiff
path: root/src/machine/device_io.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/machine/device_io.rs')
-rw-r--r--src/machine/device_io.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/machine/device_io.rs b/src/machine/device_io.rs
index 4573653..2a0c907 100644
--- a/src/machine/device_io.rs
+++ b/src/machine/device_io.rs
@@ -1,2 +1,22 @@
#[cfg(target_arch = "x86_64")]
pub use crate::arch::x86_64::io_port::*;
+
+// either use the io functions directly, or via a IOPort instance.
+pub struct IOPort(u16);
+impl IOPort {
+ pub fn new(port: u16) -> Self {
+ Self(port)
+ }
+ pub fn inw(&self) -> u16 {
+ inw(self.0)
+ }
+ pub fn inb(&self) -> u8 {
+ inb(self.0)
+ }
+ pub fn outw(&self, val: u16) {
+ outw(self.0, val);
+ }
+ pub fn outb(&self, val: u8) {
+ outb(self.0, val);
+ }
+}