Changeset a35b458 in mainline for uspace/srv/hid/output/output.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/output/output.c
r3061bc1 ra35b458 44 44 typedef struct { 45 45 link_t link; 46 46 47 47 size_t size; 48 48 unsigned int flags; … … 56 56 { 57 57 assert(ops->get_dimensions); 58 58 59 59 outdev_t *dev = (outdev_t *) malloc(sizeof(outdev_t)); 60 60 if (dev == NULL) 61 61 return NULL; 62 62 63 63 link_initialize(&dev->link); 64 64 65 65 dev->ops = *ops; 66 66 dev->data = data; 67 67 68 68 ops->get_dimensions(dev, &dev->cols, &dev->rows); 69 69 dev->backbuf = chargrid_create(dev->cols, dev->rows, … … 73 73 return NULL; 74 74 } 75 75 76 76 list_append(&dev->link, &outdevs); 77 77 return dev; … … 81 81 { 82 82 errno_t ret = EOK; 83 83 84 84 list_foreach(outdevs, link, outdev_t, dev) { 85 85 assert(dev->ops.yield); 86 86 87 87 errno_t rc = dev->ops.yield(dev); 88 88 if (rc != EOK) 89 89 ret = rc; 90 90 } 91 91 92 92 async_answer_0(iid, ret); 93 93 } … … 96 96 { 97 97 errno_t ret = EOK; 98 98 99 99 list_foreach(outdevs, link, outdev_t, dev) { 100 100 assert(dev->ops.claim); 101 101 102 102 errno_t rc = dev->ops.claim(dev); 103 103 if (rc != EOK) 104 104 ret = rc; 105 105 } 106 106 107 107 async_answer_0(iid, ret); 108 108 } … … 112 112 sysarg_t cols = MAX_COLS; 113 113 sysarg_t rows = MAX_ROWS; 114 114 115 115 list_foreach(outdevs, link, outdev_t, dev) { 116 116 cols = min(cols, dev->cols); 117 117 rows = min(rows, dev->rows); 118 118 } 119 119 120 120 async_answer_2(iid, EOK, cols, rows); 121 121 } … … 124 124 { 125 125 console_caps_t caps = 0; 126 126 127 127 list_foreach(outdevs, link, outdev_t, dev) { 128 128 assert(dev->ops.get_caps); 129 129 130 130 caps |= dev->ops.get_caps(dev); 131 131 } 132 132 133 133 async_answer_1(iid, EOK, caps); 134 134 } … … 143 143 } 144 144 } 145 145 146 146 if (frontbuf == NULL) { 147 147 async_answer_0(iid, ENOENT); 148 148 return NULL; 149 149 } 150 150 151 151 return frontbuf; 152 152 } … … 159 159 return; 160 160 } 161 161 162 162 link_initialize(&frontbuf->link); 163 163 164 164 ipc_callid_t callid; 165 165 if (!async_share_out_receive(&callid, &frontbuf->size, … … 169 169 return; 170 170 } 171 171 172 172 errno_t rc = async_share_out_finalize(callid, &frontbuf->data); 173 173 if ((rc != EOK) || (frontbuf->data == AS_MAP_FAILED)) { … … 176 176 return; 177 177 } 178 178 179 179 list_append(&frontbuf->link, &frontbufs); 180 180 async_answer_1(iid, EOK, (sysarg_t) frontbuf); … … 186 186 if (frontbuf == NULL) 187 187 return; 188 188 189 189 list_remove(&frontbuf->link); 190 190 as_area_destroy(frontbuf->data); 191 191 free(frontbuf); 192 192 193 193 async_answer_0(iid, EOK); 194 194 } … … 199 199 if (frontbuf == NULL) 200 200 return; 201 201 202 202 chargrid_t *buf = (chargrid_t *) frontbuf->data; 203 203 bool visible = chargrid_get_cursor_visibility(buf); 204 204 205 205 sysarg_t col; 206 206 sysarg_t row; 207 207 chargrid_get_cursor(buf, &col, &row); 208 208 209 209 list_foreach(outdevs, link, outdev_t, dev) { 210 210 assert(dev->ops.cursor_update); 211 211 212 212 sysarg_t prev_col; 213 213 sysarg_t prev_row; 214 214 chargrid_get_cursor(dev->backbuf, &prev_col, &prev_row); 215 215 216 216 chargrid_set_cursor(dev->backbuf, col, row); 217 217 chargrid_set_cursor_visibility(dev->backbuf, visible); 218 218 219 219 dev->ops.cursor_update(dev, prev_col, prev_row, col, row, 220 220 visible); … … 222 222 223 223 } 224 224 225 225 async_answer_0(iid, EOK); 226 226 } … … 233 233 (console_style_t) IPC_GET_ARG1(*icall); 234 234 } 235 235 236 236 async_answer_0(iid, EOK); 237 237 } … … 248 248 (console_color_attr_t) IPC_GET_ARG3(*icall); 249 249 } 250 250 251 251 async_answer_0(iid, EOK); 252 252 } … … 259 259 dev->attrs.val.rgb.fgcolor = IPC_GET_ARG2(*icall); 260 260 } 261 261 262 262 async_answer_0(iid, EOK); 263 263 } … … 266 266 { 267 267 assert(dev->ops.char_update); 268 268 269 269 sysarg_t top_row = chargrid_get_top_row(buf); 270 270 271 271 if (dev->top_row == top_row) 272 272 return false; 273 273 274 274 dev->top_row = top_row; 275 275 276 276 for (sysarg_t y = 0; y < dev->rows; y++) { 277 277 for (sysarg_t x = 0; x < dev->cols; x++) { … … 281 281 chargrid_charfield_at(dev->backbuf, x, y); 282 282 bool update = false; 283 283 284 284 if (front_field->ch != back_field->ch) { 285 285 back_field->ch = front_field->ch; 286 286 update = true; 287 287 } 288 288 289 289 if (!attrs_same(front_field->attrs, back_field->attrs)) { 290 290 back_field->attrs = front_field->attrs; 291 291 update = true; 292 292 } 293 293 294 294 front_field->flags &= ~CHAR_FLAG_DIRTY; 295 295 296 296 if (update) 297 297 dev->ops.char_update(dev, x, y); 298 298 } 299 299 } 300 300 301 301 return true; 302 302 } … … 307 307 if (frontbuf == NULL) 308 308 return; 309 309 310 310 chargrid_t *buf = (chargrid_t *) frontbuf->data; 311 311 312 312 list_foreach(outdevs, link, outdev_t, dev) { 313 313 assert(dev->ops.char_update); 314 314 315 315 if (srv_update_scroll(dev, buf)) 316 316 continue; 317 317 318 318 for (sysarg_t y = 0; y < dev->rows; y++) { 319 319 for (sysarg_t x = 0; x < dev->cols; x++) { … … 323 323 chargrid_charfield_at(dev->backbuf, x, y); 324 324 bool update = false; 325 325 326 326 if ((front_field->flags & CHAR_FLAG_DIRTY) == 327 327 CHAR_FLAG_DIRTY) { … … 330 330 update = true; 331 331 } 332 332 333 333 if (!attrs_same(front_field->attrs, 334 334 back_field->attrs)) { … … 336 336 update = true; 337 337 } 338 338 339 339 front_field->flags &= ~CHAR_FLAG_DIRTY; 340 340 } 341 341 342 342 if (update) 343 343 dev->ops.char_update(dev, x, y); 344 344 } 345 345 } 346 346 347 347 dev->ops.flush(dev); 348 348 } 349 350 349 350 351 351 async_answer_0(iid, EOK); 352 352 } … … 357 357 if (frontbuf == NULL) 358 358 return; 359 359 360 360 chargrid_t *buf = (chargrid_t *) frontbuf->data; 361 361 362 362 list_foreach(outdevs, link, outdev_t, dev) { 363 363 assert(dev->ops.char_update); 364 364 365 365 if (srv_update_scroll(dev, buf)) 366 366 continue; 367 367 368 368 sysarg_t col = IPC_GET_ARG2(*icall); 369 369 sysarg_t row = IPC_GET_ARG3(*icall); 370 370 371 371 sysarg_t cols = IPC_GET_ARG4(*icall); 372 372 sysarg_t rows = IPC_GET_ARG5(*icall); 373 373 374 374 for (sysarg_t y = 0; y < rows; y++) { 375 375 for (sysarg_t x = 0; x < cols; x++) { … … 378 378 charfield_t *back_field = 379 379 chargrid_charfield_at(dev->backbuf, col + x, row + y); 380 380 381 381 back_field->ch = front_field->ch; 382 382 back_field->attrs = front_field->attrs; … … 395 395 /* Accept the connection */ 396 396 async_answer_0(iid, EOK); 397 397 398 398 while (true) { 399 399 ipc_call_t call; 400 400 ipc_callid_t callid = async_get_call(&call); 401 401 402 402 if (!IPC_GET_IMETHOD(call)) { 403 403 async_answer_0(callid, EOK); 404 404 break; 405 405 } 406 406 407 407 switch (IPC_GET_IMETHOD(call)) { 408 408 case OUTPUT_YIELD: … … 418 418 srv_get_caps(callid, &call); 419 419 break; 420 420 421 421 case OUTPUT_FRONTBUF_CREATE: 422 422 srv_frontbuf_create(callid, &call); … … 425 425 srv_frontbuf_destroy(callid, &call); 426 426 break; 427 427 428 428 case OUTPUT_CURSOR_UPDATE: 429 429 srv_cursor_update(callid, &call); … … 444 444 srv_damage(callid, &call); 445 445 break; 446 446 447 447 default: 448 448 async_answer_0(callid, EINVAL); … … 462 462 return 1; 463 463 } 464 464 465 465 printf("%s: HelenOS output service\n", NAME); 466 466 467 467 /* Register server */ 468 468 async_set_fallback_port_handler(client_connection, NULL); … … 472 472 return rc; 473 473 } 474 474 475 475 service_id_t service_id; 476 476 rc = loc_service_register(argv[1], &service_id); … … 479 479 return rc; 480 480 } 481 481 482 482 if (!config_key_exists("console")) { 483 483 ega_init(); 484 484 } 485 485 486 486 chardev_init(); 487 487 488 488 printf("%s: Accepting connections\n", NAME); 489 489 task_retval(0); 490 490 async_manager(); 491 491 492 492 /* Never reached */ 493 493 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.