18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * OpenRISC Linux 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Linux architectural port borrowing liberally from similar works of 68c2ecf20Sopenharmony_ci * others. All original copyrights apply as per the original source 78c2ecf20Sopenharmony_ci * declaration. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * OpenRISC implementation: 108c2ecf20Sopenharmony_ci * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> 118c2ecf20Sopenharmony_ci * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> 128c2ecf20Sopenharmony_ci * et al. 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#ifndef __ASM_OPENRISC_UNALIGNED_H 168c2ecf20Sopenharmony_ci#define __ASM_OPENRISC_UNALIGNED_H 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* 198c2ecf20Sopenharmony_ci * This is copied from the generic implementation and the C-struct 208c2ecf20Sopenharmony_ci * variant replaced with the memmove variant. The GCC compiler 218c2ecf20Sopenharmony_ci * for the OR32 arch optimizes too aggressively for the C-struct 228c2ecf20Sopenharmony_ci * variant to work, so use the memmove variant instead. 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * It may be worth considering implementing the unaligned access 258c2ecf20Sopenharmony_ci * exception handler and allowing unaligned accesses (access_ok.h)... 268c2ecf20Sopenharmony_ci * not sure if it would be much of a performance win without further 278c2ecf20Sopenharmony_ci * investigation. 288c2ecf20Sopenharmony_ci */ 298c2ecf20Sopenharmony_ci#include <asm/byteorder.h> 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#if defined(__LITTLE_ENDIAN) 328c2ecf20Sopenharmony_ci# include <linux/unaligned/le_memmove.h> 338c2ecf20Sopenharmony_ci# include <linux/unaligned/be_byteshift.h> 348c2ecf20Sopenharmony_ci# include <linux/unaligned/generic.h> 358c2ecf20Sopenharmony_ci# define get_unaligned __get_unaligned_le 368c2ecf20Sopenharmony_ci# define put_unaligned __put_unaligned_le 378c2ecf20Sopenharmony_ci#elif defined(__BIG_ENDIAN) 388c2ecf20Sopenharmony_ci# include <linux/unaligned/be_memmove.h> 398c2ecf20Sopenharmony_ci# include <linux/unaligned/le_byteshift.h> 408c2ecf20Sopenharmony_ci# include <linux/unaligned/generic.h> 418c2ecf20Sopenharmony_ci# define get_unaligned __get_unaligned_be 428c2ecf20Sopenharmony_ci# define put_unaligned __put_unaligned_be 438c2ecf20Sopenharmony_ci#else 448c2ecf20Sopenharmony_ci# error need to define endianess 458c2ecf20Sopenharmony_ci#endif 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#endif /* __ASM_OPENRISC_UNALIGNED_H */ 48