Changeset 2f79a38 in mainline


Ignore:
Timestamp:
2012-01-04T00:45:06Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bd87ae0
Parents:
22e4e9b
Message:

ps2mouse: User exchange rather than session in chardev iface.

Location:
uspace/drv/char/ps2mouse
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/char/ps2mouse/chardev.c

    r22e4e9b r2f79a38  
    4040};
    4141
    42 static ssize_t chardev_read_int(async_exch_t *exch, void *data, size_t size)
     42ssize_t chardev_read(async_exch_t *exch, void *data, size_t size)
    4343{
    4444        if (!exch)
     
    5555}
    5656
    57 static ssize_t chardev_write_int(async_exch_t *exch, const void *data, size_t size)
     57ssize_t chardev_write(async_exch_t *exch, const void *data, size_t size)
    5858{
    5959        if (!exch)
     
    6767            message[0], message[1], message[2]);
    6868}
    69 
    70 
    71 ssize_t chardev_write(async_sess_t *sess, const void *data, size_t size)
    72 {
    73         async_exch_t *exch = async_exchange_begin(sess);
    74         const ssize_t ret = chardev_write_int(exch, data, size);
    75         async_exchange_end(exch);
    76         return ret;
    77 }
    78 
    79 ssize_t chardev_read(async_sess_t *sess, void *data, size_t size)
    80 {
    81         async_exch_t *exch = async_exchange_begin(sess);
    82         const ssize_t ret = chardev_read_int(exch, data, size);
    83         async_exchange_end(exch);
    84         return ret;
    85 }
  • uspace/drv/char/ps2mouse/chardev.h

    r22e4e9b r2f79a38  
    3939#include <async.h>
    4040
    41 ssize_t chardev_read(async_sess_t *, void *, size_t);
    42 ssize_t chardev_write(async_sess_t *, const void *, size_t);
     41ssize_t chardev_read(async_exch_t *, void *, size_t);
     42ssize_t chardev_write(async_exch_t *, const void *, size_t);
    4343
    4444#endif
  • uspace/drv/char/ps2mouse/ps2mouse.c

    r22e4e9b r2f79a38  
    7474do { \
    7575        uint8_t data = 0; \
    76         const ssize_t size = chardev_read(session, &data, 1); \
     76        const ssize_t size = chardev_read(sess, &data, 1); \
    7777        if (size != 1) { \
    7878                ddf_msg(LVL_ERROR, "Failed reading byte: %d)", size);\
     
    8989do { \
    9090        uint8_t data = (value); \
    91         const ssize_t size = chardev_write(session, &data, 1); \
     91        const ssize_t size = chardev_write(sess, &data, 1); \
    9292        if (size < 0 ) { \
    9393                ddf_msg(LVL_ERROR, "Failed writing byte: %hhx", value); \
     
    9898static int polling_ps2(void *);
    9999static int polling_intellimouse(void *);
    100 static int probe_intellimouse(async_sess_t *, bool);
     100static int probe_intellimouse(async_exch_t *, bool);
    101101static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
    102102
     
    148148        /* Probe IntelliMouse extensions. */
    149149        int (*polling_f)(void*) = polling_ps2;
    150         if (probe_intellimouse(mouse->parent_sess, false) == EOK) {
     150        async_exch_t *exch = async_exchange_begin(mouse->parent_sess);
     151        if (probe_intellimouse(exch, false) == EOK) {
    151152                ddf_msg(LVL_NOTE, "Enabled IntelliMouse extensions");
    152153                polling_f = polling_intellimouse;
    153                 if (probe_intellimouse(mouse->parent_sess, true) == EOK)
     154                if (probe_intellimouse(exch, true) == EOK)
    154155                        ddf_msg(LVL_NOTE, "Enabled 4th and 5th button.");
    155156        }
    156157        /* Enable mouse data reporting. */
    157158        uint8_t report = PS2_MOUSE_ENABLE_DATA_REPORT;
    158         ssize_t size = chardev_write(mouse->parent_sess, &report, 1);
     159        ssize_t size = chardev_write(exch, &report, 1);
    159160        if (size != 1) {
    160161                ddf_msg(LVL_ERROR, "Failed to enable data reporting.");
     162                async_exchange_end(exch);
    161163                async_hangup(mouse->parent_sess);
    162164                ddf_fun_unbind(mouse->mouse_fun);
     
    166168        }
    167169
    168         size = chardev_read(mouse->parent_sess, &report, 1);
     170        size = chardev_read(exch, &report, 1);
     171        async_exchange_end(exch);
    169172        if (size != 1 || report != PS2_MOUSE_ACK) {
    170173                ddf_msg(LVL_ERROR, "Failed to confirm data reporting: %hhx.",
     
    200203        assert(mouse->parent_sess);
    201204        bool buttons[PS2_BUTTON_COUNT] = {};
     205        async_exch_t *parent_exch = async_exchange_begin(mouse->parent_sess);
    202206        while (1) {
    203207
    204208                uint8_t packet[PS2_BUFSIZE] = {};
    205209                const ssize_t size =
    206                     chardev_read(mouse->parent_sess, packet, PS2_BUFSIZE);
     210                    chardev_read(parent_exch, packet, PS2_BUFSIZE);
    207211
    208212                if (size != PS2_BUFSIZE) {
     
    242246                async_exchange_end(exch);
    243247        }
     248        async_exchange_end(parent_exch);
    244249}
    245250
     
    255260        assert(mouse->parent_sess);
    256261        bool buttons[INTELLIMOUSE_BUTTON_COUNT] = {};
     262        async_exch_t *parent_exch = NULL;
    257263        while (1) {
     264                if (!parent_exch)
     265                        parent_exch = async_exchange_begin(mouse->parent_sess);
    258266
    259267                uint8_t packet[INTELLIMOUSE_BUFSIZE] = {};
    260268                const ssize_t size = chardev_read(
    261                     mouse->parent_sess, packet, INTELLIMOUSE_BUFSIZE);
     269                    parent_exch, packet, INTELLIMOUSE_BUFSIZE);
    262270
    263271                if (size != INTELLIMOUSE_BUFSIZE) {
     
    316324                async_exchange_end(exch);
    317325        }
     326        async_exchange_end(parent_exch);
    318327}
    319328
    320329/** Send magic sequence to initialize IntelliMouse extensions.
    321  * @param session IPC session to the parent device.
     330 * @param exch IPC exchange to the parent device.
    322331 * @param buttons True selects magic sequence for 4th and 5th button,
    323332 * false selects wheel support magic sequence.
    324333 * See http://www.computer-engineering.org/ps2mouse/ for details.
    325334 */
    326 static int probe_intellimouse(async_sess_t *session, bool buttons)
     335static int probe_intellimouse(async_exch_t *exch, bool buttons)
    327336{
    328         assert(session);
    329 
    330         MOUSE_WRITE_BYTE(session, PS2_MOUSE_SET_SAMPLE_RATE);
    331         MOUSE_READ_BYTE_TEST(session, PS2_MOUSE_ACK);
    332         MOUSE_WRITE_BYTE(session, 200);
    333         MOUSE_READ_BYTE_TEST(session, PS2_MOUSE_ACK);
    334 
    335         MOUSE_WRITE_BYTE(session, PS2_MOUSE_SET_SAMPLE_RATE);
    336         MOUSE_READ_BYTE_TEST(session, PS2_MOUSE_ACK);
    337         MOUSE_WRITE_BYTE(session, buttons ? 200 : 100);
    338         MOUSE_READ_BYTE_TEST(session, PS2_MOUSE_ACK);
    339 
    340         MOUSE_WRITE_BYTE(session, PS2_MOUSE_SET_SAMPLE_RATE);
    341         MOUSE_READ_BYTE_TEST(session, PS2_MOUSE_ACK);
    342         MOUSE_WRITE_BYTE(session, 80);
    343         MOUSE_READ_BYTE_TEST(session, PS2_MOUSE_ACK);
    344 
    345         MOUSE_WRITE_BYTE(session, PS2_MOUSE_GET_DEVICE_ID);
    346         MOUSE_READ_BYTE_TEST(session, PS2_MOUSE_ACK);
    347         MOUSE_READ_BYTE_TEST(session, buttons ? 4 : 3);
     337        assert(exch);
     338
     339        MOUSE_WRITE_BYTE(exch, PS2_MOUSE_SET_SAMPLE_RATE);
     340        MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
     341        MOUSE_WRITE_BYTE(exch, 200);
     342        MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
     343
     344        MOUSE_WRITE_BYTE(exch, PS2_MOUSE_SET_SAMPLE_RATE);
     345        MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
     346        MOUSE_WRITE_BYTE(exch, buttons ? 200 : 100);
     347        MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
     348
     349        MOUSE_WRITE_BYTE(exch, PS2_MOUSE_SET_SAMPLE_RATE);
     350        MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
     351        MOUSE_WRITE_BYTE(exch, 80);
     352        MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
     353
     354        MOUSE_WRITE_BYTE(exch, PS2_MOUSE_GET_DEVICE_ID);
     355        MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
     356        MOUSE_READ_BYTE_TEST(exch, buttons ? 4 : 3);
    348357
    349358        return EOK;
Note: See TracChangeset for help on using the changeset viewer.