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 <sys/types.h> 10 #include <kernel/thread.h> 11 #include <platform.h> 12 #include <platform/interrupts.h> 13 #include <platform/debug.h> 14 #include <platform/timer.h> 15 #include <platform/sifive.h> 16 #include <dev/interrupt/riscv_plic.h> 17 18 #include "platform_p.h" 19 platform_early_init(void)20void platform_early_init(void) { 21 gpio_early_init(); 22 23 sifive_uart_early_init(); 24 25 plic_early_init(PLIC_BASE, SIFIVE_NUM_IRQS, true); 26 } 27 platform_init(void)28void platform_init(void) { 29 plic_init(); 30 gpio_init(); 31 sifive_uart_init(); 32 } 33 platform_dputc(char c)34void platform_dputc(char c) { 35 if (c == '\n') 36 sifive_uart_write('\r'); 37 sifive_uart_write(c); 38 } 39 platform_dgetc(char * c,bool wait)40int platform_dgetc(char *c, bool wait) { 41 return sifive_uart_read(c, wait); 42 } 43 44 45