]>
git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/ppc/OSByteOrder.h
3fa0081bc2344d0e50253e4b37dff9a476066cf1
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
35 #if !defined(OS_INLINE)
36 # define OS_INLINE static inline
39 /* Functions for byte reversed loads. */
44 const volatile void * base
,
49 __asm__
volatile("lhbrx %0, %1, %2"
51 : "b%" (base
), "r" (offset
)
59 const volatile void * base
,
64 __asm__
volatile("lwbrx %0, %1, %2"
66 : "b%" (base
), "r" (offset
)
74 const volatile void * base
,
78 const volatile uint64_t * inp
;
84 inp
= (const volatile uint64_t *)base
;
85 outv
.ul
[0] = OSReadSwapInt32(inp
, offset
+ 4);
86 outv
.ul
[1] = OSReadSwapInt32(inp
, offset
);
90 /* Functions for byte reversed stores. */
100 __asm__
volatile("sthbrx %0, %1, %2"
102 : "r" (data
), "b%" (base
), "r" (offset
)
109 volatile void * base
,
114 __asm__
volatile("stwbrx %0, %1, %2"
116 : "r" (data
), "b%" (base
), "r" (offset
)
123 volatile void * base
,
128 volatile uint64_t * outp
;
129 volatile union ullc
{
134 outp
= (volatile uint64_t *)base
;
135 inp
= (volatile union ullc
*)&data
;
136 OSWriteSwapInt32(outp
, offset
, inp
->ul
[1]);
137 OSWriteSwapInt32(outp
, offset
+ 4, inp
->ul
[0]);
140 /* Generic byte swapping functions. */
148 uint16_t temp
= data
;
149 return OSReadSwapInt16(&temp
, 0);
158 uint32_t temp
= data
;
159 return OSReadSwapInt32(&temp
, 0);
168 uint64_t temp
= data
;
169 return OSReadSwapInt64(&temp
, 0);
172 #endif /* ! _OS_OSBYTEORDERPPC_H */