Changeset a33f0a6 in mainline for uspace/srv/hid


Ignore:
Timestamp:
2011-08-03T17:34:57Z (14 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1940326
Parents:
52a79081 (diff), 3fab770 (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:

Merge from mainline

Location:
uspace/srv/hid
Files:
11 added
5 deleted
13 edited
31 moved

Legend:

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

    r52a79081 ra33f0a6  
    11/*
    22 * Copyright (c) 2006 Josef Cejka
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    3435
    3536#include <libc.h>
    36 #include <ipc/kbd.h>
     37#include <ipc/input.h>
    3738#include <io/keycode.h>
    38 #include <ipc/mouse.h>
    3939#include <ipc/fb.h>
    4040#include <ipc/services.h>
    41 #include <ipc/ns.h>
     41#include <ns.h>
     42#include <ns_obsolete.h>
    4243#include <errno.h>
     44#include <str_error.h>
    4345#include <ipc/console.h>
    4446#include <unistd.h>
    4547#include <async.h>
     48#include <async_obsolete.h>
    4649#include <adt/fifo.h>
    4750#include <sys/mman.h>
     
    6164#include "keybuffer.h"
    6265
    63 
    6466#define NAME       "console"
    6567#define NAMESPACE  "term"
    6668
    67 /** Phone to the keyboard driver. */
    68 static int kbd_phone;
    69 
    70 /** Phone to the mouse driver. */
    71 static int mouse_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{
    113         async_msg_1(fb_info.phone, FB_CURSOR_VISIBILITY, visible);
     124        async_obsolete_msg_1(fb_info.phone, FB_CURSOR_VISIBILITY, visible);
    114125}
    115126
    116127static void curs_hide_sync(void)
    117128{
    118         async_req_1_0(fb_info.phone, FB_CURSOR_VISIBILITY, false);
     129        async_obsolete_req_1_0(fb_info.phone, FB_CURSOR_VISIBILITY, false);
    119130}
    120131
    121132static void curs_goto(sysarg_t x, sysarg_t y)
    122133{
    123         async_msg_2(fb_info.phone, FB_CURSOR_GOTO, x, y);
     134        async_obsolete_msg_2(fb_info.phone, FB_CURSOR_GOTO, x, y);
    124135}
    125136
    126137static void screen_clear(void)
    127138{
    128         async_msg_0(fb_info.phone, FB_CLEAR);
     139        async_obsolete_msg_0(fb_info.phone, FB_CLEAR);
    129140}
    130141
    131142static void screen_yield(void)
    132143{
    133         async_req_0_0(fb_info.phone, FB_SCREEN_YIELD);
     144        async_obsolete_req_0_0(fb_info.phone, FB_SCREEN_YIELD);
    134145}
    135146
    136147static void screen_reclaim(void)
    137148{
    138         async_req_0_0(fb_info.phone, FB_SCREEN_RECLAIM);
    139 }
    140 
    141 static void kbd_yield(void)
    142 {
    143         async_req_0_0(kbd_phone, KBD_YIELD);
    144 }
    145 
    146 static void kbd_reclaim(void)
    147 {
    148         async_req_0_0(kbd_phone, KBD_RECLAIM);
     149        async_obsolete_req_0_0(fb_info.phone, FB_SCREEN_RECLAIM);
     150}
     151
     152static void input_yield(void)
     153{
     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);
     163}
     164
     165static void input_reclaim(void)
     166{
     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
    151178static void set_style(uint8_t style)
    152179{
    153         async_msg_1(fb_info.phone, FB_SET_STYLE, style);
     180        async_obsolete_msg_1(fb_info.phone, FB_SET_STYLE, style);
    154181}
    155182
    156183static void set_color(uint8_t fgcolor, uint8_t bgcolor, uint8_t flags)
    157184{
    158         async_msg_3(fb_info.phone, FB_SET_COLOR, fgcolor, bgcolor, flags);
     185        async_obsolete_msg_3(fb_info.phone, FB_SET_COLOR, fgcolor, bgcolor, flags);
    159186}
    160187
    161188static void set_rgb_color(uint32_t fgcolor, uint32_t bgcolor)
    162189{
    163         async_msg_2(fb_info.phone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
     190        async_obsolete_msg_2(fb_info.phone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
    164191}
    165192
     
    216243                }
    217244               
    218                 async_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA,
     245                async_obsolete_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA,
    219246                    x0, y0, width, height);
    220247        }
     
    257284static void fb_putchar(wchar_t c, sysarg_t col, sysarg_t row)
    258285{
    259         async_msg_3(fb_info.phone, FB_PUTCHAR, c, col, row);
     286        async_obsolete_msg_3(fb_info.phone, FB_PUTCHAR, c, col, row);
    260287}
    261288
     
    306333               
    307334                if (cons == active_console)
    308                         async_msg_1(fb_info.phone, FB_SCROLL, 1);
     335                        async_obsolete_msg_1(fb_info.phone, FB_SCROLL, 1);
    309336        }
    310337       
     
    323350       
    324351        if (cons == kernel_console) {
    325                 async_serialize_start();
     352                console_serialize_start();
    326353                curs_hide_sync();
    327354                gcons_in_kernel();
    328355                screen_yield();
    329                 kbd_yield();
    330                 async_serialize_end();
    331                
    332                 if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) {
     356                input_yield();
     357                console_serialize_end();
     358               
     359                if (console_kcon()) {
    333360                        prev_console = active_console;
    334361                        active_console = kernel_console;
     
    338365       
    339366        if (cons != kernel_console) {
    340                 async_serialize_start();
     367                console_serialize_start();
    341368               
    342369                if (active_console == kernel_console) {
    343370                        screen_reclaim();
    344                         kbd_reclaim();
     371                        input_reclaim();
    345372                        gcons_redraw_console();
    346373                }
     
    365392                       
    366393                        /* This call can preempt, but we are already at the end */
    367                         rc = async_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA,
     394                        rc = async_obsolete_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA,
    368395                            0, 0, cons->scr.size_x,
    369396                            cons->scr.size_y);
     
    393420                curs_visibility(cons->scr.is_cursor_visible);
    394421               
    395                 async_serialize_end();
    396         }
    397 }
    398 
    399 /** Handler for keyboard */
    400 static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall)
     422                console_serialize_end();
     423        }
     424}
     425
     426/** Handler for input events */
     427static void input_events(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    401428{
    402429        /* Ignore parameters, the connection is already opened */
     
    406433               
    407434                int retval;
    408                 console_event_t ev;
     435                kbd_event_t ev;
     436               
     437                if (!IPC_GET_IMETHOD(call)) {
     438                        /* TODO: Handle hangup */
     439                        async_hangup(input_sess);
     440                        return;
     441                }
    409442               
    410443                switch (IPC_GET_IMETHOD(call)) {
    411                 case IPC_M_PHONE_HUNGUP:
    412                         /* TODO: Handle hangup */
    413                         return;
    414                 case KBD_EVENT:
    415                         /* Got event from keyboard driver. */
     444                case INPUT_EVENT_KEY:
     445                        /* Got key press/release event */
    416446                        retval = 0;
    417447                        ev.type = IPC_GET_ARG1(call);
     
    434464                        fibril_mutex_unlock(&input_mutex);
    435465                        break;
    436                 default:
    437                         retval = ENOENT;
    438                 }
    439                 async_answer_0(callid, retval);
    440         }
    441 }
    442 
    443 /** Handler for mouse events */
    444 static void mouse_events(ipc_callid_t iid, ipc_call_t *icall)
    445 {
    446         /* Ignore parameters, the connection is already opened */
    447         while (true) {
    448                 ipc_call_t call;
    449                 ipc_callid_t callid = async_get_call(&call);
    450                
    451                 int retval;
    452                
    453                 switch (IPC_GET_IMETHOD(call)) {
    454                 case IPC_M_PHONE_HUNGUP:
    455                         /* TODO: Handle hangup */
    456                         return;
    457                 case MEVENT_BUTTON:
     466                case INPUT_EVENT_MOVE:
     467                        /* Got pointer move event */
     468                        gcons_mouse_move((int) IPC_GET_ARG1(call),
     469                            (int) IPC_GET_ARG2(call));
     470                        retval = 0;
     471                        break;
     472                case INPUT_EVENT_BUTTON:
     473                        /* Got pointer button press/release event */
    458474                        if (IPC_GET_ARG1(call) == 1) {
    459475                                int newcon = gcons_mouse_btn((bool) IPC_GET_ARG2(call));
     
    463479                        retval = 0;
    464480                        break;
    465                 case MEVENT_MOVE:
    466                         gcons_mouse_move((int) IPC_GET_ARG1(call),
    467                             (int) IPC_GET_ARG2(call));
    468                         retval = 0;
    469                         break;
    470481                default:
    471482                        retval = ENOENT;
     
    487498        }
    488499       
    489         async_serialize_start();
     500        console_serialize_start();
    490501       
    491502        size_t off = 0;
     
    495506        }
    496507       
    497         async_serialize_end();
     508        console_serialize_end();
    498509       
    499510        gcons_notify_char(cons->index);
     
    521532       
    522533        size_t pos = 0;
    523         console_event_t ev;
     534        kbd_event_t ev;
    524535        fibril_mutex_lock(&input_mutex);
    525536       
     
    546557static void cons_get_event(console_t *cons, ipc_callid_t rid, ipc_call_t *request)
    547558{
    548         console_event_t ev;
     559        kbd_event_t ev;
    549560       
    550561        fibril_mutex_lock(&input_mutex);
     
    562573
    563574/** Default thread for new connections */
    564 static void client_connection(ipc_callid_t iid, ipc_call_t *icall)
     575static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    565576{
    566577        console_t *cons = NULL;
     
    590601        int rc;
    591602       
    592         async_serialize_start();
     603        console_serialize_start();
    593604        if (cons->refcount == 0)
    594605                gcons_notify_connect(cons->index);
     
    600611       
    601612        while (true) {
    602                 async_serialize_end();
     613                console_serialize_end();
    603614                callid = async_get_call(&call);
    604                 async_serialize_start();
     615                console_serialize_start();
    605616               
    606617                arg1 = 0;
     
    608619                arg3 = 0;
    609620               
    610                 switch (IPC_GET_IMETHOD(call)) {
    611                 case IPC_M_PHONE_HUNGUP:
     621                if (!IPC_GET_IMETHOD(call)) {
    612622                        cons->refcount--;
    613623                        if (cons->refcount == 0)
    614624                                gcons_notify_disconnect(cons->index);
     625                        console_serialize_end();
    615626                        return;
     627                }
     628               
     629                switch (IPC_GET_IMETHOD(call)) {
    616630                case VFS_OUT_READ:
    617                         async_serialize_end();
     631                        console_serialize_end();
    618632                        cons_read(cons, callid, &call);
    619                         async_serialize_start();
     633                        console_serialize_start();
    620634                        continue;
    621635                case VFS_OUT_WRITE:
    622                         async_serialize_end();
     636                        console_serialize_end();
    623637                        cons_write(cons, callid, &call);
    624                         async_serialize_start();
     638                        console_serialize_start();
    625639                        continue;
    626640                case VFS_OUT_SYNC:
    627641                        fb_pending_flush();
    628642                        if (cons == active_console) {
    629                                 async_req_0_0(fb_info.phone, FB_FLUSH);
     643                                async_obsolete_req_0_0(fb_info.phone, FB_FLUSH);
    630644                                curs_goto(cons->scr.position_x, cons->scr.position_y);
    631645                        }
     
    634648                        /* Send message to fb */
    635649                        if (cons == active_console)
    636                                 async_msg_0(fb_info.phone, FB_CLEAR);
     650                                async_obsolete_msg_0(fb_info.phone, FB_CLEAR);
    637651                       
    638652                        screenbuffer_clear(&cons->scr);
     
    693707                        break;
    694708                case CONSOLE_GET_EVENT:
    695                         async_serialize_end();
     709                        console_serialize_end();
    696710                        cons_get_event(cons, callid, &call);
    697                         async_serialize_start();
     711                        console_serialize_start();
    698712                        continue;
    699                 case CONSOLE_KCON_ENABLE:
    700                         change_console(kernel_console);
    701                         break;
    702713                }
    703714                async_answer_3(callid, EOK, arg1, arg2, arg3);
     
    710721}
    711722
    712 static bool console_init(char *input)
    713 {
    714         /* Connect to input device */
    715         int input_fd = open(input, O_RDONLY);
    716         if (input_fd < 0) {
    717                 printf(NAME ": Failed opening %s\n", input);
     723static async_sess_t *connect_input(const char *dev_path)
     724{
     725        async_sess_t *sess;
     726        async_exch_t *exch;
     727        devmap_handle_t handle;
     728       
     729        int rc = devmap_device_get_handle(dev_path, &handle, 0);
     730        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;
     735                }
     736        } 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;
     744        }
     745       
     746        /* 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);
     750
     751        if (rc != EOK) {
     752                async_hangup(sess);
     753                printf("%s: Failed to create callback from input server (%s).\n",
     754                    NAME, str_error(rc));
     755                return NULL;
     756        }
     757       
     758        return sess;
     759}
     760
     761static bool console_srv_init(char *input_dev)
     762{
     763        /* Connect to input server */
     764        input_sess = connect_input(input_dev);
     765        if (input_sess == NULL)
    718766                return false;
    719         }
    720        
    721         kbd_phone = fd_phone(input_fd);
    722         if (kbd_phone < 0) {
    723                 printf(NAME ": Failed to connect to input device\n");
     767       
     768        /* Connect to framebuffer driver */
     769        fb_info.phone = service_obsolete_connect_blocking(SERVICE_VIDEO, 0, 0);
     770        if (fb_info.phone < 0) {
     771                printf("%s: Failed to connect to video service\n", NAME);
    724772                return false;
    725         }
    726        
    727         /* NB: The callback connection is slotted for removal */
    728         if (async_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, keyboard_events)
    729             != 0) {
    730                 printf(NAME ": Failed to create callback from input device\n");
    731                 return false;
    732         }
    733        
    734         /* Connect to mouse device */
    735         mouse_phone = -1;
    736         int mouse_fd = open("/dev/hid_in/mouse", O_RDONLY);
    737        
    738         if (mouse_fd < 0) {
    739                 printf(NAME ": Notice - failed opening %s\n", "/dev/hid_in/mouse");
    740                 goto skip_mouse;
    741         }
    742        
    743         mouse_phone = fd_phone(mouse_fd);
    744         if (mouse_phone < 0) {
    745                 printf(NAME ": Failed to connect to mouse device\n");
    746                 goto skip_mouse;
    747         }
    748        
    749         if (async_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, mouse_events)
    750             != 0) {
    751                 printf(NAME ": Failed to create callback from mouse device\n");
    752                 mouse_phone = -1;
    753                 goto skip_mouse;
    754         }
    755        
    756 skip_mouse:
    757        
    758         /* Connect to framebuffer driver */
    759         fb_info.phone = service_connect_blocking(SERVICE_VIDEO, 0, 0);
    760         if (fb_info.phone < 0) {
    761                 printf(NAME ": Failed to connect to video service\n");
    762                 return -1;
    763773        }
    764774       
     
    766776        int rc = devmap_driver_register(NAME, client_connection);
    767777        if (rc < 0) {
    768                 printf(NAME ": Unable to register driver (%d)\n", rc);
     778                printf("%s: Unable to register driver (%d)\n", NAME, rc);
    769779                return false;
    770780        }
     
    774784       
    775785        /* Synchronize, the gcons could put something in queue */
    776         async_req_0_0(fb_info.phone, FB_FLUSH);
    777         async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.cols, &fb_info.rows);
    778         async_req_0_1(fb_info.phone, FB_GET_COLOR_CAP, &fb_info.color_cap);
     786        async_obsolete_req_0_0(fb_info.phone, FB_FLUSH);
     787        async_obsolete_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.cols, &fb_info.rows);
     788        async_obsolete_req_0_1(fb_info.phone, FB_GET_COLOR_CAP, &fb_info.color_cap);
    779789       
    780790        /* Set up shared memory buffer. */
     
    787797       
    788798        if (interbuffer) {
    789                 if (async_share_out_start(fb_info.phone, interbuffer,
     799                if (async_obsolete_share_out_start(fb_info.phone, interbuffer,
    790800                    AS_AREA_READ) != EOK) {
    791801                        as_area_destroy(interbuffer);
     
    802812                        if (screenbuffer_init(&consoles[i].scr,
    803813                            fb_info.cols, fb_info.rows) == NULL) {
    804                                 printf(NAME ": Unable to allocate screen buffer %zu\n", i);
     814                                printf("%s: Unable to allocate screen buffer %zu\n", NAME, i);
    805815                                return false;
    806816                        }
     
    814824                       
    815825                        if (devmap_device_register(vc, &consoles[i].devmap_handle) != EOK) {
    816                                 printf(NAME ": Unable to register device %s\n", vc);
     826                                printf("%s: Unable to register device %s\n", NAME, vc);
    817827                                return false;
    818828                        }
     
    820830        }
    821831       
    822         /* Disable kernel output to the console */
    823         __SYSCALL0(SYS_DEBUG_DISABLE_CONSOLE);
    824        
    825832        /* Initialize the screen */
    826         async_serialize_start();
     833        console_serialize_start();
    827834        gcons_redraw_console();
    828835        set_style(STYLE_NORMAL);
     
    830837        curs_goto(0, 0);
    831838        curs_visibility(active_console->scr.is_cursor_visible);
    832         async_serialize_end();
     839        console_serialize_end();
    833840       
    834841        /* Receive kernel notifications */
    835842        async_set_interrupt_received(interrupt_received);
    836843        if (event_subscribe(EVENT_KCONSOLE, 0) != EOK)
    837                 printf(NAME ": Error registering kconsole notifications\n");
     844                printf("%s: Error registering kconsole notifications\n", NAME);
    838845       
    839846        return true;
     
    842849static void usage(void)
    843850{
    844         printf("Usage: console <input>\n");
     851        printf("Usage: console <input_dev>\n");
    845852}
    846853
     
    854861        printf(NAME ": HelenOS Console service\n");
    855862       
    856         if (!console_init(argv[1]))
     863        if (!console_srv_init(argv[1]))
    857864                return -1;
    858865       
  • uspace/srv/hid/console/gcons.c

    r52a79081 ra33f0a6  
    3535#include <ipc/fb.h>
    3636#include <async.h>
     37#include <async_obsolete.h>
    3738#include <stdio.h>
    3839#include <sys/mman.h>
     
    115116static void vp_switch(int vp)
    116117{
    117         async_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp);
     118        async_obsolete_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp);
    118119}
    119120
     
    121122static int vp_create(sysarg_t x, sysarg_t y, sysarg_t width, sysarg_t height)
    122123{
    123         return async_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y,
     124        return async_obsolete_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y,
    124125            (width << 16) | height);
    125126}
     
    127128static void clear(void)
    128129{
    129         async_msg_0(fbphone, FB_CLEAR);
     130        async_obsolete_msg_0(fbphone, FB_CLEAR);
    130131}
    131132
    132133static void set_rgb_color(uint32_t fgcolor, uint32_t bgcolor)
    133134{
    134         async_msg_2(fbphone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
     135        async_obsolete_msg_2(fbphone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
    135136}
    136137
     
    138139static void tran_putch(wchar_t ch, sysarg_t col, sysarg_t row)
    139140{
    140         async_msg_3(fbphone, FB_PUTCHAR, ch, col, row);
     141        async_obsolete_msg_3(fbphone, FB_PUTCHAR, ch, col, row);
    141142}
    142143
     
    149150       
    150151        if (ic_pixmaps[state] != -1)
    151                 async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[index],
     152                async_obsolete_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[index],
    152153                    ic_pixmaps[state]);
    153154       
     
    167168void gcons_change_console(size_t index)
    168169{
    169         if (!use_gcons)
    170                 return;
     170        if (!use_gcons) {
     171                active_console = index;
     172                return;
     173        }
    171174       
    172175        if (active_console == KERNEL_CONSOLE) {
     
    177180               
    178181                if (animation != -1)
    179                         async_msg_1(fbphone, FB_ANIM_START, animation);
     182                        async_obsolete_msg_1(fbphone, FB_ANIM_START, animation);
    180183        } else {
    181184                if (console_state[active_console] == CONS_DISCONNECTED_SEL)
     
    258261{
    259262        if (animation != -1)
    260                 async_msg_1(fbphone, FB_ANIM_STOP, animation);
     263                async_obsolete_msg_1(fbphone, FB_ANIM_STOP, animation);
    261264       
    262265        active_console = KERNEL_CONSOLE;
     
    294297       
    295298        if (active_console != KERNEL_CONSOLE)
    296                 async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y);
     299                async_obsolete_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y);
    297300}
    298301
     
    374377       
    375378        /* Send area */
    376         int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
     379        int rc = async_obsolete_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
    377380        if (rc)
    378381                goto exit;
    379382       
    380         rc = async_share_out_start(fbphone, shm, PROTO_READ);
     383        rc = async_obsolete_share_out_start(fbphone, shm, PROTO_READ);
    381384        if (rc)
    382385                goto drop;
    383386       
    384387        /* Draw logo */
    385         async_msg_2(fbphone, FB_DRAW_PPM, x, y);
     388        async_obsolete_msg_2(fbphone, FB_DRAW_PPM, x, y);
    386389       
    387390drop:
    388391        /* Drop area */
    389         async_msg_0(fbphone, FB_DROP_SHM);
     392        async_obsolete_msg_0(fbphone, FB_DROP_SHM);
    390393       
    391394exit:
     
    436439       
    437440        /* Send area */
    438         int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
     441        int rc = async_obsolete_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
    439442        if (rc)
    440443                goto exit;
    441444       
    442         rc = async_share_out_start(fbphone, shm, PROTO_READ);
     445        rc = async_obsolete_share_out_start(fbphone, shm, PROTO_READ);
    443446        if (rc)
    444447                goto drop;
    445448       
    446449        /* Obtain pixmap */
    447         rc = async_req_0_0(fbphone, FB_SHM2PIXMAP);
     450        rc = async_obsolete_req_0_0(fbphone, FB_SHM2PIXMAP);
    448451        if (rc < 0)
    449452                goto drop;
     
    453456drop:
    454457        /* Drop area */
    455         async_msg_0(fbphone, FB_DROP_SHM);
     458        async_obsolete_msg_0(fbphone, FB_DROP_SHM);
    456459       
    457460exit:
     
    464467static void make_anim(void)
    465468{
    466         int an = async_req_1_0(fbphone, FB_ANIM_CREATE,
     469        int an = async_obsolete_req_1_0(fbphone, FB_ANIM_CREATE,
    467470            cstatus_vp[KERNEL_CONSOLE]);
    468471        if (an < 0)
     
    471474        int pm = make_pixmap(_binary_gfx_anim_1_ppm_start,
    472475            (size_t) &_binary_gfx_anim_1_ppm_size);
    473         async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
     476        async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    474477       
    475478        pm = make_pixmap(_binary_gfx_anim_2_ppm_start,
    476479            (size_t) &_binary_gfx_anim_2_ppm_size);
    477         async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
     480        async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    478481       
    479482        pm = make_pixmap(_binary_gfx_anim_3_ppm_start,
    480483            (size_t) &_binary_gfx_anim_3_ppm_size);
    481         async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
     484        async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    482485       
    483486        pm = make_pixmap(_binary_gfx_anim_4_ppm_start,
    484487            (size_t) &_binary_gfx_anim_4_ppm_size);
    485         async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    486        
    487         async_msg_1(fbphone, FB_ANIM_START, an);
     488        async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
     489       
     490        async_obsolete_msg_1(fbphone, FB_ANIM_START, an);
    488491       
    489492        animation = an;
     
    495498        fbphone = phone;
    496499       
    497         int rc = async_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres);
     500        int rc = async_obsolete_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres);
    498501        if (rc)
    499502                return;
  • uspace/srv/hid/console/keybuffer.c

    r52a79081 ra33f0a6  
    9090 *
    9191 */
    92 void keybuffer_push(keybuffer_t *keybuffer, const console_event_t *ev)
     92void keybuffer_push(keybuffer_t *keybuffer, const kbd_event_t *ev)
    9393{
    9494        futex_down(&keybuffer_futex);
     
    110110 *
    111111 */
    112 bool keybuffer_pop(keybuffer_t *keybuffer, console_event_t *edst)
     112bool keybuffer_pop(keybuffer_t *keybuffer, kbd_event_t *edst)
    113113{
    114114        futex_down(&keybuffer_futex);
  • uspace/srv/hid/console/keybuffer.h

    r52a79081 ra33f0a6  
    4646
    4747typedef struct {
    48         console_event_t fifo[KEYBUFFER_SIZE];
     48        kbd_event_t fifo[KEYBUFFER_SIZE];
    4949        size_t head;
    5050        size_t tail;
     
    5656extern size_t keybuffer_available(keybuffer_t *);
    5757extern bool keybuffer_empty(keybuffer_t *);
    58 extern void keybuffer_push(keybuffer_t *, const console_event_t *);
    59 extern bool keybuffer_pop(keybuffer_t *, console_event_t *);
     58extern void keybuffer_push(keybuffer_t *, const kbd_event_t *);
     59extern bool keybuffer_pop(keybuffer_t *, kbd_event_t *);
    6060
    6161#endif
  • uspace/srv/hid/fb/Makefile

    r52a79081 ra33f0a6  
    8484                EXTRA_CFLAGS += -DNIAGARA_ENABLED
    8585        endif
    86        
    87         ifeq ($(MACHINE),serengeti)
    88                 SOURCES += \
    89                         sgcn.c \
    90                         serial_console.c
    91                 EXTRA_CFLAGS += -DSGCN_ENABLED
    92         endif
    9386endif
    9487
  • uspace/srv/hid/fb/ega.c

    r52a79081 ra33f0a6  
    5252#include <io/screenbuffer.h>
    5353#include <sys/types.h>
    54 
    5554#include "ega.h"
    5655#include "main.h"
     56
     57// FIXME: remove this header
     58#include <kernel/ipc/ipc_methods.h>
    5759
    5860#define MAX_SAVED_SCREENS  256
     
    254256}
    255257
    256 static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall)
     258static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall,
     259    void *arg)
    257260{
    258261        size_t intersize = 0;
     
    291294                int retval;
    292295               
    293                 switch (IPC_GET_IMETHOD(call)) {
    294                 case IPC_M_PHONE_HUNGUP:
     296                if (!IPC_GET_IMETHOD(call)) {
    295297                        client_connected = 0;
    296298                        async_answer_0(callid, EOK);
     
    298300                        /* Exit thread */
    299301                        return;
     302                }
     303               
     304                switch (IPC_GET_IMETHOD(call)) {
    300305                case IPC_M_SHARE_OUT:
    301306                        /* We accept one area for data interchange */
  • uspace/srv/hid/fb/fb.c

    r52a79081 ra33f0a6  
    5959#include <byteorder.h>
    6060#include <io/screenbuffer.h>
    61 
    6261#include "font-8x16.h"
    6362#include "fb.h"
    6463#include "main.h"
    6564#include "ppm.h"
    66 
    6765#include "pointer.xbm"
    6866#include "pointer_mask.xbm"
     67
     68// FIXME: remove this header
     69#include <kernel/ipc/ipc_methods.h>
    6970
    7071#define DEFAULT_BGCOLOR  0xf0f0f0
     
    15751576 *
    15761577 */
    1577 static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall)
     1578static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall,
     1579    void *arg)
    15781580{
    15791581        unsigned int vp = 0;
     
    16201622                        continue;
    16211623               
    1622                 switch (IPC_GET_IMETHOD(call)) {
    1623                 case IPC_M_PHONE_HUNGUP:
     1624                if (!IPC_GET_IMETHOD(call)) {
    16241625                        client_connected = false;
    16251626                       
     
    16301631                        /* Exit thread */
    16311632                        return;
     1633                }
    16321634               
     1635                switch (IPC_GET_IMETHOD(call)) {
    16331636                case FB_PUTCHAR:
    16341637                        ch = IPC_GET_ARG1(call);
  • uspace/srv/hid/fb/main.c

    r52a79081 ra33f0a6  
    2828
    2929#include <ipc/services.h>
    30 #include <ipc/ns.h>
     30#include <ns.h>
    3131#include <sysinfo.h>
    3232#include <async.h>
     
    4040#include "msim.h"
    4141#include "ski.h"
    42 #include "sgcn.h"
    4342#include "niagara.h"
    4443#include "main.h"
     
    9291        }
    9392#endif
    94 #ifdef SGCN_ENABLED
    95         if ((!initialized) && (fb_kind == 4)) {
    96                 if (sgcn_init() == 0)
    97                         initialized = true;
    98         }
    99 #endif
    10093#ifdef NIAGARA_ENABLED
    10194        if ((!initialized) && (fb_kind == 5)) {
  • uspace/srv/hid/fb/niagara.c

    r52a79081 ra33f0a6  
    2929 */
    3030
    31 /** @defgroup niagarafb SGCN
     31/** @defgroup niagarafb
    3232 * @brief       userland driver of the Niagara console output
    3333 * @{
  • uspace/srv/hid/fb/niagara.h

    r52a79081 ra33f0a6  
    2727 */
    2828
    29 /** @defgroup sgcnfb SGCN
    30  * @brief       userland driver of the Serengeti console output
     29/** @defgroup niagarafb
     30 * @brief       userland driver of the Niagara console output
    3131 * @{
    3232 */
  • uspace/srv/hid/fb/serial_console.c

    r52a79081 ra33f0a6  
    5252#include "serial_console.h"
    5353
     54// FIXME: remove this header
     55#include <kernel/ipc/ipc_methods.h>
     56
    5457#define MAX_CONTROL 20
    5558
     
    312315 * Main function of the thread serving client connections.
    313316 */
    314 void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall)
     317void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    315318{
    316319        keyfield_t *interbuf = NULL;
     
    344347                int retval;
    345348               
    346                 switch (IPC_GET_IMETHOD(call)) {
    347                 case IPC_M_PHONE_HUNGUP:
     349                if (!IPC_GET_IMETHOD(call)) {
    348350                        client_connected = 0;
    349351                        async_answer_0(callid, EOK);
     
    351353                        /* Exit thread */
    352354                        return;
     355                }
     356               
     357                switch (IPC_GET_IMETHOD(call)) {
    353358                case IPC_M_SHARE_OUT:
    354359                        /* We accept one area for data interchange */
  • uspace/srv/hid/fb/serial_console.h

    r52a79081 ra33f0a6  
    5252extern void serial_set_scroll_region(sysarg_t);
    5353extern void serial_console_init(putc_function_t, sysarg_t, sysarg_t);
    54 extern void serial_client_connection(ipc_callid_t, ipc_call_t *);
     54extern void serial_client_connection(ipc_callid_t, ipc_call_t *, void *arg);
    5555
    5656#endif
  • uspace/srv/hid/input/ctl/apple.c

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2828
    2929/** @addtogroup kbd_ctl
    30  * @ingroup kbd
     30 * @ingroup input
    3131 * @{
    3232 */
    3333/**
    3434 * @file
    35  * @brief       Apple ADB keyboard controller driver.
     35 * @brief Apple ADB keyboard controller driver.
    3636 */
    3737
     
    4040#include <io/keycode.h>
    4141#include <kbd_ctl.h>
     42#include <kbd_port.h>
     43
     44static void apple_ctl_parse(sysarg_t);
     45static int apple_ctl_init(kbd_dev_t *);
     46static void apple_ctl_set_ind(kbd_dev_t *, unsigned int);
     47
     48kbd_ctl_ops_t apple_ctl = {
     49        .parse = apple_ctl_parse,
     50        .init = apple_ctl_init,
     51        .set_ind = apple_ctl_set_ind
     52};
    4253
    4354#define KBD_KEY_RELEASE         0x80
    4455
     56static kbd_dev_t *kbd_dev;
     57
    4558static int scanmap[];
    4659
    47 int kbd_ctl_init(void)
     60static int apple_ctl_init(kbd_dev_t *kdev)
    4861{
     62        kbd_dev = kdev;
    4963        return 0;
    5064}
    5165
    52 void kbd_ctl_parse_scancode(int scancode)
     66static void apple_ctl_parse(sysarg_t scancode)
    5367{
    54         console_ev_type_t type;
     68        kbd_event_type_t type;
    5569        unsigned int key;
    5670
    57         if (scancode < 0 || scancode >= 0x100)
     71        if (scancode >= 0x100)
    5872                return;
    5973
     
    6781        key = scanmap[scancode];
    6882        if (key != 0)
    69                 kbd_push_ev(type, key);
     83                kbd_push_event(kbd_dev, type, key);
    7084}
    7185
    72 void kbd_ctl_set_ind(unsigned mods)
     86static void apple_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
    7387{
    7488        (void) mods;
  • uspace/srv/hid/input/ctl/gxe_fb.c

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2828
    2929/** @addtogroup kbd_ctl
    30  * @ingroup kbd
     30 * @ingroup input
    3131 * @{
    3232 */
     
    4040#include <io/keycode.h>
    4141#include <kbd_ctl.h>
     42#include <kbd_port.h>
    4243#include <gsp.h>
    4344#include <stroke.h>
    4445
     46static void gxe_fb_ctl_parse(sysarg_t);
     47static int gxe_fb_ctl_init(kbd_dev_t *);
     48static void gxe_fb_ctl_set_ind(kbd_dev_t *, unsigned int);
     49
     50kbd_ctl_ops_t gxe_fb_ctl = {
     51        .parse = gxe_fb_ctl_parse,
     52        .init = gxe_fb_ctl_init,
     53        .set_ind = gxe_fb_ctl_set_ind
     54};
     55
     56static kbd_dev_t *kbd_dev;
     57
    4558/** Scancode parser */
    4659static gsp_t sp;
     
    5164#include <stdio.h>
    5265
    53 int seq_defs[] = {
     66static int seq_defs[] = {
    5467        /* Not shifted */
    5568
     
    207220};
    208221
    209 int kbd_ctl_init(void)
     222static int gxe_fb_ctl_init(kbd_dev_t *kdev)
    210223{
     224        kbd_dev = kdev;
    211225        ds = 0;
    212226
     
    215229}
    216230
    217 void kbd_ctl_parse_scancode(int scancode)
     231static void gxe_fb_ctl_parse(sysarg_t scancode)
    218232{
    219233        unsigned mods, key;
     
    221235        ds = gsp_step(&sp, ds, scancode, &mods, &key);
    222236        if (key != 0) {
    223                 stroke_sim(mods, key);
     237                stroke_sim(kbd_dev, mods, key);
    224238        }
    225239}
    226240
    227 void kbd_ctl_set_ind(unsigned mods)
     241static void gxe_fb_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
    228242{
    229243        (void) mods;
  • uspace/srv/hid/input/ctl/pc.c

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2828
    2929/** @addtogroup kbd_ctl
    30  * @ingroup kbd
     30 * @ingroup input
    3131 * @{
    3232 */
     
    4343#include <gsp.h>
    4444
     45static void pc_ctl_parse(sysarg_t);
     46static int pc_ctl_init(kbd_dev_t *);
     47static void pc_ctl_set_ind(kbd_dev_t *, unsigned int);
     48
     49kbd_ctl_ops_t pc_ctl = {
     50        .parse = pc_ctl_parse,
     51        .init = pc_ctl_init,
     52        .set_ind = pc_ctl_set_ind
     53};
     54
    4555enum dec_state {
    4656        ds_s,
     
    6474
    6575static enum dec_state ds;
     76static kbd_dev_t *kbd_dev;
    6677
    6778static int scanmap_simple[] = {
     
    197208};
    198209
    199 int kbd_ctl_init(void)
     210static int pc_ctl_init(kbd_dev_t *kdev)
    200211{
     212        kbd_dev = kdev;
    201213        ds = ds_s;
    202214        return 0;
    203215}
    204216
    205 void kbd_ctl_parse_scancode(int scancode)
     217static void pc_ctl_parse(sysarg_t scancode)
    206218{
    207         console_ev_type_t type;
     219        kbd_event_type_t type;
    208220        unsigned int key;
    209221        int *map;
     
    245257        }
    246258
    247         if ((scancode < 0) || ((size_t) scancode >= map_length))
     259        if ((size_t) scancode >= map_length)
    248260                return;
    249261
    250262        key = map[scancode];
    251263        if (key != 0)
    252                 kbd_push_ev(type, key);
     264                kbd_push_event(kbd_dev, type, key);
    253265}
    254266
    255 void kbd_ctl_set_ind(unsigned mods)
     267static void pc_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
    256268{
    257269        uint8_t b;
     
    265277                b = b | LI_SCROLL;
    266278
    267         kbd_port_write(KBD_CMD_SET_LEDS);
    268         kbd_port_write(b);
     279        (*kbd_dev->port_ops->write)(KBD_CMD_SET_LEDS);
     280        (*kbd_dev->port_ops->write)(b);
    269281}
    270282
  • uspace/srv/hid/input/ctl/stty.c

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2828
    2929/** @addtogroup kbd_ctl
    30  * @ingroup kbd
     30 * @ingroup input
    3131 * @{
    3232 */
    3333/**
    3434 * @file
    35  * @brief       Serial TTY-like keyboard controller driver.
     35 * @brief Serial TTY-like keyboard controller driver.
     36 *
     37 * Keyboard emulation on a serial terminal.
    3638 */
    3739
     
    3941#include <io/keycode.h>
    4042#include <kbd_ctl.h>
     43#include <kbd_port.h>
    4144#include <gsp.h>
    4245#include <stroke.h>
    4346
     47static void stty_ctl_parse(sysarg_t);
     48static int stty_ctl_init(kbd_dev_t *);
     49static void stty_ctl_set_ind(kbd_dev_t *, unsigned int);
     50
     51kbd_ctl_ops_t stty_ctl = {
     52        .parse = stty_ctl_parse,
     53        .init = stty_ctl_init,
     54        .set_ind = stty_ctl_set_ind
     55};
     56
     57static kbd_dev_t *kbd_dev;
     58
    4459/** Scancode parser */
    4560static gsp_t sp;
     
    5065#include <stdio.h>
    5166
    52 int seq_defs[] = {
     67/**
     68 * Sequnece definitions are primarily for Xterm. Additionally we define
     69 * sequences that are unique to Gnome terminal -- most are the same but
     70 * some differ.
     71 */
     72static int seq_defs[] = {
    5373        /* Not shifted */
    5474
     
    6888        0,      KC_MINUS,       0x2d, GSP_END,
    6989        0,      KC_EQUALS,      0x3d, GSP_END,
     90
    7091        0,      KC_BACKSPACE,   0x08, GSP_END,
    7192
     
    203224        0,      KC_RIGHT,       0x1b, 0x5b, 0x43, GSP_END,
    204225
     226        /*
     227         * Sequences specific to Gnome terminal
     228         */
     229        0,      KC_BACKSPACE,   0x7f, GSP_END, /* ASCII DEL */
     230        0,      KC_HOME,        0x1b, 0x4f, 0x48, GSP_END,
     231        0,      KC_END,         0x1b, 0x4f, 0x46, GSP_END,
     232
    205233        0,      0
    206234};
    207235
    208 int kbd_ctl_init(void)
     236static int stty_ctl_init(kbd_dev_t *kdev)
    209237{
     238        kbd_dev = kdev;
    210239        ds = 0;
    211240
     
    214243}
    215244
    216 void kbd_ctl_parse_scancode(int scancode)
     245static void stty_ctl_parse(sysarg_t scancode)
    217246{
    218247        unsigned mods, key;
     
    220249        ds = gsp_step(&sp, ds, scancode, &mods, &key);
    221250        if (key != 0) {
    222                 stroke_sim(mods, key);
     251                stroke_sim(kbd_dev, mods, key);
    223252        }
    224253}
    225254
    226 void kbd_ctl_set_ind(unsigned mods)
     255static void stty_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
    227256{
    228257        (void) mods;
  • uspace/srv/hid/input/ctl/sun.c

    r52a79081 ra33f0a6  
    11/*
    22 * Copyright (c) 2006 Jakub Jermar
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    2829
    2930/** @addtogroup kbd_ctl
    30  * @ingroup kbd
     31 * @ingroup input
    3132 * @{
    3233 */
    3334/**
    3435 * @file
    35  * @brief       Sun keyboard controller driver.
     36 * @brief Sun keyboard controller driver.
    3637 */
    3738
     
    4041#include <io/keycode.h>
    4142#include <kbd_ctl.h>
     43#include <kbd_port.h>
     44
     45static void sun_ctl_parse(sysarg_t);
     46static int sun_ctl_init(kbd_dev_t *);
     47static void sun_ctl_set_ind(kbd_dev_t *, unsigned int);
     48
     49kbd_ctl_ops_t sun_ctl = {
     50        .parse = sun_ctl_parse,
     51        .init = sun_ctl_init,
     52        .set_ind = sun_ctl_set_ind
     53};
     54
     55static kbd_dev_t *kbd_dev;
    4256
    4357#define KBD_KEY_RELEASE         0x80
     
    4660static int scanmap_simple[];
    4761
    48 int kbd_ctl_init(void)
     62static int sun_ctl_init(kbd_dev_t *kdev)
    4963{
     64        kbd_dev = kdev;
    5065        return 0;
    5166}
    5267
    53 void kbd_ctl_parse_scancode(int scancode)
     68static void sun_ctl_parse(sysarg_t scancode)
    5469{
    55         console_ev_type_t type;
     70        kbd_event_type_t type;
    5671        unsigned int key;
    5772
    58         if (scancode < 0 || scancode >= 0x100)
     73        if (scancode >= 0x100)
    5974                return;
    6075
     
    7186        key = scanmap_simple[scancode];
    7287        if (key != 0)
    73                 kbd_push_ev(type, key);
     88                kbd_push_event(kbd_dev, type, key);
    7489}
    7590
    76 void kbd_ctl_set_ind(unsigned mods)
     91static void sun_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
    7792{
    7893        (void) mods;
  • uspace/srv/hid/input/generic/gsp.c

    r52a79081 ra33f0a6  
    2929/**
    3030 * @addtogroup kbdgen generic
    31  * @ingroup  kbd
     31 * @ingroup  input
    3232 * @{
    3333 */
     
    104104                if (key == 0) break;
    105105
    106                 /* Insert one sequence. */             
     106                /* Insert one sequence. */
    107107                rc = gsp_insert_seq(p, dp, mods, key);
    108108                if (rc != 0)
     
    197197
    198198        if (t == NULL) {
    199                 printf("gsp_step: not found\n");
     199                printf("gsp_step: not found, state=%d, input=0x%x\n",
     200                    state, input);
    200201                *mods = 0;
    201202                *key = 0;
     
    205206        *mods = t->out_mods;
    206207        *key = t->out_key;
     208
    207209        return t->new_state;
    208210}
  • uspace/srv/hid/input/generic/stroke.c

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup kbd
     29/** @addtogroup input
    3030 * @{
    3131 */
     
    5252
    5353/** Simulate keystroke using sequences of key presses and releases. */
    54 void stroke_sim(unsigned mod, unsigned key)
     54void stroke_sim(kbd_dev_t *kdev, unsigned mod, unsigned key)
    5555{
    5656        int i;
     
    6060        while (mods_keys[i][0] != 0) {
    6161                if (mod & mods_keys[i][0]) {
    62                         kbd_push_ev(KEY_PRESS, mods_keys[i][1]);
     62                        kbd_push_event(kdev, KEY_PRESS, mods_keys[i][1]);
    6363                }
    6464                ++i;
     
    6767        /* Simulate key press and release. */
    6868        if (key != 0) {
    69                 kbd_push_ev(KEY_PRESS, key);
    70                 kbd_push_ev(KEY_RELEASE, key);
     69                kbd_push_event(kdev, KEY_PRESS, key);
     70                kbd_push_event(kdev, KEY_RELEASE, key);
    7171        }
    7272
     
    7575        while (mods_keys[i][0] != 0) {
    7676                if (mod & mods_keys[i][0]) {
    77                         kbd_push_ev(KEY_RELEASE, mods_keys[i][1]);
     77                        kbd_push_event(kdev, KEY_RELEASE, mods_keys[i][1]);
    7878                }
    7979                ++i;
  • uspace/srv/hid/input/include/gsp.h

    r52a79081 ra33f0a6  
    2727 */
    2828
    29 /** @addtogroup kbdgen generic
     29/** @addtogroup inputgen generic
    3030 * @brief       Generic scancode parser.
    31  * @ingroup  kbd
     31 * @ingroup  input
    3232 * @{
    33  */ 
     33 */
    3434/** @file
    3535 */
  • uspace/srv/hid/input/include/input.h

    r52a79081 ra33f0a6  
    11/*
    22 * Copyright (c) 2006 Josef Cejka
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    2728 */
    2829
    29 /** @addtogroup kbdgen generic
    30  * @brief HelenOS generic uspace keyboard handler.
    31  * @ingroup kbd
     30/** @addtogroup inputgen generic
     31 * @brief HelenOS input server.
     32 * @ingroup input
    3233 * @{
    3334 */
     
    3536 */
    3637
    37 #ifndef KBD_KBD_H_
    38 #define KBD_KBD_H_
     38#ifndef INPUT_H_
     39#define INPUT_H_
    3940
    4041#include <bool.h>
    4142
     43#define NAME       "input"
     44#define NAMESPACE  "hid"
     45
    4246extern bool irc_service;
    4347extern int irc_phone;
    44 
    45 extern void kbd_push_scancode(int);
    46 extern void kbd_push_ev(int, unsigned int);
    4748
    4849#endif
  • uspace/srv/hid/input/include/kbd_ctl.h

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup kbdgen generic
    30  * @brief       HelenOS generic uspace keyboard handler.
    31  * @ingroup  kbd
     29/** @addtogroup inputgen generic
     30 * @brief Keyboard controller driver interface.
     31 * @ingroup input
    3232 * @{
    33  */ 
     33 */
    3434/** @file
    3535 */
     
    3838#define KBD_CTL_H_
    3939
    40 extern void kbd_ctl_parse_scancode(int);
    41 extern int kbd_ctl_init(void);
    42 extern void kbd_ctl_set_ind(unsigned);
     40#include <kbd_port.h>
     41
     42struct kbd_dev;
     43
     44typedef struct kbd_ctl_ops {
     45        void (*parse)(sysarg_t);
     46        int (*init)(struct kbd_dev *);
     47        void (*set_ind)(struct kbd_dev *, unsigned int);
     48} kbd_ctl_ops_t;
     49
     50extern kbd_ctl_ops_t apple_ctl;
     51extern kbd_ctl_ops_t gxe_fb_ctl;
     52extern kbd_ctl_ops_t kbdev_ctl;
     53extern kbd_ctl_ops_t pc_ctl;
     54extern kbd_ctl_ops_t stty_ctl;
     55extern kbd_ctl_ops_t sun_ctl;
    4356
    4457#endif
     
    4659/**
    4760 * @}
    48  */
    49 
     61 */
  • uspace/srv/hid/input/include/mouse_port.h

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mouse
    30  * @brief
     29/** @addtogroup inputgen generic
     30 * @brief Mouse port driver interface.
     31 * @ingroup input
    3132 * @{
    3233 */
     
    3940#include <sys/types.h>
    4041
    41 extern int mouse_port_init(void);
    42 extern void mouse_port_yield(void);
    43 extern void mouse_port_reclaim(void);
    44 extern void mouse_port_write(uint8_t);
     42struct mouse_dev;
     43
     44typedef struct mouse_port_ops {
     45        int (*init)(struct mouse_dev *);
     46        void (*yield)(void);
     47        void (*reclaim)(void);
     48        void (*write)(uint8_t);
     49} mouse_port_ops_t;
     50
     51extern mouse_port_ops_t adb_mouse_port;
     52extern mouse_port_ops_t chardev_mouse_port;
    4553
    4654#endif
     
    4856/**
    4957 * @}
    50  */
    51 
     58 */
  • uspace/srv/hid/input/include/mouse_proto.h

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mouse
    30  * @brief
     29/** @addtogroup inputgen generic
     30 * @brief Mouse protocol driver interface.
     31 * @ingroup input
    3132 * @{
    3233 */
     
    3738#define MOUSE_PROTO_H_
    3839
    39 extern void mouse_proto_parse_byte(int);
    40 extern int mouse_proto_init(void);
     40#include <mouse_port.h>
     41
     42struct mouse_dev;
     43
     44typedef struct mouse_proto_ops {
     45        void (*parse)(sysarg_t);
     46        int (*init)(struct mouse_dev *);
     47} mouse_proto_ops_t;
     48
     49extern mouse_proto_ops_t adb_proto;
     50extern mouse_proto_ops_t ps2_proto;
     51extern mouse_proto_ops_t mousedev_proto;
    4152
    4253#endif
  • uspace/srv/hid/input/include/stroke.h

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup kbdgen generic
     29/** @addtogroup inputgen generic
    3030 * @brief       Generic scancode parser.
    31  * @ingroup  kbd
     31 * @ingroup  input
    3232 * @{
    3333 */
     
    3838#define KBD_STROKE_H_
    3939
    40 extern void stroke_sim(unsigned, unsigned);
     40#include <kbd.h>
     41
     42extern void stroke_sim(kbd_dev_t *, unsigned, unsigned);
    4143
    4244#endif
  • uspace/srv/hid/input/layout/cz.c

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup kbd
     29/** @addtogroup input
    3030 * @brief Czech QWERTZ layout.
    3131 * @{
    3232 */
    3333
    34 #include <kbd.h>
     34#include <errno.h>
     35#include <input.h>
    3536#include <io/console.h>
    3637#include <io/keycode.h>
    3738#include <bool.h>
    3839#include <layout.h>
    39 
    40 static void layout_reset(void);
    41 static wchar_t layout_parse_ev(console_event_t *ev);
     40#include <stdlib.h>
     41
     42static int cz_create(layout_t *);
     43static void cz_destroy(layout_t *);
     44static wchar_t cz_parse_ev(layout_t *, kbd_event_t *ev);
    4245
    4346enum m_state {
     
    4750};
    4851
    49 static enum m_state mstate;
    50 
    51 layout_op_t cz_op = {
    52         layout_reset,
    53         layout_parse_ev
     52typedef struct {
     53        enum m_state mstate;
     54} layout_cz_t;
     55
     56layout_ops_t cz_ops = {
     57        .create = cz_create,
     58        .destroy = cz_destroy,
     59        .parse_ev = cz_parse_ev
    5460};
    5561
     
    273279}
    274280
    275 static wchar_t parse_ms_hacek(console_event_t *ev)
     281static wchar_t parse_ms_hacek(layout_cz_t *cz_state, kbd_event_t *ev)
    276282{
    277283        wchar_t c;
    278284
    279         mstate = ms_start;
     285        cz_state->mstate = ms_start;
    280286
    281287        /* Produce no characters when Ctrl or Alt is pressed. */
     
    291297}
    292298
    293 static wchar_t parse_ms_carka(console_event_t *ev)
     299static wchar_t parse_ms_carka(layout_cz_t *cz_state, kbd_event_t *ev)
    294300{
    295301        wchar_t c;
    296302
    297         mstate = ms_start;
     303        cz_state->mstate = ms_start;
    298304
    299305        /* Produce no characters when Ctrl or Alt is pressed. */
     
    309315}
    310316
    311 static wchar_t parse_ms_start(console_event_t *ev)
     317static wchar_t parse_ms_start(layout_cz_t *cz_state, kbd_event_t *ev)
    312318{
    313319        wchar_t c;
     
    319325        if (ev->key == KC_EQUALS) {
    320326                if ((ev->mods & KM_SHIFT) != 0)
    321                         mstate = ms_hacek;
     327                        cz_state->mstate = ms_hacek;
    322328                else
    323                         mstate = ms_carka;
     329                        cz_state->mstate = ms_carka;
    324330
    325331                return 0;
     
    379385}
    380386
    381 static void layout_reset(void)
    382 {
    383         mstate = ms_start;
    384 }
    385 
    386 static wchar_t layout_parse_ev(console_event_t *ev)
    387 {
     387static int cz_create(layout_t *state)
     388{
     389        layout_cz_t *cz_state;
     390
     391        cz_state = malloc(sizeof(layout_cz_t));
     392        if (cz_state == NULL) {
     393                printf("%s: Out of memory.\n", NAME);
     394                return ENOMEM;
     395        }
     396
     397        cz_state->mstate = ms_start;
     398        state->layout_priv = (void *) cz_state;
     399
     400        return EOK;
     401}
     402
     403static void cz_destroy(layout_t *state)
     404{
     405        free(state->layout_priv);
     406}
     407
     408static wchar_t cz_parse_ev(layout_t *state, kbd_event_t *ev)
     409{
     410        layout_cz_t *cz_state = (layout_cz_t *) state->layout_priv;
     411
    388412        if (ev->type != KEY_PRESS)
    389413                return 0;
     
    392416                return 0;
    393417       
    394         switch (mstate) {
     418        switch (cz_state->mstate) {
    395419        case ms_start:
    396                 return parse_ms_start(ev);
     420                return parse_ms_start(cz_state, ev);
    397421        case ms_hacek:
    398                 return parse_ms_hacek(ev);
     422                return parse_ms_hacek(cz_state, ev);
    399423        case ms_carka:
    400                 return parse_ms_carka(ev);
     424                return parse_ms_carka(cz_state, ev);
    401425        }
    402426       
  • uspace/srv/hid/input/layout/us_dvorak.c

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup kbd
     29/** @addtogroup input
    3030 * @brief US Dvorak Simplified Keyboard layout.
    3131 * @{
    3232 */
    3333
     34#include <errno.h>
    3435#include <kbd.h>
    3536#include <io/console.h>
     
    3738#include <layout.h>
    3839
    39 static void layout_reset(void);
    40 static wchar_t layout_parse_ev(console_event_t *ev);
    41 
    42 layout_op_t us_dvorak_op = {
    43         layout_reset,
    44         layout_parse_ev
     40static int us_dvorak_create(layout_t *);
     41static void us_dvorak_destroy(layout_t *);
     42static wchar_t us_dvorak_parse_ev(layout_t *, kbd_event_t *ev);
     43
     44layout_ops_t us_dvorak_ops = {
     45        .create = us_dvorak_create,
     46        .destroy = us_dvorak_destroy,
     47        .parse_ev = us_dvorak_parse_ev
    4548};
    4649
     
    206209}
    207210
    208 static void layout_reset(void)
    209 {
    210 }
    211 
    212 static wchar_t layout_parse_ev(console_event_t *ev)
     211static int us_dvorak_create(layout_t *state)
     212{
     213        return EOK;
     214}
     215
     216static void us_dvorak_destroy(layout_t *state)
     217{
     218}
     219
     220static wchar_t us_dvorak_parse_ev(layout_t *state, kbd_event_t *ev)
    213221{
    214222        wchar_t c;
  • uspace/srv/hid/input/layout/us_qwerty.c

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup kbd
     29/** @addtogroup input
    3030 * @brief       US QWERTY layout.
    3131 * @{
    32  */
    33 
     32 */
     33
     34#include <errno.h>
    3435#include <kbd.h>
    3536#include <io/console.h>
     
    3738#include <layout.h>
    3839
    39 static void layout_reset(void);
    40 static wchar_t layout_parse_ev(console_event_t *ev);
    41 
    42 layout_op_t us_qwerty_op = {
    43         layout_reset,
    44         layout_parse_ev
     40static int us_qwerty_create(layout_t *);
     41static void us_qwerty_destroy(layout_t *);
     42static wchar_t us_qwerty_parse_ev(layout_t *, kbd_event_t *ev);
     43
     44layout_ops_t us_qwerty_ops = {
     45        .create = us_qwerty_create,
     46        .destroy = us_qwerty_destroy,
     47        .parse_ev = us_qwerty_parse_ev
    4548};
    4649
     
    200203}
    201204
    202 static void layout_reset(void)
    203 {
    204 }
    205 
    206 static wchar_t layout_parse_ev(console_event_t *ev)
     205static int us_qwerty_create(layout_t *state)
     206{
     207        return EOK;
     208}
     209
     210static void us_qwerty_destroy(layout_t *state)
     211{
     212}
     213
     214static wchar_t us_qwerty_parse_ev(layout_t *state, kbd_event_t *ev)
    207215{
    208216        wchar_t c;
  • uspace/srv/hid/input/port/adb.c

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3030 * @ingroup kbd
    3131 * @{
    32  */ 
     32 */
    3333/** @file
    3434 * @brief ADB keyboard port driver.
     
    3737#include <ipc/adb.h>
    3838#include <async.h>
     39#include <input.h>
    3940#include <kbd_port.h>
    4041#include <kbd.h>
     
    4243#include <fcntl.h>
    4344#include <errno.h>
     45#include <devmap.h>
    4446
    45 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall);
     47static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg);
    4648static void adb_kbd_reg0_data(uint16_t data);
    4749
    48 static int dev_phone;
     50static int adb_port_init(kbd_dev_t *);
     51static void adb_port_yield(void);
     52static void adb_port_reclaim(void);
     53static void adb_port_write(uint8_t data);
    4954
    50 #define NAME "kbd"
     55kbd_port_ops_t adb_port = {
     56        .init = adb_port_init,
     57        .yield = adb_port_yield,
     58        .reclaim = adb_port_reclaim,
     59        .write = adb_port_write
     60};
    5161
    52 int kbd_port_init(void)
     62static kbd_dev_t *kbd_dev;
     63static async_sess_t *dev_sess;
     64
     65static int adb_port_init(kbd_dev_t *kdev)
    5366{
    54         const char *input = "/dev/adb/kbd";
    55         int input_fd;
    56 
    57         printf(NAME ": open %s\n", input);
    58 
    59         input_fd = open(input, O_RDONLY);
    60         if (input_fd < 0) {
    61                 printf(NAME ": Failed opening %s (%d)\n", input, input_fd);
    62                 return false;
     67        const char *dev = "adb/kbd";
     68        devmap_handle_t handle;
     69        async_exch_t *exch;
     70        int rc;
     71       
     72        kbd_dev = kdev;
     73       
     74        rc = devmap_device_get_handle(dev, &handle, 0);
     75        if (rc != EOK)
     76                return rc;
     77       
     78        dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);
     79        if (dev_sess == NULL) {
     80                printf("%s: Failed to connect to device\n", NAME);
     81                return ENOENT;
    6382        }
    64 
    65         dev_phone = fd_phone(input_fd);
    66         if (dev_phone < 0) {
    67                 printf(NAME ": Failed to connect to device\n");
    68                 return false;
     83       
     84        exch = async_exchange_begin(dev_sess);
     85        if (exch == NULL) {
     86                printf("%s: Failed starting exchange with device\n", NAME);
     87                async_hangup(dev_sess);
     88                return ENOMEM;
    6989        }
    70 
     90       
    7191        /* NB: The callback connection is slotted for removal */
    72         if (async_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) {
    73                 printf(NAME ": Failed to create callback from device\n");
    74                 return false;
     92        rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL);
     93        async_exchange_end(exch);
     94        if (rc != EOK) {
     95                printf("%s: Failed to create callback from device\n", NAME);
     96                async_hangup(dev_sess);
     97                return rc;
    7598        }
    76 
    77         return 0;
     99       
     100        return EOK;
    78101}
    79102
    80 void kbd_port_yield(void)
     103static void adb_port_yield(void)
    81104{
    82105}
    83106
    84 void kbd_port_reclaim(void)
     107static void adb_port_reclaim(void)
    85108{
    86109}
    87110
    88 void kbd_port_write(uint8_t data)
     111static void adb_port_write(uint8_t data)
    89112{
    90113        /*async_msg_1(dev_phone, CHAR_WRITE_BYTE, data);*/
    91114}
    92115
    93 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall)
     116static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    94117{
    95118        /* Ignore parameters, the connection is already opened */
     
    100123
    101124                int retval;
    102 
    103                 switch (IPC_GET_IMETHOD(call)) {
    104                 case IPC_M_PHONE_HUNGUP:
     125               
     126                if (!IPC_GET_IMETHOD(call)) {
    105127                        /* TODO: Handle hangup */
    106128                        return;
     129                }
     130               
     131                switch (IPC_GET_IMETHOD(call)) {
    107132                case ADB_REG_NOTIF:
    108133                        adb_kbd_reg0_data(IPC_GET_ARG1(call));
     
    117142static void adb_kbd_reg0_data(uint16_t data)
    118143{
    119         uint8_t b0, b1;
    120 
    121         b0 = (data >> 8) & 0xff;
    122         b1 = data & 0xff;
    123 
     144        uint8_t b0 = (data >> 8) & 0xff;
     145        uint8_t b1 = data & 0xff;
     146       
    124147        if (b0 != 0xff)
    125                 kbd_push_scancode(b0);
     148                kbd_push_data(kbd_dev, b0);
     149       
    126150        if (b1 != 0xff)
    127                 kbd_push_scancode(b1);
     151                kbd_push_data(kbd_dev, b1);
    128152}
    129153
  • uspace/srv/hid/input/port/adb_mouse.c

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mouse
     29/** @addtogroup mouse_port
     30 * @ingroup mouse
    3031 * @{
    31  */ 
     32 */
    3233/** @file
    33  * @brief
     34 * @brief ADB mouse port driver.
    3435 */
    3536
    36 #include <ipc/char.h>
     37#include <ipc/adb.h>
    3738#include <async.h>
    38 #include <vfs/vfs.h>
    39 #include <fcntl.h>
     39#include <input.h>
     40#include <mouse_port.h>
     41#include <mouse.h>
    4042#include <errno.h>
     43#include <devmap.h>
    4144
    42 #include <char_mouse.h>
    43 #include <mouse_port.h>
     45static mouse_dev_t *mouse_dev;
     46static async_sess_t *dev_sess;
    4447
    45 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall);
    46 
    47 static int dev_phone;
    48 
    49 #define NAME "char_mouse"
    50 
    51 int mouse_port_init(void)
    52 {
    53         const char *input = "/dev/char/ps2b";
    54         int input_fd;
    55 
    56         printf(NAME ": open %s\n", input);
    57 
    58         input_fd = open(input, O_RDONLY);
    59         if (input_fd < 0) {
    60                 printf(NAME ": Failed opening %s (%d)\n", input, input_fd);
    61                 return false;
    62         }
    63 
    64         dev_phone = fd_phone(input_fd);
    65         if (dev_phone < 0) {
    66                 printf(NAME ": Failed to connect to device\n");
    67                 return false;
    68         }
    69 
    70         /* NB: The callback connection is slotted for removal */
    71         if (async_connect_to_me(dev_phone, 0, 0, 0, chardev_events) != 0) {
    72                 printf(NAME ": Failed to create callback from device\n");
    73                 return false;
    74         }
    75 
    76         return 0;
    77 }
    78 
    79 void mouse_port_yield(void)
    80 {
    81 }
    82 
    83 void mouse_port_reclaim(void)
    84 {
    85 }
    86 
    87 void mouse_port_write(uint8_t data)
    88 {
    89         async_msg_1(dev_phone, CHAR_WRITE_BYTE, data);
    90 }
    91 
    92 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall)
     48static void mouse_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    9349{
    9450        /* Ignore parameters, the connection is already opened */
    9551        while (true) {
    96 
    9752                ipc_call_t call;
    9853                ipc_callid_t callid = async_get_call(&call);
    99 
     54               
    10055                int retval;
    101 
    102                 switch (IPC_GET_IMETHOD(call)) {
    103                 case IPC_M_PHONE_HUNGUP:
     56               
     57                if (!IPC_GET_IMETHOD(call)) {
    10458                        /* TODO: Handle hangup */
    10559                        return;
    106                 case IPC_FIRST_USER_METHOD:
    107                         mouse_handle_byte(IPC_GET_ARG1(call));
     60                }
     61               
     62                switch (IPC_GET_IMETHOD(call)) {
     63                case ADB_REG_NOTIF:
     64                        mouse_push_data(mouse_dev, IPC_GET_ARG1(call));
    10865                        break;
    10966                default:
    11067                        retval = ENOENT;
    11168                }
     69               
    11270                async_answer_0(callid, retval);
    11371        }
    11472}
    11573
     74static int adb_port_init(mouse_dev_t *mdev)
     75{
     76        const char *dev = "adb/mouse";
     77       
     78        mouse_dev = mdev;
     79       
     80        devmap_handle_t handle;
     81        int rc = devmap_device_get_handle(dev, &handle, 0);
     82        if (rc != EOK)
     83                return rc;
     84       
     85        dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);
     86        if (dev_sess == NULL) {
     87                printf("%s: Failed to connect to device\n", NAME);
     88                return ENOENT;
     89        }
     90       
     91        async_exch_t *exch = async_exchange_begin(dev_sess);
     92        if (exch == NULL) {
     93                printf("%s: Failed starting exchange with device\n", NAME);
     94                async_hangup(dev_sess);
     95                return ENOMEM;
     96        }
     97       
     98        /* NB: The callback connection is slotted for removal */
     99        rc = async_connect_to_me(exch, 0, 0, 0, mouse_port_events, NULL);
     100        async_exchange_end(exch);
     101        if (rc != EOK) {
     102                printf("%s: Failed to create callback from device\n", NAME);
     103                async_hangup(dev_sess);
     104                return rc;
     105        }
     106       
     107        return EOK;
     108}
     109
     110static void adb_port_yield(void)
     111{
     112}
     113
     114static void adb_port_reclaim(void)
     115{
     116}
     117
     118static void adb_port_write(uint8_t data)
     119{
     120}
     121
     122mouse_port_ops_t adb_mouse_port = {
     123        .init = adb_port_init,
     124        .yield = adb_port_yield,
     125        .reclaim = adb_port_reclaim,
     126        .write = adb_port_write
     127};
     128
    116129/**
    117130 * @}
  • uspace/srv/hid/input/port/chardev.c

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3030 * @ingroup kbd
    3131 * @{
    32  */ 
     32 */
    3333/** @file
    3434 * @brief Chardev keyboard port driver.
     
    3737#include <ipc/char.h>
    3838#include <async.h>
     39#include <input.h>
    3940#include <kbd_port.h>
    4041#include <kbd.h>
    41 #include <vfs/vfs.h>
    42 #include <sys/stat.h>
    43 #include <fcntl.h>
     42#include <devmap.h>
    4443#include <errno.h>
     44#include <stdio.h>
    4545
    46 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall);
     46static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg);
    4747
    48 static int dev_phone;
     48static int chardev_port_init(kbd_dev_t *);
     49static void chardev_port_yield(void);
     50static void chardev_port_reclaim(void);
     51static void chardev_port_write(uint8_t data);
    4952
    50 #define NAME "kbd"
     53kbd_port_ops_t chardev_port = {
     54        .init = chardev_port_init,
     55        .yield = chardev_port_yield,
     56        .reclaim = chardev_port_reclaim,
     57        .write = chardev_port_write
     58};
     59
     60static kbd_dev_t *kbd_dev;
     61static async_sess_t *dev_sess;
    5162
    5263/** List of devices to try connecting to. */
    5364static const char *in_devs[] = {
    54         "/dev/char/ps2a",
    55         "/dev/char/s3c24ser"
     65        "char/ps2a",
     66        "char/s3c24ser"
    5667};
    5768
    58 static const int num_devs = sizeof(in_devs) / sizeof(in_devs[0]);
     69static const unsigned int num_devs = sizeof(in_devs) / sizeof(in_devs[0]);
    5970
    60 int kbd_port_init(void)
     71static int chardev_port_init(kbd_dev_t *kdev)
    6172{
    62         int input_fd;
    63         int i;
    64 
    65         input_fd = -1;
     73        devmap_handle_t handle;
     74        async_exch_t *exch;
     75        unsigned int i;
     76        int rc;
     77       
     78        kbd_dev = kdev;
     79       
    6680        for (i = 0; i < num_devs; i++) {
    67                 struct stat s;
    68 
    69                 if (stat(in_devs[i], &s) == EOK)
     81                rc = devmap_device_get_handle(in_devs[i], &handle, 0);
     82                if (rc == EOK)
    7083                        break;
    7184        }
    72 
     85       
    7386        if (i >= num_devs) {
    74                 printf(NAME ": Could not find any suitable input device.\n");
     87                printf("%s: Could not find any suitable input device\n", NAME);
    7588                return -1;
    7689        }
    77 
    78         input_fd = open(in_devs[i], O_RDONLY);
    79         if (input_fd < 0) {
    80                 printf(NAME ": failed opening device %s (%d).\n", in_devs[i],
    81                     input_fd);
     90       
     91        dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle,
     92            IPC_FLAG_BLOCKING);
     93        if (dev_sess == NULL) {
     94                printf("%s: Failed connecting to device\n", NAME);
     95                return ENOENT;
     96        }
     97       
     98        exch = async_exchange_begin(dev_sess);
     99        if (exch == NULL) {
     100                printf("%s: Failed starting exchange with device\n", NAME);
     101                async_hangup(dev_sess);
     102                return ENOMEM;
     103        }
     104       
     105        /* NB: The callback connection is slotted for removal */
     106        rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL);
     107        async_exchange_end(exch);
     108       
     109        if (rc != 0) {
     110                printf("%s: Failed to create callback from device\n", NAME);
     111                async_hangup(dev_sess);
    82112                return -1;
    83113        }
    84 
    85         dev_phone = fd_phone(input_fd);
    86         if (dev_phone < 0) {
    87                 printf(NAME ": Failed connecting to device\n");
    88                 return -1;
    89         }
    90 
    91         /* NB: The callback connection is slotted for removal */
    92         if (async_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) {
    93                 printf(NAME ": Failed to create callback from device\n");
    94                 return -1;
    95         }
    96 
     114       
    97115        return 0;
    98116}
    99117
    100 void kbd_port_yield(void)
     118static void chardev_port_yield(void)
    101119{
    102120}
    103121
    104 void kbd_port_reclaim(void)
     122static void chardev_port_reclaim(void)
    105123{
    106124}
    107125
    108 void kbd_port_write(uint8_t data)
     126static void chardev_port_write(uint8_t data)
    109127{
    110         async_msg_1(dev_phone, CHAR_WRITE_BYTE, data);
     128        async_exch_t *exch = async_exchange_begin(dev_sess);
     129        if (exch == NULL) {
     130                printf("%s: Failed starting exchange with device\n", NAME);
     131                return;
     132        }
     133
     134        async_msg_1(exch, CHAR_WRITE_BYTE, data);
     135        async_exchange_end(exch);
    111136}
    112137
    113 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall)
     138static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    114139{
    115140        /* Ignore parameters, the connection is already opened */
     
    118143                ipc_call_t call;
    119144                ipc_callid_t callid = async_get_call(&call);
     145               
     146                if (!IPC_GET_IMETHOD(call)) {
     147                        /* TODO: Handle hangup */
     148                        return;
     149                }
    120150
    121151                int retval;
    122152
    123153                switch (IPC_GET_IMETHOD(call)) {
    124                 case IPC_M_PHONE_HUNGUP:
    125                         /* TODO: Handle hangup */
    126                         return;
    127154                case CHAR_NOTIF_BYTE:
    128                         kbd_push_scancode(IPC_GET_ARG1(call));
     155                        kbd_push_data(kbd_dev, IPC_GET_ARG1(call));
    129156                        break;
    130157                default:
  • uspace/srv/hid/input/port/gxemul.c

    r52a79081 ra33f0a6  
    11/*
    22 * Copyright (c) 2007 Michal Kebrt
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    4243#include <errno.h>
    4344
     45static int gxemul_port_init(kbd_dev_t *);
     46static void gxemul_port_yield(void);
     47static void gxemul_port_reclaim(void);
     48static void gxemul_port_write(uint8_t data);
     49
     50kbd_port_ops_t gxemul_port = {
     51        .init = gxemul_port_init,
     52        .yield = gxemul_port_yield,
     53        .reclaim = gxemul_port_reclaim,
     54        .write = gxemul_port_write
     55};
     56
     57static kbd_dev_t *kbd_dev;
     58
    4459static irq_cmd_t gxemul_cmds[] = {
    4560        {
     
    6176
    6277/** Initializes keyboard handler. */
    63 int kbd_port_init(void)
     78static int gxemul_port_init(kbd_dev_t *kdev)
    6479{
     80        kbd_dev = kdev;
     81       
    6582        sysarg_t addr;
    6683        if (sysinfo_get_value("kbd.address.virtual", &addr) != EOK)
     
    7794}
    7895
    79 void kbd_port_yield(void)
     96static void gxemul_port_yield(void)
    8097{
    8198}
    8299
    83 void kbd_port_reclaim(void)
     100static void gxemul_port_reclaim(void)
    84101{
    85102}
    86103
    87 void kbd_port_write(uint8_t data)
     104static void gxemul_port_write(uint8_t data)
    88105{
    89106        (void) data;
     
    91108
    92109/** Process data sent when a key is pressed.
    93  * 
    94  *  @param keybuffer Buffer of pressed keys.
    95  *  @param call      IPC call.
    96110 *
    97  *  @return Always 1.
     111 * @param keybuffer Buffer of pressed keys.
     112 * @param call      IPC call.
     113 *
    98114 */
    99115static void gxemul_irq_handler(ipc_callid_t iid, ipc_call_t *call)
    100116{
    101         int scan_code = IPC_GET_ARG2(*call);
    102 
    103         kbd_push_scancode(scan_code);
     117        kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
    104118}
    105119
  • uspace/srv/hid/input/port/msim.c

    r52a79081 ra33f0a6  
    11/*
    22 * Copyright (c) 2006 Josef Cejka
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    4243#include <errno.h>
    4344
    44 irq_cmd_t msim_cmds[] = {
     45static int msim_port_init(kbd_dev_t *);
     46static void msim_port_yield(void);
     47static void msim_port_reclaim(void);
     48static void msim_port_write(uint8_t data);
     49
     50kbd_port_ops_t msim_port = {
     51        .init = msim_port_init,
     52        .yield = msim_port_yield,
     53        .reclaim = msim_port_reclaim,
     54        .write = msim_port_write
     55};
     56
     57static kbd_dev_t *kbd_dev;
     58
     59static irq_cmd_t msim_cmds[] = {
    4560        {
    4661                .cmd = CMD_PIO_READ_8,
     
    5166                .cmd = CMD_ACCEPT
    5267        }
    53        
    5468};
    5569
    56 irq_code_t msim_kbd = {
     70static irq_code_t msim_kbd = {
    5771        sizeof(msim_cmds) / sizeof(irq_cmd_t),
    5872        msim_cmds
     
    6175static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call);
    6276
    63 int kbd_port_init(void)
     77static int msim_port_init(kbd_dev_t *kdev)
    6478{
     79        kbd_dev = kdev;
     80
    6581        sysarg_t vaddr;
    6682        if (sysinfo_get_value("kbd.address.virtual", &vaddr) != EOK)
     
    7894}
    7995
    80 void kbd_port_yield(void)
     96static void msim_port_yield(void)
    8197{
    8298}
    8399
    84 void kbd_port_reclaim(void)
     100static void msim_port_reclaim(void)
    85101{
    86102}
    87103
    88 void kbd_port_write(uint8_t data)
     104static void msim_port_write(uint8_t data)
    89105{
    90106        (void) data;
     
    93109static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call)
    94110{
    95         int scan_code = IPC_GET_ARG2(*call);
    96         kbd_push_scancode(scan_code);
     111        kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
    97112}
    98113
    99114/** @}
    100 */
     115 */
  • uspace/srv/hid/input/port/niagara.c

    r52a79081 ra33f0a6  
    11/*
    22 * Copyright (c) 2008 Pavel Rimsky
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    4647#include <errno.h>
    4748
     49static int niagara_port_init(kbd_dev_t *);
     50static void niagara_port_yield(void);
     51static void niagara_port_reclaim(void);
     52static void niagara_port_write(uint8_t data);
     53
     54kbd_port_ops_t niagara_port = {
     55        .init = niagara_port_init,
     56        .yield = niagara_port_yield,
     57        .reclaim = niagara_port_reclaim,
     58        .write = niagara_port_write
     59};
     60
     61static kbd_dev_t *kbd_dev;
     62
    4863#define POLL_INTERVAL  10000
    4964
     
    7085
    7186/* virtual address of the shared buffer */
    72 input_buffer_t input_buffer;
     87static input_buffer_t input_buffer;
    7388
    7489static volatile bool polling_disabled = false;
     
    7994 * Maps the shared buffer and creates the polling thread.
    8095 */
    81 int kbd_port_init(void)
     96static int niagara_port_init(kbd_dev_t *kdev)
    8297{
     98        kbd_dev = kdev;
     99       
    83100        sysarg_t paddr;
    84101        if (sysinfo_get_value("niagara.inbuf.address", &paddr) != EOK)
     
    105122}
    106123
    107 void kbd_port_yield(void)
     124static void niagara_port_yield(void)
    108125{
    109126        polling_disabled = true;
    110127}
    111128
    112 void kbd_port_reclaim(void)
     129static void niagara_port_reclaim(void)
    113130{
    114131        polling_disabled = false;
    115132}
    116133
    117 void kbd_port_write(uint8_t data)
     134static void niagara_port_write(uint8_t data)
    118135{
    119136        (void) data;
     
    131148                c = input_buffer->data[input_buffer->read_ptr];
    132149                input_buffer->read_ptr =
    133                         ((input_buffer->read_ptr) + 1) % INPUT_BUFFER_SIZE;
    134                 kbd_push_scancode(c);
     150                    ((input_buffer->read_ptr) + 1) % INPUT_BUFFER_SIZE;
     151                kbd_push_data(kbd_dev, c);
    135152        }
    136153}
    137154
    138155/**
    139  * Thread to poll SGCN for keypresses.
     156 * Thread to poll Niagara console for keypresses.
    140157 */
    141158static void niagara_thread_impl(void *arg)
  • uspace/srv/hid/input/port/ns16550.c

    r52a79081 ra33f0a6  
    11/*
    22 * Copyright (c) 2006 Josef Cejka
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    3738#include <ipc/irc.h>
    3839#include <async.h>
     40#include <async_obsolete.h>
    3941#include <sysinfo.h>
     42#include <input.h>
    4043#include <kbd.h>
    4144#include <kbd_port.h>
    42 #include <sun.h>
    4345#include <ddi.h>
    4446#include <errno.h>
     47
     48static int ns16550_port_init(kbd_dev_t *);
     49static void ns16550_port_yield(void);
     50static void ns16550_port_reclaim(void);
     51static void ns16550_port_write(uint8_t data);
     52
     53kbd_port_ops_t ns16550_port = {
     54        .init = ns16550_port_init,
     55        .yield = ns16550_port_yield,
     56        .reclaim = ns16550_port_reclaim,
     57        .write = ns16550_port_write
     58};
     59
     60static kbd_dev_t *kbd_dev;
    4561
    4662/* NS16550 registers */
     
    90106
    91107static uintptr_t ns16550_physical;
    92 static uintptr_t ns16550_kernel; 
     108static uintptr_t ns16550_kernel;
    93109
    94 int ns16550_port_init(void)
     110static kbd_dev_t *kbd_dev;
     111
     112static int ns16550_port_init(kbd_dev_t *kdev)
    95113{
    96114        void *vaddr;
    97 
     115       
     116        kbd_dev = kdev;
     117       
     118        sysarg_t ns16550;
     119        if (sysinfo_get_value("kbd.type.ns16550", &ns16550) != EOK)
     120                return -1;
     121        if (!ns16550)
     122                return -1;
     123       
    98124        if (sysinfo_get_value("kbd.address.physical", &ns16550_physical) != EOK)
    99125                return -1;
     
    115141}
    116142
     143static void ns16550_port_yield(void)
     144{
     145}
     146
     147static void ns16550_port_reclaim(void)
     148{
     149}
     150
     151static void ns16550_port_write(uint8_t data)
     152{
     153        (void) data;
     154}
     155
    117156static void ns16550_irq_handler(ipc_callid_t iid, ipc_call_t *call)
    118157{
    119         int scan_code = IPC_GET_ARG2(*call);
    120         kbd_push_scancode(scan_code);
     158        kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
    121159       
    122160        if (irc_service)
    123                 async_msg_1(irc_phone, IRC_CLEAR_INTERRUPT,
     161                async_obsolete_msg_1(irc_phone, IRC_CLEAR_INTERRUPT,
    124162                    IPC_GET_IMETHOD(*call));
    125163}
  • uspace/srv/hid/input/port/pl050.c

    r52a79081 ra33f0a6  
    11/*
    22 * Copyright (c) 2009 Vineeth Pillai
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    4647#include <errno.h>
    4748
     49static int pl050_port_init(kbd_dev_t *);
     50static void pl050_port_yield(void);
     51static void pl050_port_reclaim(void);
     52static void pl050_port_write(uint8_t data);
     53
     54kbd_port_ops_t pl050_port = {
     55        .init = pl050_port_init,
     56        .yield = pl050_port_yield,
     57        .reclaim = pl050_port_reclaim,
     58        .write = pl050_port_write
     59};
     60
     61static kbd_dev_t *kbd_dev;
     62
    4863#define PL050_STAT_RXFULL  (1 << 4)
    4964
     
    8297static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call);
    8398
    84 int kbd_port_init(void)
     99static int pl050_port_init(kbd_dev_t *kdev)
    85100{
     101        kbd_dev = kdev;
     102       
    86103        sysarg_t addr;
    87104        if (sysinfo_get_value("kbd.address.status", &addr) != EOK)
     
    105122}
    106123
    107 void kbd_port_yield(void)
     124static void pl050_port_yield(void)
    108125{
    109126}
    110127
    111 void kbd_port_reclaim(void)
     128static void pl050_port_reclaim(void)
    112129{
    113130}
    114131
    115 void kbd_port_write(uint8_t data)
     132static void pl050_port_write(uint8_t data)
    116133{
    117134        (void) data;
     
    120137static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call)
    121138{
    122         int scan_code = IPC_GET_ARG2(*call);
    123 
    124         kbd_push_scancode(scan_code);
    125         return;
     139        kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
    126140}
    127141
    128142/**
    129143 * @}
    130  */ 
     144 */
  • uspace/srv/hid/input/port/ski.c

    r52a79081 ra33f0a6  
    11/*
    22 * Copyright (c) 2005 Jakub Jermar
    3  * Copyright (c) 2009 Jiri Svoboda
     3 * Copyright (c) 2011 Jiri Svoboda
    44 * All rights reserved.
    55 *
     
    4545#include <bool.h>
    4646
     47static int ski_port_init(kbd_dev_t *);
     48static void ski_port_yield(void);
     49static void ski_port_reclaim(void);
     50static void ski_port_write(uint8_t data);
     51
     52kbd_port_ops_t ski_port = {
     53        .init = ski_port_init,
     54        .yield = ski_port_yield,
     55        .reclaim = ski_port_reclaim,
     56        .write = ski_port_write
     57};
     58
     59static kbd_dev_t *kbd_dev;
     60
    4761#define SKI_GETCHAR             21
    4862
     
    5569
    5670/** Initialize Ski port driver. */
    57 int kbd_port_init(void)
     71static int ski_port_init(kbd_dev_t *kdev)
    5872{
    5973        thread_id_t tid;
    6074        int rc;
     75
     76        kbd_dev = kdev;
    6177
    6278        rc = thread_create(ski_thread_impl, NULL, "kbd_poll", &tid);
     
    6884}
    6985
    70 void kbd_port_yield(void)
     86static void ski_port_yield(void)
    7187{
    7288        polling_disabled = true;
    7389}
    7490
    75 void kbd_port_reclaim(void)
     91static void ski_port_reclaim(void)
    7692{
    7793        polling_disabled = false;
    7894}
    7995
    80 void kbd_port_write(uint8_t data)
     96static void ski_port_write(uint8_t data)
    8197{
    8298        (void) data;
     
    94110                        if (c == 0)
    95111                                break;
    96                         kbd_push_scancode(c);
     112                        kbd_push_data(kbd_dev, c);
    97113                }
    98114
     
    112128        uint64_t ch;
    113129       
     130#ifdef UARCH_ia64
    114131        asm volatile (
    115132                "mov r15 = %1\n"
     
    121138                : "r15", "r8"
    122139        );
    123 
     140#else
     141        ch = 0;
     142#endif
    124143        return (int32_t) ch;
    125144}
  • uspace/srv/hid/input/proto/ps2.c

    r52a79081 ra33f0a6  
    11/*
    2  * Copyright (c) 2006 Ondrej Palkovsky
     2 * Copyright (c) 2011 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mouse
     29/** @addtogroup mouse_proto
     30 * @ingroup input
    3031 * @{
    3132 */
    3233/**
    3334 * @file
    34  * @brief PS/2 mouse protocol driver.
     35 * @brief PS/2 protocol driver.
    3536 */
    3637
    37 #include <stdio.h>
     38#include <mouse.h>
    3839#include <mouse_port.h>
    39 #include <char_mouse.h>
    4040#include <mouse_proto.h>
    41 
    42 #define BUFSIZE 3
    4341
    4442#define PS2_MOUSE_OUT_INIT  0xf4
    4543#define PS2_MOUSE_ACK       0xfa
     44
     45#define BUFSIZE 3
    4646
    4747typedef struct {
     
    4949                unsigned char data[BUFSIZE];
    5050                struct {
    51                         unsigned leftbtn : 1;
    52                         unsigned rightbtn : 1;
    53                         unsigned middlebtn : 1;
    54                         unsigned isone : 1; /* Always one */
    55                         unsigned xsign : 1;
    56                         unsigned ysign : 1;
    57                         unsigned xovfl : 1;
    58                         unsigned yovfl : 1;
     51                        unsigned int leftbtn : 1;
     52                        unsigned int rightbtn : 1;
     53                        unsigned int middlebtn : 1;
     54                        unsigned int isone : 1; /* Always one */
     55                        unsigned int xsign : 1;
     56                        unsigned int ysign : 1;
     57                        unsigned int xovfl : 1;
     58                        unsigned int yovfl : 1;
    5959                        unsigned char x;
    6060                        unsigned char y;
     
    6464
    6565static ps2packet_t buf;
    66 static int bufpos = 0;
    67 static int leftbtn = 0;
    68 static int rightbtn = 0;
    69 static int middlebtn = 0;
     66static unsigned int bufpos;
     67static unsigned int leftbtn;
     68static unsigned int rightbtn;
     69static unsigned int middlebtn;
    7070
    71 int mouse_proto_init(void)
     71static mouse_dev_t *mouse_dev;
     72
     73static int ps2_proto_init(mouse_dev_t *mdev)
    7274{
    73         mouse_port_write(PS2_MOUSE_OUT_INIT);
     75        mouse_dev = mdev;
     76        bufpos = 0;
     77        leftbtn = 0;
     78        rightbtn = 0;
     79       
     80        mouse_dev->port_ops->write(PS2_MOUSE_OUT_INIT);
    7481        return 0;
    7582}
     
    7986{
    8087        int tmp;
    81 
     88       
    8289        if (!sign)
    8390                return data;
    84 
    85         tmp = ((unsigned char)~data) + 1;
     91       
     92        tmp = ((unsigned char) ~data) + 1;
    8693        return -tmp;
    8794}
    8895
    8996/** Process mouse data */
    90 void mouse_proto_parse_byte(int data)
     97static void ps2_proto_parse(sysarg_t data)
    9198{
    9299        int x, y;
    93 
     100       
    94101        /* Check that we have not lost synchronization */
    95102        if (bufpos == 0 && !(data & 0x8))
    96103                return; /* Synchro lost, ignore byte */
    97 
     104       
    98105        buf.u.data[bufpos++] = data;
    99106        if (bufpos == BUFSIZE) {
    100107                bufpos = 0;
    101 
     108               
    102109                if (buf.u.val.leftbtn ^ leftbtn) {
    103110                        leftbtn = buf.u.val.leftbtn;
    104                         mouse_ev_btn(1, leftbtn);
     111                        mouse_push_event_button(mouse_dev, 1, leftbtn);
    105112                }
    106 
     113               
    107114                if (buf.u.val.rightbtn ^ rightbtn) {
    108115                        rightbtn = buf.u.val.rightbtn;
    109                         mouse_ev_btn(2, rightbtn);
     116                        mouse_push_event_button(mouse_dev, 2, rightbtn);
    110117                }
    111 
     118               
    112119                if (buf.u.val.middlebtn ^ middlebtn) {
    113120                        middlebtn = buf.u.val.middlebtn;
    114                         mouse_ev_btn(3, middlebtn);
     121                        mouse_push_event_button(mouse_dev, 3, middlebtn);
    115122                }
     123               
     124                x = bit9toint(buf.u.val.xsign, buf.u.val.x);
     125                y = -bit9toint(buf.u.val.ysign, buf.u.val.y);
     126               
     127                if (x != 0 || y != 0)
     128                        mouse_push_event_move(mouse_dev, x, y);
     129        }
     130}
    116131
    117                 x =   bit9toint(buf.u.val.xsign, buf.u.val.x);
    118                 y = - bit9toint(buf.u.val.ysign, buf.u.val.y);
    119 
    120                 if (x != 0 || y != 0) {
    121                         mouse_ev_move(x, y);
    122                 }
    123         }
    124 
    125         return;
    126 }
     132mouse_proto_ops_t ps2_proto = {
     133        .parse = ps2_proto_parse,
     134        .init = ps2_proto_init
     135};
    127136
    128137/**
  • uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c

    r52a79081 ra33f0a6  
    4242#include <io/console.h>
    4343#include <vfs/vfs.h>
    44 #include <ipc/mouse.h>
     44#include <ipc/mouseev.h>
    4545#include <async.h>
     46#include <async_obsolete.h>
    4647#include <unistd.h>
    4748#include <stdio.h>
     
    5051#include <errno.h>
    5152#include <inttypes.h>
    52 
    5353#include "s3c24xx_ts.h"
    5454
     55// FIXME: remove this header
     56#include <kernel/ipc/ipc_methods.h>
     57
    5558#define NAME "s3c24ser"
    56 #define NAMESPACE "hid_in"
     59#define NAMESPACE "hid"
    5760
    5861static irq_cmd_t ts_irq_cmds[] = {
     
    7073static s3c24xx_ts_t *ts;
    7174
    72 static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall);
     75static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall,
     76    void *arg);
    7377static void s3c24xx_ts_irq_handler(ipc_callid_t iid, ipc_call_t *call);
    7478static void s3c24xx_ts_pen_down(s3c24xx_ts_t *ts);
     
    280284        button = 1;
    281285        press = 0;
    282         async_msg_2(ts->client_phone, MEVENT_BUTTON, button, press);
     286        async_obsolete_msg_2(ts->client_phone, MOUSEEV_BUTTON_EVENT, button, press);
    283287
    284288        s3c24xx_ts_wait_for_int_mode(ts, updn_down);
     
    321325
    322326        /* Send notifications to client. */
    323         async_msg_2(ts->client_phone, MEVENT_MOVE, dx, dy);
    324         async_msg_2(ts->client_phone, MEVENT_BUTTON, button, press);
     327        async_obsolete_msg_2(ts->client_phone, MOUSEEV_MOVE_EVENT, dx, dy);
     328        async_obsolete_msg_2(ts->client_phone, MOUSEEV_BUTTON_EVENT, button, press);
    325329
    326330        ts->last_x = x_pos;
     
    370374
    371375/** Handle mouse client connection. */
    372 static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall)
     376static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall,
     377    void *arg)
    373378{
    374379        ipc_callid_t callid;
     
    380385        while (1) {
    381386                callid = async_get_call(&call);
    382                 switch (IPC_GET_IMETHOD(call)) {
    383                 case IPC_M_PHONE_HUNGUP:
     387               
     388                if (!IPC_GET_IMETHOD(call)) {
    384389                        if (ts->client_phone != -1) {
    385                                 async_hangup(ts->client_phone);
     390                                async_obsolete_hangup(ts->client_phone);
    386391                                ts->client_phone = -1;
    387392                        }
     
    389394                        async_answer_0(callid, EOK);
    390395                        return;
     396                }
     397               
     398                switch (IPC_GET_IMETHOD(call)) {
    391399                case IPC_M_CONNECT_TO_ME:
    392400                        if (ts->client_phone != -1) {
Note: See TracChangeset for help on using the changeset viewer.