Changeset 1601f3c in mainline
- Timestamp:
- 2009-05-21T15:32:42Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7d158097
- Parents:
- a095d20
- Location:
- uspace/srv/console
- Files:
-
- 7 edited
- 10 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/console/Makefile
ra095d20 r1601f3c 43 43 44 44 OUTPUT = console 45 45 46 GENERIC_SOURCES = \ 46 47 console.c \ … … 49 50 gcons.c 50 51 51 IMAGES = helenos.ppm nameic.ppm cons_selected.ppm cons_idle.ppm \ 52 cons_has_data.ppm cons_kernel.ppm anim_1.ppm anim_2.ppm anim_3.ppm \ 53 anim_4.ppm 54 55 ARCH_SOURCES = 52 IMAGES = \ 53 gfx/helenos.ppm \ 54 gfx/nameic.ppm \ 55 gfx/cons_selected.ppm \ 56 gfx/cons_idle.ppm \ 57 gfx/cons_has_data.ppm \ 58 gfx/cons_kernel.ppm \ 59 gfx/anim_1.ppm \ 60 gfx/anim_2.ppm \ 61 gfx/anim_3.ppm \ 62 gfx/anim_4.ppm 56 63 57 64 GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES))) \ 58 $(addsuffix .o,$(basename $(IMAGES))) 59 ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES))) 65 $(addsuffix .o,$(basename $(IMAGES))) 60 66 61 OBJECTS := $(GENERIC_OBJECTS) $(ARCH_OBJECTS)67 OBJECTS := $(GENERIC_OBJECTS) 62 68 63 69 .PHONY: all clean depend disasm -
uspace/srv/console/console.c
ra095d20 r1601f3c 28 28 29 29 /** @addtogroup console 30 * @{ 30 * @{ 31 31 */ 32 32 /** @file … … 56 56 #include "gcons.h" 57 57 58 #define MAX_KEYREQUESTS_BUFFERED 32 59 60 #define NAME "console" 58 #define NAME "console" 59 60 #define MAX_KEYREQUESTS_BUFFERED 32 61 62 /** Size of cwrite_buf. */ 63 #define CWRITE_BUF_SIZE 256 61 64 62 65 /** Index of currently used virtual console. … … 70 73 /** Information about framebuffer */ 71 74 struct { 72 int phone; 73 ipcarg_t rows; 74 ipcarg_t cols; 75 int phone; /**< Framebuffer phone */ 76 ipcarg_t rows; /**< Framebuffer rows */ 77 ipcarg_t cols; /**< Framebuffer columns */ 75 78 } fb_info; 76 79 77 80 typedef struct { 78 keybuffer_t keybuffer; /**< Buffer for incoming keys. */ 81 keybuffer_t keybuffer; /**< Buffer for incoming keys. */ 82 79 83 /** Buffer for unsatisfied request for keys. */ 80 84 FIFO_CREATE_STATIC(keyrequests, ipc_callid_t, 81 MAX_KEYREQUESTS_BUFFERED); 82 int keyrequest_counter; /**< Number of requests in buffer. */ 83 int client_phone; /**< Phone to connected client. */ 84 int used; /**< 1 if this virtual console is 85 * connected to some client.*/ 86 screenbuffer_t screenbuffer; /**< Screenbuffer for saving screen 87 * contents and related settings. */ 85 MAX_KEYREQUESTS_BUFFERED); 86 87 int keyrequest_counter; /**< Number of requests in buffer. */ 88 int client_phone; /**< Phone to connected client. */ 89 int used; /**< 1 if this virtual console is 90 connected to some client. */ 91 screenbuffer_t screenbuffer; /**< Screenbuffer for saving screen 92 contents and related settings. */ 88 93 } connection_t; 89 94 90 static connection_t connections[CONSOLE_COUNT]; /**< Array of data for virtual 91 * consoles */ 92 static keyfield_t *interbuffer = NULL; /**< Pointer to memory shared 93 *with framebufer used for94 * faster virtual console 95 * switching */ 95 /** Array of data for virtual consoles */ 96 static connection_t connections[CONSOLE_COUNT]; 97 98 /** Pointer to memory shared with framebufer used for 99 faster virtual console switching */ 100 static keyfield_t *interbuffer = NULL; 96 101 97 102 /** Information on row-span yet unsent to FB driver. */ 98 103 struct { 99 int row; 100 int col; 101 int n;/**< Width of the span. */104 int row; /**< Row where the span lies. */ 105 int col; /**< Leftmost column of the span. */ 106 int cnt; /**< Width of the span. */ 102 107 } fb_pending; 103 104 /** Size of cwrite_buf. */105 #define CWRITE_BUF_SIZE 256106 108 107 109 /** Buffer for receiving data via the CONSOLE_WRITE call from the client. */ 108 110 static char cwrite_buf[CWRITE_BUF_SIZE]; 109 110 static void fb_putchar(wchar_t c, int row, int col);111 112 111 113 112 /** Find unused virtual console. … … 122 121 return i; 123 122 } 123 124 124 return -1; 125 125 } … … 186 186 set_style(attrs->a.s.style); 187 187 break; 188 189 188 case at_idx: 190 189 set_color(attrs->a.i.fg_color, attrs->a.i.bg_color, 191 190 attrs->a.i.flags); 192 191 break; 193 194 192 case at_rgb: 195 193 set_rgb_color(attrs->a.r.fg_color, attrs->a.r.bg_color); … … 201 199 static void fb_update_area(connection_t *conn, int x, int y, int w, int h) 202 200 { 203 int i , j;204 int rc;201 int i; 202 int j; 205 203 attrs_t *attrs; 206 204 keyfield_t *field; 207 205 208 206 if (interbuffer) { 209 207 for (j = 0; j < h; j++) { 210 208 for (i = 0; i < w; i++) { 211 209 interbuffer[i + j * w] = 212 *get_field_at(&conn->screenbuffer, 213 x + i, y + j); 210 *get_field_at(&conn->screenbuffer, x + i, y + j); 214 211 } 215 212 } 216 217 rc =async_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA,213 214 async_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA, 218 215 x, y, w, h); 219 } else {220 rc = ENOTSUP;221 }222 223 if (rc != 0) {224 /*225 attrs = &conn->screenbuffer.attrs;226 227 for (j = 0; j < h; j++) {228 for (i = 0; i < w; i++) {229 field = get_field_at(&conn->screenbuffer,230 x + i, y + j);231 if (!attrs_same(*attrs, field->attrs))232 set_attrs(&field->attrs);233 attrs = &field->attrs;234 235 fb_putchar(field->character, y + j, x + i);236 }237 }*/238 216 } 239 217 } … … 242 220 static void fb_pending_flush(void) 243 221 { 244 screenbuffer_t *scr; 245 246 scr = &(connections[active_console].screenbuffer); 247 248 if (fb_pending.n > 0) { 222 screenbuffer_t *scr 223 = &(connections[active_console].screenbuffer); 224 225 if (fb_pending.cnt > 0) { 249 226 fb_update_area(&connections[active_console], fb_pending.col, 250 fb_pending.row, fb_pending. n, 1);251 fb_pending. n= 0;227 fb_pending.row, fb_pending.cnt, 1); 228 fb_pending.cnt = 0; 252 229 } 253 230 } … … 257 234 * This adds the cell to the pending rowspan if possible. Otherwise 258 235 * the old span is flushed first. 236 * 259 237 */ 260 238 static void cell_mark_changed(int row, int col) 261 239 { 262 if (fb_pending. n!= 0) {263 if ( row != fb_pending.row ||264 col != fb_pending.col + fb_pending.n) {240 if (fb_pending.cnt != 0) { 241 if ((row != fb_pending.row) 242 || (col != fb_pending.col + fb_pending.cnt)) { 265 243 fb_pending_flush(); 266 244 } 267 245 } 268 269 if (fb_pending. n== 0) {246 247 if (fb_pending.cnt == 0) { 270 248 fb_pending.row = row; 271 249 fb_pending.col = col; 272 250 } 273 274 ++fb_pending.n; 275 } 276 251 252 fb_pending.cnt++; 253 } 277 254 278 255 /** Print a character to the active VC with buffering. */ … … 287 264 bool flush_cursor = false; 288 265 screenbuffer_t *scr = &(connections[console].screenbuffer); 289 266 290 267 switch (ch) { 291 268 case '\n': … … 299 276 case '\t': 300 277 scr->position_x += 8; 301 scr->position_x -= scr->position_x % 8; 278 scr->position_x -= scr->position_x % 8; 302 279 break; 303 280 case '\b': … … 309 286 screenbuffer_putchar(scr, ' '); 310 287 break; 311 default: 288 default: 312 289 if (console == active_console) 313 290 cell_mark_changed(scr->position_y, scr->position_x); 314 291 315 292 screenbuffer_putchar(scr, ch); 316 293 scr->position_x++; 317 294 } 318 295 319 296 if (scr->position_x >= scr->size_x) { 320 297 flush_cursor = true; … … 330 307 async_msg_1(fb_info.phone, FB_SCROLL, 1); 331 308 } 332 309 333 310 scr->position_x = scr->position_x % scr->size_x; 334 311 335 312 if (console == active_console && flush_cursor) 336 313 curs_goto(scr->position_y, scr->position_x); … … 341 318 { 342 319 connection_t *conn; 343 int i, j, rc; 320 int i; 321 int j; 322 int rc; 344 323 keyfield_t *field; 345 324 attrs_t *attrs; … … 347 326 if (newcons == active_console) 348 327 return; 349 328 350 329 fb_pending_flush(); 351 330 352 331 if (newcons == KERNEL_CONSOLE) { 353 332 async_serialize_start(); … … 357 336 kbd_yield(); 358 337 async_serialize_end(); 359 338 360 339 361 340 if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) { … … 409 388 attrs = &field->attrs; 410 389 if ((field->character == ' ') && 411 (attrs_same(field->attrs, 412 conn->screenbuffer.attrs))) 390 (attrs_same(field->attrs, conn->screenbuffer.attrs))) 413 391 continue; 414 392 415 393 fb_putchar(field->character, j, i); 416 394 } … … 436 414 437 415 /* Ignore parameters, the connection is alread opened */ 438 while ( 1) {416 while (true) { 439 417 callid = async_get_call(&call); 440 418 switch (IPC_GET_METHOD(call)) { … … 461 439 ev.c = IPC_GET_ARG4(call); 462 440 463 /* switch to another virtual console */ 464 441 /* Switch to another virtual console */ 465 442 conn = &connections[active_console]; 466 443 467 444 if ((ev.key >= KC_F1) && (ev.key < KC_F1 + 468 445 CONSOLE_COUNT) && ((ev.mods & KM_CTRL) == 0)) { … … 474 451 } 475 452 476 /* if client is awaiting key, send it */477 if (conn->keyrequest_counter > 0) { 453 /* If client is awaiting key, send it */ 454 if (conn->keyrequest_counter > 0) { 478 455 conn->keyrequest_counter--; 479 456 ipc_answer_4(fifo_pop(conn->keyrequests), EOK, … … 481 458 break; 482 459 } 483 460 484 461 keybuffer_push(&conn->keybuffer, &ev); 485 462 retval = 0; 486 463 487 464 break; 488 465 default: … … 500 477 wchar_t ch; 501 478 size_t off; 502 479 503 480 if (!ipc_data_write_receive(&callid, &size)) { 504 481 ipc_answer_0(callid, EINVAL); … … 506 483 return; 507 484 } 508 485 509 486 if (size > CWRITE_BUF_SIZE) 510 487 size = CWRITE_BUF_SIZE; 511 488 512 489 (void) ipc_data_write_finalize(callid, cwrite_buf, size); 513 490 514 491 async_serialize_start(); 515 492 516 493 off = 0; 517 494 while (off < size) { … … 519 496 write_char(consnum, ch); 520 497 } 521 498 522 499 async_serialize_end(); 523 500 524 501 gcons_notify_char(consnum); 525 502 ipc_answer_1(rid, EOK, size); … … 553 530 ipc_answer_0(iid, EOK); 554 531 555 while ( 1) {532 while (true) { 556 533 async_serialize_end(); 557 534 callid = async_get_call(&call); … … 562 539 arg3 = 0; 563 540 arg4 = 0; 564 541 565 542 switch (IPC_GET_METHOD(call)) { 566 543 case IPC_M_PHONE_HUNGUP: … … 609 586 if (consnum == active_console) { 610 587 async_req_0_0(fb_info.phone, FB_FLUSH); 611 588 612 589 scr = &(connections[consnum].screenbuffer); 613 590 curs_goto(scr->position_y, scr->position_x); … … 651 628 /* buffer is empty -> store request */ 652 629 if (conn->keyrequest_counter < 653 MAX_KEYREQUESTS_BUFFERED) { 630 MAX_KEYREQUESTS_BUFFERED) { 654 631 fifo_push(conn->keyrequests, callid); 655 632 conn->keyrequest_counter++; … … 744 721 } 745 722 connections[KERNEL_CONSOLE].used = 1; 746 723 747 724 /* Set up shared memory buffer. */ 748 725 ib_size = sizeof(keyfield_t) * fb_info.cols * fb_info.rows; 749 726 interbuffer = as_get_mappable_page(ib_size); 750 751 fb_pending. n= 0;752 727 728 fb_pending.cnt = 0; 729 753 730 if (as_area_create(interbuffer, ib_size, AS_AREA_READ | 754 731 AS_AREA_WRITE | AS_AREA_CACHEABLE) != interbuffer) { 755 732 interbuffer = NULL; 756 733 } 757 734 758 735 if (interbuffer) { 759 736 if (ipc_share_out_start(fb_info.phone, interbuffer, … … 775 752 if (event_subscribe(EVENT_KCONSOLE, 0) != EOK) 776 753 printf(NAME ": Error registering kconsole notifications\n"); 777 754 778 755 async_set_interrupt_received(interrupt_received); 779 756 -
uspace/srv/console/console.h
ra095d20 r1601f3c 28 28 29 29 /** @addtogroup console 30 * @{ 30 * @{ 31 31 */ 32 32 /** @file … … 36 36 #define __CONSOLE_H__ 37 37 38 #define KERNEL_CONSOLE 11 39 40 #define CONSOLE_COUNT 12 38 #define CONSOLE_COUNT 12 39 #define KERNEL_CONSOLE 11 41 40 42 41 #endif 43 42 44 43 /** @} 45 44 */ -
uspace/srv/console/gcons.c
ra095d20 r1601f3c 28 28 29 29 /** @addtogroup console 30 * @{ 30 * @{ 31 31 */ 32 32 /** @file … … 44 44 #include "gcons.h" 45 45 46 #define CONSOLE_TOP 47 #define CONSOLE_MARGIN 48 49 #define STATUS_START 50 #define STATUS_TOP 51 #define STATUS_SPACE 52 #define STATUS_WIDTH 53 #define STATUS_HEIGHT 54 55 #define MAIN_COLOR 46 #define CONSOLE_TOP 66 47 #define CONSOLE_MARGIN 6 48 49 #define STATUS_START 110 50 #define STATUS_TOP 8 51 #define STATUS_SPACE 4 52 #define STATUS_WIDTH 48 53 #define STATUS_HEIGHT 48 54 55 #define MAIN_COLOR 0xffffff 56 56 57 57 static int use_gcons = 0; … … 115 115 int i; 116 116 enum butstate state = console_state[consnum]; 117 117 118 118 vp_switch(cstatus_vp[consnum]); 119 119 if (ic_pixmaps[state] != -1) 120 120 async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], 121 121 ic_pixmaps[state]); 122 123 124 125 126 127 128 122 123 if (state != CONS_DISCONNECTED && state != CONS_KERNEL && 124 state != CONS_DISCONNECTED_SEL) { 125 snprintf(data, 5, "%d", consnum + 1); 126 for (i = 0; data[i]; i++) 127 tran_putch(data[i], 1, 2 + i); 128 } 129 129 } 130 130 … … 133 133 { 134 134 int i; 135 135 136 136 if (!use_gcons) 137 137 return; 138 138 139 139 if (active_console == KERNEL_CONSOLE) { 140 140 for (i = 0; i < CONSOLE_COUNT; i++) … … 150 150 } 151 151 active_console = consnum; 152 152 153 153 if (console_state[consnum] == CONS_DISCONNECTED) { 154 154 console_state[consnum] = CONS_DISCONNECTED_SEL; … … 157 157 console_state[consnum] = CONS_SELECTED; 158 158 redraw_state(consnum); 159 159 160 160 vp_switch(console_vp); 161 161 } … … 166 166 if (!use_gcons) 167 167 return; 168 169 if ( consnum == active_console||170 console_state[consnum] == CONS_HAS_DATA)171 return; 172 168 169 if ((consnum == active_console) || 170 (console_state[consnum] == CONS_HAS_DATA)) 171 return; 172 173 173 console_state[consnum] = CONS_HAS_DATA; 174 174 175 175 if (active_console == KERNEL_CONSOLE) 176 176 return; 177 177 178 178 redraw_state(consnum); 179 179 … … 186 186 if (!use_gcons) 187 187 return; 188 188 189 if (active_console == consnum) 189 190 console_state[consnum] = CONS_DISCONNECTED_SEL; … … 203 204 if (!use_gcons) 204 205 return; 206 205 207 if (active_console == consnum) 206 208 console_state[consnum] = CONS_SELECTED; 207 209 else 208 210 console_state[consnum] = CONS_IDLE; 209 211 210 212 if (active_console == KERNEL_CONSOLE) 211 213 return; 212 214 213 215 redraw_state(consnum); 214 216 vp_switch(console_vp); … … 226 228 227 229 /** Return x, where left <= x <= right && |a-x|==min(|a-x|) is smallest */ 228 static inline int limit(int a, int left, int right)230 static inline int limit(int a, int left, int right) 229 231 { 230 232 if (a < left) … … 247 249 mouse_x = limit(mouse_x + dx, 0, xres); 248 250 mouse_y = limit(mouse_y + dy, 0, yres); 249 251 250 252 async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y); 251 253 } … … 254 256 { 255 257 int status_start = STATUS_START + (xres - 800) / 2; 256 257 if ( y < STATUS_TOP || y >= STATUS_TOP + STATUS_HEIGHT)258 259 if ((y < STATUS_TOP) || (y >= STATUS_TOP + STATUS_HEIGHT)) 258 260 return -1; 259 261 … … 276 278 { 277 279 int conbut; 278 280 279 281 if (state) { 280 282 conbut = gcons_find_conbut(mouse_x, mouse_y); … … 285 287 } 286 288 return -1; 287 } 288 if (!state && !btn_pressed) 289 return -1; 289 } 290 291 if ((!state) && (!btn_pressed)) 292 return -1; 293 290 294 btn_pressed = 0; 291 295 292 296 conbut = gcons_find_conbut(mouse_x, mouse_y); 293 297 if (conbut == gcons_find_conbut(btn_x, btn_y)) 294 298 return conbut; 299 295 300 return -1; 296 301 } … … 308 313 char *shm; 309 314 int rc; 310 315 311 316 /* Create area */ 312 317 shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | … … 314 319 if (shm == MAP_FAILED) 315 320 return; 316 321 317 322 memcpy(shm, logo, size); 323 318 324 /* Send area */ 319 325 rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); 320 326 if (rc) 321 327 goto exit; 328 322 329 rc = ipc_share_out_start(fbphone, shm, PROTO_READ); 323 330 if (rc) 324 331 goto drop; 332 325 333 /* Draw logo */ 326 334 async_msg_2(fbphone, FB_DRAW_PPM, x, y); 335 327 336 drop: 328 337 /* Drop area */ 329 338 async_msg_0(fbphone, FB_DROP_SHM); 330 exit: 339 340 exit: 331 341 /* Remove area */ 332 342 munmap(shm, size); 333 343 } 334 344 335 extern char _binary_ helenos_ppm_start[0];336 extern int _binary_ helenos_ppm_size;337 extern char _binary_ nameic_ppm_start[0];338 extern int _binary_ nameic_ppm_size;345 extern char _binary_gfx_helenos_ppm_start[0]; 346 extern int _binary_gfx_helenos_ppm_size; 347 extern char _binary_gfx_nameic_ppm_start[0]; 348 extern int _binary_gfx_nameic_ppm_size; 339 349 340 350 /** Redraws console graphics */ … … 349 359 set_rgb_color(MAIN_COLOR, MAIN_COLOR); 350 360 clear(); 351 draw_pixmap(_binary_ helenos_ppm_start,352 (size_t) &_binary_ helenos_ppm_size, xres - 66, 2);353 draw_pixmap(_binary_ nameic_ppm_start,354 (size_t) &_binary_ nameic_ppm_size, 5, 17);361 draw_pixmap(_binary_gfx_helenos_ppm_start, 362 (size_t) &_binary_gfx_helenos_ppm_size, xres - 66, 2); 363 draw_pixmap(_binary_gfx_nameic_ppm_start, 364 (size_t) &_binary_gfx_nameic_ppm_size, 5, 17); 355 365 356 366 for (i = 0; i < CONSOLE_COUNT; i++) 357 367 redraw_state(i); 368 358 369 vp_switch(console_vp); 359 370 } … … 370 381 int rc; 371 382 int pxid = -1; 372 383 373 384 /* Create area */ 374 385 shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | … … 376 387 if (shm == MAP_FAILED) 377 388 return -1; 378 389 379 390 memcpy(shm, data, size); 391 380 392 /* Send area */ 381 393 rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); 382 394 if (rc) 383 395 goto exit; 396 384 397 rc = ipc_share_out_start(fbphone, shm, PROTO_READ); 385 398 if (rc) 386 399 goto drop; 387 400 388 401 /* Obtain pixmap */ 389 402 rc = async_req_0_0(fbphone, FB_SHM2PIXMAP); 390 403 if (rc < 0) 391 404 goto drop; 405 392 406 pxid = rc; 407 393 408 drop: 394 409 /* Drop area */ 395 410 async_msg_0(fbphone, FB_DROP_SHM); 396 exit: 411 412 exit: 397 413 /* Remove area */ 398 414 munmap(shm, size); 399 415 400 416 return pxid; 401 417 } 402 418 403 extern char _binary_ anim_1_ppm_start[0];404 extern int _binary_ anim_1_ppm_size;405 extern char _binary_ anim_2_ppm_start[0];406 extern int _binary_ anim_2_ppm_size;407 extern char _binary_ anim_3_ppm_start[0];408 extern int _binary_ anim_3_ppm_size;409 extern char _binary_ anim_4_ppm_start[0];410 extern int _binary_ anim_4_ppm_size;419 extern char _binary_gfx_anim_1_ppm_start[0]; 420 extern int _binary_gfx_anim_1_ppm_size; 421 extern char _binary_gfx_anim_2_ppm_start[0]; 422 extern int _binary_gfx_anim_2_ppm_size; 423 extern char _binary_gfx_anim_3_ppm_start[0]; 424 extern int _binary_gfx_anim_3_ppm_size; 425 extern char _binary_gfx_anim_4_ppm_start[0]; 426 extern int _binary_gfx_anim_4_ppm_size; 411 427 412 428 static void make_anim(void) 413 429 { 414 int an; 415 int pm; 416 417 an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]); 430 int an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]); 418 431 if (an < 0) 419 432 return; 420 421 pm = make_pixmap(_binary_anim_1_ppm_start,422 (int) &_binary_ anim_1_ppm_size);433 434 int pm = make_pixmap(_binary_gfx_anim_1_ppm_start, 435 (int) &_binary_gfx_anim_1_ppm_size); 423 436 async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 424 425 pm = make_pixmap(_binary_ anim_2_ppm_start,426 (int) &_binary_ anim_2_ppm_size);437 438 pm = make_pixmap(_binary_gfx_anim_2_ppm_start, 439 (int) &_binary_gfx_anim_2_ppm_size); 427 440 async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 428 429 pm = make_pixmap(_binary_ anim_3_ppm_start,430 (int) &_binary_ anim_3_ppm_size);441 442 pm = make_pixmap(_binary_gfx_anim_3_ppm_start, 443 (int) &_binary_gfx_anim_3_ppm_size); 431 444 async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 432 433 pm = make_pixmap(_binary_ anim_4_ppm_start,434 (int) &_binary_ anim_4_ppm_size);445 446 pm = make_pixmap(_binary_gfx_anim_4_ppm_start, 447 (int) &_binary_gfx_anim_4_ppm_size); 435 448 async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 436 449 437 450 async_msg_1(fbphone, FB_ANIM_START, an); 438 451 439 452 animation = an; 440 453 } 441 454 442 extern char _binary_ cons_selected_ppm_start[0];443 extern int _binary_ cons_selected_ppm_size;444 extern char _binary_ cons_idle_ppm_start[0];445 extern int _binary_ cons_idle_ppm_size;446 extern char _binary_ cons_has_data_ppm_start[0];447 extern int _binary_ cons_has_data_ppm_size;448 extern char _binary_ cons_kernel_ppm_start[0];449 extern int _binary_ cons_kernel_ppm_size;455 extern char _binary_gfx_cons_selected_ppm_start[0]; 456 extern int _binary_gfx_cons_selected_ppm_size; 457 extern char _binary_gfx_cons_idle_ppm_start[0]; 458 extern int _binary_gfx_cons_idle_ppm_size; 459 extern char _binary_gfx_cons_has_data_ppm_start[0]; 460 extern int _binary_gfx_cons_has_data_ppm_size; 461 extern char _binary_gfx_cons_kernel_ppm_start[0]; 462 extern int _binary_gfx_cons_kernel_ppm_size; 450 463 451 464 /** Initialize nice graphical console environment */ … … 465 478 return; 466 479 467 /* create console viewport */ 480 /* Create console viewport */ 481 468 482 /* Align width & height to character size */ 469 483 console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, … … 487 501 /* Initialize icons */ 488 502 ic_pixmaps[CONS_SELECTED] = 489 make_pixmap(_binary_cons_selected_ppm_start, 490 (int) &_binary_cons_selected_ppm_size); 491 ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start, 492 (int) &_binary_cons_idle_ppm_size); 503 make_pixmap(_binary_gfx_cons_selected_ppm_start, 504 (int) &_binary_gfx_cons_selected_ppm_size); 505 ic_pixmaps[CONS_IDLE] = 506 make_pixmap(_binary_gfx_cons_idle_ppm_start, 507 (int) &_binary_gfx_cons_idle_ppm_size); 493 508 ic_pixmaps[CONS_HAS_DATA] = 494 make_pixmap(_binary_ cons_has_data_ppm_start,495 (int) &_binary_ cons_has_data_ppm_size);509 make_pixmap(_binary_gfx_cons_has_data_ppm_start, 510 (int) &_binary_gfx_cons_has_data_ppm_size); 496 511 ic_pixmaps[CONS_DISCONNECTED] = 497 make_pixmap(_binary_cons_idle_ppm_start, 498 (int) &_binary_cons_idle_ppm_size); 499 ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start, 500 (int) &_binary_cons_kernel_ppm_size); 512 make_pixmap(_binary_gfx_cons_idle_ppm_start, 513 (int) &_binary_gfx_cons_idle_ppm_size); 514 ic_pixmaps[CONS_KERNEL] = 515 make_pixmap(_binary_gfx_cons_kernel_ppm_start, 516 (int) &_binary_gfx_cons_kernel_ppm_size); 501 517 ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; 502 518 -
uspace/srv/console/gcons.h
ra095d20 r1601f3c 28 28 29 29 /** @addtogroup console 30 * @{ 30 * @{ 31 31 */ 32 32 /** @file … … 47 47 48 48 #endif 49 49 50 50 /** @} 51 51 */ -
uspace/srv/console/screenbuffer.c
ra095d20 r1601f3c 28 28 29 29 /** @addtogroup console 30 * @{ 30 * @{ 31 31 */ 32 32 /** @file … … 38 38 #include <unistd.h> 39 39 40 /** Store one character to screenbuffer. Its position is determined by 41 * scr->position_x and scr->position_y. 40 /** Store one character to screenbuffer. 42 41 * 43 * @param scr screenbuffer 44 * @param c stored character 42 * Its position is determined by scr->position_x 43 * and scr->position_y. 44 * 45 * @param scr Screenbuffer 46 * @param c Stored character 47 * 45 48 */ 46 49 void screenbuffer_putchar(screenbuffer_t *scr, wchar_t ch) 47 50 { 48 keyfield_t *field; 49 50 field = get_field_at(scr, scr->position_x, scr->position_y); 51 51 keyfield_t *field = 52 get_field_at(scr, scr->position_x, scr->position_y); 53 52 54 field->character = ch; 53 55 field->attrs = scr->attrs; 54 56 } 55 57 56 /** Initilize screenbuffer. Allocate space for screen content in accordance to given size. 57 * @param scr initialized screenbuffer 58 * @param size_x width in characters 59 * @param size_y height in characters 60 * @return pointer to screenbuffer (same as scr parameter) or NULL 58 /** Initilize screenbuffer. 59 * 60 * Allocate space for screen content in accordance to given size. 61 * 62 * @param scr Initialized screenbuffer 63 * @param size_x Width in characters 64 * @param size_y Height in characters 65 * 66 * @return Pointer to screenbuffer (same as scr parameter) or NULL 67 * 61 68 */ 62 69 screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, int size_x, int size_y) 63 70 { 64 71 scr->buffer = (keyfield_t *) malloc(sizeof(keyfield_t) * size_x * size_y); 65 if (!scr->buffer) {72 if (!scr->buffer) 66 73 return NULL; 67 }68 74 69 75 scr->size_x = size_x; … … 78 84 } 79 85 80 /** Clear screenbuffer. 81 * @param scr screenbuffer 86 /** Clear screenbuffer. 87 * 88 * @param scr Screenbuffer 89 * 82 90 */ 83 91 void screenbuffer_clear(screenbuffer_t *scr) … … 89 97 scr->buffer[i].attrs = scr->attrs; 90 98 } 91 99 92 100 scr->top_line = 0; 93 101 scr->position_y = 0; … … 96 104 97 105 /** Clear one buffer line. 106 * 98 107 * @param scr 99 108 * @param line One buffer line (not a screen line!) 109 * 100 110 */ 101 111 void screenbuffer_clear_line(screenbuffer_t *scr, unsigned int line) … … 110 120 111 121 /** Copy content buffer from screenbuffer to given memory. 112 * @param scr source screenbuffer 113 * @param dest destination 122 * 123 * @param scr Source screenbuffer 124 * @param dest Destination 125 * 114 126 */ 115 127 void screenbuffer_copy_buffer(screenbuffer_t *scr, keyfield_t *dest) … … 117 129 unsigned int i; 118 130 119 for (i = 0; i < scr->size_x * scr->size_y; i++) {131 for (i = 0; i < scr->size_x * scr->size_y; i++) 120 132 dest[i] = scr->buffer[i]; 121 }122 133 } 123 134 124 135 /** Set new cursor position in screenbuffer. 136 * 125 137 * @param scr 126 138 * @param x 127 139 * @param y 140 * 128 141 */ 129 142 void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y) … … 134 147 135 148 /** Set new style. 149 * 136 150 * @param scr 137 151 * @param fg_color 138 152 * @param bg_color 153 * 139 154 */ 140 155 void screenbuffer_set_style(screenbuffer_t *scr, int style) … … 145 160 146 161 /** Set new color. 162 * 147 163 * @param scr 148 164 * @param fg_color 149 165 * @param bg_color 166 * 150 167 */ 151 168 void screenbuffer_set_color(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color, unsigned int flags) … … 158 175 159 176 /** Set new RGB color. 177 * 160 178 * @param scr 161 179 * @param fg_color 162 180 * @param bg_color 181 * 163 182 */ 164 183 void screenbuffer_set_rgb_color(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color) … … 169 188 } 170 189 171 172 190 /** @} 173 191 */ -
uspace/srv/console/screenbuffer.h
ra095d20 r1601f3c 28 28 29 29 /** @addtogroup console 30 * @{ 30 * @{ 31 31 */ 32 32 /** @file 33 33 */ 34 34 35 #ifndef __SCREENBUFFER_H__36 #define __SCREENBUFFER_H__35 #ifndef SCREENBUFFER_H__ 36 #define SCREENBUFFER_H__ 37 37 38 38 #include <stdint.h> 39 39 #include <sys/types.h> 40 40 41 #define DEFAULT_FOREGROUND 0x0 42 #define DEFAULT_BACKGROUND 0xf0f0f0 41 #define DEFAULT_FOREGROUND 0x0 /**< default console foreground color */ 42 #define DEFAULT_BACKGROUND 0xf0f0f0 /**< default console background color */ 43 43 44 44 typedef struct { … … 53 53 54 54 typedef struct { 55 uint32_t bg_color; 56 uint32_t fg_color; 55 uint32_t bg_color; /**< background color */ 56 uint32_t fg_color; /**< foreground color */ 57 57 } attr_rgb_t; 58 58 … … 67 67 attr_idx_t i; 68 68 attr_rgb_t r; 69 } a; 69 } a; 70 70 } attrs_t; 71 71 72 72 /** One field on screen. It contain one character and its attributes. */ 73 73 typedef struct { 74 wchar_t character; 75 attrs_t attrs; 74 wchar_t character; /**< Character itself */ 75 attrs_t attrs; /**< Character`s attributes */ 76 76 } keyfield_t; 77 77 … … 79 79 */ 80 80 typedef struct { 81 keyfield_t *buffer; /**< Screen content - characters and their attributes. Used as a circular buffer. */ 82 unsigned int size_x, size_y; /**< Number of columns and rows */ 83 unsigned int position_x, position_y; /**< Coordinates of last printed character for determining cursor position */ 84 attrs_t attrs; /**< Current attributes. */ 85 unsigned int top_line; /**< Points to buffer[][] line that will be printed at screen as the first line */ 86 unsigned char is_cursor_visible; /**< Cursor state - default is visible */ 81 keyfield_t *buffer; /**< Screen content - characters and 82 their attributes (used as a circular buffer) */ 83 unsigned int size_x; /**< Number of columns */ 84 unsigned int size_y; /**< Number of rows */ 85 86 /** Coordinates of last printed character for determining cursor position */ 87 unsigned int position_x; 88 unsigned int position_y; 89 90 attrs_t attrs; /**< Current attributes. */ 91 unsigned int top_line; /**< Points to buffer[][] line that will 92 be printed at screen as the first line */ 93 unsigned char is_cursor_visible; /**< Cursor state - default is visible */ 87 94 } screenbuffer_t; 88 95 89 /** Returns keyfield for position on screen. Screenbuffer->buffer is cyclic buffer so we must couted in index of the topmost line. 90 * @param scr screenbuffer 91 * @param x position on screen 92 * @param y position on screen 93 * @return keyfield structure with character and its attributes on x,y 96 /** Returns keyfield for position on screen 97 * 98 * Screenbuffer->buffer is cyclic buffer so we 99 * must couted in index of the topmost line. 100 * 101 * @param scr Screenbuffer 102 * @param x Position on screen 103 * @param y Position on screen 104 * 105 * @return Keyfield structure with character and its attributes on x, y 106 * 94 107 */ 95 108 static inline keyfield_t *get_field_at(screenbuffer_t *scr, unsigned int x, unsigned int y) … … 99 112 100 113 /** Compares two sets of attributes. 101 * @param s1 first style 102 * @param s2 second style 103 * @return nonzero on equality 114 * 115 * @param s1 First style 116 * @param s2 Second style 117 * 118 * @return Nonzero on equality 119 * 104 120 */ 105 121 static inline int attrs_same(attrs_t a1, attrs_t a2) 106 122 { 107 if (a1.t != a2.t) return 0; 108 123 if (a1.t != a2.t) 124 return 0; 125 109 126 switch (a1.t) { 110 case at_style: return a1.a.s.style == a2.a.s.style; 111 case at_idx: return a1.a.i.fg_color == a2.a.i.fg_color && 112 a1.a.i.bg_color == a2.a.i.bg_color && 113 a1.a.i.flags == a2.a.i.flags; 114 case at_rgb: return a1.a.r.fg_color == a2.a.r.fg_color && 115 a1.a.r.bg_color == a2.a.r.bg_color; 127 case at_style: 128 return (a1.a.s.style == a2.a.s.style); 129 case at_idx: 130 return (a1.a.i.fg_color == a2.a.i.fg_color) 131 && (a1.a.i.bg_color == a2.a.i.bg_color) 132 && (a1.a.i.flags == a2.a.i.flags); 133 case at_rgb: 134 return (a1.a.r.fg_color == a2.a.r.fg_color) 135 && (a1.a.r.bg_color == a2.a.r.bg_color); 116 136 } 117 137 } … … 133 153 #endif 134 154 135 136 155 /** @} 137 156 */ 138
Note:
See TracChangeset
for help on using the changeset viewer.