From: Gleb Natapov <gleb@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH kvm-unit-tests 2/2] realmode: print to serial port
Date: Thu, 9 May 2013 17:26:39 +0300 [thread overview]
Message-ID: <20130509142639.GS12349@redhat.com> (raw)
In-Reply-To: <1368109414-6458-3-git-send-email-pbonzini@redhat.com>
On Thu, May 09, 2013 at 04:23:34PM +0200, Paolo Bonzini wrote:
> The realmode test is still printing to the old debug port at 0xf1.
> Use the serial port instead.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> x86/realmode.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 63 insertions(+), 2 deletions(-)
>
> diff --git a/x86/realmode.c b/x86/realmode.c
> index 71c8a7d..67582b5 100644
> --- a/x86/realmode.c
> +++ b/x86/realmode.c
> @@ -1,3 +1,7 @@
> +#ifndef USE_SERIAL
> +#define USE_SERIAL
> +#endif
> +
> asm(".code16gcc");
>
> typedef unsigned char u8;
> @@ -22,16 +26,73 @@ static int strlen(const char *str)
> return n;
> }
>
> +static void outb(u8 data, u16 port)
> +{
> + asm volatile("out %0, %1" : : "a"(data), "d"(port));
> +}
> +
> +#ifdef USE_SERIAL
> +static int serial_iobase = 0x3f8;
> +static int serial_inited = 0;
It is never set to 1. The same is in the file this is copied from.
Noticed it while trying to do the same.
> +
> +static u8 inb(u16 port)
> +{
> + u8 data;
> + asm volatile("in %1, %0" : "=a"(data) : "d"(port));
> + return data;
> +}
> +
> +static void serial_outb(char ch)
> +{
> + u8 lsr;
> +
> + do {
> + lsr = inb(serial_iobase + 0x05);
> + } while (!(lsr & 0x20));
> +
> + outb(ch, serial_iobase + 0x00);
> +}
> +
> +static void serial_init(void)
> +{
> + u8 lcr;
> +
> + /* set DLAB */
> + lcr = inb(serial_iobase + 0x03);
> + lcr |= 0x80;
> + outb(lcr, serial_iobase + 0x03);
> +
> + /* set baud rate to 115200 */
> + outb(0x01, serial_iobase + 0x00);
> + outb(0x00, serial_iobase + 0x01);
> +
> + /* clear DLAB */
> + lcr = inb(serial_iobase + 0x03);
> + lcr &= ~0x80;
> + outb(lcr, serial_iobase + 0x03);
> +}
> +#endif
> +
> static void print_serial(const char *buf)
> {
> unsigned long len = strlen(buf);
> -
> +#ifdef USE_SERIAL
> + unsigned long i;
> + if (!serial_inited) {
> + serial_init();
> + }
> +
> + for (i = 0; i < len; i++) {
> + serial_outb(buf[i]);
> + }
> +#else
> asm volatile ("addr32/rep/outsb" : "+S"(buf), "+c"(len) : "d"(0xf1));
> +#endif
> }
>
> static void exit(int code)
> {
> - asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4));
> + outb(code, 0xf4);
> }
>
> struct regs {
> --
> 1.8.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Gleb.
prev parent reply other threads:[~2013-05-09 14:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-09 14:23 [PATCH kvm-unit-tests 0/2] realmode: print to serial port Paolo Bonzini
2013-05-09 14:23 ` [PATCH kvm-unit-tests 1/2] realmode: restore DF at exit from exec_in_big_real_mode Paolo Bonzini
2013-05-09 14:23 ` [PATCH kvm-unit-tests 2/2] realmode: print to serial port Paolo Bonzini
2013-05-09 14:26 ` Gleb Natapov [this message]
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=20130509142639.GS12349@redhat.com \
--to=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.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 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.