Subversion Repositories HelenOS

Rev

Rev 3022 | Rev 4296 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3022 Rev 4055
Line 36... Line 36...
36
#include <arch/types.h>
36
#include <arch/types.h>
37
 
37
 
38
#include <arch/drivers/scr.h>
38
#include <arch/drivers/scr.h>
39
#include <arch/drivers/kbd.h>
39
#include <arch/drivers/kbd.h>
40
 
40
 
41
#ifdef CONFIG_Z8530
-
 
42
#include <genarch/kbd/z8530.h>
-
 
43
#endif
-
 
44
#ifdef CONFIG_NS16550
-
 
45
#include <genarch/kbd/ns16550.h>
41
#include <arch/drivers/sgcn.h>
46
#endif
-
 
47
 
42
 
48
#include <console/chardev.h>
43
#include <console/chardev.h>
49
#include <console/console.h>
44
#include <console/console.h>
50
#include <arch/asm.h>
45
#include <arch/asm.h>
51
#include <arch/register.h>
46
#include <arch/register.h>
52
#include <proc/thread.h>
47
#include <proc/thread.h>
53
#include <arch/mm/tlb.h>
48
#include <arch/mm/tlb.h>
54
#include <genarch/ofw/ofw_tree.h>
49
#include <genarch/ofw/ofw_tree.h>
55
#include <arch.h>
50
#include <arch.h>
56
#include <panic.h>
51
#include <panic.h>
-
 
52
#include <string.h>
57
#include <print.h>
53
#include <print.h>
58
 
54
 
59
#define KEYBOARD_POLL_PAUSE 50000   /* 50ms */
55
#define KEYBOARD_POLL_PAUSE 50000   /* 50ms */
60
 
56
 
-
 
57
/**
61
/** Initialize kernel console to use framebuffer and keyboard directly. */
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
 */
62
void standalone_sparc64_console_init(void)
63
static void standard_console_init(ofw_tree_node_t *aliases)
63
{
64
{
64
    stdin = NULL;
65
#ifdef CONFIG_FB
65
 
-
 
66
    ofw_tree_node_t *aliases;
-
 
67
    ofw_tree_property_t *prop;
66
    ofw_tree_property_t *prop;
68
    ofw_tree_node_t *screen;
67
    ofw_tree_node_t *screen;
69
    ofw_tree_node_t *keyboard;
68
    ofw_tree_node_t *keyboard;
70
   
69
   
71
    aliases = ofw_tree_lookup("/aliases");
-
 
72
    if (!aliases)
-
 
73
        panic("Can't find /aliases.\n");
-
 
74
   
-
 
75
    prop = ofw_tree_getprop(aliases, "screen");
70
    prop = ofw_tree_getprop(aliases, "screen");
76
    if (!prop)
71
    if (!prop)
77
        panic("Can't find property \"screen\".\n");
72
        panic("Cannot find property 'screen'.");
78
    if (!prop->value)
73
    if (!prop->value)
79
        panic("Can't find screen alias.\n");
74
        panic("Cannot find screen alias.");
80
    screen = ofw_tree_lookup(prop->value);
75
    screen = ofw_tree_lookup(prop->value);
81
    if (!screen)
76
    if (!screen)
82
        panic("Can't find %s\n", prop->value);
77
        panic("Cannot find %s.", prop->value);
83
 
78
 
84
    scr_init(screen);
79
    scr_init(screen);
85
 
80
 
86
    prop = ofw_tree_getprop(aliases, "keyboard");
81
    prop = ofw_tree_getprop(aliases, "keyboard");
87
    if (!prop)
82
    if (!prop)
88
        panic("Can't find property \"keyboard\".\n");
83
        panic("Cannot find property 'keyboard'.");
89
    if (!prop->value)
84
    if (!prop->value)
90
        panic("Can't find keyboard alias.\n");
85
        panic("Cannot find keyboard alias.");
91
    keyboard = ofw_tree_lookup(prop->value);
86
    keyboard = ofw_tree_lookup(prop->value);
92
    if (!keyboard)
87
    if (!keyboard)
93
        panic("Can't find %s\n", prop->value);
88
        panic("Cannot find %s.", prop->value);
94
 
89
 
95
    kbd_init(keyboard);
90
    kbd_init(keyboard);
-
 
91
#else
-
 
92
    panic("Standard console requires FB, "
-
 
93
          "but the kernel is not compiled with FB support.");
-
 
94
#endif
-
 
95
}
-
 
96
 
-
 
97
/** Initilize I/O on the Serengeti machine. */
-
 
98
static void serengeti_init(void)
-
 
99
{
-
 
100
    sgcn_init();
96
}
101
}
97
 
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
 
98
/** Kernel thread for polling keyboard.
127
/** Kernel thread for polling keyboard.
99
 *
128
 *
100
 * @param arg Ignored.
129
 * @param arg Ignored.
101
 */
130
 */
102
void kkbdpoll(void *arg)
131
void kkbdpoll(void *arg)
103
{
132
{
104
    thread_detach(THREAD);
133
    thread_detach(THREAD);
105
 
134
 
106
#ifdef CONFIG_Z8530
-
 
107
    if (kbd_type == KBD_Z8530) {
135
    if (kbd_type != KBD_SGCN)
108
        /*
-
 
109
         * The z8530 driver is interrupt-driven.
-
 
110
         */
-
 
111
        return;
136
        return;
112
    }
-
 
113
#endif
-
 
114
 
137
 
115
    while (1) {
138
    while (1) {
116
#ifdef CONFIG_NS16550
139
#ifdef CONFIG_SGCN
117
        if (kbd_type == KBD_NS16550)
140
        if (kbd_type == KBD_SGCN)
118
            ns16550_poll();
141
            sgcn_poll();
119
#endif
142
#endif
120
        thread_usleep(KEYBOARD_POLL_PAUSE);
143
        thread_usleep(KEYBOARD_POLL_PAUSE);
121
    }
144
    }
122
}
145
}
123
 
146
 
124
/** Acquire console back for kernel
147
/** Acquire console back for kernel
125
 *
148
 *
126
 */
149
 */
127
void arch_grab_console(void)
150
void arch_grab_console(void)
128
{
151
{
129
    switch (kbd_type) {
-
 
130
#ifdef CONFIG_Z8530
152
#ifdef CONFIG_FB
131
    case KBD_Z8530:
-
 
132
        z8530_grab();
153
    scr_redraw();
133
        break;
-
 
134
#endif
154
#endif
-
 
155
    switch (kbd_type) {
135
#ifdef CONFIG_NS16550
156
#ifdef CONFIG_SGCN
136
    case KBD_NS16550:
157
    case KBD_SGCN:
137
        ns16550_grab();
158
        sgcn_grab();
138
        break;
159
        break;
139
#endif
160
#endif
140
    default:
161
    default:
141
        break;
162
        break;
142
    }
163
    }
Line 146... Line 167...
146
 *
167
 *
147
 */
168
 */
148
void arch_release_console(void)
169
void arch_release_console(void)
149
{
170
{
150
    switch (kbd_type) {
171
    switch (kbd_type) {
151
#ifdef CONFIG_Z8530
172
#ifdef CONFIG_SGCN
152
    case KBD_Z8530:
173
    case KBD_SGCN:
153
        z8530_release();
174
        sgcn_release();
154
        break;
-
 
155
#endif
-
 
156
#ifdef CONFIG_NS16550
-
 
157
    case KBD_NS16550:
-
 
158
        ns16550_release();
-
 
159
        break;
175
        break;
160
#endif
176
#endif
161
    default:
177
    default:
162
        break;
178
        break;
163
    }
179
    }