source: mainline/kernel/arch/sparc64/src/console.c

Last change on this file was 1b1be5f, checked in by Jakub Jermar <jakub@…>, 6 years ago

Add support for serial kernel console on sun4u

This feature is currently disabled by default (CONFIG_SUN_TTY) due to
the following behavior observed with QEMU 3.1. After producing a couple
of lines of serial output, the kernel seems to hang on an IO read of the
NS 16550's LSR register (which it needs in order to test for
LSR_TH_READY). Providing some input on the serial console results in
unblocking the kernel for a while until it blocks again a couple of
lines of output later.

  • Property mode set to 100644
File size: 3.6 KB
RevLine 
[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
[c5429fe]29/** @addtogroup kernel_sparc64
[b45c443]30 * @{
31 */
32/** @file
33 */
34
[adb2ebf8]35#include <arch/console.h>
[287920f]36
[5d684e4]37#include <arch/drivers/scr.h>
[287920f]38#include <arch/drivers/kbd.h>
[1b1be5f]39#include <arch/drivers/tty.h>
[de88998]40#include <genarch/srln/srln.h>
[481c520]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>
[97f1691]46#include <arch/mm/tlb.h>
[28ecadb]47#include <genarch/ofw/ofw_tree.h>
[7bb6b06]48#include <arch.h>
[28ecadb]49#include <panic.h>
[19f857a]50#include <str.h>
[adb2ebf8]51
[30ab05f]52#define KEYBOARD_POLL_PAUSE 50000 /* 50ms */
53
[965dc18]54/**
55 * Initialize kernel console to use framebuffer and keyboard directly.
56 * Called on UltraSPARC machines with standard keyboard and framebuffer.
57 *
[1b20da0]58 * @param aliases the "/aliases" OBP node
[965dc18]59 */
60static void standard_console_init(ofw_tree_node_t *aliases)
[481c520]61{
[753d851]62#ifdef CONFIG_FB
[9693835]63 ofw_tree_property_t *prop_scr = ofw_tree_getprop(aliases, "screen");
64 if (!prop_scr)
[f651e80]65 panic("Cannot find property 'screen'.");
[9693835]66 if (!prop_scr->value)
[f651e80]67 panic("Cannot find screen alias.");
[9693835]68 ofw_tree_node_t *screen = ofw_tree_lookup(prop_scr->value);
[28ecadb]69 if (!screen)
[7e752b2]70 panic("Cannot find %s.", (char *) prop_scr->value);
[a35b458]71
[5d684e4]72 scr_init(screen);
[9693835]73#endif
[5d684e4]74
[9693835]75#ifdef CONFIG_SUN_KBD
76 ofw_tree_property_t *prop_kbd = ofw_tree_getprop(aliases, "keyboard");
77 if (!prop_kbd)
[f651e80]78 panic("Cannot find property 'keyboard'.");
[9693835]79 if (!prop_kbd->value)
[f651e80]80 panic("Cannot find keyboard alias.");
[9693835]81 ofw_tree_node_t *keyboard = ofw_tree_lookup(prop_kbd->value);
[28ecadb]82 if (!keyboard)
[7e752b2]83 panic("Cannot find %s.", (char *) prop_kbd->value);
[a35b458]84
[28ecadb]85 kbd_init(keyboard);
[753d851]86#endif
[1b1be5f]87
88#ifdef CONFIG_SUN_TTY
89 ofw_tree_property_t *prop_tty = ofw_tree_getprop(aliases, "ttya");
90 if (prop_tty && prop_tty->value) {
91 ofw_tree_node_t *tty = ofw_tree_lookup(prop_tty->value);
92 if (tty)
93 tty_init(tty);
94 }
95#endif
[30ab05f]96}
97
[965dc18]98/**
99 * Initialize input/output. Auto-detects the type of machine
[1b20da0]100 * and calls the appropriate I/O init routine.
[965dc18]101 */
102void standalone_sparc64_console_init(void)
103{
104 ofw_tree_node_t *aliases;
105 ofw_tree_property_t *prop;
[a35b458]106
[965dc18]107 aliases = ofw_tree_lookup("/aliases");
108 if (!aliases)
[f651e80]109 panic("Cannot find '/aliases'.");
[a35b458]110
[965dc18]111 /* "def-cn" = "default console" */
112 prop = ofw_tree_getprop(aliases, "def-cn");
[a35b458]113
[336d2f52]114 if ((!prop) || (!prop->value))
[965dc18]115 standard_console_init(aliases);
116}
117
[2f40fe4]118/** @}
[b45c443]119 */
Note: See TracBrowser for help on using the repository browser.