Changeset 79ae36dd in mainline for uspace/drv
- Timestamp:
- 2011-06-08T19:01:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0eff68e
- Parents:
- 764d71e
- Location:
- uspace/drv
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ehci_hcd/pci.c
r764d71e r79ae36dd 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 /** 29 30 * @addtogroup drvusbehci … … 34 35 * PCI related functions needed by the EHCI driver. 35 36 */ 37 36 38 #include <errno.h> 37 39 #include <str_error.h> … … 72 74 #define PCI_READ(size) \ 73 75 do { \ 74 const int parent_phone = \ 75 devman_parent_device_connect(dev->handle, IPC_FLAG_BLOCKING);\ 76 if (parent_phone < 0) {\ 77 return parent_phone; \ 78 } \ 79 sysarg_t add = (sysarg_t)address; \ 76 async_sess_t *parent_sess = \ 77 devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, \ 78 IPC_FLAG_BLOCKING); \ 79 if (!parent_sess) \ 80 return ENOMEM; \ 81 \ 82 sysarg_t add = (sysarg_t) address; \ 80 83 sysarg_t val; \ 84 \ 85 async_exch_t *exch = async_exchange_begin(parent_sess); \ 86 \ 81 87 const int ret = \ 82 async_req_2_1( parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE), \88 async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE), \ 83 89 IPC_M_CONFIG_SPACE_READ_##size, add, &val); \ 90 \ 91 async_exchange_end(exch); \ 92 async_hangup(parent_sess); \ 93 \ 84 94 assert(value); \ 95 \ 85 96 *value = val; \ 86 async_hangup(parent_phone); \ 97 return ret; \ 98 } while (0) 99 100 static int pci_read32(const ddf_dev_t *dev, int address, uint32_t *value) 101 { 102 PCI_READ(32); 103 } 104 105 static int pci_read16(const ddf_dev_t *dev, int address, uint16_t *value) 106 { 107 PCI_READ(16); 108 } 109 110 static int pci_read8(const ddf_dev_t *dev, int address, uint8_t *value) 111 { 112 PCI_READ(8); 113 } 114 115 #define PCI_WRITE(size) \ 116 do { \ 117 async_sess_t *parent_sess = \ 118 devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, \ 119 IPC_FLAG_BLOCKING); \ 120 if (!parent_sess) \ 121 return ENOMEM; \ 122 \ 123 sysarg_t add = (sysarg_t) address; \ 124 sysarg_t val = value; \ 125 \ 126 async_exch_t *exch = async_exchange_begin(parent_sess); \ 127 \ 128 const int ret = \ 129 async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE), \ 130 IPC_M_CONFIG_SPACE_WRITE_##size, add, val); \ 131 \ 132 async_exchange_end(exch); \ 133 async_hangup(parent_sess); \ 134 \ 87 135 return ret; \ 88 136 } while(0) 89 137 90 static int pci_read32(const ddf_dev_t *dev, int address, uint32_t *value)91 {92 PCI_READ(32);93 }94 static int pci_read16(const ddf_dev_t *dev, int address, uint16_t *value)95 {96 PCI_READ(16);97 }98 static int pci_read8(const ddf_dev_t *dev, int address, uint8_t *value)99 {100 PCI_READ(8);101 }102 #define PCI_WRITE(size) \103 do { \104 const int parent_phone = \105 devman_parent_device_connect(dev->handle, IPC_FLAG_BLOCKING);\106 if (parent_phone < 0) {\107 return parent_phone; \108 } \109 sysarg_t add = (sysarg_t)address; \110 sysarg_t val = value; \111 const int ret = \112 async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE), \113 IPC_M_CONFIG_SPACE_WRITE_##size, add, val); \114 async_hangup(parent_phone); \115 return ret; \116 } while(0)117 118 138 static int pci_write32(const ddf_dev_t *dev, int address, uint32_t value) 119 139 { 120 140 PCI_WRITE(32); 121 141 } 142 122 143 static int pci_write16(const ddf_dev_t *dev, int address, uint16_t value) 123 144 { 124 145 PCI_WRITE(16); 125 146 } 147 126 148 static int pci_write8(const ddf_dev_t *dev, int address, uint8_t value) 127 149 { … … 141 163 { 142 164 assert(dev != NULL); 143 144 const int parent_phone = 145 devman_parent_device_connect(dev->handle, IPC_FLAG_BLOCKING); 146 if (parent_phone < 0) { 147 return parent_phone; 148 } 149 150 int rc; 151 165 166 async_sess_t *parent_sess = 167 devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, 168 IPC_FLAG_BLOCKING); 169 if (!parent_sess) 170 return ENOMEM; 171 152 172 hw_resource_list_t hw_resources; 153 rc = hw_res_get_resource_list(parent_phone, &hw_resources);173 int rc = hw_res_get_resource_list(parent_sess, &hw_resources); 154 174 if (rc != EOK) { 155 async_hangup(parent_ phone);175 async_hangup(parent_sess); 156 176 return rc; 157 177 } 158 178 159 179 uintptr_t mem_address = 0; 160 180 size_t mem_size = 0; 161 181 bool mem_found = false; 162 182 163 183 int irq = 0; 164 184 bool irq_found = false; 165 185 166 186 size_t i; 167 187 for (i = 0; i < hw_resources.count; i++) { 168 188 hw_resource_t *res = &hw_resources.resources[i]; 169 switch (res->type) 170 { 189 switch (res->type) { 171 190 case INTERRUPT: 172 191 irq = res->res.interrupt.irq; … … 174 193 usb_log_debug2("Found interrupt: %d.\n", irq); 175 194 break; 176 177 195 case MEM_RANGE: 178 196 if (res->res.mem_range.address != 0 … … 183 201 mem_address, mem_size); 184 202 mem_found = true; 185 203 } 186 204 default: 187 205 break; 188 206 } 189 207 } 190 208 191 209 if (mem_found && irq_found) { 192 210 *mem_reg_address = mem_address; … … 197 215 rc = ENOENT; 198 216 } 199 200 async_hangup(parent_ phone);217 218 async_hangup(parent_sess); 201 219 return rc; 202 220 } … … 209 227 int pci_enable_interrupts(const ddf_dev_t *device) 210 228 { 211 const int parent_phone = 212 devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING); 213 if (parent_phone < 0) { 214 return parent_phone; 215 } 216 const bool enabled = hw_res_enable_interrupt(parent_phone); 217 async_hangup(parent_phone); 229 async_sess_t *parent_sess = 230 devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle, 231 IPC_FLAG_BLOCKING); 232 if (!parent_sess) 233 return ENOMEM; 234 235 const bool enabled = hw_res_enable_interrupt(parent_sess); 236 async_hangup(parent_sess); 237 218 238 return enabled ? EOK : EIO; 219 239 } … … 366 386 #undef CHECK_RET_RETURN 367 387 } 368 /*----------------------------------------------------------------------------*/ 388 369 389 /** 370 390 * @} 371 391 */ 372 373 /**374 * @}375 */ -
uspace/drv/ns8250/ns8250.c
r764d71e r79ae36dd 263 263 static void ns8250_dev_cleanup(ns8250_t *ns) 264 264 { 265 if (ns->dev->parent_ phone > 0) {266 async_hangup(ns->dev->parent_ phone);267 ns->dev->parent_ phone = 0;265 if (ns->dev->parent_sess) { 266 async_hangup(ns->dev->parent_sess); 267 ns->dev->parent_sess = NULL; 268 268 } 269 269 } … … 337 337 338 338 /* Connect to the parent's driver. */ 339 ns->dev->parent_ phone = devman_parent_device_connect(ns->dev->handle,340 IPC_FLAG_BLOCKING);341 if ( ns->dev->parent_phone < 0) {339 ns->dev->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE, 340 ns->dev->handle, IPC_FLAG_BLOCKING); 341 if (!ns->dev->parent_sess) { 342 342 ddf_msg(LVL_ERROR, "Failed to connect to parent driver of " 343 343 "device %s.", ns->dev->name); 344 ret = ns->dev->parent_phone;344 ret = ENOENT; 345 345 goto failed; 346 346 } 347 347 348 348 /* Get hw resources. */ 349 ret = hw_res_get_resource_list(ns->dev->parent_ phone, &hw_resources);349 ret = hw_res_get_resource_list(ns->dev->parent_sess, &hw_resources); 350 350 if (ret != EOK) { 351 351 ddf_msg(LVL_ERROR, "Failed to get HW resources for device " -
uspace/drv/ohci/pci.c
r764d71e r79ae36dd 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 /** 29 30 * @addtogroup drvusbohci … … 34 35 * PCI related functions needed by the OHCI driver. 35 36 */ 37 36 38 #include <errno.h> 37 39 #include <assert.h> … … 63 65 assert(irq_no); 64 66 65 int parent_phone = devman_parent_device_connect(dev->handle, 67 async_sess_t *parent_sess = 68 devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, 66 69 IPC_FLAG_BLOCKING); 67 if (parent_phone < 0) { 68 return parent_phone; 69 } 70 71 int rc; 72 70 if (!parent_sess) 71 return ENOMEM; 72 73 73 hw_resource_list_t hw_resources; 74 rc = hw_res_get_resource_list(parent_phone, &hw_resources);74 int rc = hw_res_get_resource_list(parent_sess, &hw_resources); 75 75 if (rc != EOK) { 76 async_hangup(parent_ phone);76 async_hangup(parent_sess); 77 77 return rc; 78 78 } 79 79 80 80 uintptr_t mem_address = 0; 81 81 size_t mem_size = 0; 82 82 bool mem_found = false; 83 83 84 84 int irq = 0; 85 85 bool irq_found = false; 86 86 87 87 size_t i; 88 88 for (i = 0; i < hw_resources.count; i++) { 89 89 hw_resource_t *res = &hw_resources.resources[i]; 90 switch (res->type) 91 { 90 switch (res->type) { 92 91 case INTERRUPT: 93 92 irq = res->res.interrupt.irq; … … 95 94 usb_log_debug2("Found interrupt: %d.\n", irq); 96 95 break; 97 98 96 case MEM_RANGE: 99 97 if (res->res.mem_range.address != 0 … … 104 102 (void *) mem_address, mem_size); 105 103 mem_found = true; 106 104 } 107 105 default: 108 106 break; 109 107 } 110 108 } 111 109 112 110 if (mem_found && irq_found) { 113 111 *mem_reg_address = mem_address; … … 115 113 *irq_no = irq; 116 114 rc = EOK; 117 } else {115 } else 118 116 rc = ENOENT; 119 } 120 121 async_hangup(parent_phone); 117 118 async_hangup(parent_sess); 122 119 return rc; 123 120 } 124 /*----------------------------------------------------------------------------*/ 125 /** Call sthe PCI driver with a request to enable interrupts121 122 /** Call the PCI driver with a request to enable interrupts 126 123 * 127 124 * @param[in] device Device asking for interrupts … … 130 127 int pci_enable_interrupts(ddf_dev_t *device) 131 128 { 132 int parent_phone = 133 devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING); 134 if (parent_phone < 0) { 135 return parent_phone; 136 } 137 bool enabled = hw_res_enable_interrupt(parent_phone); 138 async_hangup(parent_phone); 129 async_sess_t *parent_sess = 130 devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle, 131 IPC_FLAG_BLOCKING); 132 if (!parent_sess) 133 return ENOMEM; 134 135 bool enabled = hw_res_enable_interrupt(parent_sess); 136 async_hangup(parent_sess); 137 139 138 return enabled ? EOK : EIO; 140 139 } 141 /**142 * @}143 */144 140 145 141 /** -
uspace/drv/pciintel/pci.c
r764d71e r79ae36dd 53 53 #include <ipc/dev_iface.h> 54 54 #include <ipc/irc.h> 55 #include < ipc/ns.h>55 #include <ns.h> 56 56 #include <ipc/services.h> 57 57 #include <sysinfo.h> … … 92 92 assert(fnode); 93 93 pci_fun_t *dev_data = (pci_fun_t *) fnode->driver_data; 94 94 95 95 sysarg_t apic; 96 96 sysarg_t i8259; 97 98 int irc_phone = ENOTSUP;99 97 98 async_sess_t *irc_sess = NULL; 99 100 100 if (((sysinfo_get_value("apic", &apic) == EOK) && (apic)) 101 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) { 102 irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE, 103 SERVICE_IRC, 0, 0); 104 } 105 106 if (!irc_sess) 106 107 return false; 107 } 108 108 109 109 size_t i = 0; 110 110 hw_resource_list_t *res = &dev_data->hw_resources; … … 112 112 if (res->resources[i].type == INTERRUPT) { 113 113 const int irq = res->resources[i].res.interrupt.irq; 114 115 async_exch_t *exch = async_exchange_begin(irc_sess); 114 116 const int rc = 115 async_req_1_0(irc_phone, IRC_ENABLE_INTERRUPT, irq); 117 async_req_1_0(exch, IRC_ENABLE_INTERRUPT, irq); 118 async_exchange_end(exch); 119 116 120 if (rc != EOK) { 117 async_hangup(irc_ phone);121 async_hangup(irc_sess); 118 122 return false; 119 123 } 120 124 } 121 125 } 122 123 async_hangup(irc_ phone);126 127 async_hangup(irc_sess); 124 128 return true; 125 129 } 126 130 127 static int pci_config_space_write_32( 128 ddf_fun_t *fun, uint32_t address,uint32_t data)131 static int pci_config_space_write_32(ddf_fun_t *fun, uint32_t address, 132 uint32_t data) 129 133 { 130 134 if (address > 252) … … 576 580 577 581 ddf_msg(LVL_DEBUG, "pci_add_device"); 578 dnode->parent_ phone = -1;582 dnode->parent_sess = NULL; 579 583 580 584 bus = pci_bus_new(); … … 587 591 dnode->driver_data = bus; 588 592 589 dnode->parent_ phone = devman_parent_device_connect(dnode->handle,590 IPC_FLAG_BLOCKING);591 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) { 592 596 ddf_msg(LVL_ERROR, "pci_add_device failed to connect to the " 593 "parent 'sdriver.");594 rc = dnode->parent_phone;597 "parent driver."); 598 rc = ENOENT; 595 599 goto fail; 596 600 } … … 598 602 hw_resource_list_t hw_resources; 599 603 600 rc = hw_res_get_resource_list(dnode->parent_ phone, &hw_resources);604 rc = hw_res_get_resource_list(dnode->parent_sess, &hw_resources); 601 605 if (rc != EOK) { 602 606 ddf_msg(LVL_ERROR, "pci_add_device failed to get hw resources " … … 651 655 if (bus != NULL) 652 656 pci_bus_delete(bus); 653 if (dnode->parent_phone >= 0) 654 async_hangup(dnode->parent_phone); 657 658 if (dnode->parent_sess) 659 async_hangup(dnode->parent_sess); 660 655 661 if (got_res) 656 662 hw_res_clean_resource_list(&hw_resources); 663 657 664 if (ctl != NULL) 658 665 ddf_fun_destroy(ctl); 659 666 660 667 return rc; 661 668 } -
uspace/drv/uhci_hcd/pci.c
r764d71e r79ae36dd 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 /** 29 30 * @addtogroup drvusbuhcihc … … 34 35 * PCI related functions needed by the UHCI driver. 35 36 */ 37 36 38 #include <errno.h> 37 39 #include <assert.h> … … 59 61 assert(io_reg_size); 60 62 assert(irq_no); 61 62 int parent_phone=63 devman_parent_device_connect( dev->handle, IPC_FLAG_BLOCKING);64 if (parent_phone < 0) {65 return parent_phone;66 }67 63 64 async_sess_t *parent_sess = 65 devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, 66 IPC_FLAG_BLOCKING); 67 if (!parent_sess) 68 return ENOMEM; 69 68 70 hw_resource_list_t hw_resources; 69 int rc = hw_res_get_resource_list(parent_ phone, &hw_resources);71 int rc = hw_res_get_resource_list(parent_sess, &hw_resources); 70 72 if (rc != EOK) { 71 async_hangup(parent_ phone);73 async_hangup(parent_sess); 72 74 return rc; 73 75 } 74 76 75 77 uintptr_t io_address = 0; 76 78 size_t io_size = 0; 77 79 bool io_found = false; 78 80 79 81 int irq = 0; 80 82 bool irq_found = false; 81 83 82 84 size_t i; 83 85 for (i = 0; i < hw_resources.count; i++) { 84 86 const hw_resource_t *res = &hw_resources.resources[i]; 85 switch (res->type) 86 { 87 switch (res->type) { 87 88 case INTERRUPT: 88 89 irq = res->res.interrupt.irq; … … 90 91 usb_log_debug2("Found interrupt: %d.\n", irq); 91 92 break; 92 93 93 case IO_RANGE: 94 94 io_address = res->res.io_range.address; … … 98 98 io_found = true; 99 99 break; 100 101 100 default: 102 101 break; 103 102 } 104 103 } 105 async_hangup(parent_phone); 106 104 105 async_hangup(parent_sess); 106 107 107 if (!io_found || !irq_found) 108 108 return ENOENT; 109 109 110 110 *io_reg_address = io_address; 111 111 *io_reg_size = io_size; 112 112 *irq_no = irq; 113 113 114 114 return EOK; 115 115 } 116 /*----------------------------------------------------------------------------*/ 116 117 117 /** Call the PCI driver with a request to enable interrupts 118 118 * … … 122 122 int pci_enable_interrupts(const ddf_dev_t *device) 123 123 { 124 const int parent_phone = 125 devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING); 126 if (parent_phone < 0) { 127 return parent_phone; 128 } 129 const bool enabled = hw_res_enable_interrupt(parent_phone); 130 async_hangup(parent_phone); 124 async_sess_t *parent_sess = 125 devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle, 126 IPC_FLAG_BLOCKING); 127 if (!parent_sess) 128 return ENOMEM; 129 130 const bool enabled = hw_res_enable_interrupt(parent_sess); 131 async_hangup(parent_sess); 132 131 133 return enabled ? EOK : EIO; 132 134 } 133 /*----------------------------------------------------------------------------*/ 135 134 136 /** Call the PCI driver with a request to clear legacy support register 135 137 * … … 140 142 { 141 143 assert(device); 142 const int parent_phone = 143 devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING); 144 if (parent_phone < 0) { 145 return parent_phone; 146 } 147 144 145 async_sess_t *parent_sess = 146 devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle, 147 IPC_FLAG_BLOCKING); 148 if (!parent_sess) 149 return ENOMEM; 150 148 151 /* See UHCI design guide for these values p.45, 149 152 * write all WC bits in USB legacy register */ 150 153 const sysarg_t address = 0xc0; 151 154 const sysarg_t value = 0xaf00; 152 153 const int rc = async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE), 155 156 async_exch_t *exch = async_exchange_begin(parent_sess); 157 158 const int rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE), 154 159 IPC_M_CONFIG_SPACE_WRITE_16, address, value); 155 async_hangup(parent_phone); 156 160 161 async_exchange_end(exch); 162 async_hangup(parent_sess); 163 157 164 return rc; 158 165 } 159 /*----------------------------------------------------------------------------*/160 /**161 * @}162 */163 166 164 167 /** -
uspace/drv/uhci_rhd/main.c
r764d71e r79ae36dd 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 /** @addtogroup drvusbuhcirh 29 30 * @{ … … 32 33 * @brief UHCI root hub initialization routines 33 34 */ 35 34 36 #include <ddf/driver.h> 35 37 #include <devman.h> … … 48 50 static int hc_get_my_registers(const ddf_dev_t *dev, 49 51 uintptr_t *io_reg_address, size_t *io_reg_size); 50 /*----------------------------------------------------------------------------*/ 52 51 53 static int uhci_rh_add_device(ddf_dev_t *device); 52 /*----------------------------------------------------------------------------*/ 54 53 55 static driver_ops_t uhci_rh_driver_ops = { 54 56 .add_device = uhci_rh_add_device, 55 57 }; 56 /*----------------------------------------------------------------------------*/ 58 57 59 static driver_t uhci_rh_driver = { 58 60 .name = NAME, 59 61 .driver_ops = &uhci_rh_driver_ops 60 62 }; 61 /*----------------------------------------------------------------------------*/ 63 62 64 /** Initialize global driver structures (NONE). 63 65 * … … 74 76 return ddf_driver_main(&uhci_rh_driver); 75 77 } 76 /*----------------------------------------------------------------------------*/ 78 77 79 /** Initialize a new ddf driver instance of UHCI root hub. 78 80 * … … 122 124 return EOK; 123 125 } 124 /*----------------------------------------------------------------------------*/ 126 125 127 /** Get address of I/O registers. 126 128 * … … 134 136 { 135 137 assert(dev); 136 137 const int parent_phone = devman_parent_device_connect(dev->handle, 138 139 async_sess_t *parent_sess = 140 devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, 138 141 IPC_FLAG_BLOCKING); 139 if (parent_phone < 0) { 140 return parent_phone; 141 } 142 142 if (!parent_sess) 143 return ENOMEM; 144 143 145 hw_resource_list_t hw_resources; 144 const int ret = hw_res_get_resource_list(parent_ phone, &hw_resources);146 const int ret = hw_res_get_resource_list(parent_sess, &hw_resources); 145 147 if (ret != EOK) { 146 async_hangup(parent_ phone);148 async_hangup(parent_sess); 147 149 return ret; 148 150 } 149 151 150 152 uintptr_t io_address = 0; 151 153 size_t io_size = 0; 152 154 bool io_found = false; 153 155 154 156 size_t i = 0; 155 157 for (; i < hw_resources.count; i++) { … … 160 162 io_found = true; 161 163 } 164 162 165 } 163 async_hangup(parent_ phone);164 165 if (!io_found) {166 async_hangup(parent_sess); 167 168 if (!io_found) 166 169 return ENOENT; 167 }168 if (io_reg_address != NULL) {170 171 if (io_reg_address != NULL) 169 172 *io_reg_address = io_address; 170 }171 if (io_reg_size != NULL) {173 174 if (io_reg_size != NULL) 172 175 *io_reg_size = io_size; 173 }176 174 177 return EOK; 175 178 } 179 176 180 /** 177 181 * @} -
uspace/drv/usbhid/kbd/kbddev.c
r764d71e r79ae36dd 42 42 #include <ipc/kbd.h> 43 43 #include <async.h> 44 #include <async_obsolete.h> 44 45 #include <fibril.h> 45 46 #include <fibril_synch.h> … … 67 68 68 69 #include "../usbhid.h" 70 71 // FIXME: remove this header 72 #include <kernel/ipc/ipc_methods.h> 69 73 70 74 /*----------------------------------------------------------------------------*/ … … 307 311 unsigned int key) 308 312 { 309 console_event_t ev;313 kbd_event_t ev; 310 314 unsigned mod_mask; 311 315 … … 399 403 } 400 404 401 async_ msg_4(kbd_dev->console_phone, KBD_EVENT, ev.type, ev.key,405 async_obsolete_msg_4(kbd_dev->console_phone, KBD_EVENT, ev.type, ev.key, 402 406 ev.mods, ev.c); 403 407 } … … 892 896 893 897 // hangup phone to the console 894 async_ hangup((*kbd_dev)->console_phone);898 async_obsolete_hangup((*kbd_dev)->console_phone); 895 899 896 900 if ((*kbd_dev)->repeat_mtx != NULL) { -
uspace/drv/usbhid/layout.h
r764d71e r79ae36dd 44 44 typedef struct { 45 45 void (*reset)(void); 46 wchar_t (*parse_ev)( console_event_t *);46 wchar_t (*parse_ev)(kbd_event_t *); 47 47 } layout_op_t; 48 48 -
uspace/drv/usbhid/mouse/mousedev.c
r764d71e r79ae36dd 41 41 #include <usb/hid/usages/core.h> 42 42 #include <errno.h> 43 #include <async.h> 44 #include <async_obsolete.h> 43 45 #include <str_error.h> 44 46 #include <ipc/mouse.h> … … 50 52 #include "mousedev.h" 51 53 #include "../usbhid.h" 54 55 // FIXME: remove this header 56 #include <kernel/ipc/ipc_methods.h> 52 57 53 58 #define NAME "mouse" … … 181 186 // hangup phone to the console 182 187 if ((*mouse_dev)->mouse_phone >= 0) { 183 async_ hangup((*mouse_dev)->mouse_phone);188 async_obsolete_hangup((*mouse_dev)->mouse_phone); 184 189 } 185 190 186 191 if ((*mouse_dev)->wheel_phone >= 0) { 187 async_ hangup((*mouse_dev)->wheel_phone);192 async_obsolete_hangup((*mouse_dev)->wheel_phone); 188 193 } 189 194 … … 196 201 static void usb_mouse_send_wheel(const usb_mouse_t *mouse_dev, int wheel) 197 202 { 198 console_event_t ev;203 kbd_event_t ev; 199 204 200 205 ev.type = KEY_PRESS; … … 214 219 for (i = 0; i < count * 3; ++i) { 215 220 usb_log_debug2("Sending key %d to the console\n", ev.key); 216 async_ msg_4(mouse_dev->wheel_phone, KBD_EVENT, ev.type,221 async_obsolete_msg_4(mouse_dev->wheel_phone, KBD_EVENT, ev.type, 217 222 ev.key, ev.mods, ev.c); 218 223 // send key release right away 219 async_ msg_4(mouse_dev->wheel_phone, KBD_EVENT, KEY_RELEASE,224 async_obsolete_msg_4(mouse_dev->wheel_phone, KBD_EVENT, KEY_RELEASE, 220 225 ev.key, ev.mods, ev.c); 221 226 } … … 303 308 304 309 if ((shift_x != 0) || (shift_y != 0)) { 305 async_ req_2_0(mouse_dev->mouse_phone,310 async_obsolete_req_2_0(mouse_dev->mouse_phone, 306 311 MEVENT_MOVE, shift_x, shift_y); 307 312 } … … 353 358 if (mouse_dev->buttons[field->usage - field->usage_minimum] == 0 354 359 && field->value != 0) { 355 async_ req_2_0(mouse_dev->mouse_phone,360 async_obsolete_req_2_0(mouse_dev->mouse_phone, 356 361 MEVENT_BUTTON, field->usage, 1); 357 362 mouse_dev->buttons[field->usage - field->usage_minimum] … … 360 365 mouse_dev->buttons[field->usage - field->usage_minimum] != 0 361 366 && field->value == 0) { 362 async_ req_2_0(mouse_dev->mouse_phone,367 async_obsolete_req_2_0(mouse_dev->mouse_phone, 363 368 MEVENT_BUTTON, field->usage, 0); 364 369 mouse_dev->buttons[field->usage - field->usage_minimum] -
uspace/drv/usbhid/multimedia/multimedia.c
r764d71e r79ae36dd 46 46 47 47 #include <errno.h> 48 #include <async.h> 49 #include <async_obsolete.h> 48 50 #include <str_error.h> 49 51 50 52 #include <ipc/kbd.h> 51 53 #include <io/console.h> 54 55 // FIXME: remove this header 56 #include <kernel/ipc/ipc_methods.h> 52 57 53 58 #define NAME "multimedia-keys" … … 143 148 assert(multim_dev != NULL); 144 149 145 console_event_t ev;150 kbd_event_t ev; 146 151 147 152 ev.type = type; … … 157 162 } 158 163 159 async_ msg_4(multim_dev->console_phone, KBD_EVENT, ev.type, ev.key,164 async_obsolete_msg_4(multim_dev->console_phone, KBD_EVENT, ev.type, ev.key, 160 165 ev.mods, ev.c); 161 166 } … … 170 175 171 176 // hangup phone to the console 172 async_ hangup((*multim_dev)->console_phone);177 async_obsolete_hangup((*multim_dev)->console_phone); 173 178 174 179 free(*multim_dev); -
uspace/drv/usbmouse/init.c
r764d71e r79ae36dd 34 34 * Initialization routines for USB mouse driver. 35 35 */ 36 36 37 #include "mouse.h" 37 38 #include <usb/debug.h> … … 41 42 #include <usb/hid/request.h> 42 43 #include <errno.h> 44 45 // FIXME: remove this header 46 #include <kernel/ipc/ipc_methods.h> 43 47 44 48 /** Mouse polling endpoint description for boot protocol subclass. */ -
uspace/drv/usbmouse/mouse.c
r764d71e r79ae36dd 34 34 * Actual handling of USB mouse protocol. 35 35 */ 36 #include "mouse.h" 36 37 37 #include <usb/debug.h> 38 38 #include <errno.h> 39 39 #include <str_error.h> 40 40 #include <ipc/mouse.h> 41 #include <async.h> 42 #include <async_obsolete.h> 43 #include "mouse.h" 41 44 42 45 /** Mouse polling callback. … … 81 84 if ((shift_x != 0) || (shift_y != 0)) { 82 85 /* FIXME: guessed for QEMU */ 83 async_ req_2_0(mouse->console_phone,86 async_obsolete_req_2_0(mouse->console_phone, 84 87 MEVENT_MOVE, 85 88 - shift_x / 10, - shift_y / 10); … … 87 90 if (butt) { 88 91 /* FIXME: proper button clicking. */ 89 async_ req_2_0(mouse->console_phone,92 async_obsolete_req_2_0(mouse->console_phone, 90 93 MEVENT_BUTTON, 1, 1); 91 async_ req_2_0(mouse->console_phone,94 async_obsolete_req_2_0(mouse->console_phone, 92 95 MEVENT_BUTTON, 1, 0); 93 96 } … … 115 118 usb_mouse_t *mouse = (usb_mouse_t *) arg; 116 119 117 async_ hangup(mouse->console_phone);120 async_obsolete_hangup(mouse->console_phone); 118 121 mouse->console_phone = -1; 119 122 -
uspace/drv/vhc/conndev.c
r764d71e r79ae36dd 38 38 #include <ddf/driver.h> 39 39 #include <usbvirt/ipc.h> 40 #include <async.h> 40 41 #include "conn.h" 41 42 … … 44 45 static fibril_local char plugged_device_name[PLUGGED_DEVICE_NAME_MAXLEN + 1] = "<unknown>"; 45 46 47 #if 0 46 48 /** Receive device name. 47 49 * 48 50 * @warning Errors are silently ignored. 49 51 * 50 * @param phone Phone to the virtual device. 52 * @param sess Session to the virtual device. 53 * 51 54 */ 52 static void receive_device_name( int phone)55 static void receive_device_name(async_sess_t *sess) 53 56 { 54 aid_t opening_request = async_send_0(phone, IPC_M_USBVIRT_GET_NAME, NULL); 57 async_exch_t *exch = async_exchange_begin(sess); 58 59 aid_t opening_request = async_send_0(exch, IPC_M_USBVIRT_GET_NAME, NULL); 55 60 if (opening_request == 0) { 61 async_exchange_end(exch); 56 62 return; 57 63 } 58 59 64 60 65 ipc_call_t data_request_call; 61 aid_t data_request = async_data_read(phone, 62 plugged_device_name, PLUGGED_DEVICE_NAME_MAXLEN, 63 &data_request_call); 64 66 aid_t data_request = async_data_read(exch, plugged_device_name, 67 PLUGGED_DEVICE_NAME_MAXLEN, &data_request_call); 68 69 async_exchange_end(exch); 70 65 71 if (data_request == 0) { 66 72 async_wait_for(opening_request, NULL); 67 73 return; 68 74 } 69 75 70 76 sysarg_t data_request_rc; 71 77 sysarg_t opening_request_rc; 72 78 async_wait_for(data_request, &data_request_rc); 73 79 async_wait_for(opening_request, &opening_request_rc); 74 75 if ((data_request_rc != EOK) || (opening_request_rc != EOK)) {80 81 if ((data_request_rc != EOK) || (opening_request_rc != EOK)) 76 82 return; 77 } 78 83 79 84 size_t len = IPC_GET_ARG2(data_request_call); 80 85 plugged_device_name[len] = 0; 81 86 } 87 #endif 82 88 83 89 /** Default handler for IPC methods not handled by DDF. … … 90 96 ipc_callid_t icallid, ipc_call_t *icall) 91 97 { 98 // FIXME: 99 // This code needs to be refactored since the async 100 // framework does not support automatic callback connections 101 // yet. 102 103 #if 0 92 104 vhc_data_t *vhc = fun->dev->driver_data; 93 105 sysarg_t method = IPC_GET_IMETHOD(*icall); … … 112 124 return; 113 125 } 126 #endif 114 127 115 128 async_answer_0(icallid, EINVAL); -
uspace/drv/vhc/devconn.c
r764d71e r79ae36dd 1 /* 2 * Copyright (c) 2011 Vojtech Horky 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 1 29 #include <errno.h> 2 30 #include "vhcd.h" … … 11 39 } 12 40 dev->address = 0; 13 dev->dev_ phone = -1;41 dev->dev_sess = NULL; 14 42 dev->dev_local = NULL; 15 43 dev->plugged = true; … … 22 50 23 51 static int vhc_virtdev_plug_generic(vhc_data_t *vhc, 24 int phone, usbvirt_device_t *virtdev,52 async_sess_t *sess, usbvirt_device_t *virtdev, 25 53 uintptr_t *handle, bool connect) 26 54 { … … 30 58 } 31 59 32 dev->dev_ phone = phone;60 dev->dev_sess = sess; 33 61 dev->dev_local = virtdev; 34 62 … … 56 84 } 57 85 58 int vhc_virtdev_plug(vhc_data_t *vhc, int phone, uintptr_t *handle)86 int vhc_virtdev_plug(vhc_data_t *vhc, async_sess_t *sess, uintptr_t *handle) 59 87 { 60 return vhc_virtdev_plug_generic(vhc, phone, NULL, handle, true);88 return vhc_virtdev_plug_generic(vhc, sess, NULL, handle, true); 61 89 } 62 90 63 91 int vhc_virtdev_plug_local(vhc_data_t *vhc, usbvirt_device_t *dev, uintptr_t *handle) 64 92 { 65 return vhc_virtdev_plug_generic(vhc, -1, dev, handle, true);93 return vhc_virtdev_plug_generic(vhc, NULL, dev, handle, true); 66 94 } 67 95 68 96 int vhc_virtdev_plug_hub(vhc_data_t *vhc, usbvirt_device_t *dev, uintptr_t *handle) 69 97 { 70 return vhc_virtdev_plug_generic(vhc, -1, dev, handle, false);98 return vhc_virtdev_plug_generic(vhc, NULL, dev, handle, false); 71 99 } 72 100 -
uspace/drv/vhc/hub.c
r764d71e r79ae36dd 33 33 * @brief Virtual USB hub. 34 34 */ 35 35 36 #include <usb/classes/classes.h> 36 37 #include <usbvirt/device.h> 37 38 #include <errno.h> 39 #include <async.h> 38 40 #include <str_error.h> 39 41 #include <stdlib.h> … … 44 46 45 47 #include "hub.h" 46 //#include "hub/virthub.h"47 48 #include "vhcd.h" 48 49 #include "conn.h" … … 97 98 * Wait until parent device is properly initialized. 98 99 */ 99 int phone;100 async_sess_t *sess; 100 101 do { 101 phone = devman_device_connect(hc_dev->handle, 0);102 } while ( phone < 0);103 async_hangup( phone);102 sess = devman_device_connect(EXCHANGE_SERIALIZE, hc_dev->handle, 0); 103 } while (!sess); 104 async_hangup(sess); 104 105 105 106 int rc; … … 129 130 return 0; 130 131 } 131 132 132 133 133 /** -
uspace/drv/vhc/hub.h
r764d71e r79ae36dd 33 33 * @brief Virtual USB hub. 34 34 */ 35 35 36 #ifndef VHCD_HUB_H_ 36 37 #define VHCD_HUB_H_ -
uspace/drv/vhc/main.c
r764d71e r79ae36dd 29 29 /** @addtogroup drvusbvhc 30 30 * @{ 31 */ 31 */ 32 32 /** @file 33 33 * Virtual host controller. -
uspace/drv/vhc/transfer.c
r764d71e r79ae36dd 1 /* 2 * Copyright (c) 2011 Vojtech Horky 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 1 29 #include <errno.h> 2 30 #include <str_error.h> … … 123 151 124 152 static int process_transfer_remote(vhc_transfer_t *transfer, 125 int phone, size_t *actual_data_size)153 async_sess_t *sess, size_t *actual_data_size) 126 154 { 127 155 int rc; … … 129 157 if (transfer->transfer_type == USB_TRANSFER_CONTROL) { 130 158 if (transfer->direction == USB_DIRECTION_IN) { 131 rc = usbvirt_ipc_send_control_read( phone,132 transfer->setup_buffer, transfer->setup_buffer_size, 133 transfer->data_buffer, transfer->data_buffer_size, 134 actual_data_size); 135 } else { 136 assert(transfer->direction == USB_DIRECTION_OUT); 137 rc = usbvirt_ipc_send_control_write( phone,138 transfer->setup_buffer, transfer->setup_buffer_size, 139 transfer->data_buffer, transfer->data_buffer_size); 140 } 141 } else { 142 if (transfer->direction == USB_DIRECTION_IN) { 143 rc = usbvirt_ipc_send_data_in( phone, transfer->endpoint,159 rc = usbvirt_ipc_send_control_read(sess, 160 transfer->setup_buffer, transfer->setup_buffer_size, 161 transfer->data_buffer, transfer->data_buffer_size, 162 actual_data_size); 163 } else { 164 assert(transfer->direction == USB_DIRECTION_OUT); 165 rc = usbvirt_ipc_send_control_write(sess, 166 transfer->setup_buffer, transfer->setup_buffer_size, 167 transfer->data_buffer, transfer->data_buffer_size); 168 } 169 } else { 170 if (transfer->direction == USB_DIRECTION_IN) { 171 rc = usbvirt_ipc_send_data_in(sess, transfer->endpoint, 144 172 transfer->transfer_type, 145 173 transfer->data_buffer, transfer->data_buffer_size, … … 147 175 } else { 148 176 assert(transfer->direction == USB_DIRECTION_OUT); 149 rc = usbvirt_ipc_send_data_out( phone, transfer->endpoint,177 rc = usbvirt_ipc_send_data_out(sess, transfer->endpoint, 150 178 transfer->transfer_type, 151 179 transfer->data_buffer, transfer->data_buffer_size); … … 206 234 int rc = EOK; 207 235 size_t data_transfer_size = 0; 208 if (dev->dev_ phone > 0) {209 rc = process_transfer_remote(transfer, dev->dev_ phone,236 if (dev->dev_sess) { 237 rc = process_transfer_remote(transfer, dev->dev_sess, 210 238 &data_transfer_size); 211 239 } else if (dev->dev_local != NULL) { -
uspace/drv/vhc/vhcd.h
r764d71e r79ae36dd 41 41 #include <usb/host/device_keeper.h> 42 42 #include <usbhc_iface.h> 43 #include <async.h> 43 44 44 45 #define NAME "vhc" … … 46 47 typedef struct { 47 48 link_t link; 48 int dev_phone;49 async_sess_t *dev_sess; 49 50 usbvirt_device_t *dev_local; 50 51 bool plugged; … … 82 83 vhc_transfer_t *vhc_transfer_create(usb_address_t, usb_endpoint_t, 83 84 usb_direction_t, usb_transfer_type_t, ddf_fun_t *, void *); 84 int vhc_virtdev_plug(vhc_data_t *, int, uintptr_t *);85 int vhc_virtdev_plug(vhc_data_t *, async_sess_t *, uintptr_t *); 85 86 int vhc_virtdev_plug_local(vhc_data_t *, usbvirt_device_t *, uintptr_t *); 86 87 int vhc_virtdev_plug_hub(vhc_data_t *, usbvirt_device_t *, uintptr_t *);
Note:
See TracChangeset
for help on using the changeset viewer.