xref: /kvm-unit-tests/lib/s390x/asm/float.h (revision ca43ec689a4cd1a1f79f124926706d92f9f09e00)
1 /*
2  * Copyright (c) 2018 Red Hat Inc
3  *
4  * Authors:
5  *  David Hildenbrand <david@redhat.com>
6  *
7  * This code is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Library General Public License version 2.
9  */
10 #ifndef _ASM_S390X_FLOAT_H_
11 #define _ASM_S390X_FLOAT_H_
12 
13 static inline void set_fpc(uint32_t fpc)
14 {
15 	asm volatile("	lfpc	%0\n" : : "m"(fpc) );
16 }
17 
18 static inline uint32_t get_fpc(void)
19 {
20 	uint32_t fpc;
21 
22 	asm volatile("	stfpc	%0\n" : "=m"(fpc));
23 
24 	return fpc;
25 }
26 
27 static inline uint8_t get_fpc_dxc(void)
28 {
29 	return get_fpc() >> 8;
30 }
31 
32 static inline void set_fpc_dxc(uint8_t dxc)
33 {
34 	uint32_t fpc = get_fpc();
35 
36 	fpc = (fpc & ~0xff00) | ((uint32_t)dxc) << 8;
37 
38 	set_fpc(fpc);
39 }
40 
41 static inline void afp_enable(void)
42 {
43 	ctl_set_bit(0, 63 - 45);
44 }
45 
46 static inline void afp_disable(void)
47 {
48 	ctl_clear_bit(0, 63 - 45);
49 }
50 
51 #endif
52