diff options
author | Simon Glass <sjg@chromium.org> | 2011-10-03 19:26:46 +0000 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2011-10-17 23:56:58 +0200 |
commit | 7accb6ea56738adb538eedbe19d5089624cf8860 (patch) | |
tree | 4be538163cc8285e9592ac4fa014e7caf94fb8e1 /drivers/serial | |
parent | bace3d00f28040f061e0e21126bc70cfb9d20930 (diff) | |
download | u-boot-imx-7accb6ea56738adb538eedbe19d5089624cf8860.zip u-boot-imx-7accb6ea56738adb538eedbe19d5089624cf8860.tar.gz u-boot-imx-7accb6ea56738adb538eedbe19d5089624cf8860.tar.bz2 |
sandbox: Add serial uart
This uart simply writes to stdout and reads from stdin. We might imagine
instead buffering the data so that a test interface can check output and
inject input.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/serial')
-rw-r--r-- | drivers/serial/Makefile | 1 | ||||
-rw-r--r-- | drivers/serial/sandbox.c | 63 |
2 files changed, 64 insertions, 0 deletions
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index 1dcc1c7..6309549 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile @@ -53,6 +53,7 @@ COBJS-$(CONFIG_SA1100_SERIAL) += serial_sa1100.o COBJS-$(CONFIG_S3C24X0_SERIAL) += serial_s3c24x0.o COBJS-$(CONFIG_S3C44B0_SERIAL) += serial_s3c44b0.o COBJS-$(CONFIG_XILINX_UARTLITE) += serial_xuartlite.o +COBJS-$(CONFIG_SANDBOX_SERIAL) += sandbox.o COBJS-$(CONFIG_SCIF_CONSOLE) += serial_sh.o COBJS-$(CONFIG_TEGRA2) += serial_tegra2.o diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c new file mode 100644 index 0000000..0d65587 --- /dev/null +++ b/drivers/serial/sandbox.c @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/* + * This provide a test serial port. It provides an emulated serial port where + * a test program and read out the serial output and inject serial input for + * U-Boot. + */ + +#include <common.h> +#include <os.h> + +int serial_init(void) +{ + return 0; +} + +void serial_setbrg(void) +{ +} + +void serial_putc(const char ch) +{ + os_write(1, &ch, 1); +} + +void serial_puts(const char *str) +{ + while (*str) + serial_putc(*str++); +} + +int serial_getc(void) +{ + char buf; + int count; + + count = os_read(0, &buf, 1); + return count == 1 ? buf : 0; +} + +int serial_tstc(void) +{ + return 0; +} |