Changeset 8c877b2 in mainline for uspace/drv/pciintel/pci.c


Ignore:
Timestamp:
2011-03-04T13:05:35Z (14 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d49728c
Parents:
dff940f8 (diff), 9a422574 (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.
Message:

merge with \usb\development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/pciintel/pci.c

    rdff940f8 r8c877b2  
    5959#include <ddi.h>
    6060#include <libarch/ddi.h>
     61#include <pci_dev_iface.h>
    6162
    6263#include "pci.h"
     
    9394  sysarg_t apic;
    9495  sysarg_t i8259;
     96
    9597        int irc_phone = -1;
    9698        int irc_service = 0;
     
    102104        }
    103105
    104   if (irc_service) {
    105     while (irc_phone < 0)
    106       irc_phone = service_connect_blocking(irc_service, 0, 0);
    107   } else {
     106  if (irc_service == 0)
    108107                return false;
    109         }
     108
     109        irc_phone = service_connect_blocking(irc_service, 0, 0);
     110        if (irc_phone < 0)
     111                return false;
    110112
    111113        size_t i;
     
    113115                if (dev_data->hw_resources.resources[i].type == INTERRUPT) {
    114116                        int irq = dev_data->hw_resources.resources[i].res.interrupt.irq;
    115                         async_msg_1(irc_phone, IRC_ENABLE_INTERRUPT, irq);
     117                        int rc = async_req_1_0(irc_phone, IRC_ENABLE_INTERRUPT, irq);
     118                        if (rc != EOK) {
     119                                async_hangup(irc_phone);
     120                                return false;
     121                        }
    116122                }
    117123        }
     
    120126        return true;
    121127}
     128
     129static int pci_config_space_write_16(ddf_fun_t *fun, uint32_t address, uint16_t data)
     130{
     131        if (address > 254)
     132                return EINVAL;
     133        pci_conf_write_16(PCI_FUN(fun), address, data);
     134        return EOK;
     135}
     136
    122137
    123138static hw_res_ops_t pciintel_hw_res_ops = {
     
    126141};
    127142
    128 static ddf_dev_ops_t pci_fun_ops;
     143static pci_dev_iface_t pci_dev_ops = {
     144        .config_space_read_8 = NULL,
     145        .config_space_read_16 = NULL,
     146        .config_space_read_32 = NULL,
     147        .config_space_write_8 = NULL,
     148        .config_space_write_16 = &pci_config_space_write_16,
     149        .config_space_write_32 = NULL
     150};
     151
     152static ddf_dev_ops_t pci_fun_ops = {
     153        .interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops,
     154        .interfaces[PCI_DEV_IFACE] = &pci_dev_ops
     155};
    129156
    130157static int pci_add_device(ddf_dev_t *);
     
    320347        /* Get the value of the BAR. */
    321348        val = pci_conf_read_32(fun, addr);
     349
     350#define IO_MASK  (~0x3)
     351#define MEM_MASK (~0xf)
    322352       
    323353        io = (bool) (val & 1);
    324354        if (io) {
    325355                addrw64 = false;
     356                mask = IO_MASK;
    326357        } else {
     358                mask = MEM_MASK;
    327359                switch ((val >> 1) & 3) {
    328360                case 0:
     
    340372        /* Get the address mask. */
    341373        pci_conf_write_32(fun, addr, 0xffffffff);
    342         mask = pci_conf_read_32(fun, addr);
     374        mask &= pci_conf_read_32(fun, addr);
    343375       
    344376        /* Restore the original value. */
     
    588620{
    589621        pci_fun_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops;
     622        pci_fun_ops.interfaces[PCI_DEV_IFACE] = &pci_dev_ops;
    590623}
    591624
     
    659692size_t pci_bar_mask_to_size(uint32_t mask)
    660693{
    661         return ((mask & 0xfffffff0) ^ 0xffffffff) + 1;
     694        size_t size = mask & ~(mask - 1);
     695        return size;
    662696}
    663697
Note: See TracChangeset for help on using the changeset viewer.