Rev 1578 | Rev 1610 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1578 | Rev 1592 | ||
---|---|---|---|
Line 331... | Line 331... | ||
331 | { |
331 | { |
332 | ipc_callid_t callid; |
332 | ipc_callid_t callid; |
333 | ipc_call_t call; |
333 | ipc_call_t call; |
334 | int consnum; |
334 | int consnum; |
335 | ipcarg_t arg1, arg2; |
335 | ipcarg_t arg1, arg2; |
- | 336 | connection_t *conn; |
|
336 | 337 | ||
337 | if ((consnum = find_free_connection()) == -1) { |
338 | if ((consnum = find_free_connection()) == -1) { |
338 | ipc_answer_fast(iid,ELIMIT,0,0); |
339 | ipc_answer_fast(iid,ELIMIT,0,0); |
339 | return; |
340 | return; |
340 | } |
341 | } |
- | 342 | conn = &connections[consnum]; |
|
341 | 343 | ||
342 | gcons_notify_connect(consnum); |
344 | gcons_notify_connect(consnum); |
343 | connections[consnum].used = 1; |
345 | conn->used = 1; |
344 | connections[consnum].client_phone = IPC_GET_ARG3(call); |
346 | conn->client_phone = IPC_GET_ARG3(call); |
345 | screenbuffer_clear(&(connections[consnum].screenbuffer)); |
347 | screenbuffer_clear(&conn->screenbuffer); |
346 | 348 | ||
347 | /* Accept the connection */ |
349 | /* Accept the connection */ |
348 | ipc_answer_fast(iid,0,0,0); |
350 | ipc_answer_fast(iid,0,0,0); |
349 | 351 | ||
350 | while (1) { |
352 | while (1) { |
351 | callid = async_get_call(&call); |
353 | callid = async_get_call(&call); |
352 | arg1 = arg2 = 0; |
354 | arg1 = arg2 = 0; |
353 | switch (IPC_GET_METHOD(call)) { |
355 | switch (IPC_GET_METHOD(call)) { |
354 | case IPC_M_PHONE_HUNGUP: |
356 | case IPC_M_PHONE_HUNGUP: |
- | 357 | gcons_notify_disconnect(consnum); |
|
- | 358 | /* Answer all pending requests */ |
|
- | 359 | while (conn->keyrequest_counter > 0) { |
|
- | 360 | conn->keyrequest_counter--; |
|
- | 361 | ipc_answer_fast(fifo_pop(conn->keyrequests), ENOENT, 0, 0); |
|
- | 362 | break; |
|
- | 363 | } |
|
- | 364 | ||
355 | /* TODO */ |
365 | /* Commit hangup */ |
356 | ipc_answer_fast(callid, 0,0,0); |
366 | ipc_answer_fast(callid, 0,0,0); |
357 | return; |
367 | return; |
358 | case CONSOLE_PUTCHAR: |
368 | case CONSOLE_PUTCHAR: |
359 | write_char(consnum, IPC_GET_ARG1(call)); |
369 | write_char(consnum, IPC_GET_ARG1(call)); |
360 | gcons_notify_char(consnum); |
370 | gcons_notify_char(consnum); |
Line 363... | Line 373... | ||
363 | /* Send message to fb */ |
373 | /* Send message to fb */ |
364 | if (consnum == active_console) { |
374 | if (consnum == active_console) { |
365 | send_call(fb_info.phone, FB_CLEAR, 0); |
375 | send_call(fb_info.phone, FB_CLEAR, 0); |
366 | } |
376 | } |
367 | 377 | ||
368 | screenbuffer_clear(&(connections[consnum].screenbuffer)); |
378 | screenbuffer_clear(&conn->screenbuffer); |
369 | 379 | ||
370 | break; |
380 | break; |
371 | case CONSOLE_GOTO: |
381 | case CONSOLE_GOTO: |
372 | 382 | ||
373 | screenbuffer_goto(&(connections[consnum].screenbuffer), IPC_GET_ARG2(call), IPC_GET_ARG1(call)); |
383 | screenbuffer_goto(&conn->screenbuffer, IPC_GET_ARG2(call), IPC_GET_ARG1(call)); |
374 | if (consnum == active_console) |
384 | if (consnum == active_console) |
375 | curs_goto(IPC_GET_ARG1(call),IPC_GET_ARG2(call)); |
385 | curs_goto(IPC_GET_ARG1(call),IPC_GET_ARG2(call)); |
376 | 386 | ||
377 | break; |
387 | break; |
378 | 388 | ||
Line 385... | Line 395... | ||
385 | break; |
395 | break; |
386 | case CONSOLE_SET_STYLE: |
396 | case CONSOLE_SET_STYLE: |
387 | 397 | ||
388 | arg1 = IPC_GET_ARG1(call); |
398 | arg1 = IPC_GET_ARG1(call); |
389 | arg2 = IPC_GET_ARG2(call); |
399 | arg2 = IPC_GET_ARG2(call); |
390 | screenbuffer_set_style(&(connections[consnum].screenbuffer),arg1, arg2); |
400 | screenbuffer_set_style(&conn->screenbuffer,arg1, arg2); |
391 | if (consnum == active_console) |
401 | if (consnum == active_console) |
392 | set_style_col(arg1, arg2); |
402 | set_style_col(arg1, arg2); |
393 | 403 | ||
394 | break; |
404 | break; |
395 | case CONSOLE_CURSOR_VISIBILITY: |
405 | case CONSOLE_CURSOR_VISIBILITY: |
396 | arg1 = IPC_GET_ARG1(call); |
406 | arg1 = IPC_GET_ARG1(call); |
397 | connections[consnum].screenbuffer.is_cursor_visible = arg1; |
407 | conn->screenbuffer.is_cursor_visible = arg1; |
398 | if (consnum == active_console) |
408 | if (consnum == active_console) |
399 | curs_visibility(arg1); |
409 | curs_visibility(arg1); |
400 | break; |
410 | break; |
401 | case CONSOLE_GETCHAR: |
411 | case CONSOLE_GETCHAR: |
402 | if (keybuffer_empty(&(connections[consnum].keybuffer))) { |
412 | if (keybuffer_empty(&conn->keybuffer)) { |
403 | /* buffer is empty -> store request */ |
413 | /* buffer is empty -> store request */ |
404 | if (connections[consnum].keyrequest_counter < MAX_KEYREQUESTS_BUFFERED) { |
414 | if (conn->keyrequest_counter < MAX_KEYREQUESTS_BUFFERED) { |
405 | fifo_push(connections[consnum].keyrequests, callid); |
415 | fifo_push(conn->keyrequests, callid); |
406 | connections[consnum].keyrequest_counter++; |
416 | conn->keyrequest_counter++; |
407 | } else { |
417 | } else { |
408 | /* no key available and too many requests => fail */ |
418 | /* no key available and too many requests => fail */ |
409 | ipc_answer_fast(callid, ELIMIT, 0, 0); |
419 | ipc_answer_fast(callid, ELIMIT, 0, 0); |
410 | } |
420 | } |
411 | continue; |
421 | continue; |
412 | }; |
422 | }; |
413 | keybuffer_pop(&(connections[consnum].keybuffer), (int *)&arg1); |
423 | keybuffer_pop(&conn->keybuffer, (int *)&arg1); |
414 | 424 | ||
415 | break; |
425 | break; |
416 | } |
426 | } |
417 | ipc_answer_fast(callid, 0, arg1, arg2); |
427 | ipc_answer_fast(callid, 0, arg1, arg2); |
418 | } |
428 | } |