Ignore:
Timestamp:
2009-08-21T14:12:45Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0e6dce8, b50b5af2, e5792d1
Parents:
90c8b8d
Message:

kernel output devices now suport multiple instances (except ski and sgcn, which respect the same interface, but behave as singletons)
if more than one output device gets initialized, the output is cloned to all of them
get rid of arch_grab_console() and arch_release_console() (output devices can implement a generic "redraw" method, input devices respect the "silent" global variable)
related cleanups and modifications

File:
1 edited

Legend:

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

    r90c8b8d ra71c158  
    3535 */
    3636
    37 
    3837#include <genarch/drivers/dsrln/dsrlnout.h>
    3938#include <console/chardev.h>
    4039#include <arch/asm.h>
     40#include <mm/slab.h>
    4141#include <console/console.h>
    4242#include <sysinfo/sysinfo.h>
    4343#include <string.h>
    4444
    45 static ioport8_t *dsrlnout_base;
     45typedef struct {
     46        ioport8_t *base;
     47} dsrlnout_instance_t;
    4648
    47 static void dsrlnout_putchar(outdev_t *dev __attribute__((unused)), const wchar_t ch, bool silent)
     49static void dsrlnout_putchar(outdev_t *dev, const wchar_t ch, bool silent)
    4850{
     51        dsrlnout_instance_t *instance = (dsrlnout_instance_t *) dev->data;
     52       
    4953        if (!silent) {
    5054                if (ascii_check(ch))
    51                         pio_write_8(dsrlnout_base, ch);
     55                        pio_write_8(instance->base, ch);
    5256                else
    53                         pio_write_8(dsrlnout_base, U_SPECIAL);
     57                        pio_write_8(instance->base, U_SPECIAL);
    5458        }
    5559}
    5660
    57 static outdev_t dsrlnout_console;
    58 static outdev_operations_t dsrlnout_ops = {
    59         .write = dsrlnout_putchar
     61static outdev_operations_t dsrlndev_ops = {
     62        .write = dsrlnout_putchar,
     63        .redraw = NULL
    6064};
    6165
    62 void dsrlnout_init(ioport8_t *base)
     66outdev_t *dsrlnout_init(ioport8_t *base)
    6367{
    64         /* Initialize the software structure. */
    65         dsrlnout_base = base;
     68        outdev_t *dsrlndev = malloc(sizeof(outdev_t), FRAME_ATOMIC);
     69        if (!dsrlndev)
     70                return NULL;
    6671       
    67         outdev_initialize("dsrlnout", &dsrlnout_console, &dsrlnout_ops);
    68         stdout_wire(&dsrlnout_console);
     72        dsrlnout_instance_t *instance = malloc(sizeof(dsrlnout_instance_t), FRAME_ATOMIC);
     73        if (!instance) {
     74                free(dsrlndev);
     75                return NULL;
     76        }
    6977       
    70         sysinfo_set_item_val("fb", NULL, true);
    71         sysinfo_set_item_val("fb.kind", NULL, 3);
    72         sysinfo_set_item_val("fb.address.physical", NULL, KA2PA(base));
     78        outdev_initialize("dsrlndev", dsrlndev, &dsrlndev_ops);
     79        dsrlndev->data = instance;
     80       
     81        instance->base = base;
     82       
     83        if (!fb_exported) {
     84                /*
     85                 * This is the necessary evil until the userspace driver is entirely
     86                 * self-sufficient.
     87                 */
     88                sysinfo_set_item_val("fb", NULL, true);
     89                sysinfo_set_item_val("fb.kind", NULL, 3);
     90                sysinfo_set_item_val("fb.address.physical", NULL, KA2PA(base));
     91               
     92                fb_exported = true;
     93        }
     94       
     95        return dsrlndev;
    7396}
    7497
Note: See TracChangeset for help on using the changeset viewer.