Subversion Repositories HelenOS

Rev

Rev 3022 | Rev 4156 | 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>
1897 jermar 40
 
4055 trochtova 41
#include <arch/drivers/sgcn.h>
1842 jermar 42
 
893 jermar 43
#include <console/chardev.h>
44
#include <console/console.h>
45
#include <arch/asm.h>
46
#include <arch/register.h>
47
#include <proc/thread.h>
897 jermar 48
#include <arch/mm/tlb.h>
1896 jermar 49
#include <genarch/ofw/ofw_tree.h>
1880 jermar 50
#include <arch.h>
1896 jermar 51
#include <panic.h>
4055 trochtova 52
#include <string.h>
1896 jermar 53
#include <print.h>
426 jermar 54
 
895 jermar 55
#define KEYBOARD_POLL_PAUSE 50000   /* 50ms */
56
 
4055 trochtova 57
/**
58
 * Initialize kernel console to use framebuffer and keyboard directly.
59
 * Called on UltraSPARC machines with standard keyboard and framebuffer.
60
 *
61
 * @param aliases   the "/aliases" OBP node
62
 */
63
static void standard_console_init(ofw_tree_node_t *aliases)
893 jermar 64
{
4055 trochtova 65
#ifdef CONFIG_FB
1896 jermar 66
    ofw_tree_property_t *prop;
67
    ofw_tree_node_t *screen;
68
    ofw_tree_node_t *keyboard;
69
 
70
    prop = ofw_tree_getprop(aliases, "screen");
71
    if (!prop)
4055 trochtova 72
        panic("Cannot find property 'screen'.");
1896 jermar 73
    if (!prop->value)
4055 trochtova 74
        panic("Cannot find screen alias.");
1896 jermar 75
    screen = ofw_tree_lookup(prop->value);
76
    if (!screen)
4055 trochtova 77
        panic("Cannot find %s.", prop->value);
1896 jermar 78
 
1897 jermar 79
    scr_init(screen);
80
 
1896 jermar 81
    prop = ofw_tree_getprop(aliases, "keyboard");
82
    if (!prop)
4055 trochtova 83
        panic("Cannot find property 'keyboard'.");
1896 jermar 84
    if (!prop->value)
4055 trochtova 85
        panic("Cannot find keyboard alias.");
1896 jermar 86
    keyboard = ofw_tree_lookup(prop->value);
87
    if (!keyboard)
4055 trochtova 88
        panic("Cannot find %s.", prop->value);
897 jermar 89
 
1896 jermar 90
    kbd_init(keyboard);
4055 trochtova 91
#else
92
    panic("Standard console requires FB, "
93
          "but the kernel is not compiled with FB support.");
94
#endif
586 jermar 95
}
893 jermar 96
 
4055 trochtova 97
/** Initilize I/O on the Serengeti machine. */
98
static void serengeti_init(void)
99
{
100
    sgcn_init();
101
}
102
 
103
/**
104
 * Initialize input/output. Auto-detects the type of machine
105
 * and calls the appropriate I/O init routine.
106
 */
107
void standalone_sparc64_console_init(void)
108
{
109
    ofw_tree_node_t *aliases;
110
    ofw_tree_property_t *prop;
111
 
112
    aliases = ofw_tree_lookup("/aliases");
113
    if (!aliases)
114
        panic("Cannot find '/aliases'.");
115
 
116
    /* "def-cn" = "default console" */
117
    prop = ofw_tree_getprop(aliases, "def-cn");
118
 
119
    if ((!prop) || (!prop->value) || (strcmp(prop->value, "/sgcn") != 0)) {
120
        standard_console_init(aliases);
121
    } else {
122
        serengeti_init();
123
    }
124
}
125
 
126
 
895 jermar 127
/** Kernel thread for polling keyboard.
128
 *
129
 * @param arg Ignored.
130
 */
131
void kkbdpoll(void *arg)
132
{
1880 jermar 133
    thread_detach(THREAD);
134
 
4055 trochtova 135
    if (kbd_type != KBD_SGCN)
1849 jermar 136
        return;
1896 jermar 137
 
138
    while (1) {
4055 trochtova 139
#ifdef CONFIG_SGCN
140
        if (kbd_type == KBD_SGCN)
141
            sgcn_poll();
1842 jermar 142
#endif
895 jermar 143
        thread_usleep(KEYBOARD_POLL_PAUSE);
144
    }
145
}
1702 cejka 146
 
1875 jermar 147
/** Acquire console back for kernel
148
 *
149
 */
150
void arch_grab_console(void)
151
{
4055 trochtova 152
#ifdef CONFIG_FB
153
    scr_redraw();
154
#endif
1931 jermar 155
    switch (kbd_type) {
4055 trochtova 156
#ifdef CONFIG_SGCN
157
    case KBD_SGCN:
158
        sgcn_grab();
1931 jermar 159
        break;
1875 jermar 160
#endif
1931 jermar 161
    default:
162
        break;
163
    }
1875 jermar 164
}
165
 
166
/** Return console to userspace
167
 *
168
 */
169
void arch_release_console(void)
170
{
1931 jermar 171
    switch (kbd_type) {
4055 trochtova 172
#ifdef CONFIG_SGCN
173
    case KBD_SGCN:
174
        sgcn_release();
1931 jermar 175
        break;
1875 jermar 176
#endif
1931 jermar 177
    default:
178
        break;
179
    }
1875 jermar 180
}
1888 jermar 181
 
1769 jermar 182
/** @}
1702 cejka 183
 */