Rev 1592 | Rev 1616 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1592 | Rev 1610 | ||
---|---|---|---|
Line 23... | Line 23... | ||
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
- | 28 | /* TODO: remove */ |
|
- | 29 | #include <stdio.h> |
|
28 | 30 | ||
29 | 31 | ||
30 | #include <kbd.h> |
32 | #include <kbd.h> |
31 | #include <fb.h> |
33 | #include <fb.h> |
32 | #include <ipc/ipc.h> |
34 | #include <ipc/ipc.h> |
Line 89... | Line 91... | ||
89 | return -1; |
91 | return -1; |
90 | } |
92 | } |
91 | 93 | ||
92 | static void clrscr(void) |
94 | static void clrscr(void) |
93 | { |
95 | { |
94 | nsend_call(fb_info.phone, FB_CLEAR, 0); |
96 | async_msg(fb_info.phone, FB_CLEAR, 0); |
95 | } |
97 | } |
96 | 98 | ||
97 | static void curs_visibility(int v) |
99 | static void curs_visibility(int v) |
98 | { |
100 | { |
99 | send_call(fb_info.phone, FB_CURSOR_VISIBILITY, v); |
101 | async_msg(fb_info.phone, FB_CURSOR_VISIBILITY, v); |
100 | } |
102 | } |
101 | 103 | ||
102 | static void curs_goto(int row, int col) |
104 | static void curs_goto(int row, int col) |
103 | { |
105 | { |
104 | nsend_call_2(fb_info.phone, FB_CURSOR_GOTO, row, col); |
106 | async_msg_2(fb_info.phone, FB_CURSOR_GOTO, row, col); |
105 | 107 | ||
106 | } |
108 | } |
107 | 109 | ||
108 | static void set_style(style_t *style) |
110 | static void set_style(style_t *style) |
109 | { |
111 | { |
110 | nsend_call_2(fb_info.phone, FB_SET_STYLE, style->fg_color, style->bg_color); |
112 | async_msg_2(fb_info.phone, FB_SET_STYLE, style->fg_color, style->bg_color); |
111 | } |
113 | } |
112 | 114 | ||
113 | static void set_style_col(int fgcolor, int bgcolor) |
115 | static void set_style_col(int fgcolor, int bgcolor) |
114 | { |
116 | { |
115 | nsend_call_2(fb_info.phone, FB_SET_STYLE, fgcolor, bgcolor); |
117 | async_msg_2(fb_info.phone, FB_SET_STYLE, fgcolor, bgcolor); |
116 | } |
118 | } |
117 | 119 | ||
118 | static void prtchr(char c, int row, int col) |
120 | static void prtchr(char c, int row, int col) |
119 | { |
121 | { |
120 | nsend_call_3(fb_info.phone, FB_PUTCHAR, c, row, col); |
122 | async_msg_3(fb_info.phone, FB_PUTCHAR, c, row, col); |
121 | 123 | ||
122 | } |
124 | } |
123 | 125 | ||
124 | /** Check key and process special keys. |
126 | /** Check key and process special keys. |
125 | * |
127 | * |
Line 163... | Line 165... | ||
163 | 165 | ||
164 | if (scr->position_y >= scr->size_y) { |
166 | if (scr->position_y >= scr->size_y) { |
165 | scr->position_y = scr->size_y - 1; |
167 | scr->position_y = scr->size_y - 1; |
166 | screenbuffer_clear_line(scr, scr->top_line++); |
168 | screenbuffer_clear_line(scr, scr->top_line++); |
167 | if (console == active_console) |
169 | if (console == active_console) |
168 | nsend_call(fb_info.phone, FB_SCROLL, 1); |
170 | async_msg(fb_info.phone, FB_SCROLL, 1); |
169 | } |
171 | } |
170 | 172 | ||
171 | scr->position_x = scr->position_x % scr->size_x; |
173 | scr->position_x = scr->position_x % scr->size_x; |
172 | 174 | ||
173 | if (console == active_console) |
175 | if (console == active_console) |
Line 183... | Line 185... | ||
183 | static int switch_screens(int oldpixmap) |
185 | static int switch_screens(int oldpixmap) |
184 | { |
186 | { |
185 | int newpmap; |
187 | int newpmap; |
186 | 188 | ||
187 | /* Save screen */ |
189 | /* Save screen */ |
188 | newpmap = sync_send(fb_info.phone, FB_VP2PIXMAP, 0, NULL); |
190 | newpmap = async_req(fb_info.phone, FB_VP2PIXMAP, 0, NULL); |
189 | if (newpmap < 0) |
191 | if (newpmap < 0) |
190 | return -1; |
192 | return -1; |
191 | 193 | ||
192 | if (oldpixmap != -1) { |
194 | if (oldpixmap != -1) { |
193 | /* Show old screen */ |
195 | /* Show old screen */ |
194 | nsend_call_2(fb_info.phone, FB_VP_DRAW_PIXMAP, 0, oldpixmap); |
196 | async_msg_2(fb_info.phone, FB_VP_DRAW_PIXMAP, 0, oldpixmap); |
195 | /* Drop old pixmap */ |
197 | /* Drop old pixmap */ |
196 | nsend_call(fb_info.phone, FB_DROP_PIXMAP, oldpixmap); |
198 | async_msg(fb_info.phone, FB_DROP_PIXMAP, oldpixmap); |
197 | } |
199 | } |
198 | 200 | ||
199 | return newpmap; |
201 | return newpmap; |
200 | } |
202 | } |
201 | 203 | ||
Line 234... | Line 236... | ||
234 | 236 | ||
235 | if (console_pixmap != -1) { |
237 | if (console_pixmap != -1) { |
236 | kernel_pixmap = switch_screens(console_pixmap); |
238 | kernel_pixmap = switch_screens(console_pixmap); |
237 | console_pixmap = -1; |
239 | console_pixmap = -1; |
238 | } |
240 | } |
239 | - | ||
240 | active_console = newcons; |
241 | active_console = newcons; |
241 | gcons_change_console(newcons); |
242 | gcons_change_console(newcons); |
242 | conn = &connections[active_console]; |
243 | conn = &connections[active_console]; |
243 | 244 | ||
244 | set_style(&conn->screenbuffer.style); |
245 | set_style(&conn->screenbuffer.style); |
245 | curs_goto(conn->screenbuffer.position_y, conn->screenbuffer.position_x); |
246 | curs_goto(conn->screenbuffer.position_y, conn->screenbuffer.position_x); |
246 | curs_visibility(0); |
247 | curs_visibility(0); |
247 | - | ||
248 | if (interbuffer) { |
248 | if (interbuffer) { |
249 | for (i = 0; i < conn->screenbuffer.size_x; i++) |
249 | for (i = 0; i < conn->screenbuffer.size_x; i++) |
250 | for (j = 0; j < conn->screenbuffer.size_y; j++) |
250 | for (j = 0; j < conn->screenbuffer.size_y; j++) |
251 | interbuffer[i + j*conn->screenbuffer.size_x] = *get_field_at(&(conn->screenbuffer),i, j); |
251 | interbuffer[i + j*conn->screenbuffer.size_x] = *get_field_at(&(conn->screenbuffer),i, j); |
252 | /* This call can preempt, but we are already at the end */ |
252 | /* This call can preempt, but we are already at the end */ |
253 | j = sync_send_2(fb_info.phone, FB_DRAW_TEXT_DATA, 0, 0, NULL, NULL); |
253 | j = async_req_2(fb_info.phone, FB_DRAW_TEXT_DATA, 0, 0, NULL, NULL); |
254 | }; |
254 | }; |
255 | 255 | ||
256 | if ((!interbuffer) || (j != 0)){ |
256 | if ((!interbuffer) || (j != 0)){ |
257 | set_style(&conn->screenbuffer.style); |
257 | set_style(&conn->screenbuffer.style); |
258 | clrscr(); |
258 | clrscr(); |
Line 299... | Line 299... | ||
299 | /* switch to another virtual console */ |
299 | /* switch to another virtual console */ |
300 | 300 | ||
301 | conn = &connections[active_console]; |
301 | conn = &connections[active_console]; |
302 | // if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) { |
302 | // if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) { |
303 | if ((c >= 0x101) && (c < 0x101 + CONSOLE_COUNT)) { |
303 | if ((c >= 0x101) && (c < 0x101 + CONSOLE_COUNT)) { |
- | 304 | async_serialize_start(); |
|
304 | if (c == 0x112) |
305 | if (c == 0x112) |
305 | change_console(KERNEL_CONSOLE); |
306 | change_console(KERNEL_CONSOLE); |
306 | else |
307 | else |
307 | change_console(c - 0x101); |
308 | change_console(c - 0x101); |
- | 309 | async_serialize_end(); |
|
308 | break; |
310 | break; |
309 | } |
311 | } |
310 | 312 | ||
311 | /* if client is awaiting key, send it */ |
313 | /* if client is awaiting key, send it */ |
312 | if (conn->keyrequest_counter > 0) { |
314 | if (conn->keyrequest_counter > 0) { |
Line 319... | Line 321... | ||
319 | keybuffer_push(&conn->keybuffer, c); |
321 | keybuffer_push(&conn->keybuffer, c); |
320 | 322 | ||
321 | break; |
323 | break; |
322 | default: |
324 | default: |
323 | retval = ENOENT; |
325 | retval = ENOENT; |
324 | } |
326 | } |
325 | ipc_answer_fast(callid, retval, 0, 0); |
327 | ipc_answer_fast(callid, retval, 0, 0); |
326 | } |
328 | } |
327 | } |
329 | } |
328 | 330 | ||
329 | /** Default thread for new connections */ |
331 | /** Default thread for new connections */ |
Line 338... | Line 340... | ||
338 | if ((consnum = find_free_connection()) == -1) { |
340 | if ((consnum = find_free_connection()) == -1) { |
339 | ipc_answer_fast(iid,ELIMIT,0,0); |
341 | ipc_answer_fast(iid,ELIMIT,0,0); |
340 | return; |
342 | return; |
341 | } |
343 | } |
342 | conn = &connections[consnum]; |
344 | conn = &connections[consnum]; |
- | 345 | conn->used = 1; |
|
343 | 346 | ||
- | 347 | async_serialize_start(); |
|
344 | gcons_notify_connect(consnum); |
348 | gcons_notify_connect(consnum); |
345 | conn->used = 1; |
- | |
346 | conn->client_phone = IPC_GET_ARG3(call); |
349 | conn->client_phone = IPC_GET_ARG3(call); |
347 | screenbuffer_clear(&conn->screenbuffer); |
350 | screenbuffer_clear(&conn->screenbuffer); |
348 | 351 | ||
349 | /* Accept the connection */ |
352 | /* Accept the connection */ |
350 | ipc_answer_fast(iid,0,0,0); |
353 | ipc_answer_fast(iid,0,0,0); |
351 | 354 | ||
352 | while (1) { |
355 | while (1) { |
- | 356 | async_serialize_end(); |
|
353 | callid = async_get_call(&call); |
357 | callid = async_get_call(&call); |
- | 358 | async_serialize_start(); |
|
- | 359 | ||
354 | arg1 = arg2 = 0; |
360 | arg1 = arg2 = 0; |
355 | switch (IPC_GET_METHOD(call)) { |
361 | switch (IPC_GET_METHOD(call)) { |
356 | case IPC_M_PHONE_HUNGUP: |
362 | case IPC_M_PHONE_HUNGUP: |
357 | gcons_notify_disconnect(consnum); |
363 | gcons_notify_disconnect(consnum); |
- | 364 | ||
358 | /* Answer all pending requests */ |
365 | /* Answer all pending requests */ |
359 | while (conn->keyrequest_counter > 0) { |
366 | while (conn->keyrequest_counter > 0) { |
360 | conn->keyrequest_counter--; |
367 | conn->keyrequest_counter--; |
361 | ipc_answer_fast(fifo_pop(conn->keyrequests), ENOENT, 0, 0); |
368 | ipc_answer_fast(fifo_pop(conn->keyrequests), ENOENT, 0, 0); |
362 | break; |
369 | break; |
363 | } |
370 | } |
364 | 371 | ||
365 | /* Commit hangup */ |
372 | /* Commit hangup */ |
366 | ipc_answer_fast(callid, 0,0,0); |
373 | ipc_answer_fast(callid, 0,0,0); |
- | 374 | async_serialize_end(); |
|
367 | return; |
375 | return; |
368 | case CONSOLE_PUTCHAR: |
376 | case CONSOLE_PUTCHAR: |
369 | write_char(consnum, IPC_GET_ARG1(call)); |
377 | write_char(consnum, IPC_GET_ARG1(call)); |
370 | gcons_notify_char(consnum); |
378 | gcons_notify_char(consnum); |
371 | break; |
379 | break; |
372 | case CONSOLE_CLEAR: |
380 | case CONSOLE_CLEAR: |
373 | /* Send message to fb */ |
381 | /* Send message to fb */ |
374 | if (consnum == active_console) { |
382 | if (consnum == active_console) { |
375 | send_call(fb_info.phone, FB_CLEAR, 0); |
383 | async_msg(fb_info.phone, FB_CLEAR, 0); |
376 | } |
384 | } |
377 | 385 | ||
378 | screenbuffer_clear(&conn->screenbuffer); |
386 | screenbuffer_clear(&conn->screenbuffer); |
379 | 387 | ||
380 | break; |
388 | break; |
Line 389... | Line 397... | ||
389 | case CONSOLE_GETSIZE: |
397 | case CONSOLE_GETSIZE: |
390 | arg1 = fb_info.rows; |
398 | arg1 = fb_info.rows; |
391 | arg2 = fb_info.cols; |
399 | arg2 = fb_info.cols; |
392 | break; |
400 | break; |
393 | case CONSOLE_FLUSH: |
401 | case CONSOLE_FLUSH: |
394 | sync_send_2(fb_info.phone, FB_FLUSH, 0, 0, NULL, NULL); |
402 | async_req_2(fb_info.phone, FB_FLUSH, 0, 0, NULL, NULL); |
395 | break; |
403 | break; |
396 | case CONSOLE_SET_STYLE: |
404 | case CONSOLE_SET_STYLE: |
397 | 405 | ||
398 | arg1 = IPC_GET_ARG1(call); |
406 | arg1 = IPC_GET_ARG1(call); |
399 | arg2 = IPC_GET_ARG2(call); |
407 | arg2 = IPC_GET_ARG2(call); |
Line 457... | Line 465... | ||
457 | kernel_pixmap = switch_screens(-1); |
465 | kernel_pixmap = switch_screens(-1); |
458 | 466 | ||
459 | /* Initialize gcons */ |
467 | /* Initialize gcons */ |
460 | gcons_init(fb_info.phone); |
468 | gcons_init(fb_info.phone); |
461 | /* Synchronize, the gcons can have something in queue */ |
469 | /* Synchronize, the gcons can have something in queue */ |
462 | sync_send(fb_info.phone, FB_FLUSH, 0, NULL); |
470 | async_req(fb_info.phone, FB_FLUSH, 0, NULL); |
463 | 471 | ||
464 | 472 | ||
465 | ipc_call_sync_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols)); |
473 | ipc_call_sync_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols)); |
466 | set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND); |
474 | set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND); |
467 | clrscr(); |
475 | clrscr(); |