Changeset 8c877b2 in mainline for uspace/drv/pciintel/pci.c
- Timestamp:
- 2011-03-04T13:05:35Z (14 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/pciintel/pci.c
rdff940f8 r8c877b2 59 59 #include <ddi.h> 60 60 #include <libarch/ddi.h> 61 #include <pci_dev_iface.h> 61 62 62 63 #include "pci.h" … … 93 94 sysarg_t apic; 94 95 sysarg_t i8259; 96 95 97 int irc_phone = -1; 96 98 int irc_service = 0; … … 102 104 } 103 105 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) 108 107 return false; 109 } 108 109 irc_phone = service_connect_blocking(irc_service, 0, 0); 110 if (irc_phone < 0) 111 return false; 110 112 111 113 size_t i; … … 113 115 if (dev_data->hw_resources.resources[i].type == INTERRUPT) { 114 116 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 } 116 122 } 117 123 } … … 120 126 return true; 121 127 } 128 129 static 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 122 137 123 138 static hw_res_ops_t pciintel_hw_res_ops = { … … 126 141 }; 127 142 128 static ddf_dev_ops_t pci_fun_ops; 143 static 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 152 static 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 }; 129 156 130 157 static int pci_add_device(ddf_dev_t *); … … 320 347 /* Get the value of the BAR. */ 321 348 val = pci_conf_read_32(fun, addr); 349 350 #define IO_MASK (~0x3) 351 #define MEM_MASK (~0xf) 322 352 323 353 io = (bool) (val & 1); 324 354 if (io) { 325 355 addrw64 = false; 356 mask = IO_MASK; 326 357 } else { 358 mask = MEM_MASK; 327 359 switch ((val >> 1) & 3) { 328 360 case 0: … … 340 372 /* Get the address mask. */ 341 373 pci_conf_write_32(fun, addr, 0xffffffff); 342 mask = pci_conf_read_32(fun, addr);374 mask &= pci_conf_read_32(fun, addr); 343 375 344 376 /* Restore the original value. */ … … 588 620 { 589 621 pci_fun_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops; 622 pci_fun_ops.interfaces[PCI_DEV_IFACE] = &pci_dev_ops; 590 623 } 591 624 … … 659 692 size_t pci_bar_mask_to_size(uint32_t mask) 660 693 { 661 return ((mask & 0xfffffff0) ^ 0xffffffff) + 1; 694 size_t size = mask & ~(mask - 1); 695 return size; 662 696 } 663 697
Note:
See TracChangeset
for help on using the changeset viewer.