[437ee6a4] | 1 | /*
|
---|
[df4ed85] | 2 | * Copyright (c) 2005 Jakub Jermar
|
---|
[437ee6a4] | 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 |
|
---|
[c2417bc] | 29 | /** @addtogroup sparc64
|
---|
[b45c443] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | */
|
---|
| 34 |
|
---|
[adb2ebf8] | 35 | #include <arch/console.h>
|
---|
[d99c1d2] | 36 | #include <typedefs.h>
|
---|
[287920f] | 37 |
|
---|
[5d684e4] | 38 | #include <arch/drivers/scr.h>
|
---|
[287920f] | 39 | #include <arch/drivers/kbd.h>
|
---|
[965dc18] | 40 | #include <arch/drivers/sgcn.h>
|
---|
[de88998] | 41 | #include <genarch/srln/srln.h>
|
---|
[481c520] | 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>
|
---|
[97f1691] | 47 | #include <arch/mm/tlb.h>
|
---|
[28ecadb] | 48 | #include <genarch/ofw/ofw_tree.h>
|
---|
[7bb6b06] | 49 | #include <arch.h>
|
---|
[28ecadb] | 50 | #include <panic.h>
|
---|
[19f857a] | 51 | #include <str.h>
|
---|
[28ecadb] | 52 | #include <print.h>
|
---|
[adb2ebf8] | 53 |
|
---|
[30ab05f] | 54 | #define KEYBOARD_POLL_PAUSE 50000 /* 50ms */
|
---|
| 55 |
|
---|
[965dc18] | 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)
|
---|
[481c520] | 63 | {
|
---|
[753d851] | 64 | #ifdef CONFIG_FB
|
---|
[9693835] | 65 | ofw_tree_property_t *prop_scr = ofw_tree_getprop(aliases, "screen");
|
---|
| 66 | if (!prop_scr)
|
---|
[f651e80] | 67 | panic("Cannot find property 'screen'.");
|
---|
[9693835] | 68 | if (!prop_scr->value)
|
---|
[f651e80] | 69 | panic("Cannot find screen alias.");
|
---|
[9693835] | 70 | ofw_tree_node_t *screen = ofw_tree_lookup(prop_scr->value);
|
---|
[28ecadb] | 71 | if (!screen)
|
---|
[7e752b2] | 72 | panic("Cannot find %s.", (char *) prop_scr->value);
|
---|
[9693835] | 73 |
|
---|
[5d684e4] | 74 | scr_init(screen);
|
---|
[9693835] | 75 | #endif
|
---|
[5d684e4] | 76 |
|
---|
[9693835] | 77 | #ifdef CONFIG_SUN_KBD
|
---|
| 78 | ofw_tree_property_t *prop_kbd = ofw_tree_getprop(aliases, "keyboard");
|
---|
| 79 | if (!prop_kbd)
|
---|
[f651e80] | 80 | panic("Cannot find property 'keyboard'.");
|
---|
[9693835] | 81 | if (!prop_kbd->value)
|
---|
[f651e80] | 82 | panic("Cannot find keyboard alias.");
|
---|
[9693835] | 83 | ofw_tree_node_t *keyboard = ofw_tree_lookup(prop_kbd->value);
|
---|
[28ecadb] | 84 | if (!keyboard)
|
---|
[7e752b2] | 85 | panic("Cannot find %s.", (char *) prop_kbd->value);
|
---|
[9693835] | 86 |
|
---|
[28ecadb] | 87 | kbd_init(keyboard);
|
---|
[753d851] | 88 | #endif
|
---|
[30ab05f] | 89 | }
|
---|
| 90 |
|
---|
[965dc18] | 91 | /** Initilize I/O on the Serengeti machine. */
|
---|
| 92 | static void serengeti_init(void)
|
---|
| 93 | {
|
---|
[08fed0a] | 94 | #ifdef CONFIG_SGCN_KBD
|
---|
[253d3d0] | 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 | }
|
---|
[08fed0a] | 104 | #endif
|
---|
[a71c158] | 105 |
|
---|
[08fed0a] | 106 | #ifdef CONFIG_SGCN_PRN
|
---|
[a71c158] | 107 | outdev_t *sgcndev = sgcnout_init();
|
---|
| 108 | if (sgcndev)
|
---|
| 109 | stdout_wire(sgcndev);
|
---|
[05915ba4] | 110 | #endif
|
---|
[965dc18] | 111 | }
|
---|
| 112 |
|
---|
| 113 | /**
|
---|
| 114 | * Initialize input/output. Auto-detects the type of machine
|
---|
| 115 | * and calls the appropriate I/O init routine.
|
---|
| 116 | */
|
---|
| 117 | void standalone_sparc64_console_init(void)
|
---|
| 118 | {
|
---|
| 119 | ofw_tree_node_t *aliases;
|
---|
| 120 | ofw_tree_property_t *prop;
|
---|
| 121 |
|
---|
| 122 | aliases = ofw_tree_lookup("/aliases");
|
---|
| 123 | if (!aliases)
|
---|
[f651e80] | 124 | panic("Cannot find '/aliases'.");
|
---|
[965dc18] | 125 |
|
---|
| 126 | /* "def-cn" = "default console" */
|
---|
| 127 | prop = ofw_tree_getprop(aliases, "def-cn");
|
---|
| 128 |
|
---|
[b60c582] | 129 | if ((!prop) || (!prop->value) || (str_cmp(prop->value, "/sgcn") != 0)) {
|
---|
[965dc18] | 130 | standard_console_init(aliases);
|
---|
| 131 | } else {
|
---|
| 132 | serengeti_init();
|
---|
| 133 | }
|
---|
| 134 | }
|
---|
| 135 |
|
---|
[2f40fe4] | 136 | /** @}
|
---|
[b45c443] | 137 | */
|
---|