Ignore:
Timestamp:
2025-04-17T16:01:16Z (5 days ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master
Children:
888c06e
Parents:
1db4e2ae (diff), 250a435 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-17 15:51:11)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-17 16:01:16)
Message:

Convert kernel console writing to byte arrays

More buffer per buffer (the original char32_t buffer takes up four
times as much space for the same amount of backlog, which is wasteful).
It is also faster, possibly thanks to bigger chunks being processed in bulk.
Gonna try to figure out if the locking can be improved further.

Also changed to use a syscall for reading KIO buffer from uspace,
to allow better synchronization.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/kconsole.c

    r1db4e2ae rc4cfe4c  
    3939 */
    4040
     41#include <adt/list.h>
     42#include <arch.h>
    4143#include <assert.h>
    42 #include <console/kconsole.h>
    43 #include <console/console.h>
    4444#include <console/chardev.h>
    4545#include <console/cmd.h>
     46#include <console/console.h>
     47#include <console/kconsole.h>
    4648#include <console/prompt.h>
     49#include <debug.h>
     50#include <errno.h>
     51#include <halt.h>
     52#include <macros.h>
     53#include <panic.h>
    4754#include <stdio.h>
    48 #include <panic.h>
     55#include <stdlib.h>
     56#include <str.h>
     57#include <symtab.h>
     58#include <sysinfo/sysinfo.h>
    4959#include <typedefs.h>
    50 #include <adt/list.h>
    51 #include <arch.h>
    52 #include <macros.h>
    53 #include <debug.h>
    54 #include <halt.h>
    55 #include <str.h>
    56 #include <sysinfo/sysinfo.h>
    57 #include <symtab.h>
    58 #include <errno.h>
    59 #include <putchar.h>
    60 #include <stdlib.h>
    6160
    6261/** Simple kernel console.
     
    158157
    159158/** Print count times a character */
    160 _NO_TRACE static void print_cc(char32_t ch, size_t count)
    161 {
    162         size_t i;
    163         for (i = 0; i < count; i++)
    164                 putuchar(ch);
     159_NO_TRACE static void print_cc(char ch, size_t count)
     160{
     161        // FIXME: only lock once
     162
     163        for (size_t i = 0; i < count; i++)
     164                putstr(&ch, 1);
    165165}
    166166
     
    347347                if (ch == '\n') {
    348348                        /* Enter */
    349                         putuchar(ch);
     349                        putstr("\n", 1);
    350350                        break;
    351351                }
     
    358358                        if (wstr_remove(current, position - 1)) {
    359359                                position--;
    360                                 putuchar('\b');
     360                                putstr("\b", 1);
    361361                                printf("%ls ", current + position);
    362362                                print_cc('\b', wstr_length(current) - position + 1);
     
    368368                        /* Tab completion */
    369369
    370                         /* Move to the end of the word */
    371                         for (; (current[position] != 0) && (!isspace(current[position]));
    372                             position++)
    373                                 putuchar(current[position]);
     370                        size_t i = position;
     371                        while (current[i] && !isspace(current[i]))
     372                                i++;
     373
     374                        char32_t stash = current[i];
     375                        current[i] = 0;
     376                        printf("%ls", &current[position]);
     377                        current[i] = stash;
     378                        position = i;
    374379
    375380                        /*
     
    430435                         */
    431436                        size_t off = 0;
    432                         size_t i = 0;
    433                         while ((ch = str_decode(tmp, &off, STR_NO_LIMIT)) != 0) {
     437                        for (size_t i = 0; (ch = str_decode(tmp, &off, STR_NO_LIMIT)); i++)
    434438                                if (!wstr_linsert(current, ch, position + i, MAX_CMDLINE))
    435439                                        break;
    436 
    437                                 i++;
    438                         }
    439440
    440441                        if (found > 1) {
     
    466467                        /* Left */
    467468                        if (position > 0) {
    468                                 putuchar('\b');
     469                                putstr("\b", 1);
    469470                                position--;
    470471                        }
     
    475476                        /* Right */
    476477                        if (position < wstr_length(current)) {
    477                                 putuchar(current[position]);
     478                                printf("%lc", current[position]);
    478479                                position++;
    479480                        }
Note: See TracChangeset for help on using the changeset viewer.