Changeset c1d2c9d in mainline
- Timestamp:
- 2006-06-01T21:51:35Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- da0c91e7
- Parents:
- 3993b3d
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
console/console.c
r3993b3d rc1d2c9d 41 41 #include <screenbuffer.h> 42 42 43 static void sysput(char c)44 {45 __SYSCALL3(SYS_IO, 1, &c, 1);46 }47 48 //#define CONSOLE_COUNT VFB_CONNECTIONS49 43 #define CONSOLE_COUNT 8 50 44 #define MAX_KEYREQUESTS_BUFFERED 32 … … 103 97 int retval; 104 98 int i, j; 105 char c; 99 char c,d; 100 connection_t *conn; 106 101 107 102 /* Ignore parameters, the connection is alread opened */ … … 118 113 retval = 0; 119 114 c = IPC_GET_ARG1(call); 120 // ipc_call_sync_2(connections[3].vfb_phone, FB_PUTCHAR, 0, c,NULL,NULL);121 122 115 /* switch to another virtual console */ 123 116 117 conn = &connections[active_console]; 124 118 if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) { 125 119 /*FIXME: draw another console content from buffer */ 126 120 127 121 active_console = c - KBD_KEY_F1; 122 conn = &connections[active_console]; 123 124 ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 0, NULL, NULL); 128 125 ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL); 129 ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, 'a', 0, 0,NULL,NULL, NULL);130 131 for (i = 0; i < connections[active_console].screenbuffer.size_x; i++)132 for (j = 0; j < connections[active_console].screenbuffer.size_y; j++) {133 134 ipc_call_async_3(fb_info.phone, FB_PUTCHAR, get_field_at(&(connections[active_console].screenbuffer),\135 i, j)->character, j, i, NULL, NULL, NULL);136 }126 for (i = 0; i < conn->screenbuffer.size_x; i++) 127 for (j = 0; j < conn->screenbuffer.size_y; j++) { 128 d = get_field_at(&(conn->screenbuffer),i, j)->character; 129 if (d && d != ' ') 130 ipc_call_async_3(fb_info.phone, FB_PUTCHAR, d, j, i, NULL, NULL); 131 } 132 ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, conn->screenbuffer.position_y, conn->screenbuffer.position_x, NULL, NULL); 133 ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL, NULL); 137 134 138 135 break; … … 140 137 141 138 /* if client is awaiting key, send it */ 142 if (conn ections[active_console].keyrequest_counter > 0) {143 conn ections[active_console].keyrequest_counter--;144 ipc_answer_fast(fifo_pop(conn ections[active_console].keyrequests), 0, c, 0);139 if (conn->keyrequest_counter > 0) { 140 conn->keyrequest_counter--; 141 ipc_answer_fast(fifo_pop(conn->keyrequests), 0, c, 0); 145 142 break; 146 143 } 147 144 148 145 /*FIXME: else store key to its buffer */ 149 keybuffer_push(&(connections[active_console].keybuffer), c); 150 151 /* Send it to first FB, DEBUG */ 152 // ipc_call_async_2(connections[0].vfb_phone, FB_PUTCHAR, 0, IPC_GET_ARG1(call),NULL,NULL); 153 // ipc_call_sync_2(connections[4].vfb_phone, FB_PUTCHAR, 0, c,NULL,NULL); 154 146 keybuffer_push(&conn->keybuffer, c); 147 155 148 break; 156 149 default: … … 192 185 /* Send message to fb */ 193 186 if (consnum == active_console) { 194 ipc_call_ sync_3(fb_info.phone, FB_PUTCHAR, IPC_GET_ARG2(call), connections[consnum].screenbuffer.position_y, \195 connections[consnum].screenbuffer.position_x, NULL, NULL , NULL);187 ipc_call_async_3(fb_info.phone, FB_PUTCHAR, IPC_GET_ARG2(call), connections[consnum].screenbuffer.position_y, \ 188 connections[consnum].screenbuffer.position_x, NULL, NULL); 196 189 } 197 190 … … 226 219 }; 227 220 keybuffer_pop(&(connections[consnum].keybuffer), (char *)&arg1); 228 // ipc_call_sync_2(connections[6].vfb_phone, FB_PUTCHAR, 0, arg1,NULL,NULL);229 221 230 222 break; … … 258 250 } 259 251 260 ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, '1', 0, 0,NULL,NULL, NULL);261 252 ipc_call_sync_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols)); 253 ipc_call_sync(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL); 262 254 263 255 /* Init virtual consoles */ 264 256 for (i = 0; i < CONSOLE_COUNT; i++) { 265 ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, '$', 2*i, 1,NULL,NULL, NULL);266 257 connections[i].used = 0; 267 258 keybuffer_init(&(connections[i].keybuffer)); 268 ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, '>', 2*i+1, 1,NULL,NULL, NULL);269 259 270 260 connections[i].keyrequests.head = connections[i].keyrequests.tail = 0; … … 272 262 connections[i].keyrequest_counter = 0; 273 263 274 ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, '?', 2*i+1, 1,NULL,NULL, NULL);275 264 if (screenbuffer_init(&(connections[i].screenbuffer), fb_info.cols, fb_info.rows ) == NULL) { 276 265 /*FIXME: handle error */ … … 283 272 }; 284 273 285 ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, 'M', 3, 3,NULL,NULL, NULL);286 274 async_manager(); 287 275 -
fb/fb.c
r3993b3d rc1d2c9d 269 269 270 270 /** Invert character at given position */ 271 static void invert_char(int vp,unsigned int col, unsigned int row)271 static void invert_char(int vp,unsigned int row, unsigned int col) 272 272 { 273 273 unsigned int x; … … 334 334 viewports[i].fgcolor = DEFAULT_FGCOLOR; 335 335 336 viewports[i].cur_col = 0; 337 viewports[i].cur_row = 0; 338 viewports[i].cursor_active = 0; 339 336 340 viewports[i].initialized = 1; 337 341 … … 416 420 } 417 421 418 static void draw_char(int vp, char c, unsigned int col, unsigned int row)422 static void draw_char(int vp, char c, unsigned int row, unsigned int col) 419 423 { 420 424 viewport_t *vport = &viewports[vp]; 421 425 422 426 if (vport->cursor_active && (vport->cur_col != col || vport->cur_row != row)) 423 invert_char(vp, vport->cur_ col,vport->cur_row);424 425 draw_glyph(vp, c, col, row);426 427 if (vport->cursor_active) {428 vport->cur_col++;429 if (vport->cur_col>= vport->cols) { 430 vport->cur_col = 0;431 vport->cur_row++;432 if (vport->cur_row >= vport->rows)433 vport->cur_row--;434 }435 invert_char(vp, vport->cur_col,vport->cur_row);427 invert_char(vp, vport->cur_row, vport->cur_col); 428 429 draw_glyph(vp, c, row, col); 430 431 vport->cur_col = col; 432 vport->cur_row = row; 433 434 vport->cur_col++; 435 if (vport->cur_col>= vport->cols) { 436 vport->cur_col = 0; 437 vport->cur_row++; 438 if (vport->cur_row >= vport->rows) 439 vport->cur_row--; 436 440 } 441 if (vport->cursor_active) 442 invert_char(vp, vport->cur_row, vport->cur_col); 437 443 } 438 444 … … 481 487 clear_port(vp); 482 488 if (vport->cursor_active) 483 invert_char(vp, vport->cur_ col,vport->cur_row);489 invert_char(vp, vport->cur_row, vport->cur_col); 484 490 retval = 0; 485 491 break; … … 493 499 retval = 0; 494 500 if (viewports[vp].cursor_active) { 495 invert_char(vp, vport->cur_ col,vport->cur_row);496 invert_char(vp, col, row);501 invert_char(vp, vport->cur_row, vport->cur_col); 502 invert_char(vp, row, col); 497 503 } 498 504 vport->cur_col = col; … … 506 512 507 513 vport->cursor_active = i; 508 invert_char(vp, vport->cur_ col,vport->cur_row);514 invert_char(vp, vport->cur_row, vport->cur_col); 509 515 break; 510 516 case FB_GET_CSIZE: … … 518 524 } 519 525 if (vport->cursor_active) 520 invert_char(vp, vport->cur_ col,vport->cur_row);526 invert_char(vp, vport->cur_row, vport->cur_col); 521 527 scroll_port(vp, i); 522 528 if (vport->cursor_active) 523 invert_char(vp, vport->cur_ col,vport->cur_row);529 invert_char(vp, vport->cur_row, vport->cur_col); 524 530 retval = 0; 525 531 break; -
init/init.c
r3993b3d rc1d2c9d 446 446 // test_async_kbd(); 447 447 // test_fb(); 448 //test_console();448 test_console(); 449 449 450 450 printf("\nBye.\n"); -
libc/generic/ipc.c
r3993b3d rc1d2c9d 116 116 } 117 117 118 /** Send asynchronous message 119 * 120 * - if fatal error, call callback handler with proper error code 121 * - if message cannot be temporarily sent, add to queue 122 */ 123 void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1, 124 ipcarg_t arg2, void *private, 125 ipc_async_callback_t callback) 118 /** Prolog to ipc_async_send functions */ 119 static inline async_call_t *ipc_prepare_async(void *private, ipc_async_callback_t callback) 126 120 { 127 121 async_call_t *call; 128 ipc_callid_t callid;129 122 130 123 call = malloc(sizeof(*call)); … … 132 125 if (callback) 133 126 callback(private, ENOMEM, NULL); 134 return; 135 } 136 127 return NULL; 128 } 137 129 call->callback = callback; 138 130 call->private = private; 131 132 return call; 133 } 134 135 /** Epilogue of ipc_async_send functions */ 136 static inline void ipc_finish_async(ipc_callid_t callid, int phoneid, async_call_t *call) 137 { 138 if (callid == IPC_CALLRET_FATAL) { 139 futex_up(&ipc_futex); 140 /* Call asynchronous handler with error code */ 141 if (call->callback) 142 call->callback(call->private, ENOENT, NULL); 143 free(call); 144 return; 145 } 146 147 if (callid == IPC_CALLRET_TEMPORARY) { 148 futex_up(&ipc_futex); 149 150 call->u.msg.phoneid = phoneid; 151 152 call->ptid = psthread_get_id(); 153 futex_down(&async_futex); 154 list_append(&call->list, &queued_calls); 155 156 psthread_schedule_next_adv(PS_TO_MANAGER); 157 /* Async futex unlocked by previous call */ 158 return; 159 } 160 call->u.callid = callid; 161 /* Add call to list of dispatched calls */ 162 list_append(&call->list, &dispatched_calls); 163 futex_up(&ipc_futex); 164 165 } 166 167 /** Send asynchronous message 168 * 169 * - if fatal error, call callback handler with proper error code 170 * - if message cannot be temporarily sent, add to queue 171 */ 172 void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1, 173 ipcarg_t arg2, void *private, 174 ipc_async_callback_t callback) 175 { 176 async_call_t *call; 177 ipc_callid_t callid; 178 179 call = ipc_prepare_async(private, callback); 180 if (!call) 181 return; 139 182 140 183 /* We need to make sure that we get callid before … … 142 185 futex_down(&ipc_futex); 143 186 callid = __SYSCALL4(SYS_IPC_CALL_ASYNC_FAST, phoneid, method, arg1, arg2); 144 if (callid == IPC_CALLRET_FATAL) {145 futex_up(&ipc_futex);146 /* Call asynchronous handler with error code */147 if (callback)148 callback(private, ENOENT, NULL);149 free(call);150 return;151 }152 187 153 188 if (callid == IPC_CALLRET_TEMPORARY) { 154 futex_up(&ipc_futex);155 156 call->u.msg.phoneid = phoneid;157 189 IPC_SET_METHOD(call->u.msg.data, method); 158 190 IPC_SET_ARG1(call->u.msg.data, arg1); 159 191 IPC_SET_ARG2(call->u.msg.data, arg2); 160 161 call->ptid = psthread_get_id(); 162 futex_down(&async_futex); 163 list_append(&call->list, &queued_calls); 164 165 psthread_schedule_next_adv(PS_TO_MANAGER); 166 /* Async futex unlocked by previous call */ 192 } 193 ipc_finish_async(callid, phoneid, call); 194 } 195 196 /** Send asynchronous message 197 * 198 * - if fatal error, call callback handler with proper error code 199 * - if message cannot be temporarily sent, add to queue 200 */ 201 void ipc_call_async_3(int phoneid, ipcarg_t method, ipcarg_t arg1, 202 ipcarg_t arg2, ipcarg_t arg3, void *private, 203 ipc_async_callback_t callback) 204 { 205 async_call_t *call; 206 ipc_callid_t callid; 207 208 call = ipc_prepare_async(private, callback); 209 if (!call) 167 210 return; 168 } 169 call->u.callid = callid; 170 /* Add call to list of dispatched calls */ 171 list_append(&call->list, &dispatched_calls); 172 futex_up(&ipc_futex); 211 212 IPC_SET_METHOD(call->u.msg.data, method); 213 IPC_SET_ARG1(call->u.msg.data, arg1); 214 IPC_SET_ARG2(call->u.msg.data, arg2); 215 IPC_SET_ARG3(call->u.msg.data, arg3); 216 /* We need to make sure that we get callid before 217 * another thread accesses the queue again */ 218 futex_down(&ipc_futex); 219 callid = _ipc_call_async(phoneid, &call->u.msg.data); 220 221 ipc_finish_async(callid, phoneid, call); 173 222 } 174 223 -
libc/include/ipc/ipc.h
r3993b3d rc1d2c9d 71 71 ipcarg_t arg2, void *private, 72 72 ipc_async_callback_t callback); 73 extern void ipc_call_async_3(int phoneid, ipcarg_t method, ipcarg_t arg1, 74 ipcarg_t arg2, ipcarg_t arg3, void *private, 75 ipc_async_callback_t callback); 73 76 extern int ipc_connect_to_me(int phoneid, int arg1, int arg2, ipcarg_t *phone); 74 77 extern int ipc_connect_me_to(int phoneid, int arg1, int arg2);
Note:
See TracChangeset
for help on using the changeset viewer.