Changeset b366a6f4 in mainline for kernel/genarch/src


Ignore:
Timestamp:
2011-06-24T15:58:01Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7250d2c
Parents:
ee2fa30a
Message:

automatic kernel console lockout

  • kernel automatically relinquishes the access to the kernel console when the uspace maps the respective physical memory area
  • kernel output before uspace initialization is currently broken on Ski (no physical memory area), but this is pending further unification
  • kernel console devices are now independent (there is no system-wide "silent" variable), thus on multiple devices the kernel console and uspace output might be usable at the same time
Location:
kernel/genarch/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/drivers/dsrln/dsrlnout.c

    ree2fa30a rb366a6f4  
    4242#include <sysinfo/sysinfo.h>
    4343#include <str.h>
     44#include <ddi/ddi.h>
    4445
    4546typedef struct {
     47        parea_t parea;
    4648        ioport8_t *base;
    4749} dsrlnout_instance_t;
    4850
    49 static void dsrlnout_putchar(outdev_t *dev, const wchar_t ch, bool silent)
     51static void dsrlnout_putchar(outdev_t *dev, const wchar_t ch)
    5052{
    5153        dsrlnout_instance_t *instance = (dsrlnout_instance_t *) dev->data;
    5254       
    53         if (!silent) {
     55        if ((!instance->parea.mapped) || (console_override)) {
    5456                if (ascii_check(ch))
    5557                        pio_write_8(instance->base, ch);
     
    7072                return NULL;
    7173       
    72         dsrlnout_instance_t *instance = malloc(sizeof(dsrlnout_instance_t), FRAME_ATOMIC);
     74        dsrlnout_instance_t *instance = malloc(sizeof(dsrlnout_instance_t),
     75            FRAME_ATOMIC);
    7376        if (!instance) {
    7477                free(dsrlndev);
     
    8083       
    8184        instance->base = base;
     85        link_initialize(&instance->parea.link);
     86        instance->parea.pbase = KA2PA(base);
     87        instance->parea.frames = 1;
     88        instance->parea.unpriv = false;
     89        instance->parea.mapped = false;
     90        ddi_parea_register(&instance->parea);
    8291       
    8392        if (!fb_exported) {
    8493                /*
    85                  * This is the necessary evil until the userspace driver is entirely
     94                 * This is the necessary evil until
     95                 * the userspace driver is entirely
    8696                 * self-sufficient.
    8797                 */
  • kernel/genarch/src/drivers/ega/ega.c

    ree2fa30a rb366a6f4  
    6464        IRQ_SPINLOCK_DECLARE(lock);
    6565       
     66        parea_t parea;
     67       
    6668        uint32_t cursor;
    6769        uint8_t *addr;
     
    7072} ega_instance_t;
    7173
    72 static void ega_putchar(outdev_t *, wchar_t, bool);
     74static void ega_putchar(outdev_t *, wchar_t);
    7375static void ega_redraw(outdev_t *);
    7476
     
    437439 * This function takes care of scrolling.
    438440 */
    439 static void ega_check_cursor(ega_instance_t *instance, bool silent)
     441static void ega_check_cursor(ega_instance_t *instance)
    440442{
    441443        if (instance->cursor < EGA_SCREEN)
     
    448450            EGA_COLS, EMPTY_CHAR);
    449451       
    450         if (!silent) {
     452        if ((!instance->parea.mapped) || (console_override)) {
    451453                memmove((void *) instance->addr,
    452454                    (void *) (instance->addr + EGA_COLS * 2),
     
    459461}
    460462
    461 static void ega_show_cursor(ega_instance_t *instance, bool silent)
    462 {
    463         if (!silent) {
     463static void ega_show_cursor(ega_instance_t *instance)
     464{
     465        if ((!instance->parea.mapped) || (console_override)) {
    464466                pio_write_8(instance->base + EGA_INDEX_REG, 0x0a);
    465467                uint8_t stat = pio_read_8(instance->base + EGA_DATA_REG);
     
    469471}
    470472
    471 static void ega_move_cursor(ega_instance_t *instance, bool silent)
    472 {
    473         if (!silent) {
     473static void ega_move_cursor(ega_instance_t *instance)
     474{
     475        if ((!instance->parea.mapped) || (console_override)) {
    474476                pio_write_8(instance->base + EGA_INDEX_REG, 0x0e);
    475477                pio_write_8(instance->base + EGA_DATA_REG,
     
    481483}
    482484
    483 static void ega_sync_cursor(ega_instance_t *instance, bool silent)
    484 {
    485         if (!silent) {
     485static void ega_sync_cursor(ega_instance_t *instance)
     486{
     487        if ((!instance->parea.mapped) || (console_override)) {
    486488                pio_write_8(instance->base + EGA_INDEX_REG, 0x0e);
    487489                uint8_t hi = pio_read_8(instance->base + EGA_DATA_REG);
     
    503505            EGA_SCREEN - instance->cursor, EMPTY_CHAR);
    504506       
    505         if (!silent)
     507        if ((!instance->parea.mapped) || (console_override))
    506508                memsetw(instance->addr + instance->cursor * 2,
    507509                    EGA_SCREEN - instance->cursor, EMPTY_CHAR);
    508510       
    509         ega_check_cursor(instance, silent);
    510         ega_move_cursor(instance, silent);
    511         ega_show_cursor(instance, silent);
    512 }
    513 
    514 static void ega_display_char(ega_instance_t *instance, wchar_t ch, bool silent)
     511        ega_check_cursor(instance);
     512        ega_move_cursor(instance);
     513        ega_show_cursor(instance);
     514}
     515
     516static void ega_display_char(ega_instance_t *instance, wchar_t ch)
    515517{
    516518        uint16_t index = ega_oem_glyph(ch);
     
    529531        instance->backbuf[instance->cursor * 2 + 1] = style;
    530532       
    531         if (!silent) {
     533        if ((!instance->parea.mapped) || (console_override)) {
    532534                instance->addr[instance->cursor * 2] = glyph;
    533535                instance->addr[instance->cursor * 2 + 1] = style;
     
    535537}
    536538
    537 static void ega_putchar(outdev_t *dev, wchar_t ch, bool silent)
     539static void ega_putchar(outdev_t *dev, wchar_t ch)
    538540{
    539541        ega_instance_t *instance = (ega_instance_t *) dev->data;
     
    555557                break;
    556558        default:
    557                 ega_display_char(instance, ch, silent);
     559                ega_display_char(instance, ch);
    558560                instance->cursor++;
    559561                break;
    560562        }
    561         ega_check_cursor(instance, silent);
    562         ega_move_cursor(instance, silent);
     563        ega_check_cursor(instance);
     564        ega_move_cursor(instance);
    563565       
    564566        irq_spinlock_unlock(&instance->lock, true);
     
    572574       
    573575        memcpy(instance->addr, instance->backbuf, EGA_VRAM_SIZE);
    574         ega_move_cursor(instance, silent);
    575         ega_show_cursor(instance, silent);
     576        ega_move_cursor(instance);
     577        ega_show_cursor(instance);
    576578       
    577579        irq_spinlock_unlock(&instance->lock, true);
     
    612614        }
    613615       
     616        link_initialize(&instance->parea.link);
     617        instance->parea.pbase = addr;
     618        instance->parea.frames = SIZE2FRAMES(EGA_VRAM_SIZE);
     619        instance->parea.unpriv = false;
     620        instance->parea.mapped = false;
     621        ddi_parea_register(&instance->parea);
     622       
    614623        /* Synchronize the back buffer and cursor position. */
    615624        memcpy(instance->backbuf, instance->addr, EGA_VRAM_SIZE);
    616         ega_sync_cursor(instance, silent);
     625        ega_sync_cursor(instance);
    617626       
    618627        if (!fb_exported) {
    619628                /*
    620                  * This is the necessary evil until the userspace driver is entirely
    621                  * self-sufficient.
     629                 * We export the kernel framebuffer for uspace usage.
     630                 * This is used in the case the uspace framebuffer
     631                 * driver is not self-sufficient.
    622632                 */
    623633                sysinfo_set_item_val("fb", NULL, true);
  • kernel/genarch/src/drivers/s3c24xx_uart/s3c24xx_uart.c

    ree2fa30a rb366a6f4  
    4444#include <arch/asm.h>
    4545#include <mm/slab.h>
     46#include <mm/page.h>
    4647#include <sysinfo/sysinfo.h>
    4748#include <str.h>
     
    5960}
    6061
    61 static void s3c24xx_uart_putchar(outdev_t *dev, wchar_t ch, bool silent)
     62static void s3c24xx_uart_putchar(outdev_t *dev, wchar_t ch)
    6263{
    63         if (!silent) {
     64        s3c24xx_uart_t *uart =
     65            (s3c24xx_uart_t *) dev->data;
     66       
     67        if ((!uart->parea.mapped) || (console_override)) {
    6468                if (!ascii_check(ch)) {
    6569                        s3c24xx_uart_sendb(dev, U_SPECIAL);
    6670                } else {
    67                         if (ch == '\n')
     71                        if (ch == '\n')
    6872                                s3c24xx_uart_sendb(dev, (uint8_t) '\r');
    6973                        s3c24xx_uart_sendb(dev, (uint8_t) ch);
     
    9397};
    9498
    95 outdev_t *s3c24xx_uart_init(s3c24xx_uart_io_t *io, inr_t inr)
     99outdev_t *s3c24xx_uart_init(uintptr_t paddr, inr_t inr)
    96100{
    97101        outdev_t *uart_dev = malloc(sizeof(outdev_t), FRAME_ATOMIC);
     
    109113        uart_dev->data = uart;
    110114
    111         uart->io = io;
     115        uart->io = (s3c24xx_uart_io_t *) hw_map(paddr, PAGE_SIZE);
    112116        uart->indev = NULL;
    113117
     
    127131        pio_write_32(&uart->io->ucon,
    128132            pio_read_32(&uart->io->ucon) & ~UCON_RX_INT_LEVEL);
    129 
     133       
     134        link_initialize(&uart->parea.link);
     135        uart->parea.pbase = paddr;
     136        uart->parea.frames = 1;
     137        uart->parea.unpriv = false;
     138        uart->parea.mapped = false;
     139        ddi_parea_register(&uart->parea);
     140       
    130141        if (!fb_exported) {
    131142                /*
    132                  * This is the necessary evil until the userspace driver is entirely
     143                 * This is the necessary evil until
     144                 * the userspace driver is entirely
    133145                 * self-sufficient.
    134146                 */
    135147                sysinfo_set_item_val("fb", NULL, true);
    136148                sysinfo_set_item_val("fb.kind", NULL, 3);
    137                 sysinfo_set_item_val("fb.address.physical", NULL, KA2PA(io));
     149                sysinfo_set_item_val("fb.address.physical", NULL, paddr);
    138150
    139151                fb_exported = true;
  • kernel/genarch/src/fb/fb.c

    ree2fa30a rb366a6f4  
    8282        SPINLOCK_DECLARE(lock);
    8383       
     84        parea_t parea;
     85       
    8486        uint8_t *addr;
    8587        uint16_t *backbuf;
     
    109111} fb_instance_t;
    110112
    111 static void fb_putchar(outdev_t *dev, wchar_t ch, bool silent);
     113static void fb_putchar(outdev_t *dev, wchar_t ch);
    112114static void fb_redraw_internal(fb_instance_t *instance);
    113115static void fb_redraw(outdev_t *dev);
     
    215217 *
    216218 */
    217 static void logo_hide(fb_instance_t *instance, bool silent)
     219static void logo_hide(fb_instance_t *instance)
    218220{
    219221        instance->ylogo = 0;
     
    221223        instance->rowtrim = instance->rows;
    222224       
    223         if (!silent)
     225        if ((!instance->parea.mapped) || (console_override))
    224226                fb_redraw_internal(instance);
    225227}
     
    229231 */
    230232static void glyph_draw(fb_instance_t *instance, uint16_t glyph,
    231     unsigned int col, unsigned int row, bool silent, bool overlay)
     233    unsigned int col, unsigned int row, bool overlay)
    232234{
    233235        unsigned int x = COL2X(col);
     
    236238       
    237239        if (y >= instance->ytrim)
    238                 logo_hide(instance, silent);
     240                logo_hide(instance);
    239241       
    240242        if (!overlay)
    241243                instance->backbuf[BB_POS(instance, col, row)] = glyph;
    242244       
    243         if (!silent) {
     245        if ((!instance->parea.mapped) || (console_override)) {
    244246                for (yd = 0; yd < FONT_SCANLINES; yd++)
    245247                        memcpy(&instance->addr[FB_POS(instance, x, y + yd + instance->ylogo)],
     
    253255 *
    254256 */
    255 static void screen_scroll(fb_instance_t *instance, bool silent)
     257static void screen_scroll(fb_instance_t *instance)
    256258{
    257259        if (instance->ylogo > 0) {
    258                 logo_hide(instance, silent);
     260                logo_hide(instance);
    259261                return;
    260262        }
    261263       
    262         if (!silent) {
     264        if ((!instance->parea.mapped) || (console_override)) {
    263265                unsigned int row;
    264266               
     
    298300}
    299301
    300 static void cursor_put(fb_instance_t *instance, bool silent)
     302static void cursor_put(fb_instance_t *instance)
    301303{
    302304        unsigned int col = instance->position % instance->cols;
    303305        unsigned int row = instance->position / instance->cols;
    304306       
    305         glyph_draw(instance, fb_font_glyph(U_CURSOR), col, row, silent, true);
    306 }
    307 
    308 static void cursor_remove(fb_instance_t *instance, bool silent)
     307        glyph_draw(instance, fb_font_glyph(U_CURSOR), col, row, true);
     308}
     309
     310static void cursor_remove(fb_instance_t *instance)
    309311{
    310312        unsigned int col = instance->position % instance->cols;
     
    312314       
    313315        glyph_draw(instance, instance->backbuf[BB_POS(instance, col, row)],
    314             col, row, silent, true);
     316            col, row, true);
    315317}
    316318
     
    362364 *
    363365 */
    364 static void fb_putchar(outdev_t *dev, wchar_t ch, bool silent)
     366static void fb_putchar(outdev_t *dev, wchar_t ch)
    365367{
    366368        fb_instance_t *instance = (fb_instance_t *) dev->data;
     
    369371        switch (ch) {
    370372        case '\n':
    371                 cursor_remove(instance, silent);
     373                cursor_remove(instance);
    372374                instance->position += instance->cols;
    373375                instance->position -= instance->position % instance->cols;
    374376                break;
    375377        case '\r':
    376                 cursor_remove(instance, silent);
     378                cursor_remove(instance);
    377379                instance->position -= instance->position % instance->cols;
    378380                break;
    379381        case '\b':
    380                 cursor_remove(instance, silent);
     382                cursor_remove(instance);
    381383                if (instance->position % instance->cols)
    382384                        instance->position--;
    383385                break;
    384386        case '\t':
    385                 cursor_remove(instance, silent);
     387                cursor_remove(instance);
    386388                do {
    387389                        glyph_draw(instance, fb_font_glyph(' '),
    388390                            instance->position % instance->cols,
    389                             instance->position / instance->cols, silent, false);
     391                            instance->position / instance->cols, false);
    390392                        instance->position++;
    391393                } while ((instance->position % 8)
     
    395397                glyph_draw(instance, fb_font_glyph(ch),
    396398                    instance->position % instance->cols,
    397                     instance->position / instance->cols, silent, false);
     399                    instance->position / instance->cols, false);
    398400                instance->position++;
    399401        }
     
    401403        if (instance->position >= instance->cols * instance->rows) {
    402404                instance->position -= instance->cols;
    403                 screen_scroll(instance, silent);
    404         }
    405        
    406         cursor_put(instance, silent);
     405                screen_scroll(instance);
     406        }
     407       
     408        cursor_put(instance);
    407409       
    408410        spinlock_unlock(&instance->lock);
     
    555557       
    556558        spinlock_initialize(&instance->lock, "*fb.instance.lock");
     559       
    557560        instance->rgb_conv = rgb_conv;
    558561        instance->pixelbytes = pixelbytes;
     
    623626        glyphs_render(instance);
    624627       
     628        link_initialize(&instance->parea.link);
     629        instance->parea.pbase = props->addr;
     630        instance->parea.frames = SIZE2FRAMES(fbsize);
     631        instance->parea.unpriv = false;
     632        instance->parea.mapped = false;
     633        ddi_parea_register(&instance->parea);
     634       
    625635        if (!fb_exported) {
    626636                /*
    627                  * This is the necessary evil until the userspace driver is entirely
    628                  * self-sufficient.
     637                 * We export the kernel framebuffer for uspace usage.
     638                 * This is used in the case the uspace framebuffer
     639                 * driver is not self-sufficient.
    629640                 */
    630641                sysinfo_set_item_val("fb", NULL, true);
Note: See TracChangeset for help on using the changeset viewer.