Changeset eaf34f7 in mainline
- Timestamp:
- 2006-05-30T18:01:51Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1029d3d3
- Parents:
- 44c6d88d
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
console/console.c
r44c6d88d reaf34f7 36 36 #include <key_buffer.h> 37 37 #include <console.h> 38 #include <unistd.h> 39 #include <async.h> 38 40 39 41 //#define CONSOLE_COUNT VFB_CONNECTIONS … … 41 43 42 44 #define NAME "CONSOLE" 45 46 int active_client = 0; 47 43 48 44 49 typedef struct { … … 77 82 } 78 83 84 /* Handler for keyboard */ 85 static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall) 86 { 87 ipc_callid_t callid; 88 ipc_call_t call; 89 int retval; 90 int i; 91 92 /* Ignore parameters, the connection is alread opened */ 93 while (1) { 94 callid = async_get_call(&call); 95 switch (IPC_GET_METHOD(call)) { 96 case IPC_M_PHONE_HUNGUP: 97 ipc_answer_fast(callid,0,0,0); 98 /* TODO: Handle hangup */ 99 return; 100 case KBD_PUSHCHAR: 101 /* got key from keyboard driver */ 102 /* find active console */ 103 /* if client is awaiting key, send it */ 104 /*FIXME: else store key to its buffer */ 105 retval = 0; 106 i = IPC_GET_ARG1(call) & 0xff; 107 /* switch to another virtual console */ 108 if ((i >= KBD_KEY_F1) && (i < KBD_KEY_F1 + CONSOLE_COUNT)) { 109 active_client = i - KBD_KEY_F1; 110 break; 111 } 112 keybuffer_push(&(connections[active_client].keybuffer), i); 113 /* Send it to first FB, DEBUG */ 114 ipc_call_async_2(connections[0].vfb_phone, FB_PUTCHAR, 0, IPC_GET_ARG1(call),NULL,NULL); 115 ipc_answer_fast(callid, 0, 0, 0); 116 break; 117 default: 118 ipc_answer_fast(callid,ENOENT,0,0); 119 } 120 } 121 } 122 123 /** Default thread for new connections */ 124 void client_connection(ipc_callid_t iid, ipc_call_t *icall) 125 { 126 ipc_callid_t callid; 127 ipc_call_t call; 128 int consnum; 129 ipcarg_t arg1; 130 131 if ((consnum = find_free_connection()) == CONSOLE_COUNT) { 132 ipc_answer_fast(iid,ELIMIT,0,0); 133 return; 134 } 135 connections[consnum].used = 1; 136 connections[consnum].client_phone = IPC_GET_ARG3(call); 137 138 /* Accept the connection */ 139 ipc_answer_fast(iid,0,0,0); 140 141 while (1) { 142 callid = async_get_call(&call); 143 switch (IPC_GET_METHOD(call)) { 144 case IPC_M_PHONE_HUNGUP: 145 /* TODO */ 146 ipc_answer_fast(callid, 0,0,0); 147 return; 148 case CONSOLE_PUTCHAR: 149 /* TODO: send message to fb */ 150 ipc_call_async_2(connections[consnum].vfb_phone, FB_PUTCHAR, IPC_GET_ARG1(call), IPC_GET_ARG2(call), NULL, NULL); 151 break; 152 case CONSOLE_GETCHAR: 153 /* FIXME: */ 154 if (!keybuffer_pop(&(connections[active_client].keybuffer), (char *)&arg1)) { 155 /* FIXME: buffer empty -> store request */ 156 arg1 = 'X'; /* Only temporary */ 157 }; 158 //ipc_call_async_2(connections[active_client].vfb_phone, FB_PUTCHAR, ' ', arg1, NULL, (void *)NULL); 159 break; 160 } 161 ipc_answer_fast(callid, 0,0,0); 162 } 163 } 164 79 165 int main(int argc, char *argv[]) 80 166 { 81 ipcarg_t phonead; 82 ipc_call_t call; 83 ipc_callid_t callid; 167 ipcarg_t phonehash; 84 168 int kbd_phone, fb_phone; 85 169 ipcarg_t retval, arg1 = 0xdead, arg2 = 0xbeef; 86 170 int i; 87 int active_client = 0;88 171 89 172 /* Connect to keyboard driver */ 90 173 91 174 while ((kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0)) < 0) { 175 usleep(10000); 92 176 }; 93 177 94 if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, &phone ad) != 0) {178 if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, &phonehash) != 0) { 95 179 return -1; 96 180 }; 181 async_new_connection(phonehash, 0, NULL, keyboard_events); 97 182 98 183 /* Connect to framebuffer driver */ … … 104 189 while ((connections[i].vfb_phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) < 0) { 105 190 106 ipc_call_async_2(connections[i].vfb_phone, FB_PUTCHAR, 'a', 'b', NULL, (void *)NULL);191 ipc_call_async_2(connections[i].vfb_phone, FB_PUTCHAR, 'a', 'b', NULL, (void *)NULL); 107 192 } 108 193 } 109 194 110 111 112 if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonead) != 0) { 195 if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) { 113 196 return -1; 114 197 }; 115 198 116 while (1) { 117 callid = ipc_wait_for_call(&call); 118 switch (IPC_GET_METHOD(call)) { 119 case IPC_M_PHONE_HUNGUP: 120 /*FIXME: if its fb or kbd then panic! */ 121 /* free connection */ 122 if (i = find_connection(IPC_GET_ARG3(call)) < CONSOLE_COUNT) { 123 connections[i].used = 0; 124 /*TODO: free connection[i].key_buffer; */ 125 /* FIXME: active_connection hungup */ 126 retval = 0; 127 } else { 128 /*FIXME: No such connection */ 129 } 130 break; 131 case IPC_M_CONNECT_ME_TO: 132 133 /* find first free connection */ 134 135 if ((i = find_free_connection()) == CONSOLE_COUNT) { 136 retval = ELIMIT; 137 break; 138 } 139 140 connections[i].used = 1; 141 connections[i].client_phone = IPC_GET_ARG3(call); 142 143 retval = 0; 144 break; 145 case KBD_PUSHCHAR: 146 /* got key from keyboard driver */ 147 /* find active console */ 148 /* if client is awaiting key, send it */ 149 /*FIXME: else store key to its buffer */ 150 retval = 0; 151 i = IPC_GET_ARG1(call) & 0xff; 152 /* switch to another virtual console */ 153 if ((i >= KBD_KEY_F1) && (i < KBD_KEY_F1 + CONSOLE_COUNT)) { 154 active_client = i - KBD_KEY_F1; 155 break; 156 } 157 158 keybuffer_push(&(connections[active_client].keybuffer), i); 159 160 break; 161 case CONSOLE_PUTCHAR: 162 /* find sender client */ 163 /* ??? 164 * if its active client, send it to vfb 165 **/ 166 /*FIXME: check, if its from active client, .... */ 167 168 if ((i = find_connection(IPC_GET_ARG3(call))) == CONSOLE_COUNT) { 169 break; 170 }; 171 172 /* TODO: send message to fb */ 173 ipc_call_async_2(connections[i].vfb_phone, FB_PUTCHAR, IPC_GET_ARG1(call), IPC_GET_ARG2(call), NULL, NULL); 174 175 break; 176 case CONSOLE_GETCHAR: 177 /* FIXME: */ 178 if (!keybuffer_pop(&(connections[active_client].keybuffer), (char *)&arg1)) { 179 /* FIXME: buffer empty -> store request */ 180 arg1 = 'X'; /* Only temporary */ 181 }; 182 //ipc_call_async_2(connections[active_client].vfb_phone, FB_PUTCHAR, ' ', arg1, NULL, (void *)NULL); 183 break; 184 default: 185 retval = ENOENT; 186 break; 187 } 188 189 if (! (callid & IPC_CALLID_NOTIFICATION)) { 190 ipc_answer_fast(callid, retval, arg1, arg2); 191 } 192 } 199 async_manager(); 193 200 194 201 return 0; -
init/init.c
r44c6d88d reaf34f7 435 435 // test_kbd(); 436 436 // test_time(); 437 test_async_kbd();437 // test_async_kbd(); 438 438 // test_fb(); 439 439 -
libc/generic/async.c
r44c6d88d reaf34f7 270 270 } 271 271 272 /** Function that gets c reated on interrupt receival272 /** Function that gets called on interrupt receival 273 273 * 274 274 * This function is defined as a weak symbol - to be redefined in … … 343 343 conn->ptid = psthread_create(connection_thread, conn); 344 344 conn->callid = callid; 345 conn->call = *call; 345 if (call) 346 conn->call = *call; 346 347 conn->active = 1; /* We will activate it asap */ 347 348 conn->cthread = cthread; -
libc/generic/time.c
r44c6d88d reaf34f7 98 98 } 99 99 100 /** Wait unconditionally for specified mi liseconds */100 /** Wait unconditionally for specified microseconds */ 101 101 void usleep(unsigned long usec) 102 102 {
Note:
See TracChangeset
for help on using the changeset viewer.