1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * OpenRISC Linux 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Linux architectural port borrowing liberally from similar works of 6*4882a593Smuzhiyun * others. All original copyrights apply as per the original source 7*4882a593Smuzhiyun * declaration. 8*4882a593Smuzhiyun * 9*4882a593Smuzhiyun * OpenRISC implementation: 10*4882a593Smuzhiyun * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> 11*4882a593Smuzhiyun * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> 12*4882a593Smuzhiyun * et al. 13*4882a593Smuzhiyun */ 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun #ifndef __ASM_OPENRISC_UNALIGNED_H 16*4882a593Smuzhiyun #define __ASM_OPENRISC_UNALIGNED_H 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun /* 19*4882a593Smuzhiyun * This is copied from the generic implementation and the C-struct 20*4882a593Smuzhiyun * variant replaced with the memmove variant. The GCC compiler 21*4882a593Smuzhiyun * for the OR32 arch optimizes too aggressively for the C-struct 22*4882a593Smuzhiyun * variant to work, so use the memmove variant instead. 23*4882a593Smuzhiyun * 24*4882a593Smuzhiyun * It may be worth considering implementing the unaligned access 25*4882a593Smuzhiyun * exception handler and allowing unaligned accesses (access_ok.h)... 26*4882a593Smuzhiyun * not sure if it would be much of a performance win without further 27*4882a593Smuzhiyun * investigation. 28*4882a593Smuzhiyun */ 29*4882a593Smuzhiyun #include <asm/byteorder.h> 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun #if defined(__LITTLE_ENDIAN) 32*4882a593Smuzhiyun # include <linux/unaligned/le_memmove.h> 33*4882a593Smuzhiyun # include <linux/unaligned/be_byteshift.h> 34*4882a593Smuzhiyun # include <linux/unaligned/generic.h> 35*4882a593Smuzhiyun # define get_unaligned __get_unaligned_le 36*4882a593Smuzhiyun # define put_unaligned __put_unaligned_le 37*4882a593Smuzhiyun #elif defined(__BIG_ENDIAN) 38*4882a593Smuzhiyun # include <linux/unaligned/be_memmove.h> 39*4882a593Smuzhiyun # include <linux/unaligned/le_byteshift.h> 40*4882a593Smuzhiyun # include <linux/unaligned/generic.h> 41*4882a593Smuzhiyun # define get_unaligned __get_unaligned_be 42*4882a593Smuzhiyun # define put_unaligned __put_unaligned_be 43*4882a593Smuzhiyun #else 44*4882a593Smuzhiyun # error need to define endianess 45*4882a593Smuzhiyun #endif 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun #endif /* __ASM_OPENRISC_UNALIGNED_H */ 48