From: Andrew Jones <drjones@redhat.com> To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Cc: dgibson@redhat.com, david@gibson.dropbear.id.au, agraf@suse.de, thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com Subject: [kvm-unit-tests PATCH 08/14] powerpc/ppc64: add HV putchar Date: Mon, 3 Aug 2015 16:41:25 +0200 [thread overview] Message-ID: <1438612891-3718-9-git-send-email-drjones@redhat.com> (raw) In-Reply-To: <1438612891-3718-1-git-send-email-drjones@redhat.com> Add the hvcall for putchar and use it in puts. That, along with a couple more lines in start to prepare for C code, and a branch to main(), gets us "hello world". Run with qemu-system-ppc64 -M pseries \ -bios powerpc/boot_rom.bin \ -display none -serial stdio \ -kernel powerpc/selftest.elf (We're still not relocating yet, that comes in a later patch. Thus, testing hello-world at this point requires a hacked QEMU and linking the unit test at QEMU's kernel load address.) Signed-off-by: Andrew Jones <drjones@redhat.com> --- lib/powerpc/io.c | 15 +++++++++++++-- powerpc/Makefile.common | 1 + powerpc/cstart64.S | 27 +++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/lib/powerpc/io.c b/lib/powerpc/io.c index cf3b6347e1e46..a7eaafeca9205 100644 --- a/lib/powerpc/io.c +++ b/lib/powerpc/io.c @@ -6,15 +6,26 @@ * This work is licensed under the terms of the GNU LGPL, version 2. */ #include <libcflat.h> +#include <asm/spinlock.h> + +extern void halt(int code); +extern void putchar(int c); + +static struct spinlock uart_lock; void io_init(void) { } -void puts(const char *s __unused) +void puts(const char *s) { + spin_lock(&uart_lock); + while (*s) + putchar(*s++); + spin_unlock(&uart_lock); } -void exit(int code __unused) +void exit(int code) { + halt(code); } diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common index 5cd3ea8085038..d6356540918a5 100644 --- a/powerpc/Makefile.common +++ b/powerpc/Makefile.common @@ -26,6 +26,7 @@ CFLAGS += -ffreestanding CFLAGS += -Wextra CFLAGS += -O2 CFLAGS += -I lib -I lib/libfdt +CFLAGS += -Wa,-mregnames asm-offsets = lib/$(ARCH)/asm-offsets.h include scripts/asm-offsets.mak diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S index d9b77f44f9e0e..d7c51cd352ee4 100644 --- a/powerpc/cstart64.S +++ b/powerpc/cstart64.S @@ -6,14 +6,41 @@ * This work is licensed under the terms of the GNU LGPL, version 2. */ +#define HVSC .long 0x44000022 +#define H_PUT_TERM_CHAR 0x58 + +#define LOAD_REG_IMMEDIATE(reg,expr) \ + lis reg,(expr)@highest; \ + ori reg,reg,(expr)@higher; \ + rldicr reg,reg,32,31; \ + oris reg,reg,(expr)@h; \ + ori reg,reg,(expr)@l; + +#define LOAD_REG_ADDR(reg,name) \ + ld reg,name@got(r2) + .section .init .globl start start: + LOAD_REG_IMMEDIATE(r1, stackptr) + LOAD_REG_IMMEDIATE(r2, tocptr) + bl .main + bl .exit b halt .text +.align 3 .globl halt halt: 1: b 1b + +.globl putchar +putchar: + sldi r6, r3, 56 + li r3, H_PUT_TERM_CHAR + li r4, 0 /* vty-reg 0 means to use the default vty */ + li r5, 1 /* sending just 1 byte */ + HVSC + blr -- 2.4.3
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Jones <drjones@redhat.com> To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Cc: dgibson@redhat.com, david@gibson.dropbear.id.au, agraf@suse.de, thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com Subject: [kvm-unit-tests PATCH 08/14] powerpc/ppc64: add HV putchar Date: Mon, 03 Aug 2015 14:41:25 +0000 [thread overview] Message-ID: <1438612891-3718-9-git-send-email-drjones@redhat.com> (raw) In-Reply-To: <1438612891-3718-1-git-send-email-drjones@redhat.com> Add the hvcall for putchar and use it in puts. That, along with a couple more lines in start to prepare for C code, and a branch to main(), gets us "hello world". Run with qemu-system-ppc64 -M pseries \ -bios powerpc/boot_rom.bin \ -display none -serial stdio \ -kernel powerpc/selftest.elf (We're still not relocating yet, that comes in a later patch. Thus, testing hello-world at this point requires a hacked QEMU and linking the unit test at QEMU's kernel load address.) Signed-off-by: Andrew Jones <drjones@redhat.com> --- lib/powerpc/io.c | 15 +++++++++++++-- powerpc/Makefile.common | 1 + powerpc/cstart64.S | 27 +++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/lib/powerpc/io.c b/lib/powerpc/io.c index cf3b6347e1e46..a7eaafeca9205 100644 --- a/lib/powerpc/io.c +++ b/lib/powerpc/io.c @@ -6,15 +6,26 @@ * This work is licensed under the terms of the GNU LGPL, version 2. */ #include <libcflat.h> +#include <asm/spinlock.h> + +extern void halt(int code); +extern void putchar(int c); + +static struct spinlock uart_lock; void io_init(void) { } -void puts(const char *s __unused) +void puts(const char *s) { + spin_lock(&uart_lock); + while (*s) + putchar(*s++); + spin_unlock(&uart_lock); } -void exit(int code __unused) +void exit(int code) { + halt(code); } diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common index 5cd3ea8085038..d6356540918a5 100644 --- a/powerpc/Makefile.common +++ b/powerpc/Makefile.common @@ -26,6 +26,7 @@ CFLAGS += -ffreestanding CFLAGS += -Wextra CFLAGS += -O2 CFLAGS += -I lib -I lib/libfdt +CFLAGS += -Wa,-mregnames asm-offsets = lib/$(ARCH)/asm-offsets.h include scripts/asm-offsets.mak diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S index d9b77f44f9e0e..d7c51cd352ee4 100644 --- a/powerpc/cstart64.S +++ b/powerpc/cstart64.S @@ -6,14 +6,41 @@ * This work is licensed under the terms of the GNU LGPL, version 2. */ +#define HVSC .long 0x44000022 +#define H_PUT_TERM_CHAR 0x58 + +#define LOAD_REG_IMMEDIATE(reg,expr) \ + lis reg,(expr)@highest; \ + ori reg,reg,(expr)@higher; \ + rldicr reg,reg,32,31; \ + oris reg,reg,(expr)@h; \ + ori reg,reg,(expr)@l; + +#define LOAD_REG_ADDR(reg,name) \ + ld reg,name@got(r2) + .section .init .globl start start: + LOAD_REG_IMMEDIATE(r1, stackptr) + LOAD_REG_IMMEDIATE(r2, tocptr) + bl .main + bl .exit b halt .text +.align 3 .globl halt halt: 1: b 1b + +.globl putchar +putchar: + sldi r6, r3, 56 + li r3, H_PUT_TERM_CHAR + li r4, 0 /* vty-reg 0 means to use the default vty */ + li r5, 1 /* sending just 1 byte */ + HVSC + blr -- 2.4.3
next prev parent reply other threads:[~2015-08-03 14:41 UTC|newest] Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-08-03 14:41 [kvm-unit-tests PATCH 00/14] ppc64: initial drop Andrew Jones 2015-08-03 14:41 ` Andrew Jones 2015-08-03 14:41 ` [kvm-unit-tests PATCH 01/14] lib: asm-generic: add missing casts Andrew Jones 2015-08-03 14:41 ` Andrew Jones 2015-08-03 14:41 ` [kvm-unit-tests PATCH 02/14] lib: share arm-selftest utility functions Andrew Jones 2015-08-03 14:41 ` Andrew Jones 2015-08-03 14:41 ` [kvm-unit-tests PATCH 03/14] config: no need to mix arch makefiles Andrew Jones 2015-08-03 14:41 ` Andrew Jones 2015-08-03 14:41 ` [kvm-unit-tests PATCH 04/14] powerpc/ppc64: start skeleton framework Andrew Jones 2015-08-03 14:41 ` Andrew Jones 2015-08-03 14:41 ` [kvm-unit-tests PATCH 05/14] powerpc/pp64: ppc-ify makefiles and linker script Andrew Jones 2015-08-03 14:41 ` Andrew Jones 2015-08-03 14:41 ` [kvm-unit-tests PATCH 06/14] powerpc/ppc64: add boot rom source Andrew Jones 2015-08-03 14:41 ` Andrew Jones 2015-08-03 14:41 ` [kvm-unit-tests PATCH 07/14] powerpc/ppc64: add bootloader to bounce into memory Andrew Jones 2015-08-03 14:41 ` Andrew Jones 2015-08-03 14:41 ` Andrew Jones [this message] 2015-08-03 14:41 ` [kvm-unit-tests PATCH 08/14] powerpc/ppc64: add HV putchar Andrew Jones 2015-08-04 3:50 ` David Gibson 2015-08-04 3:50 ` David Gibson 2015-08-04 7:33 ` Andrew Jones 2015-08-04 7:33 ` Andrew Jones 2015-08-03 14:41 ` [kvm-unit-tests PATCH 09/14] powerpc/ppc64: adapt arm's setup Andrew Jones 2015-08-03 14:41 ` Andrew Jones 2015-08-03 14:41 ` [kvm-unit-tests PATCH 10/14] powerpc/ppc64: relocate linker VMAs Andrew Jones 2015-08-03 14:41 ` Andrew Jones 2015-08-04 3:53 ` David Gibson 2015-08-04 3:53 ` David Gibson 2015-08-04 7:35 ` Andrew Jones 2015-08-04 7:35 ` Andrew Jones 2015-08-03 14:41 ` [kvm-unit-tests PATCH 11/14] powerpc/ppc64: add rtas_power_off Andrew Jones 2015-08-03 14:41 ` Andrew Jones 2015-08-03 17:08 ` Paolo Bonzini 2015-08-03 17:08 ` Paolo Bonzini 2015-08-03 18:02 ` Andrew Jones 2015-08-03 18:02 ` Andrew Jones 2015-08-03 22:27 ` Alexander Graf 2015-08-03 22:27 ` Alexander Graf 2015-08-04 4:09 ` David Gibson 2015-08-04 4:09 ` David Gibson 2015-08-04 7:47 ` Andrew Jones 2015-08-04 7:47 ` Andrew Jones 2015-08-04 13:15 ` Paolo Bonzini 2015-08-04 13:15 ` Paolo Bonzini 2015-08-04 13:21 ` Andrew Jones 2015-08-04 13:21 ` Andrew Jones 2015-08-05 0:06 ` David Gibson 2015-08-05 0:06 ` David Gibson 2015-08-04 4:03 ` David Gibson 2015-08-04 4:03 ` David Gibson 2015-08-04 7:51 ` Andrew Jones 2015-08-04 7:51 ` Andrew Jones 2015-08-04 4:11 ` David Gibson 2015-08-04 4:11 ` David Gibson 2015-08-04 7:54 ` Andrew Jones 2015-08-04 7:54 ` Andrew Jones 2015-08-05 0:12 ` David Gibson 2015-08-05 0:12 ` David Gibson 2015-08-03 14:41 ` [kvm-unit-tests PATCH 12/14] scripts: add exit code snooper Andrew Jones 2015-08-03 14:41 ` Andrew Jones 2015-08-03 14:41 ` [kvm-unit-tests PATCH 13/14] powerpc/ppc64: add run script and unittests.cfg Andrew Jones 2015-08-03 14:41 ` Andrew Jones 2015-08-03 14:41 ` [kvm-unit-tests PATCH 14/14] mkstandalone: add support for powerpc Andrew Jones 2015-08-03 14:41 ` Andrew Jones 2015-08-03 17:06 ` [kvm-unit-tests PATCH 00/14] ppc64: initial drop Paolo Bonzini 2015-08-03 17:06 ` Paolo Bonzini 2015-11-03 7:08 ` Thomas Huth 2015-11-03 7:08 ` Thomas Huth 2015-11-03 9:40 ` Paolo Bonzini 2015-11-03 9:40 ` Paolo Bonzini 2015-11-03 14:56 ` Andrew Jones 2015-11-03 14:56 ` Andrew Jones
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=1438612891-3718-9-git-send-email-drjones@redhat.com \ --to=drjones@redhat.com \ --cc=agraf@suse.de \ --cc=david@gibson.dropbear.id.au \ --cc=dgibson@redhat.com \ --cc=kvm-ppc@vger.kernel.org \ --cc=kvm@vger.kernel.org \ --cc=lvivier@redhat.com \ --cc=pbonzini@redhat.com \ --cc=thuth@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: linkBe 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.