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