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 <machine/cpu.h> 57 58 /* FreeBSD doesn't support floating point on powerpc kernel yet */ 59 #define kfpu_allowed() 0 60 61 #define kfpu_initialize(tsk) do {} while (0) 62 #define kfpu_begin() do {} while (0) 63 #define kfpu_end() do {} while (0) 64 #define kfpu_init() (0) 65 #define kfpu_fini() do {} while (0) 66 67 /* 68 * Check if Altivec is available 69 */ 70 static inline boolean_t 71 zfs_altivec_available(void) 72 { 73 return ((cpu_features & PPC_FEATURE_HAS_ALTIVEC) != 0); 74 } 75 76 /* 77 * Check if VSX is available 78 */ 79 static inline boolean_t 80 zfs_vsx_available(void) 81 { 82 return ((cpu_features & PPC_FEATURE_HAS_VSX) != 0); 83 } 84 85 /* 86 * Check if POWER ISA 2.07 is available (SHA2) 87 */ 88 static inline boolean_t 89 zfs_isa207_available(void) 90 { 91 return ((cpu_features2 & PPC_FEATURE2_ARCH_2_07) != 0); 92 } 93 94 #endif 95