xref: /kvm-unit-tests/lib/powerpc/hcall.c (revision 0c4e631ecaf30f8065dec5cc589d5894c961e6ee)
1 /*
2  * Hypercall helpers
3  *
4  * broken_sc1 probing/patching inspired by SLOF, see
5  *   SLOF:lib/libhvcall/brokensc1.c
6  *
7  * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com>
8  *
9  * This work is licensed under the terms of the GNU LGPL, version 2.
10  */
11 #include <asm/hcall.h>
12 
13 int hcall_have_broken_sc1(void)
14 {
15 	register unsigned long r3 asm("r3") = H_SET_DABR;
16 	register unsigned long r4 asm("r4") = 0;
17 
18 	asm volatile("sc 1"
19 	: "=r" (r3)
20 	: "r" (r3), "r" (r4)
21 	: "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
22 
23 	return r3 == (unsigned long)H_PRIVILEGE;
24 }
25 
26 void putchar(int c)
27 {
28 	unsigned long vty = 0;		/* 0 == default */
29 	unsigned long nr_chars = 1;
30 	unsigned long chars = (unsigned long)c << 56;
31 
32 	hcall(H_PUT_TERM_CHAR, vty, nr_chars, chars);
33 }
34