Changeset d51838f in mainline
- Timestamp:
- 2017-10-14T22:49:18Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 75911d24
- Parents:
- ce732e74
- Location:
- uspace
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/hdaudio/hdaudio.c
rce732e74 rd51838f 36 36 #include <bitops.h> 37 37 #include <ddi.h> 38 #include <device/hw_res.h> 38 39 #include <device/hw_res_parsed.h> 39 #include <irc.h>40 40 #include <stdio.h> 41 41 #include <errno.h> … … 257 257 ddf_msg(LVL_NOTE, "range0.base=%zu", hdaudio_irq_pio_ranges[0].base); 258 258 259 rc = irc_enable_interrupt(res.irqs.irqs[0]);259 rc = hw_res_enable_interrupt(hda->parent_sess, res.irqs.irqs[0]); 260 260 if (rc != EOK) { 261 261 ddf_msg(LVL_ERROR, "Failed enabling interrupt. (%d)", rc); -
uspace/drv/block/ahci/ahci.c
rce732e74 rd51838f 36 36 #include <ddf/interrupt.h> 37 37 #include <ddf/log.h> 38 #include <device/hw_res.h> 38 39 #include <device/hw_res_parsed.h> 39 40 #include <pci_dev_iface.h> 40 #include <irc.h>41 41 #include <ahci_iface.h> 42 42 #include "ahci.h" … … 1192 1192 } 1193 1193 1194 int rc = irc_enable_interrupt(hw_res_parsed.irqs.irqs[0]); 1194 int rc = hw_res_enable_interrupt(ahci->parent_sess, 1195 hw_res_parsed.irqs.irqs[0]); 1195 1196 if (rc != EOK) { 1196 1197 ddf_msg(LVL_ERROR, "Failed enable interupt."); -
uspace/drv/bus/isa/isa.c
rce732e74 rd51838f 115 115 } 116 116 117 static int isa_fun_enable_interrupt(ddf_fun_t *fnode, int irq) 118 { 119 isa_fun_t *fun = isa_fun(fnode); 117 static bool isa_fun_owns_interrupt(isa_fun_t *fun, int irq) 118 { 120 119 const hw_resource_list_t *res = &fun->hw_resources; 121 bool found;122 120 123 121 /* Check that specified irq really belongs to the function */ 124 found = false;125 122 for (size_t i = 0; i < res->count; ++i) { 126 123 if (res->resources[i].type == INTERRUPT && 127 124 res->resources[i].res.interrupt.irq == irq) { 128 found = true; 129 break; 130 } 131 } 132 133 if (!found) 125 return true; 126 } 127 } 128 129 return false; 130 } 131 132 static int isa_fun_enable_interrupt(ddf_fun_t *fnode, int irq) 133 { 134 isa_fun_t *fun = isa_fun(fnode); 135 136 if (!isa_fun_owns_interrupt(fun, irq)) 134 137 return EINVAL; 135 138 136 139 return irc_enable_interrupt(irq); 140 } 141 142 static int isa_fun_disable_interrupt(ddf_fun_t *fnode, int irq) 143 { 144 isa_fun_t *fun = isa_fun(fnode); 145 146 if (!isa_fun_owns_interrupt(fun, irq)) 147 return EINVAL; 148 149 return irc_disable_interrupt(irq); 150 } 151 152 static int isa_fun_clear_interrupt(ddf_fun_t *fnode, int irq) 153 { 154 isa_fun_t *fun = isa_fun(fnode); 155 156 if (!isa_fun_owns_interrupt(fun, irq)) 157 return EINVAL; 158 159 return irc_clear_interrupt(irq); 137 160 } 138 161 … … 185 208 .get_resource_list = isa_fun_get_resources, 186 209 .enable_interrupt = isa_fun_enable_interrupt, 210 .disable_interrupt = isa_fun_disable_interrupt, 211 .clear_interrupt = isa_fun_clear_interrupt, 187 212 .dma_channel_setup = isa_fun_setup_dma, 188 213 .dma_channel_remain = isa_fun_remain_dma, -
uspace/drv/bus/pci/pciintel/pci.c
rce732e74 rd51838f 99 99 } 100 100 101 static int pciintel_fun_owns_interrupt(pci_fun_t *fun, int irq) 102 { 103 size_t i; 104 hw_resource_list_t *res = &fun->hw_resources; 105 106 for (i = 0; i < res->count; i++) { 107 if (res->resources[i].type == INTERRUPT && 108 res->resources[i].res.interrupt.irq == irq) { 109 return true; 110 } 111 } 112 113 return false; 114 } 115 101 116 static int pciintel_enable_interrupt(ddf_fun_t *fnode, int irq) 102 117 { 103 pci_fun_t *dev_data = pci_fun(fnode); 104 105 size_t i; 106 hw_resource_list_t *res = &dev_data->hw_resources; 107 bool found = false; 108 109 found = false; 110 for (i = 0; i < res->count; i++) { 111 if (res->resources[i].type == INTERRUPT) { 112 found = true; 113 break; 114 } 115 } 116 117 if (!found) 118 pci_fun_t *fun = pci_fun(fnode); 119 120 if (!pciintel_fun_owns_interrupt(fun, irq)) 118 121 return EINVAL; 119 122 120 123 return irc_enable_interrupt(irq); 124 } 125 126 static int pciintel_disable_interrupt(ddf_fun_t *fnode, int irq) 127 { 128 pci_fun_t *fun = pci_fun(fnode); 129 130 if (!pciintel_fun_owns_interrupt(fun, irq)) 131 return EINVAL; 132 133 return irc_disable_interrupt(irq); 134 } 135 136 static int pciintel_clear_interrupt(ddf_fun_t *fnode, int irq) 137 { 138 pci_fun_t *fun = pci_fun(fnode); 139 140 if (!pciintel_fun_owns_interrupt(fun, irq)) 141 return EINVAL; 142 143 return irc_clear_interrupt(irq); 121 144 } 122 145 … … 188 211 .get_resource_list = &pciintel_get_resources, 189 212 .enable_interrupt = &pciintel_enable_interrupt, 213 .disable_interrupt = &pciintel_disable_interrupt, 214 .clear_interrupt = &pciintel_clear_interrupt, 190 215 }; 191 216 -
uspace/drv/char/ns8250/ns8250.c
rce732e74 rd51838f 55 55 #include <ops/char_dev.h> 56 56 57 #include <irc.h>58 57 #include <device/hw_res.h> 59 58 #include <ipc/serial_ctl.h> … … 154 153 /** DDF function node */ 155 154 ddf_fun_t *fun; 155 /** Parent session */ 156 async_sess_t *parent_sess; 156 157 /** I/O registers **/ 157 158 ns8250_regs_t *regs; … … 382 383 static int ns8250_dev_initialize(ns8250_t *ns) 383 384 { 384 async_sess_t *parent_sess;385 385 int ret = EOK; 386 386 … … 390 390 memset(&hw_resources, 0, sizeof(hw_resource_list_t)); 391 391 392 /* Connect to the parent's driver. */393 parent_sess = ddf_dev_parent_sess_get(ns->dev);394 if (parent_sess == NULL) {395 ddf_msg(LVL_ERROR, "Failed to connect to parent driver of "396 "device %s.", ddf_dev_get_name(ns->dev));397 ret = ENOENT;398 goto failed;399 }400 401 392 /* Get hw resources. */ 402 ret = hw_res_get_resource_list( parent_sess, &hw_resources);393 ret = hw_res_get_resource_list(ns->parent_sess, &hw_resources); 403 394 if (ret != EOK) { 404 395 ddf_msg(LVL_ERROR, "Failed to get HW resources for device " … … 487 478 { 488 479 /* Enable interrupt using IRC service. */ 489 int rc = irc_enable_interrupt(ns->irq);480 int rc = hw_res_enable_interrupt(ns->parent_sess, ns->irq); 490 481 if (rc != EOK) 491 482 return EIO; … … 780 771 781 772 ns8250_read_from_device(ns); 782 irc_clear_interrupt(ns->irq);773 hw_res_clear_interrupt(ns->parent_sess, ns->irq); 783 774 } 784 775 … … 829 820 fibril_condvar_initialize(&ns->input_buffer_available); 830 821 ns->dev = dev; 822 823 ns->parent_sess = ddf_dev_parent_sess_get(ns->dev); 824 if (ns->parent_sess == NULL) { 825 ddf_msg(LVL_ERROR, "Failed to connect to parent driver of " 826 "device %s.", ddf_dev_get_name(ns->dev)); 827 rc = EIO; 828 goto fail; 829 } 831 830 832 831 rc = ns8250_dev_initialize(ns); -
uspace/drv/char/pl050/pl050.c
rce732e74 rd51838f 38 38 #include <ddf/interrupt.h> 39 39 #include <ddf/log.h> 40 #include <device/hw_res.h> 40 41 #include <device/hw_res_parsed.h> 41 42 #include <io/chardev_srv.h> 42 #include <irc.h>43 43 44 44 #include "pl050_hw.h" … … 221 221 } 222 222 223 rc = irc_enable_interrupt(res.irqs.irqs[0]);223 rc = hw_res_enable_interrupt(pl050->parent_sess, res.irqs.irqs[0]); 224 224 if (rc != EOK) { 225 225 ddf_msg(LVL_ERROR, "Failed enabling interrupt. (%d)", rc); -
uspace/drv/nic/e1k/e1k.c
rce732e74 rd51838f 40 40 #include <thread.h> 41 41 #include <byteorder.h> 42 #include <irc.h>43 42 #include <as.h> 44 43 #include <ddi.h> 45 44 #include <ddf/log.h> 46 45 #include <ddf/interrupt.h> 46 #include <device/hw_res.h> 47 47 #include <device/hw_res_parsed.h> 48 48 #include <pci_dev_iface.h> … … 116 116 /** E1000 device data */ 117 117 typedef struct { 118 /** DDF device */ 119 ddf_dev_t *dev; 120 /** Parent session */ 121 async_sess_t *parent_sess; 118 122 /** Device configuration */ 119 123 e1000_info_t info; … … 1757 1761 e1000_enable_interrupts(e1000); 1758 1762 1759 int rc = irc_enable_interrupt(e1000->irq);1763 int rc = hw_res_enable_interrupt(e1000->parent_sess, e1000->irq); 1760 1764 if (rc != EOK) { 1761 1765 e1000_disable_interrupts(e1000); … … 1802 1806 e1000_disable_rx(e1000); 1803 1807 1804 irc_disable_interrupt(e1000->irq);1808 hw_res_disable_interrupt(e1000->parent_sess, e1000->irq); 1805 1809 e1000_disable_interrupts(e1000); 1806 1810 … … 1884 1888 1885 1889 memset(e1000, 0, sizeof(e1000_t)); 1890 e1000->dev = dev; 1886 1891 1887 1892 nic_set_specific(nic, e1000); … … 1998 2003 ddf_msg(LVL_ERROR, "Unable to allocate device softstate"); 1999 2004 return ENOMEM; 2005 } 2006 2007 e1000->parent_sess = ddf_dev_parent_sess_get(dev); 2008 if (e1000->parent_sess == NULL) { 2009 ddf_msg(LVL_ERROR, "Failed connecting parent device."); 2010 return EIO; 2000 2011 } 2001 2012 … … 2119 2130 { 2120 2131 ddf_fun_t *fun; 2121 assert(dev);2122 2132 2123 2133 /* Initialize device structure for E1000 */ -
uspace/drv/nic/ne2k/dp8390.h
rce732e74 rd51838f 50 50 #define __NET_NETIF_DP8390_H__ 51 51 52 #include <async.h> 53 #include <ddf/driver.h> 52 54 #include <fibril_synch.h> 53 55 #include <nic.h> … … 223 225 224 226 typedef struct { 227 /** DDF device */ 228 ddf_dev_t *dev; 229 /** Parent session */ 230 async_sess_t *parent_sess; 225 231 /* Device configuration */ 226 232 void *base_port; /**< Port assigned from ISA configuration **/ -
uspace/drv/nic/ne2k/ne2k.c
rce732e74 rd51838f 40 40 #include <stdio.h> 41 41 #include <errno.h> 42 #include < irc.h>42 #include <device/hw_res.h> 43 43 #include <stdlib.h> 44 44 #include <str_error.h> … … 256 256 return rc; 257 257 258 rc = irc_enable_interrupt(ne2k->irq);258 rc = hw_res_enable_interrupt(ne2k->parent_sess, ne2k->irq); 259 259 if (rc != EOK) { 260 260 ne2k_down(ne2k); … … 269 269 ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data); 270 270 271 (void) irc_disable_interrupt(ne2k->irq);271 (void) hw_res_disable_interrupt(ne2k->parent_sess, ne2k->irq); 272 272 ne2k->receive_configuration = RCR_AB | RCR_AM; 273 273 ne2k_down(ne2k); … … 384 384 } 385 385 386 ne2k->dev = dev; 387 ne2k->parent_sess = ddf_dev_parent_sess_get(dev); 388 if (ne2k->parent_sess == NULL) { 389 ne2k_dev_cleanup(dev); 390 return ENOMEM; 391 } 392 386 393 int rc = ne2k_dev_init(nic_data); 387 394 if (rc != EOK) { -
uspace/drv/nic/rtl8139/driver.c
rce732e74 rd51838f 36 36 #include <ddf/log.h> 37 37 #include <ddf/interrupt.h> 38 #include <device/hw_res.h> 38 39 #include <io/log.h> 39 40 #include <nic.h> 40 41 #include <pci_dev_iface.h> 41 #include <irc.h>42 42 #include <stdio.h> 43 43 #include <str.h> … … 920 920 rtl8139_hw_int_set(rtl8139); 921 921 922 int rc = irc_enable_interrupt(rtl8139->irq);922 int rc = hw_res_enable_interrupt(rtl8139->parent_sess, rtl8139->irq); 923 923 if (rc != EOK) { 924 924 rtl8139_on_stopped(nic_data); … … 976 976 return NULL; 977 977 978 rtl8139_t *rtl8139 = malloc(sizeof(rtl8139_t));978 rtl8139_t *rtl8139 = calloc(1, sizeof(rtl8139_t)); 979 979 if (!rtl8139) { 980 980 nic_unbind_and_destroy(dev); … … 982 982 } 983 983 984 memset(rtl8139, 0, sizeof(rtl8139_t));984 rtl8139->dev = dev; 985 985 986 986 rtl8139->nic_data = nic_data; … … 1166 1166 1167 1167 ddf_msg(LVL_DEBUG, "rtl8139: dev_data created"); 1168 rtl8139->parent_sess = ddf_dev_parent_sess_get(dev); 1169 if (rtl8139->parent_sess == NULL) { 1170 ddf_msg(LVL_ERROR, "Error connecting parent device."); 1171 return EIO; 1172 } 1168 1173 1169 1174 /* Obtain and fill hardware resources info and connect to parent */ … … 1258 1263 ddf_fun_t *fun; 1259 1264 1260 assert(dev);1261 1265 ddf_msg(LVL_NOTE, "RTL8139_dev_add %s (handle = %zu)", 1262 1266 ddf_dev_get_name(dev), ddf_dev_get_handle(dev)); -
uspace/drv/nic/rtl8139/driver.h
rce732e74 rd51838f 87 87 /** RTL8139 device data */ 88 88 typedef struct rtl8139_data { 89 /** DDF device */ 90 ddf_dev_t *dev; 91 /** Parent session */ 92 async_sess_t *parent_sess; 89 93 /** I/O address of the device */ 90 94 void *io_addr; -
uspace/drv/nic/rtl8169/driver.c
rce732e74 rd51838f 31 31 #include <align.h> 32 32 #include <byteorder.h> 33 #include <irc.h>34 33 #include <libarch/barrier.h> 35 34 … … 38 37 #include <ddf/log.h> 39 38 #include <ddf/interrupt.h> 39 #include <device/hw_res.h> 40 #include <device/hw_res_parsed.h> 40 41 #include <io/log.h> 41 42 #include <nic.h> 42 43 #include <pci_dev_iface.h> 43 44 44 #include <ipc/irc.h>45 45 #include <sysinfo.h> 46 46 #include <ipc/ns.h> … … 396 396 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 397 397 398 rtl8169->dev = dev; 399 rtl8169->parent_sess = ddf_dev_parent_sess_get(dev); 400 if (rtl8169->parent_sess == NULL) 401 return EIO; 402 398 403 /* Get PCI VID & PID */ 399 rc = pci_config_space_read_16( ddf_dev_parent_sess_get(dev),400 PCI_VENDOR_ID,&rtl8169->pci_vid);404 rc = pci_config_space_read_16(rtl8169->parent_sess, PCI_VENDOR_ID, 405 &rtl8169->pci_vid); 401 406 if (rc != EOK) 402 407 return rc; 403 408 404 rc = pci_config_space_read_16( ddf_dev_parent_sess_get(dev),405 PCI_DEVICE_ID,&rtl8169->pci_pid);409 rc = pci_config_space_read_16(rtl8169->parent_sess, PCI_DEVICE_ID, 410 &rtl8169->pci_pid); 406 411 if (rc != EOK) 407 412 return rc; … … 745 750 746 751 pio_write_16(rtl8169->regs + IMR, 0xffff); 747 irc_enable_interrupt(rtl8169->irq); 752 /* XXX Check return value */ 753 hw_res_enable_interrupt(rtl8169->parent_sess, rtl8169->irq); 748 754 749 755 return EOK; -
uspace/drv/nic/rtl8169/driver.h
rce732e74 rd51838f 49 49 /** RTL8139 device data */ 50 50 typedef struct rtl8169_data { 51 /** DDF device */ 52 ddf_dev_t *dev; 53 /** Parent session */ 54 async_sess_t *parent_sess; 51 55 /** I/O address of the device */ 52 56 void *regs_phys; -
uspace/drv/platform/icp/icp.c
rce732e74 rd51838f 39 39 #include <stdio.h> 40 40 #include <errno.h> 41 #include <irc.h> 41 42 #include <stdbool.h> 42 43 #include <stdlib.h> … … 142 143 } 143 144 144 static int icp_enable_interrupt(ddf_fun_t *fun, int irq) 145 { 146 /* TODO */ 145 static bool icp_fun_owns_interrupt(icp_fun_t *fun, int irq) 146 { 147 const hw_resource_list_t *res = &fun->hw_resources; 148 149 /* Check that specified irq really belongs to the function */ 150 for (size_t i = 0; i < res->count; ++i) { 151 if (res->resources[i].type == INTERRUPT && 152 res->resources[i].res.interrupt.irq == irq) { 153 return true; 154 } 155 } 156 147 157 return false; 158 } 159 160 static int icp_fun_enable_interrupt(ddf_fun_t *fnode, int irq) 161 { 162 icp_fun_t *fun = icp_fun(fnode); 163 164 if (!icp_fun_owns_interrupt(fun, irq)) 165 return EINVAL; 166 167 return irc_enable_interrupt(irq); 148 168 } 149 169 … … 155 175 static hw_res_ops_t icp_hw_res_ops = { 156 176 .get_resource_list = &icp_get_resources, 157 .enable_interrupt = &icp_ enable_interrupt,177 .enable_interrupt = &icp_fun_enable_interrupt, 158 178 }; 159 179 -
uspace/lib/c/generic/device/hw_res.c
rce732e74 rd51838f 86 86 } 87 87 88 int hw_res_disable_interrupt(async_sess_t *sess, int irq) 89 { 90 async_exch_t *exch = async_exchange_begin(sess); 91 92 int rc = async_req_2_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE), 93 HW_RES_DISABLE_INTERRUPT, irq); 94 async_exchange_end(exch); 95 96 return rc; 97 } 98 99 int hw_res_clear_interrupt(async_sess_t *sess, int irq) 100 { 101 async_exch_t *exch = async_exchange_begin(sess); 102 103 int rc = async_req_2_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE), 104 HW_RES_CLEAR_INTERRUPT, irq); 105 async_exchange_end(exch); 106 107 return rc; 108 } 109 88 110 /** Setup DMA channel to specified place and mode. 89 111 * -
uspace/lib/c/include/device/hw_res.h
rce732e74 rd51838f 52 52 HW_RES_GET_RESOURCE_LIST = 0, 53 53 HW_RES_ENABLE_INTERRUPT, 54 HW_RES_DISABLE_INTERRUPT, 55 HW_RES_CLEAR_INTERRUPT, 54 56 HW_RES_DMA_CHANNEL_SETUP, 55 57 HW_RES_DMA_CHANNEL_REMAIN, … … 116 118 extern int hw_res_get_resource_list(async_sess_t *, hw_resource_list_t *); 117 119 extern int hw_res_enable_interrupt(async_sess_t *, int); 120 extern int hw_res_disable_interrupt(async_sess_t *, int); 121 extern int hw_res_clear_interrupt(async_sess_t *, int); 118 122 119 123 extern int hw_res_dma_channel_setup(async_sess_t *, unsigned int, uint32_t, -
uspace/lib/drv/generic/remote_hw_res.c
rce732e74 rd51838f 45 45 static void remote_hw_res_enable_interrupt(ddf_fun_t *, void *, ipc_callid_t, 46 46 ipc_call_t *); 47 static void remote_hw_res_disable_interrupt(ddf_fun_t *, void *, ipc_callid_t, 48 ipc_call_t *); 49 static void remote_hw_res_clear_interrupt(ddf_fun_t *, void *, ipc_callid_t, 50 ipc_call_t *); 47 51 static void remote_hw_res_dma_channel_setup(ddf_fun_t *, void *, ipc_callid_t, 48 52 ipc_call_t *); … … 53 57 [HW_RES_GET_RESOURCE_LIST] = &remote_hw_res_get_resource_list, 54 58 [HW_RES_ENABLE_INTERRUPT] = &remote_hw_res_enable_interrupt, 59 [HW_RES_DISABLE_INTERRUPT] = &remote_hw_res_disable_interrupt, 60 [HW_RES_CLEAR_INTERRUPT] = &remote_hw_res_clear_interrupt, 55 61 [HW_RES_DMA_CHANNEL_SETUP] = &remote_hw_res_dma_channel_setup, 56 62 [HW_RES_DMA_CHANNEL_REMAIN] = &remote_hw_res_dma_channel_remain, … … 68 74 69 75 if (hw_res_ops->enable_interrupt == NULL) { 76 async_answer_0(callid, ENOTSUP); 77 return; 78 } 79 80 const int irq = DEV_IPC_GET_ARG1(*call); 81 const int ret = hw_res_ops->enable_interrupt(fun, irq); 82 async_answer_0(callid, ret); 83 } 84 85 static void remote_hw_res_disable_interrupt(ddf_fun_t *fun, void *ops, 86 ipc_callid_t callid, ipc_call_t *call) 87 { 88 hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops; 89 90 if (hw_res_ops->disable_interrupt == NULL) { 91 async_answer_0(callid, ENOTSUP); 92 return; 93 } 94 95 const int irq = DEV_IPC_GET_ARG1(*call); 96 const int ret = hw_res_ops->disable_interrupt(fun, irq); 97 async_answer_0(callid, ret); 98 } 99 100 static void remote_hw_res_clear_interrupt(ddf_fun_t *fun, void *ops, 101 ipc_callid_t callid, ipc_call_t *call) 102 { 103 hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops; 104 105 if (hw_res_ops->clear_interrupt == NULL) { 70 106 async_answer_0(callid, ENOTSUP); 71 107 return; -
uspace/lib/drv/include/ops/hw_res.h
rce732e74 rd51838f 45 45 hw_resource_list_t *(*get_resource_list)(ddf_fun_t *); 46 46 int (*enable_interrupt)(ddf_fun_t *, int); 47 int (*disable_interrupt)(ddf_fun_t *, int); 48 int (*clear_interrupt)(ddf_fun_t *, int); 47 49 int (*dma_channel_setup)(ddf_fun_t *, unsigned, uint32_t, uint32_t, uint8_t); 48 50 int (*dma_channel_remain)(ddf_fun_t *, unsigned, size_t *);
Note:
See TracChangeset
for help on using the changeset viewer.