162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Altivec XOR operations
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright 2017 IBM Corp.
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include <linux/preempt.h>
962306a36Sopenharmony_ci#include <linux/export.h>
1062306a36Sopenharmony_ci#include <linux/sched.h>
1162306a36Sopenharmony_ci#include <asm/switch_to.h>
1262306a36Sopenharmony_ci#include <asm/xor_altivec.h>
1362306a36Sopenharmony_ci#include "xor_vmx.h"
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_civoid xor_altivec_2(unsigned long bytes, unsigned long * __restrict p1,
1662306a36Sopenharmony_ci		   const unsigned long * __restrict p2)
1762306a36Sopenharmony_ci{
1862306a36Sopenharmony_ci	preempt_disable();
1962306a36Sopenharmony_ci	enable_kernel_altivec();
2062306a36Sopenharmony_ci	__xor_altivec_2(bytes, p1, p2);
2162306a36Sopenharmony_ci	disable_kernel_altivec();
2262306a36Sopenharmony_ci	preempt_enable();
2362306a36Sopenharmony_ci}
2462306a36Sopenharmony_ciEXPORT_SYMBOL(xor_altivec_2);
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_civoid xor_altivec_3(unsigned long bytes, unsigned long * __restrict p1,
2762306a36Sopenharmony_ci		   const unsigned long * __restrict p2,
2862306a36Sopenharmony_ci		   const unsigned long * __restrict p3)
2962306a36Sopenharmony_ci{
3062306a36Sopenharmony_ci	preempt_disable();
3162306a36Sopenharmony_ci	enable_kernel_altivec();
3262306a36Sopenharmony_ci	__xor_altivec_3(bytes, p1, p2, p3);
3362306a36Sopenharmony_ci	disable_kernel_altivec();
3462306a36Sopenharmony_ci	preempt_enable();
3562306a36Sopenharmony_ci}
3662306a36Sopenharmony_ciEXPORT_SYMBOL(xor_altivec_3);
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_civoid xor_altivec_4(unsigned long bytes, unsigned long * __restrict p1,
3962306a36Sopenharmony_ci		   const unsigned long * __restrict p2,
4062306a36Sopenharmony_ci		   const unsigned long * __restrict p3,
4162306a36Sopenharmony_ci		   const unsigned long * __restrict p4)
4262306a36Sopenharmony_ci{
4362306a36Sopenharmony_ci	preempt_disable();
4462306a36Sopenharmony_ci	enable_kernel_altivec();
4562306a36Sopenharmony_ci	__xor_altivec_4(bytes, p1, p2, p3, p4);
4662306a36Sopenharmony_ci	disable_kernel_altivec();
4762306a36Sopenharmony_ci	preempt_enable();
4862306a36Sopenharmony_ci}
4962306a36Sopenharmony_ciEXPORT_SYMBOL(xor_altivec_4);
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_civoid xor_altivec_5(unsigned long bytes, unsigned long * __restrict p1,
5262306a36Sopenharmony_ci		   const unsigned long * __restrict p2,
5362306a36Sopenharmony_ci		   const unsigned long * __restrict p3,
5462306a36Sopenharmony_ci		   const unsigned long * __restrict p4,
5562306a36Sopenharmony_ci		   const unsigned long * __restrict p5)
5662306a36Sopenharmony_ci{
5762306a36Sopenharmony_ci	preempt_disable();
5862306a36Sopenharmony_ci	enable_kernel_altivec();
5962306a36Sopenharmony_ci	__xor_altivec_5(bytes, p1, p2, p3, p4, p5);
6062306a36Sopenharmony_ci	disable_kernel_altivec();
6162306a36Sopenharmony_ci	preempt_enable();
6262306a36Sopenharmony_ci}
6362306a36Sopenharmony_ciEXPORT_SYMBOL(xor_altivec_5);
64