]>
git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/i386/OSByteOrder.h
0aa2270f16b6ea5f92219b932ac0f73327cdb93f
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.
32 #ifndef _OS_OSBYTEORDERI386_H
33 #define _OS_OSBYTEORDERI386_H
35 #include <libkern/OSTypes.h>
37 /* Functions for byte reversed loads. */
48 result
= *(volatile UInt16
*)((UInt8
*)base
+ offset
);
49 __asm__
volatile("xchgb %b0,%h0"
64 result
= *(volatile UInt32
*)((UInt8
*)base
+ offset
);
65 __asm__
volatile("bswap %0"
85 outv
.ul
[0] = OSReadSwapInt32(inp
, offset
+ 4);
86 outv
.ul
[1] = OSReadSwapInt32(inp
, offset
);
99 result
= *(volatile UInt
*)((UInt8
*)base
+ offset
);
100 __asm__
volatile("bswap %0"
106 /* Functions for byte reversed stores. */
111 volatile void * base
,
116 __asm__
volatile("xchgb %b0,%h0"
119 *(volatile UInt16
*)((UInt8
*)base
+ offset
) = data
;
125 volatile void * base
,
130 __asm__
volatile("bswap %0"
133 *(volatile UInt32
*)((UInt8
*)base
+ offset
) = data
;
139 volatile void * base
,
150 outp
= (UInt64
*)base
;
151 inp
= (union ullc
*)&data
;
152 OSWriteSwapInt32(outp
, offset
, inp
->ul
[1]);
153 OSWriteSwapInt32(outp
, offset
+ 4, inp
->ul
[0]);
159 volatile void * base
,
164 __asm__
volatile("bswap %0"
167 *(volatile UInt
*)((UInt8
*)base
+ offset
) = data
;
170 /* Generic byte swapping functions. */
179 return OSReadSwapInt16(&temp
, 0);
189 return OSReadSwapInt32(&temp
, 0);
199 return OSReadSwapInt64(&temp
, 0);
209 return OSReadSwapInt(&temp
, 0);
212 #endif /* ! _OS_OSBYTEORDERI386_H */