Revision a94fd955 hw/apb_pci.c

b/hw/apb_pci.c
22 22
 * THE SOFTWARE.
23 23
 */
24 24

  
25
/* XXX This file and most of its contests are somewhat misnamed.  The
25
/* XXX This file and most of its contents are somewhat misnamed.  The
26 26
   Ultrasparc PCI host is called the PCI Bus Module (PBM).  The APB is
27 27
   the secondary PCI bridge.  */
28 28

  
29 29
#include "hw.h"
30 30
#include "pci.h"
31

  
32
/* debug APB */
33
//#define DEBUG_APB
34

  
35
#ifdef DEBUG_APB
36
#define APB_DPRINTF(fmt, args...) \
37
do { printf("APB: " fmt , ##args); } while (0)
38
#else
39
#define APB_DPRINTF(fmt, args...)
40
#endif
41

  
31 42
typedef target_phys_addr_t pci_addr_t;
32 43
#include "pci_host.h"
33 44

  
......
37 48
                                         uint32_t val)
38 49
{
39 50
    APBState *s = opaque;
40
    int i;
41 51

  
42
    for (i = 11; i < 32; i++) {
43
        if ((val & (1 << i)) != 0)
44
            break;
45
    }
46
    s->config_reg = (1 << 16) | (val & 0x7FC) | (i << 11);
52
#ifdef TARGET_WORDS_BIGENDIAN
53
    val = bswap32(val);
54
#endif
55
    APB_DPRINTF("config_writel addr " TARGET_FMT_plx " val %x\n", addr,
56
                val);
57
    s->config_reg = val;
47 58
}
48 59

  
49 60
static uint32_t pci_apb_config_readl (void *opaque,
......
51 62
{
52 63
    APBState *s = opaque;
53 64
    uint32_t val;
54
    int devfn;
55 65

  
56
    devfn = (s->config_reg >> 8) & 0xFF;
57
    val = (1 << (devfn >> 3)) | ((devfn & 0x07) << 8) | (s->config_reg & 0xFC);
66
    val = s->config_reg;
67
#ifdef TARGET_WORDS_BIGENDIAN
68
    val = bswap32(val);
69
#endif
70
    APB_DPRINTF("config_readl addr " TARGET_FMT_plx " val %x\n", addr,
71
                val);
58 72
    return val;
59 73
}
60 74

  
......
259 273
                                "Advanced PCI Bus secondary bridge 1");
260 274
    pci_bridge_init(s->bus, 9, 0x108e5000, pci_apb_map_irq,
261 275
                    "Advanced PCI Bus secondary bridge 2");
262
    return secondary;
276
    return s->bus;
263 277
}

Also available in: Unified diff