source: mainline/kernel/arch/sparc64/src/console.c@ 16da5f8e

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 16da5f8e was 16da5f8e, checked in by Jiri Svoboda <jirik.svoboda@…>, 16 years ago

String functions should be declared in string.h (and implemented in string.c) in the kernel.

  • Property mode set to 100644
File size: 4.4 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>
[5d684e4]40
[965dc18]41#include <arch/drivers/sgcn.h>
42
[287920f]43#ifdef CONFIG_Z8530
44#include <genarch/kbd/z8530.h>
45#endif
[8b4be29]46#ifdef CONFIG_NS16550
47#include <genarch/kbd/ns16550.h>
[287920f]48#endif
49
[481c520]50#include <console/chardev.h>
51#include <console/console.h>
52#include <arch/asm.h>
53#include <arch/register.h>
54#include <proc/thread.h>
[97f1691]55#include <arch/mm/tlb.h>
[28ecadb]56#include <genarch/ofw/ofw_tree.h>
[7bb6b06]57#include <arch.h>
[28ecadb]58#include <panic.h>
[16da5f8e]59#include <string.h>
[28ecadb]60#include <print.h>
[adb2ebf8]61
[30ab05f]62#define KEYBOARD_POLL_PAUSE 50000 /* 50ms */
63
[965dc18]64/**
65 * Initialize kernel console to use framebuffer and keyboard directly.
66 * Called on UltraSPARC machines with standard keyboard and framebuffer.
67 *
68 * @param aliases the "/aliases" OBP node
69 */
70static void standard_console_init(ofw_tree_node_t *aliases)
[481c520]71{
[753d851]72#ifdef CONFIG_FB
[481c520]73 stdin = NULL;
[28ecadb]74
75 ofw_tree_property_t *prop;
76 ofw_tree_node_t *screen;
77 ofw_tree_node_t *keyboard;
78
79 prop = ofw_tree_getprop(aliases, "screen");
80 if (!prop)
[f651e80]81 panic("Cannot find property 'screen'.");
[28ecadb]82 if (!prop->value)
[f651e80]83 panic("Cannot find screen alias.");
[28ecadb]84 screen = ofw_tree_lookup(prop->value);
85 if (!screen)
[f651e80]86 panic("Cannot find %s.", prop->value);
[28ecadb]87
[5d684e4]88 scr_init(screen);
89
[28ecadb]90 prop = ofw_tree_getprop(aliases, "keyboard");
91 if (!prop)
[f651e80]92 panic("Cannot find property 'keyboard'.");
[28ecadb]93 if (!prop->value)
[f651e80]94 panic("Cannot find keyboard alias.");
[28ecadb]95 keyboard = ofw_tree_lookup(prop->value);
96 if (!keyboard)
[f651e80]97 panic("Cannot find %s.", prop->value);
[da74747]98
[28ecadb]99 kbd_init(keyboard);
[753d851]100#else
101 panic("Standard console requires FB, "
102 "but the kernel is not compiled with FB support.");
103#endif
[30ab05f]104}
105
[965dc18]106/** Initilize I/O on the Serengeti machine. */
107static void serengeti_init(void)
108{
109 sgcn_init();
110}
111
112/**
113 * Initialize input/output. Auto-detects the type of machine
114 * and calls the appropriate I/O init routine.
115 */
116void standalone_sparc64_console_init(void)
117{
118 ofw_tree_node_t *aliases;
119 ofw_tree_property_t *prop;
120
121 aliases = ofw_tree_lookup("/aliases");
122 if (!aliases)
[f651e80]123 panic("Cannot find '/aliases'.");
[965dc18]124
125 /* "def-cn" = "default console" */
126 prop = ofw_tree_getprop(aliases, "def-cn");
127
128 if ((!prop) || (!prop->value) || (strcmp(prop->value, "/sgcn") != 0)) {
129 standard_console_init(aliases);
130 } else {
131 serengeti_init();
132 }
133}
134
135
[30ab05f]136/** Kernel thread for polling keyboard.
137 *
138 * @param arg Ignored.
139 */
140void kkbdpoll(void *arg)
141{
[7bb6b06]142 thread_detach(THREAD);
143
[e7f2ad68]144 if (kbd_type != KBD_SGCN)
[f9a56c0]145 return;
[28ecadb]146
147 while (1) {
[965dc18]148#ifdef CONFIG_SGCN
149 if (kbd_type == KBD_SGCN)
150 sgcn_poll();
[287920f]151#endif
[30ab05f]152 thread_usleep(KEYBOARD_POLL_PAUSE);
[481c520]153 }
154}
[b45c443]155
[253f35a1]156/** Acquire console back for kernel
157 *
158 */
159void arch_grab_console(void)
160{
[753d851]161#ifdef CONFIG_FB
[c484842]162 scr_redraw();
[753d851]163#endif
[8513ad7]164 switch (kbd_type) {
[965dc18]165#ifdef CONFIG_SGCN
166 case KBD_SGCN:
167 sgcn_grab();
168 break;
[253f35a1]169#endif
[8513ad7]170 default:
171 break;
172 }
[253f35a1]173}
174
175/** Return console to userspace
176 *
177 */
178void arch_release_console(void)
179{
[8513ad7]180 switch (kbd_type) {
[965dc18]181#ifdef CONFIG_SGCN
182 case KBD_SGCN:
183 sgcn_release();
184 break;
[8513ad7]185#endif
186 default:
187 break;
188 }
[253f35a1]189}
[06e1e95]190
[2f40fe4]191/** @}
[b45c443]192 */
Note: See TracBrowser for help on using the repository browser.