Changeset a46e56b in mainline for uspace/lib/c/generic/io/con_srv.c
- Timestamp:
- 2018-03-22T06:49:35Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 77f0a1d
- Parents:
- 3e242d2
- git-author:
- Jakub Jermar <jakub@…> (2018-03-21 23:29:06)
- git-committer:
- Jakub Jermar <jakub@…> (2018-03-22 06:49:35)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/io/con_srv.c
r3e242d2 ra46e56b 66 66 } 67 67 68 static void con_read_srv(con_srv_t *srv, cap_call_handle_t c allid,68 static void con_read_srv(con_srv_t *srv, cap_call_handle_t chandle, 69 69 ipc_call_t *call) 70 70 { … … 72 72 size_t size; 73 73 errno_t rc; 74 cap_call_handle_t rcall id;75 76 if (!async_data_read_receive(&rcall id, &size)) {77 async_answer_0(c allid, EINVAL);74 cap_call_handle_t rcall_handle; 75 76 if (!async_data_read_receive(&rcall_handle, &size)) { 77 async_answer_0(chandle, EINVAL); 78 78 return; 79 79 } … … 81 81 buf = malloc(size); 82 82 if (buf == NULL) { 83 async_answer_0(rcall id, ENOMEM);84 async_answer_0(c allid, ENOMEM);83 async_answer_0(rcall_handle, ENOMEM); 84 async_answer_0(chandle, ENOMEM); 85 85 return; 86 86 } 87 87 88 88 if (srv->srvs->ops->read == NULL) { 89 async_answer_0(rcall id, ENOTSUP);90 async_answer_0(c allid, ENOTSUP);89 async_answer_0(rcall_handle, ENOTSUP); 90 async_answer_0(chandle, ENOTSUP); 91 91 free(buf); 92 92 return; … … 96 96 rc = srv->srvs->ops->read(srv, buf, size, &nread); 97 97 if (rc != EOK) { 98 async_answer_0(rcall id, rc);99 async_answer_0(c allid, rc);98 async_answer_0(rcall_handle, rc); 99 async_answer_0(chandle, rc); 100 100 free(buf); 101 101 return; 102 102 } 103 103 104 async_data_read_finalize(rcall id, buf, nread);104 async_data_read_finalize(rcall_handle, buf, nread); 105 105 free(buf); 106 106 107 async_answer_1(c allid, EOK, nread);108 } 109 110 static void con_write_srv(con_srv_t *srv, cap_call_handle_t c allid,107 async_answer_1(chandle, EOK, nread); 108 } 109 110 static void con_write_srv(con_srv_t *srv, cap_call_handle_t chandle, 111 111 ipc_call_t *call) 112 112 { … … 117 117 rc = async_data_write_accept(&data, false, 0, 0, 0, &size); 118 118 if (rc != EOK) { 119 async_answer_0(c allid, rc);119 async_answer_0(chandle, rc); 120 120 return; 121 121 } 122 122 123 123 if (srv->srvs->ops->write == NULL) { 124 async_answer_0(c allid, ENOTSUP);124 async_answer_0(chandle, ENOTSUP); 125 125 return; 126 126 } … … 130 130 free(data); 131 131 132 async_answer_1(c allid, rc, nwritten);133 } 134 135 static void con_sync_srv(con_srv_t *srv, cap_call_handle_t c allid,132 async_answer_1(chandle, rc, nwritten); 133 } 134 135 static void con_sync_srv(con_srv_t *srv, cap_call_handle_t chandle, 136 136 ipc_call_t *call) 137 137 { 138 138 if (srv->srvs->ops->sync == NULL) { 139 async_answer_0(c allid, ENOTSUP);139 async_answer_0(chandle, ENOTSUP); 140 140 return; 141 141 } 142 142 143 143 srv->srvs->ops->sync(srv); 144 async_answer_0(c allid, EOK);145 } 146 147 static void con_clear_srv(con_srv_t *srv, cap_call_handle_t c allid,144 async_answer_0(chandle, EOK); 145 } 146 147 static void con_clear_srv(con_srv_t *srv, cap_call_handle_t chandle, 148 148 ipc_call_t *call) 149 149 { 150 150 if (srv->srvs->ops->clear == NULL) { 151 async_answer_0(c allid, ENOTSUP);151 async_answer_0(chandle, ENOTSUP); 152 152 return; 153 153 } 154 154 155 155 srv->srvs->ops->clear(srv); 156 async_answer_0(c allid, EOK);157 } 158 159 static void con_set_pos_srv(con_srv_t *srv, cap_call_handle_t c allid,156 async_answer_0(chandle, EOK); 157 } 158 159 static void con_set_pos_srv(con_srv_t *srv, cap_call_handle_t chandle, 160 160 ipc_call_t *call) 161 161 { … … 167 167 168 168 if (srv->srvs->ops->set_pos == NULL) { 169 async_answer_0(c allid, ENOTSUP);169 async_answer_0(chandle, ENOTSUP); 170 170 return; 171 171 } 172 172 173 173 srv->srvs->ops->set_pos(srv, col, row); 174 async_answer_0(c allid, EOK);175 } 176 177 static void con_get_pos_srv(con_srv_t *srv, cap_call_handle_t c allid,174 async_answer_0(chandle, EOK); 175 } 176 177 static void con_get_pos_srv(con_srv_t *srv, cap_call_handle_t chandle, 178 178 ipc_call_t *call) 179 179 { … … 183 183 184 184 if (srv->srvs->ops->get_pos == NULL) { 185 async_answer_0(c allid, ENOTSUP);185 async_answer_0(chandle, ENOTSUP); 186 186 return; 187 187 } 188 188 189 189 rc = srv->srvs->ops->get_pos(srv, &col, &row); 190 async_answer_2(c allid, rc, col, row);191 } 192 193 static void con_get_size_srv(con_srv_t *srv, cap_call_handle_t c allid,190 async_answer_2(chandle, rc, col, row); 191 } 192 193 static void con_get_size_srv(con_srv_t *srv, cap_call_handle_t chandle, 194 194 ipc_call_t *call) 195 195 { … … 199 199 200 200 if (srv->srvs->ops->get_size == NULL) { 201 async_answer_0(c allid, ENOTSUP);201 async_answer_0(chandle, ENOTSUP); 202 202 return; 203 203 } 204 204 205 205 rc = srv->srvs->ops->get_size(srv, &cols, &rows); 206 async_answer_2(c allid, rc, cols, rows);207 } 208 209 static void con_get_color_cap_srv(con_srv_t *srv, cap_call_handle_t c allid,206 async_answer_2(chandle, rc, cols, rows); 207 } 208 209 static void con_get_color_cap_srv(con_srv_t *srv, cap_call_handle_t chandle, 210 210 ipc_call_t *call) 211 211 { … … 214 214 215 215 if (srv->srvs->ops->get_color_cap == NULL) { 216 async_answer_0(c allid, ENOTSUP);216 async_answer_0(chandle, ENOTSUP); 217 217 return; 218 218 } 219 219 220 220 rc = srv->srvs->ops->get_color_cap(srv, &ccap); 221 async_answer_1(c allid, rc, (sysarg_t)ccap);222 } 223 224 static void con_set_style_srv(con_srv_t *srv, cap_call_handle_t c allid,221 async_answer_1(chandle, rc, (sysarg_t)ccap); 222 } 223 224 static void con_set_style_srv(con_srv_t *srv, cap_call_handle_t chandle, 225 225 ipc_call_t *call) 226 226 { … … 230 230 231 231 if (srv->srvs->ops->set_style == NULL) { 232 async_answer_0(c allid, ENOTSUP);232 async_answer_0(chandle, ENOTSUP); 233 233 return; 234 234 } 235 235 236 236 srv->srvs->ops->set_style(srv, style); 237 async_answer_0(c allid, EOK);238 } 239 240 static void con_set_color_srv(con_srv_t *srv, cap_call_handle_t c allid,237 async_answer_0(chandle, EOK); 238 } 239 240 static void con_set_color_srv(con_srv_t *srv, cap_call_handle_t chandle, 241 241 ipc_call_t *call) 242 242 { … … 250 250 251 251 if (srv->srvs->ops->set_color == NULL) { 252 async_answer_0(c allid, ENOTSUP);252 async_answer_0(chandle, ENOTSUP); 253 253 return; 254 254 } 255 255 256 256 srv->srvs->ops->set_color(srv, bgcolor, fgcolor, flags); 257 async_answer_0(c allid, EOK);258 } 259 260 static void con_set_rgb_color_srv(con_srv_t *srv, cap_call_handle_t c allid,257 async_answer_0(chandle, EOK); 258 } 259 260 static void con_set_rgb_color_srv(con_srv_t *srv, cap_call_handle_t chandle, 261 261 ipc_call_t *call) 262 262 { … … 268 268 269 269 if (srv->srvs->ops->set_rgb_color == NULL) { 270 async_answer_0(c allid, ENOTSUP);270 async_answer_0(chandle, ENOTSUP); 271 271 return; 272 272 } 273 273 274 274 srv->srvs->ops->set_rgb_color(srv, bgcolor, fgcolor); 275 async_answer_0(c allid, EOK);276 } 277 278 static void con_set_cursor_visibility_srv(con_srv_t *srv, cap_call_handle_t c allid,275 async_answer_0(chandle, EOK); 276 } 277 278 static void con_set_cursor_visibility_srv(con_srv_t *srv, cap_call_handle_t chandle, 279 279 ipc_call_t *call) 280 280 { … … 284 284 285 285 if (srv->srvs->ops->set_cursor_visibility == NULL) { 286 async_answer_0(c allid, ENOTSUP);286 async_answer_0(chandle, ENOTSUP); 287 287 return; 288 288 } 289 289 290 290 srv->srvs->ops->set_cursor_visibility(srv, show); 291 async_answer_0(c allid, EOK);292 } 293 294 static void con_get_event_srv(con_srv_t *srv, cap_call_handle_t c allid,291 async_answer_0(chandle, EOK); 292 } 293 294 static void con_get_event_srv(con_srv_t *srv, cap_call_handle_t chandle, 295 295 ipc_call_t *call) 296 296 { … … 300 300 301 301 if (srv->srvs->ops->get_event == NULL) { 302 async_answer_0(c allid, ENOTSUP);302 async_answer_0(chandle, ENOTSUP); 303 303 return; 304 304 } … … 306 306 rc = srv->srvs->ops->get_event(srv, &event); 307 307 if (rc != EOK) { 308 async_answer_0(c allid, rc);308 async_answer_0(chandle, rc); 309 309 return; 310 310 } … … 312 312 rc = console_ev_encode(&event, &result); 313 313 if (rc != EOK) { 314 async_answer_0(c allid, rc);315 return; 316 } 317 318 async_answer_5(c allid, rc, IPC_GET_ARG1(result), IPC_GET_ARG2(result),314 async_answer_0(chandle, rc); 315 return; 316 } 317 318 async_answer_5(chandle, rc, IPC_GET_ARG1(result), IPC_GET_ARG2(result), 319 319 IPC_GET_ARG3(result), IPC_GET_ARG4(result), IPC_GET_ARG5(result)); 320 320 } … … 340 340 } 341 341 342 errno_t con_conn(cap_call_handle_t i id, ipc_call_t *icall, con_srvs_t *srvs)342 errno_t con_conn(cap_call_handle_t icall_handle, ipc_call_t *icall, con_srvs_t *srvs) 343 343 { 344 344 con_srv_t *srv; … … 346 346 347 347 /* Accept the connection */ 348 async_answer_0(i id, EOK);348 async_answer_0(icall_handle, EOK); 349 349 350 350 srv = con_srv_create(srvs); … … 366 366 while (true) { 367 367 ipc_call_t call; 368 cap_call_handle_t c allid= 0;369 370 while (c allid== 0) {368 cap_call_handle_t chandle = 0; 369 370 while (chandle == 0) { 371 371 /* XXX Need to be able to abort immediately */ 372 c allid= async_get_call_timeout(&call,372 chandle = async_get_call_timeout(&call, 373 373 srvs->abort_timeout); 374 374 375 375 if (srv->srvs->aborted) { 376 if (c allid!= 0)377 async_answer_0(c allid, EINTR);376 if (chandle != 0) 377 async_answer_0(chandle, EINTR); 378 378 break; 379 379 } 380 380 } 381 381 382 if (c allid== 0)382 if (chandle == 0) 383 383 break; 384 384 … … 387 387 if (!method) { 388 388 /* The other side has hung up */ 389 async_answer_0(c allid, EOK);389 async_answer_0(chandle, EOK); 390 390 break; 391 391 } … … 393 393 switch (method) { 394 394 case VFS_OUT_READ: 395 con_read_srv(srv, c allid, &call);395 con_read_srv(srv, chandle, &call); 396 396 break; 397 397 case VFS_OUT_WRITE: 398 con_write_srv(srv, c allid, &call);398 con_write_srv(srv, chandle, &call); 399 399 break; 400 400 case VFS_OUT_SYNC: 401 con_sync_srv(srv, c allid, &call);401 con_sync_srv(srv, chandle, &call); 402 402 break; 403 403 case CONSOLE_CLEAR: 404 con_clear_srv(srv, c allid, &call);404 con_clear_srv(srv, chandle, &call); 405 405 break; 406 406 case CONSOLE_SET_POS: 407 con_set_pos_srv(srv, c allid, &call);407 con_set_pos_srv(srv, chandle, &call); 408 408 break; 409 409 case CONSOLE_GET_POS: 410 con_get_pos_srv(srv, c allid, &call);410 con_get_pos_srv(srv, chandle, &call); 411 411 break; 412 412 case CONSOLE_GET_SIZE: 413 con_get_size_srv(srv, c allid, &call);413 con_get_size_srv(srv, chandle, &call); 414 414 break; 415 415 case CONSOLE_GET_COLOR_CAP: 416 con_get_color_cap_srv(srv, c allid, &call);416 con_get_color_cap_srv(srv, chandle, &call); 417 417 break; 418 418 case CONSOLE_SET_STYLE: 419 con_set_style_srv(srv, c allid, &call);419 con_set_style_srv(srv, chandle, &call); 420 420 break; 421 421 case CONSOLE_SET_COLOR: 422 con_set_color_srv(srv, c allid, &call);422 con_set_color_srv(srv, chandle, &call); 423 423 break; 424 424 case CONSOLE_SET_RGB_COLOR: 425 con_set_rgb_color_srv(srv, c allid, &call);425 con_set_rgb_color_srv(srv, chandle, &call); 426 426 break; 427 427 case CONSOLE_SET_CURSOR_VISIBILITY: 428 con_set_cursor_visibility_srv(srv, c allid, &call);428 con_set_cursor_visibility_srv(srv, chandle, &call); 429 429 break; 430 430 case CONSOLE_GET_EVENT: 431 con_get_event_srv(srv, c allid, &call);431 con_get_event_srv(srv, chandle, &call); 432 432 break; 433 433 default: 434 async_answer_0(c allid, ENOTSUP);434 async_answer_0(chandle, ENOTSUP); 435 435 } 436 436 }
Note:
See TracChangeset
for help on using the changeset viewer.