Changes in / [664af708:eb1a2f4] in mainline
- Files:
-
- 152 added
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
r664af708 reb1a2f4 547 547 548 548 % Launch (devman) test drivers 549 ! [CONFIG_DEBUG=y] CONFIG_TEST_DRIVERS (y/n) 550 549 ! [CONFIG_DEBUG=y] CONFIG_TEST_DRIVERS (n/y) 550 551 % Start virtual USB host controller 552 ! CONFIG_RUN_VIRTUAL_USB_HC (n/y) 553 -
Makefile
r664af708 reb1a2f4 92 92 $(MAKE) -C uspace clean 93 93 $(MAKE) -C boot clean 94 95 -include Makefile.local -
boot/Makefile.common
r664af708 reb1a2f4 139 139 $(USPACE_PATH)/app/ping/ping \ 140 140 $(USPACE_PATH)/app/stats/stats \ 141 $(USPACE_PATH)/app/sysinfo/sysinfo \ 142 $(USPACE_PATH)/app/tasks/tasks \ 141 143 $(USPACE_PATH)/app/top/top \ 142 $(USPACE_PATH)/app/sysinfo/sysinfo \ 144 $(USPACE_PATH)/app/usbinfo/usbinfo \ 145 $(USPACE_PATH)/app/virtusbkbd/vuk \ 146 $(USPACE_PATH)/app/virtusbhub/vuh \ 143 147 $(USPACE_PATH)/app/websrv/websrv 144 148 -
boot/arch/amd64/Makefile.inc
r664af708 reb1a2f4 42 42 pciintel \ 43 43 isa \ 44 ns8250 44 ns8250 \ 45 uhci-hcd \ 46 uhci-rhd \ 47 usbhub \ 48 usbhid \ 49 usbmid \ 50 vhc 45 51 46 52 RD_DRV_CFG += \ -
kernel/generic/include/mm/page.h
r664af708 reb1a2f4 37 37 38 38 #include <typedefs.h> 39 #include <proc/task.h> 39 40 #include <mm/as.h> 40 41 #include <memstr.h> … … 62 63 extern uintptr_t hw_map(uintptr_t, size_t); 63 64 65 extern sysarg_t sys_page_find_mapping(uintptr_t, uintptr_t *); 66 64 67 #endif 65 68 -
kernel/generic/include/syscall/syscall.h
r664af708 reb1a2f4 61 61 SYS_AS_GET_UNMAPPED_AREA, 62 62 63 SYS_PAGE_FIND_MAPPING, 64 63 65 SYS_IPC_CALL_SYNC_FAST, 64 66 SYS_IPC_CALL_SYNC_SLOW, -
kernel/generic/src/mm/page.c
r664af708 reb1a2f4 60 60 61 61 #include <mm/page.h> 62 #include <genarch/mm/page_ht.h> 63 #include <genarch/mm/page_pt.h> 62 64 #include <arch/mm/page.h> 63 65 #include <arch/mm/asid.h> … … 70 72 #include <debug.h> 71 73 #include <arch.h> 74 #include <syscall/copy.h> 75 #include <errno.h> 72 76 73 77 /** Virtual operations for page subsystem. */ … … 173 177 } 174 178 179 /** Syscall wrapper for getting mapping of a virtual page. 180 * 181 * @retval EOK Everything went find, @p uspace_frame and @p uspace_node 182 * contains correct values. 183 * @retval ENOENT Virtual address has no mapping. 184 */ 185 sysarg_t sys_page_find_mapping(uintptr_t virt_address, 186 uintptr_t *uspace_frame) 187 { 188 mutex_lock(&AS->lock); 189 190 pte_t *pte = page_mapping_find(AS, virt_address); 191 if (!PTE_VALID(pte) || !PTE_PRESENT(pte)) { 192 mutex_unlock(&AS->lock); 193 194 return (sysarg_t) ENOENT; 195 } 196 197 uintptr_t phys_address = PTE_GET_FRAME(pte); 198 199 mutex_unlock(&AS->lock); 200 201 int rc = copy_to_uspace(uspace_frame, 202 &phys_address, sizeof(phys_address)); 203 if (rc != EOK) { 204 return (sysarg_t) rc; 205 } 206 207 return EOK; 208 } 209 175 210 /** @} 176 211 */ -
kernel/generic/src/syscall/syscall.c
r664af708 reb1a2f4 41 41 #include <proc/program.h> 42 42 #include <mm/as.h> 43 #include <mm/page.h> 43 44 #include <print.h> 44 45 #include <arch.h> … … 145 146 (syshandler_t) sys_as_get_unmapped_area, 146 147 148 /* Page mapping related syscalls. */ 149 (syshandler_t) sys_page_find_mapping, 150 147 151 /* IPC related syscalls. */ 148 152 (syshandler_t) sys_ipc_call_sync_fast, -
uspace/Makefile
r664af708 reb1a2f4 50 50 app/trace \ 51 51 app/top \ 52 app/usbinfo \ 53 app/virtusbkbd \ 54 app/virtusbhub \ 52 55 app/netecho \ 53 56 app/nettest1 \ … … 113 116 drv/ns8250 \ 114 117 srv/hw/irc/apic \ 115 srv/hw/irc/i8259 118 srv/hw/irc/i8259 \ 119 drv/uhci-hcd \ 120 drv/uhci-rhd \ 121 drv/usbhid \ 122 drv/usbhub \ 123 drv/usbmid \ 124 drv/vhc 116 125 endif 117 126 … … 123 132 drv/ns8250 \ 124 133 srv/hw/irc/apic \ 125 srv/hw/irc/i8259 134 srv/hw/irc/i8259 \ 135 drv/uhci-hcd \ 136 drv/uhci-rhd \ 137 drv/usbhid \ 138 drv/usbhub \ 139 drv/usbmid \ 140 drv/vhc 126 141 endif 127 142 … … 150 165 lib/net 151 166 167 ifeq ($(UARCH),amd64) 168 LIBS += lib/usb 169 LIBS += lib/usbvirt 170 endif 171 172 ifeq ($(UARCH),ia32) 173 LIBS += lib/usb 174 LIBS += lib/usbvirt 175 endif 176 152 177 LIBC_BUILD = $(addsuffix .build,$(LIBC)) 153 178 LIBS_BUILD = $(addsuffix .build,$(LIBS)) -
uspace/Makefile.common
r664af708 reb1a2f4 86 86 LIBCLUI_PREFIX = $(LIB_PREFIX)/clui 87 87 88 89 LIBUSB_PREFIX = $(LIB_PREFIX)/usb 90 LIBUSBVIRT_PREFIX = $(LIB_PREFIX)/usbvirt 88 91 LIBDRV_PREFIX = $(LIB_PREFIX)/drv 89 92 LIBPACKET_PREFIX = $(LIB_PREFIX)/packet -
uspace/app/bdsh/cmds/modules/cat/cat.c
r664af708 reb1a2f4 144 144 return CMD_SUCCESS; 145 145 case 'H': 146 printf( cat_oops);146 printf("%s", cat_oops); 147 147 return CMD_FAILURE; 148 148 case 't': 149 printf( cat_oops);149 printf("%s", cat_oops); 150 150 return CMD_FAILURE; 151 151 case 'b': 152 printf( cat_oops);152 printf("%s", cat_oops); 153 153 break; 154 154 case 'm': 155 printf( cat_oops);155 printf("%s", cat_oops); 156 156 return CMD_FAILURE; 157 157 } -
uspace/app/bdsh/cmds/modules/rm/rm.c
r664af708 reb1a2f4 227 227 } 228 228 memset(buff, 0, sizeof(buff)); 229 snprintf(buff, len, argv[i]);229 snprintf(buff, len, "%s", argv[i]); 230 230 231 231 scope = rm_scope(buff); -
uspace/app/init/init.c
r664af708 reb1a2f4 313 313 getterm("term/vc5", "/app/bdsh", false); 314 314 getterm("term/vc6", "/app/klog", false); 315 getterm("term/vc7", "/srv/devman", false); 315 316 316 317 return 0; -
uspace/app/tester/Makefile
r664af708 reb1a2f4 31 31 BINARY = tester 32 32 33 LIBS += $(LIBUSB_PREFIX)/libusb.a 34 EXTRA_CFLAGS += -I$(LIBUSB_PREFIX)/include 35 33 36 SOURCES = \ 34 37 tester.c \ 38 adt/usbaddrkeep.c \ 35 39 thread/thread1.c \ 36 40 print/print1.c \ … … 49 53 loop/loop1.c \ 50 54 mm/malloc1.c \ 55 mm/mapping1.c \ 51 56 hw/misc/virtchar1.c \ 52 57 hw/serial/serial1.c -
uspace/app/tester/tester.c
r664af708 reb1a2f4 62 62 #include "loop/loop1.def" 63 63 #include "mm/malloc1.def" 64 #include "mm/mapping1.def" 64 65 #include "hw/serial/serial1.def" 66 #include "adt/usbaddrkeep.def" 65 67 #include "hw/misc/virtchar1.def" 66 68 {NULL, NULL, NULL, false} -
uspace/app/tester/tester.h
r664af708 reb1a2f4 78 78 extern const char *test_loop1(void); 79 79 extern const char *test_malloc1(void); 80 extern const char *test_mapping1(void); 80 81 extern const char *test_serial1(void); 82 extern const char *test_usbaddrkeep(void); 81 83 extern const char *test_virtchar1(void); 82 84 -
uspace/doc/doxygroups.h
r664af708 reb1a2f4 150 150 * @endcond 151 151 */ 152 152 153 153 /** 154 154 * @defgroup emul Emulation Libraries … … 165 165 * @ingroup emul 166 166 */ 167 168 /** 169 * @defgroup usb USB 170 * @ingroup uspace 171 * @brief USB support for HelenOS. 172 */ 173 /** 174 * @defgroup libusb USB library 175 * @ingroup usb 176 * @brief Library for creating USB devices drivers. 177 */ 178 179 /** 180 * @defgroup usbvirt USB virtualization 181 * @ingroup usb 182 * @brief Support for virtual USB devices. 183 */ 184 185 /** 186 * @defgroup libusbvirt USB virtualization library 187 * @ingroup usbvirt 188 * @brief Library for creating virtual USB devices. 189 */ 190 191 /** 192 * @defgroup drvusbvhc Virtual USB host controller 193 * @ingroup usbvirt 194 * @brief Driver simulating work of USB host controller. 195 */ 196 197 /** 198 * @defgroup usbvirthub Virtual USB hub 199 * @ingroup usbvirt 200 * @brief Extra virtual USB hub for virtual host controller. 201 * @details 202 * Some of the sources are shared with virtual host controller, 203 * see @ref drvusbvhc for the rest of the files. 204 */ 205 206 /** 207 * @defgroup usbvirtkbd Virtual USB keybaord 208 * @ingroup usbvirt 209 * @brief Virtual USB keyboard for virtual host controller. 210 */ 211 212 /** 213 * @defgroup usbinfo USB info application 214 * @ingroup usb 215 * @brief Application for querying USB devices. 216 * @details 217 * The intended usage of this application is to query new USB devices 218 * for their descriptors etc. to simplify driver writing. 219 */ 220 221 /** 222 * @defgroup drvusbmid USB multi interface device driver 223 * @ingroup usb 224 * @brief USB multi interface device driver 225 * @details 226 * This driver serves as a mini hub (or bus) driver for devices 227 * that have the class defined at interface level (those devices 228 * usually have several interfaces). 229 * 230 * The term multi interface device driver (MID) was borrowed 231 * Solaris operating system. 232 */ 233 234 /** 235 * @defgroup drvusbhub USB hub driver 236 * @ingroup usb 237 * @brief USB hub driver. 238 */ 239 240 /** 241 * @defgroup drvusbhid USB HID driver 242 * @ingroup usb 243 * @brief USB driver for HID devices. 244 */ 245 246 /** 247 * @defgroup drvusbuhci UHCI driver 248 * @ingroup usb 249 * @brief Driver for USB host controller UHCI. 250 */ 251 -
uspace/drv/pciintel/pci.c
r664af708 reb1a2f4 51 51 #include <ipc/devman.h> 52 52 #include <ipc/dev_iface.h> 53 #include <ipc/irc.h> 54 #include <ipc/ns.h> 55 #include <ipc/services.h> 56 #include <sysinfo.h> 53 57 #include <ops/hw_res.h> 54 58 #include <device/hw_res.h> … … 83 87 static bool pciintel_enable_interrupt(ddf_fun_t *fnode) 84 88 { 85 /* TODO */ 86 87 return false; 89 /* This is an old ugly way, copied from ne2000 driver */ 90 assert(fnode); 91 pci_fun_t *dev_data = (pci_fun_t *) fnode->driver_data; 92 93 sysarg_t apic; 94 sysarg_t i8259; 95 int irc_phone = -1; 96 int irc_service = 0; 97 98 if ((sysinfo_get_value("apic", &apic) == EOK) && (apic)) { 99 irc_service = SERVICE_APIC; 100 } else if ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259)) { 101 irc_service = SERVICE_I8259; 102 } 103 104 if (irc_service) { 105 while (irc_phone < 0) 106 irc_phone = service_connect_blocking(irc_service, 0, 0); 107 } else { 108 return false; 109 } 110 111 size_t i; 112 for (i = 0; i < dev_data->hw_resources.count; i++) { 113 if (dev_data->hw_resources.resources[i].type == INTERRUPT) { 114 int irq = dev_data->hw_resources.resources[i].res.interrupt.irq; 115 async_msg_1(irc_phone, IRC_ENABLE_INTERRUPT, irq); 116 } 117 } 118 119 async_hangup(irc_phone); 120 return true; 88 121 } 89 122 -
uspace/drv/rootvirt/devices.def
r664af708 reb1a2f4 22 22 }, 23 23 #endif 24 #ifdef CONFIG_RUN_VIRTUAL_USB_HC 25 /* Virtual USB host controller. */ 26 { 27 .name = "usbhc", 28 .match_id = "usb&hc=vhc" 29 }, 30 #endif -
uspace/lib/c/generic/as.c
r664af708 reb1a2f4 35 35 #include <as.h> 36 36 #include <libc.h> 37 #include <errno.h> 37 38 #include <unistd.h> 38 39 #include <align.h> … … 114 115 } 115 116 117 /** Find mapping to physical address. 118 * 119 * @param address Virtual address in question (virtual). 120 * @param[out] frame Frame address (physical). 121 * @return Error code. 122 * @retval EOK No error, @p frame holds the translation. 123 * @retval ENOENT Mapping not found. 124 */ 125 int as_get_physical_mapping(void *address, uintptr_t *frame) 126 { 127 uintptr_t tmp_frame; 128 uintptr_t virt = (uintptr_t) address; 129 130 int rc = (int) __SYSCALL2(SYS_PAGE_FIND_MAPPING, 131 (sysarg_t) virt, (sysarg_t) &tmp_frame); 132 if (rc != EOK) { 133 return rc; 134 } 135 136 if (frame != NULL) { 137 *frame = tmp_frame; 138 } 139 140 return EOK; 141 } 142 116 143 /** @} 117 144 */ -
uspace/lib/c/generic/async.c
r664af708 reb1a2f4 1567 1567 } 1568 1568 1569 /** Start IPC_M_DATA_READ using the async framework. 1570 * 1571 * @param phoneid Phone that will be used to contact the receiving side. 1572 * @param dst Address of the beginning of the destination buffer. 1573 * @param size Size of the destination buffer (in bytes). 1574 * @param dataptr Storage of call data (arg 2 holds actual data size). 1575 * @return Hash of the sent message or 0 on error. 1576 */ 1577 aid_t async_data_read(int phoneid, void *dst, size_t size, ipc_call_t *dataptr) 1578 { 1579 return async_send_2(phoneid, IPC_M_DATA_READ, (sysarg_t) dst, 1580 (sysarg_t) size, dataptr); 1581 } 1582 1569 1583 /** Wrapper for IPC_M_DATA_READ calls using the async framework. 1570 1584 * -
uspace/lib/c/generic/str_error.c
r664af708 reb1a2f4 33 33 */ 34 34 35 #include <errno.h> 35 36 #include <str_error.h> 36 37 #include <stdio.h> … … 63 64 static fibril_local char noerr[NOERR_LEN]; 64 65 65 const char *str_error(const int e rrno)66 const char *str_error(const int e) 66 67 { 67 if ((e rrno <= 0) && (errno>= MIN_ERRNO))68 return err_desc[-e rrno];68 if ((e <= 0) && (e >= MIN_ERRNO)) 69 return err_desc[-e]; 69 70 70 snprintf(noerr, NOERR_LEN, "Unkown error code %d", errno); 71 /* Ad hoc descriptions of error codes interesting for USB. */ 72 switch (e) { 73 case EBADCHECKSUM: 74 return "Bad checksum"; 75 case ESTALL: 76 return "Operation stalled"; 77 case EAGAIN: 78 return "Resource temporarily unavailable"; 79 default: 80 break; 81 } 82 83 snprintf(noerr, NOERR_LEN, "Unkown error code %d", e); 71 84 return noerr; 72 85 } -
uspace/lib/c/include/as.h
r664af708 reb1a2f4 60 60 extern void *set_maxheapsize(size_t mhs); 61 61 extern void * as_get_mappable_page(size_t sz); 62 extern int as_get_physical_mapping(void *address, uintptr_t *frame); 62 63 63 64 #endif -
uspace/lib/c/include/async.h
r664af708 reb1a2f4 340 340 (arg4), (answer)) 341 341 342 extern aid_t async_data_read(int, void *, size_t, ipc_call_t *); 342 343 extern int async_data_read_start(int, void *, size_t); 343 344 extern bool async_data_read_receive(ipc_callid_t *, size_t *); -
uspace/lib/c/include/errno.h
r664af708 reb1a2f4 56 56 #define EMLINK (-266) 57 57 58 /** Bad checksum. */ 59 #define EBADCHECKSUM (-300) 60 61 /** USB: stalled operation. */ 62 #define ESTALL (-301) 63 58 64 /** An API function is called while another blocking function is in progress. */ 59 65 #define EINPROGRESS (-10036) -
uspace/lib/c/include/ipc/dev_iface.h
r664af708 reb1a2f4 37 37 HW_RES_DEV_IFACE = 0, 38 38 CHAR_DEV_IFACE, 39 40 /** Interface provided by any USB device. */ 41 USB_DEV_IFACE, 42 /** Interface provided by USB host controller. */ 43 USBHC_DEV_IFACE, 44 39 45 DEV_IFACE_MAX 40 46 } dev_inferface_idx_t; … … 48 54 DEV_IFACE_ID(DEV_FIRST_CUSTOM_METHOD_IDX) 49 55 56 /* 57 * The first argument is actually method (as the "real" method is used 58 * for indexing into interfaces. 59 */ 60 61 #define DEV_IPC_GET_ARG1(call) IPC_GET_ARG2((call)) 62 #define DEV_IPC_GET_ARG2(call) IPC_GET_ARG3((call)) 63 #define DEV_IPC_GET_ARG3(call) IPC_GET_ARG4((call)) 64 #define DEV_IPC_GET_ARG4(call) IPC_GET_ARG5((call)) 65 50 66 51 67 #endif -
uspace/lib/c/include/ipc/kbd.h
r664af708 reb1a2f4 39 39 40 40 #include <ipc/common.h> 41 #include <ipc/dev_iface.h> 41 42 42 43 typedef enum { 43 KBD_YIELD = IPC_FIRST_USER_METHOD,44 KBD_YIELD = DEV_FIRST_CUSTOM_METHOD, 44 45 KBD_RECLAIM 45 46 } kbd_request_t; -
uspace/lib/drv/Makefile
r664af708 reb1a2f4 29 29 30 30 USPACE_PREFIX = ../.. 31 EXTRA_CFLAGS = -Iinclude 31 EXTRA_CFLAGS = -Iinclude -I$(LIBUSB_PREFIX)/include 32 32 LIBRARY = libdrv 33 33 … … 35 35 generic/driver.c \ 36 36 generic/dev_iface.c \ 37 generic/remote_char_dev.c \ 37 38 generic/remote_hw_res.c \ 38 generic/remote_char_dev.c 39 generic/remote_usb.c \ 40 generic/remote_usbhc.c 39 41 40 42 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/drv/generic/dev_iface.c
r664af708 reb1a2f4 41 41 #include "remote_hw_res.h" 42 42 #include "remote_char_dev.h" 43 #include "remote_usb.h" 44 #include "remote_usbhc.h" 43 45 44 46 static iface_dipatch_table_t remote_ifaces = { 45 47 .ifaces = { 46 48 &remote_hw_res_iface, 47 &remote_char_dev_iface 49 &remote_char_dev_iface, 50 &remote_usb_iface, 51 &remote_usbhc_iface 48 52 } 49 53 }; -
uspace/srv/devman/devman.c
r664af708 reb1a2f4 148 148 printf(NAME": the '%s' driver was added to the list of available " 149 149 "drivers.\n", drv->name); 150 151 printf(NAME ": match ids:"); 152 link_t *cur; 153 for (cur = drv->match_ids.ids.next; cur != &drv->match_ids.ids; cur = cur->next) { 154 match_id_t *match_id = list_get_instance(cur, match_id_t, link); 155 printf(" %d:%s", match_id->score, match_id->id); 156 } 157 printf("\n"); 150 158 } 151 159 -
uspace/srv/devman/main.c
r664af708 reb1a2f4 507 507 508 508 if (driver == NULL) { 509 printf(NAME ": devman_forward error - the device is not in %" PRIun 510 " usable state.\n", handle); 509 printf(NAME ": devman_forward error - the device %" PRIun \ 510 " (%s) is not in usable state.\n", 511 handle, dev->pfun->pathname); 511 512 async_answer_0(iid, ENOENT); 512 513 return; -
uspace/srv/hid/console/console.c
r664af708 reb1a2f4 317 317 static void change_console(console_t *cons) 318 318 { 319 if (cons == active_console) 319 if (cons == active_console) { 320 320 return; 321 } 321 322 322 323 fb_pending_flush(); … … 458 459 if (IPC_GET_ARG1(call) == 1) { 459 460 int newcon = gcons_mouse_btn((bool) IPC_GET_ARG2(call)); 460 if (newcon != -1) 461 if (newcon != -1) { 461 462 change_console(&consoles[newcon]); 463 } 462 464 } 463 465 retval = 0; … … 710 712 } 711 713 714 static int connect_keyboard(char *path) 715 { 716 int fd = open(path, O_RDONLY); 717 if (fd < 0) { 718 return fd; 719 } 720 721 int phone = fd_phone(fd); 722 if (phone < 0) { 723 printf(NAME ": Failed to connect to input device\n"); 724 return phone; 725 } 726 727 /* NB: The callback connection is slotted for removal */ 728 sysarg_t phonehash; 729 sysarg_t taskhash; 730 int rc = async_req_3_5(phone, IPC_M_CONNECT_TO_ME, SERVICE_CONSOLE, 731 0, 0, NULL, NULL, NULL, &taskhash, &phonehash); 732 if (rc != EOK) { 733 printf(NAME ": Failed to create callback from input device\n"); 734 return rc; 735 } 736 737 async_new_connection(taskhash, phonehash, 0, NULL, keyboard_events); 738 739 printf(NAME ": we got a hit (new keyboard \"%s\").\n", path); 740 741 return phone; 742 } 743 744 /** Try to connect to given keyboard, bypassing provided libc routines. 745 * 746 * @param devmap_path Path to keyboard without /dev prefix. 747 * @return Phone or error code. 748 */ 749 static int connect_keyboard_bypass(char *devmap_path) 750 { 751 int devmap_phone = async_connect_me_to_blocking(PHONE_NS, 752 SERVICE_DEVMAP, DEVMAP_CLIENT, 0); 753 if (devmap_phone < 0) { 754 return devmap_phone; 755 } 756 ipc_call_t answer; 757 aid_t req = async_send_2(devmap_phone, DEVMAP_DEVICE_GET_HANDLE, 758 0, 0, &answer); 759 760 sysarg_t retval = async_data_write_start(devmap_phone, 761 devmap_path, str_size(devmap_path)); 762 if (retval != EOK) { 763 async_wait_for(req, NULL); 764 async_hangup(devmap_phone); 765 return retval; 766 } 767 768 async_wait_for(req, &retval); 769 770 if (retval != EOK) { 771 async_hangup(devmap_phone); 772 return retval; 773 } 774 775 devmap_handle_t handle = (devmap_handle_t) IPC_GET_ARG1(answer); 776 777 async_hangup(devmap_phone); 778 779 int phone = async_connect_me_to(PHONE_NS, 780 SERVICE_DEVMAP, DEVMAP_CONNECT_TO_DEVICE, handle); 781 if (phone < 0) { 782 return phone; 783 } 784 785 /* NB: The callback connection is slotted for removal */ 786 sysarg_t phonehash; 787 sysarg_t taskhash; 788 int rc = async_req_3_5(phone, IPC_M_CONNECT_TO_ME, SERVICE_CONSOLE, 789 0, 0, NULL, NULL, NULL, &taskhash, &phonehash); 790 if (rc != EOK) { 791 printf(NAME ": Failed to create callback from input device\n"); 792 return rc; 793 } 794 795 async_new_connection(taskhash, phonehash, 0, NULL, keyboard_events); 796 797 printf(NAME ": we got a hit (new keyboard \"/dev/%s\").\n", 798 devmap_path); 799 800 return phone; 801 } 802 803 804 static int check_new_keyboards(void *arg) 805 { 806 char *class_name = (char *) arg; 807 808 int index = 1; 809 810 while (true) { 811 async_usleep(1 * 500 * 1000); 812 char *path; 813 int rc = asprintf(&path, "class/%s\\%d", class_name, index); 814 if (rc < 0) { 815 continue; 816 } 817 rc = 0; 818 rc = connect_keyboard_bypass(path); 819 if (rc > 0) { 820 /* We do not allow unplug. */ 821 index++; 822 } 823 824 free(path); 825 } 826 827 return EOK; 828 } 829 830 831 /** Start a fibril monitoring hot-plugged keyboards. 832 */ 833 static void check_new_keyboards_in_background() 834 { 835 fid_t fid = fibril_create(check_new_keyboards, (void *)"keyboard"); 836 if (!fid) { 837 printf(NAME ": failed to create hot-plug-watch fibril.\n"); 838 return; 839 } 840 fibril_add_ready(fid); 841 } 842 712 843 static bool console_init(char *input) 713 844 { 714 845 /* Connect to input device */ 715 int input_fd = open(input, O_RDONLY); 716 if (input_fd < 0) { 717 printf(NAME ": Failed opening %s\n", input); 846 kbd_phone = connect_keyboard(input); 847 if (kbd_phone < 0) { 718 848 return false; 719 849 } 720 721 kbd_phone = fd_phone(input_fd); 722 if (kbd_phone < 0) { 723 printf(NAME ": Failed to connect to input device\n"); 724 return false; 725 } 726 727 /* NB: The callback connection is slotted for removal */ 728 if (async_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, keyboard_events) 729 != 0) { 730 printf(NAME ": Failed to create callback from input device\n"); 731 return false; 732 } 733 850 734 851 /* Connect to mouse device */ 735 852 mouse_phone = -1; … … 837 954 printf(NAME ": Error registering kconsole notifications\n"); 838 955 956 /* Start fibril for checking on hot-plugged keyboards. */ 957 check_new_keyboards_in_background(); 958 839 959 return true; 840 960 } … … 856 976 if (!console_init(argv[1])) 857 977 return -1; 858 978 859 979 printf(NAME ": Accepting connections\n"); 860 980 async_manager(); -
uspace/srv/net/tl/udp/udp.c
r664af708 reb1a2f4 740 740 int socket_id; 741 741 size_t addrlen; 742 size_t size ;742 size_t size = 0; 743 743 ipc_call_t answer; 744 744 size_t answer_count;
Note:
See TracChangeset
for help on using the changeset viewer.