Subversion Repositories HelenOS

Rev

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

Rev 4346 Rev 4347
Line 53... Line 53...
53
#include <macros.h>
53
#include <macros.h>
54
#include <sysinfo/sysinfo.h>
54
#include <sysinfo/sysinfo.h>
55
#include <ddi/device.h>
55
#include <ddi/device.h>
56
#include <symtab.h>
56
#include <symtab.h>
57
#include <errno.h>
57
#include <errno.h>
-
 
58
#include <putchar.h>
58
 
59
 
59
/** Simple kernel console.
60
/** Simple kernel console.
60
 *
61
 *
61
 * The console is realized by kernel thread kconsole.
62
 * The console is realized by kernel thread kconsole.
62
 * It doesn't understand any useful command on its own,
63
 * It doesn't understand any useful command on its own,
Line 85... Line 86...
85
static cmd_info_t *parse_cmdline(char *cmdline, size_t len);
86
static cmd_info_t *parse_cmdline(char *cmdline, size_t len);
86
static bool parse_argument(char *cmdline, size_t len, index_t *start,
87
static bool parse_argument(char *cmdline, size_t len, index_t *start,
87
    index_t *end);
88
    index_t *end);
88
static char history[KCONSOLE_HISTORY][MAX_CMDLINE] = {};
89
static char history[KCONSOLE_HISTORY][MAX_CMDLINE] = {};
89
 
90
 
90
/*
-
 
91
 * For now, we use 0 as INR.
-
 
92
 * However, it is therefore desirable to have architecture specific
-
 
93
 * definition of KCONSOLE_VIRT_INR in the future.
-
 
94
 */
-
 
95
#define KCONSOLE_VIRT_INR  0
-
 
96
 
-
 
97
bool kconsole_notify = false;
-
 
98
irq_t kconsole_irq;
-
 
99
 
-
 
100
 
-
 
101
/** Allways refuse IRQ ownership.
-
 
102
 *
-
 
103
 * This is not a real IRQ, so we always decline.
-
 
104
 *
-
 
105
 * @return Always returns IRQ_DECLINE.
-
 
106
 *
-
 
107
 */
-
 
108
static irq_ownership_t kconsole_claim(irq_t *irq)
-
 
109
{
-
 
110
    return IRQ_DECLINE;
-
 
111
}
-
 
112
 
-
 
113
 
-
 
114
/** Initialize kconsole data structures
91
/** Initialize kconsole data structures
115
 *
92
 *
116
 * This is the most basic initialization, almost no
93
 * This is the most basic initialization, almost no
117
 * other kernel subsystem is ready yet.
94
 * other kernel subsystem is ready yet.
118
 *
95
 *
Line 124... Line 101...
124
    cmd_init();
101
    cmd_init();
125
    for (i = 0; i < KCONSOLE_HISTORY; i++)
102
    for (i = 0; i < KCONSOLE_HISTORY; i++)
126
        history[i][0] = '\0';
103
        history[i][0] = '\0';
127
}
104
}
128
 
105
 
129
 
-
 
130
/** Initialize kconsole notification mechanism
-
 
131
 *
-
 
132
 * Initialize the virtual IRQ notification mechanism.
-
 
133
 *
-
 
134
 */
-
 
135
void kconsole_notify_init(void)
-
 
136
{
-
 
137
    devno_t devno = device_assign_devno();
-
 
138
   
-
 
139
    sysinfo_set_item_val("kconsole.present", NULL, true);
-
 
140
    sysinfo_set_item_val("kconsole.devno", NULL, devno);
-
 
141
    sysinfo_set_item_val("kconsole.inr", NULL, KCONSOLE_VIRT_INR);
-
 
142
   
-
 
143
    irq_initialize(&kconsole_irq);
-
 
144
    kconsole_irq.devno = devno;
-
 
145
    kconsole_irq.inr = KCONSOLE_VIRT_INR;
-
 
146
    kconsole_irq.claim = kconsole_claim;
-
 
147
    irq_register(&kconsole_irq);
-
 
148
   
-
 
149
    kconsole_notify = true;
-
 
150
}
-
 
151
 
-
 
152
 
-
 
153
/** Register kconsole command.
106
/** Register kconsole command.
154
 *
107
 *
155
 * @param cmd Structure describing the command.
108
 * @param cmd Structure describing the command.
156
 *
109
 *
157
 * @return 0 on failure, 1 on success.
110
 * @return 0 on failure, 1 on success.
Line 205... Line 158...
205
    spinlock_unlock(&cmd_lock);
158
    spinlock_unlock(&cmd_lock);
206
    return 1;
159
    return 1;
207
}
160
}
208
 
161
 
209
/** Print count times a character */
162
/** Print count times a character */
210
static void rdln_print_c(char ch, int count)
163
static void rdln_print_c(wchar_t ch, count_t count)
211
{
164
{
212
    int i;
165
    count_t i;
213
    for (i = 0; i < count; i++)
166
    for (i = 0; i < count; i++)
214
        putchar(ch);
167
        putchar(ch);
215
}
168
}
216
 
169
 
217
/** Insert character to string */
170
/** Insert character to string */