commit 0be390cab1d76a0e4444a993a3619fa7426c4c74
parent 563e1d61afab3d8c845fd1b151148458c07c118e
Author: Ambroise Vincent <ambroise.vincent@arm.com>
Date: Fri, 10 May 2019 16:15:17 +0100
[drivers] Add dummy UART driver for hosted
Change-Id: Iad5e0fe9b5d1355df4ef2c9a499b3515bce666d3
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
Diffstat:
7 files changed, 118 insertions(+), 4 deletions(-)
diff --git a/README b/README
@@ -20,6 +20,9 @@ make CROSS_COMPILE=aarch64-linux-gnu- BL2_AT_EL3=1 BL33=<bl33.bin> all fip
Running rcode
=============
+On amd64-linux, use 'stty -echo raw min 1' before launching rcode with the
+dummy uart driver.
+
Launch the FVP model with the following options:
#!/bin/sh
diff --git a/drivers/dummyuart.c b/drivers/dummyuart.c
@@ -0,0 +1,95 @@
+#include <rcode/rcode.h>
+#include <rcode/io.h>
+
+#include "dev.h"
+#include "uart.h"
+
+extern int sys_read(int fd, void *buf, size_t n);
+extern int sys_write(int fd, void *buf, size_t n);
+
+static int
+setbauds(Uart *up, long rate)
+{
+ return 0;
+}
+
+static void
+dummyuartinit(Uart *up, Attr *attr)
+{
+ return;
+}
+
+static int
+dummyuartread(Uart *up, void *buf, int n)
+{
+ return sys_read(0, buf, n);
+}
+
+static int
+dummyuartwrite(Uart *up, void *buf, int n)
+{
+ return sys_write(1, buf, n);
+}
+
+static int
+dummyuartsignal(Uart *up, int sign, int val)
+{
+ return 1;
+}
+
+static int
+dummyuartflush(Uart *up)
+{
+ return 0;
+}
+
+static int
+dummyuartfifo(Uart *up, int trigger)
+{
+ return 0;
+}
+
+static int
+dummyuartbits(Uart *up, int nbits)
+{
+ return 0;
+}
+
+static int
+dummyuartparity(Uart *up, int mode)
+{
+ return 0;
+}
+
+static int
+dummyuartstop(Uart *up, int nbits)
+{
+ return 0;
+}
+
+static int
+dummyuartobey(Uart *up, int signal, int ena)
+{
+ return 0;
+}
+
+static int
+dummyuartstatus(Uart *up, struct uartstat *st)
+{
+ return 0;
+}
+
+const Uartphy dummyuartphy = {
+ .init = dummyuartinit,
+ .setbauds = setbauds,
+ .read = dummyuartread,
+ .write = dummyuartwrite,
+ .signal = dummyuartsignal,
+ .flush = dummyuartflush,
+ .setfifo = dummyuartfifo,
+ .numbits = dummyuartbits,
+ .parity = dummyuartparity,
+ .bitstop = dummyuartstop,
+ .obey = dummyuartobey,
+ .status = dummyuartstatus,
+};
diff --git a/src/libc/arch/amd64/linux/Makefile b/src/libc/arch/amd64/linux/Makefile
@@ -24,6 +24,8 @@ OBJS = _Exit.o \
time.o \
_sys_errlist.o \
crt.o \
+ sys_read.o \
+ sys_write.o
all: syscall
$(MAKE) objs
diff --git a/src/libc/arch/amd64/linux/sys_read.s b/src/libc/arch/amd64/linux/sys_read.s
@@ -0,0 +1,7 @@
+ .file "sys_read.s"
+
+ .globl sys_read
+sys_read:
+ movq $0,%rax
+ syscall
+ jmp _cerrno
diff --git a/src/libc/arch/amd64/linux/sys_write.s b/src/libc/arch/amd64/linux/sys_write.s
@@ -0,0 +1,7 @@
+ .file "sys_write.s"
+
+ .globl sys_write
+sys_write:
+ movq $1,%rax
+ syscall
+ jmp _cerrno
diff --git a/src/libc/arch/amd64/linux/syscall.lst b/src/libc/arch/amd64/linux/syscall.lst
@@ -1,6 +1,6 @@
#number name
-0 _read
-1 _write
+0 sys_read
+1 sys_write
2 _open
3 _close
8 _lseek
diff --git a/target/hosted/rcode b/target/hosted/rcode
@@ -1,8 +1,8 @@
dev
root
uart
- pl011 base=0x1c0c0000,clk=24000000,cfg=b115200 l8 #t0
- pl011 base=0x1c0c0100,clk=24000000 #t1
+ dummyuart base=0x1c0c0000,clk=24000000,cfg=b115200 l8 #t0
+ dummyuart base=0x1c0c0100,clk=24000000 #t1
cons
ar
blob