diff options
author | Jay Freeman <saurik@saurik.com> | 2008-03-06 17:26:18 +0000 |
---|---|---|
committer | Jay Freeman <saurik@saurik.com> | 2008-03-06 17:26:18 +0000 |
commit | 294906ee694d21bb40a5ddc71d1cdb6278455f83 (patch) | |
tree | 15d1c6482bc2fedbabbea5002290db240f84c779 /tool/headers/libkern/arm | |
parent | 67d8a376ae087b3668b96f1affbab031827662cd (diff) |
Committing all the headers I changed.
git-svn-id: http://svn.telesphoreo.org/trunk@161 514c082c-b64e-11dc-b46d-3d985efe055d
Diffstat (limited to 'tool/headers/libkern/arm')
-rw-r--r-- | tool/headers/libkern/arm/Makefile | 36 | ||||
-rw-r--r-- | tool/headers/libkern/arm/OSByteOrder.h | 117 | ||||
-rw-r--r-- | tool/headers/libkern/arm/_OSByteOrder.h | 79 |
3 files changed, 232 insertions, 0 deletions
diff --git a/tool/headers/libkern/arm/Makefile b/tool/headers/libkern/arm/Makefile new file mode 100644 index 000000000..3fc89f6c4 --- /dev/null +++ b/tool/headers/libkern/arm/Makefile @@ -0,0 +1,36 @@ +export MakeInc_cmd=${SRCROOT}/makedefs/MakeInc.cmd +export MakeInc_def=${SRCROOT}/makedefs/MakeInc.def +export MakeInc_rule=${SRCROOT}/makedefs/MakeInc.rule +export MakeInc_dir=${SRCROOT}/makedefs/MakeInc.dir + +include $(MakeInc_cmd) +include $(MakeInc_def) + +INSTINC_SUBDIRS = + +INSTINC_SUBDIRS_PPC = + +INSTINC_SUBDIRS_I386 = + +EXPINC_SUBDIRS = ${INSTINC_SUBDIRS} + +EXPINC_SUBDIRS_PPC = ${INSTINC_SUBDIRS_PPC} + +EXPINC_SUBDIRS_I386 = ${INSTINC_SUBDIRS_I386} + +DATAFILES = \ + OSByteOrder.h \ + _OSByteOrder.h + +INSTALL_MD_LIST = ${DATAFILES} + +INSTALL_MD_DIR = libkern/i386 + +EXPORT_MD_LIST = ${DATAFILES} + +EXPORT_MD_DIR = libkern/i386 + +include $(MakeInc_rule) +include $(MakeInc_dir) + + diff --git a/tool/headers/libkern/arm/OSByteOrder.h b/tool/headers/libkern/arm/OSByteOrder.h new file mode 100644 index 000000000..0de325870 --- /dev/null +++ b/tool/headers/libkern/arm/OSByteOrder.h @@ -0,0 +1,117 @@ +/* + * Copyright (c) 1999-2006 Apple Computer, Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _OS_OSBYTEORDERI386_H +#define _OS_OSBYTEORDERI386_H + +#include <stdint.h> +#include <libkern/arm/_OSByteOrder.h> + +#if !defined(OS_INLINE) +#define OS_INLINE __DARWIN_OS_INLINE +#endif + +/* Functions for byte reversed loads. */ + +OS_INLINE +uint16_t +OSReadSwapInt16( + const volatile void * base, + uintptr_t byteOffset +) +{ + uint16_t result; + + result = *(volatile uint16_t *)((uintptr_t)base + byteOffset); + return _OSSwapInt16(result); +} + +OS_INLINE +uint32_t +OSReadSwapInt32( + const volatile void * base, + uintptr_t byteOffset +) +{ + uint32_t result; + + result = *(volatile uint32_t *)((uintptr_t)base + byteOffset); + return _OSSwapInt32(result); +} + +OS_INLINE +uint64_t +OSReadSwapInt64( + const volatile void * base, + uintptr_t byteOffset +) +{ + uint64_t result; + + result = *(volatile uint64_t *)((uintptr_t)base + byteOffset); + return _OSSwapInt64(result); +} + +/* Functions for byte reversed stores. */ + +OS_INLINE +void +OSWriteSwapInt16( + volatile void * base, + uintptr_t byteOffset, + uint16_t data +) +{ + *(volatile uint16_t *)((uintptr_t)base + byteOffset) = _OSSwapInt16(data); +} + +OS_INLINE +void +OSWriteSwapInt32( + volatile void * base, + uintptr_t byteOffset, + uint32_t data +) +{ + *(volatile uint32_t *)((uintptr_t)base + byteOffset) = _OSSwapInt32(data); +} + +#if 0 +OS_INLINE +void +OSWriteSwapInt64( + volatile void * base, + uintptr_t byteOffset, + uint64_t data +) +{ + *(volatile uint64_t *)((uintptr_t)base + byteOffset) = _OSSwapInt64(data); +} +#endif + +#endif /* ! _OS_OSBYTEORDERI386_H */ diff --git a/tool/headers/libkern/arm/_OSByteOrder.h b/tool/headers/libkern/arm/_OSByteOrder.h new file mode 100644 index 000000000..bb4b152e1 --- /dev/null +++ b/tool/headers/libkern/arm/_OSByteOrder.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _OS__OSBYTEORDERI386_H +#define _OS__OSBYTEORDERI386_H + +#if !defined(__DARWIN_OS_INLINE) +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# define __DARWIN_OS_INLINE static inline +# elif defined(__MWERKS__) || defined(__cplusplus) +# define __DARWIN_OS_INLINE static inline +# else +# define __DARWIN_OS_INLINE static __inline__ +# endif +#endif + +/* Generic byte swapping functions. */ + +__DARWIN_OS_INLINE +__uint16_t +_OSSwapInt16( + __uint16_t _data +) +{ + return ((_data << 8) | (_data >> 8)); +} + +__DARWIN_OS_INLINE +__uint32_t +_OSSwapInt32( + __uint32_t _data +) +{ + uint32_t tmp = _data; + __asm volatile ("EOR %1, %0, %0, ROR #16\n" + "BIC %1, %1, #0xff0000\n" + "MOV %0, %0, ROR #8\n" + "EOR %0, %0, %1, LSR #8\n" + : "=r" (_data), "=r" (tmp) + : "0" (_data), "1" (tmp)); + + return _data; +} + +__DARWIN_OS_INLINE +__uint64_t +_OSSwapInt64( + __uint64_t _data +) +{ + return (__uint64_t) _OSSwapInt32(_data & 0xffffffff) << 32 | _OSSwapInt32(_data >> 32 & 0xffffff); +} + +#endif /* ! _OS__OSBYTEORDERI386_H */ |