]>
git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/i386/OSByteOrder.h
da3d0a459505bd3286b0169587d122dbc122b6bf
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.
29 #ifndef _OS_OSBYTEORDERI386_H
30 #define _OS_OSBYTEORDERI386_H
32 #include <libkern/OSBase.h>
34 /* Functions for byte reversed loads. */
45 result
= *(volatile UInt16
*)((UInt8
*)base
+ offset
);
46 __asm__
volatile("xchgb %b0,%h0"
61 result
= *(volatile UInt32
*)((UInt8
*)base
+ offset
);
62 __asm__
volatile("bswap %0"
82 outv
.ul
[0] = OSReadSwapInt32(inp
, offset
+ 4);
83 outv
.ul
[1] = OSReadSwapInt32(inp
, offset
);
96 result
= *(volatile UInt
*)((UInt8
*)base
+ offset
);
97 __asm__
volatile("bswap %0"
103 /* Functions for byte reversed stores. */
108 volatile void * base
,
113 __asm__
volatile("xchgb %b0,%h0"
116 *(volatile UInt16
*)((UInt8
*)base
+ offset
) = data
;
122 volatile void * base
,
127 __asm__
volatile("bswap %0"
130 *(volatile UInt32
*)((UInt8
*)base
+ offset
) = data
;
136 volatile void * base
,
147 outp
= (UInt64
*)base
;
148 inp
= (union ullc
*)&data
;
149 OSWriteSwapInt32(outp
, offset
, inp
->ul
[1]);
150 OSWriteSwapInt32(outp
, offset
+ 4, inp
->ul
[0]);
156 volatile void * base
,
161 __asm__
volatile("bswap %0"
164 *(volatile UInt
*)((UInt8
*)base
+ offset
) = data
;
167 /* Generic byte swapping functions. */
176 return OSReadSwapInt16(&temp
, 0);
186 return OSReadSwapInt32(&temp
, 0);
196 return OSReadSwapInt64(&temp
, 0);
206 return OSReadSwapInt(&temp
, 0);
209 #endif /* ! _OS_OSBYTEORDERI386_H */