Subversion Repositories HelenOS

Rev

Rev 4071 | Rev 4111 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
426 jermar 1
/*
2071 jermar 2
 * Copyright (c) 2005 Jakub Jermar
426 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
 
1769 jermar 29
/** @addtogroup sparc64
1702 cejka 30
 * @{
31
 */
32
/** @file
33
 */
34
 
586 jermar 35
#include <arch/console.h>
669 jermar 36
#include <arch/types.h>
1842 jermar 37
 
1897 jermar 38
#include <arch/drivers/scr.h>
1842 jermar 39
#include <arch/drivers/kbd.h>
3672 jermar 40
#include <arch/drivers/sgcn.h>
4071 jermar 41
#include <genarch/srln/srln.h>
893 jermar 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>
897 jermar 47
#include <arch/mm/tlb.h>
1896 jermar 48
#include <genarch/ofw/ofw_tree.h>
1880 jermar 49
#include <arch.h>
1896 jermar 50
#include <panic.h>
4011 svoboda 51
#include <string.h>
1896 jermar 52
#include <print.h>
426 jermar 53
 
895 jermar 54
#define KEYBOARD_POLL_PAUSE 50000   /* 50ms */
55
 
3672 jermar 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)
893 jermar 63
{
3865 rimsky 64
#ifdef CONFIG_FB
1896 jermar 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)
3790 svoboda 71
        panic("Cannot find property 'screen'.");
1896 jermar 72
    if (!prop->value)
3790 svoboda 73
        panic("Cannot find screen alias.");
1896 jermar 74
    screen = ofw_tree_lookup(prop->value);
75
    if (!screen)
3790 svoboda 76
        panic("Cannot find %s.", prop->value);
1896 jermar 77
 
1897 jermar 78
    scr_init(screen);
79
 
1896 jermar 80
    prop = ofw_tree_getprop(aliases, "keyboard");
81
    if (!prop)
3790 svoboda 82
        panic("Cannot find property 'keyboard'.");
1896 jermar 83
    if (!prop->value)
3790 svoboda 84
        panic("Cannot find keyboard alias.");
1896 jermar 85
    keyboard = ofw_tree_lookup(prop->value);
86
    if (!keyboard)
3790 svoboda 87
        panic("Cannot find %s.", prop->value);
897 jermar 88
 
1896 jermar 89
    kbd_init(keyboard);
3865 rimsky 90
#else
91
    panic("Standard console requires FB, "
92
          "but the kernel is not compiled with FB support.");
93
#endif
586 jermar 94
}
893 jermar 95
 
3672 jermar 96
/** Initilize I/O on the Serengeti machine. */
97
static void serengeti_init(void)
98
{
4072 jermar 99
#ifdef CONFIG_SRLN
4071 jermar 100
    srln_init(stdin);
101
    sgcn_init(&srlnin);
4072 jermar 102
#endif
3672 jermar 103
}
104
 
105
/**
106
 * Initialize input/output. Auto-detects the type of machine
107
 * and calls the appropriate I/O init routine.
108
 */
109
void standalone_sparc64_console_init(void)
110
{
111
    ofw_tree_node_t *aliases;
112
    ofw_tree_property_t *prop;
113
 
114
    aliases = ofw_tree_lookup("/aliases");
115
    if (!aliases)
3790 svoboda 116
        panic("Cannot find '/aliases'.");
3672 jermar 117
 
118
    /* "def-cn" = "default console" */
119
    prop = ofw_tree_getprop(aliases, "def-cn");
120
 
121
    if ((!prop) || (!prop->value) || (strcmp(prop->value, "/sgcn") != 0)) {
122
        standard_console_init(aliases);
123
    } else {
124
        serengeti_init();
125
    }
126
}
127
 
128
 
1875 jermar 129
/** Acquire console back for kernel
130
 *
131
 */
132
void arch_grab_console(void)
133
{
3865 rimsky 134
#ifdef CONFIG_FB
3740 jermar 135
    scr_redraw();
3865 rimsky 136
#endif
1931 jermar 137
    switch (kbd_type) {
3672 jermar 138
#ifdef CONFIG_SGCN
139
    case KBD_SGCN:
140
        sgcn_grab();
141
        break;
142
#endif
1931 jermar 143
    default:
144
        break;
145
    }
1875 jermar 146
}
147
 
148
/** Return console to userspace
149
 *
150
 */
151
void arch_release_console(void)
152
{
1931 jermar 153
    switch (kbd_type) {
3672 jermar 154
#ifdef CONFIG_SGCN
155
    case KBD_SGCN:
156
        sgcn_release();
157
        break;
158
#endif
1931 jermar 159
    default:
160
        break;
161
    }
1875 jermar 162
}
1888 jermar 163
 
1769 jermar 164
/** @}
1702 cejka 165
 */