Changeset cf3a905c in mainline


Ignore:
Timestamp:
2018-11-23T18:32:50Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
04c35fca
Parents:
2519349
git-author:
Jiri Svoboda <jiri@…> (2018-11-22 19:31:08)
git-committer:
Jiri Svoboda <jiri@…> (2018-11-23 18:32:50)
Message:

Arbitrate ski console device using an arbitration parea.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia64/src/drivers/ski.c

    r2519349 rcf3a905c  
    3737#include <console/console.h>
    3838#include <console/chardev.h>
     39#include <ddi/ddi.h>
    3940#include <sysinfo/sysinfo.h>
    4041#include <stdint.h>
     
    6970
    7071static ski_instance_t *instance = NULL;
     72static parea_t ski_parea;
    7173
    7274/** Ask debug console if a key was pressed.
     
    105107        int count = POLL_LIMIT;
    106108
     109        if (ski_parea.mapped)
     110                return;
     111
    107112        while (count > 0) {
    108113                wchar_t ch = ski_getchar();
     
    122127
    123128        while (true) {
    124                 // TODO FIXME:
    125                 // This currently breaks the kernel console
    126                 // before we get the override from uspace.
    127                 if (console_override)
    128                         poll_keyboard(instance);
    129 
     129                poll_keyboard(instance);
    130130                thread_usleep(POLL_INTERVAL);
    131131        }
     
    140140static void ski_init(void)
    141141{
     142        uintptr_t faddr;
     143
    142144        if (instance)
    143145                return;
     
    150152            : "r15", "r8"
    151153        );
     154
     155        faddr = frame_alloc(1, FRAME_LOWMEM | FRAME_ATOMIC, 0);
     156        if (faddr == 0)
     157                panic("Cannot allocate page for ski console.");
     158
     159        ddi_parea_init(&ski_parea);
     160        ski_parea.pbase = faddr;
     161        ski_parea.frames = 1;
     162        ski_parea.unpriv = false;
     163        ski_parea.mapped = false;
     164        ddi_parea_register(&ski_parea);
     165
     166        sysinfo_set_item_val("ski.paddr", NULL, (sysarg_t) faddr);
    152167
    153168        instance = malloc(sizeof(ski_instance_t));
     
    190205static void ski_putwchar(outdev_t *dev, wchar_t ch)
    191206{
    192         // TODO FIXME:
    193         // This currently breaks the kernel console
    194         // before we get the override from uspace.
    195         if (console_override) {
    196                 if (ascii_check(ch)) {
    197                         if (ch == '\n')
    198                                 ski_do_putchar('\r');
    199 
    200                         ski_do_putchar(ch);
    201                 } else {
    202                         ski_do_putchar('?');
    203                 }
     207        if (ski_parea.mapped)
     208                return;
     209
     210        if (ascii_check(ch)) {
     211                if (ch == '\n')
     212                        ski_do_putchar('\r');
     213
     214                ski_do_putchar(ch);
     215        } else {
     216                ski_do_putchar('?');
    204217        }
    205218}
  • uspace/drv/char/ski-con/ski-con.c

    r2519349 rcf3a905c  
    3131 */
    3232
     33#include <as.h>
    3334#include <async.h>
    3435#include <ddf/driver.h>
    3536#include <ddf/log.h>
     37#include <ddi.h>
    3638#include <errno.h>
    3739#include <fibril.h>
     
    6971        ddf_fun_t *fun = NULL;
    7072        bool bound = false;
     73        uintptr_t faddr;
     74        void *addr = AS_AREA_ANY;
    7175        errno_t rc;
    7276
     
    8892        con->cds.sarg = con;
    8993
     94        rc = sysinfo_get_value("ski.paddr", &faddr);
     95        if (rc != EOK)
     96                faddr = 0; /* No kernel driver to arbitrate with */
     97
     98        if (faddr != 0) {
     99                addr = AS_AREA_ANY;
     100                rc = physmem_map(faddr, 1, AS_AREA_READ | AS_AREA_CACHEABLE,
     101                    &addr);
     102                if (rc != EOK) {
     103                        ddf_msg(LVL_ERROR, "Cannot map kernel driver arbitration area.");
     104                        goto error;
     105                }
     106        }
     107
    90108        rc = ddf_fun_bind(fun);
    91109        if (rc != EOK) {
     
    108126        return EOK;
    109127error:
     128        if (addr != AS_AREA_ANY)
     129                as_area_destroy(addr);
    110130        if (bound)
    111131                ddf_fun_unbind(fun);
  • uspace/drv/char/ski-con/ski-con.h

    r2519349 rcf3a905c  
    5656        fibril_mutex_t buf_lock;
    5757        fibril_condvar_t buf_cv;
     58        /** Memory area mapped to arbitrate with the kernel driver */
     59        void *mem_area;
    5860} ski_con_t;
    5961
Note: See TracChangeset for help on using the changeset viewer.