Rev 3675 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3675 | Rev 4377 | ||
|---|---|---|---|
| Line 24... | Line 24... | ||
| 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 | - | ||
| 43 | #ifdef CONFIG_Z8530 |
- | |
| 44 | #include <genarch/kbd/z8530.h> |
41 | #include <genarch/srln/srln.h> |
| 45 | #endif |
- | |
| 46 | #ifdef CONFIG_NS16550 |
- | |
| 47 | #include <genarch/kbd/ns16550.h> |
- | |
| 48 | #endif |
- | |
| 49 | - | ||
| 50 | #include <console/chardev.h> |
42 | #include <console/chardev.h> |
| 51 | #include <console/console.h> |
43 | #include <console/console.h> |
| 52 | #include <arch/asm.h> |
44 | #include <arch/asm.h> |
| 53 | #include <arch/register.h> |
45 | #include <arch/register.h> |
| 54 | #include <proc/thread.h> |
46 | #include <proc/thread.h> |
| 55 | #include <arch/mm/tlb.h> |
47 | #include <arch/mm/tlb.h> |
| 56 | #include <genarch/ofw/ofw_tree.h> |
48 | #include <genarch/ofw/ofw_tree.h> |
| 57 | #include <arch.h> |
49 | #include <arch.h> |
| 58 | #include <panic.h> |
50 | #include <panic.h> |
| 59 | #include <func.h> |
51 | #include <string.h> |
| 60 | #include <print.h> |
52 | #include <print.h> |
| 61 | 53 | ||
| 62 | #define KEYBOARD_POLL_PAUSE 50000 /* 50ms */ |
54 | #define KEYBOARD_POLL_PAUSE 50000 /* 50ms */ |
| 63 | 55 | ||
| 64 | /** |
56 | /** |
| Line 67... | Line 59... | ||
| 67 | * |
59 | * |
| 68 | * @param aliases the "/aliases" OBP node |
60 | * @param aliases the "/aliases" OBP node |
| 69 | */ |
61 | */ |
| 70 | static void standard_console_init(ofw_tree_node_t *aliases) |
62 | static void standard_console_init(ofw_tree_node_t *aliases) |
| 71 | { |
63 | { |
| 72 | stdin = NULL; |
64 | #ifdef CONFIG_FB |
| 73 | - | ||
| 74 | ofw_tree_property_t *prop; |
- | |
| 75 | ofw_tree_node_t *screen; |
- | |
| 76 | ofw_tree_node_t *keyboard; |
- | |
| 77 | - | ||
| 78 | prop = ofw_tree_getprop(aliases, "screen"); |
65 | ofw_tree_property_t *prop_scr = ofw_tree_getprop(aliases, "screen"); |
| 79 | if (!prop) |
66 | if (!prop_scr) |
| 80 | panic("Can't find property \"screen\".\n"); |
67 | panic("Cannot find property 'screen'."); |
| 81 | if (!prop->value) |
68 | if (!prop_scr->value) |
| 82 | panic("Can't find screen alias.\n"); |
69 | panic("Cannot find screen alias."); |
| 83 | screen = ofw_tree_lookup(prop->value); |
70 | ofw_tree_node_t *screen = ofw_tree_lookup(prop_scr->value); |
| 84 | if (!screen) |
71 | if (!screen) |
| 85 | panic("Can't find %s\n", prop->value); |
72 | panic("Cannot find %s.", prop_scr->value); |
| 86 | 73 | ||
| 87 | scr_init(screen); |
74 | scr_init(screen); |
| - | 75 | #endif |
|
| 88 | 76 | ||
| - | 77 | #ifdef CONFIG_SUN_KBD |
|
| 89 | prop = ofw_tree_getprop(aliases, "keyboard"); |
78 | ofw_tree_property_t *prop_kbd = ofw_tree_getprop(aliases, "keyboard"); |
| 90 | if (!prop) |
79 | if (!prop_kbd) |
| 91 | panic("Can't find property \"keyboard\".\n"); |
80 | panic("Cannot find property 'keyboard'."); |
| 92 | if (!prop->value) |
81 | if (!prop_kbd->value) |
| 93 | panic("Can't find keyboard alias.\n"); |
82 | panic("Cannot find keyboard alias."); |
| 94 | keyboard = ofw_tree_lookup(prop->value); |
83 | ofw_tree_node_t *keyboard = ofw_tree_lookup(prop_kbd->value); |
| 95 | if (!keyboard) |
84 | if (!keyboard) |
| 96 | panic("Can't find %s\n", prop->value); |
85 | panic("Cannot find %s.", prop_kbd->value); |
| 97 | 86 | ||
| 98 | kbd_init(keyboard); |
87 | kbd_init(keyboard); |
| - | 88 | #endif |
|
| 99 | } |
89 | } |
| 100 | 90 | ||
| 101 | /** Initilize I/O on the Serengeti machine. */ |
91 | /** Initilize I/O on the Serengeti machine. */ |
| 102 | static void serengeti_init(void) |
92 | static void serengeti_init(void) |
| 103 | { |
93 | { |
| - | 94 | #ifdef CONFIG_SGCN_KBD |
|
| - | 95 | sgcn_instance_t *sgcn_instance = sgcnin_init(); |
|
| - | 96 | if (sgcn_instance) { |
|
| - | 97 | srln_instance_t *srln_instance = srln_init(); |
|
| - | 98 | if (srln_instance) { |
|
| - | 99 | indev_t *sink = stdin_wire(); |
|
| - | 100 | indev_t *srln = srln_wire(srln_instance, sink); |
|
| - | 101 | sgcnin_wire(sgcn_instance, srln); |
|
| - | 102 | } |
|
| - | 103 | } |
|
| - | 104 | #endif |
|
| - | 105 | #ifdef CONFIG_SGCN_PRN |
|
| 104 | sgcn_init(); |
106 | sgcnout_init(); |
| - | 107 | #endif |
|
| 105 | } |
108 | } |
| 106 | 109 | ||
| 107 | /** |
110 | /** |
| 108 | * Initialize input/output. Auto-detects the type of machine |
111 | * Initialize input/output. Auto-detects the type of machine |
| 109 | * and calls the appropriate I/O init routine. |
112 | * and calls the appropriate I/O init routine. |
| Line 113... | Line 116... | ||
| 113 | ofw_tree_node_t *aliases; |
116 | ofw_tree_node_t *aliases; |
| 114 | ofw_tree_property_t *prop; |
117 | ofw_tree_property_t *prop; |
| 115 | 118 | ||
| 116 | aliases = ofw_tree_lookup("/aliases"); |
119 | aliases = ofw_tree_lookup("/aliases"); |
| 117 | if (!aliases) |
120 | if (!aliases) |
| 118 | panic("Can't find /aliases.\n"); |
121 | panic("Cannot find '/aliases'."); |
| 119 | 122 | ||
| 120 | /* "def-cn" = "default console" */ |
123 | /* "def-cn" = "default console" */ |
| 121 | prop = ofw_tree_getprop(aliases, "def-cn"); |
124 | prop = ofw_tree_getprop(aliases, "def-cn"); |
| 122 | 125 | ||
| 123 | if ((!prop) || (!prop->value) || (strcmp(prop->value, "/sgcn") != 0)) { |
126 | if ((!prop) || (!prop->value) || (str_cmp(prop->value, "/sgcn") != 0)) { |
| 124 | standard_console_init(aliases); |
127 | standard_console_init(aliases); |
| 125 | } else { |
128 | } else { |
| 126 | serengeti_init(); |
129 | serengeti_init(); |
| 127 | } |
130 | } |
| 128 | } |
131 | } |
| 129 | 132 | ||
| 130 | 133 | ||
| 131 | /** Kernel thread for polling keyboard. |
- | |
| 132 | * |
- | |
| 133 | * @param arg Ignored. |
- | |
| 134 | */ |
- | |
| 135 | void kkbdpoll(void *arg) |
- | |
| 136 | { |
- | |
| 137 | thread_detach(THREAD); |
- | |
| 138 | - | ||
| 139 | #ifdef CONFIG_Z8530 |
- | |
| 140 | if (kbd_type == KBD_Z8530) { |
- | |
| 141 | /* |
- | |
| 142 | * The z8530 driver is interrupt-driven. |
- | |
| 143 | */ |
- | |
| 144 | return; |
- | |
| 145 | } |
- | |
| 146 | #endif |
- | |
| 147 | - | ||
| 148 | #ifdef CONFIG_NS16550 |
- | |
| 149 | #ifdef CONFIG_NS16550_INTERRUPT_DRIVEN |
- | |
| 150 | if (kbd_type == KBD_NS16550) { |
- | |
| 151 | /* |
- | |
| 152 | * The ns16550 driver is interrupt-driven. |
- | |
| 153 | */ |
- | |
| 154 | return; |
- | |
| 155 | } |
- | |
| 156 | #endif |
- | |
| 157 | #endif |
- | |
| 158 | while (1) { |
- | |
| 159 | #ifdef CONFIG_NS16550 |
- | |
| 160 | #ifndef CONFIG_NS16550_INTERRUPT_DRIVEN |
- | |
| 161 | if (kbd_type == KBD_NS16550) |
- | |
| 162 | ns16550_poll(); |
- | |
| 163 | #endif |
- | |
| 164 | #endif |
- | |
| 165 | #ifdef CONFIG_SGCN |
- | |
| 166 | if (kbd_type == KBD_SGCN) |
- | |
| 167 | sgcn_poll(); |
- | |
| 168 | #endif |
- | |
| 169 | thread_usleep(KEYBOARD_POLL_PAUSE); |
- | |
| 170 | } |
- | |
| 171 | } |
- | |
| 172 | - | ||
| 173 | /** Acquire console back for kernel |
134 | /** Acquire console back for kernel |
| 174 | * |
135 | * |
| 175 | */ |
136 | */ |
| 176 | void arch_grab_console(void) |
137 | void arch_grab_console(void) |
| 177 | { |
138 | { |
| 178 | switch (kbd_type) { |
- | |
| 179 | #ifdef CONFIG_Z8530 |
139 | #ifdef CONFIG_FB |
| 180 | case KBD_Z8530: |
- | |
| 181 | z8530_grab(); |
140 | scr_redraw(); |
| 182 | break; |
- | |
| 183 | #endif |
141 | #endif |
| 184 | #ifdef CONFIG_NS16550 |
- | |
| 185 | case KBD_NS16550: |
- | |
| 186 | ns16550_grab(); |
- | |
| 187 | break; |
142 | |
| 188 | #endif |
- | |
| 189 | #ifdef CONFIG_SGCN |
143 | #ifdef CONFIG_SGCN_KBD |
| 190 | case KBD_SGCN: |
- | |
| 191 | sgcn_grab(); |
144 | sgcn_grab(); |
| 192 | break; |
- | |
| 193 | #endif |
145 | #endif |
| 194 | default: |
- | |
| 195 | break; |
- | |
| 196 | } |
- | |
| 197 | } |
146 | } |
| 198 | 147 | ||
| 199 | /** Return console to userspace |
148 | /** Return console to userspace |
| 200 | * |
149 | * |
| 201 | */ |
150 | */ |
| 202 | void arch_release_console(void) |
151 | void arch_release_console(void) |
| 203 | { |
152 | { |
| 204 | switch (kbd_type) { |
- | |
| 205 | #ifdef CONFIG_Z8530 |
- | |
| 206 | case KBD_Z8530: |
- | |
| 207 | z8530_release(); |
- | |
| 208 | break; |
- | |
| 209 | #endif |
- | |
| 210 | #ifdef CONFIG_NS16550 |
- | |
| 211 | case KBD_NS16550: |
- | |
| 212 | ns16550_release(); |
- | |
| 213 | break; |
- | |
| 214 | #endif |
- | |
| 215 | #ifdef CONFIG_SGCN |
153 | #ifdef CONFIG_SGCN_KBD |
| 216 | case KBD_SGCN: |
- | |
| 217 | sgcn_release(); |
154 | sgcn_release(); |
| 218 | break; |
- | |
| 219 | #endif |
155 | #endif |
| 220 | default: |
- | |
| 221 | break; |
- | |
| 222 | } |
- | |
| 223 | } |
156 | } |
| 224 | 157 | ||
| 225 | /** @} |
158 | /** @} |
| 226 | */ |
159 | */ |