Antonio Nino Diaz 09d40e0e08 Sanitise includes across codebase
Enforce full include path for includes. Deprecate old paths.

The following folders inside include/lib have been left unchanged:

- include/lib/cpus/${ARCH}
- include/lib/el3_runtime/${ARCH}

The reason for this change is that having a global namespace for
includes isn't a good idea. It defeats one of the advantages of having
folders and it introduces problems that are sometimes subtle (because
you may not know the header you are actually including if there are two
of them).

For example, this patch had to be created because two headers were
called the same way: e0ea0928d5b7 ("Fix gpio includes of mt8173 platform
to avoid collision."). More recently, this patch has had similar
problems: 46f9b2c3a282 ("drivers: add tzc380 support").

This problem was introduced in commit 4ecca33988b9 ("Move include and
source files to logical locations"). At that time, there weren't too
many headers so it wasn't a real issue. However, time has shown that
this creates problems.

Platforms that want to preserve the way they include headers may add the
removed paths to PLAT_INCLUDES, but this is discouraged.

Change-Id: I39dc53ed98f9e297a5966e723d1936d6ccf2fc8f
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
2019-01-04 10:43:17 +00:00

85 lines
2.6 KiB
ArmAsm

/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef CONSOLE_MACROS_S
#define CONSOLE_MACROS_S
#include <drivers/console.h>
/*
* This macro encapsulates the common setup that has to be done at the end of
* a console driver's register function. It will register all of the driver's
* callbacks in the console_t structure and initialize the flags field (by
* default consoles are enabled for the "boot" and "crash" states, this can be
* changed after registration with the console_set_scope() function). It ends
* with a tail call that will include return to the caller.
* REQUIRES console_t pointer in x0 and a valid return address in x30.
*/
/*
* The USE_FINISH_CONSOLE_REG_2 guard is introduced to allow selection between
* the 2 variants of the finish_console_register macro and will be removed
* once the deprecated variant is removed.
*/
#ifndef USE_FINISH_CONSOLE_REG_2
#if !ERROR_DEPRECATED
/* This version of the macro is deprecated. Use the new version */
.macro finish_console_register _driver
/*
* Add these weak definitions so we will automatically write a 0 if the
* function doesn't exist. I'd rather use .ifdef but that only works if
* the function was defined (not just declared .global) above this point
* in the file, which we can't guarantee.
*/
.weak console_\_driver\()_putc
.weak console_\_driver\()_getc
.weak console_\_driver\()_flush
/* Don't use adrp on weak funcs! See GNU ld bugzilla issue 22589. */
ldr r1, =console_\_driver\()_putc
str r1, [r0, #CONSOLE_T_PUTC]
ldr r1, =console_\_driver\()_getc
str r1, [r0, #CONSOLE_T_GETC]
ldr r1, =console_\_driver\()_flush
str r1, [r0, #CONSOLE_T_FLUSH]
mov r1, #(CONSOLE_FLAG_BOOT | CONSOLE_FLAG_CRASH)
str r1, [r0, #CONSOLE_T_FLAGS]
b console_register
.endm
#endif /* ERROR_DEPRECATED */
#else /* USE_FINISH_CONSOLE_REG_2 */
/* The new version of the macro not using weak references */
.macro finish_console_register _driver, putc=0, getc=0, flush=0
/*
* If any of the callback is not specified or set as 0, then the
* corresponding callback entry in console_t is set to 0.
*/
.ifne \putc
ldr r1, =console_\_driver\()_putc
.else
mov r1, #0
.endif
str r1, [r0, #CONSOLE_T_PUTC]
.ifne \getc
ldr r1, =console_\_driver\()_getc
.else
mov r1, #0
.endif
str r1, [r0, #CONSOLE_T_GETC]
.ifne \flush
ldr r1, =console_\_driver\()_flush
.else
mov r1, #0
.endif
str r1, [r0, #CONSOLE_T_FLUSH]
mov r1, #(CONSOLE_FLAG_BOOT | CONSOLE_FLAG_CRASH)
str r1, [r0, #CONSOLE_T_FLAGS]
b console_register
.endm
#endif /* USE_FINISH_CONSOLE_REG_2 */
#endif /* CONSOLE_MACROS_S */