Changeset 72af8da in mainline for uspace/drv/pciintel/pci.c


Ignore:
Timestamp:
2011-03-16T18:50:17Z (14 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
42a3a57
Parents:
3e7b7cd (diff), fcf07e6 (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 from usb/development

File:
1 edited

Legend:

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

    r3e7b7cd r72af8da  
    9292        pci_fun_t *dev_data = (pci_fun_t *) fnode->driver_data;
    9393
    94   sysarg_t apic;
    95   sysarg_t i8259;
     94        sysarg_t apic;
     95        sysarg_t i8259;
    9696
    9797        int irc_phone = -1;
    98         int irc_service = 0;
    99 
    100   if ((sysinfo_get_value("apic", &apic) == EOK) && (apic)) {
    101     irc_service = SERVICE_APIC;
     98        int irc_service = -1;
     99
     100        if ((sysinfo_get_value("apic", &apic) == EOK) && (apic)) {
     101                irc_service = SERVICE_APIC;
    102102        } else if ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259)) {
    103     irc_service = SERVICE_I8259;
    104         }
    105 
    106   if (irc_service == 0)
     103                irc_service = SERVICE_I8259;
     104        }
     105
     106        if (irc_service == -1) {
    107107                return false;
     108        }
    108109
    109110        irc_phone = service_connect_blocking(irc_service, 0, 0);
    110         if (irc_phone < 0)
     111        if (irc_phone < 0) {
    111112                return false;
     113        }
    112114
    113115        size_t i;
    114   for (i = 0; i < dev_data->hw_resources.count; i++) {
     116        for (i = 0; i < dev_data->hw_resources.count; i++) {
    115117                if (dev_data->hw_resources.resources[i].type == INTERRUPT) {
    116118                        int irq = dev_data->hw_resources.resources[i].res.interrupt.irq;
     
    127129}
    128130
    129 static int pci_config_space_write_16(ddf_fun_t *fun, uint32_t address, uint16_t data)
     131static int pci_config_space_write_32(
     132    ddf_fun_t *fun, uint32_t address, 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
     140static int pci_config_space_write_16(
     141    ddf_fun_t *fun, uint32_t address, uint16_t data)
    130142{
    131143        if (address > 254)
     
    135147}
    136148
     149static 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
     158static 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
     167static 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
     176static 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;
     183}
    137184
    138185static hw_res_ops_t pciintel_hw_res_ops = {
     
    142189
    143190static 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,
     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,
    148195        .config_space_write_16 = &pci_config_space_write_16,
    149         .config_space_write_32 = NULL
     196        .config_space_write_32 = &pci_config_space_write_32
    150197};
    151198
Note: See TracChangeset for help on using the changeset viewer.