Ignore:
File:
1 edited

Legend:

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

    rb366a6f4 r854eddd6  
    5454#include <event.h>
    5555#include <devmap.h>
     56#include <devmap_obsolete.h>
    5657#include <fcntl.h>
    5758#include <vfs/vfs.h>
     
    6768#define NAMESPACE  "term"
    6869
    69 /** Session with the input server. */
    70 static async_sess_t *input_sess;
     70/** Phone to the input server. */
     71static int input_phone;
    7172
    7273/** Information about framebuffer */
     
    108109static FIBRIL_CONDVAR_INITIALIZE(input_cv);
    109110
    110 static FIBRIL_MUTEX_INITIALIZE(big_console_lock);
    111 
    112 static void console_serialize_start(void)
    113 {
    114         fibril_mutex_lock(&big_console_lock);
    115 }
    116 
    117 static void console_serialize_end(void)
    118 {
    119         fibril_mutex_unlock(&big_console_lock);
    120 }
    121 
    122111static void curs_visibility(bool visible)
    123112{
     
    152141static void input_yield(void)
    153142{
    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);
     143        async_obsolete_req_0_0(input_phone, INPUT_YIELD);
    163144}
    164145
    165146static void input_reclaim(void)
    166147{
    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);
     148        async_obsolete_req_0_0(input_phone, INPUT_RECLAIM);
    176149}
    177150
     
    350323       
    351324        if (cons == kernel_console) {
    352                 console_serialize_start();
     325                async_obsolete_serialize_start();
    353326                curs_hide_sync();
    354327                gcons_in_kernel();
    355328                screen_yield();
    356329                input_yield();
    357                 console_serialize_end();
    358                
    359                 if (console_kcon()) {
     330                async_obsolete_serialize_end();
     331               
     332                if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) {
    360333                        prev_console = active_console;
    361334                        active_console = kernel_console;
     
    365338       
    366339        if (cons != kernel_console) {
    367                 console_serialize_start();
     340                async_obsolete_serialize_start();
    368341               
    369342                if (active_console == kernel_console) {
     
    420393                curs_visibility(cons->scr.is_cursor_visible);
    421394               
    422                 console_serialize_end();
     395                async_obsolete_serialize_end();
    423396        }
    424397}
     
    437410                if (!IPC_GET_IMETHOD(call)) {
    438411                        /* TODO: Handle hangup */
    439                         async_hangup(input_sess);
     412                        async_obsolete_hangup(input_phone);
    440413                        return;
    441414                }
     
    482455                        retval = ENOENT;
    483456                }
    484 
    485457                async_answer_0(callid, retval);
    486458        }
     
    498470        }
    499471       
    500         console_serialize_start();
     472        async_obsolete_serialize_start();
    501473       
    502474        size_t off = 0;
     
    506478        }
    507479       
    508         console_serialize_end();
     480        async_obsolete_serialize_end();
    509481       
    510482        gcons_notify_char(cons->index);
     
    601573        int rc;
    602574       
    603         console_serialize_start();
     575        async_obsolete_serialize_start();
    604576        if (cons->refcount == 0)
    605577                gcons_notify_connect(cons->index);
     
    611583       
    612584        while (true) {
    613                 console_serialize_end();
     585                async_obsolete_serialize_end();
    614586                callid = async_get_call(&call);
    615                 console_serialize_start();
     587                async_obsolete_serialize_start();
    616588               
    617589                arg1 = 0;
     
    623595                        if (cons->refcount == 0)
    624596                                gcons_notify_disconnect(cons->index);
    625                         console_serialize_end();
    626597                        return;
    627598                }
     
    629600                switch (IPC_GET_IMETHOD(call)) {
    630601                case VFS_OUT_READ:
    631                         console_serialize_end();
     602                        async_obsolete_serialize_end();
    632603                        cons_read(cons, callid, &call);
    633                         console_serialize_start();
     604                        async_obsolete_serialize_start();
    634605                        continue;
    635606                case VFS_OUT_WRITE:
    636                         console_serialize_end();
     607                        async_obsolete_serialize_end();
    637608                        cons_write(cons, callid, &call);
    638                         console_serialize_start();
     609                        async_obsolete_serialize_start();
    639610                        continue;
    640611                case VFS_OUT_SYNC:
     
    707678                        break;
    708679                case CONSOLE_GET_EVENT:
    709                         console_serialize_end();
     680                        async_obsolete_serialize_end();
    710681                        cons_get_event(cons, callid, &call);
    711                         console_serialize_start();
     682                        async_obsolete_serialize_start();
    712683                        continue;
     684                case CONSOLE_KCON_ENABLE:
     685                        change_console(kernel_console);
     686                        break;
    713687                }
    714688                async_answer_3(callid, EOK, arg1, arg2, arg3);
     
    721695}
    722696
    723 static async_sess_t *connect_input(const char *dev_path)
    724 {
    725         async_sess_t *sess;
    726         async_exch_t *exch;
     697static int connect_input(const char *dev_path)
     698{
     699        int phone;
    727700        devmap_handle_t handle;
    728701       
    729702        int rc = devmap_device_get_handle(dev_path, &handle, 0);
    730703        if (rc == EOK) {
    731                 sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);
    732                 if (sess == NULL) {
    733                         printf("%s: Failed to connect to input server\n", NAME);
    734                         return NULL;
     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;
    735708                }
    736709        } else {
    737                 return NULL;
    738         }
    739        
    740         exch = async_exchange_begin(sess);
    741         if (exch == NULL) {
    742                 printf("%s: Failed to create callback from input server.\n", NAME);
    743                 return NULL;
     710                return rc;
    744711        }
    745712       
    746713        /* NB: The callback connection is slotted for removal */
    747         rc = async_connect_to_me(exch, 0, 0, 0, input_events, NULL);
    748 
    749         async_exchange_end(exch);
     714        rc = async_obsolete_connect_to_me(phone, SERVICE_CONSOLE, 0, 0,
     715            input_events, NULL);
    750716
    751717        if (rc != EOK) {
    752                 async_hangup(sess);
    753                 printf("%s: Failed to create callback from input server (%s).\n",
     718                async_obsolete_hangup(phone);
     719                printf("%s: Failed to create callback from input device (%s).\n",
    754720                    NAME, str_error(rc));
    755                 return NULL;
    756         }
    757        
    758         return sess;
     721                return rc;
     722        }
     723       
     724        return phone;
    759725}
    760726
     
    762728{
    763729        /* Connect to input server */
    764         input_sess = connect_input(input_dev);
    765         if (input_sess == NULL)
     730        input_phone = connect_input(input_dev);
     731        if (input_phone < 0)
    766732                return false;
    767733       
     
    830796        }
    831797       
     798        /* Disable kernel output to the console */
     799        __SYSCALL0(SYS_DEBUG_DISABLE_CONSOLE);
     800       
    832801        /* Initialize the screen */
    833         console_serialize_start();
     802        async_obsolete_serialize_start();
    834803        gcons_redraw_console();
    835804        set_style(STYLE_NORMAL);
     
    837806        curs_goto(0, 0);
    838807        curs_visibility(active_console->scr.is_cursor_visible);
    839         console_serialize_end();
     808        async_obsolete_serialize_end();
    840809       
    841810        /* Receive kernel notifications */
Note: See TracChangeset for help on using the changeset viewer.