Changeset a40dea3 in mainline for uspace/srv/hid/console/console.c


Ignore:
Timestamp:
2011-06-20T20:04:39Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6a0ff7f4
Parents:
5203e256
Message:

Eliminate devmap_obsolete API.

File:
1 edited

Legend:

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

    r5203e256 ra40dea3  
    5454#include <event.h>
    5555#include <devmap.h>
    56 #include <devmap_obsolete.h>
    5756#include <fcntl.h>
    5857#include <vfs/vfs.h>
     
    6867#define NAMESPACE  "term"
    6968
    70 /** Phone to the input server. */
    71 static int input_phone;
     69/** Session with the input server. */
     70static async_sess_t *input_sess;
    7271
    7372/** Information about framebuffer */
     
    109108static FIBRIL_CONDVAR_INITIALIZE(input_cv);
    110109
     110static FIBRIL_MUTEX_INITIALIZE(big_console_lock);
     111
     112static void console_serialize_start(void)
     113{
     114        fibril_mutex_lock(&big_console_lock);
     115}
     116
     117static void console_serialize_end(void)
     118{
     119        fibril_mutex_unlock(&big_console_lock);
     120}
     121
    111122static void curs_visibility(bool visible)
    112123{
     
    141152static void input_yield(void)
    142153{
    143         async_obsolete_req_0_0(input_phone, INPUT_YIELD);
     154        async_exch_t *exch = async_exchange_begin(input_sess);
     155        if (exch == NULL) {
     156                printf("%s: Failed starting exchange with input device.\n",
     157                    NAME);
     158                return;
     159        }
     160       
     161        async_req_0_0(exch, INPUT_YIELD);
     162        async_exchange_end(exch);
    144163}
    145164
    146165static void input_reclaim(void)
    147166{
    148         async_obsolete_req_0_0(input_phone, INPUT_RECLAIM);
     167        async_exch_t *exch = async_exchange_begin(input_sess);
     168        if (exch == NULL) {
     169                printf("%s: Failed starting exchange with input device.\n",
     170                    NAME);
     171                return;
     172        }
     173       
     174        async_req_0_0(exch, INPUT_RECLAIM);
     175        async_exchange_end(exch);
    149176}
    150177
     
    323350       
    324351        if (cons == kernel_console) {
    325                 async_obsolete_serialize_start();
     352                console_serialize_start();
    326353                curs_hide_sync();
    327354                gcons_in_kernel();
    328355                screen_yield();
    329356                input_yield();
    330                 async_obsolete_serialize_end();
     357                console_serialize_end();
    331358               
    332359                if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) {
     
    338365       
    339366        if (cons != kernel_console) {
    340                 async_obsolete_serialize_start();
     367                console_serialize_start();
    341368               
    342369                if (active_console == kernel_console) {
     
    393420                curs_visibility(cons->scr.is_cursor_visible);
    394421               
    395                 async_obsolete_serialize_end();
     422                console_serialize_end();
    396423        }
    397424}
     
    410437                if (!IPC_GET_IMETHOD(call)) {
    411438                        /* TODO: Handle hangup */
    412                         async_obsolete_hangup(input_phone);
     439                        async_hangup(input_sess);
    413440                        return;
    414441                }
     
    470497        }
    471498       
    472         async_obsolete_serialize_start();
     499        console_serialize_start();
    473500       
    474501        size_t off = 0;
     
    478505        }
    479506       
    480         async_obsolete_serialize_end();
     507        console_serialize_end();
    481508       
    482509        gcons_notify_char(cons->index);
     
    573600        int rc;
    574601       
    575         async_obsolete_serialize_start();
     602        console_serialize_start();
    576603        if (cons->refcount == 0)
    577604                gcons_notify_connect(cons->index);
     
    583610       
    584611        while (true) {
    585                 async_obsolete_serialize_end();
     612                console_serialize_end();
    586613                callid = async_get_call(&call);
    587                 async_obsolete_serialize_start();
     614                console_serialize_start();
    588615               
    589616                arg1 = 0;
     
    595622                        if (cons->refcount == 0)
    596623                                gcons_notify_disconnect(cons->index);
     624                        console_serialize_end();
    597625                        return;
    598626                }
     
    600628                switch (IPC_GET_IMETHOD(call)) {
    601629                case VFS_OUT_READ:
    602                         async_obsolete_serialize_end();
     630                        console_serialize_end();
    603631                        cons_read(cons, callid, &call);
    604                         async_obsolete_serialize_start();
     632                        console_serialize_start();
    605633                        continue;
    606634                case VFS_OUT_WRITE:
    607                         async_obsolete_serialize_end();
     635                        console_serialize_end();
    608636                        cons_write(cons, callid, &call);
    609                         async_obsolete_serialize_start();
     637                        console_serialize_start();
    610638                        continue;
    611639                case VFS_OUT_SYNC:
     
    678706                        break;
    679707                case CONSOLE_GET_EVENT:
    680                         async_obsolete_serialize_end();
     708                        console_serialize_end();
    681709                        cons_get_event(cons, callid, &call);
    682                         async_obsolete_serialize_start();
     710                        console_serialize_start();
    683711                        continue;
    684712                case CONSOLE_KCON_ENABLE:
     
    695723}
    696724
    697 static int connect_input(const char *dev_path)
    698 {
    699         int phone;
     725static async_sess_t *connect_input(const char *dev_path)
     726{
     727        async_sess_t *sess;
     728        async_exch_t *exch;
    700729        devmap_handle_t handle;
    701730       
    702731        int rc = devmap_device_get_handle(dev_path, &handle, 0);
    703732        if (rc == EOK) {
    704                 phone = devmap_obsolete_device_connect(handle, 0);
    705                 if (phone < 0) {
    706                         printf("%s: Failed to connect to input device\n", NAME);
    707                         return phone;
     733                sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);
     734                if (sess == NULL) {
     735                        printf("%s: Failed to connect to input server\n", NAME);
     736                        return NULL;
    708737                }
    709738        } else {
    710                 return rc;
     739                return NULL;
     740        }
     741       
     742        exch = async_exchange_begin(sess);
     743        if (exch == NULL) {
     744                printf("%s: Failed to create callback from input server.\n", NAME);
     745                return NULL;
    711746        }
    712747       
    713748        /* NB: The callback connection is slotted for removal */
    714         rc = async_obsolete_connect_to_me(phone, SERVICE_CONSOLE, 0, 0,
    715             input_events, NULL);
     749        rc = async_connect_to_me(exch, SERVICE_CONSOLE, 0, 0, input_events,
     750            NULL);
     751
     752        async_exchange_end(exch);
    716753
    717754        if (rc != EOK) {
    718                 async_obsolete_hangup(phone);
    719                 printf("%s: Failed to create callback from input device (%s).\n",
     755                async_hangup(sess);
     756                printf("%s: Failed to create callback from input server (%s).\n",
    720757                    NAME, str_error(rc));
    721                 return rc;
    722         }
    723        
    724         return phone;
     758                return NULL;
     759        }
     760       
     761        return sess;
    725762}
    726763
     
    728765{
    729766        /* Connect to input server */
    730         input_phone = connect_input(input_dev);
    731         if (input_phone < 0)
     767        input_sess = connect_input(input_dev);
     768        if (input_sess == NULL)
    732769                return false;
    733770       
     
    800837       
    801838        /* Initialize the screen */
    802         async_obsolete_serialize_start();
     839        console_serialize_start();
    803840        gcons_redraw_console();
    804841        set_style(STYLE_NORMAL);
     
    806843        curs_goto(0, 0);
    807844        curs_visibility(active_console->scr.is_cursor_visible);
    808         async_obsolete_serialize_end();
     845        console_serialize_end();
    809846       
    810847        /* Receive kernel notifications */
Note: See TracChangeset for help on using the changeset viewer.