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