diff options
author | Antonio Nino Diaz <antonio.ninodiaz@arm.com> | 2018-05-08 13:38:19 +0100 |
---|---|---|
committer | Antonio Nino Diaz <antonio.ninodiaz@arm.com> | 2018-05-08 13:38:19 +0100 |
commit | f9cba35a00a91a79962a62e496649b66c2dd2117 (patch) | |
tree | bbbe2c9267cb28f2ed978fc96d17a39beae5657e | |
parent | f7c965e39bc1bb955a00b41b3be9458fe85ee7bf (diff) |
pl011: Reorganize getc implementation
Split the function console_getc into console_getc and console_core_getc
like the rest of the console driver interfaces.
Change-Id: If1defe6ab99c3f72245a1e02b57d886fe92c2b2c
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
-rw-r--r-- | drivers/arm/pl011/aarch32/pl011_console.S | 22 | ||||
-rw-r--r-- | drivers/arm/pl011/aarch64/pl011_console.S | 37 |
2 files changed, 46 insertions, 13 deletions
diff --git a/drivers/arm/pl011/aarch32/pl011_console.S b/drivers/arm/pl011/aarch32/pl011_console.S index 90124dc..7dd2024 100644 --- a/drivers/arm/pl011/aarch32/pl011_console.S +++ b/drivers/arm/pl011/aarch32/pl011_console.S @@ -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. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -33,11 +33,12 @@ .globl console_init .globl console_putc + .globl console_getc .globl console_flush .globl console_core_init .globl console_core_putc + .globl console_core_getc .globl console_core_flush - .globl console_getc /* * The console base is in the data section and not in .bss @@ -179,12 +180,27 @@ endfunc console_core_putc * Function to get a character from the console. * It returns the character grabbed on success * or -1 on error. + * Out : return -1 on error else return character. * Clobber list : r0, r1 * --------------------------------------------- */ func console_getc ldr r1, =console_base ldr r0, [r1] + b console_core_getc +endfunc console_getc + + /* --------------------------------------------- + * int console_core_getc(void) + * Function to get a character from the console. + * It returns the character grabbed on success + * or -1 on error. + * In : r0 - console base address + * Out : return -1 on error else return character. + * Clobber list : r0, r1 + * --------------------------------------------- + */ +func console_core_getc cmp r0, #0 beq getc_error 1: @@ -198,7 +214,7 @@ func console_getc getc_error: mov r0, #-1 bx lr -endfunc console_getc +endfunc console_core_getc /* --------------------------------------------- * int console_flush(void) diff --git a/drivers/arm/pl011/aarch64/pl011_console.S b/drivers/arm/pl011/aarch64/pl011_console.S index 6487c37..3a2a34c 100644 --- a/drivers/arm/pl011/aarch64/pl011_console.S +++ b/drivers/arm/pl011/aarch64/pl011_console.S @@ -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. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -33,11 +33,12 @@ .globl console_init .globl console_putc + .globl console_getc .globl console_flush .globl console_core_init .globl console_core_putc + .globl console_core_getc .globl console_core_flush - .globl console_getc /* * The console base is in the data section and not in .bss @@ -172,23 +173,39 @@ endfunc console_core_putc * Function to get a character from the console. * It returns the character grabbed on success * or -1 on error. + * Out : return -1 on error else return character. * Clobber list : x0, x1 * --------------------------------------------- */ func console_getc adrp x0, console_base - ldr x1, [x0, :lo12:console_base] - cbz x1, getc_error -1: - /* Check if the receive FIFO is empty */ - ldr w0, [x1, #UARTFR] - tbnz w0, #PL011_UARTFR_RXFE_BIT, 1b - ldr w0, [x1, #UARTDR] + ldr x0, [x0, :lo12:console_base] + b console_core_getc +endfunc console_getc + + /* --------------------------------------------- + * int console_core_getc(void) + * Function to get a character from the console. + * It returns the character grabbed on success + * or -1 on error. + * In : x0 - console base address + * Out : return -1 on error else return character. + * Clobber list : x0, x1 + * --------------------------------------------- + */ +func console_core_getc + cbz x0, getc_error + +1: /* Check if the receive FIFO is empty */ + ldr w1, [x0, #UARTFR] + tbnz w1, #PL011_UARTFR_RXFE_BIT, 1b + + ldr w0, [x0, #UARTDR] ret getc_error: mov w0, #-1 ret -endfunc console_getc +endfunc console_core_getc /* --------------------------------------------- * int console_flush(void) |