Ignore:
Timestamp:
2010-05-06T11:42:55Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ab1aa871
Parents:
ba95e8f
Message:

writing to serial port using character interface

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libdrv/generic/remote_char.c

    rba95e8f rca97cad  
    4545static void remote_char_write(device_t *dev, void *iface, ipc_callid_t callid, ipc_call_t *call);
    4646
     47/** Remote character interface operations.
     48 */
    4749static remote_iface_func_ptr_t remote_char_iface_ops [] = {
    4850        &remote_char_read,
     
    5052};
    5153 
     54/** Remote character interface structure.
     55 * Interface for processing request from remote clients addressed to the character interface.
     56 */
    5257remote_iface_t remote_char_iface = {
    5358        .method_count = sizeof(remote_char_iface_ops) / sizeof(remote_iface_func_ptr_t),
     
    5560};
    5661
     62/** Process the read request from the remote client.
     63 *
     64 * Receive the read request's parameters from the remote client and pass them to the local interface.
     65 * Return the result of the operation processed by the local interface to the remote client.
     66 *
     67 * @param dev the device from which the data are read.
     68 * @param iface the local interface structure.
     69 */
    5770static void remote_char_read(device_t *dev, void *iface, ipc_callid_t callid, ipc_call_t *call)
    5871{       
     
    8699        }
    87100       
     101        // the operation was successful, return the number of data read
    88102        async_data_read_finalize(cid, buf, ret);
    89103        ipc_answer_1(callid, EOK, ret);
    90104}
    91105
     106/** Process the write request from the remote client.
     107 *
     108 * Receive the write request's parameters from the remote client and pass them to the local interface.
     109 * Return the result of the operation processed by the local interface to the remote client.
     110 *
     111 * @param dev the device to which the data are written.
     112 * @param iface the local interface structure.
     113 */
    92114static void remote_char_write(device_t *dev, void *iface, ipc_callid_t callid, ipc_call_t *call)
    93115{
    94116        char_iface_t *char_iface = (char_iface_t *)iface;
     117        ipc_callid_t cid;
     118        size_t len;
     119       
     120        if (!async_data_write_receive(&cid, &len)) {
     121                // TODO handle protocol error
     122                ipc_answer_0(callid, EINVAL);
     123                return;
     124    }
     125       
    95126        if (!char_iface->write) {
     127                async_data_write_finalize(cid, NULL, 0);
    96128                ipc_answer_0(callid, ENOTSUP);
    97129                return;
    98130        }       
    99        
    100         size_t len;
    101         if (!async_data_write_receive(&callid, &len)) {
    102                 // TODO handle protocol error
    103                 return;
    104     }
    105131       
    106132        if (len > MAX_CHAR_RW_COUNT) {
     
    110136        char buf[MAX_CHAR_RW_COUNT];
    111137       
    112         async_data_write_finalize(callid, buf, len);
     138        async_data_write_finalize(cid, buf, len);
    113139       
    114140        int ret = (*char_iface->write)(dev, buf, len);
     
    116142                ipc_answer_0(callid, ret);
    117143        } else {
     144                // the operation was successful, return the number of data written
    118145                ipc_answer_1(callid, EOK, ret);
    119146        }
Note: See TracChangeset for help on using the changeset viewer.