All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@seco.com>
To: Tom Rini <trini@konsulko.com>
Cc: Liviu Dudau <liviu.dudau@foss.arm.com>,
	u-boot@lists.denx.de, Simon Glass <sjg@chromium.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Andre Przywara <andre.przywara@arm.com>,
	Sean Anderson <sean.anderson@seco.com>
Subject: [PATCH v2 27/28] serial: sandbox: Implement puts
Date: Thu, 10 Mar 2022 15:50:57 -0500	[thread overview]
Message-ID: <20220310205059.499269-28-sean.anderson@seco.com> (raw)
In-Reply-To: <20220310205059.499269-1-sean.anderson@seco.com>

This implements puts for sandbox. It is fairly straightforward, except
that we break out the shared color printing functionality into its own
function.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

Changes in v2:
- New

 drivers/serial/sandbox.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c
index 0b1756f5c0..9843e4a70d 100644
--- a/drivers/serial/sandbox.c
+++ b/drivers/serial/sandbox.c
@@ -67,7 +67,7 @@ static int sandbox_serial_remove(struct udevice *dev)
 	return 0;
 }
 
-static int sandbox_serial_putc(struct udevice *dev, const char ch)
+static void sandbox_print_color(struct udevice *dev)
 {
 	struct sandbox_serial_priv *priv = dev_get_priv(dev);
 	struct sandbox_serial_plat *plat = dev_get_plat(dev);
@@ -78,7 +78,13 @@ static int sandbox_serial_putc(struct udevice *dev, const char ch)
 		priv->start_of_line = false;
 		output_ansi_colour(plat->colour);
 	}
+}
 
+static int sandbox_serial_putc(struct udevice *dev, const char ch)
+{
+	struct sandbox_serial_priv *priv = dev_get_priv(dev);
+
+	sandbox_print_color(dev);
 	os_write(1, &ch, 1);
 	if (ch == '\n')
 		priv->start_of_line = true;
@@ -86,6 +92,18 @@ static int sandbox_serial_putc(struct udevice *dev, const char ch)
 	return 0;
 }
 
+static int sandbox_serial_puts(struct udevice *dev, const char *s, size_t *len)
+{
+	struct sandbox_serial_priv *priv = dev_get_priv(dev);
+
+	sandbox_print_color(dev);
+	os_write(1, s, *len);
+	if (s[*len - 1] == '\n')
+		priv->start_of_line = true;
+
+	return 0;
+}
+
 static int sandbox_serial_pending(struct udevice *dev, bool input)
 {
 	struct sandbox_serial_priv *priv = dev_get_priv(dev);
@@ -212,6 +230,7 @@ static int sandbox_serial_of_to_plat(struct udevice *dev)
 
 static const struct dm_serial_ops sandbox_serial_ops = {
 	.putc = sandbox_serial_putc,
+	.puts = sandbox_serial_puts,
 	.pending = sandbox_serial_pending,
 	.getc = sandbox_serial_getc,
 	.getconfig = sandbox_serial_getconfig,
-- 
2.25.1


  parent reply	other threads:[~2022-03-10 20:56 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10 20:50 [PATCH v2 00/28] arm: semihosting: Cleanups and new features Sean Anderson
2022-03-10 20:50 ` [PATCH v2 01/28] doc: Convert semihosting readme to rST Sean Anderson
2022-03-10 20:50 ` [PATCH v2 02/28] nxp: ls1046ardb: Convert README " Sean Anderson
2022-03-10 20:50 ` [PATCH v2 03/28] doc: ls1046ardb: Expand boot mode section Sean Anderson
2022-03-10 20:50 ` [PATCH v2 04/28] doc: ls1046ardb: Document debug uart Sean Anderson
2022-03-10 20:50 ` [PATCH v2 05/28] arm: smh: Add semihosting entry to MAINTAINERS Sean Anderson
2022-03-10 20:50 ` [PATCH v2 06/28] arm: smh: Export semihosting functions Sean Anderson
2022-03-10 20:50 ` [PATCH v2 07/28] arm: smh: Use numeric modes for smh_open Sean Anderson
2022-03-10 20:50 ` [PATCH v2 08/28] arm: smh: Return errno on error Sean Anderson
2022-03-10 20:50 ` [PATCH v2 09/28] arm: smh: Document functions in header Sean Anderson
2022-03-10 20:50 ` [PATCH v2 10/28] arm: smh: Add some file manipulation commands Sean Anderson
2022-03-10 20:50 ` [PATCH v2 11/28] spl: Add semihosting boot method Sean Anderson
2022-03-10 20:50 ` [PATCH v2 12/28] fs: Add semihosting filesystem Sean Anderson
2022-03-10 20:50 ` [PATCH v2 13/28] cmd: fdt: Use start/size for chosen instead of start/end Sean Anderson
2022-03-10 20:50 ` [PATCH v2 14/28] arm: smh: Remove smhload command Sean Anderson
2022-03-10 20:50 ` [PATCH v2 15/28] arm: smh: Add some functions for working with the host console Sean Anderson
2022-03-10 20:50 ` [PATCH v2 16/28] serial: Add semihosting driver Sean Anderson
2022-03-10 20:50 ` [PATCH v2 17/28] doc: smh: Update semihosting documentation Sean Anderson
2022-03-10 20:50 ` [PATCH v2 18/28] ls1046ardb: Add support for JTAG boot Sean Anderson
2022-03-10 20:50 ` [PATCH v2 19/28] arm64: Save esr in pt_regs Sean Anderson
2022-03-10 20:50 ` [PATCH v2 20/28] arm64: Save spsr " Sean Anderson
2022-03-10 21:01   ` Sean Anderson
2022-03-10 20:50 ` [PATCH v2 21/28] arm64: Import some ESR and SPSR defines from Linux Sean Anderson
2022-03-10 20:50 ` [PATCH v2 22/28] arm: smh: Add option to detect semihosting Sean Anderson
2022-03-10 20:50 ` [PATCH v2 23/28] arm: Catch non-emulated semihosting calls Sean Anderson
2022-03-10 20:50 ` [PATCH v2 24/28] serial: smh: Initialize serial only if semihosting is enabled Sean Anderson
2022-03-10 20:50 ` [PATCH v2 25/28] arm64: ls1046a: Support semihosting fallback Sean Anderson
2022-03-10 20:50 ` [PATCH v2 26/28] serial: dm: Add support for puts Sean Anderson
2022-03-11 15:40   ` Sean Anderson
2022-03-12  5:02   ` Simon Glass
2022-03-12  5:53     ` Sean Anderson
2022-03-12 17:58       ` Simon Glass
2022-03-10 20:50 ` Sean Anderson [this message]
2022-03-10 20:50 ` [PATCH v2 28/28] serial: smh: Implement puts for DM Sean Anderson
2022-03-11 18:22 ` [PATCH v2 00/28] arm: semihosting: Cleanups and new features Andre Przywara
2022-03-11 19:20   ` Sean Anderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220310205059.499269-28-sean.anderson@seco.com \
    --to=sean.anderson@seco.com \
    --cc=andre.przywara@arm.com \
    --cc=linus.walleij@linaro.org \
    --cc=liviu.dudau@foss.arm.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.