Changes in / [0d8a304:3375bd4] in mainline
- Files:
-
- 269 added
- 46 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
r0d8a304 r3375bd4 541 541 542 542 % Run devman on startup 543 ! CONFIG_START_DEVMAN (y /n)543 ! CONFIG_START_DEVMAN (y) 544 544 545 545 % Launch (devman) test drivers … … 566 566 % Line debugging information 567 567 ! [CONFIG_STRIP_BINARIES!=y] CONFIG_LINE_DEBUG (n/y) 568 569 # USB settings 570 571 % USB release build (less logging) 572 ! CONFIG_USB_RELEASE_BUILD (n/y) 573 574 % Start virtual USB host controller 575 ! CONFIG_RUN_VIRTUAL_USB_HC (n/y) 576 577 % Polling UHCI & OHCI (no interrupts) 578 ! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_USBHC_NO_INTERRUPTS (y/n) 579 580 % Run devman in kconsole (not recommended) 581 ! CONFIG_DEVMAN_EARLY_LAUNCH (n/y) -
Makefile
r0d8a304 r3375bd4 106 106 $(MAKE) -C uspace clean 107 107 $(MAKE) -C boot clean 108 109 -include Makefile.local -
boot/Makefile.common
r0d8a304 r3375bd4 141 141 $(USPACE_PATH)/app/killall/killall \ 142 142 $(USPACE_PATH)/app/mkfat/mkfat \ 143 $(USPACE_PATH)/app/lsusb/lsusb \ 143 144 $(USPACE_PATH)/app/sbi/sbi \ 144 145 $(USPACE_PATH)/app/redir/redir \ … … 152 153 $(USPACE_PATH)/app/ping/ping \ 153 154 $(USPACE_PATH)/app/stats/stats \ 155 $(USPACE_PATH)/app/sysinfo/sysinfo \ 154 156 $(USPACE_PATH)/app/top/top \ 155 $(USPACE_PATH)/app/sysinfo/sysinfo \ 157 $(USPACE_PATH)/app/usbinfo/usbinfo \ 158 $(USPACE_PATH)/app/vuhid/vuh \ 156 159 $(USPACE_PATH)/app/websrv/websrv 157 160 -
boot/arch/amd64/Makefile.inc
r0d8a304 r3375bd4 42 42 pciintel \ 43 43 isa \ 44 ns8250 44 ns8250 \ 45 ehci-hcd \ 46 ohci \ 47 uhci-hcd \ 48 uhci-rhd \ 49 usbflbk \ 50 usbhub \ 51 usbkbd \ 52 usbhid \ 53 usbmast \ 54 usbmid \ 55 usbmouse \ 56 vhc 45 57 46 58 RD_DRV_CFG += \ -
kernel/generic/include/ddi/irq.h
r0d8a304 r3375bd4 77 77 */ 78 78 CMD_PIO_WRITE_A_32, 79 79 80 /** Read 1 byte from the memory space. */ 81 CMD_MEM_READ_8, 82 /** Read 2 bytes from the memory space. */ 83 CMD_MEM_READ_16, 84 /** Read 4 bytes from the memory space. */ 85 CMD_MEM_READ_32, 86 87 /** Write 1 byte to the memory space. */ 88 CMD_MEM_WRITE_8, 89 /** Write 2 bytes to the memory space. */ 90 CMD_MEM_WRITE_16, 91 /** Write 4 bytes to the memory space. */ 92 CMD_MEM_WRITE_32, 93 94 /** Write 1 byte from the source argument to the memory space. */ 95 CMD_MEM_WRITE_A_8, 96 /** Write 2 bytes from the source argument to the memory space. */ 97 CMD_MEM_WRITE_A_16, 98 /** Write 4 bytes from the source argument to the memory space. */ 99 CMD_MEM_WRITE_A_32, 100 80 101 /** 81 102 * Perform a bit masking on the source argument … … 203 224 /** Notification configuration structure. */ 204 225 ipc_notif_cfg_t notif_cfg; 226 227 as_t *driver_as; 205 228 } irq_t; 206 229 -
kernel/generic/include/mm/page.h
r0d8a304 r3375bd4 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/proc/thread.h
r0d8a304 r3375bd4 259 259 extern sysarg_t sys_thread_get_id(thread_id_t *); 260 260 extern sysarg_t sys_thread_usleep(uint32_t); 261 extern sysarg_t sys_thread_udelay(uint32_t); 261 262 262 263 #endif -
kernel/generic/include/syscall/syscall.h
r0d8a304 r3375bd4 44 44 SYS_THREAD_GET_ID, 45 45 SYS_THREAD_USLEEP, 46 SYS_THREAD_UDELAY, 46 47 47 48 SYS_TASK_GET_ID, … … 60 61 SYS_AS_AREA_DESTROY, 61 62 SYS_AS_GET_UNMAPPED_AREA, 63 64 SYS_PAGE_FIND_MAPPING, 62 65 63 66 SYS_IPC_CALL_SYNC_FAST, -
kernel/generic/src/ipc/irq.c
r0d8a304 r3375bd4 174 174 irq->notif_cfg.code = code; 175 175 irq->notif_cfg.counter = 0; 176 irq->driver_as = AS; 176 177 177 178 /* … … 364 365 return IRQ_DECLINE; 365 366 367 #define CMD_MEM_READ(target) \ 368 do { \ 369 void *va = code->cmds[i].addr; \ 370 if (AS != irq->driver_as) \ 371 as_switch(AS, irq->driver_as); \ 372 printf("Copying data from address: %p.\n", va); \ 373 memcpy_from_uspace(&target, va, (sizeof(target))); \ 374 if (dstarg) \ 375 scratch[dstarg] = target; \ 376 } while(0) 377 378 #define CMD_MEM_WRITE(val) \ 379 do { \ 380 void *va = code->cmds[i].addr; \ 381 if (AS != irq->driver_as) \ 382 as_switch(AS, irq->driver_as); \ 383 printf("Writing data to address: %p.\n", va); \ 384 memcpy_to_uspace(va, &val, sizeof(val)); \ 385 } while (0) 386 387 as_t *current_as = AS; 366 388 size_t i; 367 389 for (i = 0; i < code->cmdcount; i++) { … … 422 444 } 423 445 break; 446 case CMD_MEM_READ_8: { 447 uint8_t val; 448 CMD_MEM_READ(val); 449 break; 450 } 451 case CMD_MEM_READ_16: { 452 uint16_t val; 453 CMD_MEM_READ(val); 454 break; 455 } 456 case CMD_MEM_READ_32: { 457 uint32_t val; 458 CMD_MEM_READ(val); 459 printf("mem READ value: %x.\n", val); 460 break; 461 } 462 case CMD_MEM_WRITE_8: { 463 uint8_t val = code->cmds[i].value; 464 CMD_MEM_WRITE(val); 465 break; 466 } 467 case CMD_MEM_WRITE_16: { 468 uint16_t val = code->cmds[i].value; 469 CMD_MEM_WRITE(val); 470 break; 471 } 472 case CMD_MEM_WRITE_32: { 473 uint32_t val = code->cmds[i].value; 474 CMD_MEM_WRITE(val); 475 break; 476 } 477 case CMD_MEM_WRITE_A_8: 478 if (srcarg) { 479 uint8_t val = scratch[srcarg]; 480 CMD_MEM_WRITE(val); 481 } 482 break; 483 case CMD_MEM_WRITE_A_16: 484 if (srcarg) { 485 uint16_t val = scratch[srcarg]; 486 CMD_MEM_WRITE(val); 487 } 488 break; 489 case CMD_MEM_WRITE_A_32: 490 if (srcarg) { 491 uint32_t val = scratch[srcarg]; 492 CMD_MEM_WRITE(val); 493 } 494 break; 424 495 case CMD_BTEST: 425 496 if ((srcarg) && (dstarg)) { … … 435 506 break; 436 507 case CMD_ACCEPT: 508 if (AS != current_as) 509 as_switch(AS, current_as); 437 510 return IRQ_ACCEPT; 438 511 case CMD_DECLINE: 439 512 default: 513 if (AS != current_as) 514 as_switch(AS, current_as); 440 515 return IRQ_DECLINE; 441 516 } 442 517 } 518 if (AS != current_as) 519 as_switch(AS, current_as); 443 520 444 521 return IRQ_DECLINE; -
kernel/generic/src/mm/as.c
r0d8a304 r3375bd4 1964 1964 sysarg_t sys_as_area_create(uintptr_t address, size_t size, unsigned int flags) 1965 1965 { 1966 if (as_area_create(AS, flags | AS_AREA_CACHEABLE, size, address,1966 if (as_area_create(AS, flags, size, address, 1967 1967 AS_AREA_ATTR_NONE, &anon_backend, NULL)) 1968 1968 return (sysarg_t) address; -
kernel/generic/src/mm/page.c
r0d8a304 r3375bd4 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/proc/thread.c
r0d8a304 r3375bd4 918 918 } 919 919 920 sysarg_t sys_thread_udelay(uint32_t usec) 921 { 922 asm_delay_loop(usec * CPU->delay_loop_const); 923 return 0; 924 } 925 920 926 /** @} 921 927 */ -
kernel/generic/src/syscall/syscall.c
r0d8a304 r3375bd4 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> … … 126 127 (syshandler_t) sys_thread_get_id, 127 128 (syshandler_t) sys_thread_usleep, 129 (syshandler_t) sys_thread_udelay, 128 130 129 131 (syshandler_t) sys_task_get_id, … … 144 146 (syshandler_t) sys_as_area_destroy, 145 147 (syshandler_t) sys_as_get_unmapped_area, 148 149 /* Page mapping related syscalls. */ 150 (syshandler_t) sys_page_find_mapping, 146 151 147 152 /* IPC related syscalls. */ -
uspace/Makefile
r0d8a304 r3375bd4 41 41 app/killall \ 42 42 app/klog \ 43 app/lsusb \ 43 44 app/mkfat \ 44 45 app/redir \ … … 50 51 app/trace \ 51 52 app/top \ 53 app/usbinfo \ 54 app/vuhid \ 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/ehci-hcd \ 120 drv/ohci \ 121 drv/uhci-hcd \ 122 drv/uhci-rhd \ 123 drv/usbflbk \ 124 drv/usbkbd \ 125 drv/usbhid \ 126 drv/usbhub \ 127 drv/usbmast \ 128 drv/usbmid \ 129 drv/usbmouse \ 130 drv/vhc 116 131 endif 117 132 … … 123 138 drv/ns8250 \ 124 139 srv/hw/irc/apic \ 125 srv/hw/irc/i8259 140 srv/hw/irc/i8259 \ 141 drv/ehci-hcd \ 142 drv/ohci \ 143 drv/uhci-hcd \ 144 drv/uhci-rhd \ 145 drv/usbflbk \ 146 drv/usbkbd \ 147 drv/usbhid \ 148 drv/usbhub \ 149 drv/usbmast \ 150 drv/usbmid \ 151 drv/usbmouse \ 152 drv/vhc 126 153 endif 127 154 … … 150 177 lib/net 151 178 179 ifeq ($(UARCH),amd64) 180 LIBS += lib/usb 181 LIBS += lib/usbhost 182 LIBS += lib/usbdev 183 LIBS += lib/usbhid 184 LIBS += lib/usbvirt 185 endif 186 187 ifeq ($(UARCH),ia32) 188 LIBS += lib/usb 189 LIBS += lib/usbhost 190 LIBS += lib/usbdev 191 LIBS += lib/usbhid 192 LIBS += lib/usbvirt 193 endif 194 152 195 LIBC_BUILD = $(addsuffix .build,$(LIBC)) 153 196 LIBS_BUILD = $(addsuffix .build,$(LIBS)) -
uspace/Makefile.common
r0d8a304 r3375bd4 108 108 LIBCLUI_PREFIX = $(LIB_PREFIX)/clui 109 109 110 111 LIBUSB_PREFIX = $(LIB_PREFIX)/usb 112 LIBUSBHOST_PREFIX = $(LIB_PREFIX)/usbhost 113 LIBUSBDEV_PREFIX = $(LIB_PREFIX)/usbdev 114 LIBUSBHID_PREFIX = $(LIB_PREFIX)/usbhid 115 LIBUSBVIRT_PREFIX = $(LIB_PREFIX)/usbvirt 110 116 LIBDRV_PREFIX = $(LIB_PREFIX)/drv 111 117 LIBPACKET_PREFIX = $(LIB_PREFIX)/packet -
uspace/app/init/init.c
r0d8a304 r3375bd4 272 272 mount_tmpfs(); 273 273 274 #ifdef CONFIG_START_DEVMAN275 spawn("/srv/devman");276 #endif277 274 spawn("/srv/apic"); 278 275 spawn("/srv/i8259"); … … 316 313 getterm("term/vc5", "/app/bdsh", false); 317 314 getterm("term/vc6", "/app/klog", false); 318 315 316 #ifdef CONFIG_START_DEVMAN 317 318 #ifdef CONFIG_DEVMAN_EARLY_LAUNCH 319 spawn("/srv/devman"); 320 #else 321 getterm("term/vc7", "/srv/devman", false); 322 #endif 323 324 #endif 325 319 326 return 0; 320 327 } -
uspace/app/tester/Makefile
r0d8a304 r3375bd4 50 50 mm/malloc1.c \ 51 51 mm/malloc2.c \ 52 mm/mapping1.c \ 52 53 devs/devman1.c \ 53 54 hw/misc/virtchar1.c \ -
uspace/app/tester/tester.c
r0d8a304 r3375bd4 63 63 #include "mm/malloc1.def" 64 64 #include "mm/malloc2.def" 65 #include "mm/mapping1.def" 65 66 #include "hw/serial/serial1.def" 66 67 #include "hw/misc/virtchar1.def" -
uspace/app/tester/tester.h
r0d8a304 r3375bd4 79 79 extern const char *test_malloc1(void); 80 80 extern const char *test_malloc2(void); 81 extern const char *test_mapping1(void); 81 82 extern const char *test_serial1(void); 82 83 extern const char *test_virtchar1(void); -
uspace/doc/doxygroups.h
r0d8a304 r3375bd4 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 lsusb HelenOS version of lsusb command 223 * @ingroup usb 224 * @brief Application for listing USB host controllers. 225 * @details 226 * List all found host controllers. 227 */ 228 229 /** 230 * @defgroup drvusbmid USB multi interface device driver 231 * @ingroup usb 232 * @brief USB multi interface device driver 233 * @details 234 * This driver serves as a mini hub (or bus) driver for devices 235 * that have the class defined at interface level (those devices 236 * usually have several interfaces). 237 * 238 * The term multi interface device driver (MID) was borrowed 239 * Solaris operating system. 240 */ 241 242 /** 243 * @defgroup drvusbhub USB hub driver 244 * @ingroup usb 245 * @brief USB hub driver. 246 */ 247 248 /** 249 * @defgroup drvusbhid USB HID driver 250 * @ingroup usb 251 * @brief USB driver for HID devices. 252 */ 253 254 /** 255 * @defgroup drvusbmouse USB mouse driver 256 * @ingroup usb 257 * @brief USB driver for mouse with boot protocol. 258 */ 259 260 /** 261 * @defgroup drvusbmast USB mass storage driver 262 * @ingroup usb 263 * @brief USB driver for mass storage devices (bulk-only protocol). 264 * This driver is a only a stub and is currently used only for 265 * testing that bulk transfers work. 266 */ 267 268 /** 269 * @defgroup drvusbuhci UHCI driver 270 * @ingroup usb 271 * @brief Drivers for USB UHCI host controller and root hub. 272 */ 273 274 /** 275 * @defgroup drvusbuhcirh UHCI root hub driver 276 * @ingroup drvusbuhci 277 * @brief Driver for UHCI complaint root hub. 278 */ 279 280 /** 281 * @defgroup drvusbuhcihc UHCI host controller driver 282 * @ingroup drvusbuhci 283 * @brief Driver for UHCI complaint USB host controller. 284 */ 285 286 /** 287 * @defgroup drvusbohci OHCI driver 288 * @ingroup usb 289 * @brief Driver for OHCI host controller. 290 */ 291 292 /** 293 * @defgroup drvusbehci EHCI driver 294 * @ingroup usb 295 * @brief Driver for EHCI host controller. 296 */ 297 298 /** 299 * @defgroup drvusbfallback USB fallback driver 300 * @ingroup usb 301 * @brief Fallback driver for any USB device. 302 * @details 303 * The purpose of this driver is to simplify querying of unknown 304 * devices from within HelenOS (without a driver, no node at all 305 * may appear under /dev/devices). 306 */ 307 308 -
uspace/drv/pciintel/pci.c
r0d8a304 r3375bd4 52 52 #include <ipc/devman.h> 53 53 #include <ipc/dev_iface.h> 54 #include <ipc/irc.h> 55 #include <ipc/ns.h> 56 #include <ipc/services.h> 57 #include <sysinfo.h> 54 58 #include <ops/hw_res.h> 55 59 #include <device/hw_res.h> 56 60 #include <ddi.h> 57 61 #include <libarch/ddi.h> 62 #include <pci_dev_iface.h> 58 63 59 64 #include "pci.h" … … 84 89 static bool pciintel_enable_interrupt(ddf_fun_t *fnode) 85 90 { 86 /* TODO */ 87 88 return false; 91 /* This is an old ugly way, copied from ne2000 driver */ 92 assert(fnode); 93 pci_fun_t *dev_data = (pci_fun_t *) fnode->driver_data; 94 95 sysarg_t apic; 96 sysarg_t i8259; 97 98 int irc_phone = ENOTSUP; 99 100 if (((sysinfo_get_value("apic", &apic) == EOK) && (apic)) 101 || ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259))) { 102 irc_phone = service_connect_blocking(SERVICE_IRC, 0, 0); 103 } 104 105 if (irc_phone < 0) { 106 return false; 107 } 108 109 size_t i = 0; 110 hw_resource_list_t *res = &dev_data->hw_resources; 111 for (; i < res->count; i++) { 112 if (res->resources[i].type == INTERRUPT) { 113 const int irq = res->resources[i].res.interrupt.irq; 114 const int rc = 115 async_req_1_0(irc_phone, IRC_ENABLE_INTERRUPT, irq); 116 if (rc != EOK) { 117 async_hangup(irc_phone); 118 return false; 119 } 120 } 121 } 122 123 async_hangup(irc_phone); 124 return true; 125 } 126 127 static int pci_config_space_write_32( 128 ddf_fun_t *fun, uint32_t address, uint32_t data) 129 { 130 if (address > 252) 131 return EINVAL; 132 pci_conf_write_32(PCI_FUN(fun), address, data); 133 return EOK; 134 } 135 136 static int pci_config_space_write_16( 137 ddf_fun_t *fun, uint32_t address, uint16_t data) 138 { 139 if (address > 254) 140 return EINVAL; 141 pci_conf_write_16(PCI_FUN(fun), address, data); 142 return EOK; 143 } 144 145 static int pci_config_space_write_8( 146 ddf_fun_t *fun, uint32_t address, uint8_t data) 147 { 148 if (address > 255) 149 return EINVAL; 150 pci_conf_write_8(PCI_FUN(fun), address, data); 151 return EOK; 152 } 153 154 static int pci_config_space_read_32( 155 ddf_fun_t *fun, uint32_t address, uint32_t *data) 156 { 157 if (address > 252) 158 return EINVAL; 159 *data = pci_conf_read_32(PCI_FUN(fun), address); 160 return EOK; 161 } 162 163 static int pci_config_space_read_16( 164 ddf_fun_t *fun, uint32_t address, uint16_t *data) 165 { 166 if (address > 254) 167 return EINVAL; 168 *data = pci_conf_read_16(PCI_FUN(fun), address); 169 return EOK; 170 } 171 172 static int pci_config_space_read_8( 173 ddf_fun_t *fun, uint32_t address, uint8_t *data) 174 { 175 if (address > 255) 176 return EINVAL; 177 *data = pci_conf_read_8(PCI_FUN(fun), address); 178 return EOK; 89 179 } 90 180 … … 94 184 }; 95 185 96 static ddf_dev_ops_t pci_fun_ops; 186 static pci_dev_iface_t pci_dev_ops = { 187 .config_space_read_8 = &pci_config_space_read_8, 188 .config_space_read_16 = &pci_config_space_read_16, 189 .config_space_read_32 = &pci_config_space_read_32, 190 .config_space_write_8 = &pci_config_space_write_8, 191 .config_space_write_16 = &pci_config_space_write_16, 192 .config_space_write_32 = &pci_config_space_write_32 193 }; 194 195 static ddf_dev_ops_t pci_fun_ops = { 196 .interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops, 197 .interfaces[PCI_DEV_IFACE] = &pci_dev_ops 198 }; 97 199 98 200 static int pci_add_device(ddf_dev_t *); … … 288 390 /* Get the value of the BAR. */ 289 391 val = pci_conf_read_32(fun, addr); 392 393 #define IO_MASK (~0x3) 394 #define MEM_MASK (~0xf) 290 395 291 396 io = (bool) (val & 1); 292 397 if (io) { 293 398 addrw64 = false; 399 mask = IO_MASK; 294 400 } else { 401 mask = MEM_MASK; 295 402 switch ((val >> 1) & 3) { 296 403 case 0: … … 308 415 /* Get the address mask. */ 309 416 pci_conf_write_32(fun, addr, 0xffffffff); 310 mask = pci_conf_read_32(fun, addr);417 mask &= pci_conf_read_32(fun, addr); 311 418 312 419 /* Restore the original value. */ … … 558 665 ddf_log_init(NAME, LVL_ERROR); 559 666 pci_fun_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops; 667 pci_fun_ops.interfaces[PCI_DEV_IFACE] = &pci_dev_ops; 560 668 } 561 669 … … 629 737 size_t pci_bar_mask_to_size(uint32_t mask) 630 738 { 631 return ((mask & 0xfffffff0) ^ 0xffffffff) + 1; 739 size_t size = mask & ~(mask - 1); 740 return size; 632 741 } 633 742 -
uspace/drv/rootvirt/devices.def
r0d8a304 r3375bd4 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/Makefile
r0d8a304 r3375bd4 76 76 generic/str.c \ 77 77 generic/str_error.c \ 78 generic/l18n/langs.c \ 78 79 generic/fibril.c \ 79 80 generic/fibril_synch.c \ -
uspace/lib/c/generic/adt/hash_table.c
r0d8a304 r3375bd4 54 54 * 55 55 */ 56 inthash_table_create(hash_table_t *h, hash_count_t m, hash_count_t max_keys,56 bool hash_table_create(hash_table_t *h, hash_count_t m, hash_count_t max_keys, 57 57 hash_table_operations_t *op) 58 58 { -
uspace/lib/c/generic/as.c
r0d8a304 r3375bd4 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
r0d8a304 r3375bd4 1569 1569 } 1570 1570 1571 /** Start IPC_M_DATA_READ using the async framework. 1572 * 1573 * @param phoneid Phone that will be used to contact the receiving side. 1574 * @param dst Address of the beginning of the destination buffer. 1575 * @param size Size of the destination buffer (in bytes). 1576 * @param dataptr Storage of call data (arg 2 holds actual data size). 1577 * @return Hash of the sent message or 0 on error. 1578 */ 1579 aid_t async_data_read(int phoneid, void *dst, size_t size, ipc_call_t *dataptr) 1580 { 1581 return async_send_2(phoneid, IPC_M_DATA_READ, (sysarg_t) dst, 1582 (sysarg_t) size, dataptr); 1583 } 1584 1571 1585 /** Wrapper for IPC_M_DATA_READ calls using the async framework. 1572 1586 * -
uspace/lib/c/generic/devman.c
r0d8a304 r3375bd4 374 374 } 375 375 376 int devman_get_device_path(devman_handle_t handle, char *path, size_t path_size) 377 { 378 int phone = devman_get_phone(DEVMAN_CLIENT, 0); 379 380 if (phone < 0) 381 return phone; 382 383 async_serialize_start(); 384 385 ipc_call_t answer; 386 aid_t req = async_send_1(phone, DEVMAN_DEVICE_GET_DEVICE_PATH, 387 handle, &answer); 388 389 ipc_call_t data_request_call; 390 aid_t data_request = async_data_read(phone, path, path_size, 391 &data_request_call); 392 if (data_request == 0) { 393 async_wait_for(req, NULL); 394 async_serialize_end(); 395 return ENOMEM; 396 } 397 398 sysarg_t data_request_rc; 399 sysarg_t opening_request_rc; 400 async_wait_for(data_request, &data_request_rc); 401 async_wait_for(req, &opening_request_rc); 402 403 async_serialize_end(); 404 405 if (data_request_rc != EOK) { 406 /* Prefer the return code of the opening request. */ 407 if (opening_request_rc != EOK) { 408 return (int) opening_request_rc; 409 } else { 410 return (int) data_request_rc; 411 } 412 } 413 if (opening_request_rc != EOK) { 414 return (int) opening_request_rc; 415 } 416 417 /* To be on the safe-side. */ 418 path[path_size - 1] = 0; 419 420 size_t transferred_size = IPC_GET_ARG2(data_request_call); 421 422 if (transferred_size >= path_size) { 423 return ELIMIT; 424 } 425 426 /* Terminate the string (trailing 0 not send over IPC). */ 427 path[transferred_size] = 0; 428 429 return EOK; 430 } 431 376 432 377 433 /** @} -
uspace/lib/c/generic/malloc.c
r0d8a304 r3375bd4 241 241 size_t asize = ALIGN_UP(size, PAGE_SIZE); 242 242 243 astart = as_area_create(astart, asize, AS_AREA_WRITE | AS_AREA_READ );243 astart = as_area_create(astart, asize, AS_AREA_WRITE | AS_AREA_READ | AS_AREA_CACHEABLE); 244 244 if (astart == (void *) -1) 245 245 return false; -
uspace/lib/c/generic/str_error.c
r0d8a304 r3375bd4 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 case EEMPTY: 80 return "Resource is empty"; 81 default: 82 break; 83 } 84 85 snprintf(noerr, NOERR_LEN, "Unkown error code %d", e); 71 86 return noerr; 72 87 } -
uspace/lib/c/generic/time.c
r0d8a304 r3375bd4 207 207 } 208 208 209 void udelay(useconds_t time) 210 { 211 (void) __SYSCALL1(SYS_THREAD_UDELAY, (sysarg_t) time); 212 } 213 214 209 215 /** Wait unconditionally for specified number of seconds 210 216 * -
uspace/lib/c/include/adt/hash_table.h
r0d8a304 r3375bd4 38 38 #include <adt/list.h> 39 39 #include <unistd.h> 40 #include <bool.h> 40 41 41 42 typedef unsigned long hash_count_t; … … 83 84 list_get_instance((item), type, member) 84 85 85 extern inthash_table_create(hash_table_t *, hash_count_t, hash_count_t,86 extern bool hash_table_create(hash_table_t *, hash_count_t, hash_count_t, 86 87 hash_table_operations_t *); 87 88 extern void hash_table_insert(hash_table_t *, unsigned long [], link_t *); -
uspace/lib/c/include/as.h
r0d8a304 r3375bd4 60 60 extern void *set_maxheapsize(size_t); 61 61 extern void * as_get_mappable_page(size_t); 62 extern int as_get_physical_mapping(void *, uintptr_t *); 62 63 63 64 #endif -
uspace/lib/c/include/async.h
r0d8a304 r3375bd4 340 340 (arg4), (answer)) 341 341 342 extern aid_t async_data_read(int, void *, size_t, ipc_call_t *); 342 343 #define async_data_read_start(p, buf, len) \ 343 344 async_data_read_start_generic((p), (buf), (len), IPC_XF_NONE) -
uspace/lib/c/include/devman.h
r0d8a304 r3375bd4 55 55 extern int devman_device_get_handle_by_class(const char *, const char *, 56 56 devman_handle_t *, unsigned int); 57 extern int devman_get_device_path(devman_handle_t, char *, size_t); 57 58 58 59 extern int devman_add_device_to_class(devman_handle_t, const char *); -
uspace/lib/c/include/errno.h
r0d8a304 r3375bd4 56 56 #define EMLINK (-266) 57 57 58 /** Bad checksum. */ 59 #define EBADCHECKSUM (-300) 60 61 /** USB: stalled operation. */ 62 #define ESTALL (-301) 63 64 /** Empty resource (no data). */ 65 #define EEMPTY (-302) 66 67 /** Negative acknowledgment. */ 68 #define ENAK (-303) 69 58 70 /** An API function is called while another blocking function is in progress. */ 59 71 #define EINPROGRESS (-10036) -
uspace/lib/c/include/ipc/dev_iface.h
r0d8a304 r3375bd4 37 37 HW_RES_DEV_IFACE = 0, 38 38 CHAR_DEV_IFACE, 39 40 /** Interface provided by any PCI device. */ 41 PCI_DEV_IFACE, 42 43 /** Interface provided by any USB device. */ 44 USB_DEV_IFACE, 45 /** Interface provided by USB host controller. */ 46 USBHC_DEV_IFACE, 47 /** Interface provided by USB HID devices. */ 48 USBHID_DEV_IFACE, 49 39 50 DEV_IFACE_MAX 40 51 } dev_inferface_idx_t; … … 48 59 DEV_IFACE_ID(DEV_FIRST_CUSTOM_METHOD_IDX) 49 60 61 /* 62 * The first argument is actually method (as the "real" method is used 63 * for indexing into interfaces. 64 */ 65 66 #define DEV_IPC_GET_ARG1(call) IPC_GET_ARG2((call)) 67 #define DEV_IPC_GET_ARG2(call) IPC_GET_ARG3((call)) 68 #define DEV_IPC_GET_ARG3(call) IPC_GET_ARG4((call)) 69 #define DEV_IPC_GET_ARG4(call) IPC_GET_ARG5((call)) 70 50 71 51 72 #endif -
uspace/lib/c/include/ipc/devman.h
r0d8a304 r3375bd4 149 149 typedef enum { 150 150 DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD, 151 DEVMAN_DEVICE_GET_HANDLE_BY_CLASS 151 DEVMAN_DEVICE_GET_HANDLE_BY_CLASS, 152 DEVMAN_DEVICE_GET_DEVICE_PATH 152 153 } client_to_devman_t; 153 154 -
uspace/lib/c/include/ipc/kbd.h
r0d8a304 r3375bd4 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/c/include/sys/time.h
r0d8a304 r3375bd4 62 62 extern int gettimeofday(struct timeval *tv, struct timezone *tz); 63 63 64 extern void udelay(useconds_t); 65 64 66 #endif 65 67 -
uspace/lib/drv/Makefile
r0d8a304 r3375bd4 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/log.c \ 38 39 generic/remote_hw_res.c \ 39 generic/remote_char_dev.c 40 generic/remote_usb.c \ 41 generic/remote_pci.c \ 42 generic/remote_usbhc.c 40 43 41 44 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/drv/generic/dev_iface.c
r0d8a304 r3375bd4 41 41 #include "remote_hw_res.h" 42 42 #include "remote_char_dev.h" 43 #include "remote_usb.h" 44 #include "remote_usbhc.h" 45 #include "remote_usbhid.h" 46 #include "remote_pci.h" 43 47 44 48 static iface_dipatch_table_t remote_ifaces = { 45 49 .ifaces = { 46 50 &remote_hw_res_iface, 47 &remote_char_dev_iface 51 &remote_char_dev_iface, 52 &remote_pci_iface, 53 &remote_usb_iface, 54 &remote_usbhc_iface, 55 &remote_usbhid_iface 48 56 } 49 57 }; -
uspace/srv/devman/main.c
r0d8a304 r3375bd4 515 515 } 516 516 517 /** Find device path by its handle. */ 518 static void devman_get_device_path_by_handle(ipc_callid_t iid, 519 ipc_call_t *icall) 520 { 521 devman_handle_t handle = IPC_GET_ARG1(*icall); 522 523 fun_node_t *fun = find_fun_node(&device_tree, handle); 524 if (fun == NULL) { 525 async_answer_0(iid, ENOMEM); 526 return; 527 } 528 529 ipc_callid_t data_callid; 530 size_t data_len; 531 if (!async_data_read_receive(&data_callid, &data_len)) { 532 async_answer_0(iid, EINVAL); 533 return; 534 } 535 536 void *buffer = malloc(data_len); 537 if (buffer == NULL) { 538 async_answer_0(data_callid, ENOMEM); 539 async_answer_0(iid, ENOMEM); 540 return; 541 } 542 543 size_t sent_length = str_size(fun->pathname); 544 if (sent_length > data_len) { 545 sent_length = data_len; 546 } 547 548 async_data_read_finalize(data_callid, fun->pathname, sent_length); 549 async_answer_0(iid, EOK); 550 551 free(buffer); 552 } 553 517 554 518 555 /** Function for handling connections from a client to the device manager. */ … … 537 574 devman_function_get_handle_by_class(callid, &call); 538 575 break; 576 case DEVMAN_DEVICE_GET_DEVICE_PATH: 577 devman_get_device_path_by_handle(callid, &call); 578 break; 539 579 default: 540 580 async_answer_0(callid, ENOENT); … … 595 635 if (driver == NULL) { 596 636 log_msg(LVL_ERROR, "IPC forwarding refused - " \ 597 "the device %" PRIun " is not in usable state.", handle); 637 "the device %" PRIun "(%s) is not in usable state.", 638 handle, dev->pfun->pathname); 598 639 async_answer_0(iid, ENOENT); 599 640 return; -
uspace/srv/fs/fat/fat_dentry.c
r0d8a304 r3375bd4 42 42 static bool is_d_char(const char ch) 43 43 { 44 if (isalnum(ch) || ch == '_' )44 if (isalnum(ch) || ch == '_' || ch == '-') 45 45 return true; 46 46 else -
uspace/srv/hid/console/console.c
r0d8a304 r3375bd4 41 41 #include <ipc/ns.h> 42 42 #include <errno.h> 43 #include <str_error.h> 43 44 #include <ipc/console.h> 44 45 #include <unistd.h> … … 64 65 #define NAME "console" 65 66 #define NAMESPACE "term" 67 /** Interval for checking for new keyboard (1/4s). */ 68 #define HOTPLUG_WATCH_INTERVAL (1000 * 250) 66 69 67 70 /** Phone to the keyboard driver. */ … … 317 320 static void change_console(console_t *cons) 318 321 { 319 if (cons == active_console) 322 if (cons == active_console) { 320 323 return; 324 } 321 325 322 326 fb_pending_flush(); … … 458 462 if (IPC_GET_ARG1(call) == 1) { 459 463 int newcon = gcons_mouse_btn((bool) IPC_GET_ARG2(call)); 460 if (newcon != -1) 464 if (newcon != -1) { 461 465 change_console(&consoles[newcon]); 466 } 462 467 } 463 468 retval = 0; … … 710 715 } 711 716 717 static int connect_keyboard_or_mouse(const char *devname, 718 async_client_conn_t handler, const char *path) 719 { 720 int fd = open(path, O_RDONLY); 721 if (fd < 0) { 722 return fd; 723 } 724 725 int phone = fd_phone(fd); 726 if (phone < 0) { 727 printf(NAME ": Failed to connect to input device\n"); 728 return phone; 729 } 730 731 int rc = async_connect_to_me(phone, SERVICE_CONSOLE, 0, 0, handler); 732 if (rc != EOK) { 733 printf(NAME ": " \ 734 "Failed to create callback from input device: %s.\n", 735 str_error(rc)); 736 return rc; 737 } 738 739 printf(NAME ": found %s \"%s\".\n", devname, path); 740 741 return phone; 742 } 743 744 static int connect_keyboard(const char *path) 745 { 746 return connect_keyboard_or_mouse("keyboard", keyboard_events, path); 747 } 748 749 static int connect_mouse(const char *path) 750 { 751 return connect_keyboard_or_mouse("mouse", mouse_events, path); 752 } 753 754 struct hid_class_info { 755 char *classname; 756 int (*connection_func)(const char *); 757 }; 758 759 /** Periodically check for new keyboards in /dev/class/. 760 * 761 * @param arg Class name. 762 * @return This function should never exit. 763 */ 764 static int check_new_device_fibril(void *arg) 765 { 766 struct hid_class_info *dev_info = arg; 767 768 size_t index = 1; 769 770 while (true) { 771 async_usleep(HOTPLUG_WATCH_INTERVAL); 772 char *path; 773 int rc = asprintf(&path, "/dev/class/%s\\%zu", 774 dev_info->classname, index); 775 if (rc < 0) { 776 continue; 777 } 778 rc = 0; 779 rc = dev_info->connection_func(path); 780 if (rc > 0) { 781 /* We do not allow unplug. */ 782 index++; 783 } 784 785 free(path); 786 } 787 788 return EOK; 789 } 790 791 792 /** Start a fibril monitoring hot-plugged keyboards. 793 */ 794 static void check_new_devices_in_background(int (*connection_func)(const char *), 795 const char *classname) 796 { 797 struct hid_class_info *dev_info = malloc(sizeof(struct hid_class_info)); 798 if (dev_info == NULL) { 799 printf(NAME ": " \ 800 "out of memory, will not start hot-plug-watch fibril.\n"); 801 return; 802 } 803 int rc; 804 805 rc = asprintf(&dev_info->classname, "%s", classname); 806 if (rc < 0) { 807 printf(NAME ": failed to format classname: %s.\n", 808 str_error(rc)); 809 return; 810 } 811 dev_info->connection_func = connection_func; 812 813 fid_t fid = fibril_create(check_new_device_fibril, (void *)dev_info); 814 if (!fid) { 815 printf(NAME 816 ": failed to create hot-plug-watch fibril for %s.\n", 817 classname); 818 return; 819 } 820 fibril_add_ready(fid); 821 } 822 712 823 static bool console_init(char *input) 713 824 { 714 825 /* 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); 826 kbd_phone = connect_keyboard(input); 827 if (kbd_phone < 0) { 718 828 return false; 719 829 } 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 734 /* Connect to mouse device */ 735 mouse_phone = -1; 736 int mouse_fd = open("/dev/hid_in/mouse", O_RDONLY); 737 738 if (mouse_fd < 0) { 739 printf(NAME ": Notice - failed opening %s\n", "/dev/hid_in/mouse"); 740 goto skip_mouse; 741 } 742 743 mouse_phone = fd_phone(mouse_fd); 830 831 mouse_phone = connect_mouse("/dev/hid_in/mouse"); 744 832 if (mouse_phone < 0) { 745 printf(NAME ": Failed to connect to mouse device\n"); 746 goto skip_mouse; 747 } 748 749 if (async_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, mouse_events) 750 != 0) { 751 printf(NAME ": Failed to create callback from mouse device\n"); 752 mouse_phone = -1; 753 goto skip_mouse; 754 } 755 756 skip_mouse: 833 printf(NAME ": Failed to connect to mouse device: %s.\n", 834 str_error(mouse_phone)); 835 } 757 836 758 837 /* Connect to framebuffer driver */ … … 837 916 printf(NAME ": Error registering kconsole notifications\n"); 838 917 918 /* Start fibril for checking on hot-plugged keyboards. */ 919 check_new_devices_in_background(connect_keyboard, "keyboard"); 920 check_new_devices_in_background(connect_mouse, "mouse"); 921 839 922 return true; 840 923 } … … 856 939 if (!console_init(argv[1])) 857 940 return -1; 858 941 859 942 printf(NAME ": Accepting connections\n"); 860 943 async_manager(); -
uspace/srv/hw/irc/apic/apic.c
r0d8a304 r3375bd4 87 87 async_answer_0(callid, EOK); 88 88 break; 89 case IPC_M_PHONE_HUNGUP: 90 /* The other side has hung up. */ 91 async_answer_0(callid, EOK); 92 return; 89 93 default: 90 94 async_answer_0(callid, EINVAL); -
uspace/srv/hw/irc/i8259/i8259.c
r0d8a304 r3375bd4 121 121 async_answer_0(callid, EOK); 122 122 break; 123 case IPC_M_PHONE_HUNGUP: 124 /* The other side has hung up. */ 125 async_answer_0(callid, EOK); 126 return; 123 127 default: 124 128 async_answer_0(callid, EINVAL);
Note:
See TracChangeset
for help on using the changeset viewer.