source: mainline/kernel/arch/sparc64/src/console.c@ 08fed0a

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 08fed0a was 08fed0a, checked in by Jakub Jermar <jakub@…>, 16 years ago

Update the SGCN driver to match the latest character I/O changes.

  • Property mode set to 100644
File size: 4.1 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
[2f40fe4]29/** @addtogroup sparc64
[b45c443]30 * @{
31 */
32/** @file
33 */
34
[adb2ebf8]35#include <arch/console.h>
[65fb232]36#include <arch/types.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>
[16da5f8e]51#include <string.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 */
62static void standard_console_init(ofw_tree_node_t *aliases)
[481c520]63{
[753d851]64#ifdef CONFIG_FB
[28ecadb]65 ofw_tree_property_t *prop;
66 ofw_tree_node_t *screen;
67 ofw_tree_node_t *keyboard;
68
69 prop = ofw_tree_getprop(aliases, "screen");
70 if (!prop)
[f651e80]71 panic("Cannot find property 'screen'.");
[28ecadb]72 if (!prop->value)
[f651e80]73 panic("Cannot find screen alias.");
[28ecadb]74 screen = ofw_tree_lookup(prop->value);
75 if (!screen)
[f651e80]76 panic("Cannot find %s.", prop->value);
[28ecadb]77
[5d684e4]78 scr_init(screen);
79
[28ecadb]80 prop = ofw_tree_getprop(aliases, "keyboard");
81 if (!prop)
[f651e80]82 panic("Cannot find property 'keyboard'.");
[28ecadb]83 if (!prop->value)
[f651e80]84 panic("Cannot find keyboard alias.");
[28ecadb]85 keyboard = ofw_tree_lookup(prop->value);
86 if (!keyboard)
[f651e80]87 panic("Cannot find %s.", prop->value);
[da74747]88
[28ecadb]89 kbd_init(keyboard);
[753d851]90#else
91 panic("Standard console requires FB, "
92 "but the kernel is not compiled with FB support.");
93#endif
[30ab05f]94}
95
[965dc18]96/** Initilize I/O on the Serengeti machine. */
97static void serengeti_init(void)
98{
[08fed0a]99#ifdef CONFIG_SGCN_KBD
100 indev_t *kbrdin;
101 kbrdin = sgcnin_init();
102 if (kbrdin)
103 srlnin_init(kbrdin);
104#endif
105#ifdef CONFIG_SGCN_PRN
106 sgcnout_init();
[05915ba4]107#endif
[965dc18]108}
109
110/**
111 * Initialize input/output. Auto-detects the type of machine
112 * and calls the appropriate I/O init routine.
113 */
114void 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)
[f651e80]121 panic("Cannot find '/aliases'.");
[965dc18]122
123 /* "def-cn" = "default console" */
124 prop = ofw_tree_getprop(aliases, "def-cn");
125
126 if ((!prop) || (!prop->value) || (strcmp(prop->value, "/sgcn") != 0)) {
127 standard_console_init(aliases);
128 } else {
129 serengeti_init();
130 }
131}
132
133
[253f35a1]134/** Acquire console back for kernel
135 *
136 */
137void arch_grab_console(void)
138{
[753d851]139#ifdef CONFIG_FB
[c484842]140 scr_redraw();
[753d851]141#endif
[8513ad7]142 switch (kbd_type) {
[965dc18]143#ifdef CONFIG_SGCN
144 case KBD_SGCN:
145 sgcn_grab();
146 break;
[253f35a1]147#endif
[8513ad7]148 default:
149 break;
150 }
[253f35a1]151}
152
153/** Return console to userspace
154 *
155 */
156void arch_release_console(void)
157{
[8513ad7]158 switch (kbd_type) {
[965dc18]159#ifdef CONFIG_SGCN
160 case KBD_SGCN:
161 sgcn_release();
162 break;
[8513ad7]163#endif
164 default:
165 break;
166 }
[253f35a1]167}
[06e1e95]168
[2f40fe4]169/** @}
[b45c443]170 */
Note: See TracBrowser for help on using the repository browser.