Changeset ca97cad in mainline for uspace/lib/libdrv/generic/remote_char.c
- Timestamp:
- 2010-05-06T11:42:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ab1aa871
- Parents:
- ba95e8f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libdrv/generic/remote_char.c
rba95e8f rca97cad 45 45 static void remote_char_write(device_t *dev, void *iface, ipc_callid_t callid, ipc_call_t *call); 46 46 47 /** Remote character interface operations. 48 */ 47 49 static remote_iface_func_ptr_t remote_char_iface_ops [] = { 48 50 &remote_char_read, … … 50 52 }; 51 53 54 /** Remote character interface structure. 55 * Interface for processing request from remote clients addressed to the character interface. 56 */ 52 57 remote_iface_t remote_char_iface = { 53 58 .method_count = sizeof(remote_char_iface_ops) / sizeof(remote_iface_func_ptr_t), … … 55 60 }; 56 61 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 */ 57 70 static void remote_char_read(device_t *dev, void *iface, ipc_callid_t callid, ipc_call_t *call) 58 71 { … … 86 99 } 87 100 101 // the operation was successful, return the number of data read 88 102 async_data_read_finalize(cid, buf, ret); 89 103 ipc_answer_1(callid, EOK, ret); 90 104 } 91 105 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 */ 92 114 static void remote_char_write(device_t *dev, void *iface, ipc_callid_t callid, ipc_call_t *call) 93 115 { 94 116 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 95 126 if (!char_iface->write) { 127 async_data_write_finalize(cid, NULL, 0); 96 128 ipc_answer_0(callid, ENOTSUP); 97 129 return; 98 130 } 99 100 size_t len;101 if (!async_data_write_receive(&callid, &len)) {102 // TODO handle protocol error103 return;104 }105 131 106 132 if (len > MAX_CHAR_RW_COUNT) { … … 110 136 char buf[MAX_CHAR_RW_COUNT]; 111 137 112 async_data_write_finalize(c allid, buf, len);138 async_data_write_finalize(cid, buf, len); 113 139 114 140 int ret = (*char_iface->write)(dev, buf, len); … … 116 142 ipc_answer_0(callid, ret); 117 143 } else { 144 // the operation was successful, return the number of data written 118 145 ipc_answer_1(callid, EOK, ret); 119 146 }
Note:
See TracChangeset
for help on using the changeset viewer.