aboutsummaryrefslogtreecommitdiff
path: root/board-qemu
diff options
context:
space:
mode:
authorNikunj A Dadhania <nikunj@linux.vnet.ibm.com>2016-10-10 16:47:06 +0530
committerAlexey Kardashevskiy <aik@ozlabs.ru>2016-10-13 10:47:05 +1100
commit8e92d6b3e8d6ac0625356f058da6ddae316e2cdc (patch)
tree1df9cff96c1bec5ebac4c3bbbe856202d83be38c /board-qemu
parentc1ab43d25be823fce882771f8407ddd93b893ac6 (diff)
downloadSLOF-8e92d6b3e8d6ac0625356f058da6ddae316e2cdc.zip
SLOF-8e92d6b3e8d6ac0625356f058da6ddae316e2cdc.tar.gz
SLOF-8e92d6b3e8d6ac0625356f058da6ddae316e2cdc.tar.bz2
Add virtio-serial device support
Add support for virtio serial device to be used as a console device. Currently, SLOF only supports spapr-vty device. With this addition virtio console can be used during boot. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'board-qemu')
-rw-r--r--board-qemu/slof/Makefile3
-rw-r--r--board-qemu/slof/OF.fs24
-rw-r--r--board-qemu/slof/pci-device_1af4_1003.fs25
-rw-r--r--board-qemu/slof/pci-device_1af4_1043.fs15
-rw-r--r--board-qemu/slof/virtio-serial.fs94
5 files changed, 155 insertions, 6 deletions
diff --git a/board-qemu/slof/Makefile b/board-qemu/slof/Makefile
index 940a15a..cf57f16 100644
--- a/board-qemu/slof/Makefile
+++ b/board-qemu/slof/Makefile
@@ -69,6 +69,8 @@ VIO_FFS_FILES = \
$(SLOFBRDDIR)/pci-device_1af4_1041.fs \
$(SLOFBRDDIR)/pci-device_1af4_1001.fs \
$(SLOFBRDDIR)/pci-device_1af4_1042.fs \
+ $(SLOFBRDDIR)/pci-device_1af4_1003.fs \
+ $(SLOFBRDDIR)/pci-device_1af4_1043.fs \
$(SLOFBRDDIR)/pci-device_1af4_1004.fs \
$(SLOFBRDDIR)/pci-device_1af4_1048.fs \
$(SLOFBRDDIR)/pci-device_1af4_1009.fs \
@@ -79,6 +81,7 @@ VIO_FFS_FILES = \
$(SLOFBRDDIR)/vio-veth.fs \
$(SLOFBRDDIR)/rtas-nvram.fs \
$(SLOFBRDDIR)/virtio-net.fs \
+ $(SLOFBRDDIR)/virtio-serial.fs \
$(SLOFBRDDIR)/virtio-block.fs \
$(SLOFBRDDIR)/virtio-fs.fs \
$(SLOFBRDDIR)/dev-null.fs \
diff --git a/board-qemu/slof/OF.fs b/board-qemu/slof/OF.fs
index 206800c..1406506 100644
--- a/board-qemu/slof/OF.fs
+++ b/board-qemu/slof/OF.fs
@@ -162,6 +162,10 @@ CREATE version-str 10 ALLOT
: dump-display-write
s" screen" find-alias IF
drop terminal-write drop
+ ELSE
+ s" vsterm" find-alias IF
+ drop type
+ THEN
THEN
;
@@ -236,12 +240,20 @@ romfs-base 400000 0 ' claim CATCH IF ." claim failed!" cr 2drop THEN drop
." using hvterm" cr
" hvterm" io
ELSE
- " /openprom" find-node ?dup IF
- set-node
- ." and no default found, creating dev-null" cr
- " dev-null.fs" included
- " devnull-console" io
- 0 set-node
+ " vsterm" find-alias IF
+ drop
+ ." using vsterm" cr
+ " vsterm" io
+ false to store-prevga?
+ dump-display-buffer
+ ELSE
+ " /openprom" find-node ?dup IF
+ set-node
+ ." and no default found, creating dev-null" cr
+ " dev-null.fs" included
+ " devnull-console" io
+ 0 set-node
+ THEN
THEN
THEN
THEN
diff --git a/board-qemu/slof/pci-device_1af4_1003.fs b/board-qemu/slof/pci-device_1af4_1003.fs
new file mode 100644
index 0000000..a7cd53b
--- /dev/null
+++ b/board-qemu/slof/pci-device_1af4_1003.fs
@@ -0,0 +1,25 @@
+\ *****************************************************************************
+\ * Copyright (c) 2016 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ ****************************************************************************/
+
+\ Handle virtio-serial device
+
+s" virtio [ serial ]" type cr
+
+my-space pci-device-generic-setup
+
+pci-master-enable
+pci-mem-enable
+pci-io-enable
+
+s" virtio-serial.fs" included
+
+pci-device-disable
diff --git a/board-qemu/slof/pci-device_1af4_1043.fs b/board-qemu/slof/pci-device_1af4_1043.fs
new file mode 100644
index 0000000..f044450
--- /dev/null
+++ b/board-qemu/slof/pci-device_1af4_1043.fs
@@ -0,0 +1,15 @@
+\ *****************************************************************************
+\ * Copyright (c) 2016 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ ****************************************************************************/
+
+\ Device ID 1044 is for virtio-serial non-transitional device.
+\ Include the driver for virtio-serial
+s" pci-device_1af4_1003.fs" included
diff --git a/board-qemu/slof/virtio-serial.fs b/board-qemu/slof/virtio-serial.fs
new file mode 100644
index 0000000..42ab3e2
--- /dev/null
+++ b/board-qemu/slof/virtio-serial.fs
@@ -0,0 +1,94 @@
+\ *****************************************************************************
+\ * Copyright (c) 2016 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ ****************************************************************************/
+
+s" serial" device-type
+
+FALSE VALUE initialized?
+
+virtio-setup-vd VALUE virtiodev
+
+\ Quiescence the virtqueue of this device so that no more background
+\ transactions can be pending.
+: shutdown ( -- )
+ initialized? IF
+ my-phandle node>path open-dev ?dup IF
+ virtiodev virtio-serial-shutdown
+ close-dev
+ THEN
+ FALSE to initialized?
+ THEN
+;
+
+: virtio-serial-term-emit
+ virtiodev SWAP virtio-serial-putchar
+;
+
+: virtio-serial-term-key? virtiodev virtio-serial-haschar ;
+: virtio-serial-term-key BEGIN virtio-serial-term-key? UNTIL virtiodev virtio-serial-getchar ;
+
+\ Basic device initialization - which has only to be done once
+: init ( -- )
+virtiodev virtio-serial-init drop
+ TRUE to initialized?
+ ['] virtio-serial-term-emit to emit
+ ['] virtio-serial-term-key to key
+ ['] virtio-serial-term-key? to key?
+ ['] shutdown add-quiesce-xt
+;
+
+0 VALUE open-count
+
+\ Standard node "open" function
+: open ( -- okay? )
+ open-count 0= IF
+ open IF initialized? 0= IF init THEN
+ true
+ ELSE false exit
+ THEN
+ ELSE true THEN
+ open-count 1 + to open-count
+;
+
+: close
+ open-count 0> IF
+ open-count 1 - dup to open-count
+ 0= IF close THEN
+ THEN
+ close
+;
+
+: write ( addr len -- actual )
+ tuck
+ 0 ?DO
+ dup c@ virtiodev SWAP virtio-serial-putchar
+ 1 +
+ LOOP
+ drop
+;
+
+: read ( addr len -- actual )
+ 0= IF drop 0 EXIT THEN
+ virtiodev virtio-serial-haschar 0= IF 0 swap c! -2 EXIT THEN
+ virtiodev virtio-serial-getchar swap c! 1
+;
+
+: setup-alias
+ " vsterm" find-alias 0= IF
+ " vsterm" get-node node>path set-alias
+ ELSE drop THEN
+;
+setup-alias
+
+\ Override serial methods to make term-io.fs happy
+: serial-emit virtio-serial-term-emit ;
+: serial-key? virtio-serial-term-key? ;
+: serial-key virtio-serial-term-key ;