Changeset 76fca31 in mainline for uspace/srv/console
- Timestamp:
- 2008-12-16T19:02:07Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5ae4443
- Parents:
- 8fe5980
- Location:
- uspace/srv/console
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/console/console.c
r8fe5980 r76fca31 87 87 * switching */ 88 88 89 static int kernel_pixmap = -1; /**< Number of fb pixmap, where kernel90 * console is stored */91 92 89 93 90 /** Find unused virtual console. … … 188 185 } 189 186 190 /** Save current screen to pixmap, draw old pixmap191 *192 * @param oldpixmap Old pixmap193 * @return ID of pixmap of current screen194 */195 static int switch_screens(int oldpixmap)196 {197 int newpmap;198 199 /* Save screen */200 newpmap = async_req_0_0(fb_info.phone, FB_VP2PIXMAP);201 if (newpmap < 0)202 return -1;203 204 if (oldpixmap != -1) {205 /* Show old screen */206 async_msg_2(fb_info.phone, FB_VP_DRAW_PIXMAP, 0, oldpixmap);207 /* Drop old pixmap */208 async_msg_1(fb_info.phone, FB_DROP_PIXMAP, oldpixmap);209 }210 211 return newpmap;212 }213 214 187 /** Switch to new console */ 215 188 static void change_console(int newcons) 216 189 { 217 190 connection_t *conn; 218 static int console_pixmap = -1;219 191 int i, j, rc; 220 192 keyfield_t *field; 221 193 style_t *style; 222 194 223 195 if (newcons == active_console) 224 196 return; 225 197 226 198 if (newcons == KERNEL_CONSOLE) { 199 async_serialize_start(); 200 curs_visibility(0); 201 gcons_in_kernel(); 202 async_serialize_end(); 203 204 if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) 205 active_console = KERNEL_CONSOLE; 206 else 207 newcons == active_console; 208 } 209 210 if (newcons != KERNEL_CONSOLE) { 211 async_serialize_start(); 212 227 213 if (active_console == KERNEL_CONSOLE) 228 return; 229 active_console = KERNEL_CONSOLE; 214 gcons_redraw_console(); 215 216 active_console = newcons; 217 gcons_change_console(newcons); 218 conn = &connections[active_console]; 219 220 set_style(&conn->screenbuffer.style); 230 221 curs_visibility(0); 231 232 async_serialize_start(); 233 if (kernel_pixmap == -1) { 234 /* store/restore unsupported */ 235 set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND); 222 if (interbuffer) { 223 for (i = 0; i < conn->screenbuffer.size_x; i++) 224 for (j = 0; j < conn->screenbuffer.size_y; j++) { 225 unsigned int size_x; 226 227 size_x = conn->screenbuffer.size_x; 228 interbuffer[i + j * size_x] = 229 *get_field_at(&conn->screenbuffer, i, j); 230 } 231 /* This call can preempt, but we are already at the end */ 232 rc = async_req_0_0(fb_info.phone, FB_DRAW_TEXT_DATA); 233 } 234 235 if ((!interbuffer) || (rc != 0)) { 236 set_style(&conn->screenbuffer.style); 236 237 clrscr(); 237 } else { 238 gcons_in_kernel(); 239 console_pixmap = switch_screens(kernel_pixmap); 240 kernel_pixmap = -1; 238 style = &conn->screenbuffer.style; 239 240 for (j = 0; j < conn->screenbuffer.size_y; j++) 241 for (i = 0; i < conn->screenbuffer.size_x; i++) { 242 field = get_field_at(&conn->screenbuffer, i, j); 243 if (!style_same(*style, field->style)) 244 set_style(&field->style); 245 style = &field->style; 246 if ((field->character == ' ') && 247 (style_same(field->style, 248 conn->screenbuffer.style))) 249 continue; 250 251 prtchr(field->character, j, i); 252 } 241 253 } 254 255 curs_goto(conn->screenbuffer.position_y, 256 conn->screenbuffer.position_x); 257 curs_visibility(conn->screenbuffer.is_cursor_visible); 258 242 259 async_serialize_end(); 243 244 __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE); 245 return; 246 } 247 248 async_serialize_start(); 249 250 if (console_pixmap != -1) { 251 kernel_pixmap = switch_screens(console_pixmap); 252 console_pixmap = -1; 253 } 254 active_console = newcons; 255 gcons_change_console(newcons); 256 conn = &connections[active_console]; 257 258 set_style(&conn->screenbuffer.style); 259 curs_visibility(0); 260 if (interbuffer) { 261 for (i = 0; i < conn->screenbuffer.size_x; i++) 262 for (j = 0; j < conn->screenbuffer.size_y; j++) { 263 unsigned int size_x; 264 265 size_x = conn->screenbuffer.size_x; 266 interbuffer[i + j * size_x] = 267 *get_field_at(&conn->screenbuffer, i, j); 268 } 269 /* This call can preempt, but we are already at the end */ 270 rc = async_req_0_0(fb_info.phone, FB_DRAW_TEXT_DATA); 271 } 272 273 if ((!interbuffer) || (rc != 0)) { 274 set_style(&conn->screenbuffer.style); 275 clrscr(); 276 style = &conn->screenbuffer.style; 277 278 for (j = 0; j < conn->screenbuffer.size_y; j++) 279 for (i = 0; i < conn->screenbuffer.size_x; i++) { 280 field = get_field_at(&conn->screenbuffer, i, j); 281 if (!style_same(*style, field->style)) 282 set_style(&field->style); 283 style = &field->style; 284 if ((field->character == ' ') && 285 (style_same(field->style, 286 conn->screenbuffer.style))) 287 continue; 288 289 prtchr(field->character, j, i); 290 } 291 } 292 293 curs_goto(conn->screenbuffer.position_y, 294 conn->screenbuffer.position_x); 295 curs_visibility(conn->screenbuffer.is_cursor_visible); 296 297 async_serialize_end(); 260 } 298 261 } 299 262 … … 498 461 499 462 /* Connect to framebuffer driver */ 500 501 463 fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0, 0); 502 464 while (fb_info.phone < 0) { … … 505 467 } 506 468 507 /* Save old kernel screen */508 kernel_pixmap = switch_screens(-1);509 510 469 /* Initialize gcons */ 511 470 gcons_init(fb_info.phone); 512 471 /* Synchronize, the gcons can have something in queue */ 513 472 async_req_0_0(fb_info.phone, FB_FLUSH); 514 /* Enable double buffering */515 async_msg_2(fb_info.phone, FB_VIEWPORT_DB, (sysarg_t) -1, 1);516 473 517 474 async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.rows, -
uspace/srv/console/gcons.c
r8fe5980 r76fca31 82 82 static void vp_switch(int vp) 83 83 { 84 async_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp);84 async_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp); 85 85 } 86 86 … … 106 106 static void tran_putch(char c, int row, int col) 107 107 { 108 async_msg_3(fbphone, FB_ TRANS_PUTCHAR, c, row, col);108 async_msg_3(fbphone, FB_PUTCHAR, c, row, col); 109 109 } 110 110 … … 190 190 else 191 191 console_state[consnum] = CONS_DISCONNECTED; 192 192 193 193 if (active_console == KERNEL_CONSOLE) 194 194 return; 195 195 196 196 redraw_state(consnum); 197 197 vp_switch(console_vp); … … 218 218 void gcons_in_kernel(void) 219 219 { 220 if (console_state[active_console] == CONS_DISCONNECTED_SEL)221 console_state[active_console] = CONS_DISCONNECTED;222 else223 console_state[active_console] = CONS_IDLE;224 redraw_state(active_console);225 226 220 if (animation != -1) 227 221 async_msg_1(fbphone, FB_ANIM_STOP, animation); 228 229 active_console = KERNEL_CONSOLE; /* Set to kernel console */222 223 active_console = KERNEL_CONSOLE; 230 224 vp_switch(0); 231 225 } … … 343 337 extern char _binary_nameic_ppm_start[0]; 344 338 extern int _binary_nameic_ppm_size; 345 /** Redraws console graphics */ 346 static void gcons_redraw_console(void) 339 340 /** Redraws console graphics */ 341 void gcons_redraw_console(void) 347 342 { 348 343 int i; 349 344 350 345 if (!use_gcons) 351 346 return; … … 358 353 draw_pixmap(_binary_nameic_ppm_start, 359 354 (size_t) &_binary_nameic_ppm_size, 5, 17); 360 355 361 356 for (i = 0; i < CONSOLE_COUNT; i++) 362 357 redraw_state(i); … … 460 455 int i; 461 456 int status_start = STATUS_START; 462 457 463 458 fbphone = phone; 464 459 465 460 rc = async_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres); 466 461 if (rc) 467 462 return; 468 463 469 if ( xres < 800 || yres < 600)470 return; 471 464 if ((xres < 800) || (yres < 600)) 465 return; 466 472 467 /* create console viewport */ 473 468 /* Align width & height to character size */ … … 507 502 508 503 make_anim(); 509 504 510 505 use_gcons = 1; 511 506 console_state[0] = CONS_DISCONNECTED_SEL; … … 513 508 gcons_redraw_console(); 514 509 } 515 510 516 511 /** @} 517 512 */ 518 -
uspace/srv/console/gcons.h
r8fe5980 r76fca31 37 37 38 38 void gcons_init(int phone); 39 void gcons_redraw_console(void); 39 40 void gcons_change_console(int consnum); 40 41 void gcons_notify_char(int consnum); -
uspace/srv/console/screenbuffer.h
r8fe5980 r76fca31 36 36 #define __SCREENBUFFER_H__ 37 37 38 #include <stdint.h> 38 39 39 40 #define DEFAULT_FOREGROUND 0x0 /**< default console foreground color */ … … 41 42 42 43 typedef struct { 43 u nsigned int bg_color;/**< background color */44 u nsigned int fg_color;/**< foreground color */44 uint32_t bg_color; /**< background color */ 45 uint32_t fg_color; /**< foreground color */ 45 46 } style_t; 46 47
Note:
See TracChangeset
for help on using the changeset viewer.