1 /*
2  * Copyright (c) 2015 MediaTek Inc.
3  *
4  * Use of this source code is governed by a MIT-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/MIT
7  */
8 #include <lk/debug.h>
9 #include <arch/ops.h>
10 #include <stdarg.h>
11 #include <dev/uart.h>
12 #include <platform/mt_uart.h>
13 #include <platform.h>
14 
_dputc(char c)15 void _dputc(char c) {
16     int port = mtk_get_current_uart();
17 
18     if (c == '\n') {
19         uart_putc(port, '\r');
20     }
21 
22     uart_putc(port, c);
23 }
24 
dgetc(char * c,bool wait)25 int dgetc(char *c, bool wait) {
26     int _c;
27     int port = mtk_get_current_uart();
28 
29     if ((_c = uart_getc(port, wait)) < 0) {
30         return -1;
31     }
32 
33     *c = _c;
34     return 0;
35 }
36 
platform_halt(platform_halt_action suggested_action,platform_halt_reason reason)37 void platform_halt(platform_halt_action suggested_action, platform_halt_reason reason) {
38     arch_disable_ints();
39     for (;;);
40 }
41 
debug_cycle_count(void)42 uint32_t debug_cycle_count(void) {
43     PANIC_UNIMPLEMENTED;
44 }
45 
platform_dputc(char c)46 void platform_dputc(char c) {
47     if (c == '\n') {
48         _dputc('\r');
49     }
50 
51     _dputc(c);
52 }
53 
platform_dgetc(char * c,bool wait)54 int platform_dgetc(char *c, bool wait) {
55     return dgetc(c, wait);
56 }
57