blob: b7c5e9444fd02922ffef02c3a53ba9921af5cd8d [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include "asm_macros.S"
8#include "platform.h"
9
10/*
11 * PL011 UART registers
12 */
13/* UART Flag Register */
14#define UARTFR 0x018
15/* Transmit FIFO full bit in UARTFR register */
16#define PL011_UARTFR_TXFF_BIT 5
17/* UART Data Register */
18#define UARTDR 0x000
19
20 .text
21 .global print_string
22 .global print_char
23
24 /*
25 * void print_char(unsigned int c);
26 * clobbers: x3, x4
27 */
28func print_char
29 ldr x3, =UART_BASE
301:
31 /* Check if the transmit FIFO is full */
32 ldr w4, [x3, #UARTFR]
33 tbnz w4, #PL011_UARTFR_TXFF_BIT, 1b
34 str w0, [x3, #UARTDR]
35 ret
36endfunc print_char
37
38 /*
39 * void print_string(const char *str);
40 * clobbers: x0, x1, x2, x9
41 */
42func print_string
43 ldr x1, =UART_BASE
44 mov x2, x0
451:
46 ldrb w0, [x2], #1
47 cmp wzr, w0
48 b.eq 2f
49
50 mov x9, x30
51 bl print_char
52 mov x30, x9
53 b 1b
542:
55 ret
56endfunc print_string