Rev 1567 | Rev 1575 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1567 | Rev 1574 | ||
---|---|---|---|
Line 76... | Line 76... | ||
76 | 76 | ||
77 | 77 | ||
78 | /** Find unused virtual console. |
78 | /** Find unused virtual console. |
79 | * |
79 | * |
80 | */ |
80 | */ |
81 | static int find_free_connection() |
81 | static int find_free_connection(void) |
82 | { |
82 | { |
83 | int i = 0; |
83 | int i = 0; |
84 | 84 | ||
85 | while (i < CONSOLE_COUNT) { |
85 | for (i=0; i < CONSOLE_COUNT; i++) { |
86 | if (connections[i].used == 0) |
86 | if (!connections[i].used) |
87 | return i; |
87 | return i; |
88 | ++i; |
- | |
89 | } |
88 | } |
90 | return CONSOLE_COUNT; |
- | |
91 | } |
- | |
92 | - | ||
93 | /** Find index of virtual console used by client with given phone. |
- | |
94 | * |
- | |
95 | */ |
- | |
96 | static int find_connection(int client_phone) |
- | |
97 | { |
- | |
98 | int i = 0; |
- | |
99 | - | ||
100 | while (i < CONSOLE_COUNT) { |
- | |
101 | if (connections[i].client_phone == client_phone) |
- | |
102 | return i; |
89 | return -1; |
103 | ++i; |
- | |
104 | } |
- | |
105 | return CONSOLE_COUNT; |
- | |
106 | } |
90 | } |
107 | 91 | ||
108 | static void clrscr(void) |
92 | static void clrscr(void) |
109 | { |
93 | { |
110 | nsend_call(fb_info.phone, FB_CLEAR, 0); |
94 | nsend_call(fb_info.phone, FB_CLEAR, 0); |
Line 337... | Line 321... | ||
337 | ipc_callid_t callid; |
321 | ipc_callid_t callid; |
338 | ipc_call_t call; |
322 | ipc_call_t call; |
339 | int consnum; |
323 | int consnum; |
340 | ipcarg_t arg1, arg2; |
324 | ipcarg_t arg1, arg2; |
341 | 325 | ||
342 | if ((consnum = find_free_connection()) == CONSOLE_COUNT) { |
326 | if ((consnum = find_free_connection()) == -1) { |
343 | ipc_answer_fast(iid,ELIMIT,0,0); |
327 | ipc_answer_fast(iid,ELIMIT,0,0); |
344 | return; |
328 | return; |
345 | } |
329 | } |
346 | 330 | ||
347 | gcons_notify_connect(consnum); |
331 | gcons_notify_connect(consnum); |
Line 446... | Line 430... | ||
446 | kernel_pixmap = switch_screens(-1); |
430 | kernel_pixmap = switch_screens(-1); |
447 | 431 | ||
448 | /* Initialize gcons */ |
432 | /* Initialize gcons */ |
449 | gcons_init(fb_info.phone); |
433 | gcons_init(fb_info.phone); |
450 | /* Synchronize, the gcons can have something in queue */ |
434 | /* Synchronize, the gcons can have something in queue */ |
451 | sync_send_2(fb_info.phone, FB_GET_CSIZE, 0, 0, NULL, NULL); |
435 | sync_send(fb_info.phone, FB_FLUSH, 0, NULL); |
452 | 436 | ||
453 | 437 | ||
454 | ipc_call_sync_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols)); |
438 | ipc_call_sync_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols)); |
455 | set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND); |
439 | set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND); |
456 | clrscr(); |
440 | clrscr(); |
Line 467... | Line 451... | ||
467 | if (screenbuffer_init(&(connections[i].screenbuffer), fb_info.cols, fb_info.rows ) == NULL) { |
451 | if (screenbuffer_init(&(connections[i].screenbuffer), fb_info.cols, fb_info.rows ) == NULL) { |
468 | /*FIXME: handle error */ |
452 | /*FIXME: handle error */ |
469 | return -1; |
453 | return -1; |
470 | } |
454 | } |
471 | } |
455 | } |
- | 456 | connections[KERNEL_CONSOLE].used = 1; |
|
472 | 457 | ||
473 | if ((interbuffer = mmap(NULL, sizeof(keyfield_t) * fb_info.cols * fb_info.rows , PROTO_READ|PROTO_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, 0 ,0 )) != NULL) { |
458 | if ((interbuffer = mmap(NULL, sizeof(keyfield_t) * fb_info.cols * fb_info.rows , PROTO_READ|PROTO_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, 0 ,0 )) != NULL) { |
474 | if (ipc_call_sync_3(fb_info.phone, IPC_M_AS_AREA_SEND, (ipcarg_t)interbuffer, 0, AS_AREA_READ, NULL, NULL, NULL) != 0) { |
459 | if (ipc_call_sync_3(fb_info.phone, IPC_M_AS_AREA_SEND, (ipcarg_t)interbuffer, 0, AS_AREA_READ, NULL, NULL, NULL) != 0) { |
475 | munmap(interbuffer, sizeof(keyfield_t) * fb_info.cols * fb_info.rows); |
460 | munmap(interbuffer, sizeof(keyfield_t) * fb_info.cols * fb_info.rows); |
476 | interbuffer = NULL; |
461 | interbuffer = NULL; |