Rev 3817 | Rev 4073 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
426 | jermar | 1 | /* |
2071 | jermar | 2 | * Copyright (c) 2005 Jakub Jermar |
426 | jermar | 3 | * All rights reserved. |
4 | * |
||
5 | * Redistribution and use in source and binary forms, with or without |
||
6 | * modification, are permitted provided that the following conditions |
||
7 | * are met: |
||
8 | * |
||
9 | * - Redistributions of source code must retain the above copyright |
||
10 | * notice, this list of conditions and the following disclaimer. |
||
11 | * - Redistributions in binary form must reproduce the above copyright |
||
12 | * notice, this list of conditions and the following disclaimer in the |
||
13 | * documentation and/or other materials provided with the distribution. |
||
14 | * - The name of the author may not be used to endorse or promote products |
||
15 | * derived from this software without specific prior written permission. |
||
16 | * |
||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
||
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
27 | */ |
||
28 | |||
1769 | jermar | 29 | /** @addtogroup sparc64 |
1702 | cejka | 30 | * @{ |
31 | */ |
||
32 | /** @file |
||
33 | */ |
||
34 | |||
586 | jermar | 35 | #include <arch/console.h> |
669 | jermar | 36 | #include <arch/types.h> |
1842 | jermar | 37 | |
1897 | jermar | 38 | #include <arch/drivers/scr.h> |
1842 | jermar | 39 | #include <arch/drivers/kbd.h> |
1897 | jermar | 40 | |
3514 | rimsky | 41 | #include <arch/drivers/sgcn.h> |
42 | |||
3817 | rimsky | 43 | #if defined (SUN4U) |
44 | #ifdef CONFIG_Z8530 |
||
45 | #include <genarch/kbd/z8530.h> |
||
46 | #endif |
||
47 | #ifdef CONFIG_NS16550 |
||
48 | #include <genarch/kbd/ns16550.h> |
||
49 | #endif |
||
50 | #elif defined (SUN4V) |
||
51 | #include <arch/drivers/niagara.h> |
||
1842 | jermar | 52 | #endif |
53 | |||
893 | jermar | 54 | #include <console/chardev.h> |
55 | #include <console/console.h> |
||
56 | #include <arch/asm.h> |
||
57 | #include <arch/register.h> |
||
58 | #include <proc/thread.h> |
||
3862 | rimsky | 59 | #include <arch/mm/tlb.h> |
1896 | jermar | 60 | #include <genarch/ofw/ofw_tree.h> |
1880 | jermar | 61 | #include <arch.h> |
1896 | jermar | 62 | #include <panic.h> |
3549 | rimsky | 63 | #include <func.h> |
1896 | jermar | 64 | #include <print.h> |
426 | jermar | 65 | |
895 | jermar | 66 | #define KEYBOARD_POLL_PAUSE 50000 /* 50ms */ |
67 | |||
3817 | rimsky | 68 | #if defined (SUN4U) |
69 | |||
3549 | rimsky | 70 | /** |
71 | * Initialize kernel console to use framebuffer and keyboard directly. |
||
3742 | rimsky | 72 | * Called on UltraSPARC machines with standard keyboard and framebuffer. |
3549 | rimsky | 73 | * |
74 | * @param aliases the "/aliases" OBP node |
||
75 | */ |
||
76 | static void standard_console_init(ofw_tree_node_t *aliases) |
||
893 | jermar | 77 | { |
78 | stdin = NULL; |
||
1896 | jermar | 79 | |
80 | ofw_tree_property_t *prop; |
||
81 | ofw_tree_node_t *screen; |
||
82 | ofw_tree_node_t *keyboard; |
||
83 | |||
84 | prop = ofw_tree_getprop(aliases, "screen"); |
||
85 | if (!prop) |
||
86 | panic("Can't find property \"screen\".\n"); |
||
87 | if (!prop->value) |
||
88 | panic("Can't find screen alias.\n"); |
||
89 | screen = ofw_tree_lookup(prop->value); |
||
90 | if (!screen) |
||
91 | panic("Can't find %s\n", prop->value); |
||
92 | |||
1897 | jermar | 93 | scr_init(screen); |
94 | |||
1896 | jermar | 95 | prop = ofw_tree_getprop(aliases, "keyboard"); |
96 | if (!prop) |
||
97 | panic("Can't find property \"keyboard\".\n"); |
||
98 | if (!prop->value) |
||
99 | panic("Can't find keyboard alias.\n"); |
||
100 | keyboard = ofw_tree_lookup(prop->value); |
||
101 | if (!keyboard) |
||
102 | panic("Can't find %s\n", prop->value); |
||
897 | jermar | 103 | |
1896 | jermar | 104 | kbd_init(keyboard); |
586 | jermar | 105 | } |
893 | jermar | 106 | |
3549 | rimsky | 107 | /** Initilize I/O on the Serengeti machine. */ |
108 | static void serengeti_init(void) |
||
109 | { |
||
110 | sgcn_init(); |
||
111 | } |
||
112 | |||
3817 | rimsky | 113 | #endif |
114 | |||
3549 | rimsky | 115 | /** |
116 | * Initialize input/output. Auto-detects the type of machine |
||
117 | * and calls the appropriate I/O init routine. |
||
118 | */ |
||
119 | void standalone_sparc64_console_init(void) |
||
120 | { |
||
3817 | rimsky | 121 | #if defined (SUN4U) |
3549 | rimsky | 122 | ofw_tree_node_t *aliases; |
123 | ofw_tree_property_t *prop; |
||
124 | |||
125 | aliases = ofw_tree_lookup("/aliases"); |
||
126 | if (!aliases) |
||
127 | panic("Can't find /aliases.\n"); |
||
128 | |||
129 | /* "def-cn" = "default console" */ |
||
130 | prop = ofw_tree_getprop(aliases, "def-cn"); |
||
131 | |||
132 | if ((!prop) || (!prop->value) || (strcmp(prop->value, "/sgcn") != 0)) { |
||
133 | standard_console_init(aliases); |
||
134 | } else { |
||
135 | serengeti_init(); |
||
136 | } |
||
3817 | rimsky | 137 | #elif defined (SUN4V) |
138 | niagara_init(); |
||
139 | #endif |
||
3549 | rimsky | 140 | } |
141 | |||
142 | |||
895 | jermar | 143 | /** Kernel thread for polling keyboard. |
144 | * |
||
145 | * @param arg Ignored. |
||
146 | */ |
||
147 | void kkbdpoll(void *arg) |
||
148 | { |
||
1880 | jermar | 149 | thread_detach(THREAD); |
150 | |||
1842 | jermar | 151 | #ifdef CONFIG_Z8530 |
1931 | jermar | 152 | if (kbd_type == KBD_Z8530) { |
153 | /* |
||
154 | * The z8530 driver is interrupt-driven. |
||
155 | */ |
||
1849 | jermar | 156 | return; |
1931 | jermar | 157 | } |
1842 | jermar | 158 | #endif |
1896 | jermar | 159 | |
3665 | rimsky | 160 | #ifdef CONFIG_NS16550 |
161 | #ifdef CONFIG_NS16550_INTERRUPT_DRIVEN |
||
162 | if (kbd_type == KBD_NS16550) { |
||
163 | /* |
||
164 | * The ns16550 driver is interrupt-driven. |
||
165 | */ |
||
166 | return; |
||
167 | } |
||
168 | #endif |
||
169 | #endif |
||
1896 | jermar | 170 | while (1) { |
1844 | jermar | 171 | #ifdef CONFIG_NS16550 |
3665 | rimsky | 172 | #ifndef CONFIG_NS16550_INTERRUPT_DRIVEN |
1896 | jermar | 173 | if (kbd_type == KBD_NS16550) |
174 | ns16550_poll(); |
||
1842 | jermar | 175 | #endif |
3665 | rimsky | 176 | #endif |
3549 | rimsky | 177 | #ifdef CONFIG_SGCN |
178 | if (kbd_type == KBD_SGCN) |
||
179 | sgcn_poll(); |
||
180 | #endif |
||
3817 | rimsky | 181 | #ifdef SUN4V |
182 | if (kbd_type == KBD_SUN4V) |
||
183 | niagara_poll(); |
||
184 | #endif |
||
895 | jermar | 185 | thread_usleep(KEYBOARD_POLL_PAUSE); |
186 | } |
||
187 | } |
||
1702 | cejka | 188 | |
1875 | jermar | 189 | /** Acquire console back for kernel |
190 | * |
||
191 | */ |
||
192 | void arch_grab_console(void) |
||
193 | { |
||
3745 | rimsky | 194 | scr_redraw(); |
1931 | jermar | 195 | switch (kbd_type) { |
1875 | jermar | 196 | #ifdef CONFIG_Z8530 |
1931 | jermar | 197 | case KBD_Z8530: |
1896 | jermar | 198 | z8530_grab(); |
1931 | jermar | 199 | break; |
1875 | jermar | 200 | #endif |
1931 | jermar | 201 | #ifdef CONFIG_NS16550 |
202 | case KBD_NS16550: |
||
203 | ns16550_grab(); |
||
204 | break; |
||
205 | #endif |
||
3549 | rimsky | 206 | #ifdef CONFIG_SGCN |
207 | case KBD_SGCN: |
||
208 | sgcn_grab(); |
||
209 | break; |
||
210 | #endif |
||
1931 | jermar | 211 | default: |
212 | break; |
||
213 | } |
||
1875 | jermar | 214 | } |
215 | |||
216 | /** Return console to userspace |
||
217 | * |
||
218 | */ |
||
219 | void arch_release_console(void) |
||
220 | { |
||
1931 | jermar | 221 | switch (kbd_type) { |
1875 | jermar | 222 | #ifdef CONFIG_Z8530 |
1931 | jermar | 223 | case KBD_Z8530: |
1896 | jermar | 224 | z8530_release(); |
1931 | jermar | 225 | break; |
1875 | jermar | 226 | #endif |
1931 | jermar | 227 | #ifdef CONFIG_NS16550 |
228 | case KBD_NS16550: |
||
229 | ns16550_release(); |
||
230 | break; |
||
231 | #endif |
||
3618 | rimsky | 232 | #ifdef CONFIG_SGCN |
233 | case KBD_SGCN: |
||
234 | sgcn_release(); |
||
235 | break; |
||
236 | #endif |
||
1931 | jermar | 237 | default: |
238 | break; |
||
239 | } |
||
1875 | jermar | 240 | } |
1888 | jermar | 241 | |
1769 | jermar | 242 | /** @} |
1702 | cejka | 243 | */ |