]>
git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/ppc/OSByteOrder.h
28ff91dc21138b5b1ab74cb7c9203fd77eb16282
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
33 #ifndef _OS_OSBYTEORDERPPC_H
34 #define _OS_OSBYTEORDERPPC_H
36 #include <libkern/OSTypes.h>
38 /* Functions for byte reversed loads. */
48 __asm__
volatile("lhbrx %0, %1, %2"
50 : "b" (base
), "r" (offset
)
63 __asm__
volatile("lwbrx %0, %1, %2"
65 : "b" (base
), "r" (offset
)
84 outv
.ul
[0] = OSReadSwapInt32(inp
, offset
+ 4);
85 outv
.ul
[1] = OSReadSwapInt32(inp
, offset
);
97 __asm__
volatile("lwbrx %0, %1, %2"
99 : "b" (base
), "r" (offset
)
104 /* Functions for byte reversed stores. */
109 volatile void * base
,
114 __asm__
volatile("sthbrx %0, %1, %2"
116 : "r" (data
), "b" (base
), "r" (offset
)
123 volatile void * base
,
128 __asm__
volatile("stwbrx %0, %1, %2"
130 : "r" (data
), "b" (base
), "r" (offset
)
137 volatile void * base
,
148 outp
= (UInt64
*)base
;
149 inp
= (union ullc
*)&data
;
150 OSWriteSwapInt32(outp
, offset
, inp
->ul
[1]);
151 OSWriteSwapInt32(outp
, offset
+ 4, inp
->ul
[0]);
157 volatile void * base
,
162 __asm__
volatile("stwbrx %0, %1, %2"
164 : "r" (data
), "b" (base
), "r" (offset
)
168 /* Generic byte swapping functions. */
177 return OSReadSwapInt16(&temp
, 0);
187 return OSReadSwapInt32(&temp
, 0);
197 return OSReadSwapInt64(&temp
, 0);
207 return OSReadSwapInt(&temp
, 0);
210 #endif /* ! _OS_OSBYTEORDERPPC_H */