From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com
Subject: [PATCH kvm-unit-tests 4/8] powerpc: Introduce getchar
Date: Wed, 7 Feb 2018 20:03:30 +0100 [thread overview]
Message-ID: <20180207190334.16516-5-drjones@redhat.com> (raw)
In-Reply-To: <20180207190334.16516-1-drjones@redhat.com>
Move the unit test specific h_get_term_char() to powerpc common code
and call it getchar(). Other architectures may want to implement
getchar() too (ARM will in a coming patch), so put the prototype in
libcflat.h
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
lib/libcflat.h | 1 +
lib/powerpc/asm/hcall.h | 1 +
lib/powerpc/hcall.c | 12 ++++++++++++
powerpc/sprs.c | 14 +-------------
4 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/lib/libcflat.h b/lib/libcflat.h
index fb465415c14a..c680b69a926e 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -82,6 +82,7 @@ typedef u64 phys_addr_t;
#define INVALID_PHYS_ADDR (~(phys_addr_t)0)
extern void puts(const char *s);
+extern int getchar(void);
extern void exit(int code);
extern void abort(void);
extern long atol(const char *ptr);
diff --git a/lib/powerpc/asm/hcall.h b/lib/powerpc/asm/hcall.h
index 80aa3e304382..a8bd7e3afc37 100644
--- a/lib/powerpc/asm/hcall.h
+++ b/lib/powerpc/asm/hcall.h
@@ -19,6 +19,7 @@
#define H_SET_DABR 0x28
#define H_PAGE_INIT 0x2c
#define H_CEDE 0xE0
+#define H_GET_TERM_CHAR 0x54
#define H_PUT_TERM_CHAR 0x58
#define H_RANDOM 0x300
#define H_SET_MODE 0x31C
diff --git a/lib/powerpc/hcall.c b/lib/powerpc/hcall.c
index cd6d26680f7c..d65af93697e4 100644
--- a/lib/powerpc/hcall.c
+++ b/lib/powerpc/hcall.c
@@ -31,3 +31,15 @@ void putchar(int c)
hcall(H_PUT_TERM_CHAR, vty, nr_chars, chars);
}
+
+int getchar(void)
+{
+ register unsigned long r3 asm("r3") = H_GET_TERM_CHAR;
+ register unsigned long r4 asm("r4") = 0; /* 0 == default vty */
+ register unsigned long r5 asm("r5");
+
+ asm volatile (" sc 1 " : "+r"(r3), "+r"(r4), "=r"(r5)
+ : "r"(r3), "r"(r4));
+
+ return r3 == H_SUCCESS && r4 > 0 ? r5 >> 48 : 0;
+}
diff --git a/powerpc/sprs.c b/powerpc/sprs.c
index 3b920e9f929a..5b5a54032819 100644
--- a/powerpc/sprs.c
+++ b/powerpc/sprs.c
@@ -38,18 +38,6 @@
uint64_t before[1024], after[1024];
-static int h_get_term_char(uint64_t termno)
-{
- register uint64_t r3 asm("r3") = 0x54; /* H_GET_TERM_CHAR */
- register uint64_t r4 asm("r4") = termno;
- register uint64_t r5 asm("r5");
-
- asm volatile (" sc 1 " : "+r"(r3), "+r"(r4), "=r"(r5)
- : "r"(r3), "r"(r4));
-
- return r3 == H_SUCCESS && r4 > 0 ? r5 >> 48 : 0;
-}
-
/* Common SPRs for all PowerPC CPUs */
static void set_sprs_common(uint64_t val)
{
@@ -297,7 +285,7 @@ int main(int argc, char **argv)
if (pause) {
puts("Now migrate the VM, then press a key to continue...\n");
- while (h_get_term_char(0) == 0)
+ while (getchar() == 0)
cpu_relax();
} else {
puts("Sleeping...\n");
--
2.13.6
next prev parent reply other threads:[~2018-02-07 19:03 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 19:03 [PATCH kvm-unit-tests 0/8] arm/arm64: extend psci tests Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 1/8] virtio-mmio: fix queue allocation Andrew Jones
2018-02-07 19:32 ` Andrew Jones
2018-02-07 19:34 ` [PATCH kvm-unit-tests v2 " Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 2/8] scripts/arch-run: run_migration improvements Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 3/8] powerpc: don't use NMI's to signal end of migration Andrew Jones
2018-02-08 10:58 ` Thomas Huth
2018-02-07 19:03 ` Andrew Jones [this message]
2018-02-08 11:06 ` [PATCH kvm-unit-tests 4/8] powerpc: Introduce getchar Thomas Huth
2018-02-08 12:59 ` Andrew Jones
2018-02-14 11:43 ` Paolo Bonzini
2018-02-14 12:38 ` Andrew Jones
2018-02-14 13:25 ` Paolo Bonzini
2018-02-14 14:38 ` Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 5/8] lib: Introduce do_migration Andrew Jones
2018-02-14 11:45 ` Paolo Bonzini
2018-02-14 12:44 ` Andrew Jones
2018-02-14 13:24 ` Paolo Bonzini
2018-02-07 19:03 ` [PATCH kvm-unit-tests 6/8] arm/arm64: Add support for migration tests Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 7/8] arm/arm64: psci: add migration test Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 8/8] arm/psci: add smccc 1.1 tests Andrew Jones
2018-02-14 11:46 ` [PATCH kvm-unit-tests 0/8] arm/arm64: extend psci tests Paolo Bonzini
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=20180207190334.16516-5-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@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 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).