Subversion Repositories HelenOS

Rev

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

Rev 3707 Rev 3844
Line 63... Line 63...
63
/**< Number of stored (not printed) kernel log characters */
63
/**< Number of stored (not printed) kernel log characters */
64
static size_t klog_stored = 0;
64
static size_t klog_stored = 0;
65
/**< Number of stored kernel log characters for uspace */
65
/**< Number of stored kernel log characters for uspace */
66
static size_t klog_uspace = 0;
66
static size_t klog_uspace = 0;
67
 
67
 
-
 
68
/**< Silent output */
-
 
69
static bool silent = false;
-
 
70
 
68
/**< Kernel log spinlock */
71
/**< Kernel log spinlock */
69
SPINLOCK_INITIALIZE(klog_lock);
72
SPINLOCK_INITIALIZE(klog_lock);
70
 
73
 
71
/** Physical memory area used for klog buffer */
74
/** Physical memory area used for klog buffer */
72
static parea_t klog_parea;
75
static parea_t klog_parea;
73
   
76
 
74
/*
77
/*
75
 * For now, we use 0 as INR.
78
 * For now, we use 0 as INR.
76
 * However, it is therefore desirable to have architecture specific
79
 * However, it is therefore desirable to have architecture specific
77
 * definition of KLOG_VIRT_INR in the future.
80
 * definition of KLOG_VIRT_INR in the future.
78
 */
81
 */
Line 142... Line 145...
142
    spinlock_lock(&klog_lock);
145
    spinlock_lock(&klog_lock);
143
    klog_inited = true;
146
    klog_inited = true;
144
    spinlock_unlock(&klog_lock);
147
    spinlock_unlock(&klog_lock);
145
}
148
}
146
 
149
 
-
 
150
void grab_console(void)
-
 
151
{
-
 
152
    silent = false;
-
 
153
    arch_grab_console();
-
 
154
}
-
 
155
 
-
 
156
void release_console(void)
-
 
157
{
-
 
158
    silent = true;
-
 
159
    arch_release_console();
-
 
160
}
-
 
161
 
147
/** Get character from character device. Do not echo character.
162
/** Get character from character device. Do not echo character.
148
 *
163
 *
149
 * @param chardev Character device.
164
 * @param chardev Character device.
150
 *
165
 *
151
 * @return Character read.
166
 * @return Character read.
Line 197... Line 212...
197
 */
212
 */
198
count_t gets(chardev_t *chardev, char *buf, size_t buflen)
213
count_t gets(chardev_t *chardev, char *buf, size_t buflen)
199
{
214
{
200
    index_t index = 0;
215
    index_t index = 0;
201
    char ch;
216
    char ch;
202
 
217
   
203
    while (index < buflen) {
218
    while (index < buflen) {
204
        ch = _getc(chardev);
219
        ch = _getc(chardev);
205
        if (ch == '\b') {
220
        if (ch == '\b') {
206
            if (index > 0) {
221
            if (index > 0) {
207
                index--;
222
                index--;
Line 211... Line 226...
211
                putchar('\b');
226
                putchar('\b');
212
            }
227
            }
213
            continue;
228
            continue;
214
        }
229
        }
215
        putchar(ch);
230
        putchar(ch);
216
 
231
       
217
        if (ch == '\n') { /* end of string => write 0, return */
232
        if (ch == '\n') { /* end of string => write 0, return */
218
            buf[index] = '\0';
233
            buf[index] = '\0';
219
            return (count_t) index;
234
            return (count_t) index;
220
        }
235
        }
221
        buf[index++] = ch;
236
        buf[index++] = ch;
Line 251... Line 266...
251
   
266
   
252
    if ((klog_stored > 0) && (stdout->op->write)) {
267
    if ((klog_stored > 0) && (stdout->op->write)) {
253
        /* Print charaters stored in kernel log */
268
        /* Print charaters stored in kernel log */
254
        index_t i;
269
        index_t i;
255
        for (i = klog_len - klog_stored; i < klog_len; i++)
270
        for (i = klog_len - klog_stored; i < klog_len; i++)
256
            stdout->op->write(stdout, klog[(klog_start + i) % KLOG_SIZE]);
271
            stdout->op->write(stdout, klog[(klog_start + i) % KLOG_SIZE], silent);
257
        klog_stored = 0;
272
        klog_stored = 0;
258
    }
273
    }
259
   
274
   
260
    /* Store character in the cyclic kernel log */
275
    /* Store character in the cyclic kernel log */
261
    klog[(klog_start + klog_len) % KLOG_SIZE] = c;
276
    klog[(klog_start + klog_len) % KLOG_SIZE] = c;
Line 263... Line 278...
263
        klog_len++;
278
        klog_len++;
264
    else
279
    else
265
        klog_start = (klog_start + 1) % KLOG_SIZE;
280
        klog_start = (klog_start + 1) % KLOG_SIZE;
266
   
281
   
267
    if (stdout->op->write)
282
    if (stdout->op->write)
268
        stdout->op->write(stdout, c);
283
        stdout->op->write(stdout, c, silent);
269
    else {
284
    else {
270
        /* The character is just in the kernel log */
285
        /* The character is just in the kernel log */
271
        if (klog_stored < klog_len)
286
        if (klog_stored < klog_len)
272
            klog_stored++;
287
            klog_stored++;
273
    }
288
    }