Changeset 47a350f in mainline for uspace/srv
- Timestamp:
- 2009-12-16T01:49:16Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- df747bd8
- Parents:
- 4491338
- Location:
- uspace/srv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/console/console.c
r4491338 r47a350f 50 50 #include <event.h> 51 51 #include <devmap.h> 52 #include <fcntl.h> 53 #include <vfs/vfs.h> 52 54 #include <fibril_synch.h> 53 55 … … 665 667 } 666 668 667 static bool console_init(void) 668 { 669 ipcarg_t color_cap; 670 671 /* Connect to keyboard driver */ 672 kbd_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_KEYBOARD, 0, 0); 669 static bool console_init(char *input) 670 { 671 /* Connect to input device */ 672 int input_fd = open(input, O_RDONLY); 673 if (input_fd < 0) { 674 printf(NAME ": Failed opening %s\n", input); 675 return false; 676 } 677 678 kbd_phone = fd_phone(input_fd); 673 679 if (kbd_phone < 0) { 674 printf(NAME ": Failed to connect to keyboard service\n");680 printf(NAME ": Failed to connect to input device\n"); 675 681 return false; 676 682 } 677 683 684 /* NB: The callback connection is slotted for removal */ 678 685 ipcarg_t phonehash; 679 686 if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) { 680 printf(NAME ": Failed to create callback from keyboard service\n");687 printf(NAME ": Failed to create callback from input device\n"); 681 688 return false; 682 689 } … … 702 709 703 710 /* Synchronize, the gcons could put something in queue */ 711 ipcarg_t color_cap; 704 712 async_req_0_0(fb_info.phone, FB_FLUSH); 705 713 async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.cols, &fb_info.rows); … … 771 779 } 772 780 781 static void usage(void) 782 { 783 printf("Usage: console <input>\n"); 784 } 785 773 786 int main(int argc, char *argv[]) 774 787 { 788 if (argc < 2) { 789 usage(); 790 return -1; 791 } 792 775 793 printf(NAME ": HelenOS Console service\n"); 776 794 777 if (!console_init( ))795 if (!console_init(argv[1])) 778 796 return -1; 779 797 -
uspace/srv/kbd/generic/kbd.c
r4491338 r47a350f 50 50 #include <io/console.h> 51 51 #include <io/keycode.h> 52 #include <devmap.h> 52 53 53 54 #include <kbd.h> … … 56 57 #include <layout.h> 57 58 58 #define NAME "kbd"59 60 int cons_connected = 0; 59 #define NAME "kbd" 60 #define NAMESPACE "hid_in" 61 61 62 int phone2cons = -1; 62 63 … … 172 173 int retval; 173 174 174 if (cons_connected) {175 ipc_answer_0(iid, ELIMIT);176 return;177 }178 cons_connected = 1;179 175 ipc_answer_0(iid, EOK); 180 176 … … 183 179 switch (IPC_GET_METHOD(call)) { 184 180 case IPC_M_PHONE_HUNGUP: 185 cons_connected = 0; 186 ipc_hangup(phone2cons); 187 phone2cons = -1; 181 if (phone2cons != -1) { 182 ipc_hangup(phone2cons); 183 phone2cons = -1; 184 } 185 188 186 ipc_answer_0(callid, EOK); 189 187 return; … … 216 214 printf(NAME ": HelenOS Keyboard service\n"); 217 215 218 ipcarg_t phonead;219 220 216 if (sysinfo_value("kbd.cir.fhc") == 1) 221 217 cir_service = SERVICE_FHC; … … 241 237 layout[active_layout]->reset(); 242 238 243 async_set_client_connection(console_connection); 244 245 /* Register service at nameserver. */ 246 if (ipc_connect_to_me(PHONE_NS, SERVICE_KEYBOARD, 0, 0, &phonead) != 0) 247 return -1; 248 239 /* Register driver */ 240 int rc = devmap_driver_register(NAME, console_connection); 241 if (rc < 0) { 242 printf(NAME ": Unable to register driver (%d)\n", rc); 243 return -1; 244 } 245 246 char kbd[DEVMAP_NAME_MAXLEN + 1]; 247 snprintf(kbd, DEVMAP_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME); 248 249 dev_handle_t dev_handle; 250 if (devmap_device_register(kbd, &dev_handle) != EOK) { 251 printf(NAME ": Unable to register device %s\n", kbd); 252 return -1; 253 } 254 249 255 printf(NAME ": Accepting connections\n"); 250 256 async_manager();
Note:
See TracChangeset
for help on using the changeset viewer.