1 /* 2 * Copyright 2007, François Revol, revol@free.fr. 3 * Distributed under the terms of the MIT License. 4 * 5 * Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de. 6 * Distributed under the terms of the MIT License. 7 * 8 * Copyright 2001, Travis Geiselbrecht. All rights reserved. 9 * Distributed under the terms of the NewOS License. 10 */ 11 12 13 //#include <arch_platform.h> 14 #include <arch/debug_console.h> 15 #include <arch/generic/debug_uart.h> 16 #include <boot/kernel_args.h> 17 #include <kernel.h> 18 #include <vm/vm.h> 19 #include <string.h> 20 21 22 // TODO: Declare this in some header 23 DebugUART *gArchDebugUART; 24 extern DebugUART *debug_uart_from_fdt(const void *fdt); 25 26 27 void 28 arch_debug_remove_interrupt_handler(uint32 line) 29 { 30 } 31 32 33 void 34 arch_debug_install_interrupt_handlers(void) 35 { 36 } 37 38 39 int 40 arch_debug_blue_screen_try_getchar(void) 41 { 42 // TODO: Implement correctly! 43 return arch_debug_blue_screen_getchar(); 44 } 45 46 47 char 48 arch_debug_blue_screen_getchar(void) 49 { 50 return arch_debug_serial_getchar(); 51 } 52 53 54 int 55 arch_debug_serial_try_getchar(void) 56 { 57 // TODO: Implement correctly! 58 return arch_debug_serial_getchar(); 59 } 60 61 62 char 63 arch_debug_serial_getchar(void) 64 { 65 return gArchDebugUART->GetChar(false); 66 } 67 68 69 void 70 arch_debug_serial_putchar(const char c) 71 { 72 gArchDebugUART->PutChar(c); 73 } 74 75 76 void 77 arch_debug_serial_puts(const char *s) 78 { 79 while (*s != '\0') { 80 arch_debug_serial_putchar(*s); 81 s++; 82 } 83 } 84 85 86 void 87 arch_debug_serial_early_boot_message(const char *string) 88 { 89 // this function will only be called in fatal situations 90 arch_debug_serial_puts(string); 91 } 92 93 94 status_t 95 arch_debug_console_init(kernel_args *args) 96 { 97 // first try with hints from the FDT 98 // TODO: Use UEFI somehow 99 100 //gArchDebugUART = debug_uart_from_fdt(args->platform_args.fdt); 101 102 // Do we can some kind of direct fallback here 103 // (aka, guess arch_get_uart_pl011 or arch_get_uart_8250?) 104 if (gArchDebugUART == NULL) 105 return B_ERROR; 106 107 gArchDebugUART->InitEarly(); 108 109 return B_OK; 110 } 111 112 113 status_t 114 arch_debug_console_init_settings(kernel_args *args) 115 { 116 return B_OK; 117 } 118