Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Release 1.0
[palacios.git] / misc / test_vm / src / geekos / io.c
diff --git a/misc/test_vm/src/geekos/io.c b/misc/test_vm/src/geekos/io.c
new file mode 100644 (file)
index 0000000..70b9f50
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * x86 port IO routines
+ * Copyright (c) 2001, David H. Hovemeyer <daveho@cs.umd.edu>
+ * $Revision: 1.2 $
+ * 
+ * This is free software.  You are permitted to use,
+ * redistribute, and modify it as specified in the file "COPYING".
+ */
+
+#include <geekos/io.h>
+
+/*
+ * Write a byte to an I/O port.
+ */
+void Out_Byte(ushort_t port, uchar_t value)
+{
+    __asm__ __volatile__ (
+       "outb %b0, %w1"
+       :
+       : "a" (value), "Nd" (port)
+    );
+}
+
+extern uchar_t InByteLL(ushort_t port);
+
+/*
+ * Read a byte from an I/O port.
+ */
+uchar_t In_Byte(ushort_t port)
+{
+  /*
+    uchar_t value;
+
+    __asm__ __volatile__ (
+       "inb %w1, %b0"
+       : "=a" (value)
+       : "Nd" (port)
+    );
+
+    return value;
+  */
+
+  return InByteLL(port);
+}
+
+/*
+ * Write a word to an I/O port.
+ */
+void Out_Word(ushort_t port, ushort_t value)
+{
+    __asm__ __volatile__ (
+       "outw %w0, %w1"
+       :
+       : "a" (value), "Nd" (port)
+    );
+}
+
+/*
+ * Read a byte from an I/O port.
+ */
+ushort_t In_Word(ushort_t port)
+{
+    ushort_t value;
+
+    __asm__ __volatile__ (
+       "inw %w1, %w0"
+       : "=a" (value)
+       : "Nd" (port)
+    );
+
+    return value;
+}
+
+/*
+ * Short delay.  May be needed when talking to some
+ * (slow) I/O devices.
+ */
+void IO_Delay(void)
+{
+    uchar_t value = 0;
+    __asm__ __volatile__ (
+       "outb %0, $0x80"
+       :
+       : "a" (value)
+    );
+}