Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 4f31ad5 | 2018-04-30 20:14:07 +0100 | [diff] [blame] | 2 | * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Julius Werner | 6b88b65 | 2018-11-27 17:50:28 -0800 | [diff] [blame^] | 7 | #if MULTI_CONSOLE_API |
| 8 | |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 9 | #include <asm_macros.S> |
| 10 | #include <assert_macros.S> |
| 11 | #include <console.h> |
| 12 | |
| 13 | .globl console_register |
| 14 | .globl console_unregister |
Antonio Nino Diaz | 4f31ad5 | 2018-04-30 20:14:07 +0100 | [diff] [blame] | 15 | .globl console_is_registered |
| 16 | .globl console_set_scope |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 17 | .globl console_switch_state |
| 18 | .globl console_putc |
| 19 | .globl console_getc |
| 20 | .globl console_flush |
Julius Werner | 1338c9c | 2018-11-19 14:25:55 -0800 | [diff] [blame] | 21 | .globl console_list |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 22 | |
| 23 | /* |
| 24 | * The console list pointer is in the data section and not in |
| 25 | * .bss even though it is zero-init. In particular, this allows |
| 26 | * the console functions to start using this variable before |
| 27 | * the runtime memory is initialized for images which do not |
| 28 | * need to copy the .data section from ROM to RAM. |
| 29 | */ |
| 30 | .section .data.console_list ; .align 3 |
| 31 | console_list: .quad 0x0 |
| 32 | .section .data.console_state ; .align 0 |
| 33 | console_state: .byte CONSOLE_FLAG_BOOT |
| 34 | |
| 35 | /* ----------------------------------------------- |
| 36 | * int console_register(console_t *console) |
| 37 | * Function to insert a new console structure into |
| 38 | * the console list. Should usually be called by |
| 39 | * console_<driver>_register implementations. The |
| 40 | * data structure passed will be taken over by the |
| 41 | * console framework and *MUST* be allocated in |
| 42 | * persistent memory (e.g. the data section). |
| 43 | * In : x0 - address of console_t structure |
| 44 | * Out: x0 - Always 1 (for easier tail calling) |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 45 | * Clobber list: x0, x1 |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 46 | * ----------------------------------------------- |
| 47 | */ |
| 48 | func console_register |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 49 | stp x21, x30, [sp, #-16]! |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 50 | #if ENABLE_ASSERTIONS |
Antonio Nino Diaz | 4f31ad5 | 2018-04-30 20:14:07 +0100 | [diff] [blame] | 51 | /* Assert that x0 isn't a NULL pointer */ |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 52 | cmp x0, #0 |
| 53 | ASM_ASSERT(ne) |
Antonio Nino Diaz | 4f31ad5 | 2018-04-30 20:14:07 +0100 | [diff] [blame] | 54 | /* Assert that the struct isn't in the stack */ |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 55 | adrp x1, __STACKS_START__ |
| 56 | add x1, x1, :lo12:__STACKS_START__ |
| 57 | cmp x0, x1 |
| 58 | b.lo not_on_stack |
| 59 | adrp x1, __STACKS_END__ |
| 60 | add x1, x1, :lo12:__STACKS_END__ |
| 61 | cmp x0, x1 |
| 62 | ASM_ASSERT(hs) |
| 63 | not_on_stack: |
Antonio Nino Diaz | 4f31ad5 | 2018-04-30 20:14:07 +0100 | [diff] [blame] | 64 | /* Assert that this struct isn't in the list */ |
| 65 | mov x1, x0 /* Preserve x0 and x30 */ |
Antonio Nino Diaz | 4f31ad5 | 2018-04-30 20:14:07 +0100 | [diff] [blame] | 66 | bl console_is_registered |
| 67 | cmp x0, #0 |
| 68 | ASM_ASSERT(eq) |
Antonio Nino Diaz | 4f31ad5 | 2018-04-30 20:14:07 +0100 | [diff] [blame] | 69 | mov x0, x1 |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 70 | #endif /* ENABLE_ASSERTIONS */ |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 71 | adrp x21, console_list |
| 72 | ldr x1, [x21, :lo12:console_list] /* X1 = first struct in list */ |
| 73 | str x0, [x21, :lo12:console_list] /* list head = new console */ |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 74 | str x1, [x0, #CONSOLE_T_NEXT] /* new console next ptr = X1 */ |
| 75 | mov x0, #1 |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 76 | ldp x21, x30, [sp], #16 |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 77 | ret |
| 78 | endfunc console_register |
| 79 | |
| 80 | /* ----------------------------------------------- |
| 81 | * int console_unregister(console_t *console) |
| 82 | * Function to find a specific console in the list |
| 83 | * of currently active consoles and remove it. |
| 84 | * In: x0 - address of console_t struct to remove |
| 85 | * Out: x0 - removed address, or NULL if not found |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 86 | * Clobber list: x0, x1 |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 87 | * ----------------------------------------------- |
| 88 | */ |
| 89 | func console_unregister |
Antonio Nino Diaz | 4f31ad5 | 2018-04-30 20:14:07 +0100 | [diff] [blame] | 90 | #if ENABLE_ASSERTIONS |
| 91 | /* Assert that x0 isn't a NULL pointer */ |
| 92 | cmp x0, #0 |
| 93 | ASM_ASSERT(ne) |
| 94 | #endif /* ENABLE_ASSERTIONS */ |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 95 | stp x21, xzr, [sp, #-16]! |
| 96 | adrp x21, console_list |
| 97 | add x21, x21, :lo12:console_list /* X21 = ptr to first struct */ |
| 98 | ldr x1, [x21] /* X1 = first struct */ |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 99 | |
| 100 | unregister_loop: |
| 101 | cbz x1, unregister_not_found |
| 102 | cmp x0, x1 |
| 103 | b.eq unregister_found |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 104 | ldr x21, [x21] /* X21 = next ptr of struct */ |
| 105 | ldr x1, [x21] /* X1 = next struct */ |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 106 | b unregister_loop |
| 107 | |
| 108 | unregister_found: |
| 109 | ldr x1, [x1] /* X1 = next struct */ |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 110 | str x1, [x21] /* prev->next = cur->next */ |
| 111 | ldp x21, xzr, [sp], #16 |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 112 | ret |
| 113 | |
| 114 | unregister_not_found: |
| 115 | mov x0, #0 /* return NULL if not found */ |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 116 | ldp x21, xzr, [sp], #16 |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 117 | ret |
| 118 | endfunc console_unregister |
| 119 | |
| 120 | /* ----------------------------------------------- |
Antonio Nino Diaz | 4f31ad5 | 2018-04-30 20:14:07 +0100 | [diff] [blame] | 121 | * int console_is_registered(console_t *console) |
| 122 | * Function to detect if a specific console is |
| 123 | * registered or not. |
| 124 | * In: x0 - address of console_t struct to remove |
| 125 | * Out: x0 - 1 if it is registered, 0 if not. |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 126 | * Clobber list: x0 |
Antonio Nino Diaz | 4f31ad5 | 2018-04-30 20:14:07 +0100 | [diff] [blame] | 127 | * ----------------------------------------------- |
| 128 | */ |
| 129 | func console_is_registered |
| 130 | #if ENABLE_ASSERTIONS |
| 131 | /* Assert that x0 isn't a NULL pointer */ |
| 132 | cmp x0, #0 |
| 133 | ASM_ASSERT(ne) |
| 134 | #endif /* ENABLE_ASSERTIONS */ |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 135 | stp x21, xzr, [sp, #-16]! |
| 136 | adrp x21, console_list |
| 137 | ldr x21, [x21, :lo12:console_list] /* X21 = first console struct */ |
Antonio Nino Diaz | 4f31ad5 | 2018-04-30 20:14:07 +0100 | [diff] [blame] | 138 | check_registered_loop: |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 139 | cbz x21, console_not_registered /* Check if end of list */ |
| 140 | cmp x0, x21 /* Check if the pointers are different */ |
Antonio Nino Diaz | 4f31ad5 | 2018-04-30 20:14:07 +0100 | [diff] [blame] | 141 | b.eq console_registered |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 142 | ldr x21, [x21, #CONSOLE_T_NEXT] /* Get pointer to next struct */ |
Antonio Nino Diaz | 4f31ad5 | 2018-04-30 20:14:07 +0100 | [diff] [blame] | 143 | b check_registered_loop |
| 144 | console_not_registered: |
| 145 | mov x0, #0 |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 146 | ldp x21, xzr, [sp], #16 |
Antonio Nino Diaz | 4f31ad5 | 2018-04-30 20:14:07 +0100 | [diff] [blame] | 147 | ret |
| 148 | console_registered: |
| 149 | mov x0, #1 |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 150 | ldp x21, xzr, [sp], #16 |
Antonio Nino Diaz | 4f31ad5 | 2018-04-30 20:14:07 +0100 | [diff] [blame] | 151 | ret |
| 152 | endfunc console_is_registered |
| 153 | |
| 154 | /* ----------------------------------------------- |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 155 | * void console_switch_state(unsigned int new_state) |
| 156 | * Function to switch the current console state. |
| 157 | * The console state determines which of the |
| 158 | * registered consoles are actually used at a time. |
| 159 | * In : w0 - global console state to move to |
| 160 | * Clobber list: x0, x1 |
| 161 | * ----------------------------------------------- |
| 162 | */ |
| 163 | func console_switch_state |
| 164 | adrp x1, console_state |
| 165 | strb w0, [x1, :lo12:console_state] |
| 166 | ret |
| 167 | endfunc console_switch_state |
| 168 | |
| 169 | /* ----------------------------------------------- |
| 170 | * void console_set_scope(console_t *console, |
| 171 | * unsigned int scope) |
| 172 | * Function to update the states that a given console |
| 173 | * may be active in. |
| 174 | * In : x0 - pointer to console_t struct |
| 175 | * : w1 - new active state mask |
| 176 | * Clobber list: x0, x1, x2 |
| 177 | * ----------------------------------------------- |
| 178 | */ |
| 179 | func console_set_scope |
| 180 | #if ENABLE_ASSERTIONS |
| 181 | tst w1, #~CONSOLE_FLAG_SCOPE_MASK |
| 182 | ASM_ASSERT(eq) |
| 183 | #endif /* ENABLE_ASSERTIONS */ |
| 184 | ldr w2, [x0, #CONSOLE_T_FLAGS] |
| 185 | and w2, w2, #~CONSOLE_FLAG_SCOPE_MASK |
| 186 | orr w2, w2, w1 |
| 187 | str w2, [x0, #CONSOLE_T_FLAGS] |
| 188 | ret |
| 189 | endfunc console_set_scope |
| 190 | |
| 191 | /* --------------------------------------------- |
| 192 | * int console_putc(int c) |
| 193 | * Function to output a character. Calls all |
| 194 | * active console's putc() handlers in succession. |
| 195 | * In : x0 - character to be printed |
| 196 | * Out: x0 - printed character on success, or < 0 |
| 197 | if at least one console had an error |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 198 | * Clobber list : x0, x1, x2 |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 199 | * --------------------------------------------- |
| 200 | */ |
| 201 | func console_putc |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 202 | stp x21, x30, [sp, #-16]! |
| 203 | stp x19, x20, [sp, #-16]! |
| 204 | mov w20, #ERROR_NO_VALID_CONSOLE /* W20 = current return value */ |
| 205 | mov w19, w0 /* W19 = character to print */ |
| 206 | adrp x21, console_list |
| 207 | ldr x21, [x21, :lo12:console_list] /* X21 = first console struct */ |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 208 | |
| 209 | putc_loop: |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 210 | cbz x21, putc_done |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 211 | adrp x1, console_state |
| 212 | ldrb w1, [x1, :lo12:console_state] |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 213 | ldr w2, [x21, #CONSOLE_T_FLAGS] |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 214 | tst w1, w2 |
| 215 | b.eq putc_continue |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 216 | ldr x2, [x21, #CONSOLE_T_PUTC] |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 217 | cbz x2, putc_continue |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 218 | mov w0, w19 |
| 219 | mov x1, x21 |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 220 | blr x2 |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 221 | cmp w20, #ERROR_NO_VALID_CONSOLE /* update W20 if it's NOVALID */ |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 222 | ccmp w0, #0, #0x8, ne /* else update it if W0 < 0 */ |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 223 | csel w20, w0, w20, lt |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 224 | putc_continue: |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 225 | ldr x21, [x21] /* X21 = next struct */ |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 226 | b putc_loop |
| 227 | |
| 228 | putc_done: |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 229 | mov w0, w20 |
| 230 | ldp x19, x20, [sp], #16 |
| 231 | ldp x21, x30, [sp], #16 |
| 232 | ret |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 233 | endfunc console_putc |
| 234 | |
| 235 | /* --------------------------------------------- |
| 236 | * int console_getc(void) |
| 237 | * Function to get a character from any console. |
| 238 | * Keeps looping through all consoles' getc() |
| 239 | * handlers until one of them returns a |
| 240 | * character, then stops iterating and returns |
| 241 | * that character to the caller. Will stop looping |
| 242 | * if all active consoles report real errors |
| 243 | * (other than just not having a char available). |
| 244 | * Out : x0 - read character, or < 0 on error |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 245 | * Clobber list : x0, x1 |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 246 | * --------------------------------------------- |
| 247 | */ |
| 248 | func console_getc |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 249 | stp x30, xzr, [sp, #-16]! |
| 250 | stp x20, x21, [sp, #-16]! |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 251 | getc_try_again: |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 252 | mov w20, #ERROR_NO_VALID_CONSOLE /* W20 = current return value */ |
| 253 | adrp x21, console_list |
| 254 | ldr x21, [x21, :lo12:console_list] /* X21 = first console struct */ |
| 255 | cbnz x21, getc_loop |
| 256 | mov w0, w20 /* If no consoles registered */ |
| 257 | ldp x20, x21, [sp], #16 |
| 258 | ldp x30, xzr, [sp], #16 |
| 259 | ret /* return immediately. */ |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 260 | |
| 261 | getc_loop: |
| 262 | adrp x0, console_state |
| 263 | ldrb w0, [x0, :lo12:console_state] |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 264 | ldr w1, [x21, #CONSOLE_T_FLAGS] |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 265 | tst w0, w1 |
| 266 | b.eq getc_continue |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 267 | ldr x1, [x21, #CONSOLE_T_GETC] |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 268 | cbz x1, getc_continue |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 269 | mov x0, x21 |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 270 | blr x1 |
| 271 | cmp w0, #0 /* if X0 >= 0: return */ |
| 272 | b.ge getc_found |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 273 | cmp w20, #ERROR_NO_PENDING_CHAR /* may update W20 (NOCHAR has */ |
| 274 | csel w20, w20, w0, eq /* precedence vs real errors) */ |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 275 | getc_continue: |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 276 | ldr x21, [x21] /* X21 = next struct */ |
| 277 | cbnz x21, getc_loop |
| 278 | cmp w20, #ERROR_NO_PENDING_CHAR /* Keep scanning if at least */ |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 279 | b.eq getc_try_again /* one console returns NOCHAR */ |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 280 | mov w0, w20 |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 281 | |
| 282 | getc_found: |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 283 | ldp x20, x21, [sp], #16 |
| 284 | ldp x30, xzr, [sp], #16 |
| 285 | ret |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 286 | endfunc console_getc |
| 287 | |
| 288 | /* --------------------------------------------- |
| 289 | * int console_flush(void) |
| 290 | * Function to force a write of all buffered |
| 291 | * data that hasn't been output. Calls all |
| 292 | * console's flush() handlers in succession. |
| 293 | * Out: x0 - 0 on success, < 0 if at least one error |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 294 | * Clobber list : x0, x1, x2 |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 295 | * --------------------------------------------- |
| 296 | */ |
| 297 | func console_flush |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 298 | stp x30, xzr, [sp, #-16]! |
| 299 | stp x20, x21, [sp, #-16]! |
| 300 | mov w20, #ERROR_NO_VALID_CONSOLE /* W20 = current return value */ |
| 301 | adrp x21, console_list |
| 302 | ldr x21, [x21, :lo12:console_list] /* X21 = first console struct */ |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 303 | |
| 304 | flush_loop: |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 305 | cbz x21, flush_done |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 306 | adrp x1, console_state |
| 307 | ldrb w1, [x1, :lo12:console_state] |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 308 | ldr w2, [x21, #CONSOLE_T_FLAGS] |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 309 | tst w1, w2 |
| 310 | b.eq flush_continue |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 311 | ldr x1, [x21, #CONSOLE_T_FLUSH] |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 312 | cbz x1, flush_continue |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 313 | mov x0, x21 |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 314 | blr x1 |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 315 | cmp w20, #ERROR_NO_VALID_CONSOLE /* update W20 if it's NOVALID */ |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 316 | ccmp w0, #0, #0x8, ne /* else update it if W0 < 0 */ |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 317 | csel w20, w0, w20, lt |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 318 | flush_continue: |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 319 | ldr x21, [x21] /* X21 = next struct */ |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 320 | b flush_loop |
| 321 | |
| 322 | flush_done: |
Sathees Balya | 28cfffc | 2018-07-31 15:11:11 +0100 | [diff] [blame] | 323 | mov w0, w20 |
| 324 | ldp x20, x21, [sp], #16 |
| 325 | ldp x30, xzr, [sp], #16 |
| 326 | ret |
Julius Werner | 94f8907 | 2017-07-31 18:15:11 -0700 | [diff] [blame] | 327 | endfunc console_flush |
Julius Werner | 6b88b65 | 2018-11-27 17:50:28 -0800 | [diff] [blame^] | 328 | |
| 329 | #endif /* MULTI_CONSOLE_API */ |