2015-01-31 17:31:03 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 Travis Geiselbrecht
|
|
|
|
|
*
|
2019-07-05 17:22:23 -07:00
|
|
|
* Use of this source code is governed by a MIT-style
|
|
|
|
|
* license that can be found in the LICENSE file or at
|
|
|
|
|
* https://opensource.org/licenses/MIT
|
2015-01-31 17:31:03 -08:00
|
|
|
*/
|
2019-06-17 18:28:51 -07:00
|
|
|
#include <lk/reg.h>
|
2015-01-31 17:51:37 -08:00
|
|
|
#include <kernel/thread.h>
|
2015-01-31 17:31:03 -08:00
|
|
|
#include <platform.h>
|
|
|
|
|
#include <platform/interrupts.h>
|
|
|
|
|
#include <platform/debug.h>
|
|
|
|
|
#include <platform/timer.h>
|
|
|
|
|
#include <sys/types.h>
|
2015-04-19 01:20:32 -07:00
|
|
|
#include <target/microblaze-config.h>
|
2015-01-31 17:31:03 -08:00
|
|
|
|
2021-10-21 23:18:09 -07:00
|
|
|
#include "uartlite.h"
|
2015-01-31 17:31:03 -08:00
|
|
|
|
2019-06-19 20:54:28 -07:00
|
|
|
void platform_dputc(char c) {
|
2015-01-31 17:31:03 -08:00
|
|
|
if (c == '\n')
|
2015-01-31 17:51:37 -08:00
|
|
|
uartlite_putc('\r');
|
|
|
|
|
uartlite_putc(c);
|
2015-01-31 17:31:03 -08:00
|
|
|
}
|
|
|
|
|
|
2019-06-19 20:54:28 -07:00
|
|
|
int platform_dgetc(char *c, bool wait) {
|
2015-01-31 17:51:37 -08:00
|
|
|
for (;;) {
|
2015-01-31 19:52:57 -08:00
|
|
|
int ret = uartlite_getc(wait);
|
2015-01-31 17:51:37 -08:00
|
|
|
if (ret >= 0) {
|
|
|
|
|
*c = ret;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!wait)
|
|
|
|
|
return -1;
|
2015-01-31 17:31:03 -08:00
|
|
|
|
2015-01-31 17:51:37 -08:00
|
|
|
thread_yield();
|
|
|
|
|
}
|
2015-01-31 17:31:03 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|