Rev 1504 | Rev 1512 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1504 | Rev 1506 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2006 Josef Cejka |
2 | * Copyright (C) 2006 Josef Cejka |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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 | 28 | ||
29 | 29 | ||
30 | #include <kbd.h> |
30 | #include <kbd.h> |
31 | #include <fb.h> |
31 | #include <fb.h> |
32 | #include <ipc/ipc.h> |
32 | #include <ipc/ipc.h> |
33 | #include <ipc/fb.h> |
33 | #include <ipc/fb.h> |
34 | #include <ipc/services.h> |
34 | #include <ipc/services.h> |
35 | #include <errno.h> |
35 | #include <errno.h> |
36 | #include <key_buffer.h> |
36 | #include <key_buffer.h> |
37 | #include <console.h> |
37 | #include <console.h> |
38 | #include <unistd.h> |
38 | #include <unistd.h> |
39 | #include <async.h> |
39 | #include <async.h> |
40 | #include <libadt/fifo.h> |
40 | #include <libadt/fifo.h> |
41 | #include <screenbuffer.h> |
41 | #include <screenbuffer.h> |
42 | 42 | ||
43 | #define CONSOLE_COUNT 12 |
43 | #define CONSOLE_COUNT 12 |
44 | #define MAX_KEYREQUESTS_BUFFERED 32 |
44 | #define MAX_KEYREQUESTS_BUFFERED 32 |
45 | 45 | ||
46 | #define NAME "CONSOLE" |
46 | #define NAME "CONSOLE" |
47 | 47 | ||
48 | int active_console = 1; |
48 | int active_console = 1; |
49 | 49 | ||
50 | struct { |
50 | struct { |
51 | int phone; /**< Framebuffer phone */ |
51 | int phone; /**< Framebuffer phone */ |
52 | int rows; /**< Framebuffer rows */ |
52 | ipcarg_t rows; /**< Framebuffer rows */ |
53 | int cols; /**< Framebuffer columns */ |
53 | ipcarg_t cols; /**< Framebuffer columns */ |
54 | } fb_info; |
54 | } fb_info; |
55 | 55 | ||
56 | typedef struct { |
56 | typedef struct { |
57 | keybuffer_t keybuffer; |
57 | keybuffer_t keybuffer; |
58 | FIFO_CREATE_STATIC(keyrequests, ipc_callid_t , MAX_KEYREQUESTS_BUFFERED); |
58 | FIFO_CREATE_STATIC(keyrequests, ipc_callid_t , MAX_KEYREQUESTS_BUFFERED); |
59 | int keyrequest_counter; |
59 | int keyrequest_counter; |
60 | int client_phone; |
60 | int client_phone; |
61 | int used; |
61 | int used; |
62 | screenbuffer_t screenbuffer; |
62 | screenbuffer_t screenbuffer; |
63 | } connection_t; |
63 | } connection_t; |
64 | 64 | ||
- | 65 | ||
- | 66 | ||
65 | connection_t connections[CONSOLE_COUNT]; |
67 | connection_t connections[CONSOLE_COUNT]; |
66 | 68 | ||
67 | static int find_free_connection() |
69 | static int find_free_connection() |
68 | { |
70 | { |
69 | int i = 0; |
71 | int i = 0; |
70 | 72 | ||
71 | while (i < CONSOLE_COUNT) { |
73 | while (i < CONSOLE_COUNT) { |
72 | if (connections[i].used == 0) |
74 | if (connections[i].used == 0) |
73 | return i; |
75 | return i; |
74 | ++i; |
76 | ++i; |
75 | } |
77 | } |
76 | return CONSOLE_COUNT; |
78 | return CONSOLE_COUNT; |
77 | } |
79 | } |
78 | 80 | ||
79 | 81 | ||
80 | static int find_connection(int client_phone) |
82 | static int find_connection(int client_phone) |
81 | { |
83 | { |
82 | int i = 0; |
84 | int i = 0; |
83 | 85 | ||
84 | while (i < CONSOLE_COUNT) { |
86 | while (i < CONSOLE_COUNT) { |
85 | if (connections[i].client_phone == client_phone) |
87 | if (connections[i].client_phone == client_phone) |
86 | return i; |
88 | return i; |
87 | ++i; |
89 | ++i; |
88 | } |
90 | } |
89 | return CONSOLE_COUNT; |
91 | return CONSOLE_COUNT; |
90 | } |
92 | } |
91 | 93 | ||
92 | /** Check key and process special keys. |
94 | /** Check key and process special keys. |
93 | * |
95 | * |
94 | * */ |
96 | * */ |
95 | static void write_char(int console, char key) |
97 | static void write_char(int console, char key) |
96 | { |
98 | { |
97 | screenbuffer_t *scr = &(connections[console].screenbuffer); |
99 | screenbuffer_t *scr = &(connections[console].screenbuffer); |
98 | 100 | ||
99 | switch (key) { |
101 | switch (key) { |
100 | case '\n': |
102 | case '\n': |
101 | scr->position_y += 1; |
103 | scr->position_y += 1; |
102 | scr->position_x = 0; |
104 | scr->position_x = 0; |
103 | break; |
105 | break; |
104 | case '\r': |
106 | case '\r': |
105 | break; |
107 | break; |
106 | case '\t': |
108 | case '\t': |
107 | scr->position_x += 8; |
109 | scr->position_x += 8; |
108 | scr->position_x -= scr->position_x % 8; |
110 | scr->position_x -= scr->position_x % 8; |
109 | break; |
111 | break; |
110 | case '\b': |
112 | case '\b': |
111 | if (scr->position_x == 0) |
113 | if (scr->position_x == 0) |
112 | break; |
114 | break; |
113 | 115 | ||
114 | scr->position_x--; |
116 | scr->position_x--; |
115 | 117 | ||
116 | if (console == active_console) { |
118 | if (console == active_console) { |
117 | ipc_call_async_3(fb_info.phone, FB_PUTCHAR, ' ', scr->position_y, scr->position_x, NULL, NULL); |
119 | ipc_call_async_3(fb_info.phone, FB_PUTCHAR, ' ', scr->position_y, scr->position_x, NULL, NULL); |
118 | } |
120 | } |
119 | 121 | ||
120 | screenbuffer_putchar(scr, ' '); |
122 | screenbuffer_putchar(scr, ' '); |
121 | 123 | ||
122 | break; |
124 | break; |
123 | default: |
125 | default: |
124 | if (console == active_console) { |
126 | if (console == active_console) { |
125 | ipc_call_async_3(fb_info.phone, FB_PUTCHAR, key, scr->position_y, scr->position_x, NULL, NULL); |
127 | ipc_call_async_3(fb_info.phone, FB_PUTCHAR, key, scr->position_y, scr->position_x, NULL, NULL); |
126 | } |
128 | } |
127 | 129 | ||
128 | screenbuffer_putchar(scr, key); |
130 | screenbuffer_putchar(scr, key); |
129 | scr->position_x++; |
131 | scr->position_x++; |
130 | } |
132 | } |
131 | 133 | ||
132 | scr->position_y += (scr->position_x >= scr->size_x); |
134 | scr->position_y += (scr->position_x >= scr->size_x); |
133 | 135 | ||
134 | if (scr->position_y >= scr->size_y) { |
136 | if (scr->position_y >= scr->size_y) { |
135 | scr->position_y = scr->size_y - 1; |
137 | scr->position_y = scr->size_y - 1; |
136 | screenbuffer_clear_line(scr, scr->top_line++); |
138 | screenbuffer_clear_line(scr, scr->top_line++); |
137 | ipc_call_async(fb_info.phone, FB_SCROLL, 1, NULL, NULL); |
139 | ipc_call_async(fb_info.phone, FB_SCROLL, 1, NULL, NULL); |
138 | } |
140 | } |
139 | 141 | ||
140 | scr->position_x = scr->position_x % scr->size_x; |
142 | scr->position_x = scr->position_x % scr->size_x; |
141 | 143 | ||
142 | if (console == active_console) |
144 | if (console == active_console) |
143 | ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, scr->position_y, scr->position_x, NULL, NULL); |
145 | ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, scr->position_y, scr->position_x, NULL, NULL); |
144 | 146 | ||
145 | } |
147 | } |
146 | 148 | ||
147 | 149 | ||
148 | /* Handler for keyboard */ |
150 | /* Handler for keyboard */ |
149 | static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall) |
151 | static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall) |
150 | { |
152 | { |
151 | ipc_callid_t callid; |
153 | ipc_callid_t callid; |
152 | ipc_call_t call; |
154 | ipc_call_t call; |
153 | int retval; |
155 | int retval; |
154 | int i, j; |
156 | int i, j; |
155 | char c,d; |
157 | char c,d; |
156 | connection_t *conn; |
158 | connection_t *conn; |
- | 159 | keyfield_t *interbuffer = NULL; |
|
157 | 160 | ||
- | 161 | // interbuffer = mmap(,, PROTO_READ|PROTO_WRITE, MAP_ANONYMOUS, , ); |
|
- | 162 | ||
158 | /* Ignore parameters, the connection is alread opened */ |
163 | /* Ignore parameters, the connection is alread opened */ |
159 | while (1) { |
164 | while (1) { |
160 | callid = async_get_call(&call); |
165 | callid = async_get_call(&call); |
161 | switch (IPC_GET_METHOD(call)) { |
166 | switch (IPC_GET_METHOD(call)) { |
162 | case IPC_M_PHONE_HUNGUP: |
167 | case IPC_M_PHONE_HUNGUP: |
163 | ipc_answer_fast(callid,0,0,0); |
168 | ipc_answer_fast(callid,0,0,0); |
164 | /* TODO: Handle hangup */ |
169 | /* TODO: Handle hangup */ |
165 | return; |
170 | return; |
166 | case KBD_PUSHCHAR: |
171 | case KBD_PUSHCHAR: |
167 | /* got key from keyboard driver */ |
172 | /* got key from keyboard driver */ |
168 | 173 | ||
169 | retval = 0; |
174 | retval = 0; |
170 | c = IPC_GET_ARG1(call); |
175 | c = IPC_GET_ARG1(call); |
171 | /* switch to another virtual console */ |
176 | /* switch to another virtual console */ |
172 | 177 | ||
173 | conn = &connections[active_console]; |
178 | conn = &connections[active_console]; |
174 | // if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) { |
179 | // if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) { |
175 | if ((c >= '1') && (c < '1' + CONSOLE_COUNT)) { |
180 | if ((c >= '1') && (c < '1' + CONSOLE_COUNT)) { |
176 | /*FIXME: draw another console content from buffer */ |
181 | /*FIXME: draw another console content from buffer */ |
177 | if (c - '1' == active_console) |
182 | if (c - '1' == active_console) |
178 | break; |
183 | break; |
179 | active_console = c - '1'; |
184 | active_console = c - '1'; |
180 | conn = &connections[active_console]; |
185 | conn = &connections[active_console]; |
181 | 186 | ||
182 | ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 0, NULL, NULL); |
187 | ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 0, NULL, NULL); |
183 | ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL); |
188 | ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL); |
184 | 189 | ||
185 | for (i = 0; i < conn->screenbuffer.size_x; i++) |
190 | for (i = 0; i < conn->screenbuffer.size_x; i++) |
186 | for (j = 0; j < conn->screenbuffer.size_y; j++) { |
191 | for (j = 0; j < conn->screenbuffer.size_y; j++) { |
187 | d = get_field_at(&(conn->screenbuffer),i, j)->character; |
192 | d = get_field_at(&(conn->screenbuffer),i, j)->character; |
188 | if (d && d != ' ') |
193 | if (d && d != ' ') |
189 | ipc_call_async_3(fb_info.phone, FB_PUTCHAR, d, j, i, NULL, NULL); |
194 | ipc_call_async_3(fb_info.phone, FB_PUTCHAR, d, j, i, NULL, NULL); |
190 | } |
195 | } |
191 | 196 | ||
192 | ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, conn->screenbuffer.position_y, conn->screenbuffer.position_x, NULL, NULL); |
197 | ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, conn->screenbuffer.position_y, conn->screenbuffer.position_x, NULL, NULL); |
193 | ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL, NULL); |
198 | ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL, NULL); |
194 | 199 | ||
195 | break; |
200 | break; |
196 | } |
201 | } |
197 | 202 | ||
198 | /* if client is awaiting key, send it */ |
203 | /* if client is awaiting key, send it */ |
199 | if (conn->keyrequest_counter > 0) { |
204 | if (conn->keyrequest_counter > 0) { |
200 | conn->keyrequest_counter--; |
205 | conn->keyrequest_counter--; |
201 | ipc_answer_fast(fifo_pop(conn->keyrequests), 0, c, 0); |
206 | ipc_answer_fast(fifo_pop(conn->keyrequests), 0, c, 0); |
202 | break; |
207 | break; |
203 | } |
208 | } |
204 | 209 | ||
205 | /*FIXME: else store key to its buffer */ |
210 | /*FIXME: else store key to its buffer */ |
206 | keybuffer_push(&conn->keybuffer, c); |
211 | keybuffer_push(&conn->keybuffer, c); |
207 | 212 | ||
208 | break; |
213 | break; |
209 | default: |
214 | default: |
210 | retval = ENOENT; |
215 | retval = ENOENT; |
211 | } |
216 | } |
212 | ipc_answer_fast(callid, retval, 0, 0); |
217 | ipc_answer_fast(callid, retval, 0, 0); |
213 | } |
218 | } |
214 | } |
219 | } |
215 | 220 | ||
216 | /** Default thread for new connections */ |
221 | /** Default thread for new connections */ |
217 | void client_connection(ipc_callid_t iid, ipc_call_t *icall) |
222 | void client_connection(ipc_callid_t iid, ipc_call_t *icall) |
218 | { |
223 | { |
219 | ipc_callid_t callid; |
224 | ipc_callid_t callid; |
220 | ipc_call_t call; |
225 | ipc_call_t call; |
221 | int consnum; |
226 | int consnum; |
222 | ipcarg_t arg1; |
227 | ipcarg_t arg1; |
223 | 228 | ||
224 | if ((consnum = find_free_connection()) == CONSOLE_COUNT) { |
229 | if ((consnum = find_free_connection()) == CONSOLE_COUNT) { |
225 | ipc_answer_fast(iid,ELIMIT,0,0); |
230 | ipc_answer_fast(iid,ELIMIT,0,0); |
226 | return; |
231 | return; |
227 | } |
232 | } |
228 | 233 | ||
229 | connections[consnum].used = 1; |
234 | connections[consnum].used = 1; |
230 | connections[consnum].client_phone = IPC_GET_ARG3(call); |
235 | connections[consnum].client_phone = IPC_GET_ARG3(call); |
231 | screenbuffer_clear(&(connections[consnum].screenbuffer)); |
236 | screenbuffer_clear(&(connections[consnum].screenbuffer)); |
232 | 237 | ||
233 | /* Accept the connection */ |
238 | /* Accept the connection */ |
234 | ipc_answer_fast(iid,0,0,0); |
239 | ipc_answer_fast(iid,0,0,0); |
235 | 240 | ||
236 | while (1) { |
241 | while (1) { |
237 | callid = async_get_call(&call); |
242 | callid = async_get_call(&call); |
238 | switch (IPC_GET_METHOD(call)) { |
243 | switch (IPC_GET_METHOD(call)) { |
239 | case IPC_M_PHONE_HUNGUP: |
244 | case IPC_M_PHONE_HUNGUP: |
240 | /* TODO */ |
245 | /* TODO */ |
241 | ipc_answer_fast(callid, 0,0,0); |
246 | ipc_answer_fast(callid, 0,0,0); |
242 | return; |
247 | return; |
243 | case CONSOLE_PUTCHAR: |
248 | case CONSOLE_PUTCHAR: |
244 | write_char(consnum, IPC_GET_ARG1(call)); |
249 | write_char(consnum, IPC_GET_ARG1(call)); |
245 | break; |
250 | break; |
246 | case CONSOLE_CLEAR: |
251 | case CONSOLE_CLEAR: |
247 | /* Send message to fb */ |
252 | /* Send message to fb */ |
248 | if (consnum == active_console) { |
253 | if (consnum == active_console) { |
249 | ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL); |
254 | ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL); |
250 | } |
255 | } |
251 | 256 | ||
252 | screenbuffer_clear(&(connections[consnum].screenbuffer)); |
257 | screenbuffer_clear(&(connections[consnum].screenbuffer)); |
253 | 258 | ||
254 | break; |
259 | break; |
255 | case CONSOLE_GOTO: |
260 | case CONSOLE_GOTO: |
256 | 261 | ||
257 | screenbuffer_goto(&(connections[consnum].screenbuffer), IPC_GET_ARG1(call), IPC_GET_ARG2(call)); |
262 | screenbuffer_goto(&(connections[consnum].screenbuffer), IPC_GET_ARG1(call), IPC_GET_ARG2(call)); |
258 | 263 | ||
259 | break; |
264 | break; |
260 | 265 | ||
261 | case CONSOLE_GETCHAR: |
266 | case CONSOLE_GETCHAR: |
262 | if (keybuffer_empty(&(connections[consnum].keybuffer))) { |
267 | if (keybuffer_empty(&(connections[consnum].keybuffer))) { |
263 | /* buffer is empty -> store request */ |
268 | /* buffer is empty -> store request */ |
264 | if (connections[consnum].keyrequest_counter < MAX_KEYREQUESTS_BUFFERED) { |
269 | if (connections[consnum].keyrequest_counter < MAX_KEYREQUESTS_BUFFERED) { |
265 | fifo_push(connections[consnum].keyrequests, callid); |
270 | fifo_push(connections[consnum].keyrequests, callid); |
266 | connections[consnum].keyrequest_counter++; |
271 | connections[consnum].keyrequest_counter++; |
267 | } else { |
272 | } else { |
268 | /* no key available and too many requests => fail */ |
273 | /* no key available and too many requests => fail */ |
269 | ipc_answer_fast(callid, ELIMIT, 0, 0); |
274 | ipc_answer_fast(callid, ELIMIT, 0, 0); |
270 | } |
275 | } |
271 | continue; |
276 | continue; |
272 | }; |
277 | }; |
273 | keybuffer_pop(&(connections[consnum].keybuffer), (char *)&arg1); |
278 | keybuffer_pop(&(connections[consnum].keybuffer), (char *)&arg1); |
274 | 279 | ||
275 | break; |
280 | break; |
276 | } |
281 | } |
277 | ipc_answer_fast(callid, 0, arg1, 0); |
282 | ipc_answer_fast(callid, 0, arg1, 0); |
278 | } |
283 | } |
279 | } |
284 | } |
280 | 285 | ||
281 | int main(int argc, char *argv[]) |
286 | int main(int argc, char *argv[]) |
282 | { |
287 | { |
283 | ipcarg_t phonehash; |
288 | ipcarg_t phonehash; |
284 | int kbd_phone, fb_phone; |
289 | int kbd_phone, fb_phone; |
285 | ipcarg_t retval, arg1 = 0xdead, arg2 = 0xbeef; |
290 | ipcarg_t retval, arg1 = 0xdead, arg2 = 0xbeef; |
286 | int i; |
291 | int i; |
287 | 292 | ||
288 | async_set_client_connection(client_connection); |
293 | async_set_client_connection(client_connection); |
289 | 294 | ||
290 | /* Connect to keyboard driver */ |
295 | /* Connect to keyboard driver */ |
291 | 296 | ||
292 | while ((kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0)) < 0) { |
297 | while ((kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0)) < 0) { |
293 | usleep(10000); |
298 | usleep(10000); |
294 | }; |
299 | }; |
295 | 300 | ||
296 | if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, &phonehash) != 0) { |
301 | if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, &phonehash) != 0) { |
297 | return -1; |
302 | return -1; |
298 | }; |
303 | }; |
299 | async_new_connection(phonehash, 0, NULL, keyboard_events); |
- | |
300 | 304 | ||
301 | /* Connect to framebuffer driver */ |
305 | /* Connect to framebuffer driver */ |
302 | 306 | ||
303 | while ((fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) < 0) { |
307 | while ((fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) < 0) { |
304 | usleep(10000); |
308 | usleep(10000); |
305 | } |
309 | } |
306 | 310 | ||
307 | ipc_call_sync_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols)); |
311 | ipc_call_sync_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols)); |
308 | ipc_call_sync(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL); |
312 | ipc_call_sync(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL); |
309 | 313 | ||
310 | /* Init virtual consoles */ |
314 | /* Init virtual consoles */ |
311 | for (i = 0; i < CONSOLE_COUNT; i++) { |
315 | for (i = 0; i < CONSOLE_COUNT; i++) { |
312 | connections[i].used = 0; |
316 | connections[i].used = 0; |
313 | keybuffer_init(&(connections[i].keybuffer)); |
317 | keybuffer_init(&(connections[i].keybuffer)); |
314 | 318 | ||
315 | connections[i].keyrequests.head = connections[i].keyrequests.tail = 0; |
319 | connections[i].keyrequests.head = connections[i].keyrequests.tail = 0; |
316 | connections[i].keyrequests.items = MAX_KEYREQUESTS_BUFFERED; |
320 | connections[i].keyrequests.items = MAX_KEYREQUESTS_BUFFERED; |
317 | connections[i].keyrequest_counter = 0; |
321 | connections[i].keyrequest_counter = 0; |
318 | 322 | ||
319 | if (screenbuffer_init(&(connections[i].screenbuffer), fb_info.cols, fb_info.rows ) == NULL) { |
323 | if (screenbuffer_init(&(connections[i].screenbuffer), fb_info.cols, fb_info.rows ) == NULL) { |
320 | /*FIXME: handle error */ |
324 | /*FIXME: handle error */ |
321 | return -1; |
325 | return -1; |
322 | } |
326 | } |
323 | } |
327 | } |
324 | 328 | ||
- | 329 | async_new_connection(phonehash, 0, NULL, keyboard_events); |
|
- | 330 | ||
325 | ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, 0, 0, NULL, NULL); |
331 | ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, 0, 0, NULL, NULL); |
326 | 332 | ||
327 | if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) { |
333 | if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) { |
328 | return -1; |
334 | return -1; |
329 | }; |
335 | }; |
330 | 336 | ||
331 | async_manager(); |
337 | async_manager(); |
332 | 338 | ||
333 | return 0; |
339 | return 0; |
334 | } |
340 | } |
335 | 341 |