Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset cccd60c3 in mainline


Ignore:
Timestamp:
2017-10-10T06:51:02Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
c46bfbc
Parents:
2bdf92a5
Message:

hw_res_enable_interrupt should allow enabling individual interrupts.

Location:
uspace
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/audio/sb16/main.c

    r2bdf92a5 rcccd60c3  
    5050static int sb_get_res(ddf_dev_t *device, addr_range_t **pp_sb_regs,
    5151    addr_range_t **pp_mpu_regs, int *irq, int *dma8, int *dma16);
    52 static int sb_enable_interrupts(ddf_dev_t *device);
     52static int sb_enable_interrupt(ddf_dev_t *device, int irq);
    5353
    5454static driver_ops_t sb_driver_ops = {
     
    134134        handler_regd = true;
    135135
    136         rc = sb_enable_interrupts(device);
     136        rc = sb_enable_interrupt(device, irq);
    137137        if (rc != EOK) {
    138138                ddf_log_error("Failed to enable interrupts: %s.",
     
    242242}
    243243
    244 int sb_enable_interrupts(ddf_dev_t *device)
     244static int sb_enable_interrupt(ddf_dev_t *device, int irq)
    245245{
    246246        async_sess_t *parent_sess = ddf_dev_parent_sess_get(device);
     
    248248                return ENOMEM;
    249249
    250         bool enabled = hw_res_enable_interrupt(parent_sess);
    251 
    252         return enabled ? EOK : EIO;
     250        return hw_res_enable_interrupt(parent_sess, irq);
    253251}
    254252
  • uspace/drv/bus/isa/isa.c

    r2bdf92a5 rcccd60c3  
    115115}
    116116
    117 static bool isa_fun_enable_interrupt(ddf_fun_t *fnode)
    118 {
    119         /* This is an old ugly way, copied from pci driver */
    120         assert(fnode);
     117static int isa_fun_enable_interrupt(ddf_fun_t *fnode, int irq)
     118{
    121119        isa_fun_t *fun = isa_fun(fnode);
    122         assert(fun);
    123 
    124120        const hw_resource_list_t *res = &fun->hw_resources;
    125         assert(res);
     121        bool found;
     122
     123        /* Check that specified irq really belongs to the function */
     124        found = false;
    126125        for (size_t i = 0; i < res->count; ++i) {
    127                 if (res->resources[i].type == INTERRUPT) {
    128                         int rc = irc_enable_interrupt(
    129                             res->resources[i].res.interrupt.irq);
    130 
    131                         if (rc != EOK)
    132                                 return false;
    133                 }
    134         }
    135 
    136         return true;
     126                if (res->resources[i].type == INTERRUPT &&
     127                    res->resources[i].res.interrupt.irq == irq) {
     128                        found = true;
     129                        break;
     130                }
     131        }
     132
     133        if (!found)
     134                return EINVAL;
     135
     136        return irc_enable_interrupt(irq);
    137137}
    138138
  • uspace/drv/bus/pci/pciintel/pci.c

    r2bdf92a5 rcccd60c3  
    9999}
    100100
    101 static bool pciintel_enable_interrupt(ddf_fun_t *fnode)
    102 {
    103         /* This is an old ugly way */
    104         assert(fnode);
     101static int pciintel_enable_interrupt(ddf_fun_t *fnode, int irq)
     102{
    105103        pci_fun_t *dev_data = pci_fun(fnode);
    106104       
    107         size_t i = 0;
     105        size_t i;
    108106        hw_resource_list_t *res = &dev_data->hw_resources;
    109         for (; i < res->count; i++) {
     107        bool found = false;
     108       
     109        found = false;
     110        for (i = 0; i < res->count; i++) {
    110111                if (res->resources[i].type == INTERRUPT) {
    111                         int rc = irc_enable_interrupt(
    112                             res->resources[i].res.interrupt.irq);
    113                        
    114                         if (rc != EOK)
    115                                 return false;
     112                        found = true;
     113                        break;
    116114                }
    117115        }
    118116       
    119         return true;
     117        if (!found)
     118                return EINVAL;
     119       
     120        return irc_enable_interrupt(irq);
    120121}
    121122
  • uspace/drv/char/i8042/i8042.c

    r2bdf92a5 rcccd60c3  
    291291        assert(parent_sess != NULL);
    292292       
    293         const bool enabled = hw_res_enable_interrupt(parent_sess);
    294         if (!enabled) {
    295                 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed to enable interrupts: %s.",
     293        rc = hw_res_enable_interrupt(parent_sess, irq_kbd);
     294        if (rc != EOK) {
     295                log_msg(LOG_DEFAULT, LVL_ERROR, "Failed to enable keyboard interrupt: %s.",
     296                    ddf_dev_get_name(ddf_dev));
     297                rc = EIO;
     298                goto error;
     299        }
     300
     301        rc = hw_res_enable_interrupt(parent_sess, irq_mouse);
     302        if (rc != EOK) {
     303                log_msg(LOG_DEFAULT, LVL_ERROR, "Failed to enable mouse interrupt: %s.",
    296304                    ddf_dev_get_name(ddf_dev));
    297305                rc = EIO;
  • uspace/drv/platform/amdm37x/main.c

    r2bdf92a5 rcccd60c3  
    150150
    151151static hw_resource_list_t *amdm37x_get_resources(ddf_fun_t *fnode);
    152 static bool amdm37x_enable_interrupt(ddf_fun_t *fun);
     152static int amdm37x_enable_interrupt(ddf_fun_t *fun, int);
    153153
    154154static hw_res_ops_t fun_hw_res_ops = {
     
    265265}
    266266
    267 static bool amdm37x_enable_interrupt(ddf_fun_t *fun)
     267static int amdm37x_enable_interrupt(ddf_fun_t *fun, int irq)
    268268{
    269269        //TODO: Implement
  • uspace/drv/platform/icp/icp.c

    r2bdf92a5 rcccd60c3  
    142142}
    143143
    144 static bool icp_enable_interrupt(ddf_fun_t *fun)
     144static int icp_enable_interrupt(ddf_fun_t *fun, int irq)
    145145{
    146146        /* TODO */
  • uspace/drv/platform/mac/mac.c

    r2bdf92a5 rcccd60c3  
    227227}
    228228
    229 static bool mac_enable_interrupt(ddf_fun_t *fun)
     229static int mac_enable_interrupt(ddf_fun_t *fun, int irq)
    230230{
    231231        /* TODO */
  • uspace/drv/platform/malta/malta.c

    r2bdf92a5 rcccd60c3  
    143143}
    144144
    145 static bool malta_enable_interrupt(ddf_fun_t *fun)
     145static int malta_enable_interrupt(ddf_fun_t *fun, int irq)
    146146{
    147147        /* TODO */
  • uspace/drv/platform/msim/msim.c

    r2bdf92a5 rcccd60c3  
    121121}
    122122
    123 static bool msim_enable_interrupt(ddf_fun_t *fun)
     123static int msim_enable_interrupt(ddf_fun_t *fun, int irq)
    124124{
    125125        /* Nothing to do. */
  • uspace/drv/platform/pc/pc.c

    r2bdf92a5 rcccd60c3  
    125125}
    126126
    127 static bool pc_enable_interrupt(ddf_fun_t *fun)
     127static int pc_enable_interrupt(ddf_fun_t *fun, int irq)
    128128{
    129129        /* TODO */
  • uspace/drv/platform/sun4u/sun4u.c

    r2bdf92a5 rcccd60c3  
    130130}
    131131
    132 static bool sun4u_enable_interrupt(ddf_fun_t *fun)
     132static int sun4u_enable_interrupt(ddf_fun_t *fun, int irq)
    133133{
    134134        /* TODO */
  • uspace/lib/c/generic/device/hw_res.c

    r2bdf92a5 rcccd60c3  
    7575}
    7676
    77 bool hw_res_enable_interrupt(async_sess_t *sess)
     77int hw_res_enable_interrupt(async_sess_t *sess, int irq)
    7878{
    7979        async_exch_t *exch = async_exchange_begin(sess);
    8080       
    81         int rc = async_req_1_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
    82             HW_RES_ENABLE_INTERRUPT);
     81        int rc = async_req_2_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE),
     82            HW_RES_ENABLE_INTERRUPT, irq);
    8383        async_exchange_end(exch);
    8484       
    85         return (rc == EOK);
     85        return rc;
    8686}
    8787
  • uspace/lib/c/include/device/hw_res.h

    r2bdf92a5 rcccd60c3  
    115115
    116116extern int hw_res_get_resource_list(async_sess_t *, hw_resource_list_t *);
    117 extern bool hw_res_enable_interrupt(async_sess_t *);
     117extern int hw_res_enable_interrupt(async_sess_t *, int);
    118118
    119119extern int hw_res_dma_channel_setup(async_sess_t *, unsigned int, uint32_t,
  • uspace/lib/drv/generic/remote_hw_res.c

    r2bdf92a5 rcccd60c3  
    6767        hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
    6868       
    69         if (hw_res_ops->enable_interrupt == NULL)
     69        if (hw_res_ops->enable_interrupt == NULL) {
    7070                async_answer_0(callid, ENOTSUP);
    71         else if (hw_res_ops->enable_interrupt(fun))
    72                 async_answer_0(callid, EOK);
    73         else
    74                 async_answer_0(callid, EREFUSED);
     71                return;
     72        }
     73       
     74        const int irq = DEV_IPC_GET_ARG1(*call);
     75        const int ret = hw_res_ops->enable_interrupt(fun, irq);
     76        async_answer_0(callid, ret);
    7577}
    7678
  • uspace/lib/drv/include/ops/hw_res.h

    r2bdf92a5 rcccd60c3  
    4444typedef struct {
    4545        hw_resource_list_t *(*get_resource_list)(ddf_fun_t *);
    46         bool (*enable_interrupt)(ddf_fun_t *);
     46        int (*enable_interrupt)(ddf_fun_t *, int);
    4747        int (*dma_channel_setup)(ddf_fun_t *, unsigned, uint32_t, uint32_t, uint8_t);
    4848        int (*dma_channel_remain)(ddf_fun_t *, unsigned, size_t *);
  • uspace/lib/usbhost/include/usb/host/ddf_helpers.h

    r2bdf92a5 rcccd60c3  
    7070hcd_t *dev_to_hcd(ddf_dev_t *dev);
    7171
    72 int hcd_ddf_enable_interrupts(ddf_dev_t *device);
     72int hcd_ddf_enable_interrupt(ddf_dev_t *device, int);
    7373int hcd_ddf_get_registers(ddf_dev_t *device, hw_res_list_parsed_t *hw_res);
    7474int hcd_ddf_setup_interrupts(ddf_dev_t *device,
  • uspace/lib/usbhost/src/ddf_helpers.c

    r2bdf92a5 rcccd60c3  
    692692
    693693//TODO: Cache parent session in HCD
    694 /** Call the parent driver with a request to enable interrupts
     694/** Call the parent driver with a request to enable interrupt
    695695 *
    696696 * @param[in] device Device asking for interrupts
     697 * @param[in] inum Interrupt number
    697698 * @return Error code.
    698699 */
    699 int hcd_ddf_enable_interrupts(ddf_dev_t *device)
     700int hcd_ddf_enable_interrupt(ddf_dev_t *device, int inum)
    700701{
    701702        async_sess_t *parent_sess = ddf_dev_parent_sess_get(device);
     
    703704                return EIO;
    704705
    705         const bool enabled = hw_res_enable_interrupt(parent_sess);
    706 
    707         return enabled ? EOK : EIO;
     706        return hw_res_enable_interrupt(parent_sess, inum);
    708707}
    709708
     
    776775
    777776        /* Enable interrupts */
    778         int ret = hcd_ddf_enable_interrupts(device);
     777        int ret = hcd_ddf_enable_interrupt(device, irq);
    779778        if (ret != EOK) {
    780779                usb_log_error("Failed to register interrupt handler: %s.\n",
Note: See TracChangeset for help on using the changeset viewer.