Rev 4263 | 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 | |||
4327 | mejdrech | 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> |
4153 | mejdrech | 40 | #include <arch/drivers/sgcn.h> |
41 | #include <genarch/srln/srln.h> |
||
893 | jermar | 42 | #include <console/chardev.h> |
43 | #include <console/console.h> |
||
44 | #include <arch/asm.h> |
||
45 | #include <arch/register.h> |
||
46 | #include <proc/thread.h> |
||
897 | jermar | 47 | #include <arch/mm/tlb.h> |
1896 | jermar | 48 | #include <genarch/ofw/ofw_tree.h> |
1880 | jermar | 49 | #include <arch.h> |
1896 | jermar | 50 | #include <panic.h> |
4153 | mejdrech | 51 | #include <string.h> |
1896 | jermar | 52 | #include <print.h> |
426 | jermar | 53 | |
895 | jermar | 54 | #define KEYBOARD_POLL_PAUSE 50000 /* 50ms */ |
55 | |||
4153 | mejdrech | 56 | /** |
57 | * Initialize kernel console to use framebuffer and keyboard directly. |
||
58 | * Called on UltraSPARC machines with standard keyboard and framebuffer. |
||
59 | * |
||
60 | * @param aliases the "/aliases" OBP node |
||
61 | */ |
||
62 | static void standard_console_init(ofw_tree_node_t *aliases) |
||
893 | jermar | 63 | { |
4153 | mejdrech | 64 | #ifdef CONFIG_FB |
65 | ofw_tree_property_t *prop_scr = ofw_tree_getprop(aliases, "screen"); |
||
66 | if (!prop_scr) |
||
67 | panic("Cannot find property 'screen'."); |
||
68 | if (!prop_scr->value) |
||
69 | panic("Cannot find screen alias."); |
||
70 | ofw_tree_node_t *screen = ofw_tree_lookup(prop_scr->value); |
||
71 | if (!screen) |
||
72 | panic("Cannot find %s.", prop_scr->value); |
||
1896 | jermar | 73 | |
1897 | jermar | 74 | scr_init(screen); |
4153 | mejdrech | 75 | #endif |
1897 | jermar | 76 | |
4153 | mejdrech | 77 | #ifdef CONFIG_SUN_KBD |
78 | ofw_tree_property_t *prop_kbd = ofw_tree_getprop(aliases, "keyboard"); |
||
79 | if (!prop_kbd) |
||
80 | panic("Cannot find property 'keyboard'."); |
||
81 | if (!prop_kbd->value) |
||
82 | panic("Cannot find keyboard alias."); |
||
83 | ofw_tree_node_t *keyboard = ofw_tree_lookup(prop_kbd->value); |
||
1896 | jermar | 84 | if (!keyboard) |
4153 | mejdrech | 85 | panic("Cannot find %s.", prop_kbd->value); |
86 | |||
1896 | jermar | 87 | kbd_init(keyboard); |
4153 | mejdrech | 88 | #endif |
586 | jermar | 89 | } |
893 | jermar | 90 | |
4153 | mejdrech | 91 | /** Initilize I/O on the Serengeti machine. */ |
92 | static void serengeti_init(void) |
||
895 | jermar | 93 | { |
4153 | mejdrech | 94 | #ifdef CONFIG_SGCN_KBD |
4327 | mejdrech | 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 | } |
||
1842 | jermar | 104 | #endif |
4153 | mejdrech | 105 | #ifdef CONFIG_SGCN_PRN |
106 | sgcnout_init(); |
||
107 | #endif |
||
108 | } |
||
1896 | jermar | 109 | |
4153 | mejdrech | 110 | /** |
111 | * Initialize input/output. Auto-detects the type of machine |
||
112 | * and calls the appropriate I/O init routine. |
||
113 | */ |
||
114 | void standalone_sparc64_console_init(void) |
||
115 | { |
||
116 | ofw_tree_node_t *aliases; |
||
117 | ofw_tree_property_t *prop; |
||
118 | |||
119 | aliases = ofw_tree_lookup("/aliases"); |
||
120 | if (!aliases) |
||
121 | panic("Cannot find '/aliases'."); |
||
122 | |||
123 | /* "def-cn" = "default console" */ |
||
124 | prop = ofw_tree_getprop(aliases, "def-cn"); |
||
125 | |||
4263 | mejdrech | 126 | if ((!prop) || (!prop->value) || (str_cmp(prop->value, "/sgcn") != 0)) { |
4153 | mejdrech | 127 | standard_console_init(aliases); |
128 | } else { |
||
129 | serengeti_init(); |
||
895 | jermar | 130 | } |
131 | } |
||
1702 | cejka | 132 | |
4153 | mejdrech | 133 | |
1875 | jermar | 134 | /** Acquire console back for kernel |
135 | * |
||
136 | */ |
||
137 | void arch_grab_console(void) |
||
138 | { |
||
4153 | mejdrech | 139 | #ifdef CONFIG_FB |
140 | scr_redraw(); |
||
141 | #endif |
||
4327 | mejdrech | 142 | |
143 | #ifdef CONFIG_SGCN_KBD |
||
144 | sgcn_grab(); |
||
1875 | jermar | 145 | #endif |
146 | } |
||
147 | |||
148 | /** Return console to userspace |
||
149 | * |
||
150 | */ |
||
151 | void arch_release_console(void) |
||
152 | { |
||
4327 | mejdrech | 153 | #ifdef CONFIG_SGCN_KBD |
154 | sgcn_release(); |
||
1875 | jermar | 155 | #endif |
156 | } |
||
1888 | jermar | 157 | |
1769 | jermar | 158 | /** @} |
1702 | cejka | 159 | */ |