Ignore:
Timestamp:
2011-06-10T19:33:41Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1878386
Parents:
13ecdac9 (diff), 79a141a (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/hw/serial/serial1.c

    r13ecdac9 r1affcdf3  
    7171                }
    7272       
    73         int res = devman_get_phone(DEVMAN_CLIENT, IPC_FLAG_BLOCKING);
    74        
    7573        devman_handle_t handle;
    76         res = devman_device_get_handle("/hw/pci0/00:01.0/com1/a", &handle,
     74        int res = devman_device_get_handle("/hw/pci0/00:01.0/com1/a", &handle,
    7775            IPC_FLAG_BLOCKING);
    7876        if (res != EOK)
    7977                return "Could not get serial device handle";
    8078       
    81         int phone = devman_device_connect(handle, IPC_FLAG_BLOCKING);
    82         if (phone < 0) {
    83                 devman_hangup_phone(DEVMAN_CLIENT);
     79        async_sess_t *sess = devman_device_connect(EXCHANGE_SERIALIZE, handle,
     80            IPC_FLAG_BLOCKING);
     81        if (!sess)
    8482                return "Unable to connect to serial device";
    85         }
    8683       
    8784        char *buf = (char *) malloc(cnt + 1);
    8885        if (buf == NULL) {
    89                 async_hangup(phone);
    90                 devman_hangup_phone(DEVMAN_CLIENT);
     86                async_hangup(sess);
    9187                return "Failed to allocate input buffer";
    9288        }
     
    9793        sysarg_t old_word_size;
    9894       
    99         res = async_req_0_4(phone, SERIAL_GET_COM_PROPS, &old_baud,
     95        async_exch_t *exch = async_exchange_begin(sess);
     96        res = async_req_0_4(exch, SERIAL_GET_COM_PROPS, &old_baud,
    10097            &old_par, &old_word_size, &old_stop);
     98        async_exchange_end(exch);
     99       
    101100        if (res != EOK) {
    102101                free(buf);
    103                 async_hangup(phone);
    104                 devman_hangup_phone(DEVMAN_CLIENT);
     102                async_hangup(sess);
    105103                return "Failed to get old serial communication parameters";
    106104        }
    107105       
    108         res = async_req_4_0(phone, SERIAL_SET_COM_PROPS, 1200,
     106        exch = async_exchange_begin(sess);
     107        res = async_req_4_0(exch, SERIAL_SET_COM_PROPS, 1200,
    109108            SERIAL_NO_PARITY, 8, 1);
     109        async_exchange_end(exch);
     110       
    110111        if (EOK != res) {
    111112                free(buf);
    112                 async_hangup(phone);
    113                 devman_hangup_phone(DEVMAN_CLIENT);
     113                async_hangup(sess);
    114114                return "Failed to set serial communication parameters";
    115115        }
     
    120120        size_t total = 0;
    121121        while (total < cnt) {
    122                 ssize_t read = char_dev_read(phone, buf, cnt - total);
     122                ssize_t read = char_dev_read(sess, buf, cnt - total);
    123123               
    124124                if (read < 0) {
    125                         async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
     125                        exch = async_exchange_begin(sess);
     126                        async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud,
    126127                            old_par, old_word_size, old_stop);
     128                        async_exchange_end(exch);
     129                       
    127130                        free(buf);
    128                         async_hangup(phone);
    129                         devman_hangup_phone(DEVMAN_CLIENT);
     131                        async_hangup(sess);
    130132                        return "Failed read from serial device";
    131133                }
    132134               
    133135                if ((size_t) read > cnt - total) {
    134                         async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
     136                        exch = async_exchange_begin(sess);
     137                        async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud,
    135138                            old_par, old_word_size, old_stop);
     139                        async_exchange_end(exch);
     140                       
    136141                        free(buf);
    137                         async_hangup(phone);
    138                         devman_hangup_phone(DEVMAN_CLIENT);
     142                        async_hangup(sess);
    139143                        return "Read more data than expected";
    140144                }
     
    151155                         * direction of data transfer.
    152156                         */
    153                         ssize_t written = char_dev_write(phone, buf, read);
     157                        ssize_t written = char_dev_write(sess, buf, read);
    154158                       
    155159                        if (written < 0) {
    156                                 async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
     160                                exch = async_exchange_begin(sess);
     161                                async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud,
    157162                                    old_par, old_word_size, old_stop);
     163                                async_exchange_end(exch);
     164                               
    158165                                free(buf);
    159                                 async_hangup(phone);
    160                                 devman_hangup_phone(DEVMAN_CLIENT);
     166                                async_hangup(sess);
    161167                                return "Failed write to serial device";
    162168                        }
    163169                       
    164170                        if (written != read) {
    165                                 async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
     171                                exch = async_exchange_begin(sess);
     172                                async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud,
    166173                                    old_par, old_word_size, old_stop);
     174                                async_exchange_end(exch);
     175                               
    167176                                free(buf);
    168                                 async_hangup(phone);
    169                                 devman_hangup_phone(DEVMAN_CLIENT);
     177                                async_hangup(sess);
    170178                                return "Written less data than read from serial device";
    171179                        }
     
    180188       
    181189        size_t eot_size = str_size(EOT);
    182         ssize_t written = char_dev_write(phone, (void *) EOT, eot_size);
    183        
    184         async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud,
     190        ssize_t written = char_dev_write(sess, (void *) EOT, eot_size);
     191       
     192        exch = async_exchange_begin(sess);
     193        async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud,
    185194            old_par, old_word_size, old_stop);
     195        async_exchange_end(exch);
     196       
    186197        free(buf);
    187         async_hangup(phone);
    188         devman_hangup_phone(DEVMAN_CLIENT);
     198        async_hangup(sess);
    189199       
    190200        if (written < 0)
Note: See TracChangeset for help on using the changeset viewer.