Unverified Commit 6d4f6aea authored by Dimitris Papastamos's avatar Dimitris Papastamos Committed by GitHub
Browse files

Merge pull request #1528 from antonio-nino-diaz-arm/an/libc

libc: Cleanup library
parents 11dfe0b4 8422a840
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <types.h> #include <stdint.h>
/*************************************************************************** /***************************************************************************
* This structure provides version information and the size of the * This structure provides version information and the size of the
......
/* /*
* Copyright (c) 2014, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#ifndef __ARM_GIC_H__ #ifndef __ARM_GIC_H__
#define __ARM_GIC_H__ #define __ARM_GIC_H__
#include <cdefs.h>
#include <stdint.h> #include <stdint.h>
/******************************************************************************* /*******************************************************************************
......
/* /*
* Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
#include <mmio.h> #include <mmio.h>
#include <stdint.h> #include <stdint.h>
#include <types.h>
/* GICv3 Re-distributor interface registers & shifts */ /* GICv3 Re-distributor interface registers & shifts */
#define GICR_PCPUBASE_SHIFT 0x11 #define GICR_PCPUBASE_SHIFT 0x11
......
/* /*
* Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -116,6 +116,7 @@ ...@@ -116,6 +116,7 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <cdefs.h>
#include <interrupt_props.h> #include <interrupt_props.h>
#include <stdint.h> #include <stdint.h>
......
...@@ -212,7 +212,6 @@ ...@@ -212,7 +212,6 @@
#include <gic_common.h> #include <gic_common.h>
#include <interrupt_props.h> #include <interrupt_props.h>
#include <stdint.h> #include <stdint.h>
#include <types.h>
#include <utils_def.h> #include <utils_def.h>
#define gicv3_is_intr_id_special_identifier(id) \ #define gicv3_is_intr_id_special_identifier(id) \
......
/* /*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <types.h> #include <stdint.h>
typedef struct { typedef struct {
console_t console; console_t console;
......
/* /*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <types.h> #include <stdint.h>
typedef struct { typedef struct {
console_t console; console_t console;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <types.h> #include <stdint.h>
typedef struct console { typedef struct console {
struct console *next; struct console *next;
......
/* /*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#ifndef __DW_UFS_H__ #ifndef __DW_UFS_H__
#define __DW_UFS_H__ #define __DW_UFS_H__
#include <sys/types.h> #include <stdint.h>
/* Bus Throtting */ /* Bus Throtting */
#define BUSTHRTL 0xC0 #define BUSTHRTL 0xC0
......
/* /*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#define __PARTITION_H__ #define __PARTITION_H__
#include <cassert.h> #include <cassert.h>
#include <types.h> #include <stdint.h>
#if !PLAT_PARTITION_MAX_ENTRIES #if !PLAT_PARTITION_MAX_ENTRIES
# define PLAT_PARTITION_MAX_ENTRIES 128 # define PLAT_PARTITION_MAX_ENTRIES 128
......
/* /*
* Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <types.h> #include <stdint.h>
typedef struct { typedef struct {
console_t console; console_t console;
......
...@@ -8,8 +8,9 @@ ...@@ -8,8 +8,9 @@
#define __ARCH_HELPERS_H__ #define __ARCH_HELPERS_H__
#include <arch.h> /* for additional register definitions */ #include <arch.h> /* for additional register definitions */
#include <cdefs.h>
#include <stdint.h> #include <stdint.h>
#include <sys/types.h> #include <string.h>
/********************************************************************** /**********************************************************************
* Macros which create inline functions to read or write CPU system * Macros which create inline functions to read or write CPU system
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <cassert.h> #include <cassert.h>
#include <types.h> #include <stdint.h>
/* /*
* The generic structure to save arguments and callee saved registers during * The generic structure to save arguments and callee saved registers during
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <arch.h> /* for additional register definitions */ #include <arch.h> /* for additional register definitions */
#include <cdefs.h> /* For __dead2 */ #include <cdefs.h> /* For __dead2 */
#include <stdint.h> #include <stdint.h>
#include <sys/types.h> #include <string.h>
/********************************************************************** /**********************************************************************
* Macros which create inline functions to read or write CPU system * Macros which create inline functions to read or write CPU system
......
/* /*
* Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#define BAKERY_LOCK_MAX_CPUS PLATFORM_CORE_COUNT #define BAKERY_LOCK_MAX_CPUS PLATFORM_CORE_COUNT
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <cdefs.h>
#include <stdint.h> #include <stdint.h>
/***************************************************************************** /*****************************************************************************
......
/* /*
* Copyright (c) 2014, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#ifndef __CASSERT_H__ #ifndef __CASSERT_H__
#define __CASSERT_H__ #define __CASSERT_H__
#include <cdefs.h>
/******************************************************************************* /*******************************************************************************
* Macro to flag a compile time assertion. It uses the preprocessor to generate * Macro to flag a compile time assertion. It uses the preprocessor to generate
* an invalid C construct if 'cond' evaluates to false. * an invalid C construct if 'cond' evaluates to false.
......
/* /*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#ifndef __COREBOOT_H__ #ifndef __COREBOOT_H__
#define __COREBOOT_H__ #define __COREBOOT_H__
#include <types.h> #include <stdint.h>
typedef struct { typedef struct {
uint32_t type; /* always 2 (memory-mapped) on ARM */ uint32_t type; /* always 2 (memory-mapped) on ARM */
......
/* /*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <cassert.h> #include <cassert.h>
#include <platform_def.h> #include <platform_def.h>
#include <stdint.h> #include <stdint.h>
#include <sys/cdefs.h> /* for CASSERT() */
/* All group 0 counters */ /* All group 0 counters */
#define AMU_GROUP0_COUNTERS_MASK 0xf #define AMU_GROUP0_COUNTERS_MASK 0xf
......
/*- /*-
* Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> * SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 1990, 1993 *
* The Regents of the University of California. All rights reserved. * Copyright (c) 2001 David E. O'Brien
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors * 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 * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
...@@ -27,95 +27,120 @@ ...@@ -27,95 +27,120 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 * @(#)endian.h 8.1 (Berkeley) 6/10/93
* From: @(#)types.h 8.3 (Berkeley) 1/5/94 * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $
* $FreeBSD$ * $FreeBSD$
*/ */
/* /*
* Portions copyright (c) 2016, ARM Limited and Contributors. * Portions copyright (c) 2018, ARM Limited and Contributors.
* All rights reserved. * All rights reserved.
*/ */
#ifndef _MACHINE__TYPES_H_ #ifndef AARCH32_ENDIAN_H
#define _MACHINE__TYPES_H_ #define AARCH32_ENDIAN_H
#ifndef _SYS_CDEFS_H_ #include <stdint.h>
#error this file needs sys/cdefs.h as a prerequisite
#endif
/* /*
* Basic types upon which most other types are built. * Definitions for byte order, according to byte significance from low
* address to high.
*/ */
typedef __signed char __int8_t; #define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
typedef unsigned char __uint8_t; #define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
typedef short __int16_t; #define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
typedef long long __int64_t;
typedef unsigned long long __uint64_t;
/* #ifdef __ARMEB__
* Standard type definitions. #define _BYTE_ORDER _BIG_ENDIAN
*/
typedef __int32_t __clock_t; /* clock()... */
typedef long __critical_t;
typedef double __double_t;
typedef float __float_t;
typedef long __intfptr_t;
typedef __int64_t __intmax_t;
typedef long __intptr_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 long __ptrdiff_t; /* ptr1 - ptr2 */
typedef long __register_t;
typedef long __segsz_t; /* segment size (in pages) */
#ifdef AARCH32
typedef unsigned int __size_t; /* sizeof() */
typedef int __ssize_t; /* byte count or error */
#elif defined AARCH64
typedef unsigned long __size_t; /* sizeof() */
typedef long __ssize_t; /* byte count or error */
#else #else
#error "Only AArch32 or AArch64 supported" #define _BYTE_ORDER _LITTLE_ENDIAN
#endif /* AARCH32 */ #endif /* __ARMEB__ */
typedef __int64_t __time_t; /* time()... */
typedef unsigned long __uintfptr_t;
typedef __uint64_t __uintmax_t;
typedef unsigned long __uintptr_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 unsigned long __u_register_t;
typedef unsigned long __vm_offset_t;
typedef __int64_t __vm_ooffset_t;
typedef unsigned long __vm_paddr_t;
typedef __uint64_t __vm_pindex_t;
typedef unsigned long __vm_size_t;
/* #if __BSD_VISIBLE
* Unusual type definitions. #define LITTLE_ENDIAN _LITTLE_ENDIAN
*/ #define BIG_ENDIAN _BIG_ENDIAN
#ifdef __GNUCLIKE_BUILTIN_VARARGS #define PDP_ENDIAN _PDP_ENDIAN
typedef __builtin_va_list __va_list; /* internally known to gcc */ #define BYTE_ORDER _BYTE_ORDER
#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
#endif /* !_MACHINE__TYPES_H_ */ #ifdef __ARMEB__
#define _QUAD_HIGHWORD 0
#define _QUAD_LOWWORD 1
#define __ntohl(x) ((uint32_t)(x))
#define __ntohs(x) ((uint16_t)(x))
#define __htonl(x) ((uint32_t)(x))
#define __htons(x) ((uint16_t)(x))
#else
#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))
#endif /* __ARMEB__ */
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);
}
#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 /* AARCH32_ENDIAN_H */
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#define SCHAR_MAX 0x7F
#define SCHAR_MIN (-SCHAR_MIN - 1)
#define CHAR_MAX 0x7F
#define CHAR_MIN (-CHAR_MAX - 1)
#define UCHAR_MAX 0xFFU
#define SHRT_MAX 0x7FFF
#define SHRT_MIN (-SHRT_MAX - 1)
#define USHRT_MAX 0xFFFFU
#define INT_MAX 0x7FFFFFFF
#define INT_MIN (-INT_MAX - 1)
#define UINT_MAX 0xFFFFFFFFU
#define LONG_MAX 0x7FFFFFFFL
#define LONG_MIN (-LONG_MAX - 1L)
#define ULONG_MAX 0xFFFFFFFFUL
#define LLONG_MAX 0x7FFFFFFFFFFFFFFFLL
#define LLONG_MIN (-LLONG_MAX - 1LL)
#define ULLONG_MAX 0xFFFFFFFFFFFFFFFFULL
#define __LONG_BIT 32
#define __WORD_BIT 32
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment