]>
git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/ppc/OSByteOrder.h
0a7e75a72fc74e384add42bd2529b179f5fff08e
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
30 #ifndef _OS_OSBYTEORDERPPC_H
31 #define _OS_OSBYTEORDERPPC_H
33 #include <libkern/OSBase.h>
35 /* Functions for byte reversed loads. */
45 __asm__
volatile("lhbrx %0, %1, %2"
47 : "b" (base
), "r" (offset
)
60 __asm__
volatile("lwbrx %0, %1, %2"
62 : "b" (base
), "r" (offset
)
81 outv
.ul
[0] = OSReadSwapInt32(inp
, offset
+ 4);
82 outv
.ul
[1] = OSReadSwapInt32(inp
, offset
);
94 __asm__
volatile("lwbrx %0, %1, %2"
96 : "b" (base
), "r" (offset
)
101 /* Functions for byte reversed stores. */
106 volatile void * base
,
111 __asm__
volatile("sthbrx %0, %1, %2"
113 : "r" (data
), "b" (base
), "r" (offset
)
120 volatile void * base
,
125 __asm__
volatile("stwbrx %0, %1, %2"
127 : "r" (data
), "b" (base
), "r" (offset
)
134 volatile void * base
,
145 outp
= (UInt64
*)base
;
146 inp
= (union ullc
*)&data
;
147 OSWriteSwapInt32(outp
, offset
, inp
->ul
[1]);
148 OSWriteSwapInt32(outp
, offset
+ 4, inp
->ul
[0]);
154 volatile void * base
,
159 __asm__
volatile("stwbrx %0, %1, %2"
161 : "r" (data
), "b" (base
), "r" (offset
)
165 /* Generic byte swapping functions. */
174 return OSReadSwapInt16(&temp
, 0);
184 return OSReadSwapInt32(&temp
, 0);
194 return OSReadSwapInt64(&temp
, 0);
204 return OSReadSwapInt(&temp
, 0);
207 #endif /* ! _OS_OSBYTEORDERPPC_H */