Changeset 46b881c in mainline for uspace/srv/hid/console/console.c


Ignore:
Timestamp:
2011-01-29T11:36:41Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0b6931a, 8add9ca5
Parents:
e26a4633 (diff), ffa2c8ef (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.
Message:

IPC/async: strictly isolate the use of low-level IPC methods (ipc_*) and async framework methods (async_*) in user code, do not allow a mixture of both in a single source file

Benefits for future plans

  • The async framework could use different communication style under the hood, but keeping the same high-level API
  • The async framework can be integrated more tightly with sessions without potential problems of intermixing session-aware async methods with session-unaware low-level methods in user code
  • The async_serialize_start()/_end() can be deprecated more easily
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/console/console.c

    re26a4633 r46b881c  
    3434
    3535#include <libc.h>
    36 #include <ipc/ipc.h>
    3736#include <ipc/kbd.h>
    3837#include <io/keycode.h>
     
    117116static void curs_hide_sync(void)
    118117{
    119         ipc_call_sync_1_0(fb_info.phone, FB_CURSOR_VISIBILITY, false);
     118        async_req_1_0(fb_info.phone, FB_CURSOR_VISIBILITY, false);
    120119}
    121120
     
    132131static void screen_yield(void)
    133132{
    134         ipc_call_sync_0_0(fb_info.phone, FB_SCREEN_YIELD);
     133        async_req_0_0(fb_info.phone, FB_SCREEN_YIELD);
    135134}
    136135
    137136static void screen_reclaim(void)
    138137{
    139         ipc_call_sync_0_0(fb_info.phone, FB_SCREEN_RECLAIM);
     138        async_req_0_0(fb_info.phone, FB_SCREEN_RECLAIM);
    140139}
    141140
    142141static void kbd_yield(void)
    143142{
    144         ipc_call_sync_0_0(kbd_phone, KBD_YIELD);
     143        async_req_0_0(kbd_phone, KBD_YIELD);
    145144}
    146145
    147146static void kbd_reclaim(void)
    148147{
    149         ipc_call_sync_0_0(kbd_phone, KBD_RECLAIM);
     148        async_req_0_0(kbd_phone, KBD_RECLAIM);
    150149}
    151150
     
    438437                        retval = ENOENT;
    439438                }
    440                 ipc_answer_0(callid, retval);
     439                async_answer_0(callid, retval);
    441440        }
    442441}
     
    473472                }
    474473
    475                 ipc_answer_0(callid, retval);
     474                async_answer_0(callid, retval);
    476475        }
    477476}
     
    484483       
    485484        if (rc != EOK) {
    486                 ipc_answer_0(rid, rc);
     485                async_answer_0(rid, rc);
    487486                return;
    488487        }
     
    499498       
    500499        gcons_notify_char(cons->index);
    501         ipc_answer_1(rid, EOK, size);
     500        async_answer_1(rid, EOK, size);
    502501       
    503502        free(buf);
     
    509508        size_t size;
    510509        if (!async_data_read_receive(&callid, &size)) {
    511                 ipc_answer_0(callid, EINVAL);
    512                 ipc_answer_0(rid, EINVAL);
     510                async_answer_0(callid, EINVAL);
     511                async_answer_0(rid, EINVAL);
    513512                return;
    514513        }
     
    516515        char *buf = (char *) malloc(size);
    517516        if (buf == NULL) {
    518                 ipc_answer_0(callid, ENOMEM);
    519                 ipc_answer_0(rid, ENOMEM);
     517                async_answer_0(callid, ENOMEM);
     518                async_answer_0(rid, ENOMEM);
    520519                return;
    521520        }
     
    535534        if (pos == size) {
    536535                (void) async_data_read_finalize(callid, buf, size);
    537                 ipc_answer_1(rid, EOK, size);
     536                async_answer_1(rid, EOK, size);
    538537                free(buf);
    539538        } else {
     
    553552recheck:
    554553        if (keybuffer_pop(&cons->keybuffer, &ev)) {
    555                 ipc_answer_4(rid, EOK, ev.type, ev.key, ev.mods, ev.c);
     554                async_answer_4(rid, EOK, ev.type, ev.key, ev.mods, ev.c);
    556555        } else {
    557556                fibril_condvar_wait(&input_cv, &input_mutex);
     
    579578       
    580579        if (cons == NULL) {
    581                 ipc_answer_0(iid, ENOENT);
     580                async_answer_0(iid, ENOENT);
    582581                return;
    583582        }
     
    598597       
    599598        /* Accept the connection */
    600         ipc_answer_0(iid, EOK);
     599        async_answer_0(iid, EOK);
    601600       
    602601        while (true) {
     
    658657                        rc = ccap_fb_to_con(fb_info.color_cap, &arg1);
    659658                        if (rc != EOK) {
    660                                 ipc_answer_0(callid, rc);
     659                                async_answer_0(callid, rc);
    661660                                continue;
    662661                        }
     
    702701                        break;
    703702                }
    704                 ipc_answer_3(callid, EOK, arg1, arg2, arg3);
     703                async_answer_3(callid, EOK, arg1, arg2, arg3);
    705704        }
    706705}
     
    727726       
    728727        /* NB: The callback connection is slotted for removal */
    729         sysarg_t taskhash;
    730         sysarg_t phonehash;
    731         if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, &taskhash,
    732             &phonehash) != 0) {
     728        if (async_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, keyboard_events)
     729            != 0) {
    733730                printf(NAME ": Failed to create callback from input device\n");
    734731                return false;
    735732        }
    736        
    737         async_new_connection(taskhash, phonehash, 0, NULL, keyboard_events);
    738733       
    739734        /* Connect to mouse device */
     
    752747        }
    753748       
    754         if (ipc_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, &taskhash,
    755             &phonehash) != 0) {
     749        if (async_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, mouse_events)
     750            != 0) {
    756751                printf(NAME ": Failed to create callback from mouse device\n");
    757752                mouse_phone = -1;
     
    759754        }
    760755       
    761         async_new_connection(taskhash, phonehash, 0, NULL, mouse_events);
    762756skip_mouse:
    763757       
Note: See TracChangeset for help on using the changeset viewer.