xref: /kvm-unit-tests/lib/s390x/hardware.h (revision f489dfa5209ed88133b9e5b1f9e4fe33c6af5a3a)
1*f489dfa5SClaudio Imbrenda /* SPDX-License-Identifier: GPL-2.0-or-later */
2*f489dfa5SClaudio Imbrenda /*
3*f489dfa5SClaudio Imbrenda  * Functions to retrieve information about the host system.
4*f489dfa5SClaudio Imbrenda  *
5*f489dfa5SClaudio Imbrenda  * Copyright (c) 2020 Red Hat Inc
6*f489dfa5SClaudio Imbrenda  * Copyright 2022 IBM Corp.
7*f489dfa5SClaudio Imbrenda  *
8*f489dfa5SClaudio Imbrenda  * Authors:
9*f489dfa5SClaudio Imbrenda  *  Claudio Imbrenda <imbrenda@linux.ibm.com>
10*f489dfa5SClaudio Imbrenda  */
11*f489dfa5SClaudio Imbrenda 
12*f489dfa5SClaudio Imbrenda #ifndef _S390X_HARDWARE_H_
13*f489dfa5SClaudio Imbrenda #define _S390X_HARDWARE_H_
14*f489dfa5SClaudio Imbrenda #include <asm/arch_def.h>
15*f489dfa5SClaudio Imbrenda 
16*f489dfa5SClaudio Imbrenda enum s390_host {
17*f489dfa5SClaudio Imbrenda 	HOST_IS_UNKNOWN,
18*f489dfa5SClaudio Imbrenda 	HOST_IS_LPAR,
19*f489dfa5SClaudio Imbrenda 	HOST_IS_KVM,
20*f489dfa5SClaudio Imbrenda 	HOST_IS_TCG
21*f489dfa5SClaudio Imbrenda };
22*f489dfa5SClaudio Imbrenda 
23*f489dfa5SClaudio Imbrenda enum s390_host detect_host(void);
24*f489dfa5SClaudio Imbrenda 
25*f489dfa5SClaudio Imbrenda static inline bool host_is_tcg(void)
26*f489dfa5SClaudio Imbrenda {
27*f489dfa5SClaudio Imbrenda 	return detect_host() == HOST_IS_TCG;
28*f489dfa5SClaudio Imbrenda }
29*f489dfa5SClaudio Imbrenda 
30*f489dfa5SClaudio Imbrenda static inline bool host_is_kvm(void)
31*f489dfa5SClaudio Imbrenda {
32*f489dfa5SClaudio Imbrenda 	return detect_host() == HOST_IS_KVM;
33*f489dfa5SClaudio Imbrenda }
34*f489dfa5SClaudio Imbrenda 
35*f489dfa5SClaudio Imbrenda static inline bool host_is_lpar(void)
36*f489dfa5SClaudio Imbrenda {
37*f489dfa5SClaudio Imbrenda 	return detect_host() == HOST_IS_LPAR;
38*f489dfa5SClaudio Imbrenda }
39*f489dfa5SClaudio Imbrenda 
40*f489dfa5SClaudio Imbrenda #endif  /* _S390X_HARDWARE_H_ */
41