Changeset 690d2e7 in mainline for uspace/drv/bus/pci/pciintel/pci.c


Ignore:
Timestamp:
2012-01-24T04:28:54Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cb3dbb63
Parents:
230385c
Message:

pci: intel pci is always little endian.

File:
1 edited

Legend:

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

    r230385c r690d2e7  
    3838
    3939#include <assert.h>
     40#include <byteorder.h>
    4041#include <stdio.h>
    4142#include <errno.h>
     
    231232        void *addr = bus->conf_data_port + (reg & 3);
    232233       
    233         pio_write_32(bus->conf_addr_port, conf_addr);
     234        pio_write_32(bus->conf_addr_port, host2uint32_t_le(conf_addr));
    234235       
    235236        switch (len) {
    236237        case 1:
     238                /* No endianness change for 1 byte */
    237239                buf[0] = pio_read_8(addr);
    238240                break;
    239241        case 2:
    240                 ((uint16_t *) buf)[0] = pio_read_16(addr);
     242                ((uint16_t *) buf)[0] = uint16_t_le2host(pio_read_16(addr));
    241243                break;
    242244        case 4:
    243                 ((uint32_t *) buf)[0] = pio_read_32(addr);
     245                ((uint32_t *) buf)[0] = uint32_t_le2host(pio_read_32(addr));
    244246                break;
    245247        }
     
    254256        fibril_mutex_lock(&bus->conf_mutex);
    255257       
    256         uint32_t conf_addr;
    257         conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg);
     258        const uint32_t conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg);
    258259        void *addr = bus->conf_data_port + (reg & 3);
    259260       
    260         pio_write_32(bus->conf_addr_port, conf_addr);
     261        pio_write_32(bus->conf_addr_port, host2uint32_t_le(conf_addr));
    261262       
    262263        switch (len) {
    263264        case 1:
     265                /* No endianness change for 1 byte */
    264266                pio_write_8(addr, buf[0]);
    265267                break;
    266268        case 2:
    267                 pio_write_16(addr, ((uint16_t *) buf)[0]);
     269                pio_write_16(addr, host2uint16_t_le(((uint16_t *) buf)[0]));
    268270                break;
    269271        case 4:
    270                 pio_write_32(addr, ((uint32_t *) buf)[0]);
     272                pio_write_32(addr, host2uint32_t_le(((uint32_t *) buf)[0]));
    271273                break;
    272274        }
Note: See TracChangeset for help on using the changeset viewer.