Patchwork [RFC,v2,4/6] Add uart test case

login
register
mail settings
Submitter Anthony Liguori
Date Dec. 1, 2011, 6:43 p.m.
Message ID <1322765012-3164-5-git-send-email-aliguori@us.ibm.com>
Download mbox | patch
Permalink /patch/128784/
State New
Headers show

Comments

Anthony Liguori - Dec. 1, 2011, 6:43 p.m.
---
 serial-test.py |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
 create mode 100644 serial-test.py

Patch

diff --git a/serial-test.py b/serial-test.py
new file mode 100644
index 0000000..7aed0cb
--- /dev/null
+++ b/serial-test.py
@@ -0,0 +1,24 @@ 
+from qtest import outb, inb
+import qtest, sys
+
+def main(args):
+    if len(args) != 1:
+        raise Exception('Missing argument')
+
+    qtest.init(args[0])
+
+    base = 0x3f8
+
+    # disable THRE and RDA interrupt
+    outb(base + 1, 0x00)
+
+    for ch in "Hello, World!\r\n":
+        # wait for THRE
+        while (inb(base + 5) & 0x20) == 0:
+            pass
+
+        outb(base + 0, ord(ch))
+
+
+if __name__ == '__main__':
+    sys.exit(main(sys.argv[1:]))