1*49cdfc7eSAndroid Build Coastguard Worker /* SPDX-License-Identifier: GPL-2.0-or-later 2*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) 2017 Cyril Hrubis <[email protected]> 3*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) Linux Test Project, 2018-2024 4*49cdfc7eSAndroid Build Coastguard Worker */ 5*49cdfc7eSAndroid Build Coastguard Worker 6*49cdfc7eSAndroid Build Coastguard Worker #ifndef TST_KERNEL_H__ 7*49cdfc7eSAndroid Build Coastguard Worker #define TST_KERNEL_H__ 8*49cdfc7eSAndroid Build Coastguard Worker 9*49cdfc7eSAndroid Build Coastguard Worker #include <stdbool.h> 10*49cdfc7eSAndroid Build Coastguard Worker 11*49cdfc7eSAndroid Build Coastguard Worker /** 12*49cdfc7eSAndroid Build Coastguard Worker * tst_kernel_bits() - Detect if running on 32bit or 64bit kernel. 13*49cdfc7eSAndroid Build Coastguard Worker * 14*49cdfc7eSAndroid Build Coastguard Worker * Return: 32 if the test process is running on 32bit kernel and 64 if on 64bit 15*49cdfc7eSAndroid Build Coastguard Worker * kernel. 16*49cdfc7eSAndroid Build Coastguard Worker */ 17*49cdfc7eSAndroid Build Coastguard Worker int tst_kernel_bits(void); 18*49cdfc7eSAndroid Build Coastguard Worker 19*49cdfc7eSAndroid Build Coastguard Worker /** 20*49cdfc7eSAndroid Build Coastguard Worker * tst_is_compat_mode() - Detect if running in compat mode. 21*49cdfc7eSAndroid Build Coastguard Worker * 22*49cdfc7eSAndroid Build Coastguard Worker * Detect if the test is 32bit binary executed on a 64bit kernel, 23*49cdfc7eSAndroid Build Coastguard Worker * i.e. we are testing the kernel compat layer. 24*49cdfc7eSAndroid Build Coastguard Worker * 25*49cdfc7eSAndroid Build Coastguard Worker * Return: non-zero if the test process is running in compat mode. 26*49cdfc7eSAndroid Build Coastguard Worker */ 27*49cdfc7eSAndroid Build Coastguard Worker int tst_is_compat_mode(void); 28*49cdfc7eSAndroid Build Coastguard Worker 29*49cdfc7eSAndroid Build Coastguard Worker /** 30*49cdfc7eSAndroid Build Coastguard Worker * tst_abi_bits() - Detect if compiled for required kernel ABI. 31*49cdfc7eSAndroid Build Coastguard Worker * 32*49cdfc7eSAndroid Build Coastguard Worker * @abi: kernel ABI bits (32 or 64). 33*49cdfc7eSAndroid Build Coastguard Worker * 34*49cdfc7eSAndroid Build Coastguard Worker * Return: true if compiled for required ABI or false otherwise. 35*49cdfc7eSAndroid Build Coastguard Worker */ 36*49cdfc7eSAndroid Build Coastguard Worker bool tst_abi_bits(int abi); 37*49cdfc7eSAndroid Build Coastguard Worker 38*49cdfc7eSAndroid Build Coastguard Worker /** 39*49cdfc7eSAndroid Build Coastguard Worker * tst_check_builtin_driver() - Check if the kernel module is built-in. 40*49cdfc7eSAndroid Build Coastguard Worker * 41*49cdfc7eSAndroid Build Coastguard Worker * @driver: the name of the driver. 42*49cdfc7eSAndroid Build Coastguard Worker * 43*49cdfc7eSAndroid Build Coastguard Worker * Return: 0 if builtin driver or -1 when driver is missing or config file not 44*49cdfc7eSAndroid Build Coastguard Worker * available. On Android *always* 0 (always expect the driver is available). 45*49cdfc7eSAndroid Build Coastguard Worker */ 46*49cdfc7eSAndroid Build Coastguard Worker int tst_check_builtin_driver(const char *driver); 47*49cdfc7eSAndroid Build Coastguard Worker 48*49cdfc7eSAndroid Build Coastguard Worker /** 49*49cdfc7eSAndroid Build Coastguard Worker * tst_check_driver() - Check support for the kernel module. 50*49cdfc7eSAndroid Build Coastguard Worker * 51*49cdfc7eSAndroid Build Coastguard Worker * Check support for the kernel module (both built-in and loadable). 52*49cdfc7eSAndroid Build Coastguard Worker * 53*49cdfc7eSAndroid Build Coastguard Worker * @driver: the name of the driver. 54*49cdfc7eSAndroid Build Coastguard Worker * 55*49cdfc7eSAndroid Build Coastguard Worker * Return: 0 if the kernel has the driver, -1 when driver is missing or config 56*49cdfc7eSAndroid Build Coastguard Worker * file not available. On Android *always* 0 (always expect the driver is 57*49cdfc7eSAndroid Build Coastguard Worker * available). 58*49cdfc7eSAndroid Build Coastguard Worker */ 59*49cdfc7eSAndroid Build Coastguard Worker int tst_check_driver(const char *driver); 60*49cdfc7eSAndroid Build Coastguard Worker 61*49cdfc7eSAndroid Build Coastguard Worker #endif /* TST_KERNEL_H__ */ 62