Rev 4311 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4311 | Rev 4313 | ||
---|---|---|---|
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 | #include <arch/drivers/sgcn.h> |
40 | #include <arch/drivers/sgcn.h> |
41 | #include <genarch/srln/srln.h> |
41 | #include <genarch/srln/srln.h> |
42 | #include <console/chardev.h> |
42 | #include <console/chardev.h> |
43 | #include <console/console.h> |
43 | #include <console/console.h> |
44 | #include <arch/asm.h> |
44 | #include <arch/asm.h> |
45 | #include <arch/register.h> |
45 | #include <arch/register.h> |
46 | #include <proc/thread.h> |
46 | #include <proc/thread.h> |
47 | #include <arch/mm/tlb.h> |
47 | #include <arch/mm/tlb.h> |
48 | #include <genarch/ofw/ofw_tree.h> |
48 | #include <genarch/ofw/ofw_tree.h> |
49 | #include <arch.h> |
49 | #include <arch.h> |
50 | #include <panic.h> |
50 | #include <panic.h> |
51 | #include <string.h> |
51 | #include <string.h> |
52 | #include <print.h> |
52 | #include <print.h> |
53 | 53 | ||
54 | #define KEYBOARD_POLL_PAUSE 50000 /* 50ms */ |
54 | #define KEYBOARD_POLL_PAUSE 50000 /* 50ms */ |
55 | 55 | ||
56 | /** |
56 | /** |
57 | * Initialize kernel console to use framebuffer and keyboard directly. |
57 | * Initialize kernel console to use framebuffer and keyboard directly. |
58 | * Called on UltraSPARC machines with standard keyboard and framebuffer. |
58 | * Called on UltraSPARC machines with standard keyboard and framebuffer. |
59 | * |
59 | * |
60 | * @param aliases the "/aliases" OBP node |
60 | * @param aliases the "/aliases" OBP node |
61 | */ |
61 | */ |
62 | static void standard_console_init(ofw_tree_node_t *aliases) |
62 | static void standard_console_init(ofw_tree_node_t *aliases) |
63 | { |
63 | { |
64 | #ifdef CONFIG_FB |
64 | #ifdef CONFIG_FB |
65 | ofw_tree_property_t *prop_scr = ofw_tree_getprop(aliases, "screen"); |
65 | ofw_tree_property_t *prop_scr = ofw_tree_getprop(aliases, "screen"); |
66 | if (!prop_scr) |
66 | if (!prop_scr) |
67 | panic("Cannot find property 'screen'."); |
67 | panic("Cannot find property 'screen'."); |
68 | if (!prop_scr->value) |
68 | if (!prop_scr->value) |
69 | panic("Cannot find screen alias."); |
69 | panic("Cannot find screen alias."); |
70 | ofw_tree_node_t *screen = ofw_tree_lookup(prop_scr->value); |
70 | ofw_tree_node_t *screen = ofw_tree_lookup(prop_scr->value); |
71 | if (!screen) |
71 | if (!screen) |
72 | panic("Cannot find %s.", prop_scr->value); |
72 | panic("Cannot find %s.", prop_scr->value); |
73 | 73 | ||
74 | scr_init(screen); |
74 | scr_init(screen); |
75 | #endif |
75 | #endif |
76 | 76 | ||
77 | #ifdef CONFIG_SUN_KBD |
77 | #ifdef CONFIG_SUN_KBD |
78 | ofw_tree_property_t *prop_kbd = ofw_tree_getprop(aliases, "keyboard"); |
78 | ofw_tree_property_t *prop_kbd = ofw_tree_getprop(aliases, "keyboard"); |
79 | if (!prop_kbd) |
79 | if (!prop_kbd) |
80 | panic("Cannot find property 'keyboard'."); |
80 | panic("Cannot find property 'keyboard'."); |
81 | if (!prop_kbd->value) |
81 | if (!prop_kbd->value) |
82 | panic("Cannot find keyboard alias."); |
82 | panic("Cannot find keyboard alias."); |
83 | ofw_tree_node_t *keyboard = ofw_tree_lookup(prop_kbd->value); |
83 | ofw_tree_node_t *keyboard = ofw_tree_lookup(prop_kbd->value); |
84 | if (!keyboard) |
84 | if (!keyboard) |
85 | panic("Cannot find %s.", prop_kbd->value); |
85 | panic("Cannot find %s.", prop_kbd->value); |
86 | 86 | ||
87 | kbd_init(keyboard); |
87 | kbd_init(keyboard); |
88 | #endif |
88 | #endif |
89 | } |
89 | } |
90 | 90 | ||
91 | /** Initilize I/O on the Serengeti machine. */ |
91 | /** Initilize I/O on the Serengeti machine. */ |
92 | static void serengeti_init(void) |
92 | static void serengeti_init(void) |
93 | { |
93 | { |
94 | #ifdef CONFIG_SGCN_KBD |
94 | #ifdef CONFIG_SGCN_KBD |
- | 95 | sgcn_instance_t *sgcn_instance = sgcnin_init(); |
|
95 | indev_t *kbrdin; |
96 | if (sgcn_instance) { |
96 | kbrdin = sgcnin_init(); |
97 | srln_instance_t *srln_instance = srln_init(); |
97 | if (kbrdin) |
98 | if (srln_instance) { |
98 | srln_init(kbrdin); |
99 | indev_t *sink = stdin_wire(); |
- | 100 | indev_t *srln = srln_wire(srln_instance, sink); |
|
- | 101 | sgcnin_wire(sgcn_instance, srln); |
|
- | 102 | } |
|
- | 103 | } |
|
99 | #endif |
104 | #endif |
100 | #ifdef CONFIG_SGCN_PRN |
105 | #ifdef CONFIG_SGCN_PRN |
101 | sgcnout_init(); |
106 | sgcnout_init(); |
102 | #endif |
107 | #endif |
103 | } |
108 | } |
104 | 109 | ||
105 | /** |
110 | /** |
106 | * Initialize input/output. Auto-detects the type of machine |
111 | * Initialize input/output. Auto-detects the type of machine |
107 | * and calls the appropriate I/O init routine. |
112 | * and calls the appropriate I/O init routine. |
108 | */ |
113 | */ |
109 | void standalone_sparc64_console_init(void) |
114 | void standalone_sparc64_console_init(void) |
110 | { |
115 | { |
111 | ofw_tree_node_t *aliases; |
116 | ofw_tree_node_t *aliases; |
112 | ofw_tree_property_t *prop; |
117 | ofw_tree_property_t *prop; |
113 | 118 | ||
114 | aliases = ofw_tree_lookup("/aliases"); |
119 | aliases = ofw_tree_lookup("/aliases"); |
115 | if (!aliases) |
120 | if (!aliases) |
116 | panic("Cannot find '/aliases'."); |
121 | panic("Cannot find '/aliases'."); |
117 | 122 | ||
118 | /* "def-cn" = "default console" */ |
123 | /* "def-cn" = "default console" */ |
119 | prop = ofw_tree_getprop(aliases, "def-cn"); |
124 | prop = ofw_tree_getprop(aliases, "def-cn"); |
120 | 125 | ||
121 | if ((!prop) || (!prop->value) || (str_cmp(prop->value, "/sgcn") != 0)) { |
126 | if ((!prop) || (!prop->value) || (str_cmp(prop->value, "/sgcn") != 0)) { |
122 | standard_console_init(aliases); |
127 | standard_console_init(aliases); |
123 | } else { |
128 | } else { |
124 | serengeti_init(); |
129 | serengeti_init(); |
125 | } |
130 | } |
126 | } |
131 | } |
127 | 132 | ||
128 | 133 | ||
129 | /** Acquire console back for kernel |
134 | /** Acquire console back for kernel |
130 | * |
135 | * |
131 | */ |
136 | */ |
132 | void arch_grab_console(void) |
137 | void arch_grab_console(void) |
133 | { |
138 | { |
134 | #ifdef CONFIG_FB |
139 | #ifdef CONFIG_FB |
135 | scr_redraw(); |
140 | scr_redraw(); |
136 | #endif |
141 | #endif |
137 | 142 | ||
138 | #ifdef CONFIG_SGCN_KBD |
143 | #ifdef CONFIG_SGCN_KBD |
139 | sgcn_grab(); |
144 | sgcn_grab(); |
140 | #endif |
145 | #endif |
141 | } |
146 | } |
142 | 147 | ||
143 | /** Return console to userspace |
148 | /** Return console to userspace |
144 | * |
149 | * |
145 | */ |
150 | */ |
146 | void arch_release_console(void) |
151 | void arch_release_console(void) |
147 | { |
152 | { |
148 | #ifdef CONFIG_SGCN_KBD |
153 | #ifdef CONFIG_SGCN_KBD |
149 | sgcn_release(); |
154 | sgcn_release(); |
150 | #endif |
155 | #endif |
151 | } |
156 | } |
152 | 157 | ||
153 | /** @} |
158 | /** @} |
154 | */ |
159 | */ |
155 | 160 |