Changeset c028b22 in mainline for uspace/drv/bus
- Timestamp:
- 2011-07-08T17:01:01Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cc1a727
- Parents:
- 4e36219 (diff), 026793d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/drv/bus
- Files:
-
- 133 added
- 12 moved
-
isa/Makefile (moved) (moved from uspace/drv/isa/Makefile ) (1 diff)
-
isa/isa.c (moved) (moved from uspace/drv/isa/isa.c )
-
isa/isa.dev (moved) (moved from uspace/drv/isa/isa.dev )
-
isa/isa.ma (moved) (moved from uspace/drv/isa/isa.ma )
-
pci/pciintel/Makefile (moved) (moved from uspace/drv/pciintel/Makefile ) (1 diff)
-
pci/pciintel/pci.c (moved) (moved from uspace/drv/pciintel/pci.c ) (11 diffs)
-
pci/pciintel/pci.h (moved) (moved from uspace/drv/pciintel/pci.h )
-
pci/pciintel/pci_regs.h (moved) (moved from uspace/drv/pciintel/pci_regs.h )
-
pci/pciintel/pciintel.ma (moved) (moved from uspace/drv/pciintel/pciintel.ma )
-
usb/ehci/Makefile (added)
-
usb/ehci/ehci.h (moved) (moved from uspace/lib/c/include/ipc/mouse.h ) (2 diffs)
-
usb/ehci/ehci.ma (added)
-
usb/ehci/hc_iface.c (added)
-
usb/ehci/main.c (added)
-
usb/ehci/pci.c (added)
-
usb/ehci/pci.h (added)
-
usb/ohci/Makefile (added)
-
usb/ohci/batch.c (added)
-
usb/ohci/batch.h (added)
-
usb/ohci/endpoint_list.c (added)
-
usb/ohci/endpoint_list.h (added)
-
usb/ohci/hc.c (added)
-
usb/ohci/hc.h (added)
-
usb/ohci/hcd_endpoint.c (added)
-
usb/ohci/hcd_endpoint.h (added)
-
usb/ohci/hw_struct/completion_codes.h (added)
-
usb/ohci/hw_struct/endpoint_descriptor.c (added)
-
usb/ohci/hw_struct/endpoint_descriptor.h (added)
-
usb/ohci/hw_struct/hcca.h (added)
-
usb/ohci/hw_struct/iso_transfer_descriptor.h (added)
-
usb/ohci/hw_struct/transfer_descriptor.c (added)
-
usb/ohci/hw_struct/transfer_descriptor.h (added)
-
usb/ohci/iface.c (added)
-
usb/ohci/iface.h (added)
-
usb/ohci/main.c (added)
-
usb/ohci/ohci.c (added)
-
usb/ohci/ohci.h (added)
-
usb/ohci/ohci.ma (added)
-
usb/ohci/ohci_regs.h (added)
-
usb/ohci/pci.c (added)
-
usb/ohci/pci.h (added)
-
usb/ohci/root_hub.c (added)
-
usb/ohci/root_hub.h (added)
-
usb/ohci/utils/malloc32.h (added)
-
usb/uhci/Makefile (added)
-
usb/uhci/batch.c (added)
-
usb/uhci/batch.h (added)
-
usb/uhci/hc.c (added)
-
usb/uhci/hc.h (added)
-
usb/uhci/hw_struct/link_pointer.h (added)
-
usb/uhci/hw_struct/queue_head.h (added)
-
usb/uhci/hw_struct/transfer_descriptor.c (added)
-
usb/uhci/hw_struct/transfer_descriptor.h (added)
-
usb/uhci/iface.c (added)
-
usb/uhci/iface.h (added)
-
usb/uhci/main.c (added)
-
usb/uhci/pci.c (added)
-
usb/uhci/pci.h (added)
-
usb/uhci/root_hub.c (added)
-
usb/uhci/root_hub.h (added)
-
usb/uhci/transfer_list.c (added)
-
usb/uhci/transfer_list.h (added)
-
usb/uhci/uhci.c (added)
-
usb/uhci/uhci.h (moved) (moved from uspace/srv/hid/char_mouse/include/char_mouse.h ) (2 diffs)
-
usb/uhci/uhci.ma (added)
-
usb/uhci/utils/malloc32.h (added)
-
usb/uhcirh/Makefile (added)
-
usb/uhcirh/main.c (added)
-
usb/uhcirh/port.c (added)
-
usb/uhcirh/port.h (added)
-
usb/uhcirh/root_hub.c (added)
-
usb/uhcirh/root_hub.h (added)
-
usb/uhcirh/uhcirh.ma (added)
-
usb/usbflbk/Makefile (added)
-
usb/usbflbk/main.c (added)
-
usb/usbflbk/usbflbk.ma (added)
-
usb/usbhid/Makefile (added)
-
usb/usbhid/generic/hiddev.c (added)
-
usb/usbhid/generic/hiddev.h (added)
-
usb/usbhid/kbd/conv.c (added)
-
usb/usbhid/kbd/conv.h (added)
-
usb/usbhid/kbd/kbddev.c (added)
-
usb/usbhid/kbd/kbddev.h (added)
-
usb/usbhid/kbd/kbdrepeat.c (added)
-
usb/usbhid/kbd/kbdrepeat.h (added)
-
usb/usbhid/main.c (added)
-
usb/usbhid/mouse/mousedev.c (added)
-
usb/usbhid/mouse/mousedev.h (added)
-
usb/usbhid/multimedia/keymap.c (added)
-
usb/usbhid/multimedia/keymap.h (added)
-
usb/usbhid/multimedia/multimedia.c (added)
-
usb/usbhid/multimedia/multimedia.h (added)
-
usb/usbhid/subdrivers.c (added)
-
usb/usbhid/subdrivers.h (added)
-
usb/usbhid/usbhid.c (added)
-
usb/usbhid/usbhid.h (added)
-
usb/usbhid/usbhid.ma (added)
-
usb/usbhub/Makefile (added)
-
usb/usbhub/main.c (moved) (moved from uspace/srv/hid/adb_mouse/adb_dev.c ) (3 diffs)
-
usb/usbhub/port_status.h (added)
-
usb/usbhub/ports.c (added)
-
usb/usbhub/ports.h (added)
-
usb/usbhub/usbhub.c (added)
-
usb/usbhub/usbhub.h (added)
-
usb/usbhub/usbhub.ma (added)
-
usb/usbhub/usbhub_private.h (added)
-
usb/usbhub/utils.c (added)
-
usb/usbmast/Makefile (added)
-
usb/usbmast/cmds.c (added)
-
usb/usbmast/cmds.h (added)
-
usb/usbmast/main.c (added)
-
usb/usbmast/mast.c (added)
-
usb/usbmast/mast.h (added)
-
usb/usbmast/scsi_ms.c (added)
-
usb/usbmast/scsi_ms.h (added)
-
usb/usbmast/usbmast.ma (added)
-
usb/usbmid/Makefile (added)
-
usb/usbmid/dump.c (added)
-
usb/usbmid/explore.c (added)
-
usb/usbmid/main.c (added)
-
usb/usbmid/usbmid.c (added)
-
usb/usbmid/usbmid.h (added)
-
usb/usbmid/usbmid.ma (added)
-
usb/usbmouse/Makefile (added)
-
usb/usbmouse/init.c (added)
-
usb/usbmouse/main.c (added)
-
usb/usbmouse/mouse.c (added)
-
usb/usbmouse/mouse.h (added)
-
usb/usbmouse/usbmouse.ma (added)
-
usb/vhc/Makefile (added)
-
usb/vhc/conn.h (added)
-
usb/vhc/conndev.c (added)
-
usb/vhc/connhost.c (added)
-
usb/vhc/devconn.c (added)
-
usb/vhc/hub.c (added)
-
usb/vhc/hub.h (added)
-
usb/vhc/hub/hub.c (added)
-
usb/vhc/hub/hub.h (added)
-
usb/vhc/hub/virthub.c (added)
-
usb/vhc/hub/virthub.h (added)
-
usb/vhc/hub/virthubops.c (added)
-
usb/vhc/main.c (added)
-
usb/vhc/transfer.c (added)
-
usb/vhc/vhc.ma (added)
-
usb/vhc/vhcd.h (added)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/isa/Makefile
r4e36219 rc028b22 27 27 # 28 28 29 USPACE_PREFIX = ../.. 29 USPACE_PREFIX = ../../.. 30 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a 31 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -
uspace/drv/bus/pci/pciintel/Makefile
r4e36219 rc028b22 27 27 # 28 28 29 USPACE_PREFIX = ../.. 29 USPACE_PREFIX = ../../../.. 30 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a 31 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -
uspace/drv/bus/pci/pciintel/pci.c
r4e36219 rc028b22 52 52 #include <ipc/devman.h> 53 53 #include <ipc/dev_iface.h> 54 #include <ipc/irc.h> 55 #include <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 async_sess_t *irc_sess = NULL; 99 100 if (((sysinfo_get_value("apic", &apic) == EOK) && (apic)) 101 || ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259))) { 102 irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE, 103 SERVICE_IRC, 0, 0); 104 } 105 106 if (!irc_sess) 107 return false; 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 115 async_exch_t *exch = async_exchange_begin(irc_sess); 116 const int rc = 117 async_req_1_0(exch, IRC_ENABLE_INTERRUPT, irq); 118 async_exchange_end(exch); 119 120 if (rc != EOK) { 121 async_hangup(irc_sess); 122 return false; 123 } 124 } 125 } 126 127 async_hangup(irc_sess); 128 return true; 129 } 130 131 static int pci_config_space_write_32(ddf_fun_t *fun, uint32_t address, 132 uint32_t data) 133 { 134 if (address > 252) 135 return EINVAL; 136 pci_conf_write_32(PCI_FUN(fun), address, data); 137 return EOK; 138 } 139 140 static int pci_config_space_write_16( 141 ddf_fun_t *fun, uint32_t address, uint16_t data) 142 { 143 if (address > 254) 144 return EINVAL; 145 pci_conf_write_16(PCI_FUN(fun), address, data); 146 return EOK; 147 } 148 149 static int pci_config_space_write_8( 150 ddf_fun_t *fun, uint32_t address, uint8_t data) 151 { 152 if (address > 255) 153 return EINVAL; 154 pci_conf_write_8(PCI_FUN(fun), address, data); 155 return EOK; 156 } 157 158 static int pci_config_space_read_32( 159 ddf_fun_t *fun, uint32_t address, uint32_t *data) 160 { 161 if (address > 252) 162 return EINVAL; 163 *data = pci_conf_read_32(PCI_FUN(fun), address); 164 return EOK; 165 } 166 167 static int pci_config_space_read_16( 168 ddf_fun_t *fun, uint32_t address, uint16_t *data) 169 { 170 if (address > 254) 171 return EINVAL; 172 *data = pci_conf_read_16(PCI_FUN(fun), address); 173 return EOK; 174 } 175 176 static int pci_config_space_read_8( 177 ddf_fun_t *fun, uint32_t address, uint8_t *data) 178 { 179 if (address > 255) 180 return EINVAL; 181 *data = pci_conf_read_8(PCI_FUN(fun), address); 182 return EOK; 89 183 } 90 184 … … 94 188 }; 95 189 96 static ddf_dev_ops_t pci_fun_ops; 190 static pci_dev_iface_t pci_dev_ops = { 191 .config_space_read_8 = &pci_config_space_read_8, 192 .config_space_read_16 = &pci_config_space_read_16, 193 .config_space_read_32 = &pci_config_space_read_32, 194 .config_space_write_8 = &pci_config_space_write_8, 195 .config_space_write_16 = &pci_config_space_write_16, 196 .config_space_write_32 = &pci_config_space_write_32 197 }; 198 199 static ddf_dev_ops_t pci_fun_ops = { 200 .interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops, 201 .interfaces[PCI_DEV_IFACE] = &pci_dev_ops 202 }; 97 203 98 204 static int pci_add_device(ddf_dev_t *); … … 288 394 /* Get the value of the BAR. */ 289 395 val = pci_conf_read_32(fun, addr); 396 397 #define IO_MASK (~0x3) 398 #define MEM_MASK (~0xf) 290 399 291 400 io = (bool) (val & 1); 292 401 if (io) { 293 402 addrw64 = false; 403 mask = IO_MASK; 294 404 } else { 405 mask = MEM_MASK; 295 406 switch ((val >> 1) & 3) { 296 407 case 0: … … 308 419 /* Get the address mask. */ 309 420 pci_conf_write_32(fun, addr, 0xffffffff); 310 mask = pci_conf_read_32(fun, addr);421 mask &= pci_conf_read_32(fun, addr); 311 422 312 423 /* Restore the original value. */ … … 469 580 470 581 ddf_msg(LVL_DEBUG, "pci_add_device"); 471 dnode->parent_ phone = -1;582 dnode->parent_sess = NULL; 472 583 473 584 bus = pci_bus_new(); … … 480 591 dnode->driver_data = bus; 481 592 482 dnode->parent_ phone = devman_parent_device_connect(dnode->handle,483 IPC_FLAG_BLOCKING);484 if ( dnode->parent_phone < 0) {593 dnode->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE, 594 dnode->handle, IPC_FLAG_BLOCKING); 595 if (!dnode->parent_sess) { 485 596 ddf_msg(LVL_ERROR, "pci_add_device failed to connect to the " 486 "parent 'sdriver.");487 rc = dnode->parent_phone;597 "parent driver."); 598 rc = ENOENT; 488 599 goto fail; 489 600 } … … 491 602 hw_resource_list_t hw_resources; 492 603 493 rc = hw_res_get_resource_list(dnode->parent_ phone, &hw_resources);604 rc = hw_res_get_resource_list(dnode->parent_sess, &hw_resources); 494 605 if (rc != EOK) { 495 606 ddf_msg(LVL_ERROR, "pci_add_device failed to get hw resources " … … 544 655 if (bus != NULL) 545 656 pci_bus_delete(bus); 546 if (dnode->parent_phone >= 0) 547 async_hangup(dnode->parent_phone); 657 658 if (dnode->parent_sess) 659 async_hangup(dnode->parent_sess); 660 548 661 if (got_res) 549 662 hw_res_clean_resource_list(&hw_resources); 663 550 664 if (ctl != NULL) 551 665 ddf_fun_destroy(ctl); 552 666 553 667 return rc; 554 668 } … … 558 672 ddf_log_init(NAME, LVL_ERROR); 559 673 pci_fun_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops; 674 pci_fun_ops.interfaces[PCI_DEV_IFACE] = &pci_dev_ops; 560 675 } 561 676 … … 629 744 size_t pci_bar_mask_to_size(uint32_t mask) 630 745 { 631 return ((mask & 0xfffffff0) ^ 0xffffffff) + 1; 746 size_t size = mask & ~(mask - 1); 747 return size; 632 748 } 633 749 -
uspace/drv/bus/usb/ehci/ehci.h
r4e36219 rc028b22 1 1 /* 2 * Copyright (c) 20 09 Jiri Svoboda2 * Copyright (c) 2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mouse 30 * @brief 29 /** @addtogroup drvusbehci 31 30 * @{ 32 31 */ 33 32 /** @file 33 * Common EHCI definitions. 34 34 */ 35 #ifndef DRV_EHCI_EHCI_H 36 #define DRV_EHCI_EHCI_H 35 37 36 #ifndef LIBC_IPC_MOUSE_H_ 37 #define LIBC_IPC_MOUSE_H_ 38 #include <usbhc_iface.h> 38 39 39 # include <ipc/common.h>40 #define NAME "ehci" 40 41 41 typedef enum { 42 MEVENT_BUTTON = IPC_FIRST_USER_METHOD, 43 MEVENT_MOVE 44 } mouse_notif_t; 42 extern usbhc_iface_t ehci_hc_iface; 45 43 46 44 #endif 47 48 45 /** 49 46 * @} 50 47 */ 48 -
uspace/drv/bus/usb/uhci/uhci.h
r4e36219 rc028b22 1 1 /* 2 * Copyright (c) 20 09 Jiri Svoboda2 * Copyright (c) 2011 Jan Vesely 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mouse 30 * @brief 29 /** @addtogroup drvusbuhci 31 30 * @{ 32 31 */ 33 32 /** @file 33 * @brief UHCI driver main structure for both host controller and root-hub. 34 34 */ 35 #ifndef DRV_UHCI_UHCI_H 36 #define DRV_UHCI_UHCI_H 37 #include <ddf/driver.h> 35 38 36 #ifndef CHAR_MOUSE_H_ 37 #define CHAR_MOUSE_H_ 38 39 extern void mouse_handle_byte(int); 40 extern void mouse_ev_btn(int button, int press); 41 extern void mouse_ev_move(int dx, int dy); 42 39 int device_setup_uhci(ddf_dev_t *device); 43 40 #endif 44 45 41 /** 46 42 * @} -
uspace/drv/bus/usb/usbhub/main.c
r4e36219 rc028b22 1 1 /* 2 * Copyright (c) 2010 Jiri Svoboda2 * Copyright (c) 2010 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mouse29 /** @addtogroup drvusbhub 30 30 * @{ 31 */32 /** @file33 * @brief34 31 */ 35 32 36 #include <ipc/adb.h> 33 #include <ddf/driver.h> 34 #include <errno.h> 37 35 #include <async.h> 38 #include <vfs/vfs.h> 39 #include <fcntl.h> 40 #include <errno.h> 36 #include <stdio.h> 41 37 42 #include "adb_mouse.h"43 #include "adb_dev.h"38 #include <usb/dev/driver.h> 39 #include <usb/classes/classes.h> 44 40 45 static void adb_dev_events(ipc_callid_t iid, ipc_call_t *icall); 41 #include "usbhub.h" 42 #include "usbhub_private.h" 46 43 47 static int dev_phone; 44 /** Hub status-change endpoint description. 45 * 46 * For more information see section 11.15.1 of USB 1.1 specification. 47 */ 48 static usb_endpoint_description_t hub_status_change_endpoint_description = { 49 .transfer_type = USB_TRANSFER_INTERRUPT, 50 .direction = USB_DIRECTION_IN, 51 .interface_class = USB_CLASS_HUB, 52 .interface_subclass = 0, 53 .interface_protocol = 0, 54 .flags = 0 55 }; 48 56 49 int adb_dev_init(void) 57 /** 58 * usb hub driver operations 59 * 60 * The most important one is add_device, which is set to usb_hub_add_device. 61 */ 62 static usb_driver_ops_t usb_hub_driver_ops = { 63 .add_device = usb_hub_add_device 64 }; 65 66 /** 67 * hub endpoints, excluding control endpoint 68 */ 69 static usb_endpoint_description_t *usb_hub_endpoints[] = { 70 &hub_status_change_endpoint_description, 71 NULL 72 }; 73 74 /** 75 * static usb hub driver information 76 */ 77 static usb_driver_t usb_hub_driver = { 78 .name = NAME, 79 .ops = &usb_hub_driver_ops, 80 .endpoints = usb_hub_endpoints 81 }; 82 83 84 int main(int argc, char *argv[]) 50 85 { 51 const char *input = "/dev/adb/mouse"; 52 int input_fd; 86 printf(NAME ": HelenOS USB hub driver.\n"); 53 87 54 printf(NAME ": open %s\n", input);88 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME); 55 89 56 input_fd = open(input, O_RDONLY); 57 if (input_fd < 0) { 58 printf(NAME ": Failed opening %s (%d)\n", input, input_fd); 59 return false; 60 } 61 62 dev_phone = fd_phone(input_fd); 63 if (dev_phone < 0) { 64 printf(NAME ": Failed to connect to device\n"); 65 return false; 66 } 67 68 /* NB: The callback connection is slotted for removal */ 69 if (async_connect_to_me(dev_phone, 0, 0, 0, adb_dev_events) != 0) { 70 printf(NAME ": Failed to create callback from device\n"); 71 return false; 72 } 73 74 return 0; 75 } 76 77 static void adb_dev_events(ipc_callid_t iid, ipc_call_t *icall) 78 { 79 /* Ignore parameters, the connection is already opened */ 80 while (true) { 81 82 ipc_call_t call; 83 ipc_callid_t callid = async_get_call(&call); 84 85 int retval; 86 87 switch (IPC_GET_IMETHOD(call)) { 88 case IPC_M_PHONE_HUNGUP: 89 /* TODO: Handle hangup */ 90 return; 91 case IPC_FIRST_USER_METHOD: 92 mouse_handle_data(IPC_GET_ARG1(call)); 93 break; 94 default: 95 retval = ENOENT; 96 } 97 async_answer_0(callid, retval); 98 } 90 return usb_driver_main(&usb_hub_driver); 99 91 } 100 92 … … 102 94 * @} 103 95 */ 96
Note:
See TracChangeset
for help on using the changeset viewer.
