1 /*
2  * Copyright (c) 2015 Travis Geiselbrecht
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/reg.h>
9 #include <kernel/thread.h>
10 #include <platform.h>
11 #include <platform/interrupts.h>
12 #include <platform/debug.h>
13 #include <platform/timer.h>
14 #include <sys/types.h>
15 #include <target/microblaze-config.h>
16 
17 #include "uartlite.h"
18 
platform_dputc(char c)19 void platform_dputc(char c) {
20     if (c == '\n')
21         uartlite_putc('\r');
22     uartlite_putc(c);
23 }
24 
platform_dgetc(char * c,bool wait)25 int platform_dgetc(char *c, bool wait) {
26     for (;;) {
27         int ret = uartlite_getc(wait);
28         if (ret >= 0) {
29             *c = ret;
30             return 0;
31         }
32 
33         if (!wait)
34             return -1;
35 
36         thread_yield();
37     }
38 }
39 
40 
41