Merge pull request #1531 from MISL-EBU-System-SW/marvell-plat-updates
plat: marvell: bl31: Update the early platform setup API
diff --git a/Makefile b/Makefile
index 18c4873..bdc317b 100644
--- a/Makefile
+++ b/Makefile
@@ -202,8 +202,6 @@
BL_COMMON_SOURCES += common/bl_common.c \
common/tf_log.c \
- common/tf_printf.c \
- common/tf_snprintf.c \
common/${ARCH}/debug.S \
lib/${ARCH}/cache_helpers.S \
lib/${ARCH}/misc_helpers.S \
@@ -213,6 +211,10 @@
plat/common/${ARCH}/platform_helpers.S \
${COMPILER_RT_SRCS}
+ifeq ($(notdir $(CC)),armclang)
+BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
+endif
+
INCLUDES += -Iinclude \
-Iinclude/bl1 \
-Iinclude/bl2 \
@@ -241,7 +243,6 @@
${SPD_INCLUDES} \
-Iinclude/tools_share
-
################################################################################
# Generic definitions
################################################################################
@@ -550,6 +551,7 @@
$(eval $(call assert_boolean,EL3_EXCEPTION_HANDLING))
$(eval $(call assert_boolean,ENABLE_AMU))
$(eval $(call assert_boolean,ENABLE_ASSERTIONS))
+$(eval $(call assert_boolean,ENABLE_MPAM_FOR_LOWER_ELS))
$(eval $(call assert_boolean,ENABLE_PLAT_COMPAT))
$(eval $(call assert_boolean,ENABLE_PMF))
$(eval $(call assert_boolean,ENABLE_PSCI_STAT))
@@ -601,6 +603,7 @@
$(eval $(call add_define,EL3_EXCEPTION_HANDLING))
$(eval $(call add_define,ENABLE_AMU))
$(eval $(call add_define,ENABLE_ASSERTIONS))
+$(eval $(call add_define,ENABLE_MPAM_FOR_LOWER_ELS))
$(eval $(call add_define,ENABLE_PLAT_COMPAT))
$(eval $(call add_define,ENABLE_PMF))
$(eval $(call add_define,ENABLE_PSCI_STAT))
diff --git a/bl1/bl1.mk b/bl1/bl1.mk
index 9a46a34..ec7d728 100644
--- a/bl1/bl1.mk
+++ b/bl1/bl1.mk
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -17,7 +17,8 @@
${MBEDTLS_SOURCES}
ifeq (${ARCH},aarch64)
-BL1_SOURCES += lib/el3_runtime/aarch64/context.S
+BL1_SOURCES += lib/cpus/aarch64/dsu_helpers.S \
+ lib/el3_runtime/aarch64/context.S
endif
ifeq (${TRUSTED_BOARD_BOOT},1)
diff --git a/bl1/bl1_private.h b/bl1/bl1_private.h
index 42a74d2..583b61f 100644
--- a/bl1/bl1_private.h
+++ b/bl1/bl1_private.h
@@ -7,7 +7,7 @@
#ifndef __BL1_PRIVATE_H__
#define __BL1_PRIVATE_H__
-#include <types.h>
+#include <stdint.h>
#include <utils_def.h>
/*******************************************************************************
diff --git a/bl2/bl2.mk b/bl2/bl2.mk
index 7e33703..af30a81 100644
--- a/bl2/bl2.mk
+++ b/bl2/bl2.mk
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -29,5 +29,10 @@
bl2/${ARCH}/bl2_el3_exceptions.S \
lib/cpus/${ARCH}/cpu_helpers.S \
lib/cpus/errata_report.c
+
+ifeq (${ARCH},aarch64)
+BL2_SOURCES += lib/cpus/aarch64/dsu_helpers.S
+endif
+
BL2_LINKERFILE := bl2/bl2_el3.ld.S
endif
diff --git a/bl31/bl31.mk b/bl31/bl31.mk
index bff9653..7777954 100644
--- a/bl31/bl31.mk
+++ b/bl31/bl31.mk
@@ -24,6 +24,7 @@
bl31/bl31_context_mgmt.c \
common/runtime_svc.c \
lib/aarch64/setjmp.S \
+ lib/cpus/aarch64/dsu_helpers.S \
plat/common/aarch64/platform_mp_stack.S \
services/arm_arch_svc/arm_arch_svc_setup.c \
services/std_svc/std_svc_setup.c \
@@ -63,6 +64,10 @@
BL31_SOURCES += lib/extensions/sve/sve.c
endif
+ifeq (${ENABLE_MPAM_FOR_LOWER_ELS},1)
+BL31_SOURCES += lib/extensions/mpam/mpam.c
+endif
+
ifeq (${WORKAROUND_CVE_2017_5715},1)
BL31_SOURCES += lib/cpus/aarch64/wa_cve_2017_5715_bpiall.S \
lib/cpus/aarch64/wa_cve_2017_5715_mmu.S
diff --git a/bl31/ehf.c b/bl31/ehf.c
index 8673564..3d6d674 100644
--- a/bl31/ehf.c
+++ b/bl31/ehf.c
@@ -18,6 +18,7 @@
#include <interrupt_mgmt.h>
#include <platform.h>
#include <pubsub_events.h>
+#include <stdbool.h>
/* Output EHF logs as verbose */
#define EHF_LOG(...) VERBOSE("EHF: " __VA_ARGS__)
@@ -26,43 +27,44 @@
/* For a valid handler, return the actual function pointer; otherwise, 0. */
#define RAW_HANDLER(h) \
- ((ehf_handler_t) ((h & _EHF_PRI_VALID) ? (h & ~_EHF_PRI_VALID) : 0))
+ ((ehf_handler_t) ((((h) & EHF_PRI_VALID_) != 0U) ? \
+ ((h) & ~EHF_PRI_VALID_) : 0U))
-#define PRI_BIT(idx) (((ehf_pri_bits_t) 1) << idx)
+#define PRI_BIT(idx) (((ehf_pri_bits_t) 1u) << (idx))
/*
* Convert index into secure priority using the platform-defined priority bits
* field.
*/
#define IDX_TO_PRI(idx) \
- ((idx << (7 - exception_data.pri_bits)) & 0x7f)
+ ((((unsigned) idx) << (7u - exception_data.pri_bits)) & 0x7fU)
/* Check whether a given index is valid */
#define IS_IDX_VALID(idx) \
- ((exception_data.ehf_priorities[idx].ehf_handler & _EHF_PRI_VALID) != 0)
+ ((exception_data.ehf_priorities[idx].ehf_handler & EHF_PRI_VALID_) != 0U)
/* Returns whether given priority is in secure priority range */
-#define IS_PRI_SECURE(pri) ((pri & 0x80) == 0)
+#define IS_PRI_SECURE(pri) (((pri) & 0x80U) == 0U)
/* To be defined by the platform */
extern const ehf_priorities_t exception_data;
/* Translate priority to the index in the priority array */
-static int pri_to_idx(unsigned int priority)
+static unsigned int pri_to_idx(unsigned int priority)
{
- int idx;
+ unsigned int idx;
idx = EHF_PRI_TO_IDX(priority, exception_data.pri_bits);
- assert((idx >= 0) && (idx < exception_data.num_priorities));
+ assert(idx < exception_data.num_priorities);
assert(IS_IDX_VALID(idx));
return idx;
}
/* Return whether there are outstanding priority activation */
-static int has_valid_pri_activations(pe_exc_data_t *pe_data)
+static bool has_valid_pri_activations(pe_exc_data_t *pe_data)
{
- return pe_data->active_pri_bits != 0;
+ return pe_data->active_pri_bits != 0U;
}
static pe_exc_data_t *this_cpu_data(void)
@@ -80,7 +82,7 @@
return EHF_INVALID_IDX;
/* Current priority is the right-most bit */
- return __builtin_ctz(pe_data->active_pri_bits);
+ return (int) __builtin_ctz(pe_data->active_pri_bits);
}
/*
@@ -95,8 +97,8 @@
*/
void ehf_activate_priority(unsigned int priority)
{
- int idx, cur_pri_idx;
- unsigned int old_mask, run_pri;
+ int cur_pri_idx;
+ unsigned int old_mask, run_pri, idx;
pe_exc_data_t *pe_data = this_cpu_data();
/*
@@ -118,7 +120,8 @@
*/
cur_pri_idx = get_pe_highest_active_idx(pe_data);
idx = pri_to_idx(priority);
- if ((cur_pri_idx != EHF_INVALID_IDX) && (idx >= cur_pri_idx)) {
+ if ((cur_pri_idx != EHF_INVALID_IDX) &&
+ (idx >= ((unsigned int) cur_pri_idx))) {
ERROR("Activation priority mismatch: req=0x%x current=0x%x\n",
priority, IDX_TO_PRI(cur_pri_idx));
panic();
@@ -144,7 +147,7 @@
* restored after the last deactivation.
*/
if (cur_pri_idx == EHF_INVALID_IDX)
- pe_data->init_pri_mask = old_mask;
+ pe_data->init_pri_mask = (uint8_t) old_mask;
EHF_LOG("activate prio=%d\n", get_pe_highest_active_idx(pe_data));
}
@@ -161,9 +164,9 @@
*/
void ehf_deactivate_priority(unsigned int priority)
{
- int idx, cur_pri_idx;
+ int cur_pri_idx;
pe_exc_data_t *pe_data = this_cpu_data();
- unsigned int old_mask, run_pri;
+ unsigned int old_mask, run_pri, idx;
/*
* Query interrupt controller for the running priority, or idle priority
@@ -184,21 +187,22 @@
*/
cur_pri_idx = get_pe_highest_active_idx(pe_data);
idx = pri_to_idx(priority);
- if ((cur_pri_idx == EHF_INVALID_IDX) || (idx != cur_pri_idx)) {
+ if ((cur_pri_idx == EHF_INVALID_IDX) ||
+ (idx != ((unsigned int) cur_pri_idx))) {
ERROR("Deactivation priority mismatch: req=0x%x current=0x%x\n",
priority, IDX_TO_PRI(cur_pri_idx));
panic();
}
/* Clear bit corresponding to highest priority */
- pe_data->active_pri_bits &= (pe_data->active_pri_bits - 1);
+ pe_data->active_pri_bits &= (pe_data->active_pri_bits - 1u);
/*
* Restore priority mask corresponding to the next priority, or the
* one stashed earlier if there are no more to deactivate.
*/
- idx = get_pe_highest_active_idx(pe_data);
- if (idx == EHF_INVALID_IDX)
+ cur_pri_idx = get_pe_highest_active_idx(pe_data);
+ if (cur_pri_idx == EHF_INVALID_IDX)
old_mask = plat_ic_set_priority_mask(pe_data->init_pri_mask);
else
old_mask = plat_ic_set_priority_mask(priority);
@@ -231,16 +235,16 @@
/* If the running priority is in the secure range, do nothing */
run_pri = plat_ic_get_running_priority();
if (IS_PRI_SECURE(run_pri))
- return 0;
+ return NULL;
/* Do nothing if there are explicit activations */
if (has_valid_pri_activations(pe_data))
- return 0;
+ return NULL;
- assert(pe_data->ns_pri_mask == 0);
+ assert(pe_data->ns_pri_mask == 0u);
pe_data->ns_pri_mask =
- plat_ic_set_priority_mask(GIC_HIGHEST_NS_PRIORITY);
+ (uint8_t) plat_ic_set_priority_mask(GIC_HIGHEST_NS_PRIORITY);
/* The previous Priority Mask is not expected to be in secure range */
if (IS_PRI_SECURE(pe_data->ns_pri_mask)) {
@@ -252,7 +256,7 @@
EHF_LOG("Priority Mask: 0x%x => 0x%x\n", pe_data->ns_pri_mask,
GIC_HIGHEST_NS_PRIORITY);
- return 0;
+ return NULL;
}
/*
@@ -274,18 +278,18 @@
/* If the running priority is in the secure range, do nothing */
run_pri = plat_ic_get_running_priority();
if (IS_PRI_SECURE(run_pri))
- return 0;
+ return NULL;
/*
* If there are explicit activations, do nothing. The Priority Mask will
* be restored upon the last deactivation.
*/
if (has_valid_pri_activations(pe_data))
- return 0;
+ return NULL;
/* Do nothing if we don't have a valid Priority Mask to restore */
- if (pe_data->ns_pri_mask == 0)
- return 0;
+ if (pe_data->ns_pri_mask == 0U)
+ return NULL;
old_pmr = plat_ic_set_priority_mask(pe_data->ns_pri_mask);
@@ -304,7 +308,7 @@
pe_data->ns_pri_mask = 0;
- return 0;
+ return NULL;
}
/*
@@ -328,7 +332,7 @@
* We should have been notified earlier of entering secure world, and
* therefore have stashed the Non-secure priority mask.
*/
- assert(pe_data->ns_pri_mask != 0);
+ assert(pe_data->ns_pri_mask != 0U);
/* Make sure no priority levels are active when requesting this */
if (has_valid_pri_activations(pe_data)) {
@@ -343,7 +347,7 @@
* to populate it, the caller would find the correct return value.
*/
ns_ctx = cm_get_context(NON_SECURE);
- assert(ns_ctx);
+ assert(ns_ctx != NULL);
write_ctx_reg(get_gpregs_ctx(ns_ctx), CTX_GPREG_X0, preempt_ret_code);
old_pmr = plat_ic_set_priority_mask(pe_data->ns_pri_mask);
@@ -376,7 +380,7 @@
*/
if (has_valid_pri_activations(pe_data))
return 0;
- if (pe_data->ns_pri_mask != 0)
+ if (pe_data->ns_pri_mask != 0U)
return 0;
return 1;
@@ -388,7 +392,9 @@
static uint64_t ehf_el3_interrupt_handler(uint32_t id, uint32_t flags,
void *handle, void *cookie)
{
- int pri, idx, intr, intr_raw, ret = 0;
+ int ret = 0;
+ uint32_t intr_raw;
+ unsigned int intr, pri, idx;
ehf_handler_t handler;
/*
@@ -425,8 +431,9 @@
/* Validate priority */
assert(pri == IDX_TO_PRI(idx));
- handler = RAW_HANDLER(exception_data.ehf_priorities[idx].ehf_handler);
- if (!handler) {
+ handler = (ehf_handler_t) RAW_HANDLER(
+ exception_data.ehf_priorities[idx].ehf_handler);
+ if (handler == NULL) {
ERROR("No EL3 exception handler for priority 0x%x\n",
IDX_TO_PRI(idx));
panic();
@@ -438,7 +445,7 @@
*/
ret = handler(intr_raw, flags, handle, cookie);
- return ret;
+ return (uint64_t) ret;
}
/*
@@ -450,21 +457,22 @@
int ret __unused;
/* Ensure EL3 interrupts are supported */
- assert(plat_ic_has_interrupt_type(INTR_TYPE_EL3));
+ assert(plat_ic_has_interrupt_type(INTR_TYPE_EL3) != 0);
/*
* Make sure that priority water mark has enough bits to represent the
* whole priority array.
*/
- assert(exception_data.num_priorities <= (sizeof(ehf_pri_bits_t) * 8));
+ assert(exception_data.num_priorities <= (sizeof(ehf_pri_bits_t) * 8U));
- assert(exception_data.ehf_priorities);
+ assert(exception_data.ehf_priorities != NULL);
/*
* Bit 7 of GIC priority must be 0 for secure interrupts. This means
* platforms must use at least 1 of the remaining 7 bits.
*/
- assert((exception_data.pri_bits >= 1) || (exception_data.pri_bits < 8));
+ assert((exception_data.pri_bits >= 1U) ||
+ (exception_data.pri_bits < 8U));
/* Route EL3 interrupts when in Secure and Non-secure. */
set_interrupt_rm_flag(flags, NON_SECURE);
@@ -484,13 +492,13 @@
*/
void ehf_register_priority_handler(unsigned int pri, ehf_handler_t handler)
{
- int idx;
+ unsigned int idx;
/* Sanity check for handler */
assert(handler != NULL);
/* Handler ought to be 4-byte aligned */
- assert((((uintptr_t) handler) & 3) == 0);
+ assert((((uintptr_t) handler) & 3U) == 0U);
/* Ensure we register for valid priority */
idx = pri_to_idx(pri);
@@ -498,7 +506,7 @@
assert(IDX_TO_PRI(idx) == pri);
/* Return failure if a handler was already registered */
- if (exception_data.ehf_priorities[idx].ehf_handler != _EHF_NO_HANDLER) {
+ if (exception_data.ehf_priorities[idx].ehf_handler != EHF_NO_HANDLER_) {
ERROR("Handler already registered for priority 0x%x\n", pri);
panic();
}
@@ -508,7 +516,7 @@
* is 4-byte aligned, which is usually the case.
*/
exception_data.ehf_priorities[idx].ehf_handler =
- (((uintptr_t) handler) | _EHF_PRI_VALID);
+ (((uintptr_t) handler) | EHF_PRI_VALID_);
EHF_LOG("register pri=0x%x handler=%p\n", pri, handler);
}
diff --git a/bl32/sp_min/sp_min_main.c b/bl32/sp_min/sp_min_main.c
index f06a48b..59e88eb 100644
--- a/bl32/sp_min/sp_min_main.c
+++ b/bl32/sp_min/sp_min_main.c
@@ -21,8 +21,8 @@
#include <stddef.h>
#include <stdint.h>
#include <std_svc.h>
+#include <stdint.h>
#include <string.h>
-#include <types.h>
#include <utils.h>
#include "sp_min_private.h"
diff --git a/common/tf_log.c b/common/tf_log.c
index 54c0a43..6da1e85 100644
--- a/common/tf_log.c
+++ b/common/tf_log.c
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -36,11 +36,11 @@
prefix_str = plat_log_get_prefix(log_level);
- if (prefix_str != NULL)
- tf_string_print(prefix_str);
+ while (*prefix_str)
+ putchar(*prefix_str++);
va_start(args, fmt);
- tf_vprintf(fmt+1, args);
+ vprintf(fmt + 1, args);
va_end(args);
}
diff --git a/common/tf_printf.c b/common/tf_printf.c
deleted file mode 100644
index 9d8333a..0000000
--- a/common/tf_printf.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (c) 2014-2017, ARM Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-#include <arch.h>
-#include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <stdint.h>
-
-/***********************************************************
- * The tf_printf implementation for all BL stages
- ***********************************************************/
-
-#define get_num_va_args(_args, _lcount) \
- (((_lcount) > 1) ? va_arg(_args, long long int) : \
- ((_lcount) ? va_arg(_args, long int) : va_arg(_args, int)))
-
-#define get_unum_va_args(_args, _lcount) \
- (((_lcount) > 1) ? va_arg(_args, unsigned long long int) : \
- ((_lcount) ? va_arg(_args, unsigned long int) : va_arg(_args, unsigned int)))
-
-void tf_string_print(const char *str)
-{
- assert(str);
-
- while (*str)
- putchar(*str++);
-}
-
-static void unsigned_num_print(unsigned long long int unum, unsigned int radix,
- char padc, int padn)
-{
- /* Just need enough space to store 64 bit decimal integer */
- unsigned char num_buf[20];
- int i = 0, rem;
-
- do {
- rem = unum % radix;
- if (rem < 0xa)
- num_buf[i++] = '0' + rem;
- else
- num_buf[i++] = 'a' + (rem - 0xa);
- } while (unum /= radix);
-
- if (padn > 0) {
- while (i < padn--) {
- putchar(padc);
- }
- }
-
- while (--i >= 0)
- putchar(num_buf[i]);
-}
-
-/*******************************************************************
- * Reduced format print for Trusted firmware.
- * The following type specifiers are supported by this print
- * %x - hexadecimal format
- * %s - string format
- * %d or %i - signed decimal format
- * %u - unsigned decimal format
- * %p - pointer format
- *
- * The following length specifiers are supported by this print
- * %l - long int (64-bit on AArch64)
- * %ll - long long int (64-bit on AArch64)
- * %z - size_t sized integer formats (64 bit on AArch64)
- *
- * The following padding specifiers are supported by this print
- * %0NN - Left-pad the number with 0s (NN is a decimal number)
- *
- * The print exits on all other formats specifiers other than valid
- * combinations of the above specifiers.
- *******************************************************************/
-void tf_vprintf(const char *fmt, va_list args)
-{
- int l_count;
- long long int num;
- unsigned long long int unum;
- char *str;
- char padc = 0; /* Padding character */
- int padn; /* Number of characters to pad */
-
- while (*fmt) {
- l_count = 0;
- padn = 0;
-
- if (*fmt == '%') {
- fmt++;
- /* Check the format specifier */
-loop:
- switch (*fmt) {
- case 'i': /* Fall through to next one */
- case 'd':
- num = get_num_va_args(args, l_count);
- if (num < 0) {
- putchar('-');
- unum = (unsigned long long int)-num;
- padn--;
- } else
- unum = (unsigned long long int)num;
-
- unsigned_num_print(unum, 10, padc, padn);
- break;
- case 's':
- str = va_arg(args, char *);
- tf_string_print(str);
- break;
- case 'p':
- unum = (uintptr_t)va_arg(args, void *);
- if (unum) {
- tf_string_print("0x");
- padn -= 2;
- }
-
- unsigned_num_print(unum, 16, padc, padn);
- break;
- case 'x':
- unum = get_unum_va_args(args, l_count);
- unsigned_num_print(unum, 16, padc, padn);
- break;
- case 'z':
- if (sizeof(size_t) == 8)
- l_count = 2;
-
- fmt++;
- goto loop;
- case 'l':
- l_count++;
- fmt++;
- goto loop;
- case 'u':
- unum = get_unum_va_args(args, l_count);
- unsigned_num_print(unum, 10, padc, padn);
- break;
- case '0':
- padc = '0';
- padn = 0;
- fmt++;
-
- while (1) {
- char ch = *fmt;
- if (ch < '0' || ch > '9') {
- goto loop;
- }
- padn = (padn * 10) + (ch - '0');
- fmt++;
- }
- default:
- /* Exit on any other format specifier */
- return;
- }
- fmt++;
- continue;
- }
- putchar(*fmt++);
- }
-}
-
-void tf_printf(const char *fmt, ...)
-{
- va_list va;
-
- va_start(va, fmt);
- tf_vprintf(fmt, va);
- va_end(va);
-}
diff --git a/docs/cpu-specific-build-macros.rst b/docs/cpu-specific-build-macros.rst
index c11f640..151c99e 100644
--- a/docs/cpu-specific-build-macros.rst
+++ b/docs/cpu-specific-build-macros.rst
@@ -68,10 +68,10 @@
with different revisions of a processor has no runtime mechanism available
for it to specify which errata workarounds should be enabled or not.
-The value of the build flags are 0 by default, that is, disabled. Any other
-value will enable it.
+The value of the build flags is 0 by default, that is, disabled. A value of 1
+will enable it.
-For Cortex-A53, following errata build flags are defined :
+For Cortex-A53, the following errata build flags are defined :
- ``ERRATA_A53_826319``: This applies errata 826319 workaround to Cortex-A53
CPU. This needs to be enabled only for revision <= r0p2 of the CPU.
@@ -97,7 +97,7 @@
Earlier revisions of the CPU have other errata which require the same
workaround in software, so they should be covered anyway.
-For Cortex-A57, following errata build flags are defined :
+For Cortex-A57, the following errata build flags are defined :
- ``ERRATA_A57_806969``: This applies errata 806969 workaround to Cortex-A57
CPU. This needs to be enabled only for revision r0p0 of the CPU.
@@ -127,11 +127,33 @@
CPU. This needs to be enabled only for revision <= r1p3 of the CPU.
-For Cortex-A72, following errata build flags are defined :
+For Cortex-A72, the following errata build flags are defined :
- ``ERRATA_A72_859971``: This applies errata 859971 workaround to Cortex-A72
CPU. This needs to be enabled only for revision <= r0p3 of the CPU.
+DSU Errata Workarounds
+----------------------
+
+Similar to CPU errata, TF-A also implements workarounds for DSU (DynamIQ
+Shared Unit) errata. The DSU errata details can be found in the respective Arm
+documentation:
+
+- `Arm DSU Software Developers Errata Notice`_.
+
+Each erratum is identified by an ``ID``, as defined in the DSU errata notice
+document. Thus, the build flags which enable/disable the errata workarounds
+have the format ``ERRATA_DSU_<ID>``. The implementation and application logic
+of DSU errata workarounds are similar to `CPU errata workarounds`_.
+
+For DSU errata, the following build flags are defined:
+
+- ``ERRATA_DSU_936184``: This applies errata 936184 workaround for the
+ affected DSU configurations. This errata applies only for those DSUs that
+ contain the ACP interface **and** the DSU revision is older than r2p0 (on
+ r2p0 it is fixed). However, please note that this workaround results in
+ increased DSU power consumption on idle.
+
CPU Specific optimizations
--------------------------
@@ -171,3 +193,4 @@
.. _Cortex-A72 MPCore Software Developers Errata Notice: http://infocenter.arm.com/help/topic/com.arm.doc.epm012079/index.html
.. _Firmware Design guide: firmware-design.rst
.. _Cortex-A57 Software Optimization Guide: http://infocenter.arm.com/help/topic/com.arm.doc.uan0015b/Cortex_A57_Software_Optimization_Guide_external.pdf
+.. _Arm DSU Software Developers Errata Notice: http://infocenter.arm.com/help/topic/com.arm.doc.epm138168/index.html
\ No newline at end of file
diff --git a/docs/porting-guide.rst b/docs/porting-guide.rst
index 65f39b0..de7b5db 100644
--- a/docs/porting-guide.rst
+++ b/docs/porting-guide.rst
@@ -2982,32 +2982,13 @@
more functionality is required, the needed library functions will need to be
added to the local implementation.
-Versions of `FreeBSD`_ headers can be found in ``include/lib/stdlib``. Some of
-these headers have been cut down in order to simplify the implementation. In
-order to minimize changes to the header files, the `FreeBSD`_ layout has been
-maintained. The generic C library definitions can be found in
-``include/lib/stdlib`` with more system and machine specific declarations in
-``include/lib/stdlib/sys`` and ``include/lib/stdlib/machine``.
+Some C headers have been obtained from `FreeBSD`_ and `SCC`_, while others have
+been written specifically for TF-A. Fome implementation files have been obtained
+from `FreeBSD`_, others have been written specifically for TF-A as well. The
+files can be found in ``include/lib/libc`` and ``lib/libc``.
-The local C library implementations can be found in ``lib/stdlib``. In order to
-extend the C library these files may need to be modified. It is recommended to
-use a release version of `FreeBSD`_ as a starting point.
-
-The C library header files in the `FreeBSD`_ source tree are located in the
-``include`` and ``sys/sys`` directories. `FreeBSD`_ machine specific definitions
-can be found in the ``sys/<machine-type>`` directories. These files define things
-like 'the size of a pointer' and 'the range of an integer'. Since an AArch64
-port for `FreeBSD`_ does not yet exist, the machine specific definitions are
-based on existing machine types with similar properties (for example SPARC64).
-
-Where possible, C library function implementations were taken from `FreeBSD`_
-as found in the ``lib/libc`` directory.
-
-A copy of the `FreeBSD`_ sources can be downloaded with ``git``.
-
-::
-
- git clone git://github.com/freebsd/freebsd.git -b origin/release/9.2.0
+SCC can be found in `http://www.simple-cc.org/`_. A copy of the `FreeBSD`_
+sources can be obtained from `http://github.com/freebsd/freebsd`_.
Storage abstraction layer
-------------------------
@@ -3082,3 +3063,4 @@
.. _Arm Generic Interrupt Controller version 2.0 (GICv2): http://infocenter.arm.com/help/topic/com.arm.doc.ihi0048b/index.html
.. _3.0 (GICv3): http://infocenter.arm.com/help/topic/com.arm.doc.ihi0069b/index.html
.. _FreeBSD: http://www.freebsd.org
+.. _SCC: http://www.simple-cc.org/
diff --git a/docs/psci-lib-integration-guide.rst b/docs/psci-lib-integration-guide.rst
index 47cbfcc..d86fc29 100644
--- a/docs/psci-lib-integration-guide.rst
+++ b/docs/psci-lib-integration-guide.rst
@@ -319,7 +319,7 @@
below. The TF-A source tree provides implementations for all
these functions but the EL3 Runtime Software may use its own implementation.
-**Functions : assert(), memcpy(), memset**
+**Functions : assert(), memcpy(), memset(), printf()**
These must be implemented as described in ISO C Standard.
@@ -353,14 +353,6 @@
This function will be called by the PSCI library on encountering a critical
failure that cannot be recovered from. This function **must not** return.
-**Function : tf\_printf()**
-
-This is printf-compatible function, but unlike printf, it does not return any
-value. The TF-A source tree provides an implementation which
-is optimized for stack usage and supports only a subset of format specifiers.
-The details of the format specifiers supported can be found in the
-``tf_printf.c`` file in the TF-A source tree.
-
CPU Context management API
~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/user-guide.rst b/docs/user-guide.rst
index 2b90bec..3f8170f 100644
--- a/docs/user-guide.rst
+++ b/docs/user-guide.rst
@@ -67,8 +67,9 @@
In addition, the following optional packages and tools may be needed:
-- ``device-tree-compiler`` package if you need to rebuild the Flattened Device
- Tree (FDT) source files (``.dts`` files) provided with this software.
+- ``device-tree-compiler`` (dtc) package if you need to rebuild the Flattened Device
+ Tree (FDT) source files (``.dts`` files) provided with this software. The
+ version of dtc must be 1.4.6 or above.
- For debugging, Arm `Development Studio 5 (DS-5)`_.
@@ -350,6 +351,17 @@
that is only required for the assertion and does not fit in the assertion
itself.
+- ``ENABLE_MPAM_FOR_LOWER_ELS``: Boolean option to enable lower ELs to use MPAM
+ feature. MPAM is an optional Armv8.4 extension that enables various memory
+ system components and resources to define partitions; software running at
+ various ELs can assign themselves to desired partition to control their
+ performance aspects.
+
+ When this option is set to ``1``, EL3 allows lower ELs to access their own
+ MPAM registers without trapping into EL3. This option doesn't make use of
+ partitioning in EL3, however. Platform initialisation code should configure
+ and use partitions in EL3 as required. This option defaults to ``0``.
+
- ``ENABLE_PMF``: Boolean option to enable support for optional Performance
Measurement Framework(PMF). Default is 0.
diff --git a/drivers/auth/mbedtls/mbedtls_common.c b/drivers/auth/mbedtls/mbedtls_common.c
index 64dc196..7095fde 100644
--- a/drivers/auth/mbedtls/mbedtls_common.c
+++ b/drivers/auth/mbedtls/mbedtls_common.c
@@ -6,6 +6,7 @@
#include <debug.h>
#include <stdlib.h>
+#include <stdio.h>
/* mbed TLS headers */
#include <mbedtls/memory_buffer_alloc.h>
@@ -45,10 +46,8 @@
mbedtls_memory_buffer_alloc_init(heap, MBEDTLS_HEAP_SIZE);
#ifdef MBEDTLS_PLATFORM_SNPRINTF_ALT
- /* Use reduced version of snprintf to save space. */
- mbedtls_platform_set_snprintf(tf_snprintf);
+ mbedtls_platform_set_snprintf(snprintf);
#endif
-
ready = 1;
}
}
diff --git a/drivers/marvell/amb_adec.c b/drivers/marvell/amb_adec.c
index 06a1957..3fb2f38 100644
--- a/drivers/marvell/amb_adec.c
+++ b/drivers/marvell/amb_adec.c
@@ -96,8 +96,8 @@
uint32_t size, size_count;
/* Dump all AMB windows */
- tf_printf("bank attribute base size\n");
- tf_printf("--------------------------------------------\n");
+ printf("bank attribute base size\n");
+ printf("--------------------------------------------\n");
for (win_id = 0; win_id < AMB_MAX_WIN_ID; win_id++) {
ctrl = mmio_read_32(AMB_WIN_CR_OFFSET(win_id));
if (ctrl & WIN_ENABLE_BIT) {
@@ -105,8 +105,8 @@
attr = (ctrl >> AMB_ATTR_OFFSET) & AMB_ATTR_MASK;
size_count = (ctrl >> AMB_SIZE_OFFSET) & AMB_SIZE_MASK;
size = (size_count + 1) * AMB_WIN_ALIGNMENT_64K;
- tf_printf("amb 0x%04x 0x%08x 0x%08x\n",
- attr, base, size);
+ printf("amb 0x%04x 0x%08x 0x%08x\n",
+ attr, base, size);
}
}
}
diff --git a/drivers/marvell/ccu.c b/drivers/marvell/ccu.c
index e478d63..1502c3f 100644
--- a/drivers/marvell/ccu.c
+++ b/drivers/marvell/ccu.c
@@ -20,7 +20,7 @@
/* common defines */
#define WIN_ENABLE_BIT (0x1)
-/* Physical address of the base of the window = {AddrLow[19:0],20’h0} */
+/* Physical address of the base of the window = {AddrLow[19:0],20'h0} */
#define ADDRESS_SHIFT (20 - 4)
#define ADDRESS_MASK (0xFFFFFFF0)
#define CCU_WIN_ALIGNMENT (0x100000)
@@ -40,8 +40,8 @@
uint64_t start, end;
/* Dump all AP windows */
- tf_printf("\tbank target start end\n");
- tf_printf("\t----------------------------------------------------\n");
+ printf("\tbank target start end\n");
+ printf("\t----------------------------------------------------\n");
for (win_id = 0; win_id < MVEBU_CCU_MAX_WINS; win_id++) {
win_cr = mmio_read_32(CCU_WIN_CR_OFFSET(ap_index, win_id));
if (win_cr & WIN_ENABLE_BIT) {
@@ -53,13 +53,13 @@
win_id));
start = ((uint64_t)alr << ADDRESS_SHIFT);
end = (((uint64_t)ahr + 0x10) << ADDRESS_SHIFT);
- tf_printf("\tccu %02x 0x%016llx 0x%016llx\n",
- target_id, start, end);
+ printf("\tccu %02x 0x%016llx 0x%016llx\n",
+ target_id, start, end);
}
}
win_cr = mmio_read_32(CCU_WIN_GCR_OFFSET(ap_index));
target_id = (win_cr >> CCU_GCR_TARGET_OFFSET) & CCU_GCR_TARGET_MASK;
- tf_printf("\tccu GCR %d - all other transactions\n", target_id);
+ printf("\tccu GCR %d - all other transactions\n", target_id);
}
#endif
diff --git a/drivers/marvell/comphy/phy-comphy-cp110.c b/drivers/marvell/comphy/phy-comphy-cp110.c
index 2b1770f..8b78280 100644
--- a/drivers/marvell/comphy/phy-comphy-cp110.c
+++ b/drivers/marvell/comphy/phy-comphy-cp110.c
@@ -18,7 +18,7 @@
/* #define DEBUG_COMPHY */
#ifdef DEBUG_COMPHY
-#define debug(format...) tf_printf(format)
+#define debug(format...) printf(format)
#else
#define debug(format, arg...)
#endif
diff --git a/drivers/marvell/gwin.c b/drivers/marvell/gwin.c
index 2b17f35..b5705f7 100644
--- a/drivers/marvell/gwin.c
+++ b/drivers/marvell/gwin.c
@@ -153,8 +153,8 @@
uint32_t win_num;
/* Dump all GWIN windows */
- tf_printf("\tbank target start end\n");
- tf_printf("\t----------------------------------------------------\n");
+ printf("\tbank target start end\n");
+ printf("\t----------------------------------------------------\n");
for (win_num = 0; win_num < MVEBU_GWIN_MAX_WINS; win_num++) {
uint32_t cr;
uint64_t alr, ahr;
@@ -166,8 +166,8 @@
alr = (alr >> ADDRESS_LSHIFT) << ADDRESS_RSHIFT;
ahr = mmio_read_32(GWIN_AHR_OFFSET(ap_index, win_num));
ahr = (ahr >> ADDRESS_LSHIFT) << ADDRESS_RSHIFT;
- tf_printf("\tgwin %d 0x%016llx 0x%016llx\n",
- (cr >> 8) & 0xF, alr, ahr);
+ printf("\tgwin %d 0x%016llx 0x%016llx\n",
+ (cr >> 8) & 0xF, alr, ahr);
}
}
}
diff --git a/drivers/marvell/io_win.c b/drivers/marvell/io_win.c
index 701dbb8..40b1982 100644
--- a/drivers/marvell/io_win.c
+++ b/drivers/marvell/io_win.c
@@ -158,8 +158,8 @@
uint64_t start, end;
/* Dump all IO windows */
- tf_printf("\tbank target start end\n");
- tf_printf("\t----------------------------------------------------\n");
+ printf("\tbank target start end\n");
+ printf("\t----------------------------------------------------\n");
for (win_id = 0; win_id < MVEBU_IO_WIN_MAX_WINS; win_id++) {
alr = mmio_read_32(IO_WIN_ALR_OFFSET(ap_index, win_id));
if (alr & WIN_ENABLE_BIT) {
@@ -169,13 +169,13 @@
win_id));
start = ((uint64_t)alr << ADDRESS_SHIFT);
end = (((uint64_t)ahr + 0x10) << ADDRESS_SHIFT);
- tf_printf("\tio-win %d 0x%016llx 0x%016llx\n",
- trgt_id, start, end);
+ printf("\tio-win %d 0x%016llx 0x%016llx\n",
+ trgt_id, start, end);
}
}
- tf_printf("\tio-win gcr is %x\n",
- mmio_read_32(MVEBU_IO_WIN_BASE(ap_index) +
- MVEBU_IO_WIN_GCR_OFFSET));
+ printf("\tio-win gcr is %x\n",
+ mmio_read_32(MVEBU_IO_WIN_BASE(ap_index) +
+ MVEBU_IO_WIN_GCR_OFFSET));
}
#endif
diff --git a/drivers/marvell/iob.c b/drivers/marvell/iob.c
index 9f9d047..acc4941 100644
--- a/drivers/marvell/iob.c
+++ b/drivers/marvell/iob.c
@@ -52,8 +52,8 @@
win->base_addr = ALIGN_UP(win->base_addr, IOB_WIN_ALIGNMENT);
ERROR("Window %d: base address unaligned to 0x%x\n",
win_num, IOB_WIN_ALIGNMENT);
- tf_printf("Align up the base address to 0x%llx\n",
- win->base_addr);
+ printf("Align up the base address to 0x%llx\n",
+ win->base_addr);
}
/* size parameter validity check */
@@ -61,7 +61,7 @@
win->win_size = ALIGN_UP(win->win_size, IOB_WIN_ALIGNMENT);
ERROR("Window %d: window size unaligned to 0x%x\n", win_num,
IOB_WIN_ALIGNMENT);
- tf_printf("Aligning size to 0x%llx\n", win->win_size);
+ printf("Aligning size to 0x%llx\n", win->win_size);
}
}
@@ -96,8 +96,8 @@
"PEX0 ", "NAND ", "RUNIT", "MCI1 " };
/* Dump all IOB windows */
- tf_printf("bank id target start end\n");
- tf_printf("----------------------------------------------------\n");
+ printf("bank id target start end\n");
+ printf("----------------------------------------------------\n");
for (win_id = 0; win_id < MVEBU_IOB_MAX_WINS; win_id++) {
win_cr = mmio_read_32(IOB_WIN_CR_OFFSET(win_id));
if (win_cr & WIN_ENABLE_BIT) {
@@ -114,9 +114,9 @@
*/
end = start + (16 << 20);
}
- tf_printf("iob %02d %s 0x%016llx 0x%016llx\n",
- win_id, iob_target_name[target_id],
- start, end);
+ printf("iob %02d %s 0x%016llx 0x%016llx\n",
+ win_id, iob_target_name[target_id],
+ start, end);
}
}
}
diff --git a/drivers/partition/partition.c b/drivers/partition/partition.c
index 5a338b8..d6fb4b8 100644
--- a/drivers/partition/partition.c
+++ b/drivers/partition/partition.c
@@ -11,6 +11,7 @@
#include <mbr.h>
#include <partition.h>
#include <platform.h>
+#include <stdio.h>
#include <string.h>
static uint8_t mbr_sector[PARTITION_BLOCK_SIZE];
@@ -24,7 +25,7 @@
VERBOSE("Partition table with %d entries:\n", num);
for (i = 0; i < num; i++) {
- len = tf_snprintf(name, EFI_NAMELEN, "%s", list.list[i].name);
+ len = snprintf(name, EFI_NAMELEN, "%s", list.list[i].name);
for (j = 0; j < EFI_NAMELEN - len - 1; j++) {
name[len + j] = ' ';
}
diff --git a/drivers/st/clk/stm32mp1_clk.c b/drivers/st/clk/stm32mp1_clk.c
index 1dc08d8..f0bf363 100644
--- a/drivers/st/clk/stm32mp1_clk.c
+++ b/drivers/st/clk/stm32mp1_clk.c
@@ -17,6 +17,7 @@
#include <mmio.h>
#include <platform.h>
#include <stdint.h>
+#include <stdio.h>
#include <stm32mp1_clk.h>
#include <stm32mp1_clkfunc.h>
#include <stm32mp1_dt.h>
@@ -1344,7 +1345,7 @@
for (i = (enum stm32mp1_pll_id)0; i < _PLL_NB; i++) {
char name[12];
- tf_snprintf(name, sizeof(name), "st,pll@%d", i);
+ snprintf(name, sizeof(name), "st,pll@%d", i);
plloff[i] = fdt_rcc_subnode_offset(name);
if (!fdt_check_node(plloff[i])) {
diff --git a/include/bl31/ehf.h b/include/bl31/ehf.h
index f963f8d..c60b04c 100644
--- a/include/bl31/ehf.h
+++ b/include/bl31/ehf.h
@@ -4,36 +4,37 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __EHF_H__
-#define __EHF_H__
+#ifndef EHF_H
+#define EHF_H
#ifndef __ASSEMBLY__
+#include <cdefs.h>
#include <stdint.h>
#include <utils_def.h>
/* Valid priorities set bit 0 of the priority handler. */
-#define _EHF_PRI_VALID (((uintptr_t) 1) << 0)
+#define EHF_PRI_VALID_ (((uintptr_t) 1) << 0)
/* Marker for no handler registered for a valid priority */
-#define _EHF_NO_HANDLER (0 | _EHF_PRI_VALID)
+#define EHF_NO_HANDLER_ (0U | EHF_PRI_VALID_)
/* Extract the specified number of top bits from 7 lower bits of priority */
#define EHF_PRI_TO_IDX(pri, plat_bits) \
- ((pri & 0x7f) >> (7 - plat_bits))
+ ((((unsigned) (pri)) & 0x7fu) >> (7u - (plat_bits)))
/* Install exception priority descriptor at a suitable index */
#define EHF_PRI_DESC(plat_bits, priority) \
[EHF_PRI_TO_IDX(priority, plat_bits)] = { \
- .ehf_handler = _EHF_NO_HANDLER, \
+ .ehf_handler = EHF_NO_HANDLER_, \
}
/* Macro for platforms to regiter its exception priorities */
#define EHF_REGISTER_PRIORITIES(priorities, num, bits) \
const ehf_priorities_t exception_data = { \
- .num_priorities = num, \
- .ehf_priorities = priorities, \
- .pri_bits = bits, \
+ .num_priorities = (num), \
+ .ehf_priorities = (priorities), \
+ .pri_bits = (bits), \
}
/*
@@ -72,10 +73,10 @@
uintptr_t ehf_handler;
} ehf_pri_desc_t;
-typedef struct ehf_priorities {
+typedef struct ehf_priority_type {
ehf_pri_desc_t *ehf_priorities;
unsigned int num_priorities;
- int pri_bits;
+ unsigned int pri_bits;
} ehf_priorities_t;
void ehf_init(void);
@@ -87,4 +88,4 @@
#endif /* __ASSEMBLY__ */
-#endif /* __EHF_H__ */
+#endif /* EHF_H */
diff --git a/include/bl31/interrupt_mgmt.h b/include/bl31/interrupt_mgmt.h
index 905dcd6..49ba9f7 100644
--- a/include/bl31/interrupt_mgmt.h
+++ b/include/bl31/interrupt_mgmt.h
@@ -61,10 +61,10 @@
#define INTR_RM_FROM_SEC_SHIFT SECURE /* BIT[0] */
#define INTR_RM_FROM_NS_SHIFT NON_SECURE /* BIT[1] */
#define INTR_RM_FROM_FLAG_MASK U(1)
-#define get_interrupt_rm_flag(flag, ss) (((flag >> INTR_RM_FLAGS_SHIFT) >> ss) \
- & INTR_RM_FROM_FLAG_MASK)
-#define set_interrupt_rm_flag(flag, ss) (flag |= U(1) << ss)
-#define clr_interrupt_rm_flag(flag, ss) (flag &= ~(U(1) << ss))
+#define get_interrupt_rm_flag(flag, ss) \
+ ((((flag) >> INTR_RM_FLAGS_SHIFT) >> (ss)) & INTR_RM_FROM_FLAG_MASK)
+#define set_interrupt_rm_flag(flag, ss) ((flag) |= U(1) << (ss))
+#define clr_interrupt_rm_flag(flag, ss) ((flag) &= ~(U(1) << (ss)))
/*******************************************************************************
@@ -101,9 +101,9 @@
******************************************************************************/
#define INTR_SRC_SS_FLAG_SHIFT U(0) /* BIT[0] */
#define INTR_SRC_SS_FLAG_MASK U(1)
-#define set_interrupt_src_ss(flag, val) (flag |= val << INTR_SRC_SS_FLAG_SHIFT)
-#define clr_interrupt_src_ss(flag) (flag &= ~(U(1) << INTR_SRC_SS_FLAG_SHIFT))
-#define get_interrupt_src_ss(flag) ((flag >> INTR_SRC_SS_FLAG_SHIFT) & \
+#define set_interrupt_src_ss(flag, val) ((flag) |= (val) << INTR_SRC_SS_FLAG_SHIFT)
+#define clr_interrupt_src_ss(flag) ((flag) &= ~(U(1) << INTR_SRC_SS_FLAG_SHIFT))
+#define get_interrupt_src_ss(flag) (((flag) >> INTR_SRC_SS_FLAG_SHIFT) & \
INTR_SRC_SS_FLAG_MASK)
#ifndef __ASSEMBLY__
diff --git a/include/common/bl_common.h b/include/common/bl_common.h
index f64e6ae..6478f12 100644
--- a/include/common/bl_common.h
+++ b/include/common/bl_common.h
@@ -61,7 +61,6 @@
#include <cassert.h>
#include <stddef.h>
#include <stdint.h>
-#include <types.h>
#include <utils_def.h> /* To retain compatibility */
diff --git a/include/common/debug.h b/include/common/debug.h
index 99f402c..4c5560f 100644
--- a/include/common/debug.h
+++ b/include/common/debug.h
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __DEBUG_H__
-#define __DEBUG_H__
+#ifndef DEBUG_H
+#define DEBUG_H
/*
* The log output macros print output to the console. These macros produce
@@ -26,6 +26,7 @@
#define LOG_LEVEL_VERBOSE 50
#ifndef __ASSEMBLY__
+#include <cdefs.h>
#include <stdarg.h>
#include <stdio.h>
@@ -89,11 +90,7 @@
void __dead2 __stack_chk_fail(void);
void tf_log(const char *fmt, ...) __printflike(1, 2);
-void tf_printf(const char *fmt, ...) __printflike(1, 2);
-int tf_snprintf(char *s, size_t n, const char *fmt, ...) __printflike(3, 4);
-void tf_vprintf(const char *fmt, va_list args);
-void tf_string_print(const char *str);
void tf_log_set_max_level(unsigned int log_level);
#endif /* __ASSEMBLY__ */
-#endif /* __DEBUG_H__ */
+#endif /* DEBUG_H */
diff --git a/include/common/ep_info.h b/include/common/ep_info.h
index 99a0390..bf3f782 100644
--- a/include/common/ep_info.h
+++ b/include/common/ep_info.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -65,7 +65,7 @@
#ifndef __ASSEMBLY__
#include <cassert.h>
-#include <types.h>
+#include <stdint.h>
typedef struct aapcs64_params {
u_register_t arg0;
diff --git a/include/common/param_header.h b/include/common/param_header.h
index c982fc9..a5a08ec 100644
--- a/include/common/param_header.h
+++ b/include/common/param_header.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -23,7 +23,7 @@
#define SET_PARAM_HEAD(_p, _type, _ver, _attr) do { \
(_p)->h.type = (uint8_t)(_type); \
(_p)->h.version = (uint8_t)(_ver); \
- (_p)->h.size = (uint16_t)sizeof(*_p); \
+ (_p)->h.size = (uint16_t)sizeof(*(_p)); \
(_p)->h.attr = (uint32_t)(_attr) ; \
} while (0)
@@ -36,7 +36,7 @@
#ifndef __ASSEMBLY__
-#include <types.h>
+#include <stdint.h>
/***************************************************************************
* This structure provides version information and the size of the
diff --git a/include/drivers/arm/arm_gic.h b/include/drivers/arm/arm_gic.h
index 019159f..8d2a232 100644
--- a/include/drivers/arm/arm_gic.h
+++ b/include/drivers/arm/arm_gic.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -7,6 +7,7 @@
#ifndef __ARM_GIC_H__
#define __ARM_GIC_H__
+#include <cdefs.h>
#include <stdint.h>
/*******************************************************************************
diff --git a/include/drivers/arm/gic_common.h b/include/drivers/arm/gic_common.h
index 6e953a0..00cbd1d 100644
--- a/include/drivers/arm/gic_common.h
+++ b/include/drivers/arm/gic_common.h
@@ -7,6 +7,8 @@
#ifndef __GIC_COMMON_H__
#define __GIC_COMMON_H__
+#include <utils_def.h>
+
/*******************************************************************************
* GIC Distributor interface general definitions
******************************************************************************/
@@ -34,10 +36,10 @@
#define GIC_INTR_CFG_EDGE (1 << 1)
/* Constants to categorise priorities */
-#define GIC_HIGHEST_SEC_PRIORITY 0x0
-#define GIC_LOWEST_SEC_PRIORITY 0x7f
-#define GIC_HIGHEST_NS_PRIORITY 0x80
-#define GIC_LOWEST_NS_PRIORITY 0xfe /* 0xff would disable all interrupts */
+#define GIC_HIGHEST_SEC_PRIORITY U(0x00)
+#define GIC_LOWEST_SEC_PRIORITY U(0x7f)
+#define GIC_HIGHEST_NS_PRIORITY U(0x80)
+#define GIC_LOWEST_NS_PRIORITY U(0xfe) /* 0xff would disable all interrupts */
/*******************************************************************************
* GIC Distributor interface register offsets that are common to GICv3 & GICv2
diff --git a/include/drivers/arm/gic_v3.h b/include/drivers/arm/gic_v3.h
index 02f9006..549b4d9 100644
--- a/include/drivers/arm/gic_v3.h
+++ b/include/drivers/arm/gic_v3.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -17,8 +17,6 @@
#include <mmio.h>
#include <stdint.h>
-#include <types.h>
-
/* GICv3 Re-distributor interface registers & shifts */
#define GICR_PCPUBASE_SHIFT 0x11
diff --git a/include/drivers/arm/gicv2.h b/include/drivers/arm/gicv2.h
index 39c7302..925d1c2 100644
--- a/include/drivers/arm/gicv2.h
+++ b/include/drivers/arm/gicv2.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -116,6 +116,7 @@
#ifndef __ASSEMBLY__
+#include <cdefs.h>
#include <interrupt_props.h>
#include <stdint.h>
diff --git a/include/drivers/arm/gicv3.h b/include/drivers/arm/gicv3.h
index 37c92e4..c13a5c9 100644
--- a/include/drivers/arm/gicv3.h
+++ b/include/drivers/arm/gicv3.h
@@ -212,7 +212,6 @@
#include <gic_common.h>
#include <interrupt_props.h>
#include <stdint.h>
-#include <types.h>
#include <utils_def.h>
#define gicv3_is_intr_id_special_identifier(id) \
diff --git a/include/drivers/arm/pl011.h b/include/drivers/arm/pl011.h
index 06d7543..137764d 100644
--- a/include/drivers/arm/pl011.h
+++ b/include/drivers/arm/pl011.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -85,7 +85,7 @@
#ifndef __ASSEMBLY__
-#include <types.h>
+#include <stdint.h>
typedef struct {
console_t console;
diff --git a/include/drivers/cadence/cdns_uart.h b/include/drivers/cadence/cdns_uart.h
index 7ab6df0..51de8e3 100644
--- a/include/drivers/cadence/cdns_uart.h
+++ b/include/drivers/cadence/cdns_uart.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -29,7 +29,7 @@
#ifndef __ASSEMBLY__
-#include <types.h>
+#include <stdint.h>
typedef struct {
console_t console;
diff --git a/include/drivers/console.h b/include/drivers/console.h
index f9ed2e5..1f041b9 100644
--- a/include/drivers/console.h
+++ b/include/drivers/console.h
@@ -30,7 +30,7 @@
#ifndef __ASSEMBLY__
-#include <types.h>
+#include <stdint.h>
typedef struct console {
struct console *next;
diff --git a/include/drivers/dw_ufs.h b/include/drivers/dw_ufs.h
index b05c7f5..a9774cf 100644
--- a/include/drivers/dw_ufs.h
+++ b/include/drivers/dw_ufs.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -7,7 +7,7 @@
#ifndef __DW_UFS_H__
#define __DW_UFS_H__
-#include <sys/types.h>
+#include <stdint.h>
/* Bus Throtting */
#define BUSTHRTL 0xC0
diff --git a/include/drivers/partition/partition.h b/include/drivers/partition/partition.h
index 4951f8c..047c7dd 100644
--- a/include/drivers/partition/partition.h
+++ b/include/drivers/partition/partition.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -8,7 +8,7 @@
#define __PARTITION_H__
#include <cassert.h>
-#include <types.h>
+#include <stdint.h>
#if !PLAT_PARTITION_MAX_ENTRIES
# define PLAT_PARTITION_MAX_ENTRIES 128
diff --git a/include/drivers/ti/uart/uart_16550.h b/include/drivers/ti/uart/uart_16550.h
index b00f664..9ee2a33 100644
--- a/include/drivers/ti/uart/uart_16550.h
+++ b/include/drivers/ti/uart/uart_16550.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -75,7 +75,7 @@
#ifndef __ASSEMBLY__
-#include <types.h>
+#include <stdint.h>
typedef struct {
console_t console;
diff --git a/include/lib/aarch32/arch_helpers.h b/include/lib/aarch32/arch_helpers.h
index aa68bcb..8eda5cb 100644
--- a/include/lib/aarch32/arch_helpers.h
+++ b/include/lib/aarch32/arch_helpers.h
@@ -8,8 +8,9 @@
#define __ARCH_HELPERS_H__
#include <arch.h> /* for additional register definitions */
+#include <cdefs.h>
#include <stdint.h>
-#include <sys/types.h>
+#include <string.h>
/**********************************************************************
* Macros which create inline functions to read or write CPU system
diff --git a/include/lib/aarch32/smccc_helpers.h b/include/lib/aarch32/smccc_helpers.h
index 731c26f..d6e525f 100644
--- a/include/lib/aarch32/smccc_helpers.h
+++ b/include/lib/aarch32/smccc_helpers.h
@@ -26,7 +26,7 @@
#ifndef __ASSEMBLY__
#include <cassert.h>
-#include <types.h>
+#include <stdint.h>
/*
* The generic structure to save arguments and callee saved registers during
diff --git a/include/lib/aarch64/arch.h b/include/lib/aarch64/arch.h
index c9619f6..cccb286 100644
--- a/include/lib/aarch64/arch.h
+++ b/include/lib/aarch64/arch.h
@@ -117,6 +117,8 @@
#define ID_AA64PFR0_SVE_SHIFT U(32)
#define ID_AA64PFR0_SVE_MASK ULL(0xf)
#define ID_AA64PFR0_SVE_LENGTH U(4)
+#define ID_AA64PFR0_MPAM_SHIFT U(40)
+#define ID_AA64PFR0_MPAM_MASK ULL(0xf)
#define ID_AA64PFR0_CSV2_SHIFT U(56)
#define ID_AA64PFR0_CSV2_MASK ULL(0xf)
#define ID_AA64PFR0_CSV2_LENGTH U(4)
@@ -658,6 +660,14 @@
#define PMBLIMITR_EL1 S3_0_C9_C10_0
/*******************************************************************************
+ * Definitions for system register interface to MPAM
+ ******************************************************************************/
+#define MPAMIDR_EL1 S3_0_C10_C4_4
+#define MPAM2_EL2 S3_4_C10_C5_0
+#define MPAMHCR_EL2 S3_4_C10_C4_0
+#define MPAM3_EL3 S3_6_C10_C5_0
+
+/*******************************************************************************
* Definitions for system register interface to AMU for ARMv8.4 onwards
******************************************************************************/
#define AMCR_EL0 S3_3_C13_C2_0
@@ -722,6 +732,11 @@
#define AMCGCR_EL0_CG1NC_LENGTH U(8)
#define AMCGCR_EL0_CG1NC_MASK U(0xff)
+/* MPAM register definitions */
+#define MPAM3_EL3_MPAMEN_BIT (ULL(1) << 63)
+
+#define MPAMIDR_HAS_HCR_BIT (ULL(1) << 17)
+
/*******************************************************************************
* RAS system registers
*******************************************************************************/
diff --git a/include/lib/aarch64/arch_helpers.h b/include/lib/aarch64/arch_helpers.h
index 58ec943..067c374 100644
--- a/include/lib/aarch64/arch_helpers.h
+++ b/include/lib/aarch64/arch_helpers.h
@@ -10,7 +10,7 @@
#include <arch.h> /* for additional register definitions */
#include <cdefs.h> /* For __dead2 */
#include <stdint.h>
-#include <sys/types.h>
+#include <string.h>
/**********************************************************************
* Macros which create inline functions to read or write CPU system
@@ -328,6 +328,11 @@
DEFINE_RENAME_SYSREG_RW_FUNCS(amcntenclr1_el0, AMCNTENCLR1_EL0)
DEFINE_RENAME_SYSREG_RW_FUNCS(amcntenset1_el0, AMCNTENSET1_EL0)
+DEFINE_RENAME_SYSREG_READ_FUNC(mpamidr_el1, MPAMIDR_EL1)
+DEFINE_RENAME_SYSREG_RW_FUNCS(mpam3_el3, MPAM3_EL3)
+DEFINE_RENAME_SYSREG_RW_FUNCS(mpam2_el2, MPAM2_EL2)
+DEFINE_RENAME_SYSREG_RW_FUNCS(mpamhcr_el2, MPAMHCR_EL2)
+
DEFINE_RENAME_SYSREG_RW_FUNCS(pmblimitr_el1, PMBLIMITR_EL1)
DEFINE_RENAME_SYSREG_WRITE_FUNC(zcr_el3, ZCR_EL3)
diff --git a/include/lib/bakery_lock.h b/include/lib/bakery_lock.h
index d4645c3..c80082e 100644
--- a/include/lib/bakery_lock.h
+++ b/include/lib/bakery_lock.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -12,6 +12,7 @@
#define BAKERY_LOCK_MAX_CPUS PLATFORM_CORE_COUNT
#ifndef __ASSEMBLY__
+#include <cdefs.h>
#include <stdint.h>
/*****************************************************************************
diff --git a/include/lib/cassert.h b/include/lib/cassert.h
index 40cb483..3119e1f 100644
--- a/include/lib/cassert.h
+++ b/include/lib/cassert.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -7,6 +7,8 @@
#ifndef __CASSERT_H__
#define __CASSERT_H__
+#include <cdefs.h>
+
/*******************************************************************************
* Macro to flag a compile time assertion. It uses the preprocessor to generate
* an invalid C construct if 'cond' evaluates to false.
diff --git a/include/lib/coreboot.h b/include/lib/coreboot.h
index 4b1f200..f8fbd93 100644
--- a/include/lib/coreboot.h
+++ b/include/lib/coreboot.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -7,7 +7,7 @@
#ifndef __COREBOOT_H__
#define __COREBOOT_H__
-#include <types.h>
+#include <stdint.h>
typedef struct {
uint32_t type; /* always 2 (memory-mapped) on ARM */
diff --git a/include/lib/cpus/aarch64/dsu_def.h b/include/lib/cpus/aarch64/dsu_def.h
new file mode 100644
index 0000000..0e2d93a
--- /dev/null
+++ b/include/lib/cpus/aarch64/dsu_def.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef DSU_DEF_H
+#define DSU_DEF_H
+
+#include <utils_def.h>
+
+/********************************************************************
+ * DSU control registers definitions *
+ ********************************************************************/
+#define CLUSTERCFR_EL1 S3_0_C15_C3_0
+#define CLUSTERIDR_EL1 S3_0_C15_C3_1
+#define CLUSTERACTLR_EL1 S3_0_C15_C3_3
+
+/********************************************************************
+ * DSU control registers bit fields *
+ ********************************************************************/
+#define CLUSTERIDR_REV_SHIFT U(0)
+#define CLUSTERIDR_REV_BITS U(4)
+#define CLUSTERIDR_VAR_SHIFT U(4)
+#define CLUSTERIDR_VAR_BITS U(4)
+#define CLUSTERCFR_ACP_SHIFT U(11)
+
+/********************************************************************
+ * Masks applied for DSU errata workarounds *
+ ********************************************************************/
+#define DSU_ERRATA_936184_MASK (ULL(0x3) << 15)
+
+#endif /* DSU_DEF_H */
diff --git a/include/lib/el3_runtime/aarch64/context.h b/include/lib/el3_runtime/aarch64/context.h
index a2ce9f8..b990674 100644
--- a/include/lib/el3_runtime/aarch64/context.h
+++ b/include/lib/el3_runtime/aarch64/context.h
@@ -241,9 +241,9 @@
* Macros to access members of any of the above structures using their
* offsets
*/
-#define read_ctx_reg(ctx, offset) ((ctx)->_regs[offset >> DWORD_SHIFT])
-#define write_ctx_reg(ctx, offset, val) (((ctx)->_regs[offset >> DWORD_SHIFT]) \
- = val)
+#define read_ctx_reg(ctx, offset) ((ctx)->_regs[(offset) >> DWORD_SHIFT])
+#define write_ctx_reg(ctx, offset, val) (((ctx)->_regs[(offset) >> DWORD_SHIFT]) \
+ = (uint64_t) (val))
/*
* Top-level context structure which is used by EL3 firmware to
diff --git a/include/lib/extensions/amu.h b/include/lib/extensions/amu.h
index 559c8f1..46d5e15 100644
--- a/include/lib/extensions/amu.h
+++ b/include/lib/extensions/amu.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -10,7 +10,6 @@
#include <cassert.h>
#include <platform_def.h>
#include <stdint.h>
-#include <sys/cdefs.h> /* for CASSERT() */
/* All group 0 counters */
#define AMU_GROUP0_COUNTERS_MASK 0xf
diff --git a/include/lib/extensions/mpam.h b/include/lib/extensions/mpam.h
new file mode 100644
index 0000000..571b96b
--- /dev/null
+++ b/include/lib/extensions/mpam.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef MPAM_H
+#define MPAM_H
+
+#include <stdbool.h>
+
+bool mpam_supported(void);
+void mpam_enable(int el2_unused);
+
+#endif /* MPAM_H */
diff --git a/include/lib/extensions/ras.h b/include/lib/extensions/ras.h
index f57fc3a..400de59 100644
--- a/include/lib/extensions/ras.h
+++ b/include/lib/extensions/ras.h
@@ -4,10 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __RAS_COMMON__
-#define __RAS_COMMON__
+#ifndef RAS_COMMON
+#define RAS_COMMON
-#define ERR_HANDLER_VERSION 1
+#define ERR_HANDLER_VERSION 1U
/* Error record access mechanism */
#define ERR_ACCESS_SYSREG 0
@@ -20,18 +20,18 @@
* are declared. Only then would ARRAY_SIZE() yield a meaningful value.
*/
#define REGISTER_ERR_RECORD_INFO(_records) \
- const struct err_record_mapping err_record_mapping = { \
- .err_records = _records, \
+ const struct err_record_mapping err_record_mappings = { \
+ .err_records = (_records), \
.num_err_records = ARRAY_SIZE(_records), \
}
/* Error record info iterator */
#define for_each_err_record_info(_i, _info) \
- for (_i = 0, _info = err_record_mapping.err_records; \
- _i < err_record_mapping.num_err_records; \
- _i++, _info++)
+ for ((_i) = 0, (_info) = err_record_mappings.err_records; \
+ (_i) < err_record_mappings.num_err_records; \
+ (_i)++, (_info)++)
-#define _ERR_RECORD_COMMON(_probe, _handler, _aux) \
+#define ERR_RECORD_COMMON_(_probe, _handler, _aux) \
.probe = _probe, \
.handler = _handler, \
.aux_data = _aux,
@@ -42,7 +42,7 @@
.sysreg.idx_start = _idx_start, \
.sysreg.num_idx = _num_idx, \
.access = ERR_ACCESS_SYSREG, \
- _ERR_RECORD_COMMON(_probe, _handler, _aux) \
+ ERR_RECORD_COMMON_(_probe, _handler, _aux) \
}
#define ERR_RECORD_MEMMAP_V1(_base_addr, _size_num_k, _probe, _handler, _aux) \
@@ -51,7 +51,7 @@
.memmap.base_addr = _base_addr, \
.memmap.size_num_k = _size_num_k, \
.access = ERR_ACCESS_MEMMAP, \
- _ERR_RECORD_COMMON(_probe, _handler, _aux) \
+ ERR_RECORD_COMMON_(_probe, _handler, _aux) \
}
/*
@@ -63,8 +63,8 @@
* array is expected to be sorted in the increasing order of interrupt number.
*/
#define REGISTER_RAS_INTERRUPTS(_array) \
- const struct ras_interrupt_mapping ras_interrupt_mapping = { \
- .intrs = _array, \
+ const struct ras_interrupt_mapping ras_interrupt_mappings = { \
+ .intrs = (_array), \
.num_intrs = ARRAY_SIZE(_array), \
}
@@ -165,8 +165,8 @@
size_t num_intrs;
};
-extern const struct err_record_mapping err_record_mapping;
-extern const struct ras_interrupt_mapping ras_interrupt_mapping;
+extern const struct err_record_mapping err_record_mappings;
+extern const struct ras_interrupt_mapping ras_interrupt_mappings;
/*
@@ -196,4 +196,4 @@
void ras_init(void);
#endif /* __ASSEMBLY__ */
-#endif /* __RAS_COMMON__ */
+#endif /* RAS_COMMON */
diff --git a/include/lib/extensions/ras_arch.h b/include/lib/extensions/ras_arch.h
index 6ec4da8..e6cd736 100644
--- a/include/lib/extensions/ras_arch.h
+++ b/include/lib/extensions/ras_arch.h
@@ -11,28 +11,28 @@
* Size of nodes implementing Standard Error Records - currently only 4k is
* supported.
*/
-#define STD_ERR_NODE_SIZE_NUM_K 4
+#define STD_ERR_NODE_SIZE_NUM_K 4U
/*
* Individual register offsets within an error record in Standard Error Record
* format when error records are accessed through memory-mapped registers.
*/
-#define ERR_FR(n) (0x0 + (64 * (n)))
-#define ERR_CTLR(n) (0x8 + (64 * (n)))
-#define ERR_STATUS(n) (0x10 + (64 * (n)))
-#define ERR_ADDR(n) (0x18 + (64 * (n)))
-#define ERR_MISC0(n) (0x20 + (64 * (n)))
-#define ERR_MISC1(n) (0x28 + (64 * (n)))
+#define ERR_FR(n) (0x0ULL + (64ULL * (n)))
+#define ERR_CTLR(n) (0x8ULL + (64ULL * (n)))
+#define ERR_STATUS(n) (0x10ULL + (64ULL * (n)))
+#define ERR_ADDR(n) (0x18ULL + (64ULL * (n)))
+#define ERR_MISC0(n) (0x20ULL + (64ULL * (n)))
+#define ERR_MISC1(n) (0x28ULL + (64ULL * (n)))
/* Group Status Register (ERR_STATUS) offset */
#define ERR_GSR(base, size_num_k, n) \
- ((base) + (0x380 * (size_num_k)) + (8 * (n)))
+ ((base) + (0x380ULL * (size_num_k)) + (8ULL * (n)))
/* Management register offsets */
#define ERR_DEVID(base, size_num_k) \
- ((base) + ((0x400 * (size_num_k)) - 0x100) + 0xc8)
+ ((base) + ((0x400ULL * (size_num_k)) - 0x100ULL) + 0xc8ULL)
-#define ERR_DEVID_MASK 0xffff
+#define ERR_DEVID_MASK 0xffffUL
/* Standard Error Record status register fields */
#define ERR_STATUS_AV_SHIFT 31
@@ -244,7 +244,8 @@
*/
static inline void ser_sys_select_record(unsigned int idx)
{
- unsigned int max_idx __unused = read_erridr_el1() & ERRIDR_MASK;
+ unsigned int max_idx __unused =
+ (unsigned int) read_erridr_el1() & ERRIDR_MASK;
assert(idx < max_idx);
diff --git a/include/lib/libc/aarch32/endian_.h b/include/lib/libc/aarch32/endian_.h
new file mode 100644
index 0000000..83a26b7
--- /dev/null
+++ b/include/lib/libc/aarch32/endian_.h
@@ -0,0 +1,146 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * 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) 2018, ARM Limited and Contributors.
+ * All rights reserved.
+ */
+
+#ifndef AARCH32_ENDIAN_H
+#define AARCH32_ENDIAN_H
+
+#include <stdint.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 */
+
+#ifdef __ARMEB__
+#define _BYTE_ORDER _BIG_ENDIAN
+#else
+#define _BYTE_ORDER _LITTLE_ENDIAN
+#endif /* __ARMEB__ */
+
+#if __BSD_VISIBLE
+#define LITTLE_ENDIAN _LITTLE_ENDIAN
+#define BIG_ENDIAN _BIG_ENDIAN
+#define PDP_ENDIAN _PDP_ENDIAN
+#define BYTE_ORDER _BYTE_ORDER
+#endif
+
+#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 */
diff --git a/include/lib/libc/aarch32/limits_.h b/include/lib/libc/aarch32/limits_.h
new file mode 100644
index 0000000..26cec17
--- /dev/null
+++ b/include/lib/libc/aarch32/limits_.h
@@ -0,0 +1,26 @@
+/*
+ * 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
diff --git a/include/lib/libc/aarch32/stddef_.h b/include/lib/libc/aarch32/stddef_.h
new file mode 100644
index 0000000..928481c
--- /dev/null
+++ b/include/lib/libc/aarch32/stddef_.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef SIZET_
+typedef unsigned int size_t;
+#define SIZET_
+#endif
+
+#ifndef _PTRDIFF_T
+typedef long ptrdiff_t;
+#define _PTRDIFF_T
+#endif
diff --git a/include/lib/libc/aarch32/stdint_.h b/include/lib/libc/aarch32/stdint_.h
new file mode 100644
index 0000000..4f49485
--- /dev/null
+++ b/include/lib/libc/aarch32/stdint_.h
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#define INT8_MAX 0x7F
+#define INT8_MIN (-INT8_MAX - 1)
+#define UINT8_MAX 0xFFU
+
+#define INT16_MAX 0x7FFF
+#define INT16_MIN (-INT16_MAX - 1)
+#define UINT16_MAX 0xFFFFU
+
+#define INT32_MAX 0x7FFFFFFF
+#define INT32_MIN (-INT32_MAX - 1)
+#define UINT32_MAX 0xFFFFFFFFU
+
+#define INT64_MAX 0x7FFFFFFFFFFFFFFFLL
+#define INT64_MIN (-INT64_MAX - 1LL)
+#define UINT64_MAX 0xFFFFFFFFFFFFFFFFULL
+
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST8_MAX INT8_MAX
+#define UINT_LEAST8_MAX UINT8_MAX
+
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST16_MAX INT16_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST32_MAX INT32_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+
+#define INT_LEAST64_MIN INT64_MIN
+#define INT_LEAST64_MAX INT64_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
+
+#define INT_FAST8_MIN INT32_MIN
+#define INT_FAST8_MAX INT32_MAX
+#define UINT_FAST8_MAX UINT32_MAX
+
+#define INT_FAST16_MIN INT32_MIN
+#define INT_FAST16_MAX INT32_MAX
+#define UINT_FAST16_MAX UINT32_MAX
+
+#define INT_FAST32_MIN INT32_MIN
+#define INT_FAST32_MAX INT32_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+
+#define INT_FAST64_MIN INT64_MIN
+#define INT_FAST64_MAX INT64_MAX
+#define UINT_FAST64_MAX UINT64_MAX
+
+#define INTPTR_MIN INT32_MIN
+#define INTPTR_MAX INT32_MAX
+#define UINTPTR_MAX UINT32_MAX
+
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
+#define UINTMAX_MAX UINT64_MAX
+
+#define PTRDIFF_MIN INT32_MIN
+#define PTRDIFF_MAX INT32_MAX
+
+#define SIZE_MAX UINT32_MAX
+
+#define INT8_C(x) x
+#define INT16_C(x) x
+#define INT32_C(x) x
+#define INT64_C(x) x ## LL
+
+#define UINT8_C(x) x
+#define UINT16_C(x) x
+#define UINT32_C(x) x ## U
+#define UINT64_C(x) x ## ULL
+
+#define INTMAX_C(x) x ## LL
+#define UINTMAX_C(x) x ## ULL
+
+typedef signed char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+typedef long long int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+
+typedef signed char int8_least_t;
+typedef short int16_least_t;
+typedef int int32_least_t;
+typedef long long int64_least_t;
+
+typedef unsigned char uint8_least_t;
+typedef unsigned short uint16_least_t;
+typedef unsigned int uint32_least_t;
+typedef unsigned long long uint64_least_t;
+
+typedef int int8_fast_t;
+typedef int int16_fast_t;
+typedef int int32_fast_t;
+typedef long long int64_fast_t;
+
+typedef unsigned int uint8_fast_t;
+typedef unsigned int uint16_fast_t;
+typedef unsigned int uint32_fast_t;
+typedef unsigned long long uint64_fast_t;
+
+typedef long intptr_t;
+typedef unsigned long uintptr_t;
+
+typedef long long intmax_t;
+typedef unsigned long long uintmax_t;
+
+typedef long register_t;
+typedef unsigned long u_register_t;
diff --git a/include/lib/libc/aarch32/stdio_.h b/include/lib/libc/aarch32/stdio_.h
new file mode 100644
index 0000000..98304bc
--- /dev/null
+++ b/include/lib/libc/aarch32/stdio_.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef SIZET_
+typedef unsigned int size_t;
+#define SIZET_
+#endif
+
+#ifndef SSIZET_
+typedef int ssize_t;
+#define SSIZET_
+#endif
diff --git a/include/lib/libc/aarch32/stdlib_.h b/include/lib/libc/aarch32/stdlib_.h
new file mode 100644
index 0000000..af96d01
--- /dev/null
+++ b/include/lib/libc/aarch32/stdlib_.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef SIZET_
+typedef unsigned int size_t;
+#define SIZET_
+#endif
+
+#define EXIT_FAILURE 1
+#define EXIT_SUCCESS 0
diff --git a/include/lib/libc/aarch32/string_.h b/include/lib/libc/aarch32/string_.h
new file mode 100644
index 0000000..b3ad602
--- /dev/null
+++ b/include/lib/libc/aarch32/string_.h
@@ -0,0 +1,10 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef SIZET_
+typedef unsigned int size_t;
+#define SIZET_
+#endif
diff --git a/include/lib/libc/aarch32/time_.h b/include/lib/libc/aarch32/time_.h
new file mode 100644
index 0000000..4fc629d
--- /dev/null
+++ b/include/lib/libc/aarch32/time_.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef SIZET_
+typedef unsigned int size_t;
+#define SIZET_
+#endif
+
+typedef long int time_t;
diff --git a/include/lib/libc/machine/endian.h b/include/lib/libc/aarch64/endian_.h
similarity index 67%
rename from include/lib/libc/machine/endian.h
rename to include/lib/libc/aarch64/endian_.h
index 57e33b1..c60b475 100644
--- a/include/lib/libc/machine/endian.h
+++ b/include/lib/libc/aarch64/endian_.h
@@ -1,4 +1,6 @@
/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
* Copyright (c) 2001 David E. O'Brien
*
* Redistribution and use in source and binary forms, with or without
@@ -30,14 +32,14 @@
* $FreeBSD$
*/
/*
- * Portions copyright (c) 2017, ARM Limited and Contributors.
+ * Portions copyright (c) 2018, ARM Limited and Contributors.
* All rights reserved.
*/
-#ifndef _MACHINE_ENDIAN_H_
-#define _MACHINE_ENDIAN_H_
+#ifndef AARCH64_ENDIAN_H
+#define AARCH64_ENDIAN_H
-#include <sys/_types.h>
+#include <stdint.h>
/*
* Definitions for byte order, according to byte significance from low
@@ -63,80 +65,38 @@
#define __htonl(x) (__bswap32(x))
#define __htons(x) (__bswap16(x))
-#ifdef AARCH32
-static __inline __uint64_t
-__bswap64(__uint64_t _x)
+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;
+ uint64_t ret;
__asm __volatile("rev %0, %1\n"
: "=&r" (ret), "+r" (x));
-
+
return (ret);
}
-static __inline __uint32_t
-__bswap32_var(__uint32_t v)
+static __inline uint32_t
+__bswap32_var(uint32_t v)
{
- __uint32_t ret;
+ uint32_t ret;
__asm __volatile("rev32 %x0, %x1\n"
: "=&r" (ret), "+r" (v));
-
+
return (ret);
}
-static __inline __uint16_t
-__bswap16_var(__uint16_t v)
+static __inline uint16_t
+__bswap16_var(uint16_t v)
{
- __uint32_t ret;
+ 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 */
+ return ((uint16_t)ret);
+}
#ifdef __OPTIMIZE__
@@ -151,13 +111,13 @@
(((x) & 0x00ff) << 8))
#define __bswap16(x) \
- ((__uint16_t)(__builtin_constant_p(x) ? \
- __bswap16_constant(x) : \
+ ((uint16_t)(__builtin_constant_p(x) ? \
+ __bswap16_constant((uint16_t)(x)) : \
__bswap16_var(x)))
#define __bswap32(x) \
- ((__uint32_t)(__builtin_constant_p(x) ? \
- __bswap32_constant(x) : \
+ ((uint32_t)(__builtin_constant_p(x) ? \
+ __bswap32_constant((uint32_t)(x)) : \
__bswap32_var(x)))
#else
@@ -165,4 +125,4 @@
#define __bswap32(x) __bswap32_var(x)
#endif /* __OPTIMIZE__ */
-#endif /* !_MACHINE_ENDIAN_H_ */
+#endif /* AARCH64_ENDIAN_H */
diff --git a/include/lib/libc/aarch64/limits_.h b/include/lib/libc/aarch64/limits_.h
new file mode 100644
index 0000000..e36cfe7
--- /dev/null
+++ b/include/lib/libc/aarch64/limits_.h
@@ -0,0 +1,26 @@
+/*
+ * 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 0x7FFFFFFFFFFFFFFFL
+#define LONG_MIN (-LONG_MAX - 1L)
+#define ULONG_MAX 0xFFFFFFFFFFFFFFFFUL
+#define LLONG_MAX 0x7FFFFFFFFFFFFFFFLL
+#define LLONG_MIN (-LLONG_MAX - 1LL)
+#define ULLONG_MAX 0xFFFFFFFFFFFFFFFFULL
+
+#define __LONG_BIT 64
+#define __WORD_BIT 32
diff --git a/include/lib/libc/aarch64/stddef_.h b/include/lib/libc/aarch64/stddef_.h
new file mode 100644
index 0000000..3e5883e
--- /dev/null
+++ b/include/lib/libc/aarch64/stddef_.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef SIZET_
+typedef unsigned long size_t;
+#define SIZET_
+#endif
+
+#ifndef _PTRDIFF_T
+typedef long ptrdiff_t;
+#define _PTRDIFF_T
+#endif
diff --git a/include/lib/libc/aarch64/stdint_.h b/include/lib/libc/aarch64/stdint_.h
new file mode 100644
index 0000000..b99be30
--- /dev/null
+++ b/include/lib/libc/aarch64/stdint_.h
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#define INT8_MAX 0x7F
+#define INT8_MIN (-INT8_MAX - 1)
+#define UINT8_MAX 0xFFU
+
+#define INT16_MAX 0x7FFF
+#define INT16_MIN (-INT16_MAX - 1)
+#define UINT16_MAX 0xFFFFU
+
+#define INT32_MAX 0x7FFFFFFF
+#define INT32_MIN (-INT32_MAX - 1)
+#define UINT32_MAX 0xFFFFFFFFU
+
+#define INT64_MAX 0x7FFFFFFFFFFFFFFFLL
+#define INT64_MIN (-INT64_MAX - 1LL)
+#define UINT64_MAX 0xFFFFFFFFFFFFFFFFULL
+
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST8_MAX INT8_MAX
+#define UINT_LEAST8_MAX UINT8_MAX
+
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST16_MAX INT16_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST32_MAX INT32_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+
+#define INT_LEAST64_MIN INT64_MIN
+#define INT_LEAST64_MAX INT64_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
+
+#define INT_FAST8_MIN INT32_MIN
+#define INT_FAST8_MAX INT32_MAX
+#define UINT_FAST8_MAX UINT32_MAX
+
+#define INT_FAST16_MIN INT32_MIN
+#define INT_FAST16_MAX INT32_MAX
+#define UINT_FAST16_MAX UINT32_MAX
+
+#define INT_FAST32_MIN INT32_MIN
+#define INT_FAST32_MAX INT32_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+
+#define INT_FAST64_MIN INT64_MIN
+#define INT_FAST64_MAX INT64_MAX
+#define UINT_FAST64_MAX UINT64_MAX
+
+#define INTPTR_MIN INT64_MIN
+#define INTPTR_MAX INT64_MAX
+#define UINTPTR_MAX UINT64_MAX
+
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
+#define UINTMAX_MAX UINT64_MAX
+
+#define PTRDIFF_MIN INT64_MIN
+#define PTRDIFF_MAX INT64_MAX
+
+#define SIZE_MAX UINT64_MAX
+
+#define INT8_C(x) x
+#define INT16_C(x) x
+#define INT32_C(x) x
+#define INT64_C(x) x ## LL
+
+#define UINT8_C(x) x
+#define UINT16_C(x) x
+#define UINT32_C(x) x ## U
+#define UINT64_C(x) x ## ULL
+
+#define INTMAX_C(x) x ## L
+#define UINTMAX_C(x) x ## ULL
+
+typedef signed char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+typedef long long int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+
+typedef signed char int8_least_t;
+typedef short int16_least_t;
+typedef int int32_least_t;
+typedef long long int64_least_t;
+
+typedef unsigned char uint8_least_t;
+typedef unsigned short uint16_least_t;
+typedef unsigned int uint32_least_t;
+typedef unsigned long long uint64_least_t;
+
+typedef int int8_fast_t;
+typedef int int16_fast_t;
+typedef int int32_fast_t;
+typedef long long int64_fast_t;
+
+typedef unsigned int uint8_fast_t;
+typedef unsigned int uint16_fast_t;
+typedef unsigned int uint32_fast_t;
+typedef unsigned long long uint64_fast_t;
+
+typedef long intptr_t;
+typedef unsigned long uintptr_t;
+
+typedef long intmax_t;
+typedef unsigned long uintmax_t;
+
+typedef long register_t;
+typedef unsigned long u_register_t;
diff --git a/include/lib/libc/aarch64/stdio_.h b/include/lib/libc/aarch64/stdio_.h
new file mode 100644
index 0000000..ad0b200
--- /dev/null
+++ b/include/lib/libc/aarch64/stdio_.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef SIZET_
+typedef unsigned long size_t;
+#define SIZET_
+#endif
+
+#ifndef SSIZET_
+typedef long ssize_t;
+#define SSIZET_
+#endif
diff --git a/include/lib/libc/aarch64/stdlib_.h b/include/lib/libc/aarch64/stdlib_.h
new file mode 100644
index 0000000..3612c99
--- /dev/null
+++ b/include/lib/libc/aarch64/stdlib_.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef SIZET_
+typedef unsigned long size_t;
+#define SIZET_
+#endif
+
+#define EXIT_FAILURE 1
+#define EXIT_SUCCESS 0
diff --git a/include/lib/libc/aarch64/string_.h b/include/lib/libc/aarch64/string_.h
new file mode 100644
index 0000000..a88a751
--- /dev/null
+++ b/include/lib/libc/aarch64/string_.h
@@ -0,0 +1,10 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef SIZET_
+typedef unsigned long size_t;
+#define SIZET_
+#endif
diff --git a/include/lib/libc/aarch64/time_.h b/include/lib/libc/aarch64/time_.h
new file mode 100644
index 0000000..cbc34e7
--- /dev/null
+++ b/include/lib/libc/aarch64/time_.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef SIZET_
+typedef unsigned long size_t;
+#define SIZET_
+#endif
+
+typedef long int time_t;
diff --git a/include/lib/libc/assert.h b/include/lib/libc/assert.h
index db567db..2cca6a0 100644
--- a/include/lib/libc/assert.h
+++ b/include/lib/libc/assert.h
@@ -1,77 +1,39 @@
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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.
- *
- * @(#)assert.h 8.2 (Berkeley) 1/21/94
- * $FreeBSD$
- */
/*
- * Portions copyright (c) 2017, ARM Limited and Contributors.
- * All rights reserved.
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef _ASSERT_H_
-#define _ASSERT_H_
+#ifndef ASSERT_H
+#define ASSERT_H
+#include <cdefs.h>
#include <debug.h>
#include <platform_def.h>
-#include <sys/cdefs.h>
#ifndef PLAT_LOG_LEVEL_ASSERT
#define PLAT_LOG_LEVEL_ASSERT LOG_LEVEL
#endif
#if ENABLE_ASSERTIONS
-#define _assert(e) assert(e)
# if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
-# define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e))
+# define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e))
# elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
-# define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__))
+# define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__))
# else
-# define assert(e) ((e) ? (void)0 : __assert())
+# define assert(e) ((e) ? (void)0 : __assert())
# endif
#else
-#define assert(e) ((void)0)
-#define _assert(e) ((void)0)
+#define assert(e) ((void)0)
#endif /* ENABLE_ASSERTIONS */
-__BEGIN_DECLS
#if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
-void __assert(const char *, unsigned int, const char *) __dead2;
+__dead2 void __assert(const char *file, unsigned int line,
+ const char *assertion);
#elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
-void __assert(const char *, unsigned int) __dead2;
+__dead2 void __assert(const char *file, unsigned int line);
#else
-void __assert(void) __dead2;
+__dead2 void __assert(void);
#endif
-__END_DECLS
-#endif /* !_ASSERT_H_ */
+#endif /* ASSERT_H */
diff --git a/include/lib/libc/cdefs.h b/include/lib/libc/cdefs.h
new file mode 100644
index 0000000..b1d10cc
--- /dev/null
+++ b/include/lib/libc/cdefs.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef CDEFS_H
+#define CDEFS_H
+
+#define __dead2 __attribute__((__noreturn__))
+#define __deprecated __attribute__((__deprecated__))
+#define __packed __attribute__((__packed__))
+#define __used __attribute__((__used__))
+#define __unused __attribute__((__unused__))
+#define __aligned(x) __attribute__((__aligned__(x)))
+#define __section(x) __attribute__((__section__(x)))
+
+#define __printflike(fmtarg, firstvararg) \
+ __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
+
+#define __weak_reference(sym, alias) \
+ __asm__(".weak alias"); \
+ __asm__(".equ alias, sym")
+
+#define __STRING(x) #x
+#define __XSTRING(x) __STRING(x)
+
+#endif /* CDEFS_H */
diff --git a/include/lib/libc/sys/endian.h b/include/lib/libc/endian.h
similarity index 89%
rename from include/lib/libc/sys/endian.h
rename to include/lib/libc/endian.h
index d50110c..2cc4c5f 100644
--- a/include/lib/libc/sys/endian.h
+++ b/include/lib/libc/endian.h
@@ -1,4 +1,6 @@
/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
* Copyright (c) 2002 Thomas Moestl <tmm@FreeBSD.org>
* All rights reserved.
*
@@ -25,34 +27,18 @@
*
* $FreeBSD$
*/
+/*
+ * Portions copyright (c) 2018, ARM Limited and Contributors.
+ * All rights reserved.
+ */
-#ifndef _SYS_ENDIAN_H_
-#define _SYS_ENDIAN_H_
+#ifndef ENDIAN_H
+#define ENDIAN_H
-#include <sys/cdefs.h>
-#include <sys/_types.h>
-#include <machine/endian.h>
+#include <cdefs.h>
+#include <stdint.h>
+#include <endian_.h>
-#ifndef _UINT8_T_DECLARED
-typedef __uint8_t uint8_t;
-#define _UINT8_T_DECLARED
-#endif
-
-#ifndef _UINT16_T_DECLARED
-typedef __uint16_t uint16_t;
-#define _UINT16_T_DECLARED
-#endif
-
-#ifndef _UINT32_T_DECLARED
-typedef __uint32_t uint32_t;
-#define _UINT32_T_DECLARED
-#endif
-
-#ifndef _UINT64_T_DECLARED
-typedef __uint64_t uint64_t;
-#define _UINT64_T_DECLARED
-#endif
-
/*
* General byte order swapping functions.
*/
@@ -202,4 +188,4 @@
le32enc(p + 4, (uint32_t)(u >> 32));
}
-#endif /* _SYS_ENDIAN_H_ */
+#endif /* SYS_ENDIAN_H */
diff --git a/include/lib/libc/sys/errno.h b/include/lib/libc/errno.h
similarity index 87%
rename from include/lib/libc/sys/errno.h
rename to include/lib/libc/errno.h
index f595514..029912f 100644
--- a/include/lib/libc/sys/errno.h
+++ b/include/lib/libc/errno.h
@@ -1,4 +1,6 @@
/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
* Copyright (c) 1982, 1986, 1989, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
@@ -15,7 +17,7 @@
* 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
+ * 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.
*
@@ -34,17 +36,13 @@
* @(#)errno.h 8.5 (Berkeley) 1/21/94
* $FreeBSD$
*/
+/*
+ * Portions copyright (c) 2018, ARM Limited and Contributors.
+ * All rights reserved.
+ */
-#ifndef _SYS_ERRNO_H_
-#define _SYS_ERRNO_H_
-
-#ifndef _KERNEL
-#include <sys/cdefs.h>
-__BEGIN_DECLS
-int * __error(void);
-__END_DECLS
-#define errno (* __error())
-#endif
+#ifndef ERRNO_H
+#define ERRNO_H
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
@@ -61,9 +59,7 @@
#define ENOMEM 12 /* Cannot allocate memory */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
-#ifndef _POSIX_SOURCE
#define ENOTBLK 15 /* Block device required */
-#endif
#define EBUSY 16 /* Device busy */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */
@@ -74,9 +70,7 @@
#define ENFILE 23 /* Too many open files in system */
#define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Inappropriate ioctl for device */
-#ifndef _POSIX_SOURCE
#define ETXTBSY 26 /* Text file busy */
-#endif
#define EFBIG 27 /* File too large */
#define ENOSPC 28 /* No space left on device */
#define ESPIPE 29 /* Illegal seek */
@@ -90,7 +84,6 @@
/* non-blocking and interrupt i/o */
#define EAGAIN 35 /* Resource temporarily unavailable */
-#ifndef _POSIX_SOURCE
#define EWOULDBLOCK EAGAIN /* Operation would block */
#define EINPROGRESS 36 /* Operation now in progress */
#define EALREADY 37 /* Operation already in progress */
@@ -125,18 +118,14 @@
#define ECONNREFUSED 61 /* Connection refused */
#define ELOOP 62 /* Too many levels of symbolic links */
-#endif /* _POSIX_SOURCE */
#define ENAMETOOLONG 63 /* File name too long */
/* should be rearranged */
-#ifndef _POSIX_SOURCE
#define EHOSTDOWN 64 /* Host is down */
#define EHOSTUNREACH 65 /* No route to host */
-#endif /* _POSIX_SOURCE */
#define ENOTEMPTY 66 /* Directory not empty */
/* quotas & mush */
-#ifndef _POSIX_SOURCE
#define EPROCLIM 67 /* Too many processes */
#define EUSERS 68 /* Too many users */
#define EDQUOT 69 /* Disc quota exceeded */
@@ -149,12 +138,10 @@
#define EPROGUNAVAIL 74 /* RPC prog. not avail */
#define EPROGMISMATCH 75 /* Program version wrong */
#define EPROCUNAVAIL 76 /* Bad procedure for program */
-#endif /* _POSIX_SOURCE */
#define ENOLCK 77 /* No locks available */
#define ENOSYS 78 /* Function not implemented */
-#ifndef _POSIX_SOURCE
#define EFTYPE 79 /* Inappropriate file type or format */
#define EAUTH 80 /* Authentication error */
#define ENEEDAUTH 81 /* Need authenticator */
@@ -166,28 +153,17 @@
#define ENOATTR 87 /* Attribute not found */
#define EDOOFUS 88 /* Programming error */
-#endif /* _POSIX_SOURCE */
#define EBADMSG 89 /* Bad message */
#define EMULTIHOP 90 /* Multihop attempted */
#define ENOLINK 91 /* Link has been severed */
#define EPROTO 92 /* Protocol error */
-#ifndef _POSIX_SOURCE
#define ENOTCAPABLE 93 /* Capabilities insufficient */
#define ECAPMODE 94 /* Not permitted in capability mode */
-#endif /* _POSIX_SOURCE */
+#define ENOTRECOVERABLE 95 /* State not recoverable */
+#define EOWNERDEAD 96 /* Previous owner died */
-#ifndef _POSIX_SOURCE
-#define ELAST 94 /* Must be equal largest errno */
-#endif /* _POSIX_SOURCE */
+#define ELAST 96 /* Must be equal largest errno */
-#ifdef _KERNEL
-/* pseudo-errors returned inside kernel to modify return to process */
-#define ERESTART (-1) /* restart syscall */
-#define EJUSTRETURN (-2) /* don't modify regs, just return */
-#define ENOIOCTL (-3) /* ioctl not handled by this layer */
-#define EDIRIOCTL (-4) /* do direct ioctl in GEOM */
-#endif
-
-#endif
+#endif /* ERRNO_H */
diff --git a/include/lib/libc/inttypes.h b/include/lib/libc/inttypes.h
deleted file mode 100644
index 269f3e7..0000000
--- a/include/lib/libc/inttypes.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
- * 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 AUTHOR 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 AUTHOR 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$
- */
-
-#ifndef _INTTYPES_H_
-#define _INTTYPES_H_
-
-#include <machine/_inttypes.h>
-#include <sys/stdint.h>
-
-typedef struct {
- intmax_t quot; /* Quotient. */
- intmax_t rem; /* Remainder. */
-} imaxdiv_t;
-
-__BEGIN_DECLS
-#ifdef _XLOCALE_H_
-#include <xlocale/_inttypes.h>
-#endif
-intmax_t imaxabs(intmax_t) __pure2;
-imaxdiv_t imaxdiv(intmax_t, intmax_t) __pure2;
-
-intmax_t strtoimax(const char *__restrict, char **__restrict, int);
-uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
-
-__END_DECLS
-
-#endif /* !_INTTYPES_H_ */
diff --git a/include/lib/libc/limits.h b/include/lib/libc/limits.h
new file mode 100644
index 0000000..41bb658
--- /dev/null
+++ b/include/lib/libc/limits.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+/*
+ * Portions copyright (c) 2018, ARM Limited and Contributors.
+ * All rights reserved.
+ */
+
+#ifndef LIMITS_H
+#define LIMITS_H
+
+#include <limits_.h>
+
+#define CHAR_BIT 8
+#define MB_LEN_MAX 1
+
+#endif /* LIMITS_H */
diff --git a/include/lib/libc/machine/_inttypes.h b/include/lib/libc/machine/_inttypes.h
deleted file mode 100644
index 7dfe9c3..0000000
--- a/include/lib/libc/machine/_inttypes.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * 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_ */
diff --git a/include/lib/libc/machine/_limits.h b/include/lib/libc/machine/_limits.h
deleted file mode 100644
index 3bdc66f..0000000
--- a/include/lib/libc/machine/_limits.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*-
- * 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_ */
diff --git a/include/lib/libc/machine/_stdint.h b/include/lib/libc/machine/_stdint.h
deleted file mode 100644
index ee5372d..0000000
--- a/include/lib/libc/machine/_stdint.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/*-
- * 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_ */
diff --git a/include/lib/libc/machine/_types.h b/include/lib/libc/machine/_types.h
deleted file mode 100644
index 037fdf2..0000000
--- a/include/lib/libc/machine/_types.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*-
- * 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;
-typedef long long __int64_t;
-typedef unsigned long long __uint64_t;
-
-/*
- * Standard type definitions.
- */
-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
-#error "Only AArch32 or AArch64 supported"
-#endif /* AARCH32 */
-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;
-
-/*
- * 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_ */
diff --git a/include/lib/libc/stdarg.h b/include/lib/libc/stdarg.h
new file mode 100644
index 0000000..e260b9b
--- /dev/null
+++ b/include/lib/libc/stdarg.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+/*
+ * Portions copyright (c) 2018, ARM Limited and Contributors.
+ * All rights reserved.
+ */
+
+#ifndef STDARG_H
+#define STDARG_H
+
+#define va_list __builtin_va_list
+#define va_start(ap, last) __builtin_va_start(ap, last)
+#define va_end(ap) __builtin_va_end(ap)
+#define va_copy(to, from) __builtin_va_copy(to, from)
+#define va_arg(to, type) __builtin_va_arg(to, type)
+
+#endif /* STDARG_H */
diff --git a/include/lib/libc/stddef.h b/include/lib/libc/stddef.h
index ea88214..c9957bd 100644
--- a/include/lib/libc/stddef.h
+++ b/include/lib/libc/stddef.h
@@ -1,64 +1,22 @@
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
+/*
+ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero
*
- * 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.
- *
- * @(#)stddef.h 8.1 (Berkeley) 6/2/93
- *
- * $FreeBSD$
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+/*
+ * Portions copyright (c) 2018, ARM Limited and Contributors.
+ * All rights reserved.
*/
-#ifndef _STDDEF_H_
-#define _STDDEF_H_
+#ifndef STDDEF_H
+#define STDDEF_H
-#include <sys/cdefs.h>
-#include <sys/_null.h>
-#include <sys/_types.h>
+#include <stddef_.h>
-typedef __ptrdiff_t ptrdiff_t;
-
-#if __BSD_VISIBLE
-#ifndef _RUNE_T_DECLARED
-typedef __rune_t rune_t;
-#define _RUNE_T_DECLARED
-#endif
+#ifndef NULL
+#define NULL ((void *) 0)
#endif
-#ifndef _SIZE_T_DECLARED
-typedef __size_t size_t;
-#define _SIZE_T_DECLARED
-#endif
+#define offsetof(st, m) __builtin_offsetof(st, m)
-#ifndef __cplusplus
-#ifndef _WCHAR_T_DECLARED
-typedef __wchar_t wchar_t;
-#define _WCHAR_T_DECLARED
-#endif
-#endif
-
-#define offsetof(type, member) __offsetof(type, member)
-
-#endif /* _STDDEF_H_ */
+#endif /* STDDEF_H */
diff --git a/include/lib/libc/stdint.h b/include/lib/libc/stdint.h
new file mode 100644
index 0000000..d44a973
--- /dev/null
+++ b/include/lib/libc/stdint.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+/*
+ * Portions copyright (c) 2018, ARM Limited and Contributors.
+ * All rights reserved.
+ */
+
+#ifndef STDINT_H
+#define STDINT_H
+
+#include <stdint_.h>
+
+#endif /* STDINT_H */
diff --git a/include/lib/libc/stdio.h b/include/lib/libc/stdio.h
index 57e5c7f..3d9323e 100644
--- a/include/lib/libc/stdio.h
+++ b/include/lib/libc/stdio.h
@@ -1,78 +1,33 @@
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * 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.
- *
- * @(#)stdio.h 8.5 (Berkeley) 4/29/95
- * $FreeBSD$
- */
-
/*
- * Portions copyright (c) 2013-2014, ARM Limited and Contributors.
+ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+/*
+ * Portions copyright (c) 2018, ARM Limited and Contributors.
* All rights reserved.
*/
+#ifndef STDIO_H
+#define STDIO_H
-#ifndef _STDIO_H_
-#define _STDIO_H_
+#include <cdefs.h>
+#include <stdio_.h>
-#include <sys/cdefs.h>
-#include <sys/_null.h>
-#include <sys/_types.h>
-
-#ifndef _SIZE_T_DECLARED
-typedef __size_t size_t;
-#define _SIZE_T_DECLARED
+#ifndef NULL
+#define NULL ((void *) 0)
#endif
-#ifndef _SSIZE_T_DECLARED
-#define _SSIZE_T_DECLARED
-typedef __ssize_t ssize_t;
+#define EOF -1
+
+int printf(const char *fmt, ...) __printflike(1, 2);
+int snprintf(char *s, size_t n, const char *fmt, ...) __printflike(3, 4);
+
+#ifdef STDARG_H
+int vprintf(const char *fmt, va_list args);
#endif
-#define EOF (-1)
+int putchar(int c);
+int puts(const char *s);
-int printf(const char * __restrict, ...) __printflike(1, 2);
-int putchar(int);
-int puts(const char *);
-int sprintf(char * __restrict, const char * __restrict, ...)
- __printflike(2, 3);
-int vsprintf(char * __restrict, const char * __restrict,
- __va_list) __printflike(2, 0);
-
-int sscanf(const char *__restrict, char const *__restrict, ...);
-
-#if __ISO_C_VISIBLE >= 1999
-int snprintf(char * __restrict, size_t, const char * __restrict,
- ...) __printflike(3, 4);
-int vsnprintf(char * __restrict, size_t, const char * __restrict,
- __va_list) __printflike(3, 0);
-#endif
-
-#endif /* !_STDIO_H_ */
+#endif /* STDIO_H */
diff --git a/include/lib/libc/stdlib.h b/include/lib/libc/stdlib.h
index b1ac1bf..edd6265 100644
--- a/include/lib/libc/stdlib.h
+++ b/include/lib/libc/stdlib.h
@@ -1,313 +1,26 @@
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
+/*
+ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero
*
- * 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.
- *
- * @(#)stdlib.h 8.5 (Berkeley) 5/19/95
- * $FreeBSD$
+ * SPDX-License-Identifier: BSD-3-Clause
*/
-
-#ifndef _STDLIB_H_
-#define _STDLIB_H_
-
-#include <sys/cdefs.h>
-#include <sys/_null.h>
-#include <sys/_types.h>
-
-#if __BSD_VISIBLE
-#ifndef _RUNE_T_DECLARED
-typedef __rune_t rune_t;
-#define _RUNE_T_DECLARED
-#endif
-#endif
-
-#ifndef _SIZE_T_DECLARED
-typedef __size_t size_t;
-#define _SIZE_T_DECLARED
-#endif
-
-typedef struct {
- int quot; /* quotient */
- int rem; /* remainder */
-} div_t;
-
-typedef struct {
- long quot;
- long rem;
-} ldiv_t;
-
-#define EXIT_FAILURE 1
-#define EXIT_SUCCESS 0
-
-#define RAND_MAX 0x7ffffffd
-
-__BEGIN_DECLS
-#ifdef _XLOCALE_H_
-#include <xlocale/_stdlib.h>
-#endif
-extern int __mb_cur_max;
-extern int ___mb_cur_max(void);
-#define MB_CUR_MAX (___mb_cur_max())
-
-_Noreturn void abort(void);
-int abs(int) __pure2;
-int atexit(void (*)(void));
-double atof(const char *);
-int atoi(const char *);
-long atol(const char *);
-void *bsearch(const void *, const void *, size_t,
- size_t, int (*)(const void *, const void *));
-void *calloc(size_t, size_t) __malloc_like;
-div_t div(int, int) __pure2;
-_Noreturn void exit(int);
-void free(void *);
-char *getenv(const char *);
-long labs(long) __pure2;
-ldiv_t ldiv(long, long) __pure2;
-void *malloc(size_t) __malloc_like;
-int mblen(const char *, size_t);
-void qsort(void *, size_t, size_t,
- int (*)(const void *, const void *));
-int rand(void);
-void *realloc(void *, size_t);
-void srand(unsigned);
-double strtod(const char *__restrict, char **__restrict);
-float strtof(const char *__restrict, char **__restrict);
-long strtol(const char *__restrict, char **__restrict, int);
-long double
- strtold(const char *__restrict, char **__restrict);
-unsigned long
- strtoul(const char *__restrict, char **__restrict, int);
-int system(const char *);
-
/*
- * Functions added in C99 which we make conditionally available in the
- * BSD^C89 namespace if the compiler supports `long long'.
- * The #if test is more complicated than it ought to be because
- * __BSD_VISIBLE implies __ISO_C_VISIBLE == 1999 *even if* `long long'
- * is not supported in the compilation environment (which therefore means
- * that it can't really be ISO C99).
- *
- * (The only other extension made by C99 in thie header is _Exit().)
+ * Portions copyright (c) 2018, ARM Limited and Contributors.
+ * All rights reserved.
*/
-#if __ISO_C_VISIBLE >= 1999
-#ifdef __LONG_LONG_SUPPORTED
-/* LONGLONG */
-typedef struct {
- long long quot;
- long long rem;
-} lldiv_t;
-/* LONGLONG */
-long long
- atoll(const char *);
-/* LONGLONG */
-long long
- llabs(long long) __pure2;
-/* LONGLONG */
-lldiv_t lldiv(long long, long long) __pure2;
-/* LONGLONG */
-long long
- strtoll(const char *__restrict, char **__restrict, int);
-/* LONGLONG */
-unsigned long long
- strtoull(const char *__restrict, char **__restrict, int);
-#endif /* __LONG_LONG_SUPPORTED */
+#ifndef STDLIB_H
+#define STDLIB_H
-_Noreturn void _Exit(int);
-#endif /* __ISO_C_VISIBLE >= 1999 */
+#include <stdlib_.h>
-/*
- * If we're in a mode greater than C99, expose C11 functions.
- */
-#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
-void *aligned_alloc(size_t, size_t) __malloc_like;
-int at_quick_exit(void (*)(void));
-_Noreturn void
- quick_exit(int);
-#endif /* __ISO_C_VISIBLE >= 2011 */
-/*
- * Extensions made by POSIX relative to C.
- */
-#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE
-char *realpath(const char *__restrict, char *__restrict);
-#endif
-#if __POSIX_VISIBLE >= 199506
-int rand_r(unsigned *); /* (TSF) */
-#endif
-#if __POSIX_VISIBLE >= 200112
-int posix_memalign(void **, size_t, size_t); /* (ADV) */
-int setenv(const char *, const char *, int);
-int unsetenv(const char *);
+#ifndef NULL
+#define NULL ((void *) 0)
#endif
-#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
-int getsubopt(char **, char *const *, char **);
-#ifndef _MKDTEMP_DECLARED
-char *mkdtemp(char *);
-#define _MKDTEMP_DECLARED
-#endif
-#ifndef _MKSTEMP_DECLARED
-int mkstemp(char *);
-#define _MKSTEMP_DECLARED
-#endif
-#endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */
+#define _ATEXIT_MAX 1
-/*
- * The only changes to the XSI namespace in revision 6 were the deletion
- * of the ttyslot() and valloc() functions, which FreeBSD never declared
- * in this header. For revision 7, ecvt(), fcvt(), and gcvt(), which
- * FreeBSD also does not have, and mktemp(), are to be deleted.
- */
-#if __XSI_VISIBLE
-/* XXX XSI requires pollution from <sys/wait.h> here. We'd rather not. */
-long a64l(const char *);
-double drand48(void);
-/* char *ecvt(double, int, int * __restrict, int * __restrict); */
-double erand48(unsigned short[3]);
-/* char *fcvt(double, int, int * __restrict, int * __restrict); */
-/* char *gcvt(double, int, int * __restrict, int * __restrict); */
-int grantpt(int);
-char *initstate(unsigned long /* XSI requires u_int */, char *, long);
-long jrand48(unsigned short[3]);
-char *l64a(long);
-void lcong48(unsigned short[7]);
-long lrand48(void);
-#if !defined(_MKTEMP_DECLARED) && (__BSD_VISIBLE || __XSI_VISIBLE <= 600)
-char *mktemp(char *);
-#define _MKTEMP_DECLARED
-#endif
-long mrand48(void);
-long nrand48(unsigned short[3]);
-int posix_openpt(int);
-char *ptsname(int);
-int putenv(char *);
-long random(void);
-unsigned short
- *seed48(unsigned short[3]);
-#ifndef _SETKEY_DECLARED
-int setkey(const char *);
-#define _SETKEY_DECLARED
-#endif
-char *setstate(/* const */ char *);
-void srand48(long);
-void srandom(unsigned long);
-int unlockpt(int);
-#endif /* __XSI_VISIBLE */
+extern void abort(void);
+extern int atexit(void (*func)(void));
+extern void exit(int status);
-#if __BSD_VISIBLE
-extern const char *malloc_conf;
-extern void (*malloc_message)(void *, const char *);
-
-/*
- * The alloca() function can't be implemented in C, and on some
- * platforms it can't be implemented at all as a callable function.
- * The GNU C compiler provides a built-in alloca() which we can use;
- * in all other cases, provide a prototype, mainly to pacify various
- * incarnations of lint. On platforms where alloca() is not in libc,
- * programs which use it will fail to link when compiled with non-GNU
- * compilers.
- */
-#if __GNUC__ >= 2 || defined(__INTEL_COMPILER)
-#undef alloca /* some GNU bits try to get cute and define this on their own */
-#define alloca(sz) __builtin_alloca(sz)
-#elif defined(lint)
-void *alloca(size_t);
-#endif
-
-void abort2(const char *, int, void **) __dead2;
-__uint32_t
- arc4random(void);
-void arc4random_addrandom(unsigned char *, int);
-void arc4random_buf(void *, size_t);
-void arc4random_stir(void);
-__uint32_t
- arc4random_uniform(__uint32_t);
-#ifdef __BLOCKS__
-int atexit_b(void (^)(void));
-void *bsearch_b(const void *, const void *, size_t,
- size_t, int (^)(const void *, const void *));
-#endif
-char *getbsize(int *, long *);
- /* getcap(3) functions */
-char *cgetcap(char *, const char *, int);
-int cgetclose(void);
-int cgetent(char **, char **, const char *);
-int cgetfirst(char **, char **);
-int cgetmatch(const char *, const char *);
-int cgetnext(char **, char **);
-int cgetnum(char *, const char *, long *);
-int cgetset(const char *);
-int cgetstr(char *, const char *, char **);
-int cgetustr(char *, const char *, char **);
-
-int daemon(int, int);
-char *devname(__dev_t, __mode_t);
-char *devname_r(__dev_t, __mode_t, char *, int);
-char *fdevname(int);
-char *fdevname_r(int, char *, int);
-int getloadavg(double [], int);
-const char *
- getprogname(void);
-
-int heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
-#ifdef __BLOCKS__
-int heapsort_b(void *, size_t, size_t, int (^)(const void *, const void *));
-void qsort_b(void *, size_t, size_t,
- int (^)(const void *, const void *));
-#endif
-int l64a_r(long, char *, int);
-int mergesort(void *, size_t, size_t, int (*)(const void *, const void *));
-#ifdef __BLOCKS__
-int mergesort_b(void *, size_t, size_t, int (^)(const void *, const void *));
-#endif
-int mkostemp(char *, int);
-int mkostemps(char *, int, int);
-void qsort_r(void *, size_t, size_t, void *,
- int (*)(void *, const void *, const void *));
-int radixsort(const unsigned char **, int, const unsigned char *,
- unsigned);
-void *reallocf(void *, size_t);
-int rpmatch(const char *);
-void setprogname(const char *);
-int sradixsort(const unsigned char **, int, const unsigned char *,
- unsigned);
-void sranddev(void);
-void srandomdev(void);
-long long
- strtonum(const char *, long long, long long, const char **);
-
-/* Deprecated interfaces, to be removed in FreeBSD 6.0. */
-__int64_t
- strtoq(const char *, char **, int);
-__uint64_t
- strtouq(const char *, char **, int);
-
-extern char *suboptarg; /* getsubopt(3) external variable */
-#endif /* __BSD_VISIBLE */
-__END_DECLS
-
-#endif /* !_STDLIB_H_ */
+#endif /* STDLIB_H */
diff --git a/include/lib/libc/string.h b/include/lib/libc/string.h
index 56677b2..050f643 100644
--- a/include/lib/libc/string.h
+++ b/include/lib/libc/string.h
@@ -1,69 +1,31 @@
-/*-
- * 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.
- * 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.
- *
- * @(#)string.h 8.1 (Berkeley) 6/2/93
- * $FreeBSD$
- */
-
/*
- * Portions copyright (c) 2013-2017, ARM Limited and Contributors.
+ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+/*
+ * Portions copyright (c) 2018, ARM Limited and Contributors.
* All rights reserved.
*/
-#ifndef _STRING_H_
-#define _STRING_H_
+#ifndef STRING_H
+#define STRING_H
-#include <sys/cdefs.h>
-#include <sys/_null.h>
-#include <sys/_types.h>
+#include <string_.h>
-#ifndef _SIZE_T_DECLARED
-typedef __size_t size_t;
-#define _SIZE_T_DECLARED
+#ifndef NULL
+#define NULL ((void *) 0)
#endif
-__BEGIN_DECLS
+void *memcpy(void *dst, const void *src, size_t len);
+void *memmove(void *dst, const void *src, size_t len);
+int memcmp(const void *s1, const void *s2, size_t len);
+int strcmp(const char *s1, const char *s2);
+int strncmp(const char *s1, const char *s2, size_t n);
+void *memchr(const void *src, int c, size_t len);
+char *strchr(const char *s, int c);
+void *memset(void *dst, int val, size_t count);
+size_t strlen(const char *s);
+size_t strnlen(const char *s, size_t maxlen);
-void *memchr(const void *, int, size_t) __pure;
-int memcmp(const void *, const void *, size_t) __pure;
-void *memcpy(void * __restrict, const void * __restrict, size_t);
-void *memcpy16(void * __restrict, const void * __restrict, size_t);
-void *memmove(void *, const void *, size_t);
-void *memset(void *, int, size_t);
-
-char *strchr(const char *, int) __pure;
-int strcmp(const char *, const char *) __pure;
-size_t strlen(const char *) __pure;
-int strncmp(const char *, const char *, size_t) __pure;
-size_t strnlen(const char *, size_t) __pure;
-int strcasecmp(const char *, const char *);
-int timingsafe_bcmp(const void *, const void *, size_t);
-
-__END_DECLS
-
-#endif /* _STRING_H_ */
+#endif /* STRING_H */
diff --git a/include/lib/libc/strings.h b/include/lib/libc/strings.h
deleted file mode 100644
index 2210df0..0000000
--- a/include/lib/libc/strings.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
- * 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 AUTHOR 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 AUTHOR 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$
- */
-
-#ifndef _STRINGS_H_
-#define _STRINGS_H_
-
-#include <sys/cdefs.h>
-#include <sys/_types.h>
-
-#ifndef _SIZE_T_DECLARED
-typedef __size_t size_t;
-#define _SIZE_T_DECLARED
-#endif
-
-__BEGIN_DECLS
-#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
-int bcmp(const void *, const void *, size_t) __pure; /* LEGACY */
-void bcopy(const void *, void *, size_t); /* LEGACY */
-void bzero(void *, size_t); /* LEGACY */
-#endif
-#if __BSD_VISIBLE
-void explicit_bzero(void *, size_t);
-#endif
-#if __XSI_VISIBLE
-int ffs(int) __pure2;
-#endif
-#if __BSD_VISIBLE
-int ffsl(long) __pure2;
-int ffsll(long long) __pure2;
-int fls(int) __pure2;
-int flsl(long) __pure2;
-int flsll(long long) __pure2;
-#endif
-#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
-char *index(const char *, int) __pure; /* LEGACY */
-char *rindex(const char *, int) __pure; /* LEGACY */
-#endif
-int strcasecmp(const char *, const char *) __pure;
-int strncasecmp(const char *, const char *, size_t) __pure;
-
-#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
-#include <xlocale/_strings.h>
-#endif
-__END_DECLS
-
-#endif /* _STRINGS_H_ */
diff --git a/include/lib/libc/sys/_null.h b/include/lib/libc/sys/_null.h
deleted file mode 100644
index 92706c6..0000000
--- a/include/lib/libc/sys/_null.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * Copyright (c) 2003 Marcel Moolenaar
- * 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 AUTHOR ``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 AUTHOR 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$
- */
-
-#ifndef NULL
-
-#if !defined(__cplusplus)
-#define NULL ((void *)0)
-#else
-#if __cplusplus >= 201103L
-#define NULL nullptr
-#elif defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4
-#define NULL __null
-#else
-#if defined(__LP64__)
-#define NULL (0L)
-#else
-#define NULL 0
-#endif /* __LP64__ */
-#endif /* __GNUG__ */
-#endif /* !__cplusplus */
-
-#endif
diff --git a/include/lib/libc/sys/_stdint.h b/include/lib/libc/sys/_stdint.h
deleted file mode 100644
index d0f9249..0000000
--- a/include/lib/libc/sys/_stdint.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * Copyright (c) 2011 David E. O'Brien <obrien@FreeBSD.org>
- * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
- * 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 AUTHOR 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 AUTHOR 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$
- */
-
-#ifndef _SYS__STDINT_H_
-#define _SYS__STDINT_H_
-
-#ifndef _INT8_T_DECLARED
-typedef __int8_t int8_t;
-#define _INT8_T_DECLARED
-#endif
-
-#ifndef _INT16_T_DECLARED
-typedef __int16_t int16_t;
-#define _INT16_T_DECLARED
-#endif
-
-#ifndef _INT32_T_DECLARED
-typedef __int32_t int32_t;
-#define _INT32_T_DECLARED
-#endif
-
-#ifndef _INT64_T_DECLARED
-typedef __int64_t int64_t;
-#define _INT64_T_DECLARED
-#endif
-
-#ifndef _UINT8_T_DECLARED
-typedef __uint8_t uint8_t;
-#define _UINT8_T_DECLARED
-#endif
-
-#ifndef _UINT16_T_DECLARED
-typedef __uint16_t uint16_t;
-#define _UINT16_T_DECLARED
-#endif
-
-#ifndef _UINT32_T_DECLARED
-typedef __uint32_t uint32_t;
-#define _UINT32_T_DECLARED
-#endif
-
-#ifndef _UINT64_T_DECLARED
-typedef __uint64_t uint64_t;
-#define _UINT64_T_DECLARED
-#endif
-
-#ifndef _INTPTR_T_DECLARED
-typedef __intptr_t intptr_t;
-#define _INTPTR_T_DECLARED
-#endif
-#ifndef _UINTPTR_T_DECLARED
-typedef __uintptr_t uintptr_t;
-#define _UINTPTR_T_DECLARED
-#endif
-
-#endif /* !_SYS__STDINT_H_ */
diff --git a/include/lib/libc/sys/_timespec.h b/include/lib/libc/sys/_timespec.h
deleted file mode 100644
index d51559c..0000000
--- a/include/lib/libc/sys/_timespec.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * Copyright (c) 1982, 1986, 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.
- *
- * @(#)time.h 8.5 (Berkeley) 5/4/95
- * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp
- * $FreeBSD$
- */
-
-#ifndef _SYS__TIMESPEC_H_
-#define _SYS__TIMESPEC_H_
-
-#include <sys/_types.h>
-
-#ifndef _TIME_T_DECLARED
-typedef __time_t time_t;
-#define _TIME_T_DECLARED
-#endif
-
-struct timespec {
- time_t tv_sec; /* seconds */
- long tv_nsec; /* and nanoseconds */
-};
-
-#endif /* !_SYS__TIMESPEC_H_ */
diff --git a/include/lib/libc/sys/_types.h b/include/lib/libc/sys/_types.h
deleted file mode 100644
index c59afd3..0000000
--- a/include/lib/libc/sys/_types.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
- * 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 AUTHOR 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 AUTHOR 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$
- */
-
-#ifndef _SYS__TYPES_H_
-#define _SYS__TYPES_H_
-
-#include <sys/cdefs.h>
-#include <machine/_types.h>
-
-/*
- * Standard type definitions.
- */
-typedef __uint32_t __blksize_t; /* file block size */
-typedef __int64_t __blkcnt_t; /* file block count */
-typedef __int32_t __clockid_t; /* clock_gettime()... */
-typedef __uint64_t __cap_rights_t; /* capability rights */
-typedef __uint32_t __fflags_t; /* file flags */
-typedef __uint64_t __fsblkcnt_t;
-typedef __uint64_t __fsfilcnt_t;
-typedef __uint32_t __gid_t;
-typedef __int64_t __id_t; /* can hold a gid_t, pid_t, or uid_t */
-typedef __uint32_t __ino_t; /* inode number */
-typedef long __key_t; /* IPC key (for Sys V IPC) */
-typedef __int32_t __lwpid_t; /* Thread ID (a.k.a. LWP) */
-typedef __uint16_t __mode_t; /* permissions */
-typedef int __accmode_t; /* access permissions */
-typedef int __nl_item;
-typedef __uint16_t __nlink_t; /* link count */
-typedef __int64_t __off_t; /* file offset */
-typedef __int32_t __pid_t; /* process [group] */
-typedef __int64_t __rlim_t; /* resource limit - intentionally */
- /* signed, because of legacy code */
- /* that uses -1 for RLIM_INFINITY */
-typedef __uint8_t __sa_family_t;
-typedef __uint32_t __socklen_t;
-typedef long __suseconds_t; /* microseconds (signed) */
-typedef struct __timer *__timer_t; /* timer_gettime()... */
-typedef struct __mq *__mqd_t; /* mq_open()... */
-typedef __uint32_t __uid_t;
-typedef unsigned int __useconds_t; /* microseconds (unsigned) */
-typedef int __cpuwhich_t; /* which parameter for cpuset. */
-typedef int __cpulevel_t; /* level parameter for cpuset. */
-typedef int __cpusetid_t; /* cpuset identifier. */
-
-/*
- * Unusual type definitions.
- */
-/*
- * rune_t is declared to be an ``int'' instead of the more natural
- * ``unsigned long'' or ``long''. Two things are happening here. It is not
- * unsigned so that EOF (-1) can be naturally assigned to it and used. Also,
- * it looks like 10646 will be a 31 bit standard. This means that if your
- * ints cannot hold 32 bits, you will be in trouble. The reason an int was
- * chosen over a long is that the is*() and to*() routines take ints (says
- * ANSI C), but they use __ct_rune_t instead of int.
- *
- * NOTE: rune_t is not covered by ANSI nor other standards, and should not
- * be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and
- * rune_t must be the same type. Also, wint_t must be no narrower than
- * wchar_t, and should be able to hold all members of the largest
- * character set plus one extra value (WEOF), and must be at least 16 bits.
- */
-typedef int __ct_rune_t; /* arg type for ctype funcs */
-typedef __ct_rune_t __rune_t; /* rune_t (see above) */
-typedef __ct_rune_t __wchar_t; /* wchar_t (see above) */
-typedef __ct_rune_t __wint_t; /* wint_t (see above) */
-
-typedef __uint32_t __dev_t; /* device number */
-
-typedef __uint32_t __fixpt_t; /* fixed point number */
-
-/*
- * mbstate_t is an opaque object to keep conversion state during multibyte
- * stream conversions.
- */
-typedef union {
- char __mbstate8[128];
- __int64_t _mbstateL; /* for alignment */
-} __mbstate_t;
-
-#endif /* !_SYS__TYPES_H_ */
diff --git a/include/lib/libc/sys/cdefs.h b/include/lib/libc/sys/cdefs.h
deleted file mode 100644
index 70c09fd..0000000
--- a/include/lib/libc/sys/cdefs.h
+++ /dev/null
@@ -1,688 +0,0 @@
-/*-
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Berkeley Software Design, Inc.
- *
- * 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.
- *
- * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
- * $FreeBSD$
- */
-
-#ifndef _SYS_CDEFS_H_
-#define _SYS_CDEFS_H_
-
-#if defined(__cplusplus)
-#define __BEGIN_DECLS extern "C" {
-#define __END_DECLS }
-#else
-#define __BEGIN_DECLS
-#define __END_DECLS
-#endif
-
-/*
- * This code has been put in place to help reduce the addition of
- * compiler specific defines in FreeBSD code. It helps to aid in
- * having a compiler-agnostic source tree.
- */
-
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
-
-#if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
-#define __GNUCLIKE_ASM 3
-#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
-#else
-#define __GNUCLIKE_ASM 2
-#endif
-#define __GNUCLIKE___TYPEOF 1
-#define __GNUCLIKE___OFFSETOF 1
-#define __GNUCLIKE___SECTION 1
-
-#ifndef __INTEL_COMPILER
-# define __GNUCLIKE_CTOR_SECTION_HANDLING 1
-#endif
-
-#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
-# if defined(__INTEL_COMPILER) && defined(__cplusplus) \
- && __INTEL_COMPILER < 800
-# undef __GNUCLIKE_BUILTIN_CONSTANT_P
-# endif
-
-#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER)
-# define __GNUCLIKE_BUILTIN_VARARGS 1
-# define __GNUCLIKE_BUILTIN_STDARG 1
-# define __GNUCLIKE_BUILTIN_VAALIST 1
-#endif
-
-#if defined(__GNUC__)
-# define __GNUC_VA_LIST_COMPATIBILITY 1
-#endif
-
-#ifndef __INTEL_COMPILER
-# define __GNUCLIKE_BUILTIN_NEXT_ARG 1
-# define __GNUCLIKE_MATH_BUILTIN_RELOPS
-#endif
-
-#define __GNUCLIKE_BUILTIN_MEMCPY 1
-
-/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
-#define __CC_SUPPORTS_INLINE 1
-#define __CC_SUPPORTS___INLINE 1
-#define __CC_SUPPORTS___INLINE__ 1
-
-#define __CC_SUPPORTS___FUNC__ 1
-#define __CC_SUPPORTS_WARNING 1
-
-#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
-
-#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
-
-#endif /* __GNUC__ || __INTEL_COMPILER */
-
-/*
- * Macro to test if we're using a specific version of gcc or later.
- */
-#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
-#define __GNUC_PREREQ__(ma, mi) \
- (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
-#else
-#define __GNUC_PREREQ__(ma, mi) 0
-#endif
-
-/*
- * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
- * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
- * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
- * mode -- there must be no spaces between its arguments, and for nested
- * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also
- * concatenate double-quoted strings produced by the __STRING macro, but
- * this only works with ANSI C.
- *
- * __XSTRING is like __STRING, but it expands any macros in its argument
- * first. It is only available with ANSI C.
- */
-#if defined(__STDC__) || defined(__cplusplus)
-#define __P(protos) protos /* full-blown ANSI C */
-#define __CONCAT1(x,y) x ## y
-#define __CONCAT(x,y) __CONCAT1(x,y)
-#define __STRING(x) #x /* stringify without expanding x */
-#define __XSTRING(x) __STRING(x) /* expand x, then stringify */
-
-#define __const const /* define reserved names to standard */
-#define __signed signed
-#define __volatile volatile
-#if defined(__cplusplus)
-#define __inline inline /* convert to C++ keyword */
-#else
-#if !(defined(__CC_SUPPORTS___INLINE))
-#define __inline /* delete GCC keyword */
-#endif /* ! __CC_SUPPORTS___INLINE */
-#endif /* !__cplusplus */
-
-#else /* !(__STDC__ || __cplusplus) */
-#define __P(protos) () /* traditional C preprocessor */
-#define __CONCAT(x,y) x/**/y
-#define __STRING(x) "x"
-
-#if !defined(__CC_SUPPORTS___INLINE)
-#define __const /* delete pseudo-ANSI C keywords */
-#define __inline
-#define __signed
-#define __volatile
-/*
- * In non-ANSI C environments, new programs will want ANSI-only C keywords
- * deleted from the program and old programs will want them left alone.
- * When using a compiler other than gcc, programs using the ANSI C keywords
- * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
- * When using "gcc -traditional", we assume that this is the intent; if
- * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
- */
-#ifndef NO_ANSI_KEYWORDS
-#define const /* delete ANSI C keywords */
-#define inline
-#define signed
-#define volatile
-#endif /* !NO_ANSI_KEYWORDS */
-#endif /* !__CC_SUPPORTS___INLINE */
-#endif /* !(__STDC__ || __cplusplus) */
-
-/*
- * Compiler-dependent macros to help declare dead (non-returning) and
- * pure (no side effects) functions, and unused variables. They are
- * null except for versions of gcc that are known to support the features
- * properly (old versions of gcc-2 supported the dead and pure features
- * in a different (wrong) way). If we do not provide an implementation
- * for a given compiler, let the compile fail if it is told to use
- * a feature that we cannot live without.
- */
-#ifdef lint
-#define __dead2
-#define __pure2
-#define __unused
-#define __packed
-#define __aligned(x)
-#define __section(x)
-#else
-#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
-#define __dead2
-#define __pure2
-#define __unused
-#endif
-#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER)
-#define __dead2 __attribute__((__noreturn__))
-#define __pure2 __attribute__((__const__))
-#define __unused
-/* XXX Find out what to do for __packed, __aligned and __section */
-#endif
-#if __GNUC_PREREQ__(2, 7)
-#define __dead2 __attribute__((__noreturn__))
-#define __pure2 __attribute__((__const__))
-#define __unused __attribute__((__unused__))
-#define __used __attribute__((__used__))
-#define __packed __attribute__((__packed__))
-#define __aligned(x) __attribute__((__aligned__(x)))
-#define __section(x) __attribute__((__section__(x)))
-#endif
-#if defined(__INTEL_COMPILER)
-#define __dead2 __attribute__((__noreturn__))
-#define __pure2 __attribute__((__const__))
-#define __unused __attribute__((__unused__))
-#define __used __attribute__((__used__))
-#define __packed __attribute__((__packed__))
-#define __aligned(x) __attribute__((__aligned__(x)))
-#define __section(x) __attribute__((__section__(x)))
-#endif
-#endif
-
-#if !__GNUC_PREREQ__(2, 95)
-#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b)
-#endif
-
-/*
- * Keywords added in C11.
- */
-#if defined(__cplusplus) && __cplusplus >= 201103L
-#define _Alignas(e) alignas(e)
-#define _Alignof(e) alignof(e)
-#define _Noreturn [[noreturn]]
-#define _Static_assert(e, s) static_assert(e, s)
-/* FIXME: change this to thread_local when clang in base supports it */
-#define _Thread_local __thread
-#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
-/* Do nothing. They are language keywords. */
-#else
-/* Not supported. Implement them using our versions. */
-#define _Alignas(x) __aligned(x)
-#define _Alignof(x) __alignof(x)
-#define _Noreturn __dead2
-#define _Thread_local __thread
-#ifdef __COUNTER__
-#define _Static_assert(x, y) __Static_assert(x, __COUNTER__)
-#define __Static_assert(x, y) ___Static_assert(x, y)
-#define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1]
-#else
-#define _Static_assert(x, y) struct __hack
-#endif
-#endif
-
-/*
- * Emulation of C11 _Generic(). Unlike the previously defined C11
- * keywords, it is not possible to implement this using exactly the same
- * syntax. Therefore implement something similar under the name
- * __generic(). Unlike _Generic(), this macro can only distinguish
- * between a single type, so it requires nested invocations to
- * distinguish multiple cases.
- */
-
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
-#define __generic(expr, t, yes, no) \
- _Generic(expr, t: yes, default: no)
-#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
-#define __generic(expr, t, yes, no) \
- __builtin_choose_expr( \
- __builtin_types_compatible_p(__typeof(expr), t), yes, no)
-#endif
-
-#if __GNUC_PREREQ__(2, 96)
-#define __malloc_like __attribute__((__malloc__))
-#define __pure __attribute__((__pure__))
-#else
-#define __malloc_like
-#define __pure
-#endif
-
-#if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
-#define __always_inline __attribute__((__always_inline__))
-#else
-#define __always_inline
-#endif
-
-#if __GNUC_PREREQ__(3, 1)
-#define __noinline __attribute__ ((__noinline__))
-#define __deprecated __attribute__ ((__deprecated__))
-#else
-#define __noinline
-#define __deprecated
-#endif
-
-#if __GNUC_PREREQ__(3, 3)
-#define __nonnull(x) __attribute__((__nonnull__(x)))
-#else
-#define __nonnull(x)
-#endif
-
-#if __GNUC_PREREQ__(3, 4)
-#define __fastcall __attribute__((__fastcall__))
-#else
-#define __fastcall
-#endif
-
-#if __GNUC_PREREQ__(4, 1)
-#define __returns_twice __attribute__((__returns_twice__))
-#else
-#define __returns_twice
-#endif
-
-/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
-#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
-#define __func__ NULL
-#endif
-
-#if (defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
-#define __LONG_LONG_SUPPORTED
-#endif
-
-/* C++11 exposes a load of C99 stuff */
-#if defined(__cplusplus) && __cplusplus >= 201103L
-#define __LONG_LONG_SUPPORTED
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS
-#endif
-#ifndef __STDC_CONSTANT_MACROS
-#define __STDC_CONSTANT_MACROS
-#endif
-#endif
-
-/*
- * GCC 2.95 provides `__restrict' as an extension to C90 to support the
- * C99-specific `restrict' type qualifier. We happen to use `__restrict' as
- * a way to define the `restrict' type qualifier without disturbing older
- * software that is unaware of C99 keywords.
- */
-#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
-#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint)
-#define __restrict
-#else
-#define __restrict restrict
-#endif
-#endif
-
-/*
- * GNU C version 2.96 adds explicit branch prediction so that
- * the CPU back-end can hint the processor and also so that
- * code blocks can be reordered such that the predicted path
- * sees a more linear flow, thus improving cache behavior, etc.
- *
- * The following two macros provide us with a way to utilize this
- * compiler feature. Use __predict_true() if you expect the expression
- * to evaluate to true, and __predict_false() if you expect the
- * expression to evaluate to false.
- *
- * A few notes about usage:
- *
- * * Generally, __predict_false() error condition checks (unless
- * you have some _strong_ reason to do otherwise, in which case
- * document it), and/or __predict_true() `no-error' condition
- * checks, assuming you want to optimize for the no-error case.
- *
- * * Other than that, if you don't know the likelihood of a test
- * succeeding from empirical or other `hard' evidence, don't
- * make predictions.
- *
- * * These are meant to be used in places that are run `a lot'.
- * It is wasteful to make predictions in code that is run
- * seldomly (e.g. at subsystem initialization time) as the
- * basic block reordering that this affects can often generate
- * larger code.
- */
-#if __GNUC_PREREQ__(2, 96)
-#define __predict_true(exp) __builtin_expect((exp), 1)
-#define __predict_false(exp) __builtin_expect((exp), 0)
-#else
-#define __predict_true(exp) (exp)
-#define __predict_false(exp) (exp)
-#endif
-
-#if __GNUC_PREREQ__(4, 2)
-#define __hidden __attribute__((__visibility__("hidden")))
-#define __exported __attribute__((__visibility__("default")))
-#else
-#define __hidden
-#define __exported
-#endif
-
-/*
- * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
- * require it.
- */
-#if __GNUC_PREREQ__(4, 1)
-#define __offsetof(type, field) __builtin_offsetof(type, field)
-#else
-#ifndef __cplusplus
-#define __offsetof(type, field) \
- ((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field))
-#else
-#define __offsetof(type, field) \
- (__offsetof__ (reinterpret_cast <__size_t> \
- (&reinterpret_cast <const volatile char &> \
- (static_cast<type *> (0)->field))))
-#endif
-#endif
-#define __rangeof(type, start, end) \
- (__offsetof(type, end) - __offsetof(type, start))
-
-/*
- * Given the pointer x to the member m of the struct s, return
- * a pointer to the containing structure. When using GCC, we first
- * assign pointer x to a local variable, to check that its type is
- * compatible with member m.
- */
-#if __GNUC_PREREQ__(3, 1)
-#define __containerof(x, s, m) ({ \
- const volatile __typeof(((s *)0)->m) *__x = (x); \
- __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
-})
-#else
-#define __containerof(x, s, m) \
- __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m))
-#endif
-
-/*
- * Compiler-dependent macros to declare that functions take printf-like
- * or scanf-like arguments. They are null except for versions of gcc
- * that are known to support the features properly (old versions of gcc-2
- * didn't permit keeping the keywords out of the application namespace).
- */
-#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
-#define __printflike(fmtarg, firstvararg)
-#define __scanflike(fmtarg, firstvararg)
-#define __format_arg(fmtarg)
-#define __strfmonlike(fmtarg, firstvararg)
-#define __strftimelike(fmtarg, firstvararg)
-#else
-#define __printflike(fmtarg, firstvararg) \
- __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
-#define __scanflike(fmtarg, firstvararg) \
- __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
-#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg)))
-#define __strfmonlike(fmtarg, firstvararg) \
- __attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))
-#define __strftimelike(fmtarg, firstvararg) \
- __attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
-#endif
-
-/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
-#if __FreeBSD_cc_version >= 300001 && defined(__GNUC__) && !defined(__INTEL_COMPILER)
-#define __printf0like(fmtarg, firstvararg) \
- __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
-#else
-#define __printf0like(fmtarg, firstvararg)
-#endif
-
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
-#ifndef __INTEL_COMPILER
-#define __strong_reference(sym,aliassym) \
- extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
-#endif
-#ifdef __STDC__
-#define __weak_reference(sym,alias) \
- __asm__(".weak " #alias); \
- __asm__(".equ " #alias ", " #sym)
-#define __warn_references(sym,msg) \
- __asm__(".section .gnu.warning." #sym); \
- __asm__(".asciz \"" msg "\""); \
- __asm__(".previous")
-#define __sym_compat(sym,impl,verid) \
- __asm__(".symver " #impl ", " #sym "@" #verid)
-#define __sym_default(sym,impl,verid) \
- __asm__(".symver " #impl ", " #sym "@@" #verid)
-#else
-#define __weak_reference(sym,alias) \
- __asm__(".weak alias"); \
- __asm__(".equ alias, sym")
-#define __warn_references(sym,msg) \
- __asm__(".section .gnu.warning.sym"); \
- __asm__(".asciz \"msg\""); \
- __asm__(".previous")
-#define __sym_compat(sym,impl,verid) \
- __asm__(".symver impl, sym@verid")
-#define __sym_default(impl,sym,verid) \
- __asm__(".symver impl, sym@@verid")
-#endif /* __STDC__ */
-#endif /* __GNUC__ || __INTEL_COMPILER */
-
-#define __GLOBL1(sym) __asm__(".globl " #sym)
-#define __GLOBL(sym) __GLOBL1(sym)
-
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
-#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
-#else
-/*
- * The following definition might not work well if used in header files,
- * but it should be better than nothing. If you want a "do nothing"
- * version, then it should generate some harmless declaration, such as:
- * #define __IDSTRING(name,string) struct __hack
- */
-#define __IDSTRING(name,string) static const char name[] __unused = string
-#endif
-
-/*
- * Embed the rcs id of a source file in the resulting library. Note that in
- * more recent ELF binutils, we use .ident allowing the ID to be stripped.
- * Usage:
- * __FBSDID("$FreeBSD$");
- */
-#ifndef __FBSDID
-#if !defined(lint) && !defined(STRIP_FBSDID)
-#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
-#else
-#define __FBSDID(s) struct __hack
-#endif
-#endif
-
-#ifndef __RCSID
-#ifndef NO__RCSID
-#define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
-#else
-#define __RCSID(s) struct __hack
-#endif
-#endif
-
-#ifndef __RCSID_SOURCE
-#ifndef NO__RCSID_SOURCE
-#define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
-#else
-#define __RCSID_SOURCE(s) struct __hack
-#endif
-#endif
-
-#ifndef __SCCSID
-#ifndef NO__SCCSID
-#define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
-#else
-#define __SCCSID(s) struct __hack
-#endif
-#endif
-
-#ifndef __COPYRIGHT
-#ifndef NO__COPYRIGHT
-#define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
-#else
-#define __COPYRIGHT(s) struct __hack
-#endif
-#endif
-
-#ifndef __DECONST
-#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var))
-#endif
-
-#ifndef __DEVOLATILE
-#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var))
-#endif
-
-#ifndef __DEQUALIFY
-#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
-#endif
-
-/*-
- * The following definitions are an extension of the behavior originally
- * implemented in <sys/_posix.h>, but with a different level of granularity.
- * POSIX.1 requires that the macros we test be defined before any standard
- * header file is included.
- *
- * Here's a quick run-down of the versions:
- * defined(_POSIX_SOURCE) 1003.1-1988
- * _POSIX_C_SOURCE == 1 1003.1-1990
- * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
- * _POSIX_C_SOURCE == 199309 1003.1b-1993
- * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
- * and the omnibus ISO/IEC 9945-1: 1996
- * _POSIX_C_SOURCE == 200112 1003.1-2001
- * _POSIX_C_SOURCE == 200809 1003.1-2008
- *
- * In addition, the X/Open Portability Guide, which is now the Single UNIX
- * Specification, defines a feature-test macro which indicates the version of
- * that specification, and which subsumes _POSIX_C_SOURCE.
- *
- * Our macros begin with two underscores to avoid namespace screwage.
- */
-
-/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
-#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
-#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
-#define _POSIX_C_SOURCE 199009
-#endif
-
-/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
-#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
-#undef _POSIX_C_SOURCE
-#define _POSIX_C_SOURCE 199209
-#endif
-
-/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
-#ifdef _XOPEN_SOURCE
-#if _XOPEN_SOURCE - 0 >= 700
-#define __XSI_VISIBLE 700
-#undef _POSIX_C_SOURCE
-#define _POSIX_C_SOURCE 200809
-#elif _XOPEN_SOURCE - 0 >= 600
-#define __XSI_VISIBLE 600
-#undef _POSIX_C_SOURCE
-#define _POSIX_C_SOURCE 200112
-#elif _XOPEN_SOURCE - 0 >= 500
-#define __XSI_VISIBLE 500
-#undef _POSIX_C_SOURCE
-#define _POSIX_C_SOURCE 199506
-#endif
-#endif
-
-/*
- * Deal with all versions of POSIX. The ordering relative to the tests above is
- * important.
- */
-#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
-#define _POSIX_C_SOURCE 198808
-#endif
-#ifdef _POSIX_C_SOURCE
-#if _POSIX_C_SOURCE >= 200809
-#define __POSIX_VISIBLE 200809
-#define __ISO_C_VISIBLE 1999
-#elif _POSIX_C_SOURCE >= 200112
-#define __POSIX_VISIBLE 200112
-#define __ISO_C_VISIBLE 1999
-#elif _POSIX_C_SOURCE >= 199506
-#define __POSIX_VISIBLE 199506
-#define __ISO_C_VISIBLE 1990
-#elif _POSIX_C_SOURCE >= 199309
-#define __POSIX_VISIBLE 199309
-#define __ISO_C_VISIBLE 1990
-#elif _POSIX_C_SOURCE >= 199209
-#define __POSIX_VISIBLE 199209
-#define __ISO_C_VISIBLE 1990
-#elif _POSIX_C_SOURCE >= 199009
-#define __POSIX_VISIBLE 199009
-#define __ISO_C_VISIBLE 1990
-#else
-#define __POSIX_VISIBLE 198808
-#define __ISO_C_VISIBLE 0
-#endif /* _POSIX_C_SOURCE */
-#else
-/*-
- * Deal with _ANSI_SOURCE:
- * If it is defined, and no other compilation environment is explicitly
- * requested, then define our internal feature-test macros to zero. This
- * makes no difference to the preprocessor (undefined symbols in preprocessing
- * expressions are defined to have value zero), but makes it more convenient for
- * a test program to print out the values.
- *
- * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
- * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
- * environment (and in fact we will never get here).
- */
-#if defined(_ANSI_SOURCE) /* Hide almost everything. */
-#define __POSIX_VISIBLE 0
-#define __XSI_VISIBLE 0
-#define __BSD_VISIBLE 0
-#define __ISO_C_VISIBLE 1990
-#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
-#define __POSIX_VISIBLE 0
-#define __XSI_VISIBLE 0
-#define __BSD_VISIBLE 0
-#define __ISO_C_VISIBLE 1999
-#else /* Default environment: show everything. */
-#define __POSIX_VISIBLE 200809
-#define __XSI_VISIBLE 700
-#define __BSD_VISIBLE 1
-#define __ISO_C_VISIBLE 1999
-#endif
-#endif
-
-#ifndef __has_feature
-#define __has_feature(x) 0
-#endif
-#ifndef __has_include
-#define __has_include(x) 0
-#endif
-#ifndef __has_builtin
-#define __has_builtin(x) 0
-#endif
-
-#if defined(__mips) || defined(__powerpc64__) || defined(__arm__)
-#define __NO_TLS 1
-#endif
-
-#endif /* !_SYS_CDEFS_H_ */
diff --git a/include/lib/libc/sys/ctype.h b/include/lib/libc/sys/ctype.h
deleted file mode 100644
index f2758b7..0000000
--- a/include/lib/libc/sys/ctype.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * Copyright (c) 1982, 1988, 1991, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Portions copyright (c) 2009-2014, ARM Limited and Contributors.
- * All rights reserved.
- */
-
-#ifndef _SYS_CTYPE_H_
-#define _SYS_CTYPE_H_
-
-#define isspace(c) ((c) == ' ' || ((c) >= '\t' && (c) <= '\r'))
-#define isascii(c) (((c) & ~0x7f) == 0)
-#define isupper(c) ((c) >= 'A' && (c) <= 'Z')
-#define islower(c) ((c) >= 'a' && (c) <= 'z')
-#define isalpha(c) (isupper(c) || islower(c))
-#define isdigit(c) ((c) >= '0' && (c) <= '9')
-#define isxdigit(c) (isdigit(c) \
- || ((c) >= 'A' && (c) <= 'F') \
- || ((c) >= 'a' && (c) <= 'f'))
-#define isprint(c) ((c) >= ' ' && (c) <= '~')
-
-#define toupper(c) ((c) - 0x20 * (((c) >= 'a') && ((c) <= 'z')))
-#define tolower(c) ((c) + 0x20 * (((c) >= 'A') && ((c) <= 'Z')))
-
-#endif /* !_SYS_CTYPE_H_ */
diff --git a/include/lib/libc/sys/limits.h b/include/lib/libc/sys/limits.h
deleted file mode 100644
index c56a337..0000000
--- a/include/lib/libc/sys/limits.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*-
- * 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.
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SYS_LIMITS_H_
-#define _SYS_LIMITS_H_
-
-#include <sys/cdefs.h>
-#include <machine/_limits.h>
-
-#define CHAR_BIT __CHAR_BIT /* number of bits in a char */
-
-#define SCHAR_MAX __SCHAR_MAX /* max value for a signed char */
-#define SCHAR_MIN __SCHAR_MIN /* min value for a signed char */
-
-#define UCHAR_MAX __UCHAR_MAX /* max value for an unsigned char */
-
-#ifdef __CHAR_UNSIGNED__
-#define CHAR_MAX UCHAR_MAX /* max value for a char */
-#define CHAR_MIN 0 /* min value for a char */
-#else
-#define CHAR_MAX SCHAR_MAX
-#define CHAR_MIN SCHAR_MIN
-#endif
-
-#define USHRT_MAX __USHRT_MAX /* max value for an unsigned short */
-#define SHRT_MAX __SHRT_MAX /* max value for a short */
-#define SHRT_MIN __SHRT_MIN /* min value for a short */
-
-#define UINT_MAX __UINT_MAX /* max value for an unsigned int */
-#define INT_MAX __INT_MAX /* max value for an int */
-#define INT_MIN __INT_MIN /* min value for an int */
-
-#define ULONG_MAX __ULONG_MAX /* max for an unsigned long */
-#define LONG_MAX __LONG_MAX /* max for a long */
-#define LONG_MIN __LONG_MIN /* min for a long */
-
-#ifdef __LONG_LONG_SUPPORTED
-#define ULLONG_MAX __ULLONG_MAX /* max for an unsigned long long */
-#define LLONG_MAX __LLONG_MAX /* max for a long long */
-#define LLONG_MIN __LLONG_MIN /* min for a long long */
-#endif
-
-#if __POSIX_VISIBLE || __XSI_VISIBLE
-#define SSIZE_MAX __SSIZE_MAX /* max value for an ssize_t */
-#endif
-
-#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
-#define SIZE_T_MAX __SIZE_T_MAX /* max value for a size_t */
-
-#define OFF_MAX __OFF_MAX /* max value for an off_t */
-#define OFF_MIN __OFF_MIN /* min value for an off_t */
-#endif
-
-#if __BSD_VISIBLE
-#define GID_MAX UINT_MAX /* max value for a gid_t */
-#define UID_MAX UINT_MAX /* max value for a uid_t */
-
-#define UQUAD_MAX (__UQUAD_MAX) /* max value for a uquad_t */
-#define QUAD_MAX (__QUAD_MAX) /* max value for a quad_t */
-#define QUAD_MIN (__QUAD_MIN) /* min value for a quad_t */
-#endif
-
-#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200809
-#define LONG_BIT __LONG_BIT
-#define WORD_BIT __WORD_BIT
-#endif
-
-#if __POSIX_VISIBLE
-#define MQ_PRIO_MAX 64
-#endif
-
-#endif /* !_SYS_LIMITS_H_ */
diff --git a/include/lib/libc/sys/stdarg.h b/include/lib/libc/sys/stdarg.h
deleted file mode 100644
index c315dfc..0000000
--- a/include/lib/libc/sys/stdarg.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * Copyright (c) 2002 David E. O'Brien. 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.
- * 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 AUTHOR 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 AUTHOR 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$
- */
-
-#ifndef _MACHINE_STDARG_H_
-#define _MACHINE_STDARG_H_
-
-#include <sys/cdefs.h>
-#include <sys/_types.h>
-
-#ifndef _VA_LIST_DECLARED
-#define _VA_LIST_DECLARED
-typedef __va_list va_list;
-#endif
-
-#ifdef __GNUCLIKE_BUILTIN_STDARG
-
-#define va_start(ap, last) \
- __builtin_va_start((ap), (last))
-
-#define va_arg(ap, type) \
- __builtin_va_arg((ap), type)
-
-#define __va_copy(dest, src) \
- __builtin_va_copy((dest), (src))
-
-#if __ISO_C_VISIBLE >= 1999
-#define va_copy(dest, src) \
- __va_copy(dest, src)
-#endif
-
-#define va_end(ap) \
- __builtin_va_end(ap)
-
-#elif defined(lint)
-/* Provide a fake implementation for lint's benefit */
-#define __va_size(type) \
- (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
-#define va_start(ap, last) \
- ((ap) = (va_list)&(last) + __va_size(last))
-#define va_arg(ap, type) \
- (*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
-#define va_end(ap)
-
-#else
-#error this file needs to be ported to your compiler
-#endif
-
-#endif /* !_MACHINE_STDARG_H_ */
diff --git a/include/lib/libc/sys/stdint.h b/include/lib/libc/sys/stdint.h
deleted file mode 100644
index aa5ac81..0000000
--- a/include/lib/libc/sys/stdint.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
- * 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 AUTHOR 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 AUTHOR 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$
- */
-
-#ifndef _SYS_STDINT_H_
-#define _SYS_STDINT_H_
-
-#include <sys/cdefs.h>
-#include <sys/_types.h>
-
-#include <machine/_stdint.h>
-#include <sys/_stdint.h>
-
-typedef __int_least8_t int_least8_t;
-typedef __int_least16_t int_least16_t;
-typedef __int_least32_t int_least32_t;
-typedef __int_least64_t int_least64_t;
-
-typedef __uint_least8_t uint_least8_t;
-typedef __uint_least16_t uint_least16_t;
-typedef __uint_least32_t uint_least32_t;
-typedef __uint_least64_t uint_least64_t;
-
-typedef __int_fast8_t int_fast8_t;
-typedef __int_fast16_t int_fast16_t;
-typedef __int_fast32_t int_fast32_t;
-typedef __int_fast64_t int_fast64_t;
-
-typedef __uint_fast8_t uint_fast8_t;
-typedef __uint_fast16_t uint_fast16_t;
-typedef __uint_fast32_t uint_fast32_t;
-typedef __uint_fast64_t uint_fast64_t;
-
-#ifndef _INTMAX_T_DECLARED
-typedef __intmax_t intmax_t;
-#define _INTMAX_T_DECLARED
-#endif
-#ifndef _UINTMAX_T_DECLARED
-typedef __uintmax_t uintmax_t;
-#define _UINTMAX_T_DECLARED
-#endif
-
-/* GNU and Darwin define this and people seem to think it's portable */
-#if defined(UINTPTR_MAX) && defined(UINT64_MAX) && (UINTPTR_MAX == UINT64_MAX)
-#define __WORDSIZE 64
-#else
-#define __WORDSIZE 32
-#endif
-
-#endif /* !_SYS_STDINT_H_ */
diff --git a/include/lib/libc/sys/timespec.h b/include/lib/libc/sys/timespec.h
deleted file mode 100644
index 2505cef..0000000
--- a/include/lib/libc/sys/timespec.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * Copyright (c) 1982, 1986, 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.
- *
- * @(#)time.h 8.5 (Berkeley) 5/4/95
- * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp
- * $FreeBSD$
- */
-
-#ifndef _SYS_TIMESPEC_H_
-#define _SYS_TIMESPEC_H_
-
-#include <sys/cdefs.h>
-#include <sys/_timespec.h>
-
-#if __BSD_VISIBLE
-#define TIMEVAL_TO_TIMESPEC(tv, ts) \
- do { \
- (ts)->tv_sec = (tv)->tv_sec; \
- (ts)->tv_nsec = (tv)->tv_usec * 1000; \
- } while (0)
-#define TIMESPEC_TO_TIMEVAL(tv, ts) \
- do { \
- (tv)->tv_sec = (ts)->tv_sec; \
- (tv)->tv_usec = (ts)->tv_nsec / 1000; \
- } while (0)
-
-#endif /* __BSD_VISIBLE */
-
-/*
- * Structure defined by POSIX.1b to be like a itimerval, but with
- * timespecs. Used in the timer_*() system calls.
- */
-struct itimerspec {
- struct timespec it_interval;
- struct timespec it_value;
-};
-
-#endif /* _SYS_TIMESPEC_H_ */
diff --git a/include/lib/libc/sys/types.h b/include/lib/libc/sys/types.h
deleted file mode 100644
index ae2ea33..0000000
--- a/include/lib/libc/sys/types.h
+++ /dev/null
@@ -1,245 +0,0 @@
-/*-
- * Copyright (c) 1982, 1986, 1991, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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.
- *
- * @(#)types.h 8.6 (Berkeley) 2/19/95
- * $FreeBSD$
- */
-
-#ifndef _SYS_TYPES_H_
-#define _SYS_TYPES_H_
-
-#include <sys/cdefs.h>
-
-/* Machine type dependent parameters. */
-#include <sys/_types.h>
-
-#if __BSD_VISIBLE
-typedef unsigned char u_char;
-typedef unsigned short u_short;
-typedef unsigned int u_int;
-typedef unsigned long u_long;
-#ifndef _KERNEL
-typedef unsigned short ushort; /* Sys V compatibility */
-typedef unsigned int uint; /* Sys V compatibility */
-#endif
-#endif
-
-/*
- * XXX POSIX sized integrals that should appear only in <sys/stdint.h>.
- */
-#include <sys/_stdint.h>
-
-typedef __uint8_t u_int8_t; /* unsigned integrals (deprecated) */
-typedef __uint16_t u_int16_t;
-typedef __uint32_t u_int32_t;
-typedef __uint64_t u_int64_t;
-
-typedef __uint64_t u_quad_t; /* quads (deprecated) */
-typedef __int64_t quad_t;
-typedef quad_t *qaddr_t;
-
-typedef char *caddr_t; /* core address */
-typedef const char *c_caddr_t; /* core address, pointer to const */
-
-#ifndef _BLKSIZE_T_DECLARED
-typedef __blksize_t blksize_t;
-#define _BLKSIZE_T_DECLARED
-#endif
-
-typedef __cpuwhich_t cpuwhich_t;
-typedef __cpulevel_t cpulevel_t;
-typedef __cpusetid_t cpusetid_t;
-
-#ifndef _BLKCNT_T_DECLARED
-typedef __blkcnt_t blkcnt_t;
-#define _BLKCNT_T_DECLARED
-#endif
-
-#ifndef _CLOCK_T_DECLARED
-typedef __clock_t clock_t;
-#define _CLOCK_T_DECLARED
-#endif
-
-#ifndef _CLOCKID_T_DECLARED
-typedef __clockid_t clockid_t;
-#define _CLOCKID_T_DECLARED
-#endif
-
-typedef __critical_t critical_t; /* Critical section value */
-typedef __int64_t daddr_t; /* disk address */
-
-#ifndef _DEV_T_DECLARED
-typedef __dev_t dev_t; /* device number or struct cdev */
-#define _DEV_T_DECLARED
-#endif
-
-#ifndef _FFLAGS_T_DECLARED
-typedef __fflags_t fflags_t; /* file flags */
-#define _FFLAGS_T_DECLARED
-#endif
-
-typedef __fixpt_t fixpt_t; /* fixed point number */
-
-#ifndef _FSBLKCNT_T_DECLARED /* for statvfs() */
-typedef __fsblkcnt_t fsblkcnt_t;
-typedef __fsfilcnt_t fsfilcnt_t;
-#define _FSBLKCNT_T_DECLARED
-#endif
-
-#ifndef _GID_T_DECLARED
-typedef __gid_t gid_t; /* group id */
-#define _GID_T_DECLARED
-#endif
-
-#ifndef _IN_ADDR_T_DECLARED
-typedef __uint32_t in_addr_t; /* base type for internet address */
-#define _IN_ADDR_T_DECLARED
-#endif
-
-#ifndef _IN_PORT_T_DECLARED
-typedef __uint16_t in_port_t;
-#define _IN_PORT_T_DECLARED
-#endif
-
-#ifndef _ID_T_DECLARED
-typedef __id_t id_t; /* can hold a uid_t or pid_t */
-#define _ID_T_DECLARED
-#endif
-
-#ifndef _INO_T_DECLARED
-typedef __ino_t ino_t; /* inode number */
-#define _INO_T_DECLARED
-#endif
-
-#ifndef _KEY_T_DECLARED
-typedef __key_t key_t; /* IPC key (for Sys V IPC) */
-#define _KEY_T_DECLARED
-#endif
-
-#ifndef _LWPID_T_DECLARED
-typedef __lwpid_t lwpid_t; /* Thread ID (a.k.a. LWP) */
-#define _LWPID_T_DECLARED
-#endif
-
-#ifndef _MODE_T_DECLARED
-typedef __mode_t mode_t; /* permissions */
-#define _MODE_T_DECLARED
-#endif
-
-#ifndef _ACCMODE_T_DECLARED
-typedef __accmode_t accmode_t; /* access permissions */
-#define _ACCMODE_T_DECLARED
-#endif
-
-#ifndef _NLINK_T_DECLARED
-typedef __nlink_t nlink_t; /* link count */
-#define _NLINK_T_DECLARED
-#endif
-
-#ifndef _OFF_T_DECLARED
-typedef __off_t off_t; /* file offset */
-#define _OFF_T_DECLARED
-#endif
-
-#ifndef _PID_T_DECLARED
-typedef __pid_t pid_t; /* process id */
-#define _PID_T_DECLARED
-#endif
-
-typedef __register_t register_t;
-
-#ifndef _RLIM_T_DECLARED
-typedef __rlim_t rlim_t; /* resource limit */
-#define _RLIM_T_DECLARED
-#endif
-
-typedef __int64_t sbintime_t;
-
-typedef __segsz_t segsz_t; /* segment size (in pages) */
-
-#ifndef _SIZE_T_DECLARED
-typedef __size_t size_t;
-#define _SIZE_T_DECLARED
-#endif
-
-#ifndef _SSIZE_T_DECLARED
-typedef __ssize_t ssize_t;
-#define _SSIZE_T_DECLARED
-#endif
-
-#ifndef _SUSECONDS_T_DECLARED
-typedef __suseconds_t suseconds_t; /* microseconds (signed) */
-#define _SUSECONDS_T_DECLARED
-#endif
-
-#ifndef _TIME_T_DECLARED
-typedef __time_t time_t;
-#define _TIME_T_DECLARED
-#endif
-
-#ifndef _TIMER_T_DECLARED
-typedef __timer_t timer_t;
-#define _TIMER_T_DECLARED
-#endif
-
-#ifndef _MQD_T_DECLARED
-typedef __mqd_t mqd_t;
-#define _MQD_T_DECLARED
-#endif
-
-typedef __u_register_t u_register_t;
-
-#ifndef _UID_T_DECLARED
-typedef __uid_t uid_t; /* user id */
-#define _UID_T_DECLARED
-#endif
-
-#ifndef _USECONDS_T_DECLARED
-typedef __useconds_t useconds_t; /* microseconds (unsigned) */
-#define _USECONDS_T_DECLARED
-#endif
-
-#ifndef _CAP_RIGHTS_T_DECLARED
-#define _CAP_RIGHTS_T_DECLARED
-struct cap_rights;
-
-typedef struct cap_rights cap_rights_t;
-#endif
-
-typedef __vm_offset_t vm_offset_t;
-typedef __vm_ooffset_t vm_ooffset_t;
-typedef __vm_paddr_t vm_paddr_t;
-typedef __vm_pindex_t vm_pindex_t;
-typedef __vm_size_t vm_size_t;
-
-#endif /* !_SYS_TYPES_H_ */
diff --git a/include/lib/libc/time.h b/include/lib/libc/time.h
index 08200cf..71d3e7e 100644
--- a/include/lib/libc/time.h
+++ b/include/lib/libc/time.h
@@ -1,204 +1,20 @@
/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
+ * Copyright (c) 2012-2017 Roberto E. Vargas Caballero
*
- * 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.
- *
- * @(#)time.h 8.3 (Berkeley) 1/21/94
+ * SPDX-License-Identifier: BSD-3-Clause
*/
-
/*
- * $FreeBSD$
+ * Portions copyright (c) 2018, ARM Limited and Contributors.
+ * All rights reserved.
*/
-#ifndef _TIME_H_
-#define _TIME_H_
+#ifndef TIME_H
+#define TIME_H
-#include <sys/cdefs.h>
-#include <sys/_null.h>
-#include <sys/_types.h>
+#include <time_.h>
-#if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
-/*
- * Frequency of the clock ticks reported by times(). Deprecated - use
- * sysconf(_SC_CLK_TCK) instead. (Removed in 1003.1-2001.)
- */
-#define CLK_TCK 128
+#ifndef NULL
+#define NULL ((void *) 0)
#endif
-/* Frequency of the clock ticks reported by clock(). */
-#define CLOCKS_PER_SEC 128
-
-#ifndef _CLOCK_T_DECLARED
-typedef __clock_t clock_t;
-#define _CLOCK_T_DECLARED
-#endif
-
-#ifndef _TIME_T_DECLARED
-typedef __time_t time_t;
-#define _TIME_T_DECLARED
-#endif
-
-#ifndef _SIZE_T_DECLARED
-typedef __size_t size_t;
-#define _SIZE_T_DECLARED
-#endif
-
-#if __POSIX_VISIBLE >= 199309
-/*
- * New in POSIX 1003.1b-1993.
- */
-#ifndef _CLOCKID_T_DECLARED
-typedef __clockid_t clockid_t;
-#define _CLOCKID_T_DECLARED
-#endif
-
-#ifndef _TIMER_T_DECLARED
-typedef __timer_t timer_t;
-#define _TIMER_T_DECLARED
-#endif
-
-#include <sys/timespec.h>
-#endif /* __POSIX_VISIBLE >= 199309 */
-
-#if __POSIX_VISIBLE >= 200112
-#ifndef _PID_T_DECLARED
-typedef __pid_t pid_t;
-#define _PID_T_DECLARED
-#endif
-#endif
-
-/* These macros are also in sys/time.h. */
-#if !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112
-#define CLOCK_REALTIME 0
-#ifdef __BSD_VISIBLE
-#define CLOCK_VIRTUAL 1
-#define CLOCK_PROF 2
-#endif
-#define CLOCK_MONOTONIC 4
-#define CLOCK_UPTIME 5 /* FreeBSD-specific. */
-#define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */
-#define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */
-#define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */
-#define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */
-#define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */
-#define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */
-#define CLOCK_SECOND 13 /* FreeBSD-specific. */
-#define CLOCK_THREAD_CPUTIME_ID 14
-#define CLOCK_PROCESS_CPUTIME_ID 15
-#endif /* !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 */
-
-#if !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112
-#if __BSD_VISIBLE
-#define TIMER_RELTIME 0x0 /* relative timer */
-#endif
-#define TIMER_ABSTIME 0x1 /* absolute timer */
-#endif /* !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 */
-
-struct tm {
- int tm_sec; /* seconds after the minute [0-60] */
- int tm_min; /* minutes after the hour [0-59] */
- int tm_hour; /* hours since midnight [0-23] */
- int tm_mday; /* day of the month [1-31] */
- int tm_mon; /* months since January [0-11] */
- int tm_year; /* years since 1900 */
- int tm_wday; /* days since Sunday [0-6] */
- int tm_yday; /* days since January 1 [0-365] */
- int tm_isdst; /* Daylight Savings Time flag */
- long tm_gmtoff; /* offset from UTC in seconds */
- char *tm_zone; /* timezone abbreviation */
-};
-
-#if __POSIX_VISIBLE
-extern char *tzname[];
-#endif
-
-__BEGIN_DECLS
-char *asctime(const struct tm *);
-clock_t clock(void);
-char *ctime(const time_t *);
-double difftime(time_t, time_t);
-/* XXX missing: getdate() */
-struct tm *gmtime(const time_t *);
-struct tm *localtime(const time_t *);
-time_t mktime(struct tm *);
-size_t strftime(char *__restrict, size_t, const char *__restrict,
- const struct tm *__restrict);
-time_t time(time_t *);
-#if __POSIX_VISIBLE >= 200112
-struct sigevent;
-int timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict);
-int timer_delete(timer_t);
-int timer_gettime(timer_t, struct itimerspec *);
-int timer_getoverrun(timer_t);
-int timer_settime(timer_t, int, const struct itimerspec *__restrict,
- struct itimerspec *__restrict);
-#endif
-#if __POSIX_VISIBLE
-void tzset(void);
-#endif
-
-#if __POSIX_VISIBLE >= 199309
-int clock_getres(clockid_t, struct timespec *);
-int clock_gettime(clockid_t, struct timespec *);
-int clock_settime(clockid_t, const struct timespec *);
-/* XXX missing: clock_nanosleep() */
-int nanosleep(const struct timespec *, struct timespec *);
-#endif /* __POSIX_VISIBLE >= 199309 */
-
-#if __POSIX_VISIBLE >= 200112
-int clock_getcpuclockid(pid_t, clockid_t *);
-#endif
-
-#if __POSIX_VISIBLE >= 199506
-char *asctime_r(const struct tm *, char *);
-char *ctime_r(const time_t *, char *);
-struct tm *gmtime_r(const time_t *, struct tm *);
-struct tm *localtime_r(const time_t *, struct tm *);
-#endif
-
-#if __XSI_VISIBLE
-char *strptime(const char *__restrict, const char *__restrict,
- struct tm *__restrict);
-#endif
-
-#if __BSD_VISIBLE
-char *timezone(int, int); /* XXX XSI conflict */
-void tzsetwall(void);
-time_t timelocal(struct tm * const);
-time_t timegm(struct tm * const);
-#endif /* __BSD_VISIBLE */
-
-#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
-#include <xlocale/_time.h>
-#endif
-__END_DECLS
-
-#endif /* !_TIME_H_ */
+#endif /* TIME_H */
diff --git a/include/lib/libc/xlocale/_strings.h b/include/lib/libc/xlocale/_strings.h
deleted file mode 100644
index da1cff3..0000000
--- a/include/lib/libc/xlocale/_strings.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * Copyright (c) 2011, 2012 The FreeBSD Foundation
- * 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 AUTHOR 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 AUTHOR 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$
- */
-
-#ifndef _LOCALE_T_DEFINED
-#define _LOCALE_T_DEFINED
-typedef struct _xlocale *locale_t;
-#endif
-
-/*
- * This file is included from both strings.h and xlocale.h. We need to expose
- * the declarations unconditionally if we are included from xlocale.h, but only
- * if we are in POSIX2008 mode if included from string.h.
- */
-
-#ifndef _XLOCALE_STRINGS1_H
-#define _XLOCALE_STRINGS1_H
-
-/*
- * POSIX2008 functions
- */
-int strcasecmp_l(const char *, const char *, locale_t);
-int strncasecmp_l(const char *, const char *, size_t, locale_t);
-#endif /* _XLOCALE_STRINGS1_H */
diff --git a/include/lib/libc/xlocale/_time.h b/include/lib/libc/xlocale/_time.h
deleted file mode 100644
index 6da49a4..0000000
--- a/include/lib/libc/xlocale/_time.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * Copyright (c) 2011, 2012 The FreeBSD Foundation
- * All rights reserved.
- *
- * This software was developed by David Chisnall under sponsorship from
- * the FreeBSD Foundation.
- *
- * 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 AUTHOR 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 AUTHOR 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$
- */
-
-#ifndef _LOCALE_T_DEFINED
-#define _LOCALE_T_DEFINED
-typedef struct _xlocale *locale_t;
-#endif
-
-/*
- * This file is included from both locale.h and xlocale.h. We need to expose
- * the declarations unconditionally if we are included from xlocale.h, but only
- * if we are in POSIX2008 mode if included from locale.h.
- */
-#ifndef _XLOCALE_LOCALE1_H
-#define _XLOCALE_LOCALE1_H
-
-size_t strftime_l(char *__restrict, size_t, const char *__restrict,
- const struct tm *__restrict, locale_t) __strftimelike(3, 0);
-
-#endif /* _XLOCALE_LOCALE1_H */
-
-#ifdef _XLOCALE_H_
-#ifndef _XLOCALE_LOCALE2_H
-#define _XLOCALE_LOCALE2_H
-
-char *strptime_l(const char *__restrict, const char *__restrict,
- struct tm *__restrict, locale_t);
-
-#endif /* _XLOCALE_LOCALE2_H */
-#endif /* _XLOCALE_H_ */
diff --git a/include/lib/psci/psci.h b/include/lib/psci/psci.h
index 71d605d..fa0da9f 100644
--- a/include/lib/psci/psci.h
+++ b/include/lib/psci/psci.h
@@ -171,7 +171,6 @@
#ifndef __ASSEMBLY__
#include <stdint.h>
-#include <types.h>
/* Function to help build the psci capabilities bitfield */
diff --git a/include/lib/psci/psci_lib.h b/include/lib/psci/psci_lib.h
index 5b30f55..134cad9 100644
--- a/include/lib/psci/psci_lib.h
+++ b/include/lib/psci/psci_lib.h
@@ -10,7 +10,8 @@
#include <ep_info.h>
#ifndef __ASSEMBLY__
-#include <types.h>
+#include <cdefs.h>
+#include <stdint.h>
/*******************************************************************************
* Optional structure populated by the Secure Payload Dispatcher to be given a
diff --git a/include/lib/spinlock.h b/include/lib/spinlock.h
index a7b0d39..8aec707 100644
--- a/include/lib/spinlock.h
+++ b/include/lib/spinlock.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -9,7 +9,7 @@
#ifndef __ASSEMBLY__
-#include <types.h>
+#include <stdint.h>
typedef struct spinlock {
volatile uint32_t lock;
diff --git a/include/lib/utils.h b/include/lib/utils.h
index 5f13e99..09ec8d9 100644
--- a/include/lib/utils.h
+++ b/include/lib/utils.h
@@ -17,7 +17,7 @@
*/
#if !(defined(__LINKER__) || defined(__ASSEMBLY__))
-#include <types.h>
+#include <stdint.h>
typedef struct mem_region {
uintptr_t base;
diff --git a/include/lib/xlat_tables/xlat_mmu_helpers.h b/include/lib/xlat_tables/xlat_mmu_helpers.h
index e1d0227..ab491e3 100644
--- a/include/lib/xlat_tables/xlat_mmu_helpers.h
+++ b/include/lib/xlat_tables/xlat_mmu_helpers.h
@@ -54,7 +54,7 @@
#include <stdbool.h>
#include <stdint.h>
-#include <sys/types.h>
+#include <string.h>
/*
* Return the values that the MMU configuration registers must contain for the
diff --git a/include/plat/arm/css/common/css_pm.h b/include/plat/arm/css/common/css_pm.h
index e834fff..a243671 100644
--- a/include/plat/arm/css/common/css_pm.h
+++ b/include/plat/arm/css/common/css_pm.h
@@ -9,7 +9,7 @@
#include <cdefs.h>
#include <psci.h>
-#include <types.h>
+#include <stdint.h>
/* System power domain at level 2, as currently implemented by CSS platforms */
#define CSS_SYSTEM_PWR_DMN_LVL ARM_PWR_LVL2
diff --git a/include/plat/common/common_def.h b/include/plat/common/common_def.h
index 827d416..e66af78 100644
--- a/include/plat/common/common_def.h
+++ b/include/plat/common/common_def.h
@@ -8,6 +8,7 @@
#include <bl_common.h>
#include <platform_def.h>
+#include <xlat_tables_defs.h>
/******************************************************************************
* Required platform porting definitions that are expected to be common to
diff --git a/include/plat/common/platform.h b/include/plat/common/platform.h
index 12eac60..dae9589 100644
--- a/include/plat/common/platform.h
+++ b/include/plat/common/platform.h
@@ -9,8 +9,6 @@
#include <psci.h>
#include <stdint.h>
-#include <types.h>
-
/*******************************************************************************
* Forward declarations
diff --git a/include/services/sdei.h b/include/services/sdei.h
index 79d1d06..4d0fd3f 100644
--- a/include/services/sdei.h
+++ b/include/services/sdei.h
@@ -4,61 +4,56 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __SDEI_H__
-#define __SDEI_H__
+#ifndef SDEI_H
+#define SDEI_H
#include <spinlock.h>
#include <utils_def.h>
/* Range 0xC4000020 - 0xC400003F reserved for SDE 64bit smc calls */
-#define SDEI_VERSION 0xC4000020
-#define SDEI_EVENT_REGISTER 0xC4000021
-#define SDEI_EVENT_ENABLE 0xC4000022
-#define SDEI_EVENT_DISABLE 0xC4000023
-#define SDEI_EVENT_CONTEXT 0xC4000024
-#define SDEI_EVENT_COMPLETE 0xC4000025
-#define SDEI_EVENT_COMPLETE_AND_RESUME 0xC4000026
+#define SDEI_VERSION 0xC4000020U
+#define SDEI_EVENT_REGISTER 0xC4000021U
+#define SDEI_EVENT_ENABLE 0xC4000022U
+#define SDEI_EVENT_DISABLE 0xC4000023U
+#define SDEI_EVENT_CONTEXT 0xC4000024U
+#define SDEI_EVENT_COMPLETE 0xC4000025U
+#define SDEI_EVENT_COMPLETE_AND_RESUME 0xC4000026U
-#define SDEI_EVENT_UNREGISTER 0xC4000027
-#define SDEI_EVENT_STATUS 0xC4000028
-#define SDEI_EVENT_GET_INFO 0xC4000029
-#define SDEI_EVENT_ROUTING_SET 0xC400002A
-#define SDEI_PE_MASK 0xC400002B
-#define SDEI_PE_UNMASK 0xC400002C
+#define SDEI_EVENT_UNREGISTER 0xC4000027U
+#define SDEI_EVENT_STATUS 0xC4000028U
+#define SDEI_EVENT_GET_INFO 0xC4000029U
+#define SDEI_EVENT_ROUTING_SET 0xC400002AU
+#define SDEI_PE_MASK 0xC400002BU
+#define SDEI_PE_UNMASK 0xC400002CU
-#define SDEI_INTERRUPT_BIND 0xC400002D
-#define SDEI_INTERRUPT_RELEASE 0xC400002E
-#define SDEI_EVENT_SIGNAL 0xC400002F
-#define SDEI_FEATURES 0xC4000030
-#define SDEI_PRIVATE_RESET 0xC4000031
-#define SDEI_SHARED_RESET 0xC4000032
+#define SDEI_INTERRUPT_BIND 0xC400002DU
+#define SDEI_INTERRUPT_RELEASE 0xC400002EU
+#define SDEI_EVENT_SIGNAL 0xC400002FU
+#define SDEI_FEATURES 0xC4000030U
+#define SDEI_PRIVATE_RESET 0xC4000031U
+#define SDEI_SHARED_RESET 0xC4000032U
/* SDEI_EVENT_REGISTER flags */
-#define SDEI_REGF_RM_ANY 0
-#define SDEI_REGF_RM_PE 1
+#define SDEI_REGF_RM_ANY 0ULL
+#define SDEI_REGF_RM_PE 1ULL
/* SDEI_EVENT_COMPLETE status flags */
-#define SDEI_EV_HANDLED 0
-#define SDEI_EV_FAILED 1
-
-/* SDE event status values in bit position */
-#define SDEI_STATF_REGISTERED 0
-#define SDEI_STATF_ENABLED 1
-#define SDEI_STATF_RUNNING 2
+#define SDEI_EV_HANDLED 0U
+#define SDEI_EV_FAILED 1U
/* Internal: SDEI flag bit positions */
-#define _SDEI_MAPF_DYNAMIC_SHIFT 1
-#define _SDEI_MAPF_BOUND_SHIFT 2
-#define _SDEI_MAPF_SIGNALABLE_SHIFT 3
-#define _SDEI_MAPF_PRIVATE_SHIFT 4
-#define _SDEI_MAPF_CRITICAL_SHIFT 5
-#define _SDEI_MAPF_EXPLICIT_SHIFT 6
+#define SDEI_MAPF_DYNAMIC_SHIFT_ 1U
+#define SDEI_MAPF_BOUND_SHIFT_ 2U
+#define SDEI_MAPF_SIGNALABLE_SHIFT_ 3U
+#define SDEI_MAPF_PRIVATE_SHIFT_ 4U
+#define SDEI_MAPF_CRITICAL_SHIFT_ 5U
+#define SDEI_MAPF_EXPLICIT_SHIFT_ 6U
/* SDEI event 0 */
#define SDEI_EVENT_0 0
/* Placeholder interrupt for dynamic mapping */
-#define SDEI_DYN_IRQ 0
+#define SDEI_DYN_IRQ 0U
/* SDEI flags */
@@ -80,20 +75,20 @@
*
* See also the is_map_bound() macro.
*/
-#define SDEI_MAPF_DYNAMIC BIT(_SDEI_MAPF_DYNAMIC_SHIFT)
-#define SDEI_MAPF_BOUND BIT(_SDEI_MAPF_BOUND_SHIFT)
-#define SDEI_MAPF_EXPLICIT BIT(_SDEI_MAPF_EXPLICIT_SHIFT)
+#define SDEI_MAPF_DYNAMIC BIT(SDEI_MAPF_DYNAMIC_SHIFT_)
+#define SDEI_MAPF_BOUND BIT(SDEI_MAPF_BOUND_SHIFT_)
+#define SDEI_MAPF_EXPLICIT BIT(SDEI_MAPF_EXPLICIT_SHIFT_)
-#define SDEI_MAPF_SIGNALABLE BIT(_SDEI_MAPF_SIGNALABLE_SHIFT)
-#define SDEI_MAPF_PRIVATE BIT(_SDEI_MAPF_PRIVATE_SHIFT)
+#define SDEI_MAPF_SIGNALABLE BIT(SDEI_MAPF_SIGNALABLE_SHIFT_)
+#define SDEI_MAPF_PRIVATE BIT(SDEI_MAPF_PRIVATE_SHIFT_)
#define SDEI_MAPF_NORMAL 0
-#define SDEI_MAPF_CRITICAL BIT(_SDEI_MAPF_CRITICAL_SHIFT)
+#define SDEI_MAPF_CRITICAL BIT(SDEI_MAPF_CRITICAL_SHIFT_)
/* Indices of private and shared mappings */
-#define _SDEI_MAP_IDX_PRIV 0
-#define _SDEI_MAP_IDX_SHRD 1
-#define _SDEI_MAP_IDX_MAX 2
+#define SDEI_MAP_IDX_PRIV_ 0U
+#define SDEI_MAP_IDX_SHRD_ 1U
+#define SDEI_MAP_IDX_MAX_ 2U
/* The macros below are used to identify SDEI calls from the SMC function ID */
#define SDEI_FID_MASK U(0xffe0)
@@ -104,22 +99,22 @@
#define SDEI_EVENT_MAP(_event, _intr, _flags) \
{ \
- .ev_num = _event, \
- .intr = _intr, \
- .map_flags = _flags \
+ .ev_num = (_event), \
+ .intr = (_intr), \
+ .map_flags = (_flags) \
}
#define SDEI_SHARED_EVENT(_event, _intr, _flags) \
SDEI_EVENT_MAP(_event, _intr, _flags)
#define SDEI_PRIVATE_EVENT(_event, _intr, _flags) \
- SDEI_EVENT_MAP(_event, _intr, _flags | SDEI_MAPF_PRIVATE)
+ SDEI_EVENT_MAP(_event, _intr, (_flags) | SDEI_MAPF_PRIVATE)
#define SDEI_DEFINE_EVENT_0(_intr) \
- SDEI_PRIVATE_EVENT(SDEI_EVENT_0, _intr, SDEI_MAPF_SIGNALABLE)
+ SDEI_PRIVATE_EVENT(SDEI_EVENT_0, (_intr), SDEI_MAPF_SIGNALABLE)
#define SDEI_EXPLICIT_EVENT(_event, _pri) \
- SDEI_EVENT_MAP(_event, 0, _pri | SDEI_MAPF_EXPLICIT | SDEI_MAPF_PRIVATE)
+ SDEI_EVENT_MAP((_event), 0, (_pri) | SDEI_MAPF_EXPLICIT | SDEI_MAPF_PRIVATE)
/*
* Declare shared and private entries for each core. Also declare a global
@@ -133,12 +128,12 @@
[PLATFORM_CORE_COUNT * ARRAY_SIZE(_private)]; \
sdei_entry_t sdei_shared_event_table[ARRAY_SIZE(_shared)]; \
const sdei_mapping_t sdei_global_mappings[] = { \
- [_SDEI_MAP_IDX_PRIV] = { \
- .map = _private, \
+ [SDEI_MAP_IDX_PRIV_] = { \
+ .map = (_private), \
.num_maps = ARRAY_SIZE(_private) \
}, \
- [_SDEI_MAP_IDX_SHRD] = { \
- .map = _shared, \
+ [SDEI_MAP_IDX_SHRD_] = { \
+ .map = (_shared), \
.num_maps = ARRAY_SIZE(_shared) \
}, \
}
@@ -185,4 +180,4 @@
/* Public API to dispatch an event to Normal world */
int sdei_dispatch_event(int ev_num);
-#endif /* __SDEI_H__ */
+#endif /* SDEI_H */
diff --git a/include/services/secure_partition.h b/include/services/secure_partition.h
index d4aff1c..8b0adc8 100644
--- a/include/services/secure_partition.h
+++ b/include/services/secure_partition.h
@@ -7,7 +7,7 @@
#ifndef __SECURE_PARTITION_H__
#define __SECURE_PARTITION_H__
-#include <types.h>
+#include <stdint.h>
#include <utils_def.h>
/*
diff --git a/lib/aarch32/armclang_printf.S b/lib/aarch32/armclang_printf.S
new file mode 100644
index 0000000..2b87bf7
--- /dev/null
+++ b/lib/aarch32/armclang_printf.S
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <asm_macros.S>
+
+/* Symbols needed by armclang */
+
+ .globl __0printf
+ .globl __1printf
+ .globl __2printf
+
+func __0printf
+__1printf:
+__2printf:
+ b printf
+endfunc __0printf
diff --git a/lib/aarch64/armclang_printf.S b/lib/aarch64/armclang_printf.S
new file mode 100644
index 0000000..2b87bf7
--- /dev/null
+++ b/lib/aarch64/armclang_printf.S
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <asm_macros.S>
+
+/* Symbols needed by armclang */
+
+ .globl __0printf
+ .globl __1printf
+ .globl __2printf
+
+func __0printf
+__1printf:
+__2printf:
+ b printf
+endfunc __0printf
diff --git a/lib/compiler-rt/builtins/int_lib.h b/lib/compiler-rt/builtins/int_lib.h
index 57dfc41..787777a 100644
--- a/lib/compiler-rt/builtins/int_lib.h
+++ b/lib/compiler-rt/builtins/int_lib.h
@@ -14,7 +14,7 @@
*/
/*
- * Portions copyright (c) 2017, ARM Limited and Contributors.
+ * Portions copyright (c) 2017-2018, ARM Limited and Contributors.
* All rights reserved.
*/
@@ -63,9 +63,8 @@
* Kernel and boot environment can't use normal headers,
* so use the equivalent system headers.
*/
-# include <sys/limits.h>
-# include <sys/stdint.h>
-# include <sys/types.h>
+# include <limits.h>
+# include <stdint.h>
/* Include the commonly used internal type definitions. */
#include "int_types.h"
diff --git a/lib/cpus/aarch64/cortex_a55.S b/lib/cpus/aarch64/cortex_a55.S
index 741c773..4e9bd9f 100644
--- a/lib/cpus/aarch64/cortex_a55.S
+++ b/lib/cpus/aarch64/cortex_a55.S
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -11,6 +11,14 @@
#include <cpu_macros.S>
#include <plat_macros.S>
+func cortex_a55_reset_func
+ mov x19, x30
+#if ERRATA_DSU_936184
+ bl errata_dsu_936184_wa
+#endif
+ ret x19
+endfunc cortex_a55_reset_func
+
/* ---------------------------------------------
* HW will do the cache maintenance while powering down
* ---------------------------------------------
@@ -27,6 +35,26 @@
ret
endfunc cortex_a55_core_pwr_dwn
+#if REPORT_ERRATA
+/*
+ * Errata printing function for Cortex A55. Must follow AAPCS & can use stack.
+ */
+func cortex_a55_errata_report
+ stp x8, x30, [sp, #-16]!
+ bl cpu_get_rev_var
+ mov x8, x0
+
+ /*
+ * Report all errata. The revision variant information is at x8, where
+ * "report_errata" is expecting it and it doesn't corrupt it.
+ */
+ report_errata ERRATA_DSU_936184, cortex_a55, dsu_936184
+
+ ldp x8, x30, [sp], #16
+ ret
+endfunc cortex_a55_errata_report
+#endif
+
/* ---------------------------------------------
* This function provides cortex_a55 specific
* register information for crash reporting.
@@ -47,5 +75,5 @@
endfunc cortex_a55_cpu_reg_dump
declare_cpu_ops cortex_a55, CORTEX_A55_MIDR, \
- CPU_NO_RESET_FUNC, \
+ cortex_a55_reset_func, \
cortex_a55_core_pwr_dwn
diff --git a/lib/cpus/aarch64/cortex_a75.S b/lib/cpus/aarch64/cortex_a75.S
index 73f566f..e121b7d 100644
--- a/lib/cpus/aarch64/cortex_a75.S
+++ b/lib/cpus/aarch64/cortex_a75.S
@@ -11,6 +11,7 @@
#include <cpu_macros.S>
func cortex_a75_reset_func
+ mov x19, x30
#if IMAGE_BL31 && WORKAROUND_CVE_2017_5715
cpu_check_csv2 x0, 1f
adr x0, wa_cve_2017_5715_bpiall_vbar
@@ -26,6 +27,10 @@
isb
#endif
+#if ERRATA_DSU_936184
+ bl errata_dsu_936184_wa
+#endif
+
#if ENABLE_AMU
/* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
mrs x0, actlr_el3
@@ -49,7 +54,7 @@
msr CPUAMCNTENSET_EL0, x0
isb
#endif
- ret
+ ret x19
endfunc cortex_a75_reset_func
func check_errata_cve_2017_5715
@@ -106,6 +111,7 @@
*/
report_errata WORKAROUND_CVE_2017_5715, cortex_a75, cve_2017_5715
report_errata WORKAROUND_CVE_2018_3639, cortex_a75, cve_2018_3639
+ report_errata ERRATA_DSU_936184, cortex_a75, dsu_936184
ldp x8, x30, [sp], #16
ret
diff --git a/lib/cpus/aarch64/cortex_a76.S b/lib/cpus/aarch64/cortex_a76.S
index 51d0b15..1697c55 100644
--- a/lib/cpus/aarch64/cortex_a76.S
+++ b/lib/cpus/aarch64/cortex_a76.S
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -207,6 +207,7 @@
endfunc cortex_a76_disable_wa_cve_2018_3639
func cortex_a76_reset_func
+ mov x19, x30
#if WORKAROUND_CVE_2018_3639
mrs x0, CORTEX_A76_CPUACTLR2_EL1
orr x0, x0, #CORTEX_A76_CPUACTLR2_EL1_DISABLE_LOAD_PASS_STORE
@@ -224,7 +225,11 @@
msr vbar_el3, x0
isb
#endif
- ret
+
+#if ERRATA_DSU_936184
+ bl errata_dsu_936184_wa
+#endif
+ ret x19
endfunc cortex_a76_reset_func
/* ---------------------------------------------
@@ -258,6 +263,7 @@
* checking functions of each errata.
*/
report_errata WORKAROUND_CVE_2018_3639, cortex_a76, cve_2018_3639
+ report_errata ERRATA_DSU_936184, cortex_a76, dsu_936184
ldp x8, x30, [sp], #16
ret
diff --git a/lib/cpus/aarch64/denver.S b/lib/cpus/aarch64/denver.S
index f04dbd6..a981d02 100644
--- a/lib/cpus/aarch64/denver.S
+++ b/lib/cpus/aarch64/denver.S
@@ -189,6 +189,25 @@
ret
endfunc denver_disable_dco
+func check_errata_cve_2017_5715
+ mov x0, #ERRATA_MISSING
+#if WORKAROUND_CVE_2017_5715
+ /*
+ * Check if the CPU supports the special instruction
+ * required to flush the indirect branch predictor and
+ * RSB. Support for this operation can be determined by
+ * comparing bits 19:16 of ID_AFR0_EL1 with 0b0001.
+ */
+ mrs x1, id_afr0_el1
+ mov x2, #0x10000
+ and x1, x1, x2
+ cbz x1, 1f
+ mov x0, #ERRATA_APPLIES
+1:
+#endif
+ ret
+endfunc check_errata_cve_2017_5715
+
/* -------------------------------------------------
* The CPU Ops reset function for Denver.
* -------------------------------------------------
@@ -248,6 +267,27 @@
ret
endfunc denver_cluster_pwr_dwn
+#if REPORT_ERRATA
+ /*
+ * Errata printing function for Denver. Must follow AAPCS.
+ */
+func denver_errata_report
+ stp x8, x30, [sp, #-16]!
+
+ bl cpu_get_rev_var
+ mov x8, x0
+
+ /*
+ * Report all errata. The revision-variant information is passed to
+ * checking functions of each errata.
+ */
+ report_errata WORKAROUND_CVE_2017_5715, denver, cve_2017_5715
+
+ ldp x8, x30, [sp], #16
+ ret
+endfunc denver_errata_report
+#endif
+
/* ---------------------------------------------
* This function provides Denver specific
* register information for crash reporting.
@@ -267,27 +307,37 @@
ret
endfunc denver_cpu_reg_dump
-declare_cpu_ops denver, DENVER_MIDR_PN0, \
+declare_cpu_ops_wa denver, DENVER_MIDR_PN0, \
denver_reset_func, \
+ check_errata_cve_2017_5715, \
+ CPU_NO_EXTRA2_FUNC, \
denver_core_pwr_dwn, \
denver_cluster_pwr_dwn
-declare_cpu_ops denver, DENVER_MIDR_PN1, \
+declare_cpu_ops_wa denver, DENVER_MIDR_PN1, \
denver_reset_func, \
+ check_errata_cve_2017_5715, \
+ CPU_NO_EXTRA2_FUNC, \
denver_core_pwr_dwn, \
denver_cluster_pwr_dwn
-declare_cpu_ops denver, DENVER_MIDR_PN2, \
+declare_cpu_ops_wa denver, DENVER_MIDR_PN2, \
denver_reset_func, \
+ check_errata_cve_2017_5715, \
+ CPU_NO_EXTRA2_FUNC, \
denver_core_pwr_dwn, \
denver_cluster_pwr_dwn
-declare_cpu_ops denver, DENVER_MIDR_PN3, \
+declare_cpu_ops_wa denver, DENVER_MIDR_PN3, \
denver_reset_func, \
+ check_errata_cve_2017_5715, \
+ CPU_NO_EXTRA2_FUNC, \
denver_core_pwr_dwn, \
denver_cluster_pwr_dwn
-declare_cpu_ops denver, DENVER_MIDR_PN4, \
+declare_cpu_ops_wa denver, DENVER_MIDR_PN4, \
denver_reset_func, \
+ check_errata_cve_2017_5715, \
+ CPU_NO_EXTRA2_FUNC, \
denver_core_pwr_dwn, \
denver_cluster_pwr_dwn
diff --git a/lib/cpus/aarch64/dsu_helpers.S b/lib/cpus/aarch64/dsu_helpers.S
new file mode 100644
index 0000000..293ed24
--- /dev/null
+++ b/lib/cpus/aarch64/dsu_helpers.S
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <asm_macros.S>
+#include <dsu_def.h>
+#include <errata_report.h>
+
+/*
+ * DSU erratum 936184
+ * Check the DSU variant, revision and configuration to determine if the
+ * erratum applies. This erratum was fixed in r2p0.
+ *
+ * This function is called from both assembly and C environment. So it
+ * follows AAPCS.
+ *
+ * Clobbers: x0-x3
+ */
+ .globl check_errata_dsu_936184
+ .globl errata_dsu_936184_wa
+
+func check_errata_dsu_936184
+ mov x2, #ERRATA_NOT_APPLIES
+ mov x3, #ERRATA_APPLIES
+
+ /* Erratum applies only if ACP interface is present in DSU */
+ mov x0, x2
+ mrs x1, CLUSTERCFR_EL1
+ ubfx x1, x1, #CLUSTERCFR_ACP_SHIFT, #1
+ cbz x1, 1f
+
+ /* If ACP is present, check if DSU is older than r2p0 */
+ mrs x1, CLUSTERIDR_EL1
+
+ /* DSU variant and revision bitfields in CLUSTERIDR are adjacent */
+ ubfx x0, x1, #CLUSTERIDR_REV_SHIFT,\
+ #(CLUSTERIDR_REV_BITS + CLUSTERIDR_VAR_BITS)
+ mov x1, #(0x2 << CLUSTERIDR_REV_BITS)
+ cmp x0, x1
+ csel x0, x2, x3, hs
+1:
+ ret
+endfunc check_errata_dsu_936184
+
+func errata_dsu_936184_wa
+ mov x20, x30
+ bl check_errata_dsu_936184
+ cbz x0, 1f
+
+ /* If erratum applies, we set a mask to a DSU control register */
+ mrs x0, CLUSTERACTLR_EL1
+ ldr x1, =DSU_ERRATA_936184_MASK
+ orr x0, x0, x1
+ msr CLUSTERACTLR_EL1, x0
+ isb
+1:
+ ret x20
+endfunc errata_dsu_936184_wa
diff --git a/lib/cpus/cpu-ops.mk b/lib/cpus/cpu-ops.mk
index 456e3e5..40a8ac7 100644
--- a/lib/cpus/cpu-ops.mk
+++ b/lib/cpus/cpu-ops.mk
@@ -123,6 +123,11 @@
# only to r0p0 and r1p0 of the Ares cpu.
ERRATA_ARES_1043202 ?=1
+# Flag to apply DSU erratum 936184. This erratum applies to DSUs containing
+# the ACP interface and revision < r2p0. Applying the workaround results in
+# higher DSU power consumption on idle.
+ERRATA_DSU_936184 ?=0
+
# Process ERRATA_A53_826319 flag
$(eval $(call assert_boolean,ERRATA_A53_826319))
$(eval $(call add_define,ERRATA_A53_826319))
@@ -187,6 +192,10 @@
$(eval $(call assert_boolean,ERRATA_ARES_1043202))
$(eval $(call add_define,ERRATA_ARES_1043202))
+# Process ERRATA_DSU_936184 flag
+$(eval $(call assert_boolean,ERRATA_DSU_936184))
+$(eval $(call add_define,ERRATA_DSU_936184))
+
# Errata build flags
ifneq (${ERRATA_A53_843419},0)
TF_LDFLAGS_aarch64 += --fix-cortex-a53-843419
diff --git a/lib/el3_runtime/aarch64/context_mgmt.c b/lib/el3_runtime/aarch64/context_mgmt.c
index f389368..2812bda 100644
--- a/lib/el3_runtime/aarch64/context_mgmt.c
+++ b/lib/el3_runtime/aarch64/context_mgmt.c
@@ -12,6 +12,7 @@
#include <context.h>
#include <context_mgmt.h>
#include <interrupt_mgmt.h>
+#include <mpam.h>
#include <platform.h>
#include <platform_def.h>
#include <pubsub_events.h>
@@ -244,6 +245,10 @@
#if ENABLE_SVE_FOR_NS
sve_enable(el2_unused);
#endif
+
+#if ENABLE_MPAM_FOR_LOWER_ELS
+ mpam_enable(el2_unused);
+#endif
#endif
}
diff --git a/lib/extensions/mpam/mpam.c b/lib/extensions/mpam/mpam.c
new file mode 100644
index 0000000..e628827
--- /dev/null
+++ b/lib/extensions/mpam/mpam.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <arch.h>
+#include <arch_helpers.h>
+#include <mpam.h>
+#include <stdbool.h>
+
+bool mpam_supported(void)
+{
+ uint64_t features = read_id_aa64dfr0_el1() >> ID_AA64PFR0_MPAM_SHIFT;
+
+ return ((features & ID_AA64PFR0_MPAM_MASK) != 0U);
+}
+
+void mpam_enable(int el2_unused)
+{
+ if (!mpam_supported())
+ return;
+
+ /*
+ * Enable MPAM, and disable trapping to EL3 when lower ELs access their
+ * own MPAM registers.
+ */
+ write_mpam3_el3(MPAM3_EL3_MPAMEN_BIT);
+
+ /*
+ * If EL2 is implemented but unused, disable trapping to EL2 when lower
+ * ELs access their own MPAM registers.
+ */
+ if (el2_unused != 0) {
+ write_mpam2_el2(0);
+
+ if ((read_mpamidr_el1() & MPAMIDR_HAS_HCR_BIT) != 0U)
+ write_mpamhcr_el2(0);
+ }
+}
diff --git a/lib/extensions/ras/ras_common.c b/lib/extensions/ras/ras_common.c
index 5a2b43c..2e65eeb 100644
--- a/lib/extensions/ras/ras_common.c
+++ b/lib/extensions/ras/ras_common.c
@@ -11,6 +11,7 @@
#include <platform.h>
#include <ras.h>
#include <ras_arch.h>
+#include <stdbool.h>
#ifndef PLAT_RAS_PRI
# error Platform must define RAS priority value
@@ -20,15 +21,15 @@
int ras_ea_handler(unsigned int ea_reason, uint64_t syndrome, void *cookie,
void *handle, uint64_t flags)
{
- unsigned int i, n_handled = 0, ret;
- int probe_data;
+ unsigned int i, n_handled = 0;
+ int probe_data, ret;
struct err_record_info *info;
const struct err_handler_data err_data = {
.version = ERR_HANDLER_VERSION,
.ea_reason = ea_reason,
.interrupt = 0,
- .syndrome = syndrome,
+ .syndrome = (uint32_t) syndrome,
.flags = flags,
.cookie = cookie,
.handle = handle
@@ -39,7 +40,7 @@
assert(info->handler != NULL);
/* Continue probing until the record group signals no error */
- while (1) {
+ while (true) {
if (info->probe(info, &probe_data) == 0)
break;
@@ -52,20 +53,20 @@
}
}
- return (n_handled != 0);
+ return (n_handled != 0U) ? 1 : 0;
}
#if ENABLE_ASSERTIONS
static void assert_interrupts_sorted(void)
{
unsigned int i, last;
- struct ras_interrupt *start = ras_interrupt_mapping.intrs;
+ struct ras_interrupt *start = ras_interrupt_mappings.intrs;
- if (ras_interrupt_mapping.num_intrs == 0)
+ if (ras_interrupt_mappings.num_intrs == 0UL)
return;
last = start[0].intr_number;
- for (i = 1; i < ras_interrupt_mapping.num_intrs; i++) {
+ for (i = 1; i < ras_interrupt_mappings.num_intrs; i++) {
assert(start[i].intr_number > last);
last = start[i].intr_number;
}
@@ -79,7 +80,7 @@
static int ras_interrupt_handler(uint32_t intr_raw, uint32_t flags,
void *handle, void *cookie)
{
- struct ras_interrupt *ras_inrs = ras_interrupt_mapping.intrs;
+ struct ras_interrupt *ras_inrs = ras_interrupt_mappings.intrs;
struct ras_interrupt *selected = NULL;
int start, end, mid, probe_data, ret __unused;
@@ -91,10 +92,10 @@
.handle = handle
};
- assert(ras_interrupt_mapping.num_intrs > 0);
+ assert(ras_interrupt_mappings.num_intrs > 0UL);
start = 0;
- end = ras_interrupt_mapping.num_intrs;
+ end = (int) ras_interrupt_mappings.num_intrs;
while (start <= end) {
mid = ((end + start) / 2);
if (intr_raw == ras_inrs[mid].intr_number) {
@@ -114,14 +115,14 @@
panic();
}
- if (selected->err_record->probe) {
+ if (selected->err_record->probe != NULL) {
ret = selected->err_record->probe(selected->err_record, &probe_data);
assert(ret != 0);
}
/* Call error handler for the record group */
assert(selected->err_record->handler != NULL);
- selected->err_record->handler(selected->err_record, probe_data,
+ (void) selected->err_record->handler(selected->err_record, probe_data,
&err_data);
return 0;
diff --git a/lib/extensions/ras/std_err_record.c b/lib/extensions/ras/std_err_record.c
index 65c007f..209cb73 100644
--- a/lib/extensions/ras/std_err_record.c
+++ b/lib/extensions/ras/std_err_record.c
@@ -13,28 +13,29 @@
*/
int ser_probe_memmap(uintptr_t base, unsigned int size_num_k, int *probe_data)
{
- int num_records, num_group_regs, i;
+ unsigned int num_records, num_group_regs, i;
uint64_t gsr;
- assert(base != 0);
+ assert(base != 0UL);
/* Only 4K supported for now */
assert(size_num_k == STD_ERR_NODE_SIZE_NUM_K);
- num_records = (mmio_read_32(ERR_DEVID(base, size_num_k)) & ERR_DEVID_MASK);
+ num_records = (unsigned int)
+ (mmio_read_32(ERR_DEVID(base, size_num_k)) & ERR_DEVID_MASK);
/* A group register shows error status for 2^6 error records */
- num_group_regs = (num_records >> 6) + 1;
+ num_group_regs = (num_records >> 6U) + 1U;
/* Iterate through group registers to find a record in error */
for (i = 0; i < num_group_regs; i++) {
gsr = mmio_read_64(ERR_GSR(base, size_num_k, i));
- if (gsr == 0)
+ if (gsr == 0ULL)
continue;
/* Return the index of the record in error */
if (probe_data != NULL)
- *probe_data = ((i << 6) + __builtin_ctz(gsr));
+ *probe_data = (((int) (i << 6U)) + __builtin_ctzll(gsr));
return 1;
}
@@ -49,13 +50,14 @@
*/
int ser_probe_sysreg(unsigned int idx_start, unsigned int num_idx, int *probe_data)
{
- int i;
+ unsigned int i;
uint64_t status;
- unsigned int max_idx __unused = read_erridr_el1() & ERRIDR_MASK;
+ unsigned int max_idx __unused =
+ ((unsigned int) read_erridr_el1()) & ERRIDR_MASK;
assert(idx_start < max_idx);
- assert(check_u32_overflow(idx_start, num_idx) == 0);
- assert((idx_start + num_idx - 1) < max_idx);
+ assert(check_u32_overflow(idx_start, num_idx));
+ assert((idx_start + num_idx - 1U) < max_idx);
for (i = 0; i < num_idx; i++) {
/* Select the error record */
@@ -65,9 +67,9 @@
status = read_erxstatus_el1();
/* Check for valid field in status */
- if (ERR_STATUS_GET_FIELD(status, V)) {
+ if (ERR_STATUS_GET_FIELD(status, V) != 0U) {
if (probe_data != NULL)
- *probe_data = i;
+ *probe_data = (int) i;
return 1;
}
}
diff --git a/lib/libc/abort.c b/lib/libc/abort.c
index 65ce4cc..c9d16cc 100644
--- a/lib/libc/abort.c
+++ b/lib/libc/abort.c
@@ -7,10 +7,7 @@
#include <debug.h>
#include <stdlib.h>
-/*
- * This is a basic implementation. This could be improved.
- */
-void abort (void)
+void abort(void)
{
ERROR("ABORT\n");
panic();
diff --git a/lib/libc/assert.c b/lib/libc/assert.c
index 97fab4b..fa12cb6 100644
--- a/lib/libc/assert.c
+++ b/lib/libc/assert.c
@@ -1,30 +1,32 @@
/*
- * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <assert.h>
+#include <cdefs.h>
#include <console.h>
#include <debug.h>
#include <platform.h>
+#include <stdio.h>
/*
-* Only print the output if PLAT_LOG_LEVEL_ASSERT is higher or equal to
-* LOG_LEVEL_INFO, which is the default value for builds with DEBUG=1.
-*/
+ * Only print the output if PLAT_LOG_LEVEL_ASSERT is higher or equal to
+ * LOG_LEVEL_INFO, which is the default value for builds with DEBUG=1.
+ */
#if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
void __assert(const char *file, unsigned int line, const char *assertion)
{
- tf_printf("ASSERT: %s:%d:%s\n", file, line, assertion);
+ printf("ASSERT: %s:%d:%s\n", file, line, assertion);
console_flush();
plat_panic_handler();
}
#elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
void __assert(const char *file, unsigned int line)
{
- tf_printf("ASSERT: %s:%d\n", file, line);
+ printf("ASSERT: %s:%d\n", file, line);
console_flush();
plat_panic_handler();
}
diff --git a/lib/libc/libc.mk b/lib/libc/libc.mk
index ded3d74..554f36b 100644
--- a/lib/libc/libc.mk
+++ b/lib/libc/libc.mk
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -8,18 +8,20 @@
abort.c \
assert.c \
exit.c \
- mem.c \
+ memchr.c \
+ memcmp.c \
+ memcpy.c \
+ memmove.c \
+ memset.c \
printf.c \
putchar.c \
puts.c \
- sscanf.c \
+ snprintf.c \
strchr.c \
strcmp.c \
strlen.c \
strncmp.c \
- strnlen.c \
- subr_prf.c \
- timingsafe_bcmp.c)
+ strnlen.c)
INCLUDES += -Iinclude/lib/libc \
- -Iinclude/lib/libc/sys
+ -Iinclude/lib/libc/$(ARCH) \
diff --git a/lib/libc/mem.c b/lib/libc/mem.c
deleted file mode 100644
index 65b62fd..0000000
--- a/lib/libc/mem.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <stddef.h> /* size_t */
-
-/*
- * Fill @count bytes of memory pointed to by @dst with @val
- */
-void *memset(void *dst, int val, size_t count)
-{
- char *ptr = dst;
-
- while (count--)
- *ptr++ = val;
-
- return dst;
-}
-
-/*
- * Compare @len bytes of @s1 and @s2
- */
-int memcmp(const void *s1, const void *s2, size_t len)
-{
- const unsigned char *s = s1;
- const unsigned char *d = s2;
- unsigned char sc;
- unsigned char dc;
-
- while (len--) {
- sc = *s++;
- dc = *d++;
- if (sc - dc)
- return (sc - dc);
- }
-
- return 0;
-}
-
-/*
- * Copy @len bytes from @src to @dst
- */
-void *memcpy(void *dst, const void *src, size_t len)
-{
- const char *s = src;
- char *d = dst;
-
- while (len--)
- *d++ = *s++;
-
- return dst;
-}
-
-/*
- * Move @len bytes from @src to @dst
- */
-void *memmove(void *dst, const void *src, size_t len)
-{
- /*
- * The following test makes use of unsigned arithmetic overflow to
- * more efficiently test the condition !(src <= dst && dst < str+len).
- * It also avoids the situation where the more explicit test would give
- * incorrect results were the calculation str+len to overflow (though
- * that issue is probably moot as such usage is probably undefined
- * behaviour and a bug anyway.
- */
- if ((size_t)dst - (size_t)src >= len) {
- /* destination not in source data, so can safely use memcpy */
- return memcpy(dst, src, len);
- } else {
- /* copy backwards... */
- const char *end = dst;
- const char *s = (const char *)src + len;
- char *d = (char *)dst + len;
- while (d != end)
- *--d = *--s;
- }
- return dst;
-}
-
-/*
- * Scan @len bytes of @src for value @c
- */
-void *memchr(const void *src, int c, size_t len)
-{
- const char *s = src;
-
- while (len--) {
- if (*s == c)
- return (void *) s;
- s++;
- }
-
- return NULL;
-}
diff --git a/lib/libc/memchr.c b/lib/libc/memchr.c
new file mode 100644
index 0000000..2eba47c
--- /dev/null
+++ b/lib/libc/memchr.c
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <stddef.h>
+
+void *memchr(const void *src, int c, size_t len)
+{
+ const char *s = src;
+
+ while (len--) {
+ if (*s == c)
+ return (void *) s;
+ s++;
+ }
+
+ return NULL;
+}
diff --git a/lib/libc/memcmp.c b/lib/libc/memcmp.c
new file mode 100644
index 0000000..a4c798b
--- /dev/null
+++ b/lib/libc/memcmp.c
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <stddef.h>
+
+int memcmp(const void *s1, const void *s2, size_t len)
+{
+ const unsigned char *s = s1;
+ const unsigned char *d = s2;
+ unsigned char sc;
+ unsigned char dc;
+
+ while (len--) {
+ sc = *s++;
+ dc = *d++;
+ if (sc - dc)
+ return (sc - dc);
+ }
+
+ return 0;
+}
diff --git a/lib/libc/memcpy.c b/lib/libc/memcpy.c
new file mode 100644
index 0000000..fc0c9fe
--- /dev/null
+++ b/lib/libc/memcpy.c
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <stddef.h>
+
+void *memcpy(void *dst, const void *src, size_t len)
+{
+ const char *s = src;
+ char *d = dst;
+
+ while (len--)
+ *d++ = *s++;
+
+ return dst;
+}
diff --git a/lib/libc/memmove.c b/lib/libc/memmove.c
new file mode 100644
index 0000000..63acf26
--- /dev/null
+++ b/lib/libc/memmove.c
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <string.h>
+
+void *memmove(void *dst, const void *src, size_t len)
+{
+ /*
+ * The following test makes use of unsigned arithmetic overflow to
+ * more efficiently test the condition !(src <= dst && dst < str+len).
+ * It also avoids the situation where the more explicit test would give
+ * incorrect results were the calculation str+len to overflow (though
+ * that issue is probably moot as such usage is probably undefined
+ * behaviour and a bug anyway.
+ */
+ if ((size_t)dst - (size_t)src >= len) {
+ /* destination not in source data, so can safely use memcpy */
+ return memcpy(dst, src, len);
+ } else {
+ /* copy backwards... */
+ const char *end = dst;
+ const char *s = (const char *)src + len;
+ char *d = (char *)dst + len;
+ while (d != end)
+ *--d = *--s;
+ }
+ return dst;
+}
diff --git a/lib/libc/memset.c b/lib/libc/memset.c
new file mode 100644
index 0000000..03aa809
--- /dev/null
+++ b/lib/libc/memset.c
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <stddef.h>
+
+void *memset(void *dst, int val, size_t count)
+{
+ char *ptr = dst;
+
+ while (count--)
+ *ptr++ = val;
+
+ return dst;
+}
diff --git a/lib/libc/printf.c b/lib/libc/printf.c
index f615641..4f4a722 100644
--- a/lib/libc/printf.c
+++ b/lib/libc/printf.c
@@ -1,36 +1,190 @@
/*
- * Copyright (c) 2013-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
*/
-
-#include <stdio.h>
+#include <assert.h>
+#include <debug.h>
#include <stdarg.h>
+#include <stdint.h>
-/* Choose max of 128 chars for now. */
-#define PRINT_BUFFER_SIZE 128
-int printf(const char *fmt, ...)
+/***********************************************************
+ * The printf implementation for all BL stages
+ ***********************************************************/
+
+#define get_num_va_args(_args, _lcount) \
+ (((_lcount) > 1) ? va_arg(_args, long long int) : \
+ ((_lcount) ? va_arg(_args, long int) : va_arg(_args, int)))
+
+#define get_unum_va_args(_args, _lcount) \
+ (((_lcount) > 1) ? va_arg(_args, unsigned long long int) : \
+ ((_lcount) ? va_arg(_args, unsigned long int) : va_arg(_args, unsigned int)))
+
+static int string_print(const char *str)
{
- va_list args;
- char buf[PRINT_BUFFER_SIZE];
- int count;
+ int count = 0;
- va_start(args, fmt);
- vsnprintf(buf, sizeof(buf) - 1, fmt, args);
- va_end(args);
+ assert(str);
- /* Use putchar directly as 'puts()' adds a newline. */
- buf[PRINT_BUFFER_SIZE - 1] = '\0';
- count = 0;
- while (buf[count])
- {
- if (putchar(buf[count]) != EOF) {
+ while (*str) {
+ putchar(*str++);
+ count++;
+ }
+
+ return count;
+}
+
+static int unsigned_num_print(unsigned long long int unum, unsigned int radix,
+ char padc, int padn)
+{
+ /* Just need enough space to store 64 bit decimal integer */
+ unsigned char num_buf[20];
+ int i = 0, rem, count = 0;
+
+ do {
+ rem = unum % radix;
+ if (rem < 0xa)
+ num_buf[i++] = '0' + rem;
+ else
+ num_buf[i++] = 'a' + (rem - 0xa);
+ } while (unum /= radix);
+
+ if (padn > 0) {
+ while (i < padn--) {
+ putchar(padc);
count++;
- } else {
- count = EOF;
- break;
}
}
+ while (--i >= 0) {
+ putchar(num_buf[i]);
+ count++;
+ }
+
+ return count;
+}
+
+/*******************************************************************
+ * Reduced format print for Trusted firmware.
+ * The following type specifiers are supported by this print
+ * %x - hexadecimal format
+ * %s - string format
+ * %d or %i - signed decimal format
+ * %u - unsigned decimal format
+ * %p - pointer format
+ *
+ * The following length specifiers are supported by this print
+ * %l - long int (64-bit on AArch64)
+ * %ll - long long int (64-bit on AArch64)
+ * %z - size_t sized integer formats (64 bit on AArch64)
+ *
+ * The following padding specifiers are supported by this print
+ * %0NN - Left-pad the number with 0s (NN is a decimal number)
+ *
+ * The print exits on all other formats specifiers other than valid
+ * combinations of the above specifiers.
+ *******************************************************************/
+int vprintf(const char *fmt, va_list args)
+{
+ int l_count;
+ long long int num;
+ unsigned long long int unum;
+ char *str;
+ char padc = 0; /* Padding character */
+ int padn; /* Number of characters to pad */
+ int count = 0; /* Number of printed characters */
+
+ while (*fmt) {
+ l_count = 0;
+ padn = 0;
+
+ if (*fmt == '%') {
+ fmt++;
+ /* Check the format specifier */
+loop:
+ switch (*fmt) {
+ case 'i': /* Fall through to next one */
+ case 'd':
+ num = get_num_va_args(args, l_count);
+ if (num < 0) {
+ putchar('-');
+ unum = (unsigned long long int)-num;
+ padn--;
+ } else
+ unum = (unsigned long long int)num;
+
+ count += unsigned_num_print(unum, 10,
+ padc, padn);
+ break;
+ case 's':
+ str = va_arg(args, char *);
+ count += string_print(str);
+ break;
+ case 'p':
+ unum = (uintptr_t)va_arg(args, void *);
+ if (unum) {
+ count += string_print("0x");
+ padn -= 2;
+ }
+
+ count += unsigned_num_print(unum, 16,
+ padc, padn);
+ break;
+ case 'x':
+ unum = get_unum_va_args(args, l_count);
+ count += unsigned_num_print(unum, 16,
+ padc, padn);
+ break;
+ case 'z':
+ if (sizeof(size_t) == 8)
+ l_count = 2;
+
+ fmt++;
+ goto loop;
+ case 'l':
+ l_count++;
+ fmt++;
+ goto loop;
+ case 'u':
+ unum = get_unum_va_args(args, l_count);
+ count += unsigned_num_print(unum, 10,
+ padc, padn);
+ break;
+ case '0':
+ padc = '0';
+ padn = 0;
+ fmt++;
+
+ while (1) {
+ char ch = *fmt;
+ if (ch < '0' || ch > '9') {
+ goto loop;
+ }
+ padn = (padn * 10) + (ch - '0');
+ fmt++;
+ }
+ default:
+ /* Exit on any other format specifier */
+ return -1;
+ }
+ fmt++;
+ continue;
+ }
+ putchar(*fmt++);
+ count++;
+ }
+
+ return count;
+}
+
+int printf(const char *fmt, ...)
+{
+ int count;
+ va_list va;
+
+ va_start(va, fmt);
+ count = vprintf(fmt, va);
+ va_end(va);
+
return count;
}
diff --git a/lib/libc/putchar.c b/lib/libc/putchar.c
index 8265667..0beb625 100644
--- a/lib/libc/putchar.c
+++ b/lib/libc/putchar.c
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -7,11 +7,6 @@
#include <stdio.h>
#include <console.h>
-/* Putchar() should either return the character printed or EOF in case of error.
- * Our current console_putc() function assumes success and returns the
- * character. Write all other printing functions in terms of putchar(), if
- * possible, so they all benefit when this is improved.
- */
int putchar(int c)
{
int res;
diff --git a/lib/libc/puts.c b/lib/libc/puts.c
index 284cf8c..717b522 100644
--- a/lib/libc/puts.c
+++ b/lib/libc/puts.c
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -9,15 +9,13 @@
int puts(const char *s)
{
int count = 0;
- while(*s) {
+
+ while (*s) {
if (putchar(*s++) == EOF)
return EOF;
count++;
}
- /* According to the puts(3) manpage, the function should write a
- * trailing newline.
- */
if (putchar('\n') == EOF)
return EOF;
diff --git a/common/tf_snprintf.c b/lib/libc/snprintf.c
similarity index 94%
rename from common/tf_snprintf.c
rename to lib/libc/snprintf.c
index 6df1377..0738a86 100644
--- a/common/tf_snprintf.c
+++ b/lib/libc/snprintf.c
@@ -52,7 +52,7 @@
* buffer was big enough. If it returns a value lower than n, the
* whole string has been written.
*******************************************************************/
-int tf_snprintf(char *s, size_t n, const char *fmt, ...)
+int snprintf(char *s, size_t n, const char *fmt, ...)
{
va_list args;
int num;
@@ -102,7 +102,7 @@
break;
default:
/* Panic on any other format specifier. */
- ERROR("tf_snprintf: specifier with ASCII code '%d' not supported.",
+ ERROR("snprintf: specifier with ASCII code '%d' not supported.",
*fmt);
plat_panic_handler();
}
diff --git a/lib/libc/sscanf.c b/lib/libc/sscanf.c
deleted file mode 100644
index a5876cf..0000000
--- a/lib/libc/sscanf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <stdio.h>
-#include <sys/cdefs.h>
-
-/*
- * TODO: This is not a real implementation of the sscanf() function. It just
- * returns the number of expected arguments based on the number of '%' found
- * in the format string.
- */
-int
-sscanf(const char *__restrict str, char const *__restrict fmt, ...)
-{
- int ret = 0;
-
- while (*fmt != '\0') {
- if (*fmt++ == '%') {
- ret++;
- }
- }
-
- return ret;
-}
diff --git a/lib/libc/strchr.c b/lib/libc/strchr.c
index 4247dcd..d94bb9e 100644
--- a/lib/libc/strchr.c
+++ b/lib/libc/strchr.c
@@ -1,4 +1,6 @@
/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -10,7 +12,7 @@
* 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
+ * 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.
*
@@ -28,11 +30,10 @@
*/
/*
- * Portions copyright (c) 2013-2014, ARM Limited and Contributors.
+ * Portions copyright (c) 2018, ARM Limited and Contributors.
* All rights reserved.
*/
-#include <sys/cdefs.h>
#include <stddef.h>
#include <string.h>
diff --git a/lib/libc/strcmp.c b/lib/libc/strcmp.c
index bb86e0f..b742f9b 100644
--- a/lib/libc/strcmp.c
+++ b/lib/libc/strcmp.c
@@ -1,4 +1,6 @@
/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -13,7 +15,7 @@
* 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
+ * 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.
*
@@ -31,12 +33,10 @@
*/
/*
- * Portions copyright (c) 2014, ARM Limited and Contributors.
+ * Portions copyright (c) 2018, ARM Limited and Contributors.
* All rights reserved.
*/
-#include <sys/cdefs.h>
-#include <sys/ctype.h>
#include <string.h>
/*
@@ -47,20 +47,6 @@
{
while (*s1 == *s2++)
if (*s1++ == '\0')
- return 0;
- return *(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1);
-}
-
-int
-strcasecmp(const char *s1, const char *s2)
-{
- const unsigned char *us1 = (const unsigned char *)s1;
- const unsigned char *us2 = (const unsigned char *)s2;
-
- while (tolower(*us1) == tolower(*us2)) {
- if (*us1++ == '\0')
- return 0;
- us2++;
- }
- return tolower(*us1) - tolower(*us2);
+ return (0);
+ return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1));
}
diff --git a/lib/libc/strlen.c b/lib/libc/strlen.c
index 23c3d39..3c27630 100644
--- a/lib/libc/strlen.c
+++ b/lib/libc/strlen.c
@@ -1,44 +1,17 @@
-/*-
- * 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.
- */
-
/*
- * Portions copyright (c) 2009-2014, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
*/
-#include <stddef.h>
+#include <string.h>
-size_t
-strlen(str)
- const char *str;
+size_t strlen(const char *s)
{
- register const char *s;
+ const char *cursor = s;
- for (s = str; *s; ++s);
- return(s - str);
+ while (*cursor)
+ cursor++;
+
+ return cursor - s;
}
diff --git a/lib/libc/strncmp.c b/lib/libc/strncmp.c
index f45f4a2..ce9e5ed 100644
--- a/lib/libc/strncmp.c
+++ b/lib/libc/strncmp.c
@@ -1,4 +1,6 @@
-/*
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -10,7 +12,7 @@
* 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
+ * 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.
*
@@ -28,11 +30,10 @@
*/
/*
- * Portions copyright (c) 2014, ARM Limited and Contributors.
+ * Portions copyright (c) 2018, ARM Limited and Contributors.
* All rights reserved.
*/
-#include <sys/cdefs.h>
#include <string.h>
int
@@ -40,7 +41,7 @@
{
if (n == 0)
- return 0;
+ return (0);
do {
if (*s1 != *s2++)
return (*(const unsigned char *)s1 -
@@ -48,5 +49,5 @@
if (*s1++ == '\0')
break;
} while (--n != 0);
- return 0;
+ return (0);
}
diff --git a/lib/libc/strnlen.c b/lib/libc/strnlen.c
index d48502b..b944e95 100644
--- a/lib/libc/strnlen.c
+++ b/lib/libc/strnlen.c
@@ -1,4 +1,6 @@
/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
* Copyright (c) 2009 David Schultz <das@FreeBSD.org>
* All rights reserved.
*
@@ -25,11 +27,10 @@
*/
/*
- * Portions copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
+ * Portions copyright (c) 2018, ARM Limited and Contributors.
+ * All rights reserved.
*/
-#include <sys/cdefs.h>
-
#include <string.h>
size_t
diff --git a/lib/libc/subr_prf.c b/lib/libc/subr_prf.c
deleted file mode 100644
index c103562..0000000
--- a/lib/libc/subr_prf.c
+++ /dev/null
@@ -1,548 +0,0 @@
-/*-
- * Copyright (c) 1986, 1988, 1991, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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.
- *
- * @(#)subr_prf.c 8.3 (Berkeley) 1/21/94
- */
-
-/*
- * Portions copyright (c) 2009-2014, ARM Limited and Contributors.
- * All rights reserved.
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <stdarg.h>
-#include <stddef.h>
-#include <string.h>
-#include <ctype.h>
-
-typedef unsigned char u_char;
-typedef unsigned int u_int;
-typedef int64_t quad_t;
-typedef uint64_t u_quad_t;
-typedef unsigned long u_long;
-typedef unsigned short u_short;
-
-static inline int imax(int a, int b) { return (a > b ? a : b); }
-
-/*
- * Note that stdarg.h and the ANSI style va_start macro is used for both
- * ANSI and traditional C compilers.
- */
-
-#define TOCONS 0x01
-#define TOTTY 0x02
-#define TOLOG 0x04
-
-/* Max number conversion buffer length: a u_quad_t in base 2, plus NUL byte. */
-#define MAXNBUF (sizeof(intmax_t) * 8 + 1)
-
-struct putchar_arg {
- int flags;
- int pri;
- struct tty *tty;
- char *p_bufr;
- size_t n_bufr;
- char *p_next;
- size_t remain;
-};
-
-struct snprintf_arg {
- char *str;
- size_t remain;
-};
-
-extern int log_open;
-
-static char *ksprintn(char *nbuf, uintmax_t num, int base, int *len, int upper);
-static void snprintf_func(int ch, void *arg);
-static int kvprintf(char const *fmt, void (*func)(int, void*), void *arg, int radix, va_list ap);
-
-int vsnprintf(char *str, size_t size, const char *format, va_list ap);
-
-static char const hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz";
-#define hex2ascii(hex) (hex2ascii_data[hex])
-
-/*
- * Scaled down version of sprintf(3).
- */
-int
-sprintf(char *buf, const char *cfmt, ...)
-{
- int retval;
- va_list ap;
-
- va_start(ap, cfmt);
- retval = kvprintf(cfmt, NULL, (void *)buf, 10, ap);
- buf[retval] = '\0';
- va_end(ap);
- return (retval);
-}
-
-/*
- * Scaled down version of vsprintf(3).
- */
-int
-vsprintf(char *buf, const char *cfmt, va_list ap)
-{
- int retval;
-
- retval = kvprintf(cfmt, NULL, (void *)buf, 10, ap);
- buf[retval] = '\0';
- return (retval);
-}
-
-/*
- * Scaled down version of snprintf(3).
- */
-int
-snprintf(char *str, size_t size, const char *format, ...)
-{
- int retval;
- va_list ap;
-
- va_start(ap, format);
- retval = vsnprintf(str, size, format, ap);
- va_end(ap);
- return(retval);
-}
-
-/*
- * Scaled down version of vsnprintf(3).
- */
-int
-vsnprintf(char *str, size_t size, const char *format, va_list ap)
-{
- struct snprintf_arg info;
- int retval;
-
- info.str = str;
- info.remain = size;
- retval = kvprintf(format, snprintf_func, &info, 10, ap);
- if (info.remain >= 1)
- *info.str++ = '\0';
- return (retval);
-}
-
-static void
-snprintf_func(int ch, void *arg)
-{
- struct snprintf_arg *const info = arg;
-
- if (info->remain >= 2) {
- *info->str++ = ch;
- info->remain--;
- }
-}
-
-
-/*
- * Kernel version which takes radix argument vsnprintf(3).
- */
-int
-vsnrprintf(char *str, size_t size, int radix, const char *format, va_list ap)
-{
- struct snprintf_arg info;
- int retval;
-
- info.str = str;
- info.remain = size;
- retval = kvprintf(format, snprintf_func, &info, radix, ap);
- if (info.remain >= 1)
- *info.str++ = '\0';
- return (retval);
-}
-
-
-/*
- * Put a NUL-terminated ASCII number (base <= 36) in a buffer in reverse
- * order; return an optional length and a pointer to the last character
- * written in the buffer (i.e., the first character of the string).
- * The buffer pointed to by `nbuf' must have length >= MAXNBUF.
- */
-static char *
-ksprintn(char *nbuf, uintmax_t num, int base, int *lenp, int upper)
-{
- char *p, c;
-
- p = nbuf;
- *p = '\0';
- do {
- c = hex2ascii(num % base);
- *++p = upper ? toupper(c) : c;
- } while (num /= base);
- if (lenp)
- *lenp = p - nbuf;
- return (p);
-}
-
-/*
- * Scaled down version of printf(3).
- *
- * Two additional formats:
- *
- * The format %b is supported to decode error registers.
- * Its usage is:
- *
- * printf("reg=%b\n", regval, "<base><arg>*");
- *
- * where <base> is the output base expressed as a control character, e.g.
- * \10 gives octal; \20 gives hex. Each arg is a sequence of characters,
- * the first of which gives the bit number to be inspected (origin 1), and
- * the next characters (up to a control character, i.e. a character <= 32),
- * give the name of the register. Thus:
- *
- * kvprintf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
- *
- * would produce output:
- *
- * reg=3<BITTWO,BITONE>
- *
- * XXX: %D -- Hexdump, takes pointer and separator string:
- * ("%6D", ptr, ":") -> XX:XX:XX:XX:XX:XX
- * ("%*D", len, ptr, " " -> XX XX XX XX ...
- */
-int
-kvprintf(char const *fmt, void (*func)(int, void*), void *arg, int radix, va_list ap)
-{
-#define PCHAR(c) {int cc=(c); if (func) (*func)(cc,arg); else *d++ = cc; retval++; }
- char nbuf[MAXNBUF];
- char *d;
- const char *p, *percent, *q;
- u_char *up;
- int ch, n;
- uintmax_t num;
- int base, lflag, qflag, tmp, width, ladjust, sharpflag, neg, sign, dot;
- int cflag, hflag, jflag, tflag, zflag;
- int dwidth, upper;
- char padc;
- int stop = 0, retval = 0;
-
- num = 0;
- if (!func)
- d = (char *) arg;
- else
- d = NULL;
-
- if (fmt == NULL)
- fmt = "(fmt null)\n";
-
- if (radix < 2 || radix > 36)
- radix = 10;
-
- for (;;) {
- padc = ' ';
- width = 0;
- while ((ch = (u_char)*fmt++) != '%' || stop) {
- if (ch == '\0')
- return (retval);
- PCHAR(ch);
- }
- percent = fmt - 1;
- qflag = 0; lflag = 0; ladjust = 0; sharpflag = 0; neg = 0;
- sign = 0; dot = 0; dwidth = 0; upper = 0;
- cflag = 0; hflag = 0; jflag = 0; tflag = 0; zflag = 0;
-reswitch: switch (ch = (u_char)*fmt++) {
- case '.':
- dot = 1;
- goto reswitch;
- case '#':
- sharpflag = 1;
- goto reswitch;
- case '+':
- sign = 1;
- goto reswitch;
- case '-':
- ladjust = 1;
- goto reswitch;
- case '%':
- PCHAR(ch);
- break;
- case '*':
- if (!dot) {
- width = va_arg(ap, int);
- if (width < 0) {
- ladjust = !ladjust;
- width = -width;
- }
- } else {
- dwidth = va_arg(ap, int);
- }
- goto reswitch;
- case '0':
- if (!dot) {
- padc = '0';
- goto reswitch;
- }
- case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- for (n = 0;; ++fmt) {
- n = n * 10 + ch - '0';
- ch = *fmt;
- if (ch < '0' || ch > '9')
- break;
- }
- if (dot)
- dwidth = n;
- else
- width = n;
- goto reswitch;
- case 'b':
- num = (u_int)va_arg(ap, int);
- p = va_arg(ap, char *);
- for (q = ksprintn(nbuf, num, *p++, NULL, 0); *q;)
- PCHAR(*q--);
-
- if (num == 0)
- break;
-
- for (tmp = 0; *p;) {
- n = *p++;
- if (num & (1 << (n - 1))) {
- PCHAR(tmp ? ',' : '<');
- for (; (n = *p) > ' '; ++p)
- PCHAR(n);
- tmp = 1;
- } else
- for (; *p > ' '; ++p)
- continue;
- }
- if (tmp)
- PCHAR('>');
- break;
- case 'c':
- PCHAR(va_arg(ap, int));
- break;
- case 'D':
- up = va_arg(ap, u_char *);
- p = va_arg(ap, char *);
- if (!width)
- width = 16;
- while(width--) {
- PCHAR(hex2ascii(*up >> 4));
- PCHAR(hex2ascii(*up & 0x0f));
- up++;
- if (width)
- for (q=p;*q;q++)
- PCHAR(*q);
- }
- break;
- case 'd':
- case 'i':
- base = 10;
- sign = 1;
- goto handle_sign;
- case 'h':
- if (hflag) {
- hflag = 0;
- cflag = 1;
- } else
- hflag = 1;
- goto reswitch;
- case 'j':
- jflag = 1;
- goto reswitch;
- case 'l':
- if (lflag) {
- lflag = 0;
- qflag = 1;
- } else
- lflag = 1;
- goto reswitch;
- case 'n':
- if (jflag)
- *(va_arg(ap, intmax_t *)) = retval;
- else if (qflag)
- *(va_arg(ap, quad_t *)) = retval;
- else if (lflag)
- *(va_arg(ap, long *)) = retval;
- else if (zflag)
- *(va_arg(ap, size_t *)) = retval;
- else if (hflag)
- *(va_arg(ap, short *)) = retval;
- else if (cflag)
- *(va_arg(ap, char *)) = retval;
- else
- *(va_arg(ap, int *)) = retval;
- break;
- case 'o':
- base = 8;
- goto handle_nosign;
- case 'p':
- base = 16;
- sharpflag = (width == 0);
- sign = 0;
- num = (uintptr_t)va_arg(ap, void *);
- goto number;
- case 'q':
- qflag = 1;
- goto reswitch;
- case 'r':
- base = radix;
- if (sign)
- goto handle_sign;
- goto handle_nosign;
- case 's':
- p = va_arg(ap, char *);
- if (p == NULL)
- p = "(null)";
- if (!dot)
- n = strlen (p);
- else
- for (n = 0; n < dwidth && p[n]; n++)
- continue;
-
- width -= n;
-
- if (!ladjust && width > 0)
- while (width--)
- PCHAR(padc);
- while (n--)
- PCHAR(*p++);
- if (ladjust && width > 0)
- while (width--)
- PCHAR(padc);
- break;
- case 't':
- tflag = 1;
- goto reswitch;
- case 'u':
- base = 10;
- goto handle_nosign;
- case 'X':
- upper = 1;
- case 'x':
- base = 16;
- goto handle_nosign;
- case 'y':
- base = 16;
- sign = 1;
- goto handle_sign;
- case 'z':
- zflag = 1;
- goto reswitch;
-handle_nosign:
- sign = 0;
- if (jflag)
- num = va_arg(ap, uintmax_t);
- else if (qflag)
- num = va_arg(ap, u_quad_t);
- else if (tflag)
- num = va_arg(ap, ptrdiff_t);
- else if (lflag)
- num = va_arg(ap, u_long);
- else if (zflag)
- num = va_arg(ap, size_t);
- else if (hflag)
- num = (u_short)va_arg(ap, int);
- else if (cflag)
- num = (u_char)va_arg(ap, int);
- else
- num = va_arg(ap, u_int);
- goto number;
-handle_sign:
- if (jflag)
- num = va_arg(ap, intmax_t);
- else if (qflag)
- num = va_arg(ap, quad_t);
- else if (tflag)
- num = va_arg(ap, ptrdiff_t);
- else if (lflag)
- num = va_arg(ap, long);
- else if (zflag)
- num = va_arg(ap, ssize_t);
- else if (hflag)
- num = (short)va_arg(ap, int);
- else if (cflag)
- num = (char)va_arg(ap, int);
- else
- num = va_arg(ap, int);
-number:
- if (sign && (intmax_t)num < 0) {
- neg = 1;
- num = -(intmax_t)num;
- }
- p = ksprintn(nbuf, num, base, &n, upper);
- tmp = 0;
- if (sharpflag && num != 0) {
- if (base == 8)
- tmp++;
- else if (base == 16)
- tmp += 2;
- }
- if (neg)
- tmp++;
-
- if (!ladjust && padc == '0')
- dwidth = width - tmp;
- width -= tmp + imax(dwidth, n);
- dwidth -= n;
- if (!ladjust)
- while (width-- > 0)
- PCHAR(' ');
- if (neg)
- PCHAR('-');
- if (sharpflag && num != 0) {
- if (base == 8) {
- PCHAR('0');
- } else if (base == 16) {
- PCHAR('0');
- PCHAR('x');
- }
- }
- while (dwidth-- > 0)
- PCHAR('0');
-
- while (*p)
- PCHAR(*p--);
-
- if (ladjust)
- while (width-- > 0)
- PCHAR(' ');
-
- break;
- default:
- while (percent < fmt)
- PCHAR(*percent++);
- /*
- * Since we ignore an formatting argument it is no
- * longer safe to obey the remaining formatting
- * arguments as the arguments will no longer match
- * the format specs.
- */
- stop = 1;
- break;
- }
- }
-#undef PCHAR
-}
diff --git a/lib/libc/timingsafe_bcmp.c b/lib/libc/timingsafe_bcmp.c
deleted file mode 100644
index d098158..0000000
--- a/lib/libc/timingsafe_bcmp.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* $OpenBSD: timingsafe_bcmp.c,v 1.3 2015/08/31 02:53:57 guenther Exp $ */
-/*
- * Copyright (c) 2010 Damien Miller. All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <string.h>
-
-int __timingsafe_bcmp(const void *, const void *, size_t);
-
-int
-__timingsafe_bcmp(const void *b1, const void *b2, size_t n)
-{
- const unsigned char *p1 = b1, *p2 = b2;
- int ret = 0;
-
- for (; n > 0; n--)
- ret |= *p1++ ^ *p2++;
- return (ret != 0);
-}
-
-__weak_reference(__timingsafe_bcmp, timingsafe_bcmp);
diff --git a/lib/pmf/pmf_main.c b/lib/pmf/pmf_main.c
index 0208948..a020860 100644
--- a/lib/pmf/pmf_main.c
+++ b/lib/pmf/pmf_main.c
@@ -178,7 +178,7 @@
*/
void __pmf_dump_timestamp(unsigned int tid, unsigned long long ts)
{
- tf_printf("PMF:cpu %u tid %u ts %llu\n",
+ printf("PMF:cpu %u tid %u ts %llu\n",
plat_my_core_pos(), tid, ts);
}
diff --git a/lib/xlat_tables/aarch64/xlat_tables.c b/lib/xlat_tables/aarch64/xlat_tables.c
index d88d7b1..4afdeed 100644
--- a/lib/xlat_tables/aarch64/xlat_tables.c
+++ b/lib/xlat_tables/aarch64/xlat_tables.c
@@ -10,7 +10,7 @@
#include <bl_common.h>
#include <common_def.h>
#include <platform_def.h>
-#include <sys/types.h>
+#include <stdint.h>
#include <utils.h>
#include <xlat_tables.h>
#include <xlat_tables_arch.h>
diff --git a/lib/xlat_tables/xlat_tables_common.c b/lib/xlat_tables/xlat_tables_common.c
index 65d3f0f..ca67f2a 100644
--- a/lib/xlat_tables/xlat_tables_common.c
+++ b/lib/xlat_tables/xlat_tables_common.c
@@ -12,8 +12,8 @@
#include <debug.h>
#include <platform_def.h>
#include <stdbool.h>
+#include <stdint.h>
#include <string.h>
-#include <types.h>
#include <utils.h>
#include <xlat_tables.h>
#include "xlat_tables_private.h"
@@ -27,7 +27,7 @@
(((level) == U(0)) ? LVL0_SPACER : \
(((level) == U(1)) ? LVL1_SPACER : \
(((level) == U(2)) ? LVL2_SPACER : LVL3_SPACER)))
-#define debug_print(...) tf_printf(__VA_ARGS__)
+#define debug_print(...) printf(__VA_ARGS__)
#else
#define debug_print(...) ((void)0)
#endif
diff --git a/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c b/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c
index d1555bf..269adc7 100644
--- a/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c
+++ b/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c
@@ -9,7 +9,7 @@
#include <assert.h>
#include <cassert.h>
#include <stdbool.h>
-#include <sys/types.h>
+#include <stdint.h>
#include <utils_def.h>
#include <xlat_tables_v2.h>
#include "../xlat_tables_private.h"
diff --git a/lib/xlat_tables_v2/xlat_tables_core.c b/lib/xlat_tables_v2/xlat_tables_core.c
index 0340bf6..003718e 100644
--- a/lib/xlat_tables_v2/xlat_tables_core.c
+++ b/lib/xlat_tables_v2/xlat_tables_core.c
@@ -10,8 +10,8 @@
#include <errno.h>
#include <platform_def.h>
#include <stdbool.h>
+#include <stdint.h>
#include <string.h>
-#include <types.h>
#include <utils_def.h>
#include <xlat_tables_defs.h>
#include <xlat_tables_v2.h>
diff --git a/lib/xlat_tables_v2/xlat_tables_utils.c b/lib/xlat_tables_v2/xlat_tables_utils.c
index 05533c6..41c01ae 100644
--- a/lib/xlat_tables_v2/xlat_tables_utils.c
+++ b/lib/xlat_tables_v2/xlat_tables_utils.c
@@ -10,7 +10,8 @@
#include <errno.h>
#include <platform_def.h>
#include <stdbool.h>
-#include <types.h>
+#include <stdint.h>
+#include <stdio.h>
#include <utils_def.h>
#include <xlat_tables_defs.h>
#include <xlat_tables_v2.h>
@@ -33,16 +34,16 @@
void xlat_mmap_print(const mmap_region_t *mmap)
{
- tf_printf("mmap:\n");
+ printf("mmap:\n");
const mmap_region_t *mm = mmap;
while (mm->size != 0U) {
- tf_printf(" VA:0x%lx PA:0x%llx size:0x%zx attr:0x%x "
- "granularity:0x%zx\n", mm->base_va, mm->base_pa,
- mm->size, mm->attr, mm->granularity);
+ printf(" VA:0x%lx PA:0x%llx size:0x%zx attr:0x%x granularity:0x%zx\n",
+ mm->base_va, mm->base_pa, mm->size, mm->attr,
+ mm->granularity);
++mm;
};
- tf_printf("\n");
+ printf("\n");
}
/* Print the attributes of the specified block descriptor. */
@@ -52,18 +53,18 @@
int xlat_regime = ctx->xlat_regime;
if (mem_type_index == ATTR_IWBWA_OWBWA_NTR_INDEX) {
- tf_printf("MEM");
+ printf("MEM");
} else if (mem_type_index == ATTR_NON_CACHEABLE_INDEX) {
- tf_printf("NC");
+ printf("NC");
} else {
assert(mem_type_index == ATTR_DEVICE_INDEX);
- tf_printf("DEV");
+ printf("DEV");
}
if ((xlat_regime == EL3_REGIME) || (xlat_regime == EL2_REGIME)) {
/* For EL3 and EL2 only check the AP[2] and XN bits. */
- tf_printf(((desc & LOWER_ATTRS(AP_RO)) != 0ULL) ? "-RO" : "-RW");
- tf_printf(((desc & UPPER_ATTRS(XN)) != 0ULL) ? "-XN" : "-EXEC");
+ printf(((desc & LOWER_ATTRS(AP_RO)) != 0ULL) ? "-RO" : "-RW");
+ printf(((desc & UPPER_ATTRS(XN)) != 0ULL) ? "-XN" : "-EXEC");
} else {
assert(xlat_regime == EL1_EL0_REGIME);
/*
@@ -81,18 +82,18 @@
assert((xn_perm == xn_mask) || (xn_perm == 0ULL));
#endif
- tf_printf(((desc & LOWER_ATTRS(AP_RO)) != 0ULL) ? "-RO" : "-RW");
+ printf(((desc & LOWER_ATTRS(AP_RO)) != 0ULL) ? "-RO" : "-RW");
/* Only check one of PXN and UXN, the other one is the same. */
- tf_printf(((desc & UPPER_ATTRS(PXN)) != 0ULL) ? "-XN" : "-EXEC");
+ printf(((desc & UPPER_ATTRS(PXN)) != 0ULL) ? "-XN" : "-EXEC");
/*
* Privileged regions can only be accessed from EL1, user
* regions can be accessed from EL1 and EL0.
*/
- tf_printf(((desc & LOWER_ATTRS(AP_ACCESS_UNPRIVILEGED)) != 0ULL)
+ printf(((desc & LOWER_ATTRS(AP_ACCESS_UNPRIVILEGED)) != 0ULL)
? "-USER" : "-PRIV");
}
- tf_printf(((LOWER_ATTRS(NS) & desc) != 0ULL) ? "-NS" : "-S");
+ printf(((LOWER_ATTRS(NS) & desc) != 0ULL) ? "-NS" : "-S");
}
static const char * const level_spacers[] = {
@@ -135,18 +136,18 @@
if ((desc & DESC_MASK) == INVALID_DESC) {
if (invalid_row_count == 0) {
- tf_printf("%sVA:0x%lx size:0x%zx\n",
- level_spacers[level],
- table_idx_va, level_size);
+ printf("%sVA:0x%lx size:0x%zx\n",
+ level_spacers[level],
+ table_idx_va, level_size);
}
invalid_row_count++;
} else {
if (invalid_row_count > 1) {
- tf_printf(invalid_descriptors_ommited,
- level_spacers[level],
- invalid_row_count - 1);
+ printf(invalid_descriptors_ommited,
+ level_spacers[level],
+ invalid_row_count - 1);
}
invalid_row_count = 0;
@@ -163,9 +164,9 @@
* but instead points to the next translation
* table in the translation table walk.
*/
- tf_printf("%sVA:0x%lx size:0x%zx\n",
- level_spacers[level],
- table_idx_va, level_size);
+ printf("%sVA:0x%lx size:0x%zx\n",
+ level_spacers[level],
+ table_idx_va, level_size);
uintptr_t addr_inner = desc & TABLE_ADDR_MASK;
@@ -173,13 +174,12 @@
(uint64_t *)addr_inner,
XLAT_TABLE_ENTRIES, level + 1U);
} else {
- tf_printf("%sVA:0x%lx PA:0x%llx size:0x%zx ",
- level_spacers[level],
- table_idx_va,
- (uint64_t)(desc & TABLE_ADDR_MASK),
- level_size);
+ printf("%sVA:0x%lx PA:0x%llx size:0x%zx ",
+ level_spacers[level], table_idx_va,
+ (uint64_t)(desc & TABLE_ADDR_MASK),
+ level_size);
xlat_desc_print(ctx, desc);
- tf_printf("\n");
+ printf("\n");
}
}
@@ -188,8 +188,8 @@
}
if (invalid_row_count > 1) {
- tf_printf(invalid_descriptors_ommited,
- level_spacers[level], invalid_row_count - 1);
+ printf(invalid_descriptors_ommited,
+ level_spacers[level], invalid_row_count - 1);
}
}
@@ -364,7 +364,7 @@
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE
VERBOSE("Attributes: ");
xlat_desc_print(ctx, desc);
- tf_printf("\n");
+ printf("\n");
#endif /* LOG_LEVEL >= LOG_LEVEL_VERBOSE */
assert(attributes != NULL);
diff --git a/make_helpers/defaults.mk b/make_helpers/defaults.mk
index e4b5bdc..49f403d 100644
--- a/make_helpers/defaults.mk
+++ b/make_helpers/defaults.mk
@@ -62,6 +62,9 @@
# development platforms.
DYN_DISABLE_AUTH := 0
+# Build option to enable MPAM for lower ELs
+ENABLE_MPAM_FOR_LOWER_ELS := 0
+
# Flag to enable Performance Measurement Framework
ENABLE_PMF := 0
diff --git a/plat/arm/board/common/board_common.mk b/plat/arm/board/common/board_common.mk
index d63ae9a..af47c0d 100644
--- a/plat/arm/board/common/board_common.mk
+++ b/plat/arm/board/common/board_common.mk
@@ -1,5 +1,5 @@
#
-# 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
#
@@ -12,13 +12,7 @@
BL1_SOURCES += plat/arm/board/common/drivers/norflash/norflash.c
-BL2_SOURCES += lib/utils/mem_region.c \
- plat/arm/common/arm_nor_psci_mem_protect.c \
- plat/arm/board/common/drivers/norflash/norflash.c
-
-BL31_SOURCES += lib/utils/mem_region.c \
- plat/arm/board/common/drivers/norflash/norflash.c \
- plat/arm/common/arm_nor_psci_mem_protect.c
+BL2_SOURCES += plat/arm/board/common/drivers/norflash/norflash.c
ifneq (${TRUSTED_BOARD_BOOT},0)
ifneq (${ARM_CRYPTOCELL_INTEG}, 1)
diff --git a/plat/arm/board/fvp/platform.mk b/plat/arm/board/fvp/platform.mk
index 2b1e0ac..fd93b99 100644
--- a/plat/arm/board/fvp/platform.mk
+++ b/plat/arm/board/fvp/platform.mk
@@ -134,13 +134,17 @@
BL2_SOURCES += drivers/io/io_semihosting.c \
+ lib/utils/mem_region.c \
lib/semihosting/semihosting.c \
lib/semihosting/${ARCH}/semihosting_call.S \
plat/arm/board/fvp/fvp_bl2_setup.c \
plat/arm/board/fvp/fvp_io_storage.c \
plat/arm/board/fvp/fvp_trusted_boot.c \
+ plat/arm/common/arm_nor_psci_mem_protect.c \
${FVP_SECURITY_SOURCES}
+
+
ifeq (${BL2_AT_EL3},1)
BL2_SOURCES += plat/arm/board/fvp/${ARCH}/fvp_helpers.S \
plat/arm/board/fvp/fvp_bl2_el3_setup.c \
@@ -156,11 +160,14 @@
${FVP_SECURITY_SOURCES}
BL31_SOURCES += drivers/arm/smmu/smmu_v3.c \
+ lib/utils/mem_region.c \
plat/arm/board/fvp/fvp_bl31_setup.c \
plat/arm/board/fvp/fvp_pm.c \
plat/arm/board/fvp/fvp_topology.c \
plat/arm/board/fvp/aarch64/fvp_helpers.S \
plat/arm/board/fvp/drivers/pwrc/fvp_pwrc.c \
+ plat/arm/board/common/drivers/norflash/norflash.c \
+ plat/arm/common/arm_nor_psci_mem_protect.c \
${FVP_CPU_LIBS} \
${FVP_GIC_SOURCES} \
${FVP_INTERCONNECT_SOURCES} \
diff --git a/plat/arm/board/juno/platform.mk b/plat/arm/board/juno/platform.mk
index 3ab99ef..16390fa 100644
--- a/plat/arm/board/juno/platform.mk
+++ b/plat/arm/board/juno/platform.mk
@@ -59,7 +59,9 @@
${JUNO_INTERCONNECT_SOURCES} \
${JUNO_SECURITY_SOURCES}
-BL2_SOURCES += plat/arm/board/juno/juno_bl2_setup.c \
+BL2_SOURCES += lib/utils/mem_region.c \
+ plat/arm/board/juno/juno_bl2_setup.c \
+ plat/arm/common/arm_nor_psci_mem_protect.c \
${JUNO_SECURITY_SOURCES}
BL2U_SOURCES += ${JUNO_SECURITY_SOURCES}
@@ -67,7 +69,10 @@
BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
lib/cpus/aarch64/cortex_a57.S \
lib/cpus/aarch64/cortex_a72.S \
+ lib/utils/mem_region.c \
plat/arm/board/juno/juno_topology.c \
+ plat/arm/board/common/drivers/norflash/norflash.c \
+ plat/arm/common/arm_nor_psci_mem_protect.c \
${JUNO_GIC_SOURCES} \
${JUNO_INTERCONNECT_SOURCES} \
${JUNO_SECURITY_SOURCES}
diff --git a/plat/arm/board/sgi575/platform.mk b/plat/arm/board/sgi575/platform.mk
index 9893ba5..284bae8 100644
--- a/plat/arm/board/sgi575/platform.mk
+++ b/plat/arm/board/sgi575/platform.mk
@@ -5,3 +5,10 @@
#
include plat/arm/css/sgi/sgi-common.mk
+
+BL2_SOURCES += lib/utils/mem_region.c \
+ plat/arm/common/arm_nor_psci_mem_protect.c
+
+BL31_SOURCES += lib/utils/mem_region.c \
+ plat/arm/board/common/drivers/norflash/norflash.c \
+ plat/arm/common/arm_nor_psci_mem_protect.c
diff --git a/plat/arm/board/sgm775/platform.mk b/plat/arm/board/sgm775/platform.mk
index 71e71e1..633cee6 100644
--- a/plat/arm/board/sgm775/platform.mk
+++ b/plat/arm/board/sgm775/platform.mk
@@ -11,3 +11,10 @@
FDT_SOURCES += ${SGM775_BASE}/fdts/sgm775_tb_fw_config.dts
PLAT_INCLUDES +=-I${SGM775_BASE}/include/
+
+BL2_SOURCES += lib/utils/mem_region.c \
+ plat/arm/common/arm_nor_psci_mem_protect.c
+
+BL31_SOURCES += lib/utils/mem_region.c \
+ plat/arm/board/common/drivers/norflash/norflash.c \
+ plat/arm/common/arm_nor_psci_mem_protect.c
diff --git a/plat/arm/common/arm_sip_svc.c b/plat/arm/common/arm_sip_svc.c
index bb5b5c6..e450c6f 100644
--- a/plat/arm/common/arm_sip_svc.c
+++ b/plat/arm/common/arm_sip_svc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -64,9 +64,9 @@
/*
* Pointers used in execution state switch are all 32 bits wide
*/
- return arm_execution_state_switch(smc_fid, (uint32_t) x1,
- (uint32_t) x2, (uint32_t) x3, (uint32_t) x4,
- handle);
+ return (uintptr_t) arm_execution_state_switch(smc_fid,
+ (uint32_t) x1, (uint32_t) x2, (uint32_t) x3,
+ (uint32_t) x4, handle);
}
case ARM_SIP_SVC_CALL_COUNT:
diff --git a/plat/arm/common/execution_state_switch.c b/plat/arm/common/execution_state_switch.c
index 22d552a..b12d82c 100644
--- a/plat/arm/common/execution_state_switch.c
+++ b/plat/arm/common/execution_state_switch.c
@@ -11,6 +11,7 @@
#include <plat_arm.h>
#include <psci.h>
#include <smccc_helpers.h>
+#include <stdbool.h>
#include <string.h>
#include <utils.h>
@@ -39,7 +40,8 @@
{
/* Execution state can be switched only if EL3 is AArch64 */
#ifdef AARCH64
- int caller_64, from_el2, el, endianness, thumb = 0;
+ bool caller_64, thumb = false, from_el2;
+ unsigned int el, endianness;
u_register_t spsr, pc, scr, sctlr;
entry_point_info_t ep;
cpu_context_t *ctx = (cpu_context_t *) handle;
@@ -50,7 +52,7 @@
/*
* Disallow state switch if any of the secondaries have been brought up.
*/
- if (psci_secondaries_brought_up())
+ if (psci_secondaries_brought_up() != 0)
goto exec_denied;
spsr = read_ctx_reg(el3_ctx, CTX_SPSR_EL3);
@@ -61,20 +63,20 @@
* If the call originated from AArch64, expect 32-bit pointers when
* switching to AArch32.
*/
- if ((pc_hi != 0) || (cookie_hi != 0))
+ if ((pc_hi != 0U) || (cookie_hi != 0U))
goto invalid_param;
pc = pc_lo;
/* Instruction state when entering AArch32 */
- thumb = pc & 1;
+ thumb = (pc & 1U) != 0U;
} else {
/* Construct AArch64 PC */
pc = (((u_register_t) pc_hi) << 32) | pc_lo;
}
/* Make sure PC is 4-byte aligned, except for Thumb */
- if ((pc & 0x3) && !thumb)
+ if (((pc & 0x3U) != 0U) && !thumb)
goto invalid_param;
/*
@@ -95,7 +97,7 @@
* Disallow switching state if there's a Hypervisor in place;
* this request must be taken up with the Hypervisor instead.
*/
- if (scr & SCR_HCE_BIT)
+ if ((scr & SCR_HCE_BIT) != 0U)
goto exec_denied;
}
@@ -105,11 +107,11 @@
* directly.
*/
sctlr = from_el2 ? read_sctlr_el2() : read_sctlr_el1();
- endianness = !!(sctlr & SCTLR_EE_BIT);
+ endianness = ((sctlr & SCTLR_EE_BIT) != 0U) ? 1U : 0U;
/* Construct SPSR for the exception state we're about to switch to */
if (caller_64) {
- int impl;
+ unsigned long long impl;
/*
* Switching from AArch64 to AArch32. Ensure this CPU implements
@@ -121,7 +123,8 @@
/* Return to the equivalent AArch32 privilege level */
el = from_el2 ? MODE32_hyp : MODE32_svc;
- spsr = SPSR_MODE32(el, thumb ? SPSR_T_THUMB : SPSR_T_ARM,
+ spsr = SPSR_MODE32((u_register_t) el,
+ thumb ? SPSR_T_THUMB : SPSR_T_ARM,
endianness, DISABLE_ALL_EXCEPTIONS);
} else {
/*
@@ -130,7 +133,8 @@
* raised), it's safe to assume AArch64 is also implemented.
*/
el = from_el2 ? MODE_EL2 : MODE_EL1;
- spsr = SPSR_64(el, MODE_SP_ELX, DISABLE_ALL_EXCEPTIONS);
+ spsr = SPSR_64((u_register_t) el, MODE_SP_ELX,
+ DISABLE_ALL_EXCEPTIONS);
}
/*
@@ -143,10 +147,11 @@
*/
zeromem(&ep, sizeof(ep));
ep.pc = pc;
- ep.spsr = spsr;
+ ep.spsr = (uint32_t) spsr;
SET_PARAM_HEAD(&ep, PARAM_EP, VERSION_1,
- ((endianness ? EP_EE_BIG : EP_EE_LITTLE) | NON_SECURE |
- EP_ST_DISABLE));
+ ((unsigned int) ((endianness != 0U) ? EP_EE_BIG :
+ EP_EE_LITTLE)
+ | NON_SECURE | EP_ST_DISABLE));
/*
* Re-initialize the system register context, and exit EL3 as if for the
diff --git a/plat/arm/css/drivers/scp/css_scp.h b/plat/arm/css/drivers/scp/css_scp.h
index 671612a..44dfbca 100644
--- a/plat/arm/css/drivers/scp/css_scp.h
+++ b/plat/arm/css/drivers/scp/css_scp.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -9,7 +9,7 @@
#include <cassert.h>
#include <platform_def.h>
-#include <types.h>
+#include <stdint.h>
/* Forward declarations */
struct psci_power_state;
diff --git a/plat/hisilicon/hikey/hikey_security.c b/plat/hisilicon/hikey/hikey_security.c
index 863ad2b..43d7b7a 100644
--- a/plat/hisilicon/hikey/hikey_security.c
+++ b/plat/hisilicon/hikey/hikey_security.c
@@ -8,7 +8,7 @@
#include <debug.h>
#include <platform_def.h>
#include <stdint.h>
-#include <strings.h>
+#include <string.h>
#include <utils_def.h>
#include "hikey_private.h"
diff --git a/plat/hisilicon/hikey/hisi_ipc.c b/plat/hisilicon/hikey/hisi_ipc.c
index 4936f83..7e02f3a 100644
--- a/plat/hisilicon/hikey/hisi_ipc.c
+++ b/plat/hisilicon/hikey/hisi_ipc.c
@@ -11,6 +11,7 @@
#include <mmio.h>
#include <platform_def.h>
#include <stdarg.h>
+#include <stdio.h>
#include <string.h>
static int ipc_init;
@@ -63,7 +64,7 @@
static void hisi_ipc_send(unsigned int ipc_num)
{
if (!ipc_init) {
- tf_printf("error ipc base is null!!!\n");
+ printf("error ipc base is null!!!\n");
return;
}
diff --git a/plat/imx/common/include/imx8_lpuart.h b/plat/imx/common/include/imx8_lpuart.h
index 4ff91bd..33f955d 100644
--- a/plat/imx/common/include/imx8_lpuart.h
+++ b/plat/imx/common/include/imx8_lpuart.h
@@ -52,7 +52,7 @@
#ifndef __ASSEMBLY__
-#include <types.h>
+#include <stdint.h>
typedef struct {
console_t console;
diff --git a/plat/imx/common/include/sci/sci_scfw.h b/plat/imx/common/include/sci/sci_scfw.h
index 9d08dad..781c69e 100644
--- a/plat/imx/common/include/sci/sci_scfw.h
+++ b/plat/imx/common/include/sci/sci_scfw.h
@@ -9,7 +9,7 @@
/* Includes */
-#include <types.h>
+#include <stdint.h>
#ifdef __cplusplus
#define __I volatile /*!< Defines 'read only' permissions */
diff --git a/plat/imx/common/sci/imx8_mu.h b/plat/imx/common/sci/imx8_mu.h
index 8834a97..8c78877 100644
--- a/plat/imx/common/sci/imx8_mu.h
+++ b/plat/imx/common/sci/imx8_mu.h
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <types.h>
+#include <stdint.h>
#define MU_ATR0_OFFSET1 0x0
#define MU_ARR0_OFFSET1 0x10
diff --git a/plat/imx/imx8qm/imx8qm_psci.c b/plat/imx/imx8qm/imx8qm_psci.c
index c37c39c..8166546 100644
--- a/plat/imx/imx8qm/imx8qm_psci.c
+++ b/plat/imx/imx8qm/imx8qm_psci.c
@@ -35,7 +35,7 @@
cluster_id = MPIDR_AFFLVL1_VAL(mpidr);
cpu_id = MPIDR_AFFLVL0_VAL(mpidr);
- tf_printf("imx_pwr_domain_on cluster_id %d, cpu_id %d\n", cluster_id, cpu_id);
+ printf("imx_pwr_domain_on cluster_id %d, cpu_id %d\n", cluster_id, cpu_id);
if (cluster_id == 0) {
sc_pm_set_resource_power_mode(ipc_handle, SC_R_A53,
@@ -94,7 +94,7 @@
SC_PM_WAKE_SRC_NONE);
if (CLUSTER_PWR_STATE(target_state) == PLAT_MAX_OFF_STATE)
cci_disable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(mpidr));
- tf_printf("turn off cluster:%d core:%d\n", cluster_id, cpu_id);
+ printf("turn off cluster:%d core:%d\n", cluster_id, cpu_id);
}
void imx_domain_suspend(const psci_power_state_t *target_state)
diff --git a/plat/imx/imx8qx/imx8qx_psci.c b/plat/imx/imx8qx/imx8qx_psci.c
index f1df267..46ea724 100644
--- a/plat/imx/imx8qx/imx8qx_psci.c
+++ b/plat/imx/imx8qx/imx8qx_psci.c
@@ -25,7 +25,7 @@
cpu_id = MPIDR_AFFLVL0_VAL(mpidr);
- tf_printf("imx_pwr_domain_on cpu_id %d\n", cpu_id);
+ printf("imx_pwr_domain_on cpu_id %d\n", cpu_id);
if (sc_pm_set_resource_power_mode(ipc_handle, ap_core_index[cpu_id],
SC_PM_PW_MODE_ON) != SC_ERR_NONE) {
@@ -61,7 +61,7 @@
plat_gic_cpuif_disable();
sc_pm_req_cpu_low_power_mode(ipc_handle, ap_core_index[cpu_id],
SC_PM_PW_MODE_OFF, SC_PM_WAKE_SRC_NONE);
- tf_printf("turn off core:%d\n", cpu_id);
+ printf("turn off core:%d\n", cpu_id);
}
void imx_domain_suspend(const psci_power_state_t *target_state)
diff --git a/plat/layerscape/board/ls1043/ls1043_psci.c b/plat/layerscape/board/ls1043/ls1043_psci.c
index 1c83df4..b402e7f 100644
--- a/plat/layerscape/board/ls1043/ls1043_psci.c
+++ b/plat/layerscape/board/ls1043/ls1043_psci.c
@@ -5,15 +5,15 @@
*/
#include <arch_helpers.h>
-#include <debug.h>
-#include <errno.h>
#include <assert.h>
+#include <debug.h>
+#include <delay_timer.h>
+#include <endian.h>
+#include <errno.h>
+#include <gicv2.h>
+#include <mmio.h>
#include <platform.h>
#include <psci.h>
-#include <mmio.h>
-#include <sys/endian.h>
-#include <gicv2.h>
-#include <delay_timer.h>
#include "platform_def.h"
#define LS_SCFG_BASE 0x01570000
diff --git a/plat/layerscape/common/include/ls_16550.h b/plat/layerscape/common/include/ls_16550.h
index 503a01d..8daafbb 100644
--- a/plat/layerscape/common/include/ls_16550.h
+++ b/plat/layerscape/common/include/ls_16550.h
@@ -65,7 +65,7 @@
#ifndef __ASSEMBLY__
-#include <types.h>
+#include <stdint.h>
typedef struct {
console_t console;
diff --git a/plat/layerscape/common/include/plat_ls.h b/plat/layerscape/common/include/plat_ls.h
index 9d5ec14..05b9c05 100644
--- a/plat/layerscape/common/include/plat_ls.h
+++ b/plat/layerscape/common/include/plat_ls.h
@@ -7,8 +7,8 @@
#ifndef __PLAT_LS_H__
#define __PLAT_LS_H__
-#include <sys/types.h>
#include <cpu_data.h>
+#include <stdint.h>
/* BL1 utility functions */
void ls_bl1_platform_setup(void);
diff --git a/plat/nvidia/tegra/common/drivers/smmu/smmu.c b/plat/nvidia/tegra/common/drivers/smmu/smmu.c
index fa3f000..4b9edb6 100644
--- a/plat/nvidia/tegra/common/drivers/smmu/smmu.c
+++ b/plat/nvidia/tegra/common/drivers/smmu/smmu.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -12,6 +12,8 @@
#include <string.h>
#include <tegra_private.h>
+extern void memcpy16(void *dest, const void *src, unsigned int length);
+
/* SMMU IDs currently supported by the driver */
enum {
TEGRA_SMMU0,
diff --git a/plat/nvidia/tegra/common/tegra_bl31_setup.c b/plat/nvidia/tegra/common/tegra_bl31_setup.c
index f0a7036..6599768 100644
--- a/plat/nvidia/tegra/common/tegra_bl31_setup.c
+++ b/plat/nvidia/tegra/common/tegra_bl31_setup.c
@@ -28,6 +28,7 @@
/* length of Trusty's input parameters (in bytes) */
#define TRUSTY_PARAMS_LEN_BYTES (4096*2)
+extern void memcpy16(void *dest, const void *src, unsigned int length);
extern void zeromem16(void *mem, unsigned int length);
/*******************************************************************************
diff --git a/plat/nvidia/tegra/include/drivers/memctrl_v2.h b/plat/nvidia/tegra/include/drivers/memctrl_v2.h
index 60c8a04..b72653e 100644
--- a/plat/nvidia/tegra/include/drivers/memctrl_v2.h
+++ b/plat/nvidia/tegra/include/drivers/memctrl_v2.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -11,7 +11,7 @@
#ifndef __ASSEMBLY__
-#include <sys/types.h>
+#include <stdint.h>
/*******************************************************************************
* StreamID to indicate no SMMU translations (requests to be steered on the
diff --git a/plat/nvidia/tegra/include/tegra_platform.h b/plat/nvidia/tegra/include/tegra_platform.h
index fbaad6e..db79fbe 100644
--- a/plat/nvidia/tegra/include/tegra_platform.h
+++ b/plat/nvidia/tegra/include/tegra_platform.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -7,7 +7,7 @@
#ifndef __TEGRA_PLATFORM_H__
#define __TEGRA_PLATFORM_H__
-#include <sys/cdefs.h>
+#include <cdefs.h>
/*
* Tegra chip major/minor version
diff --git a/plat/nvidia/tegra/soc/t186/drivers/mce/ari.c b/plat/nvidia/tegra/soc/t186/drivers/mce/ari.c
index 7eb6c6c..7126c3b 100644
--- a/plat/nvidia/tegra/soc/t186/drivers/mce/ari.c
+++ b/plat/nvidia/tegra/soc/t186/drivers/mce/ari.c
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -10,10 +10,10 @@
#include <debug.h>
#include <delay_timer.h>
#include <denver.h>
+#include <errno.h>
#include <mce_private.h>
#include <mmio.h>
#include <platform.h>
-#include <sys/errno.h>
#include <t18x_ari.h>
/*******************************************************************************
diff --git a/plat/nvidia/tegra/soc/t186/drivers/mce/mce.c b/plat/nvidia/tegra/soc/t186/drivers/mce/mce.c
index 1353b6a..712519f 100644
--- a/plat/nvidia/tegra/soc/t186/drivers/mce/mce.c
+++ b/plat/nvidia/tegra/soc/t186/drivers/mce/mce.c
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -12,11 +12,11 @@
#include <context_mgmt.h>
#include <debug.h>
#include <denver.h>
+#include <errno.h>
#include <mce.h>
#include <mce_private.h>
#include <mmio.h>
#include <string.h>
-#include <sys/errno.h>
#include <t18x_ari.h>
#include <tegra_def.h>
#include <tegra_platform.h>
diff --git a/plat/nvidia/tegra/soc/t186/drivers/mce/nvg.c b/plat/nvidia/tegra/soc/t186/drivers/mce/nvg.c
index 243c8f3..857cfbb 100644
--- a/plat/nvidia/tegra/soc/t186/drivers/mce/nvg.c
+++ b/plat/nvidia/tegra/soc/t186/drivers/mce/nvg.c
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -8,9 +8,9 @@
#include <arch_helpers.h>
#include <debug.h>
#include <denver.h>
+#include <errno.h>
#include <mce_private.h>
#include <mmio.h>
-#include <sys/errno.h>
#include <t18x_ari.h>
int32_t nvg_enter_cstate(uint32_t ari_base, uint32_t state, uint32_t wake_time)
diff --git a/plat/nvidia/tegra/soc/t186/plat_psci_handlers.c b/plat/nvidia/tegra/soc/t186/plat_psci_handlers.c
index 095614e..6eb18fa 100644
--- a/plat/nvidia/tegra/soc/t186/plat_psci_handlers.c
+++ b/plat/nvidia/tegra/soc/t186/plat_psci_handlers.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -20,6 +20,8 @@
#include <t18x_ari.h>
#include <tegra_private.h>
+extern void memcpy16(void *dest, const void *src, unsigned int length);
+
extern void prepare_cpu_pwr_dwn(void);
extern void tegra186_cpu_reset_handler(void);
extern uint32_t __tegra186_cpu_reset_handler_end,
diff --git a/plat/nvidia/tegra/soc/t186/plat_secondary.c b/plat/nvidia/tegra/soc/t186/plat_secondary.c
index 52daab2..ebc2b46 100644
--- a/plat/nvidia/tegra/soc/t186/plat_secondary.c
+++ b/plat/nvidia/tegra/soc/t186/plat_secondary.c
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -21,6 +21,8 @@
#define CPU_RESET_MODE_AA64 1
+extern void memcpy16(void *dest, const void *src, unsigned int length);
+
extern uint64_t tegra_bl31_phys_base;
extern uint64_t __tegra186_cpu_reset_handler_end;
diff --git a/plat/qemu/qemu_private.h b/plat/qemu/qemu_private.h
index 800fa03..0fb7cd5 100644
--- a/plat/qemu/qemu_private.h
+++ b/plat/qemu/qemu_private.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -7,9 +7,8 @@
#ifndef __QEMU_PRIVATE_H
#define __QEMU_PRIVATE_H
-#include <sys/types.h>
+#include <stdint.h>
-#include <xlat_tables_defs.h>
#include "../../bl1/bl1_private.h"
void qemu_configure_mmu_secure(unsigned long total_base,
diff --git a/plat/qemu/topology.c b/plat/qemu/topology.c
index d7ba9b7..569d15f 100644
--- a/plat/qemu/topology.c
+++ b/plat/qemu/topology.c
@@ -1,12 +1,12 @@
/*
- * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <arch.h>
#include <platform_def.h>
-#include <sys/types.h>
+#include <stdint.h>
#include "qemu_private.h"
/* The power domain tree descriptor */
diff --git a/plat/rockchip/common/aarch64/plat_helpers.S b/plat/rockchip/common/aarch64/plat_helpers.S
index f415f87..f0136b0 100644
--- a/plat/rockchip/common/aarch64/plat_helpers.S
+++ b/plat/rockchip/common/aarch64/plat_helpers.S
@@ -18,7 +18,7 @@
.globl platform_cpu_warmboot
.globl plat_secondary_cold_boot_setup
.globl plat_report_exception
- .globl platform_is_primary_cpu
+ .globl plat_is_my_cpu_primary
.globl plat_my_core_pos
.globl plat_reset_handler
.globl plat_panic_handler
@@ -73,12 +73,13 @@
b cb_panic
endfunc plat_secondary_cold_boot_setup
-func platform_is_primary_cpu
+func plat_is_my_cpu_primary
+ mrs x0, mpidr_el1
and x0, x0, #(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)
cmp x0, #PLAT_RK_PRIMARY_CPU
cset x0, eq
ret
-endfunc platform_is_primary_cpu
+endfunc plat_is_my_cpu_primary
/* --------------------------------------------------------------------
* void plat_panic_handler(void)
diff --git a/plat/rockchip/rk3399/drivers/dp/cdn_dp.c b/plat/rockchip/rk3399/drivers/dp/cdn_dp.c
index f1a5e2b..2adab8f 100644
--- a/plat/rockchip/rk3399/drivers/dp/cdn_dp.c
+++ b/plat/rockchip/rk3399/drivers/dp/cdn_dp.c
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <cdefs.h>
#include <cdn_dp.h>
#include <smccc.h>
#include <stdlib.h>
diff --git a/plat/rpi3/include/platform_def.h b/plat/rpi3/include/platform_def.h
index 1950376..76a5ff4 100644
--- a/plat/rpi3/include/platform_def.h
+++ b/plat/rpi3/include/platform_def.h
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -215,7 +215,8 @@
/*
* Other memory-related defines.
*/
-#define ADDR_SPACE_SIZE (ULL(1) << 32)
+#define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 32)
+#define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 32)
#define MAX_MMAP_REGIONS 8
#define MAX_XLAT_TABLES 4
diff --git a/plat/rpi3/platform.mk b/plat/rpi3/platform.mk
index 55201ef..d6d0d56 100644
--- a/plat/rpi3/platform.mk
+++ b/plat/rpi3/platform.mk
@@ -33,7 +33,7 @@
plat/rpi3/rpi3_io_storage.c
BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
- plat/common/aarch64/plat_psci_common.c \
+ plat/common/plat_psci_common.c \
plat/rpi3/aarch64/plat_helpers.S \
plat/rpi3/rpi3_bl31_setup.c \
plat/rpi3/rpi3_pm.c \
diff --git a/plat/rpi3/rpi3_bl2_setup.c b/plat/rpi3/rpi3_bl2_setup.c
index 13e8c01..c78024e 100644
--- a/plat/rpi3/rpi3_bl2_setup.c
+++ b/plat/rpi3/rpi3_bl2_setup.c
@@ -24,8 +24,12 @@
* in x0. This memory layout is sitting at the base of the free trusted SRAM.
* Copy it to a safe location before its reclaimed by later BL2 functionality.
******************************************************************************/
-void bl2_early_platform_setup(meminfo_t *mem_layout)
+
+void bl2_early_platform_setup2(u_register_t arg0, u_register_t arg1,
+ u_register_t arg2, u_register_t arg3)
{
+ meminfo_t *mem_layout = (meminfo_t *) arg1;
+
/* Initialize the console to provide early debug support */
rpi3_console_init();
diff --git a/plat/rpi3/rpi3_bl31_setup.c b/plat/rpi3/rpi3_bl31_setup.c
index 5bbb13c..306f26b 100644
--- a/plat/rpi3/rpi3_bl31_setup.c
+++ b/plat/rpi3/rpi3_bl31_setup.c
@@ -53,23 +53,21 @@
* tables. BL2 has flushed this information to memory, so we are guaranteed
* to pick up good data.
******************************************************************************/
-void bl31_early_platform_setup(void *from_bl2,
- void *plat_params_from_bl2)
+void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
+ u_register_t arg2, u_register_t arg3)
+
{
/* Initialize the console to provide early debug support */
rpi3_console_init();
/*
- * In debug builds, we pass a special value in 'plat_params_from_bl2'
- * to verify platform parameters from BL2 to BL31.
- * In release builds, it's not used.
+ * In debug builds, a special value is passed in 'arg1' to verify
+ * platform parameters from BL2 to BL31. Not used in release builds.
*/
- assert(((uintptr_t)plat_params_from_bl2) == RPI3_BL31_PLAT_PARAM_VAL);
+ assert(arg1 == RPI3_BL31_PLAT_PARAM_VAL);
- /*
- * Check params passed from BL2 should not be NULL,
- */
- bl_params_t *params_from_bl2 = (bl_params_t *)from_bl2;
+ /* Check that params passed from BL2 are not NULL. */
+ bl_params_t *params_from_bl2 = (bl_params_t *) arg0;
assert(params_from_bl2 != NULL);
assert(params_from_bl2->h.type == PARAM_BL_PARAMS);
diff --git a/plat/rpi3/rpi3_private.h b/plat/rpi3/rpi3_private.h
index 91b7add..368d09b 100644
--- a/plat/rpi3/rpi3_private.h
+++ b/plat/rpi3/rpi3_private.h
@@ -7,7 +7,7 @@
#ifndef __RPI3_PRIVATE_H__
#define __RPI3_PRIVATE_H__
-#include <sys/types.h>
+#include <stdint.h>
/*******************************************************************************
* Function and variable prototypes
diff --git a/plat/rpi3/rpi3_stack_protector.c b/plat/rpi3/rpi3_stack_protector.c
index d939cd3..812f6ed 100644
--- a/plat/rpi3/rpi3_stack_protector.c
+++ b/plat/rpi3/rpi3_stack_protector.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <sys/types.h>
+#include <stdint.h>
#include <utils.h>
#include "rpi3_private.h"
diff --git a/plat/rpi3/rpi3_topology.c b/plat/rpi3/rpi3_topology.c
index 0e03ec3..31a22a4 100644
--- a/plat/rpi3/rpi3_topology.c
+++ b/plat/rpi3/rpi3_topology.c
@@ -1,12 +1,12 @@
/*
- * 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
*/
#include <arch.h>
#include <platform_def.h>
-#include <sys/types.h>
+#include <stdint.h>
#include "rpi3_private.h"
diff --git a/plat/socionext/synquacer/include/sq_common.h b/plat/socionext/synquacer/include/sq_common.h
index 58b1e24..7f0633a 100644
--- a/plat/socionext/synquacer/include/sq_common.h
+++ b/plat/socionext/synquacer/include/sq_common.h
@@ -7,7 +7,7 @@
#ifndef __SQ_COMMON_H__
#define __SQ_COMMON_H__
-#include <sys/types.h>
+#include <stdint.h>
#include <xlat_tables_v2.h>
struct draminfo {
diff --git a/plat/socionext/uniphier/uniphier.h b/plat/socionext/uniphier/uniphier.h
index 1768e3b..7ff1464 100644
--- a/plat/socionext/uniphier/uniphier.h
+++ b/plat/socionext/uniphier/uniphier.h
@@ -8,7 +8,7 @@
#define __UNIPHIER_H__
#include <stdint.h>
-#include <types.h>
+#include <string.h>
unsigned int uniphier_get_soc_type(void);
unsigned int uniphier_get_soc_model(void);
diff --git a/plat/socionext/uniphier/uniphier_emmc.c b/plat/socionext/uniphier/uniphier_emmc.c
index fcd4cb4..db87637 100644
--- a/plat/socionext/uniphier/uniphier_emmc.c
+++ b/plat/socionext/uniphier/uniphier_emmc.c
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -9,7 +9,7 @@
#include <io/io_block.h>
#include <mmio.h>
#include <platform_def.h>
-#include <sys/types.h>
+#include <stdint.h>
#include <utils_def.h>
#include "uniphier.h"
diff --git a/plat/socionext/uniphier/uniphier_io_storage.c b/plat/socionext/uniphier/uniphier_io_storage.c
index ed1f6fa..1fd835b 100644
--- a/plat/socionext/uniphier/uniphier_io_storage.c
+++ b/plat/socionext/uniphier/uniphier_io_storage.c
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -12,7 +12,7 @@
#include <io/io_fip.h>
#include <io/io_memmap.h>
#include <platform_def.h>
-#include <types.h>
+#include <stdint.h>
#include <utils_def.h>
#include <xlat_tables_v2.h>
diff --git a/plat/socionext/uniphier/uniphier_nand.c b/plat/socionext/uniphier/uniphier_nand.c
index a118b85..c8e825d 100644
--- a/plat/socionext/uniphier/uniphier_nand.c
+++ b/plat/socionext/uniphier/uniphier_nand.c
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -9,7 +9,7 @@
#include <io/io_block.h>
#include <mmio.h>
#include <platform_def.h>
-#include <sys/types.h>
+#include <stdint.h>
#include <utils_def.h>
#include "uniphier.h"
diff --git a/plat/socionext/uniphier/uniphier_usb.c b/plat/socionext/uniphier/uniphier_usb.c
index 4be0e90..b51b601 100644
--- a/plat/socionext/uniphier/uniphier_usb.c
+++ b/plat/socionext/uniphier/uniphier_usb.c
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -9,7 +9,7 @@
#include <io/io_block.h>
#include <mmio.h>
#include <platform_def.h>
-#include <sys/types.h>
+#include <stdint.h>
#include <utils_def.h>
#include "uniphier.h"
diff --git a/readme.rst b/readme.rst
index 4897f36..26e1fde 100644
--- a/readme.rst
+++ b/readme.rst
@@ -30,8 +30,9 @@
This project contains code from other projects as listed below. The original
license text is included in those source files.
-- The stdlib source code is derived from FreeBSD code, which uses various
- BSD licenses, including BSD-3-Clause and BSD-2-Clause.
+- The libc source code is derived from `FreeBSD`_ and `SCC`_. FreeBSD uses
+ various BSD licenses, including BSD-3-Clause and BSD-2-Clause. The SCC code
+ is used under the BSD-3-Clause license with the author's permission.
- The libfdt source code is disjunctively dual licensed
(GPL-2.0+ OR BSD-2-Clause). It is used by this project under the terms of
@@ -275,3 +276,5 @@
.. _Change Log: ./docs/change-log.rst
.. _User Guide: ./docs/user-guide.rst
.. _Porting Guide: ./docs/porting-guide.rst
+.. _FreeBSD: http://www.freebsd.org
+.. _SCC: http://www.simple-cc.org/
diff --git a/services/spd/trusty/generic-arm64-smcall.c b/services/spd/trusty/generic-arm64-smcall.c
index 1362c1c..6f766c4 100644
--- a/services/spd/trusty/generic-arm64-smcall.c
+++ b/services/spd/trusty/generic-arm64-smcall.c
@@ -6,6 +6,7 @@
#include <debug.h>
#include <runtime_svc.h>
+#include <stdio.h>
#include "generic-arm64-smcall.h"
@@ -29,14 +30,14 @@
s->linebuf[s->l++] = ch;
if (s->l == sizeof(s->linebuf) || ch == '\n') {
if (secure)
- tf_printf("secure os: ");
+ printf("secure os: ");
else
- tf_printf("non-secure os: ");
+ printf("non-secure os: ");
for (i = 0; i < s->l; i++) {
putchar(s->linebuf[i]);
}
if (ch != '\n') {
- tf_printf(" <...>\n");
+ printf(" <...>\n");
}
s->l = 0;
}
diff --git a/services/std_svc/sdei/sdei_event.c b/services/std_svc/sdei/sdei_event.c
index bf0e779..ec69b9d 100644
--- a/services/std_svc/sdei/sdei_event.c
+++ b/services/std_svc/sdei/sdei_event.c
@@ -1,5 +1,5 @@
/*
- * 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
*/
@@ -21,7 +21,8 @@
{
const sdei_mapping_t *mapping;
sdei_entry_t *cpu_priv_base;
- unsigned int idx, base_idx;
+ unsigned int base_idx;
+ long int idx;
if (is_event_private(map)) {
/*
@@ -32,7 +33,7 @@
idx = MAP_OFF(map, mapping);
/* Base of private mappings for this CPU */
- base_idx = plat_my_core_pos() * mapping->num_maps;
+ base_idx = plat_my_core_pos() * ((unsigned int) mapping->num_maps);
cpu_priv_base = &sdei_private_event_table[base_idx];
/*
@@ -52,7 +53,7 @@
* Find event mapping for a given interrupt number: On success, returns pointer
* to the event mapping. On error, returns NULL.
*/
-sdei_ev_map_t *find_event_map_by_intr(int intr_num, int shared)
+sdei_ev_map_t *find_event_map_by_intr(unsigned int intr_num, bool shared)
{
const sdei_mapping_t *mapping;
sdei_ev_map_t *map;
diff --git a/services/std_svc/sdei/sdei_intr_mgmt.c b/services/std_svc/sdei/sdei_intr_mgmt.c
index a37188a..e834a2b 100644
--- a/services/std_svc/sdei/sdei_intr_mgmt.c
+++ b/services/std_svc/sdei/sdei_intr_mgmt.c
@@ -16,17 +16,14 @@
#include <string.h>
#include "sdei_private.h"
-#define PE_MASKED 1
-#define PE_NOT_MASKED 0
-
/* x0-x17 GPREGS context */
-#define SDEI_SAVED_GPREGS 18
+#define SDEI_SAVED_GPREGS 18U
/* Maximum preemption nesting levels: Critical priority and Normal priority */
-#define MAX_EVENT_NESTING 2
+#define MAX_EVENT_NESTING 2U
/* Per-CPU SDEI state access macro */
-#define sdei_get_this_pe_state() (&sdei_cpu_state[plat_my_core_pos()])
+#define sdei_get_this_pe_state() (&cpu_state[plat_my_core_pos()])
/* Structure to store information about an outstanding dispatch */
typedef struct sdei_dispatch_context {
@@ -48,31 +45,33 @@
typedef struct sdei_cpu_state {
sdei_dispatch_context_t dispatch_stack[MAX_EVENT_NESTING];
unsigned short stack_top; /* Empty ascending */
- unsigned int pe_masked:1;
- unsigned int pending_enables:1;
+ bool pe_masked;
+ bool pending_enables;
} sdei_cpu_state_t;
/* SDEI states for all cores in the system */
-static sdei_cpu_state_t sdei_cpu_state[PLATFORM_CORE_COUNT];
+static sdei_cpu_state_t cpu_state[PLATFORM_CORE_COUNT];
-unsigned int sdei_pe_mask(void)
+int64_t sdei_pe_mask(void)
{
- unsigned int ret;
+ int64_t ret = 0;
sdei_cpu_state_t *state = sdei_get_this_pe_state();
/*
* Return value indicates whether this call had any effect in the mask
* status of this PE.
*/
- ret = (state->pe_masked ^ PE_MASKED);
- state->pe_masked = PE_MASKED;
+ if (!state->pe_masked) {
+ state->pe_masked = true;
+ ret = 1;
+ }
return ret;
}
void sdei_pe_unmask(void)
{
- int i;
+ unsigned int i;
sdei_ev_map_t *map;
sdei_entry_t *se;
sdei_cpu_state_t *state = sdei_get_this_pe_state();
@@ -95,8 +94,7 @@
se = get_event_entry(map);
sdei_map_lock(map);
- if (is_map_bound(map) &&
- GET_EV_STATE(se, ENABLED) &&
+ if (is_map_bound(map) && GET_EV_STATE(se, ENABLED) &&
(se->reg_flags == SDEI_REGF_RM_PE) &&
(se->affinity == my_mpidr)) {
plat_ic_enable_interrupt(map->intr);
@@ -105,8 +103,8 @@
}
}
- state->pending_enables = 0;
- state->pe_masked = PE_NOT_MASKED;
+ state->pending_enables = false;
+ state->pe_masked = false;
}
/* Push a dispatch context to the dispatch stack */
@@ -129,7 +127,7 @@
{
sdei_cpu_state_t *state = sdei_get_this_pe_state();
- if (state->stack_top == 0)
+ if (state->stack_top == 0U)
return NULL;
assert(state->stack_top <= MAX_EVENT_NESTING);
@@ -144,27 +142,27 @@
{
sdei_cpu_state_t *state = sdei_get_this_pe_state();
- if (state->stack_top == 0)
+ if (state->stack_top == 0U)
return NULL;
assert(state->stack_top <= MAX_EVENT_NESTING);
- return &state->dispatch_stack[state->stack_top - 1];
+ return &state->dispatch_stack[state->stack_top - 1U];
}
static sdei_dispatch_context_t *save_event_ctx(sdei_ev_map_t *map,
void *tgt_ctx)
{
sdei_dispatch_context_t *disp_ctx;
- gp_regs_t *tgt_gpregs;
- el3_state_t *tgt_el3;
+ const gp_regs_t *tgt_gpregs;
+ const el3_state_t *tgt_el3;
- assert(tgt_ctx);
+ assert(tgt_ctx != NULL);
tgt_gpregs = get_gpregs_ctx(tgt_ctx);
tgt_el3 = get_el3state_ctx(tgt_ctx);
disp_ctx = push_dispatch();
- assert(disp_ctx);
+ assert(disp_ctx != NULL);
disp_ctx->map = map;
/* Save general purpose and exception registers */
@@ -175,12 +173,12 @@
return disp_ctx;
}
-static void restore_event_ctx(sdei_dispatch_context_t *disp_ctx, void *tgt_ctx)
+static void restore_event_ctx(const sdei_dispatch_context_t *disp_ctx, void *tgt_ctx)
{
gp_regs_t *tgt_gpregs;
el3_state_t *tgt_el3;
- assert(tgt_ctx);
+ assert(tgt_ctx != NULL);
tgt_gpregs = get_gpregs_ctx(tgt_ctx);
tgt_el3 = get_el3state_ctx(tgt_ctx);
@@ -226,7 +224,7 @@
cm_set_next_eret_context(NON_SECURE);
ns_ctx = cm_get_context(NON_SECURE);
- assert(ns_ctx);
+ assert(ns_ctx != NULL);
return ns_ctx;
}
@@ -251,7 +249,7 @@
* - x2: Interrupted PC
* - x3: Interrupted SPSR
*/
- SMC_SET_GP(ctx, CTX_GPREG_X0, map->ev_num);
+ SMC_SET_GP(ctx, CTX_GPREG_X0, (uint64_t) map->ev_num);
SMC_SET_GP(ctx, CTX_GPREG_X1, se->arg);
SMC_SET_GP(ctx, CTX_GPREG_X2, disp_ctx->elr_el3);
SMC_SET_GP(ctx, CTX_GPREG_X3, disp_ctx->spsr_el3);
@@ -286,7 +284,7 @@
sdei_cpu_state_t *state, unsigned int intr_raw)
{
uint64_t my_mpidr __unused = (read_mpidr_el1() & MPIDR_AFFINITY_MASK);
- int disable = 0;
+ bool disable = false;
/* Nothing to do for event 0 */
if (map->ev_num == SDEI_EVENT_0)
@@ -297,18 +295,17 @@
* this CPU, we disable interrupt, leave the interrupt pending, and do
* EOI.
*/
- if (is_event_private(map)) {
- disable = 1;
- } else if (se->reg_flags == SDEI_REGF_RM_PE) {
+ if (is_event_private(map) || (se->reg_flags == SDEI_REGF_RM_PE))
+ disable = true;
+
+ if (se->reg_flags == SDEI_REGF_RM_PE)
assert(se->affinity == my_mpidr);
- disable = 1;
- }
if (disable) {
plat_ic_disable_interrupt(map->intr);
plat_ic_set_interrupt_pending(map->intr);
plat_ic_end_of_interrupt(intr_raw);
- state->pending_enables = 1;
+ state->pending_enables = true;
return;
}
@@ -321,7 +318,7 @@
* Therefore, we set the interrupt back pending so as to give other
* suitable PEs a chance of handling it.
*/
- assert(plat_ic_is_spi(map->intr));
+ assert(plat_ic_is_spi(map->intr) != 0);
plat_ic_set_interrupt_pending(map->intr);
/*
@@ -344,11 +341,12 @@
sdei_entry_t *se;
cpu_context_t *ctx;
sdei_ev_map_t *map;
- sdei_dispatch_context_t *disp_ctx;
+ const sdei_dispatch_context_t *disp_ctx;
unsigned int sec_state;
sdei_cpu_state_t *state;
uint32_t intr;
struct jmpbuf dispatch_jmp;
+ const uint64_t mpidr = read_mpidr_el1();
/*
* To handle an event, the following conditions must be true:
@@ -374,8 +372,8 @@
* this interrupt
*/
intr = plat_ic_get_interrupt_id(intr_raw);
- map = find_event_map_by_intr(intr, plat_ic_is_spi(intr));
- if (!map) {
+ map = find_event_map_by_intr(intr, (plat_ic_is_spi(intr) != 0));
+ if (map == NULL) {
ERROR("No SDEI map for interrupt %u\n", intr);
panic();
}
@@ -389,13 +387,13 @@
se = get_event_entry(map);
state = sdei_get_this_pe_state();
- if (state->pe_masked == PE_MASKED) {
+ if (state->pe_masked) {
/*
* Interrupts received while this PE was masked can't be
* dispatched.
*/
- SDEI_LOG("interrupt %u on %lx while PE masked\n", map->intr,
- read_mpidr_el1());
+ SDEI_LOG("interrupt %u on %llx while PE masked\n", map->intr,
+ mpidr);
if (is_event_shared(map))
sdei_map_lock(map);
@@ -416,8 +414,7 @@
/* Assert shared event routed to this PE had been configured so */
if (is_event_shared(map) && (se->reg_flags == SDEI_REGF_RM_PE)) {
- assert(se->affinity ==
- (read_mpidr_el1() & MPIDR_AFFINITY_MASK));
+ assert(se->affinity == (mpidr & MPIDR_AFFINITY_MASK));
}
if (!can_sdei_state_trans(se, DO_DISPATCH)) {
@@ -451,7 +448,7 @@
* dispatch, assert the latter is a Normal dispatch. Critical
* events can preempt an outstanding Normal event dispatch.
*/
- if (disp_ctx)
+ if (disp_ctx != NULL)
assert(is_event_normal(disp_ctx->map));
} else {
/*
@@ -467,9 +464,8 @@
if (is_event_shared(map))
sdei_map_unlock(map);
- SDEI_LOG("ACK %lx, ev:%d ss:%d spsr:%lx ELR:%lx\n", read_mpidr_el1(),
- map->ev_num, sec_state, read_spsr_el3(),
- read_elr_el3());
+ SDEI_LOG("ACK %llx, ev:%d ss:%d spsr:%lx ELR:%lx\n", mpidr, map->ev_num,
+ sec_state, read_spsr_el3(), read_elr_el3());
ctx = handle;
@@ -497,7 +493,7 @@
* Non-secure context was fully saved before dispatch, and has been
* returned to its pre-dispatch state.
*/
- if ((sec_state == SECURE) && (ehf_is_ns_preemption_allowed() == 0))
+ if ((sec_state == SECURE) && (ehf_is_ns_preemption_allowed() == 0U))
restore_and_resume_secure_context();
/*
@@ -511,9 +507,6 @@
}
plat_ic_end_of_interrupt(intr_raw);
- if (is_event_shared(map))
- sdei_map_unlock(map);
-
return 0;
}
@@ -539,7 +532,7 @@
/* Can't dispatch if events are masked on this PE */
state = sdei_get_this_pe_state();
- if (state->pe_masked == PE_MASKED)
+ if (state->pe_masked)
return -1;
/* Event 0 can't be dispatched */
@@ -548,7 +541,7 @@
/* Locate mapping corresponding to this event */
map = find_event_map(ev_num);
- if (!map)
+ if (map == NULL)
return -1;
/* Only explicit events can be dispatched */
@@ -557,7 +550,7 @@
/* Examine state of dispatch stack */
disp_ctx = get_outstanding_dispatch();
- if (disp_ctx) {
+ if (disp_ctx != NULL) {
/*
* There's an outstanding dispatch. If the outstanding dispatch
* is critical, no more dispatches are possible.
@@ -606,7 +599,7 @@
longjmp(buffer);
}
-int sdei_event_complete(int resume, uint64_t pc)
+int sdei_event_complete(bool resume, uint64_t pc)
{
sdei_dispatch_context_t *disp_ctx;
sdei_entry_t *se;
@@ -617,7 +610,7 @@
/* Return error if called without an active event */
disp_ctx = get_outstanding_dispatch();
- if (!disp_ctx)
+ if (disp_ctx == NULL)
return SDEI_EDENY;
/* Validate resumption point */
@@ -625,9 +618,12 @@
return SDEI_EDENY;
map = disp_ctx->map;
- assert(map);
+ assert(map != NULL);
se = get_event_entry(map);
+ if (is_event_shared(map))
+ sdei_map_lock(map);
+
act = resume ? DO_COMPLETE_RESUME : DO_COMPLETE;
if (!can_sdei_state_trans(se, act)) {
if (is_event_shared(map))
@@ -635,15 +631,15 @@
return SDEI_EDENY;
}
+ if (is_event_shared(map))
+ sdei_map_unlock(map);
+
/* Having done sanity checks, pop dispatch */
- pop_dispatch();
+ (void) pop_dispatch();
SDEI_LOG("EOI:%lx, %d spsr:%lx elr:%lx\n", read_mpidr_el1(),
map->ev_num, read_spsr_el3(), read_elr_el3());
- if (is_event_shared(map))
- sdei_map_lock(map);
-
/*
* Restore Non-secure to how it was originally interrupted. Once done,
* it's up-to-date with the saved copy.
@@ -684,7 +680,7 @@
return 0;
}
-int sdei_event_context(void *handle, unsigned int param)
+int64_t sdei_event_context(void *handle, unsigned int param)
{
sdei_dispatch_context_t *disp_ctx;
@@ -693,10 +689,10 @@
/* Get outstanding dispatch on this CPU */
disp_ctx = get_outstanding_dispatch();
- if (!disp_ctx)
+ if (disp_ctx == NULL)
return SDEI_EDENY;
- assert(disp_ctx->map);
+ assert(disp_ctx->map != NULL);
if (!can_sdei_state_trans(get_event_entry(disp_ctx->map), DO_CONTEXT))
return SDEI_EDENY;
@@ -706,5 +702,5 @@
* which can complete the event
*/
- return disp_ctx->x[param];
+ return (int64_t) disp_ctx->x[param];
}
diff --git a/services/std_svc/sdei/sdei_main.c b/services/std_svc/sdei/sdei_main.c
index 28afc1d..9b78d7f 100644
--- a/services/std_svc/sdei/sdei_main.c
+++ b/services/std_svc/sdei/sdei_main.c
@@ -22,14 +22,12 @@
#include <utils.h>
#include "sdei_private.h"
-#define MAJOR_VERSION 1
-#define MINOR_VERSION 0
-#define VENDOR_VERSION 0
+#define MAJOR_VERSION 1ULL
+#define MINOR_VERSION 0ULL
+#define VENDOR_VERSION 0ULL
#define MAKE_SDEI_VERSION(_major, _minor, _vendor) \
- ((((unsigned long long)(_major)) << 48) | \
- (((unsigned long long)(_minor)) << 32) | \
- (_vendor))
+ ((((_major)) << 48ULL) | (((_minor)) << 32ULL) | (_vendor))
#define LOWEST_INTR_PRIORITY 0xff
@@ -47,7 +45,7 @@
}
/* Convert mapping to SDEI class */
-sdei_class_t map_to_class(sdei_ev_map_t *map)
+static sdei_class_t map_to_class(sdei_ev_map_t *map)
{
return is_event_critical(map) ? SDEI_CRITICAL : SDEI_NORMAL;
}
@@ -64,7 +62,7 @@
/* Perform CPU-specific state initialisation */
static void *sdei_cpu_on_init(const void *arg)
{
- int i;
+ unsigned int i;
sdei_ev_map_t *map;
sdei_entry_t *se;
@@ -78,15 +76,16 @@
SDEI_LOG("Private events initialized on %lx\n", read_mpidr_el1());
/* All PEs start with SDEI events masked */
- sdei_pe_mask();
+ (void) sdei_pe_mask();
- return 0;
+ return NULL;
}
/* Initialise an SDEI class */
-void sdei_class_init(sdei_class_t class)
+static void sdei_class_init(sdei_class_t class)
{
- unsigned int i, zero_found __unused = 0;
+ unsigned int i;
+ bool zero_found __unused = false;
int ev_num_so_far __unused;
sdei_ev_map_t *map;
@@ -126,7 +125,7 @@
num_dyn_shrd_slots++;
} else {
/* Shared mappings must be bound to shared interrupt */
- assert(plat_ic_is_spi(map->intr));
+ assert(plat_ic_is_spi(map->intr) != 0);
set_map_bound(map);
}
@@ -143,7 +142,7 @@
ev_num_so_far = map->ev_num;
if (map->ev_num == SDEI_EVENT_0) {
- zero_found = 1;
+ zero_found = true;
/* Event 0 must be a Secure SGI */
assert(is_secure_sgi(map->intr));
@@ -197,7 +196,7 @@
* Private mappings must be bound to private
* interrupt.
*/
- assert(plat_ic_is_ppi(map->intr));
+ assert(plat_ic_is_ppi((unsigned) map->intr) != 0);
set_map_bound(map);
}
}
@@ -208,7 +207,7 @@
/* Ensure event 0 is in the mapping */
assert(zero_found);
- sdei_cpu_on_init(NULL);
+ (void) sdei_cpu_on_init(NULL);
}
/* SDEI dispatcher initialisation */
@@ -236,7 +235,7 @@
se->reg_flags = flags;
}
-static unsigned long long sdei_version(void)
+static uint64_t sdei_version(void)
{
return MAKE_SDEI_VERSION(MAJOR_VERSION, MINOR_VERSION, VENDOR_VERSION);
}
@@ -263,17 +262,18 @@
/* Set routing of an SDEI event */
static int sdei_event_routing_set(int ev_num, uint64_t flags, uint64_t mpidr)
{
- int ret, routing;
+ int ret;
+ unsigned int routing;
sdei_ev_map_t *map;
sdei_entry_t *se;
ret = validate_flags(flags, mpidr);
- if (ret)
+ if (ret != 0)
return ret;
/* Check if valid event number */
map = find_event_map(ev_num);
- if (!map)
+ if (map == NULL)
return SDEI_EINVAL;
/* The event must not be private */
@@ -295,11 +295,11 @@
}
/* Choose appropriate routing */
- routing = (flags == SDEI_REGF_RM_ANY) ? INTR_ROUTING_MODE_ANY :
- INTR_ROUTING_MODE_PE;
+ routing = (unsigned int) ((flags == SDEI_REGF_RM_ANY) ?
+ INTR_ROUTING_MODE_ANY : INTR_ROUTING_MODE_PE);
/* Update event registration flag */
- se->reg_flags = flags;
+ se->reg_flags = (unsigned int) flags;
/*
* ROUTING_SET is permissible only when event composite state is
@@ -315,24 +315,27 @@
}
/* Register handler and argument for an SDEI event */
-static int sdei_event_register(int ev_num, uint64_t ep, uint64_t arg,
+static int64_t sdei_event_register(int ev_num, uint64_t ep, uint64_t arg,
uint64_t flags, uint64_t mpidr)
{
int ret;
+ unsigned int routing;
sdei_entry_t *se;
sdei_ev_map_t *map;
sdei_state_t backup_state;
- if (!ep || (plat_sdei_validate_entry_point(ep, sdei_client_el()) != 0))
+ if ((ep == 0U) || (plat_sdei_validate_entry_point(
+ ep, sdei_client_el()) != 0)) {
return SDEI_EINVAL;
+ }
ret = validate_flags(flags, mpidr);
- if (ret)
+ if (ret != 0)
return ret;
/* Check if valid event number */
map = find_event_map(ev_num);
- if (!map)
+ if (map == NULL)
return SDEI_EINVAL;
/* Private events always target the PE */
@@ -371,7 +374,7 @@
if (is_map_bound(map)) {
/* Meanwhile, did any PE ACK the interrupt? */
- if (plat_ic_get_interrupt_active(map->intr))
+ if (plat_ic_get_interrupt_active(map->intr) != 0U)
goto fallback;
/* The interrupt must currently owned by Non-secure */
@@ -404,16 +407,15 @@
* already ensure that shared events get bound to SPIs.
*/
if (is_event_shared(map)) {
- plat_ic_set_spi_routing(map->intr,
- ((flags == SDEI_REGF_RM_ANY) ?
- INTR_ROUTING_MODE_ANY :
- INTR_ROUTING_MODE_PE),
+ routing = (unsigned int) ((flags == SDEI_REGF_RM_ANY) ?
+ INTR_ROUTING_MODE_ANY : INTR_ROUTING_MODE_PE);
+ plat_ic_set_spi_routing(map->intr, routing,
(u_register_t) mpidr);
}
}
/* Populate event entries */
- set_sdei_entry(se, ep, arg, flags, mpidr);
+ set_sdei_entry(se, ep, arg, (unsigned int) flags, mpidr);
/* Increment register count */
map->reg_count++;
@@ -432,15 +434,16 @@
}
/* Enable SDEI event */
-static int sdei_event_enable(int ev_num)
+static int64_t sdei_event_enable(int ev_num)
{
sdei_ev_map_t *map;
sdei_entry_t *se;
- int ret, before, after;
+ int ret;
+ bool before, after;
/* Check if valid event number */
map = find_event_map(ev_num);
- if (!map)
+ if (map == NULL)
return SDEI_EINVAL;
se = get_event_entry(map);
@@ -475,11 +478,12 @@
{
sdei_ev_map_t *map;
sdei_entry_t *se;
- int ret, before, after;
+ int ret;
+ bool before, after;
/* Check if valid event number */
map = find_event_map(ev_num);
- if (!map)
+ if (map == NULL)
return SDEI_EINVAL;
se = get_event_entry(map);
@@ -510,17 +514,18 @@
}
/* Query SDEI event information */
-static uint64_t sdei_event_get_info(int ev_num, int info)
+static int64_t sdei_event_get_info(int ev_num, int info)
{
sdei_entry_t *se;
sdei_ev_map_t *map;
- unsigned int flags, registered;
+ uint64_t flags;
+ bool registered;
uint64_t affinity;
/* Check if valid event number */
map = find_event_map(ev_num);
- if (!map)
+ if (map == NULL)
return SDEI_EINVAL;
se = get_event_entry(map);
@@ -576,7 +581,7 @@
/* Check if valid event number */
map = find_event_map(ev_num);
- if (!map)
+ if (map == NULL)
return SDEI_EINVAL;
se = get_event_entry(map);
@@ -648,7 +653,7 @@
/* Check if valid event number */
map = find_event_map(ev_num);
- if (!map)
+ if (map == NULL)
return SDEI_EINVAL;
se = get_event_entry(map);
@@ -662,27 +667,27 @@
if (is_event_shared(map))
sdei_map_unlock(map);
- return state;
+ return (int) state;
}
/* Bind an SDEI event to an interrupt */
-static int sdei_interrupt_bind(int intr_num)
+static int sdei_interrupt_bind(unsigned int intr_num)
{
sdei_ev_map_t *map;
- int retry = 1, shared_mapping;
+ bool retry = true, shared_mapping;
/* SGIs are not allowed to be bound */
- if (plat_ic_is_sgi(intr_num))
+ if (plat_ic_is_sgi(intr_num) != 0)
return SDEI_EINVAL;
- shared_mapping = plat_ic_is_spi(intr_num);
+ shared_mapping = (plat_ic_is_spi(intr_num) != 0);
do {
/*
* Bail out if there is already an event for this interrupt,
* either platform-defined or dynamic.
*/
map = find_event_map_by_intr(intr_num, shared_mapping);
- if (map) {
+ if (map != NULL) {
if (is_map_dynamic(map)) {
if (is_map_bound(map)) {
/*
@@ -703,7 +708,7 @@
* SDEI_DYN_IRQ.
*/
map = find_event_map_by_intr(SDEI_DYN_IRQ, shared_mapping);
- if (!map)
+ if (map == NULL)
return SDEI_ENOMEM;
/* The returned mapping must be dynamic */
@@ -727,7 +732,7 @@
if (!is_map_bound(map)) {
map->intr = intr_num;
set_map_bound(map);
- retry = 0;
+ retry = false;
}
sdei_map_unlock(map);
} while (retry);
@@ -744,7 +749,7 @@
/* Check if valid event number */
map = find_event_map(ev_num);
- if (!map)
+ if (map == NULL)
return SDEI_EINVAL;
if (!is_map_dynamic(map))
@@ -774,7 +779,7 @@
* Deny release if the interrupt is active, which means it's
* probably being acknowledged and handled elsewhere.
*/
- if (plat_ic_get_interrupt_active(map->intr)) {
+ if (plat_ic_get_interrupt_active(map->intr) != 0U) {
ret = SDEI_EDENY;
goto finish;
}
@@ -802,7 +807,8 @@
static int sdei_private_reset(void)
{
sdei_ev_map_t *map;
- int ret = 0, final_ret = 0, i;
+ int ret = 0, final_ret = 0;
+ unsigned int i;
/* Unregister all private events */
for_each_private_map(i, map) {
@@ -824,7 +830,8 @@
{
const sdei_mapping_t *mapping;
sdei_ev_map_t *map;
- int ret = 0, final_ret = 0, i, j;
+ int ret = 0, final_ret = 0;
+ unsigned int i, j;
/* Unregister all shared events */
for_each_shared_map(i, map) {
@@ -867,17 +874,17 @@
}
/* Send a signal to another SDEI client PE */
-int sdei_signal(int event, uint64_t target_pe)
+static int sdei_signal(int ev_num, uint64_t target_pe)
{
sdei_ev_map_t *map;
/* Only event 0 can be signalled */
- if (event != SDEI_EVENT_0)
+ if (ev_num != SDEI_EVENT_0)
return SDEI_EINVAL;
/* Find mapping for event 0 */
map = find_event_map(SDEI_EVENT_0);
- if (!map)
+ if (map == NULL)
return SDEI_EINVAL;
/* The event must be signalable */
@@ -889,20 +896,20 @@
return SDEI_EINVAL;
/* Raise SGI. Platform will validate target_pe */
- plat_ic_raise_el3_sgi(map->intr, (u_register_t) target_pe);
+ plat_ic_raise_el3_sgi((int) map->intr, (u_register_t) target_pe);
return 0;
}
/* Query SDEI dispatcher features */
-uint64_t sdei_features(unsigned int feature)
+static uint64_t sdei_features(unsigned int feature)
{
if (feature == SDEI_FEATURE_BIND_SLOTS) {
return FEATURE_BIND_SLOTS(num_dyn_priv_slots,
num_dyn_shrd_slots);
}
- return SDEI_EINVAL;
+ return (uint64_t) SDEI_EINVAL;
}
/* SDEI top level handler for servicing SMCs */
@@ -917,56 +924,59 @@
{
uint64_t x5;
- int ss = get_interrupt_src_ss(flags);
+ unsigned int ss = (unsigned int) get_interrupt_src_ss(flags);
int64_t ret;
- unsigned int resume = 0;
+ bool resume = false;
+ cpu_context_t *ctx = handle;
+ int ev_num = (int) x1;
if (ss != NON_SECURE)
- SMC_RET1(handle, SMC_UNK);
+ SMC_RET1(ctx, SMC_UNK);
/* Verify the caller EL */
if (GET_EL(read_spsr_el3()) != sdei_client_el())
- SMC_RET1(handle, SMC_UNK);
+ SMC_RET1(ctx, SMC_UNK);
switch (smc_fid) {
case SDEI_VERSION:
SDEI_LOG("> VER\n");
- ret = sdei_version();
+ ret = (int64_t) sdei_version();
SDEI_LOG("< VER:%llx\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
case SDEI_EVENT_REGISTER:
- x5 = SMC_GET_GP(handle, CTX_GPREG_X5);
- SDEI_LOG("> REG(n:%d e:%llx a:%llx f:%x m:%llx)\n", (int) x1,
+ x5 = SMC_GET_GP(ctx, CTX_GPREG_X5);
+ SDEI_LOG("> REG(n:%d e:%llx a:%llx f:%x m:%llx)\n", ev_num,
x2, x3, (int) x4, x5);
- ret = sdei_event_register(x1, x2, x3, x4, x5);
+ ret = sdei_event_register(ev_num, x2, x3, x4, x5);
SDEI_LOG("< REG:%lld\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
case SDEI_EVENT_ENABLE:
SDEI_LOG("> ENABLE(n:%d)\n", (int) x1);
- ret = sdei_event_enable(x1);
+ ret = sdei_event_enable(ev_num);
SDEI_LOG("< ENABLE:%lld\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
case SDEI_EVENT_DISABLE:
- SDEI_LOG("> DISABLE(n:%d)\n", (int) x1);
- ret = sdei_event_disable(x1);
+ SDEI_LOG("> DISABLE(n:%d)\n", ev_num);
+ ret = sdei_event_disable(ev_num);
SDEI_LOG("< DISABLE:%lld\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
case SDEI_EVENT_CONTEXT:
SDEI_LOG("> CTX(p:%d):%lx\n", (int) x1, read_mpidr_el1());
- ret = sdei_event_context(handle, x1);
+ ret = sdei_event_context(ctx, (unsigned int) x1);
SDEI_LOG("< CTX:%lld\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
case SDEI_EVENT_COMPLETE_AND_RESUME:
- resume = 1;
+ resume = true;
+ /* Fallthrough */
case SDEI_EVENT_COMPLETE:
- SDEI_LOG("> COMPLETE(r:%d sta/ep:%llx):%lx\n", resume, x1,
- read_mpidr_el1());
+ SDEI_LOG("> COMPLETE(r:%u sta/ep:%llx):%lx\n",
+ (unsigned int) resume, x1, read_mpidr_el1());
ret = sdei_event_complete(resume, x1);
SDEI_LOG("< COMPLETE:%llx\n", ret);
@@ -977,82 +987,82 @@
* shouldn't be modified. We don't return to the caller in this
* case anyway.
*/
- if (ret)
- SMC_RET1(handle, ret);
+ if (ret != 0)
+ SMC_RET1(ctx, ret);
- SMC_RET0(handle);
+ SMC_RET0(ctx);
case SDEI_EVENT_STATUS:
- SDEI_LOG("> STAT(n:%d)\n", (int) x1);
- ret = sdei_event_status(x1);
+ SDEI_LOG("> STAT(n:%d)\n", ev_num);
+ ret = sdei_event_status(ev_num);
SDEI_LOG("< STAT:%lld\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
case SDEI_EVENT_GET_INFO:
- SDEI_LOG("> INFO(n:%d, %d)\n", (int) x1, (int) x2);
- ret = sdei_event_get_info(x1, x2);
+ SDEI_LOG("> INFO(n:%d, %d)\n", ev_num, (int) x2);
+ ret = sdei_event_get_info(ev_num, (int) x2);
SDEI_LOG("< INFO:%lld\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
case SDEI_EVENT_UNREGISTER:
- SDEI_LOG("> UNREG(n:%d)\n", (int) x1);
- ret = sdei_event_unregister(x1);
+ SDEI_LOG("> UNREG(n:%d)\n", ev_num);
+ ret = sdei_event_unregister(ev_num);
SDEI_LOG("< UNREG:%lld\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
case SDEI_PE_UNMASK:
SDEI_LOG("> UNMASK:%lx\n", read_mpidr_el1());
sdei_pe_unmask();
SDEI_LOG("< UNMASK:%d\n", 0);
- SMC_RET1(handle, 0);
+ SMC_RET1(ctx, 0);
case SDEI_PE_MASK:
SDEI_LOG("> MASK:%lx\n", read_mpidr_el1());
ret = sdei_pe_mask();
SDEI_LOG("< MASK:%lld\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
case SDEI_INTERRUPT_BIND:
SDEI_LOG("> BIND(%d)\n", (int) x1);
- ret = sdei_interrupt_bind(x1);
+ ret = sdei_interrupt_bind((unsigned int) x1);
SDEI_LOG("< BIND:%lld\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
case SDEI_INTERRUPT_RELEASE:
- SDEI_LOG("> REL(%d)\n", (int) x1);
- ret = sdei_interrupt_release(x1);
+ SDEI_LOG("> REL(%d)\n", ev_num);
+ ret = sdei_interrupt_release(ev_num);
SDEI_LOG("< REL:%lld\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
case SDEI_SHARED_RESET:
SDEI_LOG("> S_RESET():%lx\n", read_mpidr_el1());
ret = sdei_shared_reset();
SDEI_LOG("< S_RESET:%lld\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
case SDEI_PRIVATE_RESET:
SDEI_LOG("> P_RESET():%lx\n", read_mpidr_el1());
ret = sdei_private_reset();
SDEI_LOG("< P_RESET:%lld\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
case SDEI_EVENT_ROUTING_SET:
- SDEI_LOG("> ROUTE_SET(n:%d f:%llx aff:%llx)\n", (int) x1, x2, x3);
- ret = sdei_event_routing_set(x1, x2, x3);
+ SDEI_LOG("> ROUTE_SET(n:%d f:%llx aff:%llx)\n", ev_num, x2, x3);
+ ret = sdei_event_routing_set(ev_num, x2, x3);
SDEI_LOG("< ROUTE_SET:%lld\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
case SDEI_FEATURES:
SDEI_LOG("> FTRS(f:%llx)\n", x1);
- ret = sdei_features(x1);
+ ret = (int64_t) sdei_features((unsigned int) x1);
SDEI_LOG("< FTRS:%llx\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
case SDEI_EVENT_SIGNAL:
- SDEI_LOG("> SIGNAL(e:%llx t:%llx)\n", x1, x2);
- ret = sdei_signal(x1, x2);
+ SDEI_LOG("> SIGNAL(e:%d t:%llx)\n", ev_num, x2);
+ ret = sdei_signal(ev_num, x2);
SDEI_LOG("< SIGNAL:%lld\n", ret);
- SMC_RET1(handle, ret);
+ SMC_RET1(ctx, ret);
default:
/* Do nothing in default case */
@@ -1060,7 +1070,7 @@
}
WARN("Unimplemented SDEI Call: 0x%x\n", smc_fid);
- SMC_RET1(handle, SMC_UNK);
+ SMC_RET1(ctx, SMC_UNK);
}
/* Subscribe to PSCI CPU on to initialize per-CPU SDEI configuration */
diff --git a/services/std_svc/sdei/sdei_private.h b/services/std_svc/sdei/sdei_private.h
index 874fc22..f5197c6 100644
--- a/services/std_svc/sdei/sdei_private.h
+++ b/services/std_svc/sdei/sdei_private.h
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __SDEI_PRIVATE_H__
-#define __SDEI_PRIVATE_H__
+#ifndef SDEI_PRIVATE_H
+#define SDEI_PRIVATE_H
#include <arch_helpers.h>
#include <context_mgmt.h>
@@ -17,7 +17,7 @@
#include <setjmp.h>
#include <spinlock.h>
#include <stdbool.h>
-#include <types.h>
+#include <stdint.h>
#include <utils_def.h>
#ifdef AARCH32
@@ -36,12 +36,12 @@
#define SDEI_LOG(...) VERBOSE("SDEI: " __VA_ARGS__)
/* SDEI handler unregistered state. This is the default state. */
-#define SDEI_STATE_UNREGISTERED 0
+#define SDEI_STATE_UNREGISTERED 0U
/* SDE event status values in bit position */
-#define SDEI_STATF_REGISTERED 0
-#define SDEI_STATF_ENABLED 1
-#define SDEI_STATF_RUNNING 2
+#define SDEI_STATF_REGISTERED 0U
+#define SDEI_STATF_ENABLED 1U
+#define SDEI_STATF_RUNNING 2U
/* SDEI SMC error codes */
#define SDEI_EINVAL (-2)
@@ -62,18 +62,18 @@
#define SDEI_INFO_EV_ROUTING_MODE 3
#define SDEI_INFO_EV_ROUTING_AFF 4
-#define SDEI_PRIVATE_MAPPING() (&sdei_global_mappings[_SDEI_MAP_IDX_PRIV])
-#define SDEI_SHARED_MAPPING() (&sdei_global_mappings[_SDEI_MAP_IDX_SHRD])
+#define SDEI_PRIVATE_MAPPING() (&sdei_global_mappings[SDEI_MAP_IDX_PRIV_])
+#define SDEI_SHARED_MAPPING() (&sdei_global_mappings[SDEI_MAP_IDX_SHRD_])
#define for_each_mapping_type(_i, _mapping) \
- for (_i = 0, _mapping = &sdei_global_mappings[i]; \
- _i < _SDEI_MAP_IDX_MAX; \
- _i++, _mapping = &sdei_global_mappings[i])
+ for ((_i) = 0, (_mapping) = &sdei_global_mappings[(_i)]; \
+ (_i) < SDEI_MAP_IDX_MAX_; \
+ (_i)++, (_mapping) = &sdei_global_mappings[(_i)])
#define iterate_mapping(_mapping, _i, _map) \
- for (_map = (_mapping)->map, _i = 0; \
- _i < (_mapping)->num_maps; \
- _i++, _map++)
+ for ((_map) = (_mapping)->map, (_i) = 0; \
+ (_i) < (_mapping)->num_maps; \
+ (_i)++, (_map)++)
#define for_each_private_map(_i, _map) \
iterate_mapping(SDEI_PRIVATE_MAPPING(), _i, _map)
@@ -82,45 +82,45 @@
iterate_mapping(SDEI_SHARED_MAPPING(), _i, _map)
/* SDEI_FEATURES */
-#define SDEI_FEATURE_BIND_SLOTS 0
-#define BIND_SLOTS_MASK 0xffff
-#define FEATURES_SHARED_SLOTS_SHIFT 16
-#define FEATURES_PRIVATE_SLOTS_SHIFT 0
+#define SDEI_FEATURE_BIND_SLOTS 0U
+#define BIND_SLOTS_MASK 0xffffU
+#define FEATURES_SHARED_SLOTS_SHIFT 16U
+#define FEATURES_PRIVATE_SLOTS_SHIFT 0U
#define FEATURE_BIND_SLOTS(_priv, _shrd) \
- ((((_priv) & BIND_SLOTS_MASK) << FEATURES_PRIVATE_SLOTS_SHIFT) | \
- (((_shrd) & BIND_SLOTS_MASK) << FEATURES_SHARED_SLOTS_SHIFT))
+ (((((uint64_t) (_priv)) & BIND_SLOTS_MASK) << FEATURES_PRIVATE_SLOTS_SHIFT) | \
+ ((((uint64_t) (_shrd)) & BIND_SLOTS_MASK) << FEATURES_SHARED_SLOTS_SHIFT))
#define GET_EV_STATE(_e, _s) get_ev_state_bit(_e, SDEI_STATF_##_s)
#define SET_EV_STATE(_e, _s) clr_ev_state_bit(_e->state, SDEI_STATF_##_s)
-static inline int is_event_private(sdei_ev_map_t *map)
+static inline bool is_event_private(sdei_ev_map_t *map)
{
- return ((map->map_flags & BIT(_SDEI_MAPF_PRIVATE_SHIFT)) != 0);
+ return ((map->map_flags & BIT_32(SDEI_MAPF_PRIVATE_SHIFT_)) != 0U);
}
-static inline int is_event_shared(sdei_ev_map_t *map)
+static inline bool is_event_shared(sdei_ev_map_t *map)
{
return !is_event_private(map);
}
-static inline int is_event_critical(sdei_ev_map_t *map)
+static inline bool is_event_critical(sdei_ev_map_t *map)
{
- return ((map->map_flags & BIT(_SDEI_MAPF_CRITICAL_SHIFT)) != 0);
+ return ((map->map_flags & BIT_32(SDEI_MAPF_CRITICAL_SHIFT_)) != 0U);
}
-static inline int is_event_normal(sdei_ev_map_t *map)
+static inline bool is_event_normal(sdei_ev_map_t *map)
{
return !is_event_critical(map);
}
-static inline int is_event_signalable(sdei_ev_map_t *map)
+static inline bool is_event_signalable(sdei_ev_map_t *map)
{
- return ((map->map_flags & BIT(_SDEI_MAPF_SIGNALABLE_SHIFT)) != 0);
+ return ((map->map_flags & BIT_32(SDEI_MAPF_SIGNALABLE_SHIFT_)) != 0U);
}
-static inline int is_map_dynamic(sdei_ev_map_t *map)
+static inline bool is_map_dynamic(sdei_ev_map_t *map)
{
- return ((map->map_flags & BIT(_SDEI_MAPF_DYNAMIC_SHIFT)) != 0);
+ return ((map->map_flags & BIT_32(SDEI_MAPF_DYNAMIC_SHIFT_)) != 0U);
}
/*
@@ -129,29 +129,29 @@
* called on them. This can be used on both static or dynamic events to check
* for an associated interrupt.
*/
-static inline int is_map_bound(sdei_ev_map_t *map)
+static inline bool is_map_bound(sdei_ev_map_t *map)
{
- return ((map->map_flags & BIT(_SDEI_MAPF_BOUND_SHIFT)) != 0);
+ return ((map->map_flags & BIT_32(SDEI_MAPF_BOUND_SHIFT_)) != 0U);
}
static inline void set_map_bound(sdei_ev_map_t *map)
{
- map->map_flags |= BIT(_SDEI_MAPF_BOUND_SHIFT);
+ map->map_flags |= BIT_32(SDEI_MAPF_BOUND_SHIFT_);
}
-static inline int is_map_explicit(sdei_ev_map_t *map)
+static inline bool is_map_explicit(sdei_ev_map_t *map)
{
- return ((map->map_flags & BIT(_SDEI_MAPF_EXPLICIT_SHIFT)) != 0);
+ return ((map->map_flags & BIT_32(SDEI_MAPF_EXPLICIT_SHIFT_)) != 0U);
}
static inline void clr_map_bound(sdei_ev_map_t *map)
{
- map->map_flags &= ~(BIT(_SDEI_MAPF_BOUND_SHIFT));
+ map->map_flags &= ~BIT_32(SDEI_MAPF_BOUND_SHIFT_);
}
-static inline int is_secure_sgi(unsigned int intr)
+static inline bool is_secure_sgi(unsigned int intr)
{
- return (plat_ic_is_sgi(intr) &&
+ return ((plat_ic_is_sgi(intr) != 0) &&
(plat_ic_get_interrupt_type(intr) == INTR_TYPE_EL3));
}
@@ -164,24 +164,24 @@
cpu_context_t *ns_ctx = cm_get_context(NON_SECURE);
el3_state_t *el3_ctx = get_el3state_ctx(ns_ctx);
- return read_ctx_reg(el3_ctx, CTX_SCR_EL3) & SCR_HCE_BIT ? MODE_EL2 :
- MODE_EL1;
+ return ((read_ctx_reg(el3_ctx, CTX_SCR_EL3) & SCR_HCE_BIT) != 0U) ?
+ MODE_EL2 : MODE_EL1;
}
static inline unsigned int sdei_event_priority(sdei_ev_map_t *map)
{
- return is_event_critical(map) ? PLAT_SDEI_CRITICAL_PRI :
- PLAT_SDEI_NORMAL_PRI;
+ return (unsigned int) (is_event_critical(map) ? PLAT_SDEI_CRITICAL_PRI :
+ PLAT_SDEI_NORMAL_PRI);
}
-static inline int get_ev_state_bit(sdei_entry_t *se, unsigned int bit_no)
+static inline bool get_ev_state_bit(sdei_entry_t *se, unsigned int bit_no)
{
- return ((se->state & BIT(bit_no)) != 0);
+ return ((se->state & BIT_32(bit_no)) != 0U);
}
static inline void clr_ev_state_bit(sdei_entry_t *se, unsigned int bit_no)
{
- se->state &= ~BIT(bit_no);
+ se->state &= ~BIT_32(bit_no);
}
/* SDEI actions for state transition */
@@ -228,19 +228,19 @@
void init_sdei_state(void);
-sdei_ev_map_t *find_event_map_by_intr(int intr_num, int shared);
+sdei_ev_map_t *find_event_map_by_intr(unsigned int intr_num, bool shared);
sdei_ev_map_t *find_event_map(int ev_num);
sdei_entry_t *get_event_entry(sdei_ev_map_t *map);
-int sdei_event_context(void *handle, unsigned int param);
-int sdei_event_complete(int resume, uint64_t arg);
+int64_t sdei_event_context(void *handle, unsigned int param);
+int sdei_event_complete(bool resume, uint64_t pc);
void sdei_pe_unmask(void);
-unsigned int sdei_pe_mask(void);
+int64_t sdei_pe_mask(void);
-int sdei_intr_handler(uint32_t intr, uint32_t flags, void *handle,
+int sdei_intr_handler(uint32_t intr_raw, uint32_t flags, void *handle,
void *cookie);
bool can_sdei_state_trans(sdei_entry_t *se, sdei_action_t act);
void begin_sdei_synchronous_dispatch(struct jmpbuf *buffer);
-#endif /* __SDEI_PRIVATE_H__ */
+#endif /* SDEI_PRIVATE_H */
diff --git a/services/std_svc/sdei/sdei_state.c b/services/std_svc/sdei/sdei_state.c
index c1f099f..6665786 100644
--- a/services/std_svc/sdei/sdei_state.c
+++ b/services/std_svc/sdei/sdei_state.c
@@ -10,13 +10,13 @@
#include "sdei_private.h"
/* Aliases for SDEI handler states: 'R'unning, 'E'nabled, and re'G'istered */
-#define r_ 0
+#define r_ 0U
#define R_ (1u << SDEI_STATF_RUNNING)
-#define e_ 0
+#define e_ 0U
#define E_ (1u << SDEI_STATF_ENABLED)
-#define g_ 0
+#define g_ 0U
#define G_ (1u << SDEI_STATF_REGISTERED)
/* All possible composite handler states */
@@ -29,7 +29,7 @@
#define REg_ (R_ | E_ | g_)
#define REG_ (R_ | E_ | G_)
-#define MAX_STATES (REG_ + 1)
+#define MAX_STATES (REG_ + 1u)
/* Invalid state */
#define SDEI_STATE_INVALID ((sdei_state_t) (-1))
diff --git a/services/std_svc/spm/spm_shim_private.h b/services/std_svc/spm/spm_shim_private.h
index 8408d1e..e65ac44 100644
--- a/services/std_svc/spm/spm_shim_private.h
+++ b/services/std_svc/spm/spm_shim_private.h
@@ -7,7 +7,7 @@
#ifndef __SPM_SHIM_PRIVATE__
#define __SPM_SHIM_PRIVATE__
-#include <types.h>
+#include <stdint.h>
#include <utils_def.h>
/* Assembly source */