Commit f07d3985 authored by davidcunado-arm's avatar davidcunado-arm Committed by GitHub
Browse files

Merge pull request #885 from antonio-nino-diaz-arm/an/console-flush

Implement console_flush()
parents 45cd814b 1e09ff93
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <auth_mod.h> #include <auth_mod.h>
#include <bl1.h> #include <bl1.h>
#include <bl_common.h> #include <bl_common.h>
#include <console.h>
#include <debug.h> #include <debug.h>
#include <errata_report.h> #include <errata_report.h>
#include <platform.h> #include <platform.h>
...@@ -166,6 +167,8 @@ void bl1_main(void) ...@@ -166,6 +167,8 @@ void bl1_main(void)
NOTICE("BL1-FWU: *******FWU Process Started*******\n"); NOTICE("BL1-FWU: *******FWU Process Started*******\n");
bl1_prepare_next_image(image_id); bl1_prepare_next_image(image_id);
console_flush();
} }
/******************************************************************************* /*******************************************************************************
......
/* /*
* Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <auth_mod.h> #include <auth_mod.h>
#include <bl1.h> #include <bl1.h>
#include <bl_common.h> #include <bl_common.h>
#include <console.h>
#include <debug.h> #include <debug.h>
#include <platform.h> #include <platform.h>
#include "bl2_private.h" #include "bl2_private.h"
...@@ -69,6 +70,8 @@ void bl2_main(void) ...@@ -69,6 +70,8 @@ void bl2_main(void)
disable_mmu_icache_secure(); disable_mmu_icache_secure();
#endif /* AARCH32 */ #endif /* AARCH32 */
console_flush();
/* /*
* Run next BL image via an SMC to BL1. Information on how to pass * Run next BL image via an SMC to BL1. Information on how to pass
* control to the BL32 (if present) and BL33 software images will * control to the BL32 (if present) and BL33 software images will
......
/* /*
* Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <auth_mod.h> #include <auth_mod.h>
#include <bl_common.h> #include <bl_common.h>
#include <bl1.h> #include <bl1.h>
#include <console.h>
#include <debug.h> #include <debug.h>
#include <platform.h> #include <platform.h>
#include <platform_def.h> #include <platform_def.h>
...@@ -63,6 +64,8 @@ void bl2u_main(void) ...@@ -63,6 +64,8 @@ void bl2u_main(void)
/* Perform platform setup in BL2U after loading SCP_BL2U */ /* Perform platform setup in BL2U after loading SCP_BL2U */
bl2u_platform_setup(); bl2u_platform_setup();
console_flush();
/* /*
* Indicate that BL2U is done and resume back to * Indicate that BL2U is done and resume back to
* normal world via an SMC to BL1. * normal world via an SMC to BL1.
......
/* /*
* Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2014-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -349,6 +349,8 @@ func do_crash_reporting ...@@ -349,6 +349,8 @@ func do_crash_reporting
/* Print some platform registers */ /* Print some platform registers */
plat_crash_print_regs plat_crash_print_regs
bl plat_crash_console_flush
/* Done reporting */ /* Done reporting */
no_ret plat_panic_handler no_ret plat_panic_handler
endfunc do_crash_reporting endfunc do_crash_reporting
......
/* /*
* Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <assert.h> #include <assert.h>
#include <bl_common.h> #include <bl_common.h>
#include <bl31.h> #include <bl31.h>
#include <console.h>
#include <context_mgmt.h> #include <context_mgmt.h>
#include <debug.h> #include <debug.h>
#include <platform.h> #include <platform.h>
...@@ -129,6 +130,8 @@ void bl31_main(void) ...@@ -129,6 +130,8 @@ void bl31_main(void)
*/ */
bl31_prepare_next_image_entry(); bl31_prepare_next_image_entry();
console_flush();
/* /*
* Perform any platform specific runtime setup prior to cold boot exit * Perform any platform specific runtime setup prior to cold boot exit
* from BL31 * from BL31
......
/* /*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -70,9 +70,12 @@ func do_panic ...@@ -70,9 +70,12 @@ func do_panic
/* Print new line */ /* Print new line */
ldr r4, =panic_end ldr r4, =panic_end
bl asm_print_str bl asm_print_str
bl plat_crash_console_flush
1: 1:
mov lr, r6 mov lr, r6
b plat_panic_handler no_ret plat_panic_handler
endfunc do_panic endfunc do_panic
/*********************************************************** /***********************************************************
...@@ -140,6 +143,9 @@ dec_print_loop: ...@@ -140,6 +143,9 @@ dec_print_loop:
udiv r5, r5, r6 /* Reduce divisor */ udiv r5, r5, r6 /* Reduce divisor */
cmp r5, #0 cmp r5, #0
bne dec_print_loop bne dec_print_loop
bl plat_crash_console_flush
1: 1:
no_ret plat_panic_handler no_ret plat_panic_handler
endfunc asm_assert endfunc asm_assert
......
/* /*
* Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2014-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -96,8 +96,9 @@ func asm_assert ...@@ -96,8 +96,9 @@ func asm_assert
b.ne _assert_loop b.ne _assert_loop
mov x4, x6 mov x4, x6
asm_print_line_dec asm_print_line_dec
bl plat_crash_console_flush
_assert_loop: _assert_loop:
b _assert_loop no_ret plat_panic_handler
endfunc asm_assert endfunc asm_assert
#endif #endif
...@@ -187,6 +188,8 @@ el3_panic: ...@@ -187,6 +188,8 @@ el3_panic:
sub x4, x4, #4 sub x4, x4, #4
bl asm_print_hex bl asm_print_hex
bl plat_crash_console_flush
_panic_handler: _panic_handler:
/* Pass to plat_panic_handler the address from where el3_panic was /* Pass to plat_panic_handler the address from where el3_panic was
* called, not the address of the call from el3_panic. */ * called, not the address of the call from el3_panic. */
......
...@@ -2242,6 +2242,17 @@ designated crash console. It must only use general purpose registers x1 and ...@@ -2242,6 +2242,17 @@ designated crash console. It must only use general purpose registers x1 and
x2 to do its work. The parameter and the return value are in general purpose x2 to do its work. The parameter and the return value are in general purpose
register x0. register x0.
### Function : plat_crash_console_flush
Argument : void
Return : int
This API is used by the crash reporting mechanism to force write of all buffered
data on the designated crash console. It should only use general purpose
registers x0 and x1 to do its work. The return value is 0 on successful
completion; otherwise the return value is -1.
4. Build flags 4. Build flags
--------------- ---------------
......
/* /*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
.globl console_core_init .globl console_core_init
.globl console_core_putc .globl console_core_putc
.globl console_core_getc .globl console_core_getc
.globl console_core_flush
/* ----------------------------------------------- /* -----------------------------------------------
...@@ -158,3 +159,29 @@ getc_error: ...@@ -158,3 +159,29 @@ getc_error:
mov r0, #-1 mov r0, #-1
bx lr bx lr
endfunc console_core_getc endfunc console_core_getc
/* ---------------------------------------------
* int console_core_flush(uintptr_t base_addr)
* Function to force a write of all buffered
* data that hasn't been output.
* In : r0 - console base address
* Out : return -1 on error else return 0.
* Clobber list : r0, r1
* ---------------------------------------------
*/
func console_core_flush
cmp r0, #0
beq flush_error
1:
/* Loop while the transmit FIFO is busy */
ldr r1, [r0, #UARTFR]
tst r1, #PL011_UARTFR_BUSY
bne 1b
mov r0, #0
bx lr
flush_error:
mov r0, #-1
bx lr
endfunc console_core_flush
/* /*
* Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
.globl console_core_init .globl console_core_init
.globl console_core_putc .globl console_core_putc
.globl console_core_getc .globl console_core_getc
.globl console_core_flush
/* ----------------------------------------------- /* -----------------------------------------------
...@@ -151,3 +152,27 @@ getc_error: ...@@ -151,3 +152,27 @@ getc_error:
mov w0, #-1 mov w0, #-1
ret ret
endfunc console_core_getc endfunc console_core_getc
/* ---------------------------------------------
* int console_core_flush(uintptr_t base_addr)
* Function to force a write of all buffered
* data that hasn't been output.
* In : x0 - console base address
* Out : return -1 on error else return 0.
* Clobber list : x0, x1
* ---------------------------------------------
*/
func console_core_flush
cbz x0, flush_error
1:
/* Loop until the transmit FIFO is empty */
ldr w1, [x0, #UARTFR]
tbnz w1, #PL011_UARTFR_BUSY_BIT, 1b
mov w0, #0
ret
flush_error:
mov w0, #-1
ret
endfunc console_core_flush
/* /*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
.globl console_core_init .globl console_core_init
.globl console_core_putc .globl console_core_putc
.globl console_core_getc .globl console_core_getc
.globl console_core_flush
/* ----------------------------------------------- /* -----------------------------------------------
* int console_core_init(unsigned long base_addr, * int console_core_init(unsigned long base_addr,
...@@ -125,3 +126,18 @@ getc_error: ...@@ -125,3 +126,18 @@ getc_error:
mov w0, #-1 mov w0, #-1
ret ret
endfunc console_core_getc endfunc console_core_getc
/* ---------------------------------------------
* int console_core_flush(uintptr_t base_addr)
* Function to force a write of all buffered
* data that hasn't been output.
* In : x0 - console base address
* Out : return -1 on error else return 0.
* Clobber list : x0, x1
* ---------------------------------------------
*/
func console_core_flush
/* Placeholder */
mov w0, #0
ret
endfunc console_core_flush
/* /*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
.globl console_uninit .globl console_uninit
.globl console_putc .globl console_putc
.globl console_getc .globl console_getc
.globl console_flush
/* /*
* The console base is in the data section and not in .bss * The console base is in the data section and not in .bss
...@@ -112,3 +113,18 @@ func console_getc ...@@ -112,3 +113,18 @@ func console_getc
ldr r0, [r1] ldr r0, [r1]
b console_core_getc b console_core_getc
endfunc console_getc endfunc console_getc
/* ---------------------------------------------
* int console_flush(void)
* Function to force a write of all buffered
* data that hasn't been output. It returns 0
* upon successful completion, otherwise it
* returns -1.
* Clobber list : r0, r1
* ---------------------------------------------
*/
func console_flush
ldr r1, =console_base
ldr r0, [r1]
b console_core_flush
endfunc console_flush
/* /*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
.globl console_core_init .globl console_core_init
.globl console_core_putc .globl console_core_putc
.globl console_core_getc .globl console_core_getc
.globl console_core_flush
/* ----------------------------------------------- /* -----------------------------------------------
* int console_core_init(uintptr_t base_addr, * int console_core_init(uintptr_t base_addr,
...@@ -109,3 +110,23 @@ getc_error: ...@@ -109,3 +110,23 @@ getc_error:
mov r0, #-1 mov r0, #-1
bx lr bx lr
endfunc console_core_getc endfunc console_core_getc
/* ---------------------------------------------
* int console_core_flush(uintptr_t base_addr)
* Function to force a write of all buffered
* data that hasn't been output.
* In : r0 - console base address
* Out : return -1 on error else return 0.
* Clobber list : r0, r1
* ---------------------------------------------
*/
func console_core_flush
cmp r0, #0
beq flush_error
/* Insert implementation here */
mov r0, #0
bx lr
flush_error:
mov r0, #-1
bx lr
endfunc console_core_flush
/* /*
* Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
.globl console_uninit .globl console_uninit
.globl console_putc .globl console_putc
.globl console_getc .globl console_getc
.globl console_flush
/* /*
* The console base is in the data section and not in .bss * The console base is in the data section and not in .bss
...@@ -111,3 +112,18 @@ func console_getc ...@@ -111,3 +112,18 @@ func console_getc
ldr x0, [x1, :lo12:console_base] ldr x0, [x1, :lo12:console_base]
b console_core_getc b console_core_getc
endfunc console_getc endfunc console_getc
/* ---------------------------------------------
* int console_flush(void)
* Function to force a write of all buffered
* data that hasn't been output. It returns 0
* upon successful completion, otherwise it
* returns -1.
* Clobber list : x0, x1
* ---------------------------------------------
*/
func console_flush
adrp x1, console_base
ldr x0, [x1, :lo12:console_base]
b console_core_flush
endfunc console_flush
/* /*
* Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
.globl console_core_init .globl console_core_init
.globl console_core_putc .globl console_core_putc
.globl console_core_getc .globl console_core_getc
.globl console_core_flush
/* ----------------------------------------------- /* -----------------------------------------------
* int console_core_init(uintptr_t base_addr, * int console_core_init(uintptr_t base_addr,
...@@ -104,3 +105,22 @@ getc_error: ...@@ -104,3 +105,22 @@ getc_error:
mov w0, #-1 mov w0, #-1
ret ret
endfunc console_core_getc endfunc console_core_getc
/* ---------------------------------------------
* int console_core_flush(uintptr_t base_addr)
* Function to force a write of all buffered
* data that hasn't been output.
* In : x0 - console base address
* Out : return -1 on error else return 0.
* Clobber list : x0, x1
* ---------------------------------------------
*/
func console_core_flush
cbz x0, flush_error
/* Insert implementation here */
mov w0, #0
ret
flush_error:
mov w0, #-1
ret
endfunc console_core_flush
/* /*
* Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
.globl console_core_init .globl console_core_init
.globl console_core_putc .globl console_core_putc
.globl console_core_getc .globl console_core_getc
.globl console_core_flush
/* ----------------------------------------------- /* -----------------------------------------------
* int console_core_init(unsigned long base_addr, * int console_core_init(unsigned long base_addr,
...@@ -153,3 +154,18 @@ getc_error: ...@@ -153,3 +154,18 @@ getc_error:
mov w0, #-1 mov w0, #-1
ret ret
endfunc console_core_getc endfunc console_core_getc
/* ---------------------------------------------
* int console_core_flush(uintptr_t base_addr)
* Function to force a write of all buffered
* data that hasn't been output.
* In : x0 - console base address
* Out : return -1 on error else return 0.
* Clobber list : x0, x1
* ---------------------------------------------
*/
func console_core_flush
/* Placeholder */
mov w0, #0
ret
endfunc console_core_flush
/* /*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -38,6 +38,7 @@ int console_init(uintptr_t base_addr, ...@@ -38,6 +38,7 @@ int console_init(uintptr_t base_addr,
void console_uninit(void); void console_uninit(void);
int console_putc(int c); int console_putc(int c);
int console_getc(void); int console_getc(void);
int console_flush(void);
#endif /* __CONSOLE_H__ */ #endif /* __CONSOLE_H__ */
...@@ -100,6 +100,7 @@ uintptr_t plat_get_my_stack(void); ...@@ -100,6 +100,7 @@ uintptr_t plat_get_my_stack(void);
void plat_report_exception(unsigned int exception_type); void plat_report_exception(unsigned int exception_type);
int plat_crash_console_init(void); int plat_crash_console_init(void);
int plat_crash_console_putc(int c); int plat_crash_console_putc(int c);
int plat_crash_console_flush(void);
void plat_error_handler(int err) __dead2; void plat_error_handler(int err) __dead2;
void plat_panic_handler(void) __dead2; void plat_panic_handler(void) __dead2;
......
/* /*
* Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2014-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <stddef.h> #include <stddef.h>
#include <arch_helpers.h> #include <arch_helpers.h>
#include <assert.h> #include <assert.h>
#include <console.h>
#include <debug.h> #include <debug.h>
#include <platform.h> #include <platform.h>
#include "psci_private.h" #include "psci_private.h"
...@@ -46,6 +47,8 @@ void psci_system_off(void) ...@@ -46,6 +47,8 @@ void psci_system_off(void)
psci_spd_pm->svc_system_off(); psci_spd_pm->svc_system_off();
} }
console_flush();
/* Call the platform specific hook */ /* Call the platform specific hook */
psci_plat_pm_ops->system_off(); psci_plat_pm_ops->system_off();
...@@ -63,6 +66,8 @@ void psci_system_reset(void) ...@@ -63,6 +66,8 @@ void psci_system_reset(void)
psci_spd_pm->svc_system_reset(); psci_spd_pm->svc_system_reset();
} }
console_flush();
/* Call the platform specific hook */ /* Call the platform specific hook */
psci_plat_pm_ops->system_reset(); psci_plat_pm_ops->system_reset();
......
/* /*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <console.h>
#include <debug.h> #include <debug.h>
#include <platform.h>
/* /*
* This is a basic implementation. This could be improved. * This is a basic implementation. This could be improved.
...@@ -37,5 +39,8 @@ void __assert (const char *function, const char *file, unsigned int line, ...@@ -37,5 +39,8 @@ void __assert (const char *function, const char *file, unsigned int line,
const char *assertion) const char *assertion)
{ {
tf_printf("ASSERT: %s <%d> : %s\n", function, line, assertion); tf_printf("ASSERT: %s <%d> : %s\n", function, line, assertion);
while(1);
console_flush();
plat_panic_handler();
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment