Changeset 92d5279 in mainline
- Timestamp:
- 2016-10-26T20:27:12Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6c34be69
- Parents:
- 9191607
- Location:
- uspace/drv/bus/pci/pciintel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/pci/pciintel/pci.c
r9191607 r92d5279 63 63 #define NAME "pciintel" 64 64 65 #define CONF_ADDR_ENABLE (1 << 31) 65 66 #define CONF_ADDR(bus, dev, fn, reg) \ 66 (( 1 << 31) | (bus << 16) | (dev << 11) | (fn << 8) | (reg & ~3))67 ((bus << 16) | (dev << 11) | (fn << 8) | (reg & ~3)) 67 68 68 69 /** Obtain PCI function soft-state from DDF function node */ … … 232 233 fibril_mutex_lock(&bus->conf_mutex); 233 234 234 pio_write_32(bus->conf_addr_reg, host2uint32_t_le(conf_addr)); 235 236 /* 237 * Always read full 32-bits from the PCI conf_data_port register and 238 * get the desired portion of it afterwards. Some architectures do not 239 * support shorter PIO reads offset from this register. 240 */ 241 val = uint32_t_le2host(pio_read_32(bus->conf_data_reg)); 235 if (bus->conf_addr_reg) { 236 pio_write_32(bus->conf_addr_reg, 237 host2uint32_t_le(CONF_ADDR_ENABLE | conf_addr)); 238 /* 239 * Always read full 32-bits from the PCI conf_data_port 240 * register and get the desired portion of it afterwards. Some 241 * architectures do not support shorter PIO reads offset from 242 * this register. 243 */ 244 val = uint32_t_le2host(pio_read_32(bus->conf_data_reg)); 245 } else { 246 val = uint32_t_le2host(pio_read_32( 247 &bus->conf_space[conf_addr / sizeof(ioport32_t)])); 248 } 242 249 243 250 switch (len) { … … 260 267 const uint32_t conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg); 261 268 pci_bus_t *bus = pci_bus_from_fun(fun); 262 uint32_t val = 0; // Prevent -Werror=maybe-uninitialized269 uint32_t val; 263 270 264 271 fibril_mutex_lock(&bus->conf_mutex); … … 275 282 * missing bits first. 276 283 */ 277 pio_write_32(bus->conf_addr_reg, host2uint32_t_le(conf_addr)); 278 val = uint32_t_le2host(pio_read_32(bus->conf_data_reg)); 284 if (bus->conf_addr_reg) { 285 pio_write_32(bus->conf_addr_reg, 286 host2uint32_t_le(CONF_ADDR_ENABLE | conf_addr)); 287 val = uint32_t_le2host(pio_read_32(bus->conf_data_reg)); 288 } else { 289 val = uint32_t_le2host(pio_read_32( 290 &bus->conf_space[conf_addr / sizeof(ioport32_t)])); 291 } 279 292 } 280 293 … … 293 306 } 294 307 295 pio_write_32(bus->conf_addr_reg, host2uint32_t_le(conf_addr)); 296 pio_write_32(bus->conf_data_reg, host2uint32_t_le(val)); 308 if (bus->conf_addr_reg) { 309 pio_write_32(bus->conf_addr_reg, 310 host2uint32_t_le(CONF_ADDR_ENABLE | conf_addr)); 311 pio_write_32(bus->conf_data_reg, host2uint32_t_le(val)); 312 } else { 313 pio_write_32(&bus->conf_space[conf_addr / sizeof(ioport32_t)], 314 host2uint32_t_le(val)); 315 } 297 316 298 317 fibril_mutex_unlock(&bus->conf_mutex); … … 620 639 ddf_msg(LVL_DEBUG, "Adding new function %s.", 621 640 ddf_fun_get_name(fun->fnode)); 622 641 623 642 pci_fun_create_match_ids(fun); 624 643 … … 688 707 689 708 690 assert(hw_resources.count > 1); 691 assert(hw_resources.resources[0].type == IO_RANGE); 692 assert(hw_resources.resources[0].res.io_range.size >= 4); 693 694 assert(hw_resources.resources[1].type == IO_RANGE); 695 assert(hw_resources.resources[1].res.io_range.size >= 4); 696 697 ddf_msg(LVL_DEBUG, "conf_addr = %" PRIx64 ".", 698 hw_resources.resources[0].res.io_range.address); 699 ddf_msg(LVL_DEBUG, "data_addr = %" PRIx64 ".", 700 hw_resources.resources[1].res.io_range.address); 701 702 if (pio_enable_resource(&bus->pio_win, &hw_resources.resources[0], 703 (void **) &bus->conf_addr_reg)) { 704 ddf_msg(LVL_ERROR, "Failed to enable configuration ports."); 705 rc = EADDRNOTAVAIL; 706 goto fail; 707 } 708 if (pio_enable_resource(&bus->pio_win, &hw_resources.resources[1], 709 (void **) &bus->conf_data_reg)) { 710 ddf_msg(LVL_ERROR, "Failed to enable configuration ports."); 711 rc = EADDRNOTAVAIL; 712 goto fail; 709 assert(hw_resources.count >= 1); 710 711 if (hw_resources.count == 1) { 712 assert(hw_resources.resources[0].type == MEM_RANGE); 713 714 ddf_msg(LVL_DEBUG, "conf_addr_space = %" PRIx64 ".", 715 hw_resources.resources[0].res.mem_range.address); 716 717 if (pio_enable_resource(&bus->pio_win, 718 &hw_resources.resources[0], 719 (void **) &bus->conf_space)) { 720 ddf_msg(LVL_ERROR, 721 "Failed to map configuration space."); 722 rc = EADDRNOTAVAIL; 723 goto fail; 724 } 725 726 } else { 727 assert(hw_resources.resources[0].type == IO_RANGE); 728 assert(hw_resources.resources[0].res.io_range.size >= 4); 729 730 assert(hw_resources.resources[1].type == IO_RANGE); 731 assert(hw_resources.resources[1].res.io_range.size >= 4); 732 733 ddf_msg(LVL_DEBUG, "conf_addr = %" PRIx64 ".", 734 hw_resources.resources[0].res.io_range.address); 735 ddf_msg(LVL_DEBUG, "data_addr = %" PRIx64 ".", 736 hw_resources.resources[1].res.io_range.address); 737 738 if (pio_enable_resource(&bus->pio_win, 739 &hw_resources.resources[0], 740 (void **) &bus->conf_addr_reg)) { 741 ddf_msg(LVL_ERROR, 742 "Failed to enable configuration ports."); 743 rc = EADDRNOTAVAIL; 744 goto fail; 745 } 746 if (pio_enable_resource(&bus->pio_win, 747 &hw_resources.resources[1], 748 (void **) &bus->conf_data_reg)) { 749 ddf_msg(LVL_ERROR, 750 "Failed to enable configuration ports."); 751 rc = EADDRNOTAVAIL; 752 goto fail; 753 } 713 754 } 714 755 -
uspace/drv/bus/pci/pciintel/pci.h
r9191607 r92d5279 47 47 ioport32_t *conf_addr_reg; 48 48 ioport32_t *conf_data_reg; 49 ioport32_t *conf_space; 49 50 pio_window_t pio_win; 50 51 fibril_mutex_t conf_mutex;
Note:
See TracChangeset
for help on using the changeset viewer.