Changeset 593e023 in mainline


Ignore:
Timestamp:
2014-08-12T17:14:32Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c3bdc92
Parents:
ce3efa0
Message:

allow compositor and console to coexist side-by-side, use the input server as a poor man's seat arbitrator

  • kernel console notifies both about the release and grab events
  • input server arbitrates the seat selection between kernel console and any number of user space UIs (currently the console server and the compositor server)
  • input port yield and reclaim methods have been removed (they are used only on Ski and Niagara, both already need a more generic mechanism for the kernel/user space cooperation)
  • console and compositor server keep track of the kernel console via the input arbitration
  • move the waiting for a character device from init and terminal widget to getterm
Files:
25 edited

Legend:

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

    rce3efa0 r593e023  
    13571357        printf("The kernel will now relinquish the console.\n");
    13581358        release_console();
    1359        
    1360         event_notify_0(EVENT_KCONSOLE, false);
    13611359        indev_pop_character(stdin);
    13621360       
  • kernel/generic/src/console/console.c

    rce3efa0 r593e023  
    204204void grab_console(void)
    205205{
     206        event_notify_1(EVENT_KCONSOLE, false, true);
    206207        bool prev = console_override;
    207208       
     
    221222{
    222223        console_override = false;
     224        event_notify_1(EVENT_KCONSOLE, false, false);
    223225}
    224226
  • uspace/app/getterm/getterm.c

    rce3efa0 r593e023  
    4242#include <str_error.h>
    4343#include <errno.h>
     44#include <loc.h>
    4445#include "version.h"
    4546#include "welcome.h"
     
    4950static void usage(void)
    5051{
    51         printf("Usage: %s <terminal> [-w] <command> [<arguments...>]\n", APP_NAME);
     52        printf("Usage: %s <terminal> <locfs> [--msg] [--wait] -- "
     53            "<command> [<arguments...>]\n", APP_NAME);
     54        printf(" <terminal>    Terminal device\n");
     55        printf(" <locfs>       Mount point of locfs\n");
     56        printf(" --msg         Print welcome message\n");
     57        printf(" --wait        Wait for the terminal to be ready\n");
    5258}
    5359
    54 static void reopen(FILE **stream, int fd, const char *path, int flags, const char *mode)
     60static void reopen(FILE **stream, int fd, const char *path, int flags,
     61    const char *mode)
    5562{
    5663        if (fclose(*stream))
     
    7683int main(int argc, char *argv[])
    7784{
    78         int rc;
    79         task_exit_t texit;
    80         int retval;
    81         task_id_t id;
    82         char *fname, *term;
    83         char **cmd_args;
    84         bool print_wmsg;
    85 
    8685        argv++;
    8786        argc--;
     87        if (argc < 4) {
     88                usage();
     89                return 1;
     90        }
     91       
     92        char *term = *argv;
     93        argv++;
     94        argc--;
     95       
     96        char *locfs = *argv;
     97        argv++;
     98        argc--;
     99       
     100        bool print_msg = false;
     101        bool wait = false;
     102       
     103        while ((argc > 0) && (str_cmp(*argv, "--") != 0)) {
     104                if (str_cmp(*argv, "--msg") == 0) {
     105                        print_msg = true;
     106                } else if (str_cmp(*argv, "--wait") == 0) {
     107                        wait = true;
     108                } else {
     109                        usage();
     110                        return 2;
     111                }
     112               
     113                argv++;
     114                argc--;
     115        }
     116       
    88117        if (argc < 1) {
    89118                usage();
    90                 return -1;
     119                return 3;
    91120        }
    92 
    93         if (str_cmp(*argv, "-w") == 0) {
    94                 print_wmsg = true;
    95                 argv++;
    96                 argc--;
    97         } else {
    98                 print_wmsg = false;
     121       
     122        /* Skip "--" */
     123        argv++;
     124        argc--;
     125       
     126        char *cmd = *argv;
     127        char **args = argv;
     128       
     129        if (wait) {
     130                /* Wait for the terminal service to be ready */
     131                service_id_t service_id;
     132                int rc = loc_service_get_id(term, &service_id, IPC_FLAG_BLOCKING);
     133                if (rc != EOK) {
     134                        printf("%s: Error waiting on %s (%s)\n", APP_NAME, term,
     135                            str_error(rc));
     136                        return rc;
     137                }
    99138        }
    100 
    101         if (argc < 2) {
    102                 usage();
    103                 return -1;
    104         }
    105 
    106         term = *argv++;
    107         fname = *argv;
    108         cmd_args = argv;
    109139       
    110         reopen(&stdin, 0, term, O_RDONLY, "r");
    111         reopen(&stdout, 1, term, O_WRONLY, "w");
    112         reopen(&stderr, 2, term, O_WRONLY, "w");
     140        char term_node[LOC_NAME_MAXLEN];
     141        snprintf(term_node, LOC_NAME_MAXLEN, "%s/%s", locfs, term);
     142       
     143        reopen(&stdin, 0, term_node, O_RDONLY, "r");
     144        reopen(&stdout, 1, term_node, O_WRONLY, "w");
     145        reopen(&stderr, 2, term_node, O_WRONLY, "w");
    113146       
    114147        if (stdin == NULL)
    115                 return -2;
     148                return 4;
    116149       
    117150        if (stdout == NULL)
    118                 return -3;
     151                return 5;
    119152       
    120153        if (stderr == NULL)
    121                 return -4;
     154                return 6;
    122155       
    123156        /*
     
    128161       
    129162        version_print(term);
    130         if (print_wmsg)
     163        if (print_msg)
    131164                welcome_msg_print();
    132 
    133         rc = task_spawnv(&id, fname, (const char * const *) cmd_args);
     165       
     166        task_id_t id;
     167       
     168        int rc = task_spawnv(&id, cmd, (const char * const *) args);
    134169        if (rc != EOK) {
    135                 printf("%s: Error spawning %s (%s)\n", APP_NAME, fname,
     170                printf("%s: Error spawning %s (%s)\n", APP_NAME, cmd,
    136171                    str_error(rc));
    137                 return -5;
     172                return rc;
    138173        }
    139 
     174       
     175        task_exit_t texit;
     176        int retval;
    140177        rc = task_wait(id, &texit, &retval);
    141178        if (rc != EOK) {
    142                 printf("%s: Error waiting for %s (%s)\n", APP_NAME, fname,
     179                printf("%s: Error waiting for %s (%s)\n", APP_NAME, cmd,
    143180                    str_error(rc));
    144                 return -6;
     181                return rc;
    145182        }
    146 
     183       
    147184        return 0;
    148185}
  • uspace/app/init/init.c

    rce3efa0 r593e023  
    272272}
    273273
    274 static void getterm(const char *svc, const char *app, bool wmsg)
    275 {
    276         char term[LOC_NAME_MAXLEN];
    277         snprintf(term, LOC_NAME_MAXLEN, "%s/%s", LOCFS_MOUNT_POINT, svc);
    278        
    279         printf("%s: Spawning %s %s %s\n", NAME, APP_GETTERM, term, app);
    280        
    281         /* Wait for the terminal service to be ready */
    282         service_id_t service_id;
    283         int rc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING);
    284         if (rc != EOK) {
    285                 printf("%s: Error waiting on %s (%s)\n", NAME, term,
    286                     str_error(rc));
    287                 return;
    288         }
    289        
    290         if (wmsg) {
    291                 rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, "-w", term,
    292                     app, NULL);
    293                 if (rc != EOK) {
    294                         printf("%s: Error spawning %s -w %s %s (%s)\n", NAME,
    295                             APP_GETTERM, term, app, str_error(rc));
    296                 }
     274static void getterm(const char *svc, const char *app, bool msg)
     275{
     276        if (msg) {
     277                printf("%s: Spawning %s %s %s --msg --wait -- %s\n", NAME,
     278                    APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
     279               
     280                int rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, svc,
     281                    LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL);
     282                if (rc != EOK)
     283                        printf("%s: Error spawning %s %s %s --msg --wait -- %s\n",
     284                            NAME, APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
    297285        } else {
    298                 rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, term, app,
    299                     NULL);
    300                 if (rc != EOK) {
    301                         printf("%s: Error spawning %s %s %s (%s)\n", NAME,
    302                             APP_GETTERM, term, app, str_error(rc));
    303                 }
     286                printf("%s: Spawning %s %s %s --wait -- %s\n", NAME,
     287                    APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
     288               
     289                int rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, svc,
     290                    LOCFS_MOUNT_POINT, "--wait", "--", app, NULL);
     291                if (rc != EOK)
     292                        printf("%s: Error spawning %s %s %s --wait -- %s\n",
     293                            NAME, APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
    304294        }
    305295}
     
    364354                gui_start("/app/vlaunch", HID_COMPOSITOR_SERVER);
    365355                gui_start("/app/vterm", HID_COMPOSITOR_SERVER);
    366         } else {
    367                 rc = console(HID_INPUT, HID_OUTPUT);
    368                 if (rc == EOK) {
    369                         getterm("term/vc0", "/app/bdsh", true);
    370                         getterm("term/vc1", "/app/bdsh", false);
    371                         getterm("term/vc2", "/app/bdsh", false);
    372                         getterm("term/vc3", "/app/bdsh", false);
    373                         getterm("term/vc4", "/app/bdsh", false);
    374                         getterm("term/vc5", "/app/bdsh", false);
    375                         getterm("term/vc6", "/app/klog", false);
    376                 }
     356        }
     357       
     358        rc = console(HID_INPUT, HID_OUTPUT);
     359        if (rc == EOK) {
     360                getterm("term/vc0", "/app/bdsh", true);
     361                getterm("term/vc1", "/app/bdsh", false);
     362                getterm("term/vc2", "/app/bdsh", false);
     363                getterm("term/vc3", "/app/bdsh", false);
     364                getterm("term/vc4", "/app/bdsh", false);
     365                getterm("term/vc5", "/app/bdsh", false);
    377366        }
    378367       
  • uspace/lib/c/generic/io/input.c

    rce3efa0 r593e023  
    8080}
    8181
    82 int input_yield(input_t *input)
     82int input_activate(input_t *input)
    8383{
    8484        async_exch_t *exch = async_exchange_begin(input->sess);
    85         int rc = async_req_0_0(exch, INPUT_YIELD);
     85        int rc = async_req_0_0(exch, INPUT_ACTIVATE);
    8686        async_exchange_end(exch);
    8787       
     
    8989}
    9090
    91 int input_reclaim(input_t *input)
    92 {
    93         async_exch_t *exch = async_exchange_begin(input->sess);
    94 
    95         int rc = async_req_0_0(exch, INPUT_RECLAIM);
    96         async_exchange_end(exch);
    97 
    98         return rc;
     91static void input_ev_active(input_t *input, ipc_callid_t callid,
     92    ipc_call_t *call)
     93{
     94        int rc = input->ev_ops->active(input);
     95        async_answer_0(callid, rc);
     96}
     97
     98static void input_ev_deactive(input_t *input, ipc_callid_t callid,
     99    ipc_call_t *call)
     100{
     101        int rc = input->ev_ops->deactive(input);
     102        async_answer_0(callid, rc);
    99103}
    100104
     
    177181
    178182                switch (IPC_GET_IMETHOD(call)) {
     183                case INPUT_EVENT_ACTIVE:
     184                        input_ev_active(input, callid, &call);
     185                        break;
     186                case INPUT_EVENT_DEACTIVE:
     187                        input_ev_deactive(input, callid, &call);
     188                        break;
    179189                case INPUT_EVENT_KEY:
    180190                        input_ev_key(input, callid, &call);
  • uspace/lib/c/include/io/input.h

    rce3efa0 r593e023  
    4949
    5050typedef struct input_ev_ops {
     51        int (*active)(input_t *);
     52        int (*deactive)(input_t *);
    5153        int (*key)(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t);
    5254        int (*move)(input_t *, int, int);
     
    5759extern int input_open(async_sess_t *, input_ev_ops_t *, void *, input_t **);
    5860extern void input_close(input_t *);
    59 extern int input_yield(input_t *);
    60 extern int input_reclaim(input_t *);
     61extern int input_activate(input_t *);
    6162
    6263#endif
  • uspace/lib/c/include/ipc/input.h

    rce3efa0 r593e023  
    3939
    4040typedef enum {
    41         INPUT_YIELD = IPC_FIRST_USER_METHOD,
    42         INPUT_RECLAIM
     41        INPUT_ACTIVATE = IPC_FIRST_USER_METHOD
    4342} input_request_t;
    4443
    4544typedef enum {
    46         INPUT_EVENT_KEY = IPC_FIRST_USER_METHOD,
     45        INPUT_EVENT_ACTIVE = IPC_FIRST_USER_METHOD,
     46        INPUT_EVENT_DEACTIVE,
     47        INPUT_EVENT_KEY,
    4748        INPUT_EVENT_MOVE,
    4849        INPUT_EVENT_ABS_MOVE,
  • uspace/lib/gui/terminal.c

    rce3efa0 r593e023  
    104104static void getterm(const char *svc, const char *app)
    105105{
    106         char term[LOC_NAME_MAXLEN];
    107         snprintf(term, LOC_NAME_MAXLEN, "%s/%s", LOCFS_MOUNT_POINT, svc);
    108        
    109         /* Wait for the terminal service to be ready */
    110         service_id_t service_id;
    111         int rc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING);
    112         if (rc != EOK)
    113                 return;
    114        
    115         task_spawnl(NULL, APP_GETTERM, APP_GETTERM, "-w", term, app, NULL);
     106        task_spawnl(NULL, APP_GETTERM, APP_GETTERM, svc, LOCFS_MOUNT_POINT,
     107            "--msg", "--wait", "--", app, NULL);
    116108}
    117109
  • uspace/srv/hid/compositor/compositor.c

    rce3efa0 r593e023  
    5656#include <loc.h>
    5757
    58 #include <event.h>
    5958#include <io/keycode.h>
    6059#include <io/mode.h>
    6160#include <io/visualizer.h>
    6261#include <io/window.h>
     62#include <io/console.h>
    6363
    6464#include <transform.h>
     
    144144/** Input server proxy */
    145145static input_t *input;
    146 
     146static bool active = false;
     147
     148static int comp_active(input_t *);
     149static int comp_deactive(input_t *);
    147150static int comp_key_press(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t);
    148151static int comp_mouse_move(input_t *, int, int);
     
    151154
    152155static input_ev_ops_t input_ev_ops = {
     156        .active = comp_active,
     157        .deactive = comp_deactive,
    153158        .key = comp_key_press,
    154159        .move = comp_mouse_move,
     
    156161        .button = comp_mouse_button
    157162};
    158 
    159 static void input_disconnect(void);
    160163
    161164static pointer_t *input_pointer(input_t *input)
     
    567570
    568571        /* Notify visualizers about updated regions. */
    569         list_foreach(viewport_list, link, viewport_t, vp) {
    570                 sysarg_t x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp;
    571                 surface_get_damaged_region(vp->surface, &x_dmg_vp, &y_dmg_vp, &w_dmg_vp, &h_dmg_vp);
    572                 surface_reset_damaged_region(vp->surface);
    573                 visualizer_update_damaged_region(
    574                     vp->sess, x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp, 0, 0);
     572        if (active) {
     573                list_foreach(viewport_list, link, viewport_t, vp) {
     574                        sysarg_t x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp;
     575                        surface_get_damaged_region(vp->surface, &x_dmg_vp, &y_dmg_vp, &w_dmg_vp, &h_dmg_vp);
     576                        surface_reset_damaged_region(vp->surface);
     577                        visualizer_update_damaged_region(vp->sess,
     578                            x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp, 0, 0);
     579                }
    575580        }
    576581       
     
    10741079}
    10751080
     1081#if 0
     1082static void comp_shutdown(void)
     1083{
     1084        loc_service_unregister(winreg_id);
     1085        input_disconnect();
     1086       
     1087        /* Close all clients and their windows. */
     1088        fibril_mutex_lock(&window_list_mtx);
     1089        list_foreach(window_list, link, window_t, win) {
     1090                window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
     1091                if (event) {
     1092                        link_initialize(&event->link);
     1093                        event->type = WINDOW_CLOSE;
     1094                        prodcons_produce(&win->queue, &event->link);
     1095                }
     1096        }
     1097        fibril_mutex_unlock(&window_list_mtx);
     1098       
     1099        async_answer_0(iid, EOK);
     1100       
     1101        /* All fibrils of the compositor will terminate soon. */
     1102}
     1103#endif
     1104
    10761105static void comp_visualizer_disconnect(viewport_t *vp, ipc_callid_t iid, ipc_call_t *icall)
    10771106{
     
    10821111        viewport_destroy(vp);
    10831112       
    1084         /* Terminate compositor if there are no more viewports. */
    1085         if (list_empty(&viewport_list)) {
    1086                 fibril_mutex_unlock(&viewport_list_mtx);
    1087                 loc_service_unregister(winreg_id);
    1088                 input_disconnect();
    1089 
    1090                 /* Close all clients and their windows. */
    1091                 fibril_mutex_lock(&window_list_mtx);
    1092                 list_foreach(window_list, link, window_t, win) {
    1093                         window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
    1094                         if (event) {
    1095                                 link_initialize(&event->link);
    1096                                 event->type = WINDOW_CLOSE;
    1097                                 prodcons_produce(&win->queue, &event->link);
    1098                         }
    1099                 }
    1100                 fibril_mutex_unlock(&window_list_mtx);
    1101 
    1102                 async_answer_0(iid, EOK);
    1103 
    1104                 /* All fibrils of the compositor will terminate soon. */
    1105         } else {
    1106                 fibril_mutex_unlock(&viewport_list_mtx);
    1107                 async_answer_0(iid, EOK);
    1108 
    1109                 comp_restrict_pointers();
    1110                 comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
    1111         }
     1113        fibril_mutex_unlock(&viewport_list_mtx);
     1114       
     1115        async_answer_0(iid, EOK);
     1116       
     1117        comp_restrict_pointers();
     1118        comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
    11121119}
    11131120
     
    17801787}
    17811788
     1789static int comp_active(input_t *input)
     1790{
     1791        active = true;
     1792        comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
     1793       
     1794        return EOK;
     1795}
     1796
     1797static int comp_deactive(input_t *input)
     1798{
     1799        active = false;
     1800        return EOK;
     1801}
     1802
    17821803static int comp_key_press(input_t *input, kbd_event_type_t type, keycode_t key,
    17831804    keymod_t mods, wchar_t c)
     
    20682089                fibril_mutex_unlock(&viewport_list_mtx);
    20692090        } else if (kconsole_switch) {
    2070                 __SYSCALL0(SYS_DEBUG_CONSOLE);
     2091                if (console_kcon())
     2092                        active = false;
    20712093        } else {
    20722094                window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
     
    21372159}
    21382160
    2139 static void interrupt_received(ipc_callid_t callid, ipc_call_t *call)
    2140 {
    2141         comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
    2142 }
    2143 
    2144 static int discover_viewports(void)
    2145 {
     2161static void discover_viewports(void)
     2162{
     2163        fibril_mutex_lock(&discovery_mtx);
     2164       
    21462165        /* Create viewports and connect them to visualizers. */
    21472166        category_id_t cat_id;
    21482167        int rc = loc_category_get_id("visualizer", &cat_id, IPC_FLAG_BLOCKING);
    2149         if (rc != EOK) {
    2150                 printf("%s: Failed to get visualizer category.\n", NAME);
    2151                 return -1;
    2152         }
     2168        if (rc != EOK)
     2169                goto ret;
    21532170       
    21542171        service_id_t *svcs;
    21552172        size_t svcs_cnt = 0;
    21562173        rc = loc_category_get_svcs(cat_id, &svcs, &svcs_cnt);
    2157         if (rc != EOK || svcs_cnt == 0) {
    2158                 printf("%s: Failed to get visualizer category services.\n", NAME);
    2159                 return -1;
    2160         }
    2161 
    2162         fibril_mutex_lock(&viewport_list_mtx); 
     2174        if (rc != EOK)
     2175                goto ret;
     2176       
     2177        fibril_mutex_lock(&viewport_list_mtx);
    21632178        for (size_t i = 0; i < svcs_cnt; ++i) {
    21642179                bool exists = false;
     
    21792194        fibril_mutex_unlock(&viewport_list_mtx);
    21802195       
    2181         /* TODO damage only newly added viewports */
    2182         comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
    2183         return EOK;
     2196        if (!list_empty(&viewport_list))
     2197                input_activate(input);
     2198       
     2199ret:
     2200        fibril_mutex_unlock(&discovery_mtx);
    21842201}
    21852202
    21862203static void category_change_cb(void)
    21872204{
    2188         fibril_mutex_lock(&discovery_mtx);
    21892205        discover_viewports();
    2190         fibril_mutex_unlock(&discovery_mtx);
    21912206}
    21922207
     
    22062221                printf("%s: Unable to register server (%s)\n", NAME, str_error(rc));
    22072222                return -1;
    2208         }
    2209        
    2210         /* Register interrupt handler to switch back from kconsole. */
    2211         async_set_interrupt_received(interrupt_received);
    2212         rc = event_subscribe(EVENT_KCONSOLE, 0);
    2213         if (rc != EOK) {
    2214                 printf("%s: Failed to register kconsole notifications (%s)\n",
    2215                     NAME, str_error(rc));
    22162223        }
    22172224       
     
    22482255                input_disconnect();
    22492256                return rc;
    2250         }       
    2251        
    2252         rc = discover_viewports();
    2253         if (rc != EOK) {
    2254                 input_disconnect();
    2255                 return rc;
    2256         }
    2257        
    2258         if (list_empty(&viewport_list)) {
    2259                 printf("%s: Failed to get viewports.\n", NAME);
    2260                 input_disconnect();
    2261                 return -1;
    2262         }
     2257        }
     2258       
     2259        discover_viewports();
    22632260       
    22642261        comp_restrict_pointers();
  • uspace/srv/hid/console/console.c

    rce3efa0 r593e023  
    4141#include <str_error.h>
    4242#include <loc.h>
    43 #include <event.h>
    4443#include <io/con_srv.h>
    4544#include <io/kbd_event.h>
     
    8483/** Input server proxy */
    8584static input_t *input;
     85static bool active = false;
    8686
    8787/** Session to the output server */
     
    9898static FIBRIL_MUTEX_INITIALIZE(switch_mtx);
    9999
    100 static console_t *prev_console = &consoles[0];
    101100static console_t *active_console = &consoles[0];
    102 static console_t *kernel_console = &consoles[KERNEL_CONSOLE];
    103 
     101
     102static int input_ev_active(input_t *);
     103static int input_ev_deactive(input_t *);
    104104static int input_ev_key(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t);
    105105static int input_ev_move(input_t *, int, int);
     
    108108
    109109static input_ev_ops_t input_ev_ops = {
     110        .active = input_ev_active,
     111        .deactive = input_ev_deactive,
    110112        .key = input_ev_key,
    111113        .move = input_ev_move,
     
    159161        fibril_mutex_lock(&cons->mtx);
    160162       
    161         if ((cons == active_console) && (active_console != kernel_console)) {
     163        if ((active) && (cons == active_console)) {
    162164                output_update(output_sess, cons->fbid);
    163165                output_cursor_update(output_sess, cons->fbid);
     
    173175        fibril_mutex_lock(&cons->mtx);
    174176       
    175         if ((cons == active_console) && (active_console != kernel_console))
     177        if ((active) && (cons == active_console))
    176178                output_cursor_update(output_sess, cons->fbid);
    177179       
     
    185187        fibril_mutex_lock(&cons->mtx);
    186188       
    187         if ((cons == active_console) && (active_console != kernel_console)) {
     189        if ((active) && (cons == active_console)) {
    188190                output_damage(output_sess, cons->fbid, 0, 0, cons->cols,
    189191                    cons->rows);
     
    195197}
    196198
    197 static void cons_switch(console_t *cons)
    198 {
     199static void cons_switch(unsigned int index)
     200{
     201        /*
     202         * The first undefined index is reserved
     203         * for switching to the kernel console.
     204         */
     205        if (index == CONSOLE_COUNT) {
     206                if (console_kcon())
     207                        active = false;
     208               
     209                return;
     210        }
     211       
     212        if (index > CONSOLE_COUNT)
     213                return;
     214       
     215        console_t *cons = &consoles[index];
     216       
    199217        fibril_mutex_lock(&switch_mtx);
    200218       
     
    204222        }
    205223       
    206         if (cons == kernel_console) {
    207                 output_yield(output_sess);
    208                 if (!console_kcon()) {
    209                         output_claim(output_sess);
    210                         fibril_mutex_unlock(&switch_mtx);
    211                         return;
    212                 }
    213         }
    214        
    215         if (active_console == kernel_console)
    216                 output_claim(output_sess);
    217        
    218         prev_console = active_console;
    219224        active_console = cons;
    220225       
     
    224229}
    225230
    226 static console_t *cons_get_active_uspace(void)
    227 {
    228         fibril_mutex_lock(&switch_mtx);
    229        
    230         console_t *active_uspace = active_console;
    231         if (active_uspace == kernel_console)
    232                 active_uspace = prev_console;
    233        
    234         assert(active_uspace != kernel_console);
    235        
    236         fibril_mutex_unlock(&switch_mtx);
    237        
    238         return active_uspace;
     231static int input_ev_active(input_t *input)
     232{
     233        active = true;
     234        output_claim(output_sess);
     235        cons_damage(active_console);
     236       
     237        return EOK;
     238}
     239
     240static int input_ev_deactive(input_t *input)
     241{
     242        active = false;
     243        output_yield(output_sess);
     244       
     245        return EOK;
    239246}
    240247
     
    242249    keymod_t mods, wchar_t c)
    243250{
    244         if ((key >= KC_F1) && (key < KC_F1 + CONSOLE_COUNT) &&
     251        if ((key >= KC_F1) && (key <= KC_F1 + CONSOLE_COUNT) &&
    245252            ((mods & KM_CTRL) == 0)) {
    246                 cons_switch(&consoles[key - KC_F1]);
     253                cons_switch(key - KC_F1);
    247254        } else {
    248255                /* Got key press/release event */
     
    259266                event->c = c;
    260267               
    261                 /*
    262                  * Kernel console does not read events
    263                  * from us, so we will redirect them
    264                  * to the (last) active userspace console
    265                  * if necessary.
    266                  */
    267                 console_t *target_console = cons_get_active_uspace();
    268                
    269                 prodcons_produce(&target_console->input_pc,
     268                prodcons_produce(&active_console->input_pc,
    270269                    &event->link);
    271270        }
     
    509508       
    510509        for (size_t i = 0; i < CONSOLE_COUNT; i++) {
    511                 if (i == KERNEL_CONSOLE)
    512                         continue;
    513                
    514510                if (consoles[i].dsid == (service_id_t) IPC_GET_ARG1(*icall)) {
    515511                        cons = &consoles[i];
     
    556552       
    557553        return EOK;
    558 }
    559 
    560 static void interrupt_received(ipc_callid_t callid, ipc_call_t *call)
    561 {
    562         cons_switch(prev_console);
    563554}
    564555
     
    609600        output_get_caps(output_sess, &ccaps);
    610601       
    611         /* Inititalize consoles */
    612         for (size_t i = 0; i < CONSOLE_COUNT; i++) {
    613                 consoles[i].index = i;
    614                 atomic_set(&consoles[i].refcnt, 0);
    615                 fibril_mutex_initialize(&consoles[i].mtx);
    616                 prodcons_initialize(&consoles[i].input_pc);
    617                 consoles[i].char_remains_len = 0;
    618                
    619                 if (i == KERNEL_CONSOLE)
    620                         continue;
    621                
    622                 consoles[i].cols = cols;
    623                 consoles[i].rows = rows;
    624                 consoles[i].ccaps = ccaps;
    625                 consoles[i].frontbuf =
    626                     chargrid_create(cols, rows, CHARGRID_FLAG_SHARED);
    627                
    628                 if (consoles[i].frontbuf == NULL) {
    629                         printf("%s: Unable to allocate frontbuffer %zu\n", NAME, i);
    630                         return false;
     602        /*
     603         * Inititalize consoles only if there are
     604         * actually some output devices.
     605         */
     606        if (ccaps != 0) {
     607                for (size_t i = 0; i < CONSOLE_COUNT; i++) {
     608                        consoles[i].index = i;
     609                        atomic_set(&consoles[i].refcnt, 0);
     610                        fibril_mutex_initialize(&consoles[i].mtx);
     611                        prodcons_initialize(&consoles[i].input_pc);
     612                        consoles[i].char_remains_len = 0;
     613                       
     614                        consoles[i].cols = cols;
     615                        consoles[i].rows = rows;
     616                        consoles[i].ccaps = ccaps;
     617                        consoles[i].frontbuf =
     618                            chargrid_create(cols, rows, CHARGRID_FLAG_SHARED);
     619                       
     620                        if (consoles[i].frontbuf == NULL) {
     621                                printf("%s: Unable to allocate frontbuffer %zu\n", NAME, i);
     622                                return false;
     623                        }
     624                       
     625                        consoles[i].fbid = output_frontbuf_create(output_sess,
     626                            consoles[i].frontbuf);
     627                        if (consoles[i].fbid == 0) {
     628                                printf("%s: Unable to create frontbuffer %zu\n", NAME, i);
     629                                return false;
     630                        }
     631                       
     632                        con_srvs_init(&consoles[i].srvs);
     633                        consoles[i].srvs.ops = &con_ops;
     634                        consoles[i].srvs.sarg = &consoles[i];
     635                       
     636                        char vc[LOC_NAME_MAXLEN + 1];
     637                        snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
     638                       
     639                        if (loc_service_register(vc, &consoles[i].dsid) != EOK) {
     640                                printf("%s: Unable to register device %s\n", NAME, vc);
     641                                return false;
     642                        }
    631643                }
    632644               
    633                 consoles[i].fbid = output_frontbuf_create(output_sess,
    634                     consoles[i].frontbuf);
    635                 if (consoles[i].fbid == 0) {
    636                         printf("%s: Unable to create frontbuffer %zu\n", NAME, i);
    637                         return false;
    638                 }
    639                
    640                 con_srvs_init(&consoles[i].srvs);
    641                 consoles[i].srvs.ops = &con_ops;
    642                 consoles[i].srvs.sarg = &consoles[i];
    643                
    644                 char vc[LOC_NAME_MAXLEN + 1];
    645                 snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
    646                
    647                 if (loc_service_register(vc, &consoles[i].dsid) != EOK) {
    648                         printf("%s: Unable to register device %s\n", NAME, vc);
    649                         return false;
    650                 }
    651         }
    652        
    653         cons_damage(active_console);
    654        
    655         /* Receive kernel notifications */
    656         async_set_interrupt_received(interrupt_received);
    657         rc = event_subscribe(EVENT_KCONSOLE, 0);
    658         if (rc != EOK)
    659                 printf("%s: Failed to register kconsole notifications (%s)\n",
    660                     NAME, str_error(rc));
     645                input_activate(input);
     646        }
    661647       
    662648        return true;
  • uspace/srv/hid/console/console.h

    rce3efa0 r593e023  
    3636#define CONSOLE_CONSOLE_H__
    3737
    38 #define CONSOLE_COUNT   12
    39 #define KERNEL_CONSOLE  11
     38#define CONSOLE_COUNT   11
    4039
    4140#endif
  • uspace/srv/hid/input/input.c

    rce3efa0 r593e023  
    5454#include <io/keycode.h>
    5555#include <loc.h>
     56#include <event.h>
     57#include <str_error.h>
    5658#include "layout.h"
    5759#include "kbd.h"
     
    6264#include "input.h"
    6365
     66bool irc_service = false;
     67async_sess_t *irc_sess = NULL;
     68
    6469#define NUM_LAYOUTS  4
    6570
     
    7176};
    7277
    73 static void kbd_devs_yield(void);
    74 static void kbd_devs_reclaim(void);
    75 
    76 async_sess_t *client_sess = NULL;
     78typedef struct {
     79        /** Link into the list of clients */
     80        link_t link;
     81       
     82        /** Indicate whether the client is active */
     83        bool active;
     84       
     85        /** Client callback session */
     86        async_sess_t *sess;
     87} client_t;
     88
     89/** List of clients */
     90static list_t clients;
     91static client_t *active_client = NULL;
    7792
    7893/** List of keyboard devices */
     
    8297static list_t mouse_devs;
    8398
    84 bool irc_service = false;
    85 async_sess_t *irc_sess = NULL;
    86 
    8799static FIBRIL_MUTEX_INITIALIZE(discovery_lock);
     100
     101static void *client_data_create(void)
     102{
     103        client_t *client = (client_t *) calloc(1, sizeof(client_t));
     104        if (client == NULL)
     105                return NULL;
     106       
     107        link_initialize(&client->link);
     108        client->active = false;
     109        client->sess = NULL;
     110       
     111        list_append(&client->link, &clients);
     112       
     113        return client;
     114}
     115
     116static void client_data_destroy(void *data)
     117{
     118        client_t *client = (client_t *) data;
     119       
     120        list_remove(&client->link);
     121        free(client);
     122}
    88123
    89124void kbd_push_data(kbd_dev_t *kdev, sysarg_t data)
     
    199234        ev.c = layout_parse_ev(kdev->active_layout, &ev);
    200235       
    201         async_exch_t *exch = async_exchange_begin(client_sess);
    202         async_msg_4(exch, INPUT_EVENT_KEY, ev.type, ev.key, ev.mods, ev.c);
    203         async_exchange_end(exch);
    204 }
    205 
    206 /** Mouse pointer has moved. */
     236        list_foreach(clients, link, client_t, client) {
     237                if (client->active) {
     238                        async_exch_t *exch = async_exchange_begin(client->sess);
     239                        async_msg_4(exch, INPUT_EVENT_KEY, ev.type, ev.key, ev.mods, ev.c);
     240                        async_exchange_end(exch);
     241                }
     242        }
     243}
     244
     245/** Mouse pointer has moved (relative mode). */
    207246void mouse_push_event_move(mouse_dev_t *mdev, int dx, int dy, int dz)
    208247{
    209         async_exch_t *exch = async_exchange_begin(client_sess);
    210         if (dx || dy)
    211                 async_msg_2(exch, INPUT_EVENT_MOVE, dx, dy);
    212         if (dz) {
    213                 // TODO: Implement proper wheel support
    214                 keycode_t code = dz > 0 ? KC_UP : KC_DOWN;
    215                 for (int i = 0; i < 3; ++i) {
    216                         async_msg_4(exch, INPUT_EVENT_KEY, KEY_PRESS, code, 0, 0);
    217                 }
    218                 async_msg_4(exch, INPUT_EVENT_KEY, KEY_RELEASE, code, 0, 0);
    219         }
    220         async_exchange_end(exch);
    221 }
    222 
    223 /** Mouse pointer has moved in absolute mode. */
     248        list_foreach(clients, link, client_t, client) {
     249                if (client->active) {
     250                        async_exch_t *exch = async_exchange_begin(client->sess);
     251                       
     252                        if ((dx) || (dy))
     253                                async_msg_2(exch, INPUT_EVENT_MOVE, dx, dy);
     254                       
     255                        if (dz) {
     256                                // TODO: Implement proper wheel support
     257                                keycode_t code = dz > 0 ? KC_UP : KC_DOWN;
     258                               
     259                                for (unsigned int i = 0; i < 3; i++)
     260                                        async_msg_4(exch, INPUT_EVENT_KEY, KEY_PRESS, code, 0, 0);
     261                               
     262                                async_msg_4(exch, INPUT_EVENT_KEY, KEY_RELEASE, code, 0, 0);
     263                        }
     264                       
     265                        async_exchange_end(exch);
     266                }
     267        }
     268}
     269
     270/** Mouse pointer has moved (absolute mode). */
    224271void mouse_push_event_abs_move(mouse_dev_t *mdev, unsigned int x, unsigned int y,
    225272    unsigned int max_x, unsigned int max_y)
    226273{
    227         if (max_x && max_y) {
    228                 async_exch_t *exch = async_exchange_begin(client_sess);
    229                 async_msg_4(exch, INPUT_EVENT_ABS_MOVE, x, y, max_x, max_y);
    230                 async_exchange_end(exch);
     274        list_foreach(clients, link, client_t, client) {
     275                if (client->active) {
     276                        if ((max_x) && (max_y)) {
     277                                async_exch_t *exch = async_exchange_begin(client->sess);
     278                                async_msg_4(exch, INPUT_EVENT_ABS_MOVE, x, y, max_x, max_y);
     279                                async_exchange_end(exch);
     280                        }
     281                }
    231282        }
    232283}
     
    235286void mouse_push_event_button(mouse_dev_t *mdev, int bnum, int press)
    236287{
    237         async_exch_t *exch = async_exchange_begin(client_sess);
    238         async_msg_2(exch, INPUT_EVENT_BUTTON, bnum, press);
    239         async_exchange_end(exch);
    240 }
    241 
     288        list_foreach(clients, link, client_t, client) {
     289                if (client->active) {
     290                        async_exch_t *exch = async_exchange_begin(client->sess);
     291                        async_msg_2(exch, INPUT_EVENT_BUTTON, bnum, press);
     292                        async_exchange_end(exch);
     293                }
     294        }
     295}
     296
     297/** Arbitrate client actiovation */
     298static void client_arbitration(client_t *req)
     299{
     300        /* Mutual exclusion of active clients */
     301        list_foreach(clients, link, client_t, client)
     302                client->active = (client == req);
     303       
     304        /* Notify clients about the arbitration */
     305        list_foreach(clients, link, client_t, client) {
     306                async_exch_t *exch = async_exchange_begin(client->sess);
     307                async_msg_0(exch, client->active ?
     308                    INPUT_EVENT_ACTIVE : INPUT_EVENT_DEACTIVE);
     309                async_exchange_end(exch);
     310        }
     311}
     312
     313/** New client connection */
    242314static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    243315{
     316        client_t *client = (client_t *) async_get_client_data();
     317        if (client == NULL) {
     318                async_answer_0(iid, ENOMEM);
     319                return;
     320        }
     321       
    244322        async_answer_0(iid, EOK);
    245323       
     
    249327               
    250328                if (!IPC_GET_IMETHOD(call)) {
    251                         if (client_sess != NULL) {
    252                                 async_hangup(client_sess);
    253                                 client_sess = NULL;
     329                        if (client->sess != NULL) {
     330                                async_hangup(client->sess);
     331                                client->sess = NULL;
    254332                        }
    255333                       
     
    261339                    async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
    262340                if (sess != NULL) {
    263                         if (client_sess == NULL) {
    264                                 client_sess = sess;
     341                        if (client->sess == NULL) {
     342                                client->sess = sess;
    265343                                async_answer_0(callid, EOK);
    266344                        } else
     
    268346                } else {
    269347                        switch (IPC_GET_IMETHOD(call)) {
    270                         case INPUT_YIELD:
    271                                 kbd_devs_yield();
    272                                 async_answer_0(callid, EOK);
    273                                 break;
    274                         case INPUT_RECLAIM:
    275                                 kbd_devs_reclaim();
     348                        case INPUT_ACTIVATE:
     349                                active_client = client;
     350                                client_arbitration(client);
    276351                                async_answer_0(callid, EOK);
    277352                                break;
     
    283358}
    284359
     360static void kconsole_event_received(ipc_callid_t callid, ipc_call_t *call)
     361{
     362        if (IPC_GET_ARG1(*call)) {
     363                /* Kernel console activated */
     364                client_arbitration(NULL);
     365        } else {
     366                /* Kernel console deactivated */
     367                client_arbitration(active_client);
     368        }
     369}
     370
    285371static kbd_dev_t *kbd_dev_new(void)
    286372{
     
    292378        }
    293379       
    294         link_initialize(&kdev->kbd_devs);
     380        link_initialize(&kdev->link);
    295381       
    296382        kdev->mods = KM_NUM_LOCK;
     
    310396        }
    311397       
    312         link_initialize(&mdev->mouse_devs);
     398        link_initialize(&mdev->link);
    313399       
    314400        return mdev;
     
    336422        }
    337423       
    338         list_append(&kdev->kbd_devs, &kbd_devs);
     424        list_append(&kdev->link, &kbd_devs);
    339425        return;
    340426       
     
    364450        }
    365451       
    366         list_append(&mdev->mouse_devs, &mouse_devs);
     452        list_append(&mdev->link, &mouse_devs);
    367453        return;
    368454       
     
    373459/** Add new kbdev device.
    374460 *
    375  * @param service_id    Service ID of the keyboard device
     461 * @param service_id Service ID of the keyboard device
    376462 *
    377463 */
     
    397483        }
    398484       
    399         list_append(&kdev->kbd_devs, &kbd_devs);
     485        list_append(&kdev->link, &kbd_devs);
    400486        *kdevp = kdev;
    401487        return EOK;
     
    410496/** Add new mousedev device.
    411497 *
    412  * @param service_id    Service ID of the mouse device
     498 * @param service_id Service ID of the mouse device
    413499 *
    414500 */
     
    434520        }
    435521       
    436         list_append(&mdev->mouse_devs, &mouse_devs);
     522        list_append(&mdev->link, &mouse_devs);
    437523        *mdevp = mdev;
    438524        return EOK;
     
    489575}
    490576
    491 static void kbd_devs_yield(void)
    492 {
    493         /* For each keyboard device */
    494         list_foreach(kbd_devs, kbd_devs, kbd_dev_t, kdev) {
    495                 /* Yield port */
    496                 if (kdev->port_ops != NULL)
    497                         (*kdev->port_ops->yield)();
    498         }
    499 }
    500 
    501 static void kbd_devs_reclaim(void)
    502 {
    503         /* For each keyboard device */
    504         list_foreach(kbd_devs, kbd_devs, kbd_dev_t, kdev) {
    505                 /* Reclaim port */
    506                 if (kdev->port_ops != NULL)
    507                         (*kdev->port_ops->reclaim)();
    508         }
    509 }
    510 
    511577static int dev_check_new_kbdevs(void)
    512578{
     
    537603               
    538604                /* Determine whether we already know this device. */
    539                 list_foreach(kbd_devs, kbd_devs, kbd_dev_t, kdev) {
     605                list_foreach(kbd_devs, link, kbd_dev_t, kdev) {
    540606                        if (kdev->svc_id == svcs[i]) {
    541607                                already_known = true;
     
    588654               
    589655                /* Determine whether we already know this device. */
    590                 list_foreach(mouse_devs, mouse_devs, mouse_dev_t, mdev) {
     656                list_foreach(mouse_devs, link, mouse_dev_t, mdev) {
    591657                        if (mdev->svc_id == svcs[i]) {
    592658                                already_known = true;
     
    668734        sysarg_t obio;
    669735       
     736        list_initialize(&clients);
    670737        list_initialize(&kbd_devs);
    671738        list_initialize(&mouse_devs);
     
    687754       
    688755        /* Register driver */
     756        async_set_client_data_constructor(client_data_create);
     757        async_set_client_data_destructor(client_data_destroy);
    689758        async_set_client_connection(client_connection);
    690759       
     
    701770                return rc;
    702771        }
     772       
     773        /* Receive kernel notifications */
     774        async_set_interrupt_received(kconsole_event_received);
     775        rc = event_subscribe(EVENT_KCONSOLE, 0);
     776        if (rc != EOK)
     777                printf("%s: Failed to register kconsole notifications (%s)\n",
     778                    NAME, str_error(rc));
    703779       
    704780        /* Start looking for new input devices */
  • uspace/srv/hid/input/kbd.h

    rce3efa0 r593e023  
    4848typedef struct kbd_dev {
    4949        /** Link to kbd_devs list */
    50         link_t kbd_devs;
     50        link_t link;
    5151
    5252        /** Service ID (only for kbdev devices) */
  • uspace/srv/hid/input/kbd_port.h

    rce3efa0 r593e023  
    4444typedef struct kbd_port_ops {
    4545        int (*init)(struct kbd_dev *);
    46         void (*yield)(void);
    47         void (*reclaim)(void);
    4846        void (*write)(uint8_t);
    4947} kbd_port_ops_t;
  • uspace/srv/hid/input/mouse.h

    rce3efa0 r593e023  
    4646typedef struct mouse_dev {
    4747        /** Link to mouse_devs list */
    48         link_t mouse_devs;
     48        link_t link;
    4949       
    5050        /** Service ID (only for mousedev devices) */
  • uspace/srv/hid/input/mouse_port.h

    rce3efa0 r593e023  
    4444typedef struct mouse_port_ops {
    4545        int (*init)(struct mouse_dev *);
    46         void (*yield)(void);
    47         void (*reclaim)(void);
    4846        void (*write)(uint8_t);
    4947} mouse_port_ops_t;
  • uspace/srv/hid/input/port/adb.c

    rce3efa0 r593e023  
    4949
    5050static int adb_port_init(kbd_dev_t *);
    51 static void adb_port_yield(void);
    52 static void adb_port_reclaim(void);
    53 static void adb_port_write(uint8_t data);
     51static void adb_port_write(uint8_t);
    5452
    5553kbd_port_ops_t adb_port = {
    5654        .init = adb_port_init,
    57         .yield = adb_port_yield,
    58         .reclaim = adb_port_reclaim,
    5955        .write = adb_port_write
    6056};
     
    9591       
    9692        return EOK;
    97 }
    98 
    99 static void adb_port_yield(void)
    100 {
    101 }
    102 
    103 static void adb_port_reclaim(void)
    104 {
    10593}
    10694
  • uspace/srv/hid/input/port/adb_mouse.c

    rce3efa0 r593e023  
    109109}
    110110
    111 static void adb_port_yield(void)
    112 {
    113 }
    114 
    115 static void adb_port_reclaim(void)
    116 {
    117 }
    118 
    119111static void adb_port_write(uint8_t data)
    120112{
     
    123115mouse_port_ops_t adb_mouse_port = {
    124116        .init = adb_port_init,
    125         .yield = adb_port_yield,
    126         .reclaim = adb_port_reclaim,
    127117        .write = adb_port_write
    128118};
  • uspace/srv/hid/input/port/chardev.c

    rce3efa0 r593e023  
    4747
    4848static int chardev_port_init(kbd_dev_t *);
    49 static void chardev_port_yield(void);
    50 static void chardev_port_reclaim(void);
    5149static void chardev_port_write(uint8_t data);
    5250
    5351kbd_port_ops_t chardev_port = {
    5452        .init = chardev_port_init,
    55         .yield = chardev_port_yield,
    56         .reclaim = chardev_port_reclaim,
    5753        .write = chardev_port_write
    5854};
     
    115111}
    116112
    117 static void chardev_port_yield(void)
    118 {
    119 }
    120 
    121 static void chardev_port_reclaim(void)
    122 {
    123 }
    124 
    125113static void chardev_port_write(uint8_t data)
    126114{
  • uspace/srv/hid/input/port/msim.c

    rce3efa0 r593e023  
    4444
    4545static int msim_port_init(kbd_dev_t *);
    46 static void msim_port_yield(void);
    47 static void msim_port_reclaim(void);
    4846static void msim_port_write(uint8_t data);
    4947
    5048kbd_port_ops_t msim_port = {
    5149        .init = msim_port_init,
    52         .yield = msim_port_yield,
    53         .reclaim = msim_port_reclaim,
    5450        .write = msim_port_write
    5551};
     
    104100}
    105101
    106 static void msim_port_yield(void)
    107 {
    108 }
    109 
    110 static void msim_port_reclaim(void)
    111 {
    112 }
    113 
    114102static void msim_port_write(uint8_t data)
    115103{
  • uspace/srv/hid/input/port/niagara.c

    rce3efa0 r593e023  
    4848
    4949static int niagara_port_init(kbd_dev_t *);
    50 static void niagara_port_yield(void);
    51 static void niagara_port_reclaim(void);
    5250static void niagara_port_write(uint8_t data);
    5351
    5452kbd_port_ops_t niagara_port = {
    5553        .init = niagara_port_init,
    56         .yield = niagara_port_yield,
    57         .reclaim = niagara_port_reclaim,
    5854        .write = niagara_port_write
    5955};
     
    7975static input_buffer_t input_buffer = (input_buffer_t) AS_AREA_ANY;
    8076
    81 static volatile bool polling_disabled = false;
    8277static void niagara_thread_impl(void *arg);
    8378
     
    108103       
    109104        return 0;
    110 }
    111 
    112 static void niagara_port_yield(void)
    113 {
    114         polling_disabled = true;
    115 }
    116 
    117 static void niagara_port_reclaim(void)
    118 {
    119         polling_disabled = false;
    120105}
    121106
     
    149134
    150135        while (1) {
    151                 if (polling_disabled == false)
    152                         niagara_key_pressed();
     136                niagara_key_pressed();
    153137                usleep(POLL_INTERVAL);
    154138        }
  • uspace/srv/hid/input/port/ns16550.c

    rce3efa0 r593e023  
    4646
    4747static int ns16550_port_init(kbd_dev_t *);
    48 static void ns16550_port_yield(void);
    49 static void ns16550_port_reclaim(void);
    5048static void ns16550_port_write(uint8_t data);
    5149
    5250kbd_port_ops_t ns16550_port = {
    5351        .init = ns16550_port_init,
    54         .yield = ns16550_port_yield,
    55         .reclaim = ns16550_port_reclaim,
    5652        .write = ns16550_port_write
    5753};
     
    146142}
    147143
    148 static void ns16550_port_yield(void)
    149 {
    150 }
    151 
    152 static void ns16550_port_reclaim(void)
    153 {
    154 }
    155 
    156144static void ns16550_port_write(uint8_t data)
    157145{
  • uspace/srv/hid/input/port/pl050.c

    rce3efa0 r593e023  
    4646
    4747static int pl050_port_init(kbd_dev_t *);
    48 static void pl050_port_yield(void);
    49 static void pl050_port_reclaim(void);
    5048static void pl050_port_write(uint8_t data);
    5149
    5250kbd_port_ops_t pl050_port = {
    5351        .init = pl050_port_init,
    54         .yield = pl050_port_yield,
    55         .reclaim = pl050_port_reclaim,
    5652        .write = pl050_port_write
    5753};
     
    129125}
    130126
    131 static void pl050_port_yield(void)
    132 {
    133 }
    134 
    135 static void pl050_port_reclaim(void)
    136 {
    137 }
    138 
    139127static void pl050_port_write(uint8_t data)
    140128{
  • uspace/srv/hid/input/port/ski.c

    rce3efa0 r593e023  
    4545
    4646static int ski_port_init(kbd_dev_t *);
    47 static void ski_port_yield(void);
    48 static void ski_port_reclaim(void);
    4947static void ski_port_write(uint8_t data);
    5048
    5149kbd_port_ops_t ski_port = {
    5250        .init = ski_port_init,
    53         .yield = ski_port_yield,
    54         .reclaim = ski_port_reclaim,
    5551        .write = ski_port_write
    5652};
     
    6460static void ski_thread_impl(void *arg);
    6561static int32_t ski_getchar(void);
    66 
    67 static volatile bool polling_disabled = false;
    6862
    6963/** Initialize Ski port driver. */
     
    8175
    8276        return 0;
    83 }
    84 
    85 static void ski_port_yield(void)
    86 {
    87         polling_disabled = true;
    88 }
    89 
    90 static void ski_port_reclaim(void)
    91 {
    92         polling_disabled = false;
    9377}
    9478
  • uspace/srv/hid/remcons/remcons.c

    rce3efa0 r593e023  
    226226        telnet_user_t *user = arg;
    227227       
    228         char term[LOC_NAME_MAXLEN];
    229         snprintf(term, LOC_NAME_MAXLEN, "%s/%s", "/loc", user->service_name);
    230        
    231228        task_id_t task;
    232         int rc = task_spawnl(&task, APP_GETTERM, APP_GETTERM, "-w", term, APP_SHELL, NULL);
    233         if (rc != EOK) {
    234                 telnet_user_error(user, "Spawning `%s -w %s %s' failed: %s.",
    235                     APP_GETTERM, term, APP_SHELL, str_error(rc));
     229        int rc = task_spawnl(&task, APP_GETTERM, APP_GETTERM, user->service_name,
     230            "/loc", "--msg", "--", APP_SHELL, NULL);
     231        if (rc != EOK) {
     232                telnet_user_error(user, "Spawning `%s %s /loc --msg -- %s' "
     233                    "failed: %s.", APP_GETTERM, user->service_name, APP_SHELL,
     234                    str_error(rc));
    236235                fibril_mutex_lock(&user->guard);
    237236                user->task_finished = true;
Note: See TracChangeset for help on using the changeset viewer.