From patchwork Tue Oct 4 05:26:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 117554 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3FC88B6F80 for ; Tue, 4 Oct 2011 16:29:58 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A76F12844D; Tue, 4 Oct 2011 07:29:21 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KQNOuqJej5tK; Tue, 4 Oct 2011 07:29:21 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0F410283B9; Tue, 4 Oct 2011 07:28:15 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 92C0F28394 for ; Tue, 4 Oct 2011 07:28:04 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ziITwyxkeSXz for ; Tue, 4 Oct 2011 07:28:03 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp-out.google.com (smtp-out.google.com [74.125.121.67]) by theia.denx.de (Postfix) with ESMTPS id 51BC028362 for ; Tue, 4 Oct 2011 07:27:55 +0200 (CEST) Received: from hpaq5.eem.corp.google.com (hpaq5.eem.corp.google.com [172.25.149.5]) by smtp-out.google.com with ESMTP id p945Rrk2001802; Mon, 3 Oct 2011 22:27:53 -0700 Received: from sglass.mtv.corp.google.com (sglass.mtv.corp.google.com [172.22.72.144]) by hpaq5.eem.corp.google.com with ESMTP id p945RoIP029952; Mon, 3 Oct 2011 22:27:52 -0700 Received: by sglass.mtv.corp.google.com (Postfix, from userid 121222) id EBC2C14137E; Mon, 3 Oct 2011 22:27:48 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 3 Oct 2011 22:26:46 -0700 Message-Id: <1317706010-17151-16-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1317706010-17151-1-git-send-email-sjg@chromium.org> References: <1317706010-17151-1-git-send-email-sjg@chromium.org> X-System-Of-Record: true Subject: [U-Boot] [PATCH v4 15/19] sandbox: Add serial uart X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 --- Changes in v4: - Remove serial_exit() drivers/serial/Makefile | 1 + drivers/serial/sandbox.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 0 deletions(-) create mode 100644 drivers/serial/sandbox.c 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 +#include + +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; +}