diff --git a/sys/arch/mips/include/endian.h b/sys/arch/mips/include/endian.h index 978fb3fb20f0..a16f0d32151f 100644 --- a/sys/arch/mips/include/endian.h +++ b/sys/arch/mips/include/endian.h @@ -1,4 +1,4 @@ -/* $NetBSD: endian.h,v 1.9 1997/10/09 15:42:24 bouyer Exp $ */ +/* $NetBSD: endian.h,v 1.10 1997/10/17 04:44:01 jonathan Exp $ */ /* * Copyright (c) 1987, 1991, 1993 @@ -35,8 +35,8 @@ * @(#)endian.h 8.1 (Berkeley) 6/11/93 */ -#ifndef _ENDIAN_H_ -#define _ENDIAN_H_ +#ifndef _MIPS_ENDIAN_H_ +#define _MIPS_ENDIAN_H_ /* * Define _NOQUAD if the compiler does NOT support 64-bit integers. @@ -58,7 +58,13 @@ #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ -#define BYTE_ORDER LITTLE_ENDIAN +#ifndef BYTE_ORDER +# error Define MIPS target CPU endian-ness in port-specific header file +#endif + + +#ifndef _LOCORE +/* C-family endian-ness definitions */ #include #include @@ -90,12 +96,31 @@ __END_DECLS #define HTONL(x) (x) #define HTONS(x) (x) -#else +#else /* LITTLE_ENDIAN || !defined(lint) */ #define NTOHL(x) (x) = ntohl((in_addr_t)x) #define NTOHS(x) (x) = ntohs((in_port_t)x) #define HTONL(x) (x) = htonl((in_addr_t)x) #define HTONS(x) (x) = htons((in_port_t)x) -#endif +#endif /* LITTLE_ENDIAN || !defined(lint) */ + +#else /* _LOCORE */ + +/* Assembly-code endian-independent aliases for unaligned memory accesses */ +#if BYTE_ORDER == LITTLE_ENDIAN +# define LWHI lwr +# define LWLO lwl +# define SWHI swr +# define SWLO swl +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + +#if BYTE_ORDER == BIG_ENDIAN +# define LWHI lwl +# define LWLO lwr +# define SWHI swl +# define SWLO swr +#endif /* BYTE_ORDER == BIG_ENDIAN */ + +#endif /* _LOCORE */ #endif /* ! _POSIX_SOURCE */ -#endif /* !_ENDIAN_H_ */ +#endif /* !_MIPS_ENDIAN_H_ */ diff --git a/sys/arch/mips/include/mips_opcode.h b/sys/arch/mips/include/mips_opcode.h index 7234040770ff..41fcc5a43f4f 100644 --- a/sys/arch/mips/include/mips_opcode.h +++ b/sys/arch/mips/include/mips_opcode.h @@ -1,4 +1,4 @@ -/* $NetBSD: mips_opcode.h,v 1.5 1996/03/23 18:49:29 jonathan Exp $ */ +/* $NetBSD: mips_opcode.h,v 1.6 1997/10/17 04:43:57 jonathan Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -81,6 +81,38 @@ typedef union { unsigned op: 6; /* always '0x11' */ } FRType; #endif +#if BYTE_ORDER == BIG_ENDIAN + struct { + unsigned op: 6; + unsigned rs: 5; + unsigned rt: 5; + unsigned imm: 16; + } IType; + + struct { + unsigned op: 6; + unsigned target: 26; + } JType; + + struct { + unsigned op: 6; + unsigned rs: 5; + unsigned rt: 5; + unsigned rd: 5; + unsigned shamt: 5; + unsigned func: 6; + } RType; + + struct { + unsigned op: 6; /* always '0x11' */ + unsigned : 1; /* always '1' */ + unsigned fmt: 4; + unsigned ft: 5; + unsigned fs: 5; + unsigned fd: 5; + unsigned func: 6; + } FRType; +#endif } InstFmt; /* diff --git a/sys/arch/mips/mips/locore.S b/sys/arch/mips/mips/locore.S index 9c89364c8529..683590639fc3 100644 --- a/sys/arch/mips/mips/locore.S +++ b/sys/arch/mips/mips/locore.S @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.45 1997/08/09 03:41:03 jonathan Exp $ */ +/* $NetBSD: locore.S,v 1.46 1997/10/17 04:44:10 jonathan Exp $ */ /* * Copyright (c) 1992, 1993 @@ -89,6 +89,7 @@ #include #include +#include /* byteorder for bcopy(), bzero(), byteswap */ #include /* XXX - misnomer ? */ #include /* XXX - ditto */ #include @@ -259,6 +260,7 @@ END(__main) * netorder = htonl(hostorder) * hostorder = ntohl(netorder) */ +#if BYTE_ORDER == LITTLE_ENDIAN LEAF(htonl) # a0 = 0x11223344, return 0x44332211 ALEAF(ntohl) srl v1, a0, 24 # v1 = 0x00000011 @@ -286,6 +288,7 @@ ALEAF(ntohs) j ra or v0, v0, v1 END(htons) +#endif /* * strlen(str) @@ -335,7 +338,7 @@ LEAF(bzero) and a3, a3, 3 beq a3, zero, 1f # skip if word aligned subu a1, a1, a3 # subtract from remaining count - swr zero, 0(a0) # clear 1, 2, or 3 bytes to align + SWHI zero, 0(a0) # clear 1, 2, or 3 bytes to align addu a0, a0, a3 1: and v0, a1, 3 # compute number of words left @@ -372,8 +375,8 @@ LEAF(bcmp) beq a3, zero, 1f subu a2, a2, a3 # subtract from remaining count move v0, v1 # init v0,v1 so unmodified bytes match - lwr v0, 0(a0) # read 1, 2, or 3 bytes - lwr v1, 0(a1) + LWHI v0, 0(a0) # read 1, 2, or 3 bytes + LWHI v1, 0(a1) addu a1, a1, a3 bne v0, v1, nomatch addu a0, a0, a3 @@ -408,8 +411,8 @@ unalignedcmp: subu a2, a2, a3 # which has to be >= (16-3) & ~3 addu a3, a3, a0 # compute ending address 3: - lwr v0, 0(a0) # compare words a0 unaligned, a1 aligned - lwl v0, 3(a0) + LWHI v0, 0(a0) # compare words a0 unaligned, a1 aligned + LWLO v0, 3(a0) lw v1, 0(a1) addu a0, a0, 4 bne v0, v1, nomatch @@ -552,13 +555,8 @@ destaligned: addu a3,a0,a3 # stop point 3: -#if MIPSEL /* little-endian */ - lwr v0,0(a0) - lwl v0,3(a0) -#else /* big-endian */ - lwl v0,0(a0) - lwr v0,3(a0) -#endif + LWHI v0,0(a0) + LWLO v0,3(a0) addi a0,4 sw v0,0(a1) bne a0,a3,3b diff --git a/sys/arch/pica/include/endian.h b/sys/arch/pica/include/endian.h index 9363be0a8e4e..ad04ec47d682 100644 --- a/sys/arch/pica/include/endian.h +++ b/sys/arch/pica/include/endian.h @@ -1,3 +1,4 @@ -/* $NetBSD: endian.h,v 1.2 1996/03/23 03:42:38 jonathan Exp $ */ +/* $NetBSD: endian.h,v 1.3 1997/10/17 04:44:17 jonathan Exp $ */ +#define BYTE_ORDER LITTLE_ENDIAN #include diff --git a/sys/arch/pmax/include/endian.h b/sys/arch/pmax/include/endian.h index fdc1f5164a00..c95c2f017589 100644 --- a/sys/arch/pmax/include/endian.h +++ b/sys/arch/pmax/include/endian.h @@ -1,3 +1,4 @@ -/* $NetBSD: endian.h,v 1.5 1996/03/19 03:06:28 jonathan Exp $ */ +/* $NetBSD: endian.h,v 1.6 1997/10/17 04:44:22 jonathan Exp $ */ +#define BYTE_ORDER LITTLE_ENDIAN #include