Ignore:
File:
1 edited

Legend:

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

    r369a5f8 rffa2c8ef  
    3434
    3535#include <libc.h>
    36 #include <ipc/ipc.h>
    3736#include <ipc/kbd.h>
    3837#include <io/keycode.h>
     
    4039#include <ipc/fb.h>
    4140#include <ipc/services.h>
     41#include <ipc/ns.h>
    4242#include <errno.h>
    4343#include <ipc/console.h>
     
    7474struct {
    7575        int phone;           /**< Framebuffer phone */
    76         ipcarg_t cols;       /**< Framebuffer columns */
    77         ipcarg_t rows;       /**< Framebuffer rows */
    78         ipcarg_t color_cap;  /**< Color capabilities (FB_CCAP_xxx) */
     76        sysarg_t cols;       /**< Framebuffer columns */
     77        sysarg_t rows;       /**< Framebuffer rows */
     78        sysarg_t color_cap;  /**< Color capabilities (FB_CCAP_xxx) */
    7979} fb_info;
    8080
     
    8282        size_t index;             /**< Console index */
    8383        size_t refcount;          /**< Connection reference count */
    84         dev_handle_t dev_handle;  /**< Device handle */
     84        devmap_handle_t devmap_handle;  /**< Device handle */
    8585        keybuffer_t keybuffer;    /**< Buffer for incoming keys. */
    8686        screenbuffer_t scr;       /**< Screenbuffer for saving screen
     
    101101/** Information on row-span yet unsent to FB driver. */
    102102struct {
    103         ipcarg_t col;  /**< Leftmost column of the span. */
    104         ipcarg_t row;  /**< Row where the span lies. */
    105         ipcarg_t cnt;  /**< Width of the span. */
     103        sysarg_t col;  /**< Leftmost column of the span. */
     104        sysarg_t row;  /**< Row where the span lies. */
     105        sysarg_t cnt;  /**< Width of the span. */
    106106} fb_pending;
    107107
     
    116116static void curs_hide_sync(void)
    117117{
    118         ipc_call_sync_1_0(fb_info.phone, FB_CURSOR_VISIBILITY, false);
    119 }
    120 
    121 static void curs_goto(ipcarg_t x, ipcarg_t y)
     118        async_req_1_0(fb_info.phone, FB_CURSOR_VISIBILITY, false);
     119}
     120
     121static void curs_goto(sysarg_t x, sysarg_t y)
    122122{
    123123        async_msg_2(fb_info.phone, FB_CURSOR_GOTO, x, y);
     
    131131static void screen_yield(void)
    132132{
    133         ipc_call_sync_0_0(fb_info.phone, FB_SCREEN_YIELD);
     133        async_req_0_0(fb_info.phone, FB_SCREEN_YIELD);
    134134}
    135135
    136136static void screen_reclaim(void)
    137137{
    138         ipc_call_sync_0_0(fb_info.phone, FB_SCREEN_RECLAIM);
     138        async_req_0_0(fb_info.phone, FB_SCREEN_RECLAIM);
    139139}
    140140
    141141static void kbd_yield(void)
    142142{
    143         ipc_call_sync_0_0(kbd_phone, KBD_YIELD);
     143        async_req_0_0(kbd_phone, KBD_YIELD);
    144144}
    145145
    146146static void kbd_reclaim(void)
    147147{
    148         ipc_call_sync_0_0(kbd_phone, KBD_RECLAIM);
     148        async_req_0_0(kbd_phone, KBD_RECLAIM);
    149149}
    150150
     
    180180}
    181181
    182 static int ccap_fb_to_con(ipcarg_t ccap_fb, ipcarg_t *ccap_con)
     182static int ccap_fb_to_con(sysarg_t ccap_fb, sysarg_t *ccap_con)
    183183{
    184184        switch (ccap_fb) {
     
    203203
    204204/** Send an area of screenbuffer to the FB driver. */
    205 static void fb_update_area(console_t *cons, ipcarg_t x0, ipcarg_t y0, ipcarg_t width, ipcarg_t height)
     205static void fb_update_area(console_t *cons, sysarg_t x0, sysarg_t y0, sysarg_t width, sysarg_t height)
    206206{
    207207        if (interbuffer) {
    208                 ipcarg_t x;
    209                 ipcarg_t y;
     208                sysarg_t x;
     209                sysarg_t y;
    210210               
    211211                for (y = 0; y < height; y++) {
     
    237237 *
    238238 */
    239 static void cell_mark_changed(ipcarg_t col, ipcarg_t row)
     239static void cell_mark_changed(sysarg_t col, sysarg_t row)
    240240{
    241241        if (fb_pending.cnt != 0) {
     
    255255
    256256/** Print a character to the active VC with buffering. */
    257 static void fb_putchar(wchar_t c, ipcarg_t col, ipcarg_t row)
     257static void fb_putchar(wchar_t c, sysarg_t col, sysarg_t row)
    258258{
    259259        async_msg_3(fb_info.phone, FB_PUTCHAR, c, col, row);
     
    352352                curs_visibility(false);
    353353               
    354                 ipcarg_t x;
    355                 ipcarg_t y;
     354                sysarg_t x;
     355                sysarg_t y;
    356356                int rc = 0;
    357357               
     
    408408                console_event_t ev;
    409409               
    410                 switch (IPC_GET_METHOD(call)) {
     410                switch (IPC_GET_IMETHOD(call)) {
    411411                case IPC_M_PHONE_HUNGUP:
    412412                        /* TODO: Handle hangup */
     
    437437                        retval = ENOENT;
    438438                }
    439                 ipc_answer_0(callid, retval);
     439                async_answer_0(callid, retval);
    440440        }
    441441}
     
    451451                int retval;
    452452               
    453                 switch (IPC_GET_METHOD(call)) {
     453                switch (IPC_GET_IMETHOD(call)) {
    454454                case IPC_M_PHONE_HUNGUP:
    455455                        /* TODO: Handle hangup */
     
    472472                }
    473473
    474                 ipc_answer_0(callid, retval);
     474                async_answer_0(callid, retval);
    475475        }
    476476}
     
    483483       
    484484        if (rc != EOK) {
    485                 ipc_answer_0(rid, rc);
     485                async_answer_0(rid, rc);
    486486                return;
    487487        }
     
    498498       
    499499        gcons_notify_char(cons->index);
    500         ipc_answer_1(rid, EOK, size);
     500        async_answer_1(rid, EOK, size);
    501501       
    502502        free(buf);
     
    508508        size_t size;
    509509        if (!async_data_read_receive(&callid, &size)) {
    510                 ipc_answer_0(callid, EINVAL);
    511                 ipc_answer_0(rid, EINVAL);
     510                async_answer_0(callid, EINVAL);
     511                async_answer_0(rid, EINVAL);
    512512                return;
    513513        }
     
    515515        char *buf = (char *) malloc(size);
    516516        if (buf == NULL) {
    517                 ipc_answer_0(callid, ENOMEM);
    518                 ipc_answer_0(rid, ENOMEM);
     517                async_answer_0(callid, ENOMEM);
     518                async_answer_0(rid, ENOMEM);
    519519                return;
    520520        }
     
    534534        if (pos == size) {
    535535                (void) async_data_read_finalize(callid, buf, size);
    536                 ipc_answer_1(rid, EOK, size);
     536                async_answer_1(rid, EOK, size);
    537537                free(buf);
    538538        } else {
     
    552552recheck:
    553553        if (keybuffer_pop(&cons->keybuffer, &ev)) {
    554                 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);
    555555        } else {
    556556                fibril_condvar_wait(&input_cv, &input_mutex);
     
    571571                        continue;
    572572               
    573                 if (consoles[i].dev_handle == (dev_handle_t) IPC_GET_ARG1(*icall)) {
     573                if (consoles[i].devmap_handle == (devmap_handle_t) IPC_GET_ARG1(*icall)) {
    574574                        cons = &consoles[i];
    575575                        break;
     
    578578       
    579579        if (cons == NULL) {
    580                 ipc_answer_0(iid, ENOENT);
     580                async_answer_0(iid, ENOENT);
    581581                return;
    582582        }
     
    584584        ipc_callid_t callid;
    585585        ipc_call_t call;
    586         ipcarg_t arg1;
    587         ipcarg_t arg2;
    588         ipcarg_t arg3;
     586        sysarg_t arg1;
     587        sysarg_t arg2;
     588        sysarg_t arg3;
    589589       
    590590        int rc;
     
    597597       
    598598        /* Accept the connection */
    599         ipc_answer_0(iid, EOK);
     599        async_answer_0(iid, EOK);
    600600       
    601601        while (true) {
     
    608608                arg3 = 0;
    609609               
    610                 switch (IPC_GET_METHOD(call)) {
     610                switch (IPC_GET_IMETHOD(call)) {
    611611                case IPC_M_PHONE_HUNGUP:
    612612                        cons->refcount--;
     
    657657                        rc = ccap_fb_to_con(fb_info.color_cap, &arg1);
    658658                        if (rc != EOK) {
    659                                 ipc_answer_0(callid, rc);
     659                                async_answer_0(callid, rc);
    660660                                continue;
    661661                        }
     
    701701                        break;
    702702                }
    703                 ipc_answer_3(callid, EOK, arg1, arg2, arg3);
     703                async_answer_3(callid, EOK, arg1, arg2, arg3);
    704704        }
    705705}
     
    726726       
    727727        /* NB: The callback connection is slotted for removal */
    728         ipcarg_t phonehash;
    729         if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) {
     728        if (async_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, keyboard_events)
     729            != 0) {
    730730                printf(NAME ": Failed to create callback from input device\n");
    731731                return false;
    732732        }
    733        
    734         async_new_connection(phonehash, 0, NULL, keyboard_events);
    735733       
    736734        /* Connect to mouse device */
     
    749747        }
    750748       
    751         if (ipc_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) {
     749        if (async_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, mouse_events)
     750            != 0) {
    752751                printf(NAME ": Failed to create callback from mouse device\n");
    753752                mouse_phone = -1;
     
    755754        }
    756755       
    757         async_new_connection(phonehash, 0, NULL, mouse_events);
    758756skip_mouse:
    759757       
    760758        /* Connect to framebuffer driver */
    761         fb_info.phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VIDEO, 0, 0);
     759        fb_info.phone = service_connect_blocking(SERVICE_VIDEO, 0, 0);
    762760        if (fb_info.phone < 0) {
    763761                printf(NAME ": Failed to connect to video service\n");
     
    804802                        if (screenbuffer_init(&consoles[i].scr,
    805803                            fb_info.cols, fb_info.rows) == NULL) {
    806                                 printf(NAME ": Unable to allocate screen buffer %u\n", i);
     804                                printf(NAME ": Unable to allocate screen buffer %zu\n", i);
    807805                                return false;
    808806                        }
     
    813811                       
    814812                        char vc[DEVMAP_NAME_MAXLEN + 1];
    815                         snprintf(vc, DEVMAP_NAME_MAXLEN, "%s/vc%u", NAMESPACE, i);
     813                        snprintf(vc, DEVMAP_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
    816814                       
    817                         if (devmap_device_register(vc, &consoles[i].dev_handle) != EOK) {
    818                                 devmap_hangup_phone(DEVMAP_DRIVER);
     815                        if (devmap_device_register(vc, &consoles[i].devmap_handle) != EOK) {
    819816                                printf(NAME ": Unable to register device %s\n", vc);
    820817                                return false;
     
    836833       
    837834        /* Receive kernel notifications */
     835        async_set_interrupt_received(interrupt_received);
    838836        if (event_subscribe(EVENT_KCONSOLE, 0) != EOK)
    839837                printf(NAME ": Error registering kconsole notifications\n");
    840        
    841         async_set_interrupt_received(interrupt_received);
    842838       
    843839        return true;
Note: See TracChangeset for help on using the changeset viewer.