From: Julius Werner <jwerner@chromium.org>
To: grub-devel@gnu.org
Cc: Paul Menzel <paulepanter@users.sourceforge.net>,
Vladimir Serbinenko <phcoder@google.com>,
Julius Werner <jwerner@chromium.org>
Subject: [PATCH] grub-core/term/i386/coreboot/cbmemc.c: Update console format
Date: Mon, 24 Apr 2017 17:00:08 -0700 [thread overview]
Message-ID: <20170425000008.10286-1-jwerner@chromium.org> (raw)
Changed cbmemc to support updated console format from coreboot.
---
grub-core/term/i386/coreboot/cbmemc.c | 44 +++++++++++++++++++++++++----------
1 file changed, 32 insertions(+), 12 deletions(-)
diff --git a/grub-core/term/i386/coreboot/cbmemc.c b/grub-core/term/i386/coreboot/cbmemc.c
index 25e64a05c..9e20f52fb 100644
--- a/grub-core/term/i386/coreboot/cbmemc.c
+++ b/grub-core/term/i386/coreboot/cbmemc.c
@@ -29,11 +29,14 @@
GRUB_MOD_LICENSE ("GPLv3+");
+#define CURSOR_MASK (1 << 28)
+#define OVERFLOW (1 << 31)
+
struct grub_linuxbios_cbmemc
{
grub_uint32_t size;
- grub_uint32_t pointer;
- char data[0];
+ grub_uint32_t cursor;
+ char body[0];
};
static struct grub_linuxbios_cbmemc *cbmemc;
@@ -41,11 +44,20 @@ static struct grub_linuxbios_cbmemc *cbmemc;
static void
put (struct grub_term_output *term __attribute__ ((unused)), const int c)
{
+ grub_uint32_t flags, cursor;
if (!cbmemc)
return;
- if (cbmemc->pointer < cbmemc->size)
- cbmemc->data[cbmemc->pointer] = c;
- cbmemc->pointer++;
+ flags = cbmemc->cursor & ~CURSOR_MASK;
+ cursor = cbmemc->cursor & CURSOR_MASK;
+ if (cursor >= cbmemc->size)
+ return;
+ cbmemc->body[cursor++] = c;
+ if (cursor >= cbmemc->size)
+ {
+ cursor = 0;
+ flags |= OVERFLOW;
+ }
+ cbmemc->cursor = flags | cursor;
}
struct grub_terminfo_output_state grub_cbmemc_terminfo_output =
@@ -87,20 +99,28 @@ grub_cmd_cbmemc (struct grub_command *cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char *argv[] __attribute__ ((unused)))
{
- grub_size_t len;
- char *str;
+ grub_size_t size, cursor;
struct grub_linuxbios_cbmemc *cbmemc_saved;
if (!cbmemc)
return grub_error (GRUB_ERR_IO, "no CBMEM console found");
- len = cbmemc->pointer;
- if (len > cbmemc->size)
- len = cbmemc->size;
- str = cbmemc->data;
cbmemc_saved = cbmemc;
cbmemc = 0;
- grub_xnputs (str, len);
+ cursor = cbmemc->cursor & CURSOR_MASK;
+ if (!(cbmemc->cursor & OVERFLOW) && cursor < cbmemc->size)
+ size = cursor;
+ else
+ size = cbmemc->size;
+ if (cbmemc->cursor & OVERFLOW)
+ {
+ if (cursor > size)
+ cursor = 0;
+ grub_xnputs(cbmemc->body + cursor, size - cursor);
+ grub_xnputs(cbmemc->body, cursor);
+ }
+ else
+ grub_xnputs(cbmemc->body, size);
cbmemc = cbmemc_saved;
return 0;
}
--
2.12.2
next reply other threads:[~2017-04-25 1:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-25 0:00 Julius Werner [this message]
2017-04-25 20:18 ` [PATCH v2] grub-core/term/i386/coreboot/cbmemc.c: Update console format Julius Werner
2017-05-09 7:03 ` Vladimir 'phcoder' Serbinenko
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=20170425000008.10286-1-jwerner@chromium.org \
--to=jwerner@chromium.org \
--cc=grub-devel@gnu.org \
--cc=paulepanter@users.sourceforge.net \
--cc=phcoder@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).