Changeset c4cfe4c in mainline for kernel/genarch/src/fb/fb.c


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/genarch/src/fb/fb.c

    r1db4e2ae rc4cfe4c  
    121121        /** Current backbuffer position */
    122122        unsigned int position;
     123
     124        /** Partial character between writes */
     125        mbstate_t mbstate;
    123126} fb_instance_t;
    124127
    125 static void fb_putuchar(outdev_t *, char32_t);
     128static void fb_write(outdev_t *, const char *, size_t);
    126129static void fb_redraw(outdev_t *);
    127130static void fb_scroll_up(outdev_t *);
     
    129132
    130133static outdev_operations_t fbdev_ops = {
    131         .write = fb_putuchar,
     134        .write = fb_write,
    132135        .redraw = fb_redraw,
    133136        .scroll_up = fb_scroll_up,
     
    418421 *
    419422 */
    420 static void fb_putuchar(outdev_t *dev, char32_t ch)
    421 {
    422         fb_instance_t *instance = (fb_instance_t *) dev->data;
    423         spinlock_lock(&instance->lock);
    424 
     423static void _putuchar(fb_instance_t *instance, char32_t ch)
     424{
    425425        switch (ch) {
    426426        case '\n':
    427                 cursor_remove(instance);
    428427                instance->position += instance->cols;
    429428                instance->position -= instance->position % instance->cols;
    430429                break;
    431430        case '\r':
    432                 cursor_remove(instance);
    433431                instance->position -= instance->position % instance->cols;
    434432                break;
    435433        case '\b':
    436                 cursor_remove(instance);
    437434                if (instance->position % instance->cols)
    438435                        instance->position--;
    439436                break;
    440437        case '\t':
    441                 cursor_remove(instance);
    442438                do {
    443439                        glyph_draw(instance, fb_font_glyph(' '),
     
    459455                screen_scroll(instance);
    460456        }
     457}
     458
     459static void fb_write(outdev_t *dev, const char *s, size_t n)
     460{
     461        fb_instance_t *instance = (fb_instance_t *) dev->data;
     462
     463        spinlock_lock(&instance->lock);
     464        cursor_remove(instance);
     465
     466        size_t offset = 0;
     467        char32_t ch;
     468
     469        while ((ch = str_decode_r(s, &offset, n, U_SPECIAL, &instance->mbstate)))
     470                _putuchar(instance, ch);
    461471
    462472        cursor_put(instance);
    463 
    464473        spinlock_unlock(&instance->lock);
    465474}
Note: See TracChangeset for help on using the changeset viewer.