Changeset 00aece0 in mainline for uspace/srv/hid/input


Ignore:
Timestamp:
2012-02-18T16:47:38Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4449c6c
Parents:
bd5f3b7 (diff), f943dd3 (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 mainline changes.

Location:
uspace/srv/hid/input
Files:
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/input/Makefile

    rbd5f3b7 r00aece0  
    4343        port/adb_mouse.c \
    4444        port/chardev.c \
    45         port/chardev_mouse.c \
    4645        port/gxemul.c \
    4746        port/msim.c \
     
    5251        proto/adb.c \
    5352        proto/mousedev.c \
    54         proto/ps2.c \
    5553        ctl/apple.c \
    5654        ctl/gxe_fb.c \
  • uspace/srv/hid/input/ctl/kbdev.c

    rbd5f3b7 r00aece0  
    111111                printf("%s: Failed allocating device structure for '%s'.\n",
    112112                    NAME, kdev->svc_name);
     113                async_hangup(sess);
    113114                return -1;
    114115        }
     
    169170                callid = async_get_call(&call);
    170171                if (!IPC_GET_IMETHOD(call)) {
    171                         /* XXX Handle hangup */
     172                        kbdev_destroy(kbdev);
    172173                        return;
    173174                }
  • uspace/srv/hid/input/generic/input.c

    rbd5f3b7 r00aece0  
    3939#include <adt/list.h>
    4040#include <bool.h>
     41#include <fibril_synch.h>
    4142#include <ipc/services.h>
    4243#include <ipc/input.h>
     
    4748#include <stdio.h>
    4849#include <ns.h>
    49 #include <ns_obsolete.h>
    5050#include <async.h>
    51 #include <async_obsolete.h>
    5251#include <errno.h>
    5352#include <adt/fifo.h>
     
    6362#include <mouse.h>
    6463
    65 // FIXME: remove this header
    66 #include <abi/ipc/methods.h>
    67 
    6864#define NUM_LAYOUTS  3
    6965
     
    7773static void kbd_devs_reclaim(void);
    7874
    79 int client_phone = -1;
     75async_sess_t *client_sess = NULL;
    8076
    8177/** List of keyboard devices */
     
    8682
    8783bool irc_service = false;
    88 int irc_phone = -1;
     84async_sess_t *irc_sess = NULL;
     85
     86static FIBRIL_MUTEX_INITIALIZE(discovery_lock);
    8987
    9088void kbd_push_data(kbd_dev_t *kdev, sysarg_t data)
     
    170168       
    171169        ev.c = layout_parse_ev(kdev->active_layout, &ev);
    172         async_obsolete_msg_4(client_phone, INPUT_EVENT_KEY, ev.type, ev.key,
    173             ev.mods, ev.c);
     170       
     171        async_exch_t *exch = async_exchange_begin(client_sess);
     172        async_msg_4(exch, INPUT_EVENT_KEY, ev.type, ev.key, ev.mods, ev.c);
     173        async_exchange_end(exch);
    174174}
    175175
    176176/** Mouse pointer has moved. */
    177 void mouse_push_event_move(mouse_dev_t *mdev, int dx, int dy)
    178 {
    179         async_obsolete_msg_2(client_phone, INPUT_EVENT_MOVE, dx, dy);
     177void mouse_push_event_move(mouse_dev_t *mdev, int dx, int dy, int dz)
     178{
     179        async_exch_t *exch = async_exchange_begin(client_sess);
     180        if (dx || dy)
     181                async_msg_2(exch, INPUT_EVENT_MOVE, dx, dy);
     182        if (dz) {
     183                // TODO: Implement proper wheel support
     184                keycode_t code = dz > 0 ? KC_UP : KC_DOWN;
     185                for (int i = 0; i < 3; ++i) {
     186                        async_msg_4(exch, INPUT_EVENT_KEY, KEY_PRESS, code, 0, 0);
     187                }
     188                async_msg_4(exch, INPUT_EVENT_KEY, KEY_RELEASE, code, 0, 0);
     189        }
     190        async_exchange_end(exch);
    180191}
    181192
     
    183194void mouse_push_event_button(mouse_dev_t *mdev, int bnum, int press)
    184195{
    185         async_obsolete_msg_2(client_phone, INPUT_EVENT_BUTTON, bnum, press);
     196        async_exch_t *exch = async_exchange_begin(client_sess);
     197        async_msg_2(exch, INPUT_EVENT_BUTTON, bnum, press);
     198        async_exchange_end(exch);
    186199}
    187200
    188201static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    189202{
    190         ipc_callid_t callid;
    191         ipc_call_t call;
    192         int retval;
    193        
    194203        async_answer_0(iid, EOK);
    195204       
    196205        while (true) {
    197                 callid = async_get_call(&call);
     206                ipc_call_t call;
     207                ipc_callid_t callid = async_get_call(&call);
    198208               
    199209                if (!IPC_GET_IMETHOD(call)) {
    200                         if (client_phone != -1) {
    201                                 async_obsolete_hangup(client_phone);
    202                                 client_phone = -1;
     210                        if (client_sess != NULL) {
     211                                async_hangup(client_sess);
     212                                client_sess = NULL;
    203213                        }
    204214                       
     
    207217                }
    208218               
    209                 switch (IPC_GET_IMETHOD(call)) {
    210                 case IPC_M_CONNECT_TO_ME:
    211                         if (client_phone != -1) {
    212                                 retval = ELIMIT;
     219                async_sess_t *sess =
     220                    async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
     221                if (sess != NULL) {
     222                        if (client_sess == NULL) {
     223                                client_sess = sess;
     224                                async_answer_0(callid, EOK);
     225                        } else
     226                                async_answer_0(callid, ELIMIT);
     227                } else {
     228                        switch (IPC_GET_IMETHOD(call)) {
     229                        case INPUT_YIELD:
     230                                kbd_devs_yield();
     231                                async_answer_0(callid, EOK);
    213232                                break;
     233                        case INPUT_RECLAIM:
     234                                kbd_devs_reclaim();
     235                                async_answer_0(callid, EOK);
     236                                break;
     237                        default:
     238                                async_answer_0(callid, EINVAL);
    214239                        }
    215                         client_phone = IPC_GET_ARG5(call);
    216                         retval = 0;
    217                         break;
    218                 case INPUT_YIELD:
    219                         kbd_devs_yield();
    220                         retval = 0;
    221                         break;
    222                 case INPUT_RECLAIM:
    223                         kbd_devs_reclaim();
    224                         retval = 0;
    225                         break;
    226                 default:
    227                         retval = EINVAL;
    228                 }
    229                
    230                 async_answer_0(callid, retval);
     240                }
    231241        }
    232242}
     
    399409         * them automatically.
    400410         */
    401 #if defined(UARCH_amd64)
    402         kbd_add_dev(&chardev_port, &pc_ctl);
    403 #endif
    404411#if defined(UARCH_arm32) && defined(MACHINE_gta02)
    405412        kbd_add_dev(&chardev_port, &stty_ctl);
     
    413420#if defined(UARCH_arm32) && defined(MACHINE_integratorcp)
    414421        kbd_add_dev(&pl050_port, &pc_ctl);
    415 #endif
    416 #if defined(UARCH_ia32)
    417         kbd_add_dev(&chardev_port, &pc_ctl);
    418 #endif
    419 #if defined(MACHINE_i460GX)
    420         kbd_add_dev(&chardev_port, &pc_ctl);
    421422#endif
    422423#if defined(MACHINE_ski)
     
    452453         * them automatically.
    453454         */
    454 #if defined(UARCH_amd64)
    455         mouse_add_dev(&chardev_mouse_port, &ps2_proto);
    456 #endif
    457 #if defined(UARCH_ia32)
    458         mouse_add_dev(&chardev_mouse_port, &ps2_proto);
    459 #endif
    460 #if defined(MACHINE_i460GX)
    461         mouse_add_dev(&chardev_mouse_port, &ps2_proto);
    462 #endif
    463455#if defined(UARCH_ppc32)
    464456        mouse_add_dev(&adb_mouse_port, &adb_proto);
     
    604596        int rc;
    605597       
     598        fibril_mutex_lock(&discovery_lock);
     599       
    606600        rc = dev_check_new_kbdevs();
    607         if (rc != EOK)
     601        if (rc != EOK) {
     602                fibril_mutex_unlock(&discovery_lock);
    608603                return rc;
     604        }
    609605       
    610606        rc = dev_check_new_mousedevs();
    611         if (rc != EOK)
     607        if (rc != EOK) {
     608                fibril_mutex_unlock(&discovery_lock);
    612609                return rc;
    613 
     610        }
     611       
     612        fibril_mutex_unlock(&discovery_lock);
     613       
    614614        return EOK;
    615615}
     
    648648       
    649649        if (irc_service) {
    650                 while (irc_phone < 0)
    651                         irc_phone = service_obsolete_connect_blocking(SERVICE_IRC, 0, 0);
     650                while (irc_sess == NULL)
     651                        irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
     652                            SERVICE_IRC, 0, 0);
    652653        }
    653654       
     
    659660       
    660661        /* Register driver */
    661         int rc = loc_server_register(NAME, client_connection);
     662        async_set_client_connection(client_connection);
     663        int rc = loc_server_register(NAME);
    662664        if (rc < 0) {
    663665                printf("%s: Unable to register server (%d)\n", NAME, rc);
  • uspace/srv/hid/input/include/input.h

    rbd5f3b7 r00aece0  
    4040
    4141#include <bool.h>
     42#include <async.h>
    4243
    4344#define NAME       "input"
     
    4546
    4647extern bool irc_service;
    47 extern int irc_phone;
     48extern async_sess_t *irc_sess;
    4849
    4950#endif
  • uspace/srv/hid/input/include/mouse.h

    rbd5f3b7 r00aece0  
    6262
    6363extern void mouse_push_data(mouse_dev_t *, sysarg_t);
    64 extern void mouse_push_event_move(mouse_dev_t *, int, int);
     64extern void mouse_push_event_move(mouse_dev_t *, int, int, int);
    6565extern void mouse_push_event_button(mouse_dev_t *, int, int);
    6666
  • uspace/srv/hid/input/include/mouse_proto.h

    rbd5f3b7 r00aece0  
    4848
    4949extern mouse_proto_ops_t adb_proto;
    50 extern mouse_proto_ops_t ps2_proto;
    5150extern mouse_proto_ops_t mousedev_proto;
    5251
  • uspace/srv/hid/input/port/chardev.c

    rbd5f3b7 r00aece0  
    6363/** List of devices to try connecting to. */
    6464static const char *in_devs[] = {
    65         "char/ps2a",
    6665        "char/s3c24ser"
    6766};
  • uspace/srv/hid/input/port/gxemul.c

    rbd5f3b7 r00aece0  
    5757static kbd_dev_t *kbd_dev;
    5858
     59static irq_pio_range_t gxemul_ranges[] = {
     60        {
     61                .base = 0,
     62                .size = 1
     63        }
     64};
     65
    5966static irq_cmd_t gxemul_cmds[] = {
    6067        {
     
    6976
    7077static irq_code_t gxemul_kbd = {
     78        sizeof(gxemul_ranges) / sizeof(irq_pio_range_t),
     79        gxemul_ranges,
    7180        sizeof(gxemul_cmds) / sizeof(irq_cmd_t),
    7281        gxemul_cmds
     
    8190       
    8291        sysarg_t addr;
    83         if (sysinfo_get_value("kbd.address.virtual", &addr) != EOK)
     92        if (sysinfo_get_value("kbd.address.physical", &addr) != EOK)
    8493                return -1;
    8594       
     
    8998       
    9099        async_set_interrupt_received(gxemul_irq_handler);
     100        gxemul_ranges[0].base = addr;
    91101        gxemul_cmds[0].addr = (void *) addr;
    92         register_irq(inr, device_assign_devno(), 0, &gxemul_kbd);
     102        irq_register(inr, device_assign_devno(), 0, &gxemul_kbd);
    93103        return 0;
    94104}
  • uspace/srv/hid/input/port/msim.c

    rbd5f3b7 r00aece0  
    5757static kbd_dev_t *kbd_dev;
    5858
     59static irq_pio_range_t msim_ranges[] = {
     60        {
     61                .base = 0,
     62                .size = 1
     63        }
     64};
     65
    5966static irq_cmd_t msim_cmds[] = {
    6067        {
     
    6976
    7077static irq_code_t msim_kbd = {
     78        sizeof(msim_ranges) / sizeof(irq_pio_range_t),
     79        msim_ranges,
    7180        sizeof(msim_cmds) / sizeof(irq_cmd_t),
    7281        msim_cmds
     
    7988        kbd_dev = kdev;
    8089
    81         sysarg_t vaddr;
    82         if (sysinfo_get_value("kbd.address.virtual", &vaddr) != EOK)
     90        sysarg_t paddr;
     91        if (sysinfo_get_value("kbd.address.physical", &paddr) != EOK)
    8392                return -1;
    8493       
     
    8796                return -1;
    8897       
    89         msim_cmds[0].addr = (void *) vaddr;
     98        msim_ranges[0].base = paddr;
     99        msim_cmds[0].addr = (void *) paddr;
    90100        async_set_interrupt_received(msim_irq_handler);
    91         register_irq(inr, device_assign_devno(), 0, &msim_kbd);
     101        irq_register(inr, device_assign_devno(), 0, &msim_kbd);
    92102       
    93103        return 0;
  • uspace/srv/hid/input/port/niagara.c

    rbd5f3b7 r00aece0  
    6363#define POLL_INTERVAL  10000
    6464
    65 /**
    66  * Virtual address mapped to the buffer shared with the kernel counterpart.
    67  */
    68 static uintptr_t input_buffer_addr;
    69 
    7065/*
    7166 * Kernel counterpart of the driver pushes characters (it has read) here.
     
    10297                return -1;
    10398       
    104         input_buffer_addr = (uintptr_t) as_get_mappable_page(PAGE_SIZE);
    105         int rc = physmem_map((void *) paddr, (void *) input_buffer_addr,
    106             1, AS_AREA_READ | AS_AREA_WRITE);
    107        
     99        int rc = physmem_map((void *) paddr, 1,
     100            AS_AREA_READ | AS_AREA_WRITE, (void *) &input_buffer);
    108101        if (rc != 0) {
    109102                printf("Niagara: uspace driver couldn't map physical memory: %d\n",
     
    111104                return rc;
    112105        }
    113        
    114         input_buffer = (input_buffer_t) input_buffer_addr;
    115106       
    116107        thread_id_t tid;
  • uspace/srv/hid/input/port/ns16550.c

    rbd5f3b7 r00aece0  
    3838#include <ipc/irc.h>
    3939#include <async.h>
    40 #include <async_obsolete.h>
    4140#include <sysinfo.h>
    4241#include <input.h>
     
    7170#define LSR_DATA_READY  0x01
    7271
     72static irq_pio_range_t ns16550_ranges[] = {
     73        {
     74                .base = 0,
     75                .size = 8
     76        }
     77};
     78
    7379static irq_cmd_t ns16550_cmds[] = {
    7480        {
     
    99105
    100106irq_code_t ns16550_kbd = {
     107        sizeof(ns16550_ranges) / sizeof(irq_pio_range_t),
     108        ns16550_ranges,
    101109        sizeof(ns16550_cmds) / sizeof(irq_cmd_t),
    102110        ns16550_cmds
     
    106114
    107115static uintptr_t ns16550_physical;
    108 static uintptr_t ns16550_kernel;
    109116
    110117static kbd_dev_t *kbd_dev;
     
    125132                return -1;
    126133       
    127         if (sysinfo_get_value("kbd.address.kernel", &ns16550_kernel) != EOK)
    128                 return -1;
    129        
    130134        sysarg_t inr;
    131135        if (sysinfo_get_value("kbd.inr", &inr) != EOK)
    132136                return -1;
    133137       
    134         ns16550_kbd.cmds[0].addr = (void *) (ns16550_kernel + LSR_REG);
    135         ns16550_kbd.cmds[3].addr = (void *) (ns16550_kernel + RBR_REG);
     138        ns16550_kbd.ranges[0].base = ns16550_physical;
     139        ns16550_kbd.cmds[0].addr = (void *) (ns16550_physical + LSR_REG);
     140        ns16550_kbd.cmds[3].addr = (void *) (ns16550_physical + RBR_REG);
    136141       
    137142        async_set_interrupt_received(ns16550_irq_handler);
    138         register_irq(inr, device_assign_devno(), inr, &ns16550_kbd);
     143        irq_register(inr, device_assign_devno(), inr, &ns16550_kbd);
    139144       
    140145        return pio_enable((void *) ns16550_physical, 8, &vaddr);
     
    158163        kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
    159164       
    160         if (irc_service)
    161                 async_obsolete_msg_1(irc_phone, IRC_CLEAR_INTERRUPT,
    162                     IPC_GET_IMETHOD(*call));
     165        if (irc_service) {
     166                async_exch_t *exch = async_exchange_begin(irc_sess);
     167                async_msg_1(exch, IRC_CLEAR_INTERRUPT, IPC_GET_IMETHOD(*call));
     168                async_exchange_end(exch);
     169        }
    163170}
    164171
  • uspace/srv/hid/input/port/pl050.c

    rbd5f3b7 r00aece0  
    6161static kbd_dev_t *kbd_dev;
    6262
     63#define PL050_STAT      4
     64#define PL050_DATA      8
     65
    6366#define PL050_STAT_RXFULL  (1 << 4)
     67
     68static irq_pio_range_t pl050_ranges[] = {
     69        {
     70                .base = 0,
     71                .size = 9,
     72        }
     73};
    6474
    6575static irq_cmd_t pl050_cmds[] = {
     
    91101
    92102static irq_code_t pl050_kbd = {
     103        sizeof(pl050_ranges) / sizeof(irq_pio_range_t),
     104        pl050_ranges,
    93105        sizeof(pl050_cmds) / sizeof(irq_cmd_t),
    94106        pl050_cmds
     
    102114       
    103115        sysarg_t addr;
    104         if (sysinfo_get_value("kbd.address.status", &addr) != EOK)
     116        if (sysinfo_get_value("kbd.address.physical", &addr) != EOK)
    105117                return -1;
    106118       
    107         pl050_kbd.cmds[0].addr = (void *) addr;
    108        
    109         if (sysinfo_get_value("kbd.address.data", &addr) != EOK)
    110                 return -1;
    111        
    112         pl050_kbd.cmds[3].addr = (void *) addr;
     119        pl050_kbd.ranges[0].base = addr;
     120        pl050_kbd.cmds[0].addr = (void *) addr + PL050_STAT;
     121        pl050_kbd.cmds[3].addr = (void *) addr + PL050_DATA;
    113122       
    114123        sysarg_t inr;
     
    117126       
    118127        async_set_interrupt_received(pl050_irq_handler);
    119         register_irq(inr, device_assign_devno(), 0, &pl050_kbd);
     128        irq_register(inr, device_assign_devno(), 0, &pl050_kbd);
    120129       
    121130        return 0;
  • uspace/srv/hid/input/proto/adb.c

    rbd5f3b7 r00aece0  
    8282       
    8383        if (dx != 0 || dy != 0)
    84                 mouse_push_event_move(mouse_dev, dx, dy);
     84                mouse_push_event_move(mouse_dev, dx, dy, 0);
    8585}
    8686
  • uspace/srv/hid/input/proto/mousedev.c

    rbd5f3b7 r00aece0  
    5454        /** Link to generic mouse device */
    5555        mouse_dev_t *mouse_dev;
    56        
    57         /** Session to mouse device */
    58         async_sess_t *sess;
    5956} mousedev_t;
    6057
     
    7269static void mousedev_destroy(mousedev_t *mousedev)
    7370{
    74         if (mousedev->sess != NULL)
    75                 async_hangup(mousedev->sess);
    76        
    7771        free(mousedev);
    7872}
     
    8983               
    9084                if (!IPC_GET_IMETHOD(call)) {
    91                         /* XXX Handle hangup */
     85                        mousedev_destroy(mousedev);
    9286                        return;
    9387                }
     
    9791                switch (IPC_GET_IMETHOD(call)) {
    9892                case MOUSEEV_MOVE_EVENT:
    99                         mouse_push_event_move(mousedev->mouse_dev, IPC_GET_ARG1(call),
    100                             IPC_GET_ARG2(call));
     93                        mouse_push_event_move(mousedev->mouse_dev,
     94                            IPC_GET_ARG1(call), IPC_GET_ARG2(call),
     95                            IPC_GET_ARG3(call));
    10196                        retval = EOK;
    10297                        break;
    10398                case MOUSEEV_BUTTON_EVENT:
    104                         mouse_push_event_button(mousedev->mouse_dev, IPC_GET_ARG1(call),
    105                             IPC_GET_ARG2(call));
     99                        mouse_push_event_button(mousedev->mouse_dev,
     100                            IPC_GET_ARG1(call), IPC_GET_ARG2(call));
    106101                        retval = EOK;
    107102                        break;
     
    129124                printf("%s: Failed allocating device structure for '%s'.\n",
    130125                    NAME, mdev->svc_name);
     126                async_hangup(sess);
    131127                return -1;
    132128        }
    133        
    134         mousedev->sess = sess;
    135129       
    136130        async_exch_t *exch = async_exchange_begin(sess);
     
    139133                    mdev->svc_name);
    140134                mousedev_destroy(mousedev);
     135                async_hangup(sess);
    141136                return -1;
    142137        }
     
    144139        int rc = async_connect_to_me(exch, 0, 0, 0, mousedev_callback_conn, mousedev);
    145140        async_exchange_end(exch);
     141        async_hangup(sess);
    146142       
    147143        if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.