1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or https://opensource.org/licenses/CDDL-1.0. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright (C) 2022 Tino Reichardt <milky-zfs@mcmilk.de> 24 */ 25 26 /* 27 * USER API: 28 * 29 * Kernel fpu methods: 30 * kfpu_allowed() 31 * kfpu_begin() 32 * kfpu_end() 33 * kfpu_init() 34 * kfpu_fini() 35 * 36 * SIMD support: 37 * 38 * Following functions should be called to determine whether CPU feature 39 * is supported. All functions are usable in kernel and user space. 40 * If a SIMD algorithm is using more than one instruction set 41 * all relevant feature test functions should be called. 42 * 43 * Supported features: 44 * zfs_altivec_available() 45 * zfs_vsx_available() 46 * zfs_isa207_available() 47 */ 48 49 #ifndef _FREEBSD_SIMD_POWERPC_H 50 #define _FREEBSD_SIMD_POWERPC_H 51 52 #include <sys/types.h> 53 #include <sys/cdefs.h> 54 55 #include <machine/pcb.h> 56 #include <powerpc/cpu.h> 57 58 #define kfpu_allowed() 1 59 #define kfpu_initialize(tsk) do {} while (0) 60 #define kfpu_begin() do {} while (0) 61 #define kfpu_end() do {} while (0) 62 #define kfpu_init() (0) 63 #define kfpu_fini() do {} while (0) 64 65 /* 66 * Check if Altivec is available 67 */ 68 static inline boolean_t 69 zfs_altivec_available(void) 70 { 71 return ((cpu_features & PPC_FEATURE_HAS_ALTIVEC) != 0); 72 } 73 74 /* 75 * Check if VSX is available 76 */ 77 static inline boolean_t 78 zfs_vsx_available(void) 79 { 80 return ((cpu_features & PPC_FEATURE_HAS_VSX) != 0); 81 } 82 83 /* 84 * Check if POWER ISA 2.07 is available (SHA2) 85 */ 86 static inline boolean_t 87 zfs_isa207_available(void) 88 { 89 return ((cpu_features2 & PPC_FEATURE2_ARCH_2_07) != 0); 90 } 91