Subversion Repositories HelenOS

Rev

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

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