1 | /*
|
---|
2 | * Copyright (c) 2005 Jakub 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 |
|
---|
29 | /** @addtogroup sparc64
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 | /** @file
|
---|
33 | */
|
---|
34 |
|
---|
35 | #include <arch/console.h>
|
---|
36 | #include <typedefs.h>
|
---|
37 |
|
---|
38 | #include <arch/drivers/scr.h>
|
---|
39 | #include <arch/drivers/kbd.h>
|
---|
40 | #include <genarch/srln/srln.h>
|
---|
41 | #include <console/chardev.h>
|
---|
42 | #include <console/console.h>
|
---|
43 | #include <arch/asm.h>
|
---|
44 | #include <arch/register.h>
|
---|
45 | #include <proc/thread.h>
|
---|
46 | #include <arch/mm/tlb.h>
|
---|
47 | #include <genarch/ofw/ofw_tree.h>
|
---|
48 | #include <arch.h>
|
---|
49 | #include <panic.h>
|
---|
50 | #include <str.h>
|
---|
51 | #include <print.h>
|
---|
52 |
|
---|
53 | #define KEYBOARD_POLL_PAUSE 50000 /* 50ms */
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Initialize kernel console to use framebuffer and keyboard directly.
|
---|
57 | * Called on UltraSPARC machines with standard keyboard and framebuffer.
|
---|
58 | *
|
---|
59 | * @param aliases the "/aliases" OBP node
|
---|
60 | */
|
---|
61 | static void standard_console_init(ofw_tree_node_t *aliases)
|
---|
62 | {
|
---|
63 | #ifdef CONFIG_FB
|
---|
64 | ofw_tree_property_t *prop_scr = ofw_tree_getprop(aliases, "screen");
|
---|
65 | if (!prop_scr)
|
---|
66 | panic("Cannot find property 'screen'.");
|
---|
67 | if (!prop_scr->value)
|
---|
68 | panic("Cannot find screen alias.");
|
---|
69 | ofw_tree_node_t *screen = ofw_tree_lookup(prop_scr->value);
|
---|
70 | if (!screen)
|
---|
71 | panic("Cannot find %s.", (char *) prop_scr->value);
|
---|
72 |
|
---|
73 | scr_init(screen);
|
---|
74 | #endif
|
---|
75 |
|
---|
76 | #ifdef CONFIG_SUN_KBD
|
---|
77 | ofw_tree_property_t *prop_kbd = ofw_tree_getprop(aliases, "keyboard");
|
---|
78 | if (!prop_kbd)
|
---|
79 | panic("Cannot find property 'keyboard'.");
|
---|
80 | if (!prop_kbd->value)
|
---|
81 | panic("Cannot find keyboard alias.");
|
---|
82 | ofw_tree_node_t *keyboard = ofw_tree_lookup(prop_kbd->value);
|
---|
83 | if (!keyboard)
|
---|
84 | panic("Cannot find %s.", (char *) prop_kbd->value);
|
---|
85 |
|
---|
86 | kbd_init(keyboard);
|
---|
87 | #endif
|
---|
88 | }
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * Initialize input/output. Auto-detects the type of machine
|
---|
92 | * and calls the appropriate I/O init routine.
|
---|
93 | */
|
---|
94 | void standalone_sparc64_console_init(void)
|
---|
95 | {
|
---|
96 | ofw_tree_node_t *aliases;
|
---|
97 | ofw_tree_property_t *prop;
|
---|
98 |
|
---|
99 | aliases = ofw_tree_lookup("/aliases");
|
---|
100 | if (!aliases)
|
---|
101 | panic("Cannot find '/aliases'.");
|
---|
102 |
|
---|
103 | /* "def-cn" = "default console" */
|
---|
104 | prop = ofw_tree_getprop(aliases, "def-cn");
|
---|
105 |
|
---|
106 | if ((!prop) || (!prop->value))
|
---|
107 | standard_console_init(aliases);
|
---|
108 | }
|
---|
109 |
|
---|
110 | /** @}
|
---|
111 | */
|
---|