xref: /haiku/src/system/kernel/arch/arm/arch_debug_console.cpp (revision a267f17ca645ceae1728e10680c6d1377589eef1)
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 <arch/arm/arch_uart_pl011.h>
17 #include <boot/kernel_args.h>
18 #include <kernel.h>
19 #include <vm/vm.h>
20 #include <string.h>
21 
22 
23 // TODO: Declare this in some header
24 DebugUART *gArchDebugUART;
25 extern DebugUART *debug_uart_from_fdt(const void *fdt);
26 
27 
28 void
29 arch_debug_remove_interrupt_handler(uint32 line)
30 {
31 }
32 
33 
34 void
35 arch_debug_install_interrupt_handlers(void)
36 {
37 }
38 
39 
40 int
41 arch_debug_blue_screen_try_getchar(void)
42 {
43 	// TODO: Implement correctly!
44 	return arch_debug_blue_screen_getchar();
45 }
46 
47 
48 char
49 arch_debug_blue_screen_getchar(void)
50 {
51 	return arch_debug_serial_getchar();
52 }
53 
54 
55 int
56 arch_debug_serial_try_getchar(void)
57 {
58 	// TODO: Implement correctly!
59 	return arch_debug_serial_getchar();
60 }
61 
62 
63 char
64 arch_debug_serial_getchar(void)
65 {
66 	if (gArchDebugUART == NULL)
67 		return NULL;
68 
69 	return gArchDebugUART->GetChar(false);
70 }
71 
72 
73 void
74 arch_debug_serial_putchar(const char c)
75 {
76 	if (gArchDebugUART == NULL)
77 		return;
78 
79 	gArchDebugUART->PutChar(c);
80 }
81 
82 
83 void
84 arch_debug_serial_puts(const char *s)
85 {
86 	while (*s != '\0') {
87 		arch_debug_serial_putchar(*s);
88 		s++;
89 	}
90 }
91 
92 
93 void
94 arch_debug_serial_early_boot_message(const char *string)
95 {
96 	// this function will only be called in fatal situations
97 	arch_debug_serial_puts(string);
98 }
99 
100 
101 status_t
102 arch_debug_console_init(kernel_args *args)
103 {
104 	// first try with hints from the FDT
105 	// TODO: Use UEFI somehow to get fdt
106 	//gArchDebugUART = debug_uart_from_fdt(args->platform_args.fdt);
107 
108 	// As a last try, lets assume qemu's pl011 at a sane address
109 	if (gArchDebugUART == NULL)
110 		gArchDebugUART = arch_get_uart_pl011(0x9000000, 0x16e3600);
111 
112 	// Oh well.
113 	if (gArchDebugUART == NULL)
114 		return B_ERROR;
115 
116 	gArchDebugUART->InitEarly();
117 
118 	return B_OK;
119 }
120 
121 
122 status_t
123 arch_debug_console_init_settings(kernel_args *args)
124 {
125 	return B_OK;
126 }
127