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