Changeset 68a552f in mainline for uspace/lib/c/generic/io/console.c
- Timestamp:
- 2021-02-22T19:52:08Z (3 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 26853ebc
- Parents:
- 2ab8ab3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/io/console.c
r2ab8ab3 r68a552f 1 1 /* 2 * Copyright (c) 2021 Jiri Svoboda 2 3 * Copyright (c) 2006 Josef Cejka 3 4 * Copyright (c) 2006 Jakub Vana 4 * Copyright (c) 2008 Jiri Svoboda5 5 * All rights reserved. 6 6 * … … 35 35 */ 36 36 37 #include <as.h> 37 38 #include <libc.h> 38 39 #include <async.h> … … 264 265 } 265 266 267 /** Create a shared buffer for fast rendering to the console. 268 * 269 * @param ctrl Console 270 * @param cols Number of columns 271 * @param rows Number of rows 272 * @param rbuf Place to store pointer to the shared buffer 273 * @return EOK on success or an error code 274 */ 275 errno_t console_map(console_ctrl_t *ctrl, sysarg_t cols, sysarg_t rows, 276 charfield_t **rbuf) 277 { 278 async_exch_t *exch = NULL; 279 void *buf; 280 aid_t req; 281 ipc_call_t answer; 282 size_t asize; 283 errno_t rc; 284 285 exch = async_exchange_begin(ctrl->output_sess); 286 req = async_send_2(exch, CONSOLE_MAP, cols, rows, &answer); 287 if (rc != EOK) 288 goto error; 289 290 asize = PAGES2SIZE(SIZE2PAGES(cols * rows * sizeof(charfield_t))); 291 292 rc = async_share_in_start_0_0(exch, asize, &buf); 293 if (rc != EOK) { 294 async_forget(req); 295 goto error; 296 } 297 298 async_exchange_end(exch); 299 exch = NULL; 300 301 async_wait_for(req, &rc); 302 if (rc != EOK) 303 goto error; 304 305 *rbuf = (charfield_t *)buf; 306 return EOK; 307 error: 308 if (exch != NULL) 309 async_exchange_end(exch); 310 return rc; 311 } 312 313 /** Unmap console shared buffer. 314 * 315 * @param ctrl Console 316 * @param buf Buffer 317 */ 318 void console_unmap(console_ctrl_t *ctrl, charfield_t *buf) 319 { 320 as_area_destroy(buf); 321 } 322 323 /** Update console rectangle from shared buffer. 324 * 325 * @param ctrl Console 326 * @param c0 Column coordinate of top-left corner (inclusive) 327 * @param r0 Row coordinate of top-left corner (inclusive) 328 * @param c1 Column coordinate of bottom-right corner (exclusive) 329 * @param r1 Row coordinate of bottom-right corner (exclusive) 330 * 331 * @return EOK on sucess or an error code 332 */ 333 errno_t console_update(console_ctrl_t *ctrl, sysarg_t c0, sysarg_t r0, 334 sysarg_t c1, sysarg_t r1) 335 { 336 async_exch_t *exch = async_exchange_begin(ctrl->output_sess); 337 errno_t rc = async_req_4_0(exch, CONSOLE_UPDATE, c0, r0, c1, r1); 338 async_exchange_end(exch); 339 340 return rc; 341 } 342 266 343 /** @} 267 344 */
Note:
See TracChangeset
for help on using the changeset viewer.