[fsbl] add fsbl for cv181x/cv180x
Change-Id: I6809bc5016d4bc148f62be2ed3f8e928ec111f19
This commit is contained in:
15
fsbl/include/stdlib/machine/_inttypes.h
Normal file
15
fsbl/include/stdlib/machine/_inttypes.h
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_INTTYPES_H_
|
||||
#define _MACHINE_INTTYPES_H_
|
||||
|
||||
/*
|
||||
* Trusted Firmware does not depend on any definitions in this file. Content
|
||||
* will be added as needed.
|
||||
*/
|
||||
|
||||
#endif /* !_MACHINE_INTTYPES_H_ */
|
||||
105
fsbl/include/stdlib/machine/_limits.h
Normal file
105
fsbl/include/stdlib/machine/_limits.h
Normal file
@ -0,0 +1,105 @@
|
||||
/*-
|
||||
* Copyright (c) 1988, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)limits.h 8.3 (Berkeley) 1/4/94
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions copyright (c) 2017, ARM Limited and Contributors.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE__LIMITS_H_
|
||||
#define _MACHINE__LIMITS_H_
|
||||
|
||||
/*
|
||||
* According to ANSI (section 2.2.4.2), the values below must be usable by
|
||||
* #if preprocessing directives. Additionally, the expression must have the
|
||||
* same type as would an expression that is an object of the corresponding
|
||||
* type converted according to the integral promotions. The subtraction for
|
||||
* INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
|
||||
* unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
|
||||
*/
|
||||
|
||||
#define __CHAR_BIT 8 /* number of bits in a char */
|
||||
|
||||
#define __SCHAR_MAX 0x7f /* max value for a signed char */
|
||||
#define __SCHAR_MIN (-0x7f-1) /* min value for a signed char */
|
||||
|
||||
#define __UCHAR_MAX 0xff /* max value for an unsigned char */
|
||||
|
||||
#define __USHRT_MAX 0xffff /* max value for an unsigned short */
|
||||
#define __SHRT_MAX 0x7fff /* max value for a short */
|
||||
#define __SHRT_MIN (-0x7fff-1) /* min value for a short */
|
||||
|
||||
#define __UINT_MAX 0xffffffffU /* max value for an unsigned int */
|
||||
#define __INT_MAX 0x7fffffff /* max value for an int */
|
||||
#define __INT_MIN (-0x7fffffff-1) /* min value for an int */
|
||||
|
||||
#ifdef AARCH32
|
||||
#define __ULONG_MAX 0xffffffffUL /* max for an unsigned long */
|
||||
#define __LONG_MAX 0x7fffffffL /* max for a long */
|
||||
#define __LONG_MIN (-0x7fffffffL-1) /* min for a long */
|
||||
#else
|
||||
#define __ULONG_MAX 0xffffffffffffffffUL /* max for an unsigned long */
|
||||
#define __LONG_MAX 0x7fffffffffffffffL /* max for a long */
|
||||
#define __LONG_MIN (-0x7fffffffffffffffL-1) /* min for a long */
|
||||
#endif
|
||||
|
||||
#define __ULLONG_MAX 0xffffffffffffffffULL /* max for an unsigned long long */
|
||||
#define __LLONG_MAX 0x7fffffffffffffffLL /* max for a long long */
|
||||
#define __LLONG_MIN (-0x7fffffffffffffffLL-1) /* min for a long long */
|
||||
|
||||
#define __SSIZE_MAX __LONG_MAX /* max value for a ssize_t */
|
||||
|
||||
#define __SIZE_T_MAX __ULONG_MAX /* max value for a size_t */
|
||||
|
||||
#define __OFF_MAX __LONG_MAX /* max value for an off_t */
|
||||
#define __OFF_MIN __LONG_MIN /* min value for an off_t */
|
||||
|
||||
#ifdef AARCH32
|
||||
/* Quads and long longs are the same size. Ensure they stay in sync. */
|
||||
#define __UQUAD_MAX (__ULLONG_MAX) /* max value for a uquad_t */
|
||||
#define __QUAD_MAX (__LLONG_MAX) /* max value for a quad_t */
|
||||
#define __QUAD_MIN (__LLONG_MIN) /* min value for a quad_t */
|
||||
#else
|
||||
/* Quads and longs are the same size. Ensure they stay in sync. */
|
||||
#define __UQUAD_MAX (__ULONG_MAX) /* max value for a uquad_t */
|
||||
#define __QUAD_MAX (__LONG_MAX) /* max value for a quad_t */
|
||||
#define __QUAD_MIN (__LONG_MIN) /* min value for a quad_t */
|
||||
#endif
|
||||
|
||||
#ifdef AARCH32
|
||||
#define __LONG_BIT 32
|
||||
#else
|
||||
#define __LONG_BIT 64
|
||||
#endif
|
||||
#define __WORD_BIT 32
|
||||
|
||||
/* Minimum signal stack size. */
|
||||
#define __MINSIGSTKSZ (1024 * 4)
|
||||
|
||||
#endif /* !_MACHINE__LIMITS_H_ */
|
||||
184
fsbl/include/stdlib/machine/_stdint.h
Normal file
184
fsbl/include/stdlib/machine/_stdint.h
Normal file
@ -0,0 +1,184 @@
|
||||
/*-
|
||||
* Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org>
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Klaus Klein.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions copyright (c) 2016-2017, ARM Limited and Contributors.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE__STDINT_H_
|
||||
#define _MACHINE__STDINT_H_
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
|
||||
|
||||
#define INT8_C(c) (c)
|
||||
#define INT16_C(c) (c)
|
||||
#define INT32_C(c) (c)
|
||||
#define INT64_C(c) (c ## LL)
|
||||
|
||||
#define UINT8_C(c) (c)
|
||||
#define UINT16_C(c) (c)
|
||||
#define UINT32_C(c) (c ## U)
|
||||
#define UINT64_C(c) (c ## ULL)
|
||||
|
||||
#define INTMAX_C(c) INT64_C(c)
|
||||
#define UINTMAX_C(c) UINT64_C(c)
|
||||
|
||||
#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
|
||||
|
||||
/*
|
||||
* ISO/IEC 9899:1999
|
||||
* 7.18.2.1 Limits of exact-width integer types
|
||||
*/
|
||||
/* Minimum values of exact-width signed integer types. */
|
||||
#define INT8_MIN (-0x7f-1)
|
||||
#define INT16_MIN (-0x7fff-1)
|
||||
#define INT32_MIN (-0x7fffffff-1)
|
||||
#define INT64_MIN (-0x7fffffffffffffffLL-1)
|
||||
|
||||
/* Maximum values of exact-width signed integer types. */
|
||||
#define INT8_MAX 0x7f
|
||||
#define INT16_MAX 0x7fff
|
||||
#define INT32_MAX 0x7fffffff
|
||||
#define INT64_MAX 0x7fffffffffffffffLL
|
||||
|
||||
/* Maximum values of exact-width unsigned integer types. */
|
||||
#define UINT8_MAX 0xff
|
||||
#define UINT16_MAX 0xffff
|
||||
#define UINT32_MAX 0xffffffffU
|
||||
#define UINT64_MAX 0xffffffffffffffffULL
|
||||
|
||||
/*
|
||||
* ISO/IEC 9899:1999
|
||||
* 7.18.2.2 Limits of minimum-width integer types
|
||||
*/
|
||||
/* Minimum values of minimum-width signed integer types. */
|
||||
#define INT_LEAST8_MIN INT8_MIN
|
||||
#define INT_LEAST16_MIN INT16_MIN
|
||||
#define INT_LEAST32_MIN INT32_MIN
|
||||
#define INT_LEAST64_MIN INT64_MIN
|
||||
|
||||
/* Maximum values of minimum-width signed integer types. */
|
||||
#define INT_LEAST8_MAX INT8_MAX
|
||||
#define INT_LEAST16_MAX INT16_MAX
|
||||
#define INT_LEAST32_MAX INT32_MAX
|
||||
#define INT_LEAST64_MAX INT64_MAX
|
||||
|
||||
/* Maximum values of minimum-width unsigned integer types. */
|
||||
#define UINT_LEAST8_MAX UINT8_MAX
|
||||
#define UINT_LEAST16_MAX UINT16_MAX
|
||||
#define UINT_LEAST32_MAX UINT32_MAX
|
||||
#define UINT_LEAST64_MAX UINT64_MAX
|
||||
|
||||
/*
|
||||
* ISO/IEC 9899:1999
|
||||
* 7.18.2.3 Limits of fastest minimum-width integer types
|
||||
*/
|
||||
/* Minimum values of fastest minimum-width signed integer types. */
|
||||
#define INT_FAST8_MIN INT32_MIN
|
||||
#define INT_FAST16_MIN INT32_MIN
|
||||
#define INT_FAST32_MIN INT32_MIN
|
||||
#define INT_FAST64_MIN INT64_MIN
|
||||
|
||||
/* Maximum values of fastest minimum-width signed integer types. */
|
||||
#define INT_FAST8_MAX INT32_MAX
|
||||
#define INT_FAST16_MAX INT32_MAX
|
||||
#define INT_FAST32_MAX INT32_MAX
|
||||
#define INT_FAST64_MAX INT64_MAX
|
||||
|
||||
/* Maximum values of fastest minimum-width unsigned integer types. */
|
||||
#define UINT_FAST8_MAX UINT32_MAX
|
||||
#define UINT_FAST16_MAX UINT32_MAX
|
||||
#define UINT_FAST32_MAX UINT32_MAX
|
||||
#define UINT_FAST64_MAX UINT64_MAX
|
||||
|
||||
/*
|
||||
* ISO/IEC 9899:1999
|
||||
* 7.18.2.4 Limits of integer types capable of holding object pointers
|
||||
*/
|
||||
#ifdef AARCH32
|
||||
#define INTPTR_MIN INT32_MIN
|
||||
#define INTPTR_MAX INT32_MAX
|
||||
#define UINTPTR_MAX UINT32_MAX
|
||||
#else
|
||||
#define INTPTR_MIN INT64_MIN
|
||||
#define INTPTR_MAX INT64_MAX
|
||||
#define UINTPTR_MAX UINT64_MAX
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ISO/IEC 9899:1999
|
||||
* 7.18.2.5 Limits of greatest-width integer types
|
||||
*/
|
||||
#define INTMAX_MIN INT64_MIN
|
||||
#define INTMAX_MAX INT64_MAX
|
||||
#define UINTMAX_MAX UINT64_MAX
|
||||
|
||||
/*
|
||||
* ISO/IEC 9899:1999
|
||||
* 7.18.3 Limits of other integer types
|
||||
*/
|
||||
/* Limits of ptrdiff_t. */
|
||||
#ifdef AARCH32
|
||||
#define PTRDIFF_MIN INT32_MIN
|
||||
#define PTRDIFF_MAX INT32_MAX
|
||||
#else
|
||||
#define PTRDIFF_MIN INT64_MIN
|
||||
#define PTRDIFF_MAX INT64_MAX
|
||||
#endif
|
||||
|
||||
/* Limits of sig_atomic_t. */
|
||||
#define SIG_ATOMIC_MIN INT32_MIN
|
||||
#define SIG_ATOMIC_MAX INT32_MAX
|
||||
|
||||
/* Limit of size_t. */
|
||||
#ifdef AARCH32
|
||||
#define SIZE_MAX UINT32_MAX
|
||||
#else
|
||||
#define SIZE_MAX UINT64_MAX
|
||||
#endif
|
||||
|
||||
#ifndef WCHAR_MIN /* Also possibly defined in <wchar.h> */
|
||||
/* Limits of wchar_t. */
|
||||
#define WCHAR_MIN INT32_MIN
|
||||
#define WCHAR_MAX INT32_MAX
|
||||
#endif
|
||||
|
||||
/* Limits of wint_t. */
|
||||
#define WINT_MIN INT32_MIN
|
||||
#define WINT_MAX INT32_MAX
|
||||
|
||||
#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
|
||||
|
||||
#endif /* !_MACHINE__STDINT_H_ */
|
||||
140
fsbl/include/stdlib/machine/_types.h
Normal file
140
fsbl/include/stdlib/machine/_types.h
Normal file
@ -0,0 +1,140 @@
|
||||
/*-
|
||||
* Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
|
||||
* From: @(#)types.h 8.3 (Berkeley) 1/5/94
|
||||
* $FreeBSD$
|
||||
*/
|
||||
/*
|
||||
* Portions copyright (c) 2016, ARM Limited and Contributors.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE__TYPES_H_
|
||||
#define _MACHINE__TYPES_H_
|
||||
|
||||
#ifndef _SYS_CDEFS_H_
|
||||
#error this file needs sys/cdefs.h as a prerequisite
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Basic types upon which most other types are built.
|
||||
*/
|
||||
typedef __signed char __int8_t;
|
||||
typedef unsigned char __uint8_t;
|
||||
typedef short __int16_t;
|
||||
typedef unsigned short __uint16_t;
|
||||
typedef int __int32_t;
|
||||
typedef unsigned int __uint32_t;
|
||||
|
||||
|
||||
/*
|
||||
* Standard type definitions which are different in AArch64 and AArch32
|
||||
*/
|
||||
#ifdef AARCH32
|
||||
typedef long long __int64_t;
|
||||
typedef unsigned long long __uint64_t;
|
||||
typedef __int32_t __critical_t;
|
||||
typedef __int32_t __intfptr_t;
|
||||
typedef __int32_t __intptr_t;
|
||||
typedef __int32_t __ptrdiff_t; /* ptr1 - ptr2 */
|
||||
typedef __int32_t __register_t;
|
||||
typedef __int32_t __segsz_t; /* segment size (in pages) */
|
||||
typedef __uint32_t __size_t; /* sizeof() */
|
||||
typedef __int32_t __ssize_t; /* byte count or error */
|
||||
typedef __uint32_t __uintfptr_t;
|
||||
typedef __uint32_t __uintptr_t;
|
||||
typedef __uint32_t __u_register_t;
|
||||
typedef __uint32_t __vm_offset_t;
|
||||
typedef __uint32_t __vm_paddr_t;
|
||||
typedef __uint32_t __vm_size_t;
|
||||
#elif defined AARCH64 || defined __riscv
|
||||
typedef long __int64_t;
|
||||
typedef unsigned long __uint64_t;
|
||||
typedef __int64_t __critical_t;
|
||||
typedef __int64_t __intfptr_t;
|
||||
typedef __int64_t __intptr_t;
|
||||
typedef __int64_t __ptrdiff_t; /* ptr1 - ptr2 */
|
||||
typedef __int64_t __register_t;
|
||||
typedef __int64_t __segsz_t; /* segment size (in pages) */
|
||||
typedef __uint64_t __size_t; /* sizeof() */
|
||||
typedef __int64_t __ssize_t; /* byte count or error */
|
||||
typedef __uint64_t __uintfptr_t;
|
||||
typedef __uint64_t __uintptr_t;
|
||||
typedef __uint64_t __u_register_t;
|
||||
typedef __uint64_t __vm_offset_t;
|
||||
typedef __uint64_t __vm_paddr_t;
|
||||
typedef __uint64_t __vm_size_t;
|
||||
#else
|
||||
#error "Only AArch32 or AArch64 or Riscv64 supported"
|
||||
#endif /* AARCH32 */
|
||||
|
||||
/*
|
||||
* Standard type definitions.
|
||||
*/
|
||||
typedef __int32_t __clock_t; /* clock()... */
|
||||
typedef double __double_t;
|
||||
typedef float __float_t;
|
||||
typedef __int64_t __intmax_t;
|
||||
typedef __int32_t __int_fast8_t;
|
||||
typedef __int32_t __int_fast16_t;
|
||||
typedef __int32_t __int_fast32_t;
|
||||
typedef __int64_t __int_fast64_t;
|
||||
typedef __int8_t __int_least8_t;
|
||||
typedef __int16_t __int_least16_t;
|
||||
typedef __int32_t __int_least32_t;
|
||||
typedef __int64_t __int_least64_t;
|
||||
typedef __int64_t __time_t; /* time()... */
|
||||
typedef __uint64_t __uintmax_t;
|
||||
typedef __uint32_t __uint_fast8_t;
|
||||
typedef __uint32_t __uint_fast16_t;
|
||||
typedef __uint32_t __uint_fast32_t;
|
||||
typedef __uint64_t __uint_fast64_t;
|
||||
typedef __uint8_t __uint_least8_t;
|
||||
typedef __uint16_t __uint_least16_t;
|
||||
typedef __uint32_t __uint_least32_t;
|
||||
typedef __uint64_t __uint_least64_t;
|
||||
typedef __int64_t __vm_ooffset_t;
|
||||
typedef __uint64_t __vm_pindex_t;
|
||||
|
||||
/*
|
||||
* Unusual type definitions.
|
||||
*/
|
||||
#ifdef __GNUCLIKE_BUILTIN_VARARGS
|
||||
typedef __builtin_va_list __va_list; /* internally known to gcc */
|
||||
#else
|
||||
typedef char * __va_list;
|
||||
#endif /* __GNUCLIKE_BUILTIN_VARARGS */
|
||||
#if defined(__GNUCLIKE_BUILTIN_VAALIST) && !defined(__GNUC_VA_LIST) \
|
||||
&& !defined(__NO_GNUC_VA_LIST)
|
||||
#define __GNUC_VA_LIST
|
||||
typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/
|
||||
#endif
|
||||
|
||||
#endif /* !_MACHINE__TYPES_H_ */
|
||||
168
fsbl/include/stdlib/machine/endian.h
Normal file
168
fsbl/include/stdlib/machine/endian.h
Normal file
@ -0,0 +1,168 @@
|
||||
/*-
|
||||
* Copyright (c) 2001 David E. O'Brien
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)endian.h 8.1 (Berkeley) 6/10/93
|
||||
* $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $
|
||||
* $FreeBSD$
|
||||
*/
|
||||
/*
|
||||
* Portions copyright (c) 2017, ARM Limited and Contributors.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_ENDIAN_H_
|
||||
#define _MACHINE_ENDIAN_H_
|
||||
|
||||
#include <sys/_types.h>
|
||||
|
||||
/*
|
||||
* Definitions for byte order, according to byte significance from low
|
||||
* address to high.
|
||||
*/
|
||||
#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
|
||||
#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
|
||||
#define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
|
||||
|
||||
#define _BYTE_ORDER _LITTLE_ENDIAN
|
||||
|
||||
#if __BSD_VISIBLE
|
||||
#define LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||
#define BIG_ENDIAN _BIG_ENDIAN
|
||||
#define PDP_ENDIAN _PDP_ENDIAN
|
||||
#define BYTE_ORDER _BYTE_ORDER
|
||||
#endif
|
||||
|
||||
#define _QUAD_HIGHWORD 1
|
||||
#define _QUAD_LOWWORD 0
|
||||
#define __ntohl(x) (__bswap32(x))
|
||||
#define __ntohs(x) (__bswap16(x))
|
||||
#define __htonl(x) (__bswap32(x))
|
||||
#define __htons(x) (__bswap16(x))
|
||||
|
||||
#ifdef AARCH32
|
||||
static __inline __uint64_t
|
||||
__bswap64(__uint64_t _x)
|
||||
{
|
||||
|
||||
return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |
|
||||
((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |
|
||||
((_x << 24) & ((__uint64_t)0xff << 40)) |
|
||||
((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
|
||||
}
|
||||
|
||||
static __inline __uint32_t
|
||||
__bswap32_var(__uint32_t v)
|
||||
{
|
||||
__uint32_t t1;
|
||||
|
||||
__asm __volatile("eor %1, %0, %0, ror #16\n"
|
||||
"bic %1, %1, #0x00ff0000\n"
|
||||
"mov %0, %0, ror #8\n"
|
||||
"eor %0, %0, %1, lsr #8\n"
|
||||
: "+r" (v), "=r" (t1));
|
||||
|
||||
return (v);
|
||||
}
|
||||
|
||||
static __inline __uint16_t
|
||||
__bswap16_var(__uint16_t v)
|
||||
{
|
||||
__uint32_t ret = v & 0xffff;
|
||||
|
||||
__asm __volatile(
|
||||
"mov %0, %0, ror #8\n"
|
||||
"orr %0, %0, %0, lsr #16\n"
|
||||
"bic %0, %0, %0, lsl #16"
|
||||
: "+r" (ret));
|
||||
|
||||
return ((__uint16_t)ret);
|
||||
}
|
||||
#elif defined AARCH64
|
||||
static __inline __uint64_t
|
||||
__bswap64(__uint64_t x)
|
||||
{
|
||||
__uint64_t ret;
|
||||
|
||||
__asm __volatile("rev %0, %1\n"
|
||||
: "=&r" (ret), "+r" (x));
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static __inline __uint32_t
|
||||
__bswap32_var(__uint32_t v)
|
||||
{
|
||||
__uint32_t ret;
|
||||
|
||||
__asm __volatile("rev32 %x0, %x1\n"
|
||||
: "=&r" (ret), "+r" (v));
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static __inline __uint16_t
|
||||
__bswap16_var(__uint16_t v)
|
||||
{
|
||||
__uint32_t ret;
|
||||
|
||||
__asm __volatile("rev16 %w0, %w1\n"
|
||||
: "=&r" (ret), "+r" (v));
|
||||
|
||||
return ((__uint16_t)ret);
|
||||
}
|
||||
#else
|
||||
#error "Only AArch32 or AArch64 supported"
|
||||
#endif /* AARCH32 */
|
||||
|
||||
#ifdef __OPTIMIZE__
|
||||
|
||||
#define __bswap32_constant(x) \
|
||||
((((x) & 0xff000000U) >> 24) | \
|
||||
(((x) & 0x00ff0000U) >> 8) | \
|
||||
(((x) & 0x0000ff00U) << 8) | \
|
||||
(((x) & 0x000000ffU) << 24))
|
||||
|
||||
#define __bswap16_constant(x) \
|
||||
((((x) & 0xff00) >> 8) | \
|
||||
(((x) & 0x00ff) << 8))
|
||||
|
||||
#define __bswap16(x) \
|
||||
((__uint16_t)(__builtin_constant_p(x) ? \
|
||||
__bswap16_constant(x) : \
|
||||
__bswap16_var(x)))
|
||||
|
||||
#define __bswap32(x) \
|
||||
((__uint32_t)(__builtin_constant_p(x) ? \
|
||||
__bswap32_constant(x) : \
|
||||
__bswap32_var(x)))
|
||||
|
||||
#else
|
||||
#define __bswap16(x) __bswap16_var(x)
|
||||
#define __bswap32(x) __bswap32_var(x)
|
||||
|
||||
#endif /* __OPTIMIZE__ */
|
||||
#endif /* !_MACHINE_ENDIAN_H_ */
|
||||
Reference in New Issue
Block a user