]>
git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/ppc/OSByteOrder.h
54b69b6a3ed67b0d7008f303ed8a1b92b5d16c05
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
31 #ifndef _OS_OSBYTEORDERPPC_H
32 #define _OS_OSBYTEORDERPPC_H
36 #if !defined(OS_INLINE)
37 # define OS_INLINE static inline
40 /* Functions for byte reversed loads. */
45 const volatile void * base
,
50 __asm__
volatile("lhbrx %0, %1, %2"
52 : "b%" (base
), "r" (offset
)
60 const volatile void * base
,
65 __asm__
volatile("lwbrx %0, %1, %2"
67 : "b%" (base
), "r" (offset
)
75 const volatile void * base
,
79 const volatile uint64_t * inp
;
85 inp
= (const volatile uint64_t *)base
;
86 outv
.ul
[0] = OSReadSwapInt32(inp
, offset
+ 4);
87 outv
.ul
[1] = OSReadSwapInt32(inp
, offset
);
91 /* Functions for byte reversed stores. */
101 __asm__
volatile("sthbrx %0, %1, %2"
103 : "r" (data
), "b%" (base
), "r" (offset
)
110 volatile void * base
,
115 __asm__
volatile("stwbrx %0, %1, %2"
117 : "r" (data
), "b%" (base
), "r" (offset
)
124 volatile void * base
,
129 volatile uint64_t * outp
;
130 volatile union ullc
{
135 outp
= (volatile uint64_t *)base
;
136 inp
= (volatile union ullc
*)&data
;
137 OSWriteSwapInt32(outp
, offset
, inp
->ul
[1]);
138 OSWriteSwapInt32(outp
, offset
+ 4, inp
->ul
[0]);
141 /* Generic byte swapping functions. */
149 uint16_t temp
= data
;
150 return OSReadSwapInt16(&temp
, 0);
159 uint32_t temp
= data
;
160 return OSReadSwapInt32(&temp
, 0);
169 uint64_t temp
= data
;
170 return OSReadSwapInt64(&temp
, 0);
173 #endif /* ! _OS_OSBYTEORDERPPC_H */