1*3be97503Schristos /* $NetBSD: endian_machdep.h,v 1.3 2013/05/23 21:39:49 christos Exp $ */ 29e21b655Smycroft 3*3be97503Schristos /*- 4*3be97503Schristos * Copyright (c) 2013 The NetBSD Foundation, Inc. 5*3be97503Schristos * All rights reserved. 6*3be97503Schristos * 7*3be97503Schristos * Redistribution and use in source and binary forms, with or without 8*3be97503Schristos * modification, are permitted provided that the following conditions 9*3be97503Schristos * are met: 10*3be97503Schristos * 1. Redistributions of source code must retain the above copyright 11*3be97503Schristos * notice, this list of conditions and the following disclaimer. 12*3be97503Schristos * 2. Redistributions in binary form must reproduce the above copyright 13*3be97503Schristos * notice, this list of conditions and the following disclaimer in the 14*3be97503Schristos * documentation and/or other materials provided with the distribution. 15*3be97503Schristos * 16*3be97503Schristos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17*3be97503Schristos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18*3be97503Schristos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19*3be97503Schristos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20*3be97503Schristos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21*3be97503Schristos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22*3be97503Schristos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23*3be97503Schristos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24*3be97503Schristos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25*3be97503Schristos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26*3be97503Schristos * POSSIBILITY OF SUCH DAMAGE. 27*3be97503Schristos */ 289e21b655Smycroft #ifndef _BYTE_ORDER 299e21b655Smycroft # error Define MIPS target CPU endian-ness in port-specific header file. 309e21b655Smycroft #endif 319e21b655Smycroft 329e21b655Smycroft #ifdef _LOCORE 339e21b655Smycroft 349e21b655Smycroft /* 359e21b655Smycroft * Endian-independent assembly-code aliases for unaligned memory accesses. 369e21b655Smycroft */ 379e21b655Smycroft #if _BYTE_ORDER == _LITTLE_ENDIAN 389e21b655Smycroft # define LWHI lwr 399e21b655Smycroft # define LWLO lwl 409e21b655Smycroft # define SWHI swr 419e21b655Smycroft # define SWLO swl 42290a34a0Smatt # if SZREG == 4 43290a34a0Smatt # define REG_LHI lwr 44290a34a0Smatt # define REG_LLO lwl 45290a34a0Smatt # define REG_SHI swr 46290a34a0Smatt # define REG_SLO swl 47290a34a0Smatt # else 48290a34a0Smatt # define REG_LHI ldr 49290a34a0Smatt # define REG_LLO ldl 50290a34a0Smatt # define REG_SHI sdr 51290a34a0Smatt # define REG_SLO sdl 52290a34a0Smatt # endif 539e21b655Smycroft #endif 549e21b655Smycroft 559e21b655Smycroft #if _BYTE_ORDER == _BIG_ENDIAN 569e21b655Smycroft # define LWHI lwl 579e21b655Smycroft # define LWLO lwr 589e21b655Smycroft # define SWHI swl 599e21b655Smycroft # define SWLO swr 60290a34a0Smatt # if SZREG == 4 61290a34a0Smatt # define REG_LHI lwl 62290a34a0Smatt # define REG_LLO lwr 63290a34a0Smatt # define REG_SHI swl 64290a34a0Smatt # define REG_SLO swr 65290a34a0Smatt # else 66290a34a0Smatt # define REG_LHI ldl 67290a34a0Smatt # define REG_LLO ldr 68290a34a0Smatt # define REG_SHI sdl 69290a34a0Smatt # define REG_SLO sdr 70290a34a0Smatt # endif 719e21b655Smycroft #endif 729e21b655Smycroft 739e21b655Smycroft #endif /* LOCORE */ 74